Conflicts: build/kitchen-sink.html build/src/ace-noconflict.js build/src/ace.js
This commit is contained in:
commit
a05a451fa5
393 changed files with 50633 additions and 4936 deletions
|
|
@ -35,6 +35,14 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* class Ace
|
||||
*
|
||||
* The main class required to set up an Ace instance in the browser.
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
|
|
@ -56,6 +64,13 @@ require("./keyboard/state_handler");
|
|||
require("./placeholder");
|
||||
require("./config").init();
|
||||
|
||||
/**
|
||||
* Ace.edit(el) -> Editor
|
||||
* - el (String | DOMElement): Either the id of an element, or the element itself
|
||||
*
|
||||
* This method embeds the Ace editor into the DOM, at the element provided by `el`.
|
||||
*
|
||||
**/
|
||||
exports.edit = function(el) {
|
||||
if (typeof(el) == "string") {
|
||||
el = document.getElementById(el);
|
||||
|
|
@ -83,4 +98,4 @@ exports.edit = function(el) {
|
|||
return editor;
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,9 +42,22 @@ var oop = require("./lib/oop");
|
|||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
|
||||
/**
|
||||
* An Anchor is a floating pointer in the document. Whenever text is inserted or
|
||||
* deleted before the cursor, the position of the cursor is updated
|
||||
*/
|
||||
* class Anchor
|
||||
*
|
||||
* Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated
|
||||
*
|
||||
**/
|
||||
|
||||
/**
|
||||
* new Anchor(doc, row, column)
|
||||
* - doc (Document): The document to associate with the anchor
|
||||
* - row (Number): The starting row position
|
||||
* - column (Number): The starting column position
|
||||
*
|
||||
* Creates a new `Anchor` and associates it with a document.
|
||||
*
|
||||
**/
|
||||
|
||||
var Anchor = exports.Anchor = function(doc, row, column) {
|
||||
this.document = doc;
|
||||
|
||||
|
|
@ -61,14 +74,36 @@ var Anchor = exports.Anchor = function(doc, row, column) {
|
|||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
/**
|
||||
* Anchor.getPosition() -> Object
|
||||
*
|
||||
* Returns an object identifying the `row` and `column` position of the current anchor.
|
||||
*
|
||||
**/
|
||||
|
||||
this.getPosition = function() {
|
||||
return this.$clipPositionToDocument(this.row, this.column);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Anchor.getDocument() -> Document
|
||||
*
|
||||
* Returns the current document.
|
||||
*
|
||||
**/
|
||||
|
||||
this.getDocument = function() {
|
||||
return this.document;
|
||||
};
|
||||
|
||||
/**
|
||||
* Anchor@onChange(e)
|
||||
* - e (Event): Contains data about the event
|
||||
*
|
||||
* Fires whenever the anchor position changes. Events that can trigger this function include `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
|
||||
*
|
||||
**/
|
||||
|
||||
this.onChange = function(e) {
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
|
|
@ -134,6 +169,16 @@ var Anchor = exports.Anchor = function(doc, row, column) {
|
|||
this.setPosition(row, column, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Anchor.setPosition(row, column, noClip)
|
||||
* - row (Number): The row index to move the anchor to
|
||||
* - column (Number): The column index to move the anchor to
|
||||
* - noClip (Boolean): Identifies if you want the position to be clipped
|
||||
*
|
||||
* Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
|
||||
*
|
||||
**/
|
||||
|
||||
this.setPosition = function(row, column, noClip) {
|
||||
var pos;
|
||||
if (noClip) {
|
||||
|
|
@ -162,10 +207,26 @@ var Anchor = exports.Anchor = function(doc, row, column) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Anchor.detach()
|
||||
*
|
||||
* When called, the `'change'` event listener is removed.
|
||||
*
|
||||
**/
|
||||
|
||||
this.detach = function() {
|
||||
this.document.removeEventListener("change", this.$onChange);
|
||||
};
|
||||
|
||||
/** internal, hide
|
||||
* Anchor.clipPositionToDocument(row, column)
|
||||
* - row (Number): The row index to clip the anchor to
|
||||
* - column (Number): The column index to clip the anchor to
|
||||
*
|
||||
* Clips the anchor position to the specified row and column.
|
||||
*
|
||||
**/
|
||||
|
||||
this.$clipPositionToDocument = function(row, column) {
|
||||
var pos = {};
|
||||
|
||||
|
|
|
|||
|
|
@ -181,4 +181,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,23 @@ define(function(require, exports, module) {
|
|||
var oop = require("./lib/oop");
|
||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
|
||||
/**
|
||||
* class BackgroundTokenizer
|
||||
*
|
||||
* Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use. If a certain row is changed, everything below that row is re-tokenized.
|
||||
*
|
||||
**/
|
||||
|
||||
/**
|
||||
* new BackgroundTokenizer(tokenizer, editor)
|
||||
* - tokenizer (Tokenizer): The tokenizer to use
|
||||
* - editor (Editor): The editor to associate with
|
||||
*
|
||||
* Creates a new `BackgroundTokenizer` object.
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
var BackgroundTokenizer = function(tokenizer, editor) {
|
||||
this.running = false;
|
||||
this.lines = [];
|
||||
|
|
@ -82,6 +99,14 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
/**
|
||||
* BackgroundTokenizer.setTokenizer(tokenizer)
|
||||
* - tokenizer (Tokenizer): The new tokenizer to use
|
||||
*
|
||||
* Sets a new tokenizer for this object.
|
||||
*
|
||||
**/
|
||||
|
||||
this.setTokenizer = function(tokenizer) {
|
||||
this.tokenizer = tokenizer;
|
||||
this.lines = [];
|
||||
|
|
@ -89,6 +114,14 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
this.start(0);
|
||||
};
|
||||
|
||||
/**
|
||||
* BackgroundTokenizer.setDocument(doc)
|
||||
* - doc (Document): The new document to associate with
|
||||
*
|
||||
* Sets a new document to associate with this object.
|
||||
*
|
||||
**/
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
this.doc = doc;
|
||||
this.lines = [];
|
||||
|
|
@ -96,6 +129,15 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
this.stop();
|
||||
};
|
||||
|
||||
/**
|
||||
* BackgroundTokenizer.fireUpdateEvent(firstRow, lastRow)
|
||||
* - firstRow (Number): The starting row region
|
||||
* - lastRow (Number): The final row region
|
||||
*
|
||||
* Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated.
|
||||
*
|
||||
**/
|
||||
|
||||
this.fireUpdateEvent = function(firstRow, lastRow) {
|
||||
var data = {
|
||||
first: firstRow,
|
||||
|
|
@ -104,6 +146,14 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
this._emit("update", {data: data});
|
||||
};
|
||||
|
||||
/**
|
||||
* BackgroundTokenizer.start(startRow)
|
||||
* - startRow (Number): The row to start at
|
||||
*
|
||||
* Starts tokenizing at the row indicated.
|
||||
*
|
||||
**/
|
||||
|
||||
this.start = function(startRow) {
|
||||
this.currentLine = Math.min(startRow || 0, this.currentLine,
|
||||
this.doc.getLength());
|
||||
|
|
@ -116,20 +166,54 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
this.running = setTimeout(this.$worker, 700);
|
||||
};
|
||||
|
||||
/**
|
||||
* BackgroundTokenizer.stop()
|
||||
*
|
||||
* Stops tokenizing.
|
||||
*
|
||||
**/
|
||||
|
||||
this.stop = function() {
|
||||
if (this.running)
|
||||
clearTimeout(this.running);
|
||||
this.running = false;
|
||||
};
|
||||
|
||||
/** related to: BackgroundTokenizer.$tokenizeRows
|
||||
* BackgroundTokenizer.getTokens(firstRow, lastRow) -> [Object]
|
||||
* - firstRow (Number): The row to start at
|
||||
* - lastRow (Number): The row to finish at
|
||||
*
|
||||
* Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.
|
||||
*
|
||||
**/
|
||||
|
||||
this.getTokens = function(firstRow, lastRow) {
|
||||
return this.$tokenizeRows(firstRow, lastRow);
|
||||
};
|
||||
|
||||
/**
|
||||
* BackgroundTokenizer.getState(row) -> String
|
||||
* - row (Number): The row to start at
|
||||
*
|
||||
* [Returns the state of tokenization for a row.]{: #BackgroundTokenizer.getState}
|
||||
*
|
||||
**/
|
||||
|
||||
this.getState = function(row) {
|
||||
return this.$tokenizeRows(row, row)[0].state;
|
||||
};
|
||||
|
||||
/**
|
||||
* BackgroundTokenizer.$tokenizeRows(firstRow, lastRow) -> [Object]
|
||||
* - startRow (Number): The row to start at
|
||||
* - lastRow (Number): The row to finish at
|
||||
* + ([Object]): A list of the tokenized rows. Each item in the list is an object with two properties, `state` and `start`.
|
||||
*
|
||||
* Tokenizes all the rows within the specified region.
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.$tokenizeRows = function(firstRow, lastRow) {
|
||||
if (!this.doc || isNaN(firstRow) || isNaN(lastRow))
|
||||
return [{'state':'start','tokens':[]}];
|
||||
|
|
|
|||
|
|
@ -5,6 +5,24 @@ var oop = require("../lib/oop");
|
|||
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
||||
var EventEmitter = require("../lib/event_emitter").EventEmitter;
|
||||
|
||||
/**
|
||||
* class CommandManager
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
/**
|
||||
* new CommandManager(platform, commands)
|
||||
* - platform (String): Identifier for the platform; must be either `'mac'` or `'win'`
|
||||
* - commands (Array): A list of commands
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
var CommandManager = function(platform, commands) {
|
||||
this.platform = platform;
|
||||
this.commands = {};
|
||||
|
|
@ -13,7 +31,7 @@ var CommandManager = function(platform, commands) {
|
|||
this.addCommands(commands);
|
||||
|
||||
this.setDefaultHandler("exec", function(e) {
|
||||
e.command.exec(e.editor, e.args || {});
|
||||
return e.command.exec(e.editor, e.args || {});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -33,8 +51,18 @@ oop.inherits(CommandManager, HashHandler);
|
|||
if (editor && editor.$readOnly && !command.readOnly)
|
||||
return false;
|
||||
|
||||
this._emit("exec", {editor: editor, command: command, args: args});
|
||||
return true;
|
||||
try {
|
||||
var retvalue = this._emit("exec", {
|
||||
editor: editor,
|
||||
command: command,
|
||||
args: args
|
||||
});
|
||||
} catch (e) {
|
||||
window.console && window.console.log(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
return retvalue === false ? false : true;
|
||||
};
|
||||
|
||||
this.toggleRecording = function() {
|
||||
|
|
|
|||
|
|
@ -190,4 +190,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ exports.commands = [{
|
|||
multiSelectAction: "forEach"
|
||||
}, {
|
||||
name: "togglecomment",
|
||||
bindKey: bindKey("Ctrl-7", "Command-7"),
|
||||
bindKey: bindKey("Ctrl-/", "Command-/"),
|
||||
exec: function(editor) { editor.toggleCommentLines(); },
|
||||
multiSelectAction: "forEach"
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -84,17 +84,18 @@ exports.defaultCommands = [{
|
|||
exec: function(editor) { editor.multiSelect.splitIntoLines(); },
|
||||
bindKey: {win: "Ctrl-Shift-L", mac: "Ctrl-Shift-L"},
|
||||
readonly: true
|
||||
}];
|
||||
|
||||
// commands active in multiselect mode
|
||||
exports.multiEditCommands = [{
|
||||
}, {
|
||||
name: "singleSelection",
|
||||
bindKey: "esc",
|
||||
exec: function(editor) { editor.exitMultiSelectMode(); },
|
||||
readonly: true
|
||||
readonly: true,
|
||||
isAvailable: function(editor) {return editor.inMultiSelectMode}
|
||||
}];
|
||||
|
||||
// commands active in multiselect mode
|
||||
exports.multiEditCommands = {"singleSelection": "esc"};
|
||||
|
||||
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
||||
exports.keyboardHandler = new HashHandler(exports.multiEditCommands);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -125,4 +125,4 @@ function deHyphenate(str) {
|
|||
return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);
|
||||
|
||||
.ace_editor {
|
||||
position: absolute;
|
||||
|
|
@ -37,6 +36,12 @@
|
|||
z-index: 1000;
|
||||
}
|
||||
|
||||
.ace_gutter_active_line {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ace_gutter.horscroll {
|
||||
box-shadow: 0px 0px 20px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
|
@ -95,8 +100,8 @@
|
|||
.ace_editor textarea {
|
||||
position: fixed;
|
||||
z-index: 0;
|
||||
width: 10px;
|
||||
height: 30px;
|
||||
width: 0.5em;
|
||||
height: 1em;
|
||||
opacity: 0;
|
||||
background: transparent;
|
||||
appearance: none;
|
||||
|
|
@ -131,6 +136,7 @@
|
|||
|
||||
.ace_text-layer {
|
||||
color: black;
|
||||
font: inherit !important;
|
||||
}
|
||||
|
||||
.ace_cjk {
|
||||
|
|
@ -179,10 +185,6 @@
|
|||
z-index: 2;
|
||||
}
|
||||
|
||||
.ace_gutter .ace_gutter_active_line{
|
||||
background-color : #dcdcdc;
|
||||
}
|
||||
|
||||
.ace_marker-layer .ace_selected_word {
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
|
|
@ -289,3 +291,25 @@
|
|||
background-color: #FFB4B4;
|
||||
border-color: #DE5555;
|
||||
}
|
||||
|
||||
.ace_fade-fold-widgets .ace_fold-widget {
|
||||
-moz-transition: 0.5s opacity;
|
||||
-webkit-transition: 0.5s opacity;
|
||||
-o-transition: 0.5s opacity;
|
||||
-ms-transition: 0.5s opacity;
|
||||
transition: 0.5s opacity;
|
||||
opacity: 0;
|
||||
}
|
||||
.ace_fade-fold-widgets:hover .ace_fold-widget {
|
||||
-moz-transition-duration: 0.05s;
|
||||
-webkit-transition-duration: 0.05s;
|
||||
-o-transition-duration: 0.05s;
|
||||
-ms-transition-duration: 0.05s;
|
||||
transition-duration: 0.05s;
|
||||
-moz-transition-delay: 0.2s;
|
||||
-webkit-transition-delay: 0.2s;
|
||||
-o-transition-delay: 0.2s;
|
||||
-ms-transition-delay: 0.2s;
|
||||
transition-delay: 0.2s;
|
||||
opacity:1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,21 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
|||
var Range = require("./range").Range;
|
||||
var Anchor = require("./anchor").Anchor;
|
||||
|
||||
/**
|
||||
* class Document
|
||||
*
|
||||
* Contains the text of the document. Documents are controlled by a single [[EditSession `EditSession`]]. At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
/**
|
||||
* new Document([text])
|
||||
* - text (String | Array): The starting text
|
||||
*
|
||||
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
|
||||
*
|
||||
**/
|
||||
var Document = function(text) {
|
||||
this.$lines = [];
|
||||
|
||||
|
|
@ -62,20 +77,48 @@ var Document = function(text) {
|
|||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
/**
|
||||
* Document.setValue(text) -> Void
|
||||
* - text (String): The text to use
|
||||
*
|
||||
* Replaces all the lines in the current `Document` with the value of `text`.
|
||||
**/
|
||||
this.setValue = function(text) {
|
||||
var len = this.getLength();
|
||||
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
|
||||
this.insert({row: 0, column:0}, text);
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.getValue() -> String
|
||||
*
|
||||
* Returns all the lines in the document as a single string, split by the new line character.
|
||||
**/
|
||||
this.getValue = function() {
|
||||
return this.getAllLines().join(this.getNewLineCharacter());
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.createAnchor(row, column) -> Anchor
|
||||
* - row (Number): The row number to use
|
||||
* - column (Number): The column number to use
|
||||
*
|
||||
* Creates a new `Anchor` to define a floating point in the document.
|
||||
**/
|
||||
this.createAnchor = function(row, column) {
|
||||
return new Anchor(this, row, column);
|
||||
};
|
||||
|
||||
/** internal, hide
|
||||
* Document.$split(text) -> [String]
|
||||
* - text (String): The text to work with
|
||||
* + ([String]): A String array, with each index containing a piece of the original `text` string.
|
||||
*
|
||||
* Splits a string of text on any newline (`\n`) or carriage-return ('\r') characters.
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
// check for IE split bug
|
||||
if ("aaa".split(/a/).length == 0)
|
||||
this.$split = function(text) {
|
||||
|
|
@ -87,6 +130,11 @@ var Document = function(text) {
|
|||
};
|
||||
|
||||
|
||||
/** internal, hide
|
||||
* Document.$detectNewLine(text) -> Void
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.$detectNewLine = function(text) {
|
||||
var match = text.match(/^.*?(\r\n|\r|\n)/m);
|
||||
if (match) {
|
||||
|
|
@ -96,6 +144,17 @@ var Document = function(text) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.getNewLineCharacter() -> String
|
||||
* + (String): If `newLineMode == windows`, `\r\n` is returned.<br/>
|
||||
* If `newLineMode == unix`, `\n` is returned.<br/>
|
||||
* If `newLineMode == auto`, the value of `autoNewLine` is returned.
|
||||
*
|
||||
* Returns the newline character that's being used, depending on the value of `newLineMode`.
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.getNewLineCharacter = function() {
|
||||
switch (this.$newLineMode) {
|
||||
case "windows":
|
||||
|
|
@ -111,6 +170,12 @@ var Document = function(text) {
|
|||
|
||||
this.$autoNewLine = "\n";
|
||||
this.$newLineMode = "auto";
|
||||
/**
|
||||
* Document.setNewLineMode(newLineMode) -> Void
|
||||
* - newLineMode(String): [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param}
|
||||
*
|
||||
* [Sets the new line mode.]{: #Document.setNewLineMode.desc}
|
||||
**/
|
||||
this.setNewLineMode = function(newLineMode) {
|
||||
if (this.$newLineMode === newLineMode)
|
||||
return;
|
||||
|
|
@ -118,51 +183,92 @@ var Document = function(text) {
|
|||
this.$newLineMode = newLineMode;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.getNewLineMode() -> String
|
||||
*
|
||||
* [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode}
|
||||
*
|
||||
**/
|
||||
this.getNewLineMode = function() {
|
||||
return this.$newLineMode;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.isNewLine(text) -> Boolean
|
||||
* - text (String): The text to check
|
||||
*
|
||||
* Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`).
|
||||
*
|
||||
**/
|
||||
this.isNewLine = function(text) {
|
||||
return (text == "\r\n" || text == "\r" || text == "\n");
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a verbatim copy of the given line as it is in the document
|
||||
*/
|
||||
* Document.getLine(row) -> String
|
||||
* - row (Number): The row index to retrieve
|
||||
*
|
||||
* Returns a verbatim copy of the given line as it is in the document
|
||||
*
|
||||
**/
|
||||
this.getLine = function(row) {
|
||||
return this.$lines[row] || "";
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.getLines(firstRow, lastRow) -> [String]
|
||||
* - firstRow (Number): The first row index to retrieve
|
||||
* - lastRow (Number): The final row index to retrieve
|
||||
*
|
||||
* Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
|
||||
*
|
||||
**/
|
||||
this.getLines = function(firstRow, lastRow) {
|
||||
return this.$lines.slice(firstRow, lastRow + 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns all lines in the document as string array. Warning: The caller
|
||||
* should not modify this array!
|
||||
*/
|
||||
* Document.getAllLines() -> [String]
|
||||
*
|
||||
* Returns all lines in the document as string array. Warning: The caller should not modify this array!
|
||||
**/
|
||||
this.getAllLines = function() {
|
||||
return this.getLines(0, this.getLength());
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.getLength() -> Number
|
||||
*
|
||||
* Returns the number of rows in the document.
|
||||
**/
|
||||
this.getLength = function() {
|
||||
return this.$lines.length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.getTextRange(range) -> String
|
||||
* - range (Range): The range to work with
|
||||
*
|
||||
* [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc}
|
||||
**/
|
||||
this.getTextRange = function(range) {
|
||||
if (range.start.row == range.end.row) {
|
||||
return this.$lines[range.start.row].substring(range.start.column,
|
||||
range.end.column);
|
||||
}
|
||||
else {
|
||||
var lines = [];
|
||||
lines.push(this.$lines[range.start.row].substring(range.start.column));
|
||||
lines.push.apply(lines, this.getLines(range.start.row+1, range.end.row-1));
|
||||
lines.push(this.$lines[range.end.row].substring(0, range.end.column));
|
||||
var lines = this.getLines(range.start.row+1, range.end.row-1);
|
||||
lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
|
||||
lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
|
||||
return lines.join(this.getNewLineCharacter());
|
||||
}
|
||||
};
|
||||
|
||||
/** internal, hide
|
||||
* Document.$clipPosition(position) -> Number
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.$clipPosition = function(position) {
|
||||
var length = this.getLength();
|
||||
if (position.row >= length) {
|
||||
|
|
@ -172,6 +278,15 @@ var Document = function(text) {
|
|||
return position;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.insert(position, text) -> Number
|
||||
* - position (Number): The position to start inserting at
|
||||
* - text (String): A chunk of text to insert
|
||||
* + (Number): The position of the last line of `text`. If the length of `text` is 0, this function simply returns `position`.
|
||||
* Inserts a block of `text` and the indicated `position`.
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.insert = function(position, text) {
|
||||
if (!text || text.length === 0)
|
||||
return position;
|
||||
|
|
@ -195,6 +310,19 @@ var Document = function(text) {
|
|||
return position;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.insertLines(row, lines) -> Object
|
||||
* - row (Number): The index of the row to insert at
|
||||
* - lines (Array): An array of strings
|
||||
* + (Object): Returns an object containing the final row and column, like this:<br/>
|
||||
* ```{row: endRow, column: 0}```<br/>
|
||||
* If `lines` is empty, this function returns an object containing the current row, and column, like this:<br/>
|
||||
* ```{row: row, column: 0}```
|
||||
*
|
||||
* Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.insertLines = function(row, lines) {
|
||||
if (lines.length == 0)
|
||||
return {row: row, column: 0};
|
||||
|
|
@ -213,6 +341,17 @@ var Document = function(text) {
|
|||
return range.end;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.insertNewLine(position) -> Object
|
||||
* - position (String): The position to insert at
|
||||
* + (Object): Returns an object containing the final row and column, like this:<br/>
|
||||
* ```{row: endRow, column: 0}```
|
||||
*
|
||||
* Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.insertNewLine = function(position) {
|
||||
position = this.$clipPosition(position);
|
||||
var line = this.$lines[position.row] || "";
|
||||
|
|
@ -235,6 +374,19 @@ var Document = function(text) {
|
|||
return end;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.insertInLine(position, text) -> Object | Number
|
||||
* - position (Number): The position to insert at
|
||||
* - text (String): A chunk of text
|
||||
* + (Object): Returns an object containing the final row and column, like this:<br/>
|
||||
* ```{row: endRow, column: 0}```
|
||||
* + (Number): If `text` is empty, this function returns the value of `position`
|
||||
*
|
||||
* Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.insertInLine = function(position, text) {
|
||||
if (text.length == 0)
|
||||
return position;
|
||||
|
|
@ -259,6 +411,15 @@ var Document = function(text) {
|
|||
return end;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.remove(range) -> Object
|
||||
* - range (Range): A specified Range to remove
|
||||
* + (Object): Returns the new `start` property of the range, which contains `startRow` and `startColumn`. If `range` is empty, this function returns the unmodified value of `range.start`.
|
||||
*
|
||||
* Removes the `range` from the document.
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.remove = function(range) {
|
||||
// clip to document
|
||||
range.start = this.$clipPosition(range.start);
|
||||
|
|
@ -291,6 +452,17 @@ var Document = function(text) {
|
|||
return range.start;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.removeInLine(row, startColumn, endColumn) -> Object
|
||||
* - row (Number): The row to remove from
|
||||
* - startColumn (Number): The column to start removing at
|
||||
* - endColumn (Number): The column to stop removing at
|
||||
* + (Object): Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
|
||||
*
|
||||
* Removes the specified columns from the `row`. This method also triggers the `'change'` event.
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.removeInLine = function(row, startColumn, endColumn) {
|
||||
if (startColumn == endColumn)
|
||||
return;
|
||||
|
|
@ -311,12 +483,15 @@ var Document = function(text) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Removes a range of full lines
|
||||
*
|
||||
* @param firstRow {Integer} The first row to be removed
|
||||
* @param lastRow {Integer} The last row to be removed
|
||||
* @return {String[]} The removed lines
|
||||
*/
|
||||
* Document.removeLines(firstRow, lastRow) -> [String]
|
||||
* - firstRow (Number): The first row to be removed
|
||||
* - lastRow (Number): The last row to be removed
|
||||
* + ([String]): Returns all the removed lines.
|
||||
*
|
||||
* Removes a range of full lines. This method also triggers the `'change'` event.
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.removeLines = function(firstRow, lastRow) {
|
||||
var range = new Range(firstRow, 0, lastRow + 1, 0);
|
||||
var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
|
||||
|
|
@ -331,6 +506,13 @@ var Document = function(text) {
|
|||
return removed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.removeNewLine(row) -> Void
|
||||
* - row (Number): The row to check
|
||||
*
|
||||
* Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
|
||||
*
|
||||
**/
|
||||
this.removeNewLine = function(row) {
|
||||
var firstLine = this.getLine(row);
|
||||
var secondLine = this.getLine(row+1);
|
||||
|
|
@ -348,6 +530,18 @@ var Document = function(text) {
|
|||
this._emit("change", { data: delta });
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.replace(range, text) -> Object
|
||||
* - range (Range): A specified Range to replace
|
||||
* - text (String): The new text to use as a replacement
|
||||
* + (Object): Returns an object containing the final row and column, like this:
|
||||
* {row: endRow, column: 0}
|
||||
* If the text and range are empty, this function returns an object containing the current `range.start` value.
|
||||
* If the text is the exact same as what currently exists, this function returns an object containing the current `range.end` value.
|
||||
*
|
||||
* Replaces a range in the document with the new `text`.
|
||||
*
|
||||
**/
|
||||
this.replace = function(range, text) {
|
||||
if (text.length == 0 && range.isEmpty())
|
||||
return range.start;
|
||||
|
|
@ -368,6 +562,11 @@ var Document = function(text) {
|
|||
return end;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.applyDeltas(deltas) -> Void
|
||||
*
|
||||
* Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
|
||||
**/
|
||||
this.applyDeltas = function(deltas) {
|
||||
for (var i=0; i<deltas.length; i++) {
|
||||
var delta = deltas[i];
|
||||
|
|
@ -384,6 +583,11 @@ var Document = function(text) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Document.revertDeltas(deltas) -> Void
|
||||
*
|
||||
* Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
|
||||
**/
|
||||
this.revertDeltas = function(deltas) {
|
||||
for (var i=deltas.length-1; i>=0; i--) {
|
||||
var delta = deltas[i];
|
||||
|
|
|
|||
|
|
@ -311,4 +311,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -41,8 +41,34 @@ define(function(require, exports, module) {
|
|||
|
||||
var TokenIterator = require("../token_iterator").TokenIterator;
|
||||
|
||||
/**
|
||||
* class BracketMatch
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
/**
|
||||
* new BracketMatch(position)
|
||||
* - platform (String): Identifier for the platform; must be either `'mac'` or `'win'`
|
||||
* - commands (Array): A list of commands
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
*
|
||||
**/
|
||||
function BracketMatch() {
|
||||
|
||||
/**
|
||||
* new findMatchingBracket(position)
|
||||
* - position (Number): Identifier for the platform; must be either `'mac'` or `'win'`
|
||||
* - commands (Array): A list of commands
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
*
|
||||
**/
|
||||
this.findMatchingBracket = function(position) {
|
||||
if (position.column == 0) return null;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
/*
|
||||
* Simple fold-data struct.
|
||||
**/
|
||||
var Fold = exports.Fold = function(range, placeholder) {
|
||||
|
|
@ -113,4 +113,4 @@ var Fold = exports.Fold = function(range, placeholder) {
|
|||
|
||||
}).call(Fold.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ define(function(require, exports, module) {
|
|||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
/**
|
||||
/*
|
||||
* If an array is passed in, the folds are expected to be sorted already.
|
||||
*/
|
||||
function FoldLine(foldData, folds) {
|
||||
|
|
@ -64,7 +64,7 @@ function FoldLine(foldData, folds) {
|
|||
}
|
||||
|
||||
(function() {
|
||||
/**
|
||||
/*
|
||||
* Note: This doesn't update wrapData!
|
||||
*/
|
||||
this.shiftRow = function(shift) {
|
||||
|
|
@ -177,7 +177,9 @@ function FoldLine(foldData, folds) {
|
|||
&& fold.start.column != column
|
||||
&& fold.start.row != row)
|
||||
{
|
||||
throw "Moving characters inside of a fold should never be reached";
|
||||
//throwing here breaks whole editor
|
||||
//@todo properly handle this
|
||||
window.console && window.console.log(row, column, fold);
|
||||
} else if (fold.start.row == row) {
|
||||
folds = this.folds;
|
||||
var i = folds.indexOf(fold);
|
||||
|
|
@ -271,4 +273,4 @@ function FoldLine(foldData, folds) {
|
|||
}).call(FoldLine.prototype);
|
||||
|
||||
exports.FoldLine = FoldLine;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ var Fold = require("./fold").Fold;
|
|||
var TokenIterator = require("../token_iterator").TokenIterator;
|
||||
|
||||
function Folding() {
|
||||
/**
|
||||
/*
|
||||
* Looks up a fold at a given row/column. Possible values for side:
|
||||
* -1: ignore a fold if fold.start = row/column
|
||||
* +1: ignore a fold if fold.end = row/column
|
||||
|
|
@ -69,7 +69,7 @@ function Folding() {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns all folds in the given range. Note, that this will return folds
|
||||
*
|
||||
*/
|
||||
|
|
@ -115,7 +115,7 @@ function Folding() {
|
|||
return foundFolds;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns all folds in the document
|
||||
*/
|
||||
this.getAllFolds = function() {
|
||||
|
|
@ -138,7 +138,7 @@ function Folding() {
|
|||
return folds;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns the string between folds at the given position.
|
||||
* E.g.
|
||||
* foo<fold>b|ar<fold>wolrd -> "bar"
|
||||
|
|
@ -257,7 +257,7 @@ function Folding() {
|
|||
return foldLine;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Adds a new fold.
|
||||
*
|
||||
* @returns
|
||||
|
|
@ -457,7 +457,7 @@ function Folding() {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Checks if a given documentRow is folded. This is true if there are some
|
||||
* folded parts such that some parts of the line is still visible.
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -982,4 +982,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -192,4 +192,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,4 +212,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ module.exports = {
|
|||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(101);
|
||||
assert.position(editor.getCursorPosition(), 100, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 90);
|
||||
assert.equal(editor.getFirstVisibleRow(), 89);
|
||||
|
||||
editor.navigateTo(100, 0);
|
||||
editor.gotoLine(11);
|
||||
|
|
@ -102,7 +102,7 @@ module.exports = {
|
|||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(191);
|
||||
assert.position(editor.getCursorPosition(), 190, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 180);
|
||||
assert.equal(editor.getFirstVisibleRow(), 179);
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(196);
|
||||
|
|
@ -168,4 +168,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ module.exports = {
|
|||
editor.onTextInput("\n");
|
||||
assert.equal(["", "{"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
|
||||
"test: outdent block" : function() {
|
||||
var session = new EditSession([" a12345", " b12345", " c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
|
@ -559,4 +559,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ var EditSession = require("../edit_session").EditSession;
|
|||
var TextLayer = require("../layer/text").Text;
|
||||
var baseStyles = require("../requirejs/text!./static.css");
|
||||
|
||||
/** Transforms a given input code snippet into HTML using the given mode
|
||||
/* Transforms a given input code snippet into HTML using the given mode
|
||||
*
|
||||
* @param {string} input Code snippet
|
||||
* @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode')
|
||||
|
|
@ -95,4 +95,4 @@ exports.render = function(input, mode, theme, lineStart) {
|
|||
};
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -78,4 +78,4 @@ function hello (a, b, c) {\n\
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ var ace = require("../ace");
|
|||
|
||||
require("ace/theme/textmate");
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns the CSS property of element.
|
||||
* 1) If the CSS property is on the style object of the element, use it, OR
|
||||
* 2) Compute the CSS property
|
||||
|
|
|
|||
|
|
@ -78,6 +78,18 @@ function HashHandler(config, platform) {
|
|||
}
|
||||
};
|
||||
|
||||
this.bindKey = function(key, command) {
|
||||
if(!key)
|
||||
return;
|
||||
|
||||
var ckb = this.commmandKeyBinding;
|
||||
key.split("|").forEach(function(keyPart) {
|
||||
var binding = this.parseKeys(keyPart, command);
|
||||
var hashId = binding.hashId;
|
||||
(ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command;
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.addCommands = function(commands) {
|
||||
commands && Object.keys(commands).forEach(function(name) {
|
||||
var command = commands[name];
|
||||
|
|
@ -100,18 +112,6 @@ function HashHandler(config, platform) {
|
|||
}, this);
|
||||
};
|
||||
|
||||
this.bindKey = function(key, command) {
|
||||
if(!key)
|
||||
return;
|
||||
|
||||
var ckb = this.commmandKeyBinding;
|
||||
key.split("|").forEach(function(keyPart) {
|
||||
var binding = parseKeys(keyPart, command);
|
||||
var hashId = binding.hashId;
|
||||
(ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command;
|
||||
});
|
||||
};
|
||||
|
||||
this.bindKeys = function(keyList) {
|
||||
Object.keys(keyList).forEach(function(key) {
|
||||
this.bindKey(key, keyList[key]);
|
||||
|
|
@ -127,10 +127,10 @@ function HashHandler(config, platform) {
|
|||
this.bindKey(key, command);
|
||||
};
|
||||
|
||||
function parseKeys(keys, val, ret) {
|
||||
this.parseKeys = function(keys, val) {
|
||||
var key;
|
||||
var hashId = 0;
|
||||
var parts = splitSafe(keys.toLowerCase());
|
||||
var parts = keys.toLowerCase().trim().split(/\s*\-\s*/);
|
||||
|
||||
for (var i = 0, l = parts.length; i < l; i++) {
|
||||
if (keyUtil.KEY_MODS[parts[i]])
|
||||
|
|
@ -143,17 +143,12 @@ function HashHandler(config, platform) {
|
|||
key: key,
|
||||
hashId: hashId
|
||||
};
|
||||
}
|
||||
|
||||
function splitSafe(s) {
|
||||
return (s.trim()
|
||||
.split(new RegExp("[\\s ]*\\-[\\s ]*", "g"), 999));
|
||||
}
|
||||
};
|
||||
|
||||
this.findKeyCommand = function findKeyCommand(hashId, keyString) {
|
||||
var ckbr = this.commmandKeyBinding;
|
||||
return ckbr[hashId] && ckbr[hashId][keyString.toLowerCase()];
|
||||
}
|
||||
};
|
||||
|
||||
this.handleKeyboard = function(data, hashId, keyString, keyCode) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -47,15 +47,27 @@ require("../commands/default_commands");
|
|||
var KeyBinding = function(editor) {
|
||||
this.$editor = editor;
|
||||
this.$data = { };
|
||||
this.$handlers = [this];
|
||||
this.$handlers = [];
|
||||
this.setDefaultHandler(editor.commands);
|
||||
};
|
||||
|
||||
(function() {
|
||||
this.setDefaultHandler = function(keyboardHandler) {
|
||||
this.removeKeyboardHandler(this.$defaultHandler);
|
||||
this.$defaultHandler = keyboardHandler;
|
||||
if (keyboardHandler)
|
||||
this.$handlers.unshift(keyboardHandler);
|
||||
this.$data = { };
|
||||
};
|
||||
|
||||
this.setKeyboardHandler = function(keyboardHandler) {
|
||||
if (this.$handlers[this.$handlers.length - 1] == keyboardHandler)
|
||||
return;
|
||||
this.$data = { };
|
||||
this.$handlers = keyboardHandler ? [this, keyboardHandler] : [this];
|
||||
this.$handlers = [];
|
||||
this.setDefaultHandler(this.$defaultHandler);
|
||||
if (keyboardHandler)
|
||||
this.$handlers.push(keyboardHandler);
|
||||
};
|
||||
|
||||
this.addKeyboardHandler = function(keyboardHandler) {
|
||||
|
|
@ -93,7 +105,7 @@ var KeyBinding = function(editor) {
|
|||
|
||||
// allow keyboardHandler to consume keys
|
||||
if (toExecute.command != "null")
|
||||
success = commands.exec(toExecute.command, this.$editor, toExecute.args);
|
||||
success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
|
||||
else
|
||||
success = true;
|
||||
|
||||
|
|
@ -103,20 +115,14 @@ var KeyBinding = function(editor) {
|
|||
return success;
|
||||
};
|
||||
|
||||
this.handleKeyboard = function(data, hashId, keyString) {
|
||||
return {
|
||||
command: this.$editor.commands.findKeyCommand(hashId, keyString)
|
||||
};
|
||||
};
|
||||
|
||||
this.onCommandKey = function(e, hashId, keyCode) {
|
||||
var keyString = keyUtil.keyCodeToString(keyCode);
|
||||
this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
|
||||
};
|
||||
|
||||
this.onTextInput = function(text, pasted) {
|
||||
this.onTextInput = function(text) {
|
||||
var success = false;
|
||||
if (!pasted && text.length == 1)
|
||||
if (text.length == 1)
|
||||
success = this.$callKeyboardHandlers(0, text);
|
||||
if (!success)
|
||||
this.$editor.commands.exec("insertstring", this.$editor, text);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ function StateHandler(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.
|
||||
|
|
@ -198,7 +198,7 @@ StateHandler.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
/*
|
||||
* This function is called by keyBinding.
|
||||
*/
|
||||
handleKeyboard: function(data, hashId, key, keyCode, e) {
|
||||
|
|
@ -224,7 +224,7 @@ StateHandler.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* This is a useful matching function and therefore is defined here so that
|
||||
* users of KeyboardStateMapper can use it.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@ var TextInput = function(parentNode, host) {
|
|||
var text = dom.createElement("textarea");
|
||||
if (useragent.isTouchPad)
|
||||
text.setAttribute("x-palm-disable-auto-cap", true);
|
||||
|
||||
|
||||
text.setAttribute("wrap", "off");
|
||||
|
||||
text.style.left = "-10000px";
|
||||
text.style.position = "fixed";
|
||||
parentNode.insertBefore(text, parentNode.firstChild);
|
||||
|
|
@ -72,13 +74,18 @@ var TextInput = function(parentNode, host) {
|
|||
if (!copied) {
|
||||
var value = valueToSend || text.value;
|
||||
if (value) {
|
||||
if (value.charCodeAt(value.length-1) == PLACEHOLDER.charCodeAt(0)) {
|
||||
value = value.slice(0, -1);
|
||||
if (value)
|
||||
host.onTextInput(value, pasted);
|
||||
if (value.length > 1) {
|
||||
if (value.charAt(0) == PLACEHOLDER)
|
||||
value = value.substr(1);
|
||||
else if (value.charAt(value.length - 1) == PLACEHOLDER)
|
||||
value = value.slice(0, -1);
|
||||
}
|
||||
else {
|
||||
host.onTextInput(value, pasted);
|
||||
|
||||
if (value && value != PLACEHOLDER) {
|
||||
if (pasted)
|
||||
host.onPaste(value);
|
||||
else
|
||||
host.onTextInput(value);
|
||||
}
|
||||
|
||||
// If editor is no longer focused we quit immediately, since
|
||||
|
|
@ -99,7 +106,7 @@ var TextInput = function(parentNode, host) {
|
|||
var onTextInput = function(e) {
|
||||
setTimeout(function () {
|
||||
if (!inCompostion)
|
||||
sendText(e.data);
|
||||
sendText(e.data);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
|
|
@ -155,6 +162,7 @@ var TextInput = function(parentNode, host) {
|
|||
};
|
||||
|
||||
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
|
||||
|
||||
if (useragent.isOldIE) {
|
||||
var keytable = { 13:1, 27:1 };
|
||||
event.addListener(text, "keyup", function (e) {
|
||||
|
|
|
|||
|
|
@ -175,6 +175,9 @@ var Cursor = function(parentEl) {
|
|||
if (overwrite != this.overwrite)
|
||||
this.$setOverite(overwrite);
|
||||
|
||||
// cache for textarea and gutter highlight
|
||||
this.$pixelPos = pixelPos;
|
||||
|
||||
this.restartTimer();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -111,9 +111,7 @@ var Marker = function(parentEl) {
|
|||
return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws a marker, which spans a range of text on multiple lines
|
||||
*/
|
||||
// Draws a marker, which spans a range of text on multiple lines
|
||||
this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) {
|
||||
// selection start
|
||||
var row = range.start.row;
|
||||
|
|
@ -137,9 +135,7 @@ var Marker = function(parentEl) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws a multi line marker, where lines span the full width
|
||||
*/
|
||||
// Draws a multi line marker, where lines span the full width
|
||||
this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) {
|
||||
var padding = type === "background" ? 0 : this.$padding;
|
||||
var layerWidth = layerConfig.width + 2 * this.$padding - padding;
|
||||
|
|
@ -186,9 +182,7 @@ var Marker = function(parentEl) {
|
|||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws a marker which covers part or whole width of a single screen line
|
||||
*/
|
||||
// Draws a marker which covers part or whole width of a single screen line
|
||||
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength, type) {
|
||||
var padding = type === "background" ? 0 : this.$padding;
|
||||
var height = layerConfig.lineHeight;
|
||||
|
|
|
|||
|
|
@ -390,21 +390,18 @@ var Text = function(parentEl) {
|
|||
|
||||
this.$renderToken = function(stringBuilder, screenColumn, token, value) {
|
||||
var self = this;
|
||||
var replaceReg = /\t|&|<|( +)|([\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000])|[\u1100-\u115F]|[\u11A3-\u11A7]|[\u11FA-\u11FF]|[\u2329-\u232A]|[\u2E80-\u2E99]|[\u2E9B-\u2EF3]|[\u2F00-\u2FD5]|[\u2FF0-\u2FFB]|[\u3000-\u303E]|[\u3041-\u3096]|[\u3099-\u30FF]|[\u3105-\u312D]|[\u3131-\u318E]|[\u3190-\u31BA]|[\u31C0-\u31E3]|[\u31F0-\u321E]|[\u3220-\u3247]|[\u3250-\u32FE]|[\u3300-\u4DBF]|[\u4E00-\uA48C]|[\uA490-\uA4C6]|[\uA960-\uA97C]|[\uAC00-\uD7A3]|[\uD7B0-\uD7C6]|[\uD7CB-\uD7FB]|[\uF900-\uFAFF]|[\uFE10-\uFE19]|[\uFE30-\uFE52]|[\uFE54-\uFE66]|[\uFE68-\uFE6B]|[\uFF01-\uFF60]|[\uFFE0-\uFFE6]/g;
|
||||
var replaceReg = /\t|&|<|( +)|([\u0000-\u0019\u00a0\u2000-\u200b\u2028\u2029\u3000])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
|
||||
var replaceFunc = function(c, a, b, tabIdx, idx4) {
|
||||
if (c.charCodeAt(0) == 32) {
|
||||
if (a) {
|
||||
return new Array(c.length+1).join(" ");
|
||||
} else if (c == "&") {
|
||||
return "&";
|
||||
} else if (c == "<") {
|
||||
return "<";
|
||||
} else if (c == "\t") {
|
||||
var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
|
||||
screenColumn += tabSize - 1;
|
||||
return self.$tabStrings[tabSize];
|
||||
} else if (c == "&") {
|
||||
if (useragent.isOldGecko)
|
||||
return "&";
|
||||
else
|
||||
return "&";
|
||||
} else if (c == "<") {
|
||||
return "<";
|
||||
} else if (c == "\u3000") {
|
||||
// U+3000 is both invisible AND full-width, so must be handled uniquely
|
||||
var classToUse = self.showInvisibles ? "ace_cjk ace_invisible" : "ace_cjk";
|
||||
|
|
@ -413,13 +410,8 @@ var Text = function(parentEl) {
|
|||
return "<span class='" + classToUse + "' style='width:" +
|
||||
(self.config.characterWidth * 2) +
|
||||
"px'>" + space + "</span>";
|
||||
} else if (c.match(/[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]/)) {
|
||||
if (self.showInvisibles) {
|
||||
var space = new Array(c.length+1).join(self.SPACE_CHAR);
|
||||
return "<span class='ace_invisible'>" + space + "</span>";
|
||||
} else {
|
||||
return " ";
|
||||
}
|
||||
} else if (b) {
|
||||
return "<span class='ace_invisible ace_invalid'>" + self.SPACE_CHAR + "</span>";
|
||||
} else {
|
||||
screenColumn += 1;
|
||||
return "<span class='ace_cjk' style='width:" +
|
||||
|
|
|
|||
|
|
@ -103,4 +103,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ var oop = require("./oop");
|
|||
var event = require("./event");
|
||||
var EventEmitter = require("./event_emitter").EventEmitter;
|
||||
|
||||
/**
|
||||
/*
|
||||
* This class keeps track of the focus state of the given window.
|
||||
* Focus changes for example when the user switches a browser tab,
|
||||
* goes to the location bar or switches to another application.
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ exports.hasCssClass = function(el, name) {
|
|||
return classes.indexOf(name) !== -1;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Add a CSS class to the list of classes on the given node
|
||||
*/
|
||||
exports.addCssClass = function(el, name) {
|
||||
|
|
@ -72,7 +72,7 @@ exports.addCssClass = function(el, name) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Remove a CSS class from the list of classes on the given node
|
||||
*/
|
||||
exports.removeCssClass = function(el, name) {
|
||||
|
|
@ -104,7 +104,7 @@ exports.toggleCssClass = function(el, name) {
|
|||
return add;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Add or remove a CSS class from the list of classes on the given node
|
||||
* depending on the value of <tt>include</tt>
|
||||
*/
|
||||
|
|
@ -255,7 +255,7 @@ exports.scrollbarWidth = function(document) {
|
|||
return noScrollbar-withScrollbar;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Optimized set innerHTML. This is faster than plain innerHTML if the element
|
||||
* already contains a lot of child elements.
|
||||
*
|
||||
|
|
@ -289,4 +289,4 @@ exports.getParentWindow = function(document) {
|
|||
return document.defaultView || document.parentWindow;
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
/**
|
||||
/*
|
||||
* Brings an environment as close to ECMAScript 5 compliance
|
||||
* as is possible with the facilities of erstwhile engines.
|
||||
*
|
||||
|
|
@ -1056,4 +1056,4 @@ var prepareString = "a"[0] != "a",
|
|||
}
|
||||
return Object(o);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ exports.removeListener = function(elem, type, callback) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Prevents propagation and clobbers the default action of the passed event
|
||||
*/
|
||||
exports.stopEvent = function(e) {
|
||||
|
|
@ -87,23 +87,7 @@ exports.preventDefault = function(e) {
|
|||
e.returnValue = false;
|
||||
};
|
||||
|
||||
exports.getDocumentX = function(e) {
|
||||
if (e.clientX) {
|
||||
return e.clientX + dom.getPageScrollLeft();
|
||||
} else {
|
||||
return e.pageX;
|
||||
}
|
||||
};
|
||||
|
||||
exports.getDocumentY = function(e) {
|
||||
if (e.clientY) {
|
||||
return e.clientY + dom.getPageScrollTop();
|
||||
} else {
|
||||
return e.pageY;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* @return {Number} 0 for left button, 1 for middle button, 2 for right button
|
||||
*/
|
||||
exports.getButton = function(e) {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ EventEmitter._dispatchEvent = function(eventName, e) {
|
|||
}
|
||||
|
||||
if (defaultHandler && !e.defaultPrevented)
|
||||
defaultHandler(e);
|
||||
return defaultHandler(e);
|
||||
};
|
||||
|
||||
EventEmitter.setDefaultHandler = function(eventName, callback) {
|
||||
|
|
@ -118,4 +118,4 @@ EventEmitter.removeAllListeners = function(eventName) {
|
|||
|
||||
exports.EventEmitter = EventEmitter;
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -69,4 +69,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ define(function(require, exports, module) {
|
|||
require("./regexp");
|
||||
require("./es5-shim");
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ define(function(require, exports, module) {
|
|||
|
||||
var oop = require("./oop");
|
||||
|
||||
/**
|
||||
/*
|
||||
* Helper functions and hashes for key handling.
|
||||
*/
|
||||
var Keys = (function() {
|
||||
|
|
@ -126,4 +126,4 @@ exports.keyCodeToString = function(keyCode) {
|
|||
return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ exports.arrayToMap = function(arr) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* splice out of 'array' anything that === 'value'
|
||||
*/
|
||||
exports.arrayRemove = function(array, value) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* based on code from:
|
||||
*
|
||||
* @license RequireJS text 0.25.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
||||
|
|
@ -59,4 +59,4 @@ exports.loadScript = function(path, callback) {
|
|||
s.onload = callback;
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Based on code from:
|
||||
*
|
||||
* XRegExp 1.5.0
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ define(function(require, exports, module) {
|
|||
var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
|
||||
var ua = navigator.userAgent;
|
||||
|
||||
/** Is the user using a browser that identifies itself as Windows */
|
||||
// Is the user using a browser that identifies itself as Windows
|
||||
exports.isWin = (os == "win");
|
||||
|
||||
/** Is the user using a browser that identifies itself as Mac OS */
|
||||
// Is the user using a browser that identifies itself as Mac OS
|
||||
exports.isMac = (os == "mac");
|
||||
|
||||
/** Is the user using a browser that identifies itself as Linux */
|
||||
// Is the user using a browser that identifies itself as Linux
|
||||
exports.isLinux = (os == "linux");
|
||||
|
||||
exports.isIE =
|
||||
|
|
@ -56,16 +56,16 @@ exports.isIE =
|
|||
|
||||
exports.isOldIE = exports.isIE && exports.isIE < 9;
|
||||
|
||||
/** Is this Firefox or related? */
|
||||
// Is this Firefox or related?
|
||||
exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
|
||||
|
||||
/** oldGecko == rev < 2.0 **/
|
||||
// oldGecko == rev < 2.0
|
||||
exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4;
|
||||
|
||||
/** Is this Opera */
|
||||
// Is this Opera
|
||||
exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
|
||||
|
||||
/** Is the user using a browser that identifies itself as WebKit */
|
||||
// Is the user using a browser that identifies itself as WebKit
|
||||
exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
|
||||
|
||||
exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
|
||||
|
|
@ -76,7 +76,7 @@ exports.isIPad = ua.indexOf("iPad") >= 0;
|
|||
|
||||
exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
|
||||
|
||||
/**
|
||||
/*
|
||||
* I hate doing this, but we need some way to determine if the user is on a Mac
|
||||
* The reason is that users have different expectations of their key combinations.
|
||||
*
|
||||
|
|
@ -89,7 +89,7 @@ exports.OS = {
|
|||
WINDOWS: "WINDOWS"
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Return an exports.OS constant
|
||||
*/
|
||||
exports.getOS = function() {
|
||||
|
|
|
|||
|
|
@ -95,4 +95,4 @@ var Behaviour = function() {
|
|||
}).call(Behaviour.prototype);
|
||||
|
||||
exports.Behaviour = Behaviour;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -222,4 +222,4 @@ var CstyleBehaviour = function () {
|
|||
oop.inherits(CstyleBehaviour, Behaviour);
|
||||
|
||||
exports.CstyleBehaviour = CstyleBehaviour;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -89,4 +89,4 @@ var XmlBehaviour = function () {
|
|||
oop.inherits(XmlBehaviour, Behaviour);
|
||||
|
||||
exports.XmlBehaviour = XmlBehaviour;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,4 +118,4 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -60,4 +60,4 @@ define(function(require, exports, module) {
|
|||
exports.parse = function(code) {
|
||||
return parser.parse(lexer.tokenize(code));
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
|
|
@ -97,4 +97,4 @@ define(function(require, exports, module) {
|
|||
};
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
|
|
@ -736,4 +736,4 @@ define(function(require, exports, module) {
|
|||
LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR'];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
|
|
@ -2753,4 +2753,4 @@ define(function(require, exports, module) {
|
|||
};
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
|
|
@ -600,4 +600,4 @@ parse: function parse(input) {
|
|||
module.exports = parser;
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -65,4 +65,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
|
|
@ -339,4 +339,4 @@ define(function(require, exports, module) {
|
|||
LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT'];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
|
|
@ -151,4 +151,4 @@ define(function(require, exports, module) {
|
|||
})();
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -69,4 +69,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,4 +89,4 @@ oop.inherits(Worker, Mirror);
|
|||
|
||||
}).call(Worker.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -96,4 +96,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,4 +82,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,4 +63,4 @@ oop.inherits(Worker, Mirror);
|
|||
|
||||
}).call(Worker.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -72,4 +72,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,4 +92,4 @@ oop.inherits(FoldMode, BaseFoldMode);
|
|||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -89,4 +89,4 @@ module.exports = {
|
|||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main)
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
|
|
|
|||
|
|
@ -83,4 +83,4 @@ var FoldMode = exports.FoldMode = function() {
|
|||
|
||||
oop.inherits(FoldMode, MixedFoldMode);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -166,4 +166,4 @@ module.exports = {
|
|||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main)
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
|
|
|
|||
|
|
@ -85,4 +85,4 @@ oop.inherits(FoldMode, BaseFoldMode);
|
|||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -62,4 +62,4 @@ oop.inherits(FoldMode, BaseFoldMode);
|
|||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -99,4 +99,4 @@ module.exports = {
|
|||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main)
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ oop.inherits(FoldMode, BaseFoldMode);
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* reads a full tag and places the iterator after the tag
|
||||
*/
|
||||
this._readTagForward = function(iterator) {
|
||||
|
|
@ -259,4 +259,4 @@ oop.inherits(FoldMode, BaseFoldMode);
|
|||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -114,4 +114,4 @@ module.exports = {
|
|||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main)
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
|
|
|
|||
|
|
@ -90,4 +90,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,4 +222,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,4 +162,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,4 +85,4 @@ oop.inherits(JavaScriptWorker, Mirror);
|
|||
|
||||
}).call(JavaScriptWorker.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -96,4 +96,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,4 +97,4 @@ oop.inherits(Mode, TextMode);
|
|||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -343,4 +343,4 @@ define(function(require, exports, module) {
|
|||
return reviver.call(holder, key, value);
|
||||
}({'': result}, '') : result;
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -100,4 +100,4 @@ oop.inherits(JsonWorker, Mirror);
|
|||
|
||||
}).call(JsonWorker.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -105,4 +105,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
|
||||
|
||||
var chunks = ["function", "then", "do", "repeat"];
|
||||
|
||||
if (state == "start") {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ var LuaHighlightRules = function() {
|
|||
this.$rules = {
|
||||
"start" :
|
||||
|
||||
|
||||
|
||||
// bracketed comments
|
||||
[{
|
||||
token : "comment", // --[[ comment
|
||||
|
|
@ -132,9 +132,9 @@ var LuaHighlightRules = function() {
|
|||
token : "comment", // --[====+[ comment
|
||||
regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
|
||||
},
|
||||
|
||||
// multiline bracketed comments
|
||||
{
|
||||
|
||||
// multiline bracketed comments
|
||||
{
|
||||
token : "comment", // --[[ comment
|
||||
regex : strPre + '\\-\\-\\[\\[.*$',
|
||||
merge : true,
|
||||
|
|
@ -184,7 +184,7 @@ var LuaHighlightRules = function() {
|
|||
},
|
||||
|
||||
// bracketed strings
|
||||
{
|
||||
{
|
||||
token : "string", // [[ string
|
||||
regex : strPre + '\\[\\[.*\\]\\]'
|
||||
}, {
|
||||
|
|
@ -203,8 +203,8 @@ var LuaHighlightRules = function() {
|
|||
token : "string", // [====+[ string
|
||||
regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
|
||||
},
|
||||
|
||||
// multiline bracketed strings
|
||||
|
||||
// multiline bracketed strings
|
||||
{
|
||||
token : "string", // [[ string
|
||||
regex : strPre + '\\[\\[.*$',
|
||||
|
|
|
|||
|
|
@ -78,4 +78,4 @@ oop.inherits(Mode, TextMode);
|
|||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -192,4 +192,4 @@ var MarkdownHighlightRules = function() {
|
|||
oop.inherits(MarkdownHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.MarkdownHighlightRules = MarkdownHighlightRules;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -83,4 +83,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,4 +68,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,4 +100,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,4 +79,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,4 @@ var Editor = exports.Editor = function() {
|
|||
|
||||
}).call(Editor.prototype);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,16 +39,27 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
function GutterHandler(editor) {
|
||||
editor.setDefaultHandler("gutterclick", function(e) {
|
||||
function GutterHandler(mouseHandler) {
|
||||
var editor = mouseHandler.editor;
|
||||
|
||||
mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
|
||||
if (e.domEvent.target.className.indexOf("ace_gutter-cell") == -1)
|
||||
return;
|
||||
|
||||
if (!editor.isFocused())
|
||||
return;
|
||||
|
||||
var row = e.getDocumentPosition().row;
|
||||
var selection = editor.session.selection;
|
||||
|
||||
|
||||
selection.moveCursorTo(row, 0);
|
||||
selection.selectLine();
|
||||
|
||||
mouseHandler.$clickSelection = selection.getRange();
|
||||
mouseHandler.captureMouse(e, "selectByLines");
|
||||
});
|
||||
}
|
||||
|
||||
exports.GutterHandler = GutterHandler;
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Mike de Boer <mike AT ajax DOT org>
|
||||
* Harutyun Amirjanyan <harutyun AT c9 DOT io>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -40,237 +41,287 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var event = require("../lib/event");
|
||||
var dom = require("../lib/dom");
|
||||
var BrowserFocus = require("../lib/browser_focus").BrowserFocus;
|
||||
|
||||
var STATE_UNKNOWN = 0;
|
||||
var STATE_SELECT = 1;
|
||||
var STATE_DRAG = 2;
|
||||
|
||||
var DRAG_OFFSET = 5; // pixels
|
||||
|
||||
function DefaultHandlers(editor) {
|
||||
this.editor = editor;
|
||||
this.$clickSelection = null;
|
||||
this.browserFocus = new BrowserFocus();
|
||||
|
||||
editor.setDefaultHandler("mousedown", this.onMouseDown.bind(this));
|
||||
editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(this));
|
||||
editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(this));
|
||||
editor.setDefaultHandler("quadclick", this.onQuadClick.bind(this));
|
||||
editor.setDefaultHandler("mousewheel", this.onScroll.bind(this));
|
||||
|
||||
function DefaultHandlers(mouseHandler) {
|
||||
mouseHandler.$clickSelection = null;
|
||||
mouseHandler.browserFocus = new BrowserFocus();
|
||||
|
||||
var editor = mouseHandler.editor;
|
||||
editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
|
||||
editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
|
||||
editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
|
||||
editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
|
||||
editor.setDefaultHandler("mousewheel", this.onScroll.bind(mouseHandler));
|
||||
|
||||
var exports = ["select", "startSelect", "drag", "dragEnd", "dragWait",
|
||||
"dragWaitEnd", "startDrag"];
|
||||
|
||||
exports.forEach(function(x) {
|
||||
mouseHandler[x] = this[x];
|
||||
}, this);
|
||||
|
||||
mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
|
||||
mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
|
||||
}
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
this.onMouseDown = function(ev) {
|
||||
this.mousedownEvent = ev;
|
||||
var inSelection = ev.inSelection();
|
||||
var pageX = ev.pageX;
|
||||
var pageY = ev.pageY;
|
||||
var pos = ev.getDocumentPosition();
|
||||
var editor = this.editor;
|
||||
var _self = this;
|
||||
|
||||
|
||||
this.ev = ev
|
||||
var selectionRange = editor.getSelectionRange();
|
||||
var selectionEmpty = selectionRange.isEmpty();
|
||||
var state = STATE_UNKNOWN;
|
||||
|
||||
// if this click caused the editor to be focused should not clear the
|
||||
// selection
|
||||
if (
|
||||
inSelection && (
|
||||
!this.browserFocus.isFocused()
|
||||
|| new Date().getTime() - this.browserFocus.lastFocus < 20
|
||||
|| !editor.isFocused()
|
||||
)
|
||||
) {
|
||||
editor.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
var button = ev.getButton();
|
||||
if (button !== 0) {
|
||||
if (selectionEmpty) {
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
if (button == 2) {
|
||||
editor.textInput.onContextMenu({x: ev.clientX, y: ev.clientY}, selectionEmpty);
|
||||
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
|
||||
}
|
||||
// 2: contextmenu, 1: linux paste
|
||||
this.moveTextarea = function() {
|
||||
editor.textInput.onContextMenu({x: _self.x, y: _self.y});
|
||||
};
|
||||
this.moveTextareaEnd = editor.textInput.onContextMenuClose;
|
||||
|
||||
editor.textInput.onContextMenu({x: this.x, y: this.y}, selectionEmpty);
|
||||
this.captureMouse(ev, "moveTextarea");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inSelection) {
|
||||
// if this click caused the editor to be focused should not clear the
|
||||
// selection
|
||||
if (inSelection && !editor.isFocused()) {
|
||||
editor.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inSelection || this.$clickSelection || ev.getShiftKey()) {
|
||||
// Directly pick STATE_SELECT, since the user is not clicking inside
|
||||
// a selection.
|
||||
onStartSelect(pos);
|
||||
}
|
||||
|
||||
var mousePageX = pageX, mousePageY = pageY;
|
||||
var mousedownTime = (new Date()).getTime();
|
||||
var dragCursor, dragRange, dragSelectionMarker;
|
||||
|
||||
var onMouseSelection = function(e) {
|
||||
mousePageX = event.getDocumentX(e);
|
||||
mousePageY = event.getDocumentY(e);
|
||||
};
|
||||
|
||||
var onMouseSelectionEnd = function(e) {
|
||||
clearInterval(timerId);
|
||||
if (state == STATE_UNKNOWN)
|
||||
onStartSelect(pos);
|
||||
else if (state == STATE_DRAG)
|
||||
onMouseDragSelectionEnd(e);
|
||||
|
||||
_self.$clickSelection = null;
|
||||
state = STATE_UNKNOWN;
|
||||
};
|
||||
|
||||
var onMouseDragSelectionEnd = function(e) {
|
||||
dom.removeCssClass(editor.container, "ace_dragging");
|
||||
editor.session.removeMarker(dragSelectionMarker);
|
||||
|
||||
if (!editor.$mouseHandler.$clickSelection) {
|
||||
if (!dragCursor) {
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
if (!dragCursor)
|
||||
return;
|
||||
|
||||
if (dragRange.contains(dragCursor.row, dragCursor.column)) {
|
||||
dragCursor = null;
|
||||
return;
|
||||
}
|
||||
|
||||
editor.clearSelection();
|
||||
if (e && (e.ctrlKey || e.altKey)) {
|
||||
var session = editor.session;
|
||||
var newRange = session.insert(dragCursor, session.getTextRange(dragRange));
|
||||
this.startSelect(pos);
|
||||
} else if (inSelection) {
|
||||
var e = ev.domEvent;
|
||||
if ((e.ctrlKey || e.altKey)) {
|
||||
this.startDrag();
|
||||
} else {
|
||||
var newRange = editor.moveText(dragRange, dragCursor);
|
||||
this.mousedownEvent.time = (new Date()).getTime();
|
||||
this.setState("dragWait");
|
||||
}
|
||||
if (!newRange) {
|
||||
dragCursor = null;
|
||||
return;
|
||||
}
|
||||
|
||||
editor.selection.setSelectionRange(newRange);
|
||||
};
|
||||
|
||||
var onSelectionInterval = function() {
|
||||
if (state == STATE_UNKNOWN) {
|
||||
var distance = calcDistance(pageX, pageY, mousePageX, mousePageY);
|
||||
var time = (new Date()).getTime();
|
||||
|
||||
if (distance > DRAG_OFFSET) {
|
||||
state = STATE_SELECT;
|
||||
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||
onStartSelect(cursor);
|
||||
}
|
||||
else if ((time - mousedownTime) > editor.getDragDelay()) {
|
||||
state = STATE_DRAG;
|
||||
dragRange = editor.getSelectionRange();
|
||||
var style = editor.getSelectionStyle();
|
||||
dragSelectionMarker = editor.session.addMarker(dragRange, "ace_selection", style);
|
||||
editor.clearSelection();
|
||||
dom.addCssClass(editor.container, "ace_dragging");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (state == STATE_DRAG)
|
||||
onDragSelectionInterval();
|
||||
else if (state == STATE_SELECT)
|
||||
onUpdateSelectionInterval();
|
||||
};
|
||||
|
||||
function onStartSelect(pos) {
|
||||
if (ev.getShiftKey()) {
|
||||
editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else {
|
||||
if (!_self.$clickSelection) {
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
}
|
||||
state = STATE_SELECT;
|
||||
}
|
||||
|
||||
var onUpdateSelectionInterval = function() {
|
||||
var anchor;
|
||||
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||
|
||||
if (_self.$clickSelection) {
|
||||
if (_self.$clickSelection.contains(cursor.row, cursor.column)) {
|
||||
editor.selection.setSelectionRange(_self.$clickSelection);
|
||||
}
|
||||
else {
|
||||
if (_self.$clickSelection.compare(cursor.row, cursor.column) == -1) {
|
||||
anchor = _self.$clickSelection.end;
|
||||
}
|
||||
else {
|
||||
anchor = _self.$clickSelection.start;
|
||||
}
|
||||
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
|
||||
editor.selection.selectToPosition(cursor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
editor.selection.selectToPosition(cursor);
|
||||
}
|
||||
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
};
|
||||
|
||||
var onDragSelectionInterval = function() {
|
||||
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||
editor.moveCursorToPosition(dragCursor);
|
||||
};
|
||||
|
||||
event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
|
||||
var timerId = setInterval(onSelectionInterval, 20);
|
||||
|
||||
return ev.preventDefault();
|
||||
this.captureMouse(ev)
|
||||
};
|
||||
|
||||
|
||||
this.startSelect = function(pos) {
|
||||
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||
if (this.mousedownEvent.getShiftKey()) {
|
||||
this.editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else if (!this.$clickSelection) {
|
||||
this.editor.moveCursorToPosition(pos);
|
||||
this.editor.selection.clearSelection();
|
||||
}
|
||||
this.setState("select");
|
||||
}
|
||||
|
||||
this.select = function() {
|
||||
var anchor, editor = this.editor;
|
||||
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||
|
||||
if (this.$clickSelection) {
|
||||
var cmp = this.$clickSelection.comparePoint(cursor);
|
||||
|
||||
if (cmp == -1) {
|
||||
anchor = this.$clickSelection.end;
|
||||
} else if (cmp == 1) {
|
||||
anchor = this.$clickSelection.start;
|
||||
} else {
|
||||
cursor = this.$clickSelection.end;
|
||||
anchor = this.$clickSelection.start;
|
||||
}
|
||||
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
|
||||
}
|
||||
editor.selection.selectToPosition(cursor);
|
||||
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
};
|
||||
|
||||
this.extendSelectionBy = function(unitName) {
|
||||
var anchor, editor = this.editor;
|
||||
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||
var range = editor.selection[unitName](cursor.row, cursor.column);
|
||||
|
||||
if (this.$clickSelection) {
|
||||
var cmpStart = this.$clickSelection.comparePoint(range.start);
|
||||
var cmpEnd = this.$clickSelection.comparePoint(range.end);
|
||||
|
||||
if (cmpStart == -1 && cmpEnd <= 0) {
|
||||
anchor = this.$clickSelection.end;
|
||||
cursor = range.start;
|
||||
} else if (cmpEnd == 1 && cmpStart >= 0) {
|
||||
anchor = this.$clickSelection.start;
|
||||
cursor = range.end;
|
||||
} else if (cmpStart == -1 && cmpEnd == 1) {
|
||||
cursor = range.end;
|
||||
anchor = range.start;
|
||||
} else {
|
||||
cursor = this.$clickSelection.end;
|
||||
anchor = this.$clickSelection.start;
|
||||
}
|
||||
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
|
||||
}
|
||||
editor.selection.selectToPosition(cursor);
|
||||
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
};
|
||||
|
||||
this.startDrag = function() {
|
||||
var editor = this.editor;
|
||||
this.setState("drag");
|
||||
this.dragRange = editor.getSelectionRange();
|
||||
var style = editor.getSelectionStyle();
|
||||
this.dragSelectionMarker = editor.session.addMarker(this.dragRange, "ace_selection", style);
|
||||
editor.clearSelection();
|
||||
dom.addCssClass(editor.container, "ace_dragging");
|
||||
if (!this.$dragKeybinding) {
|
||||
this.$dragKeybinding = {
|
||||
handleKeyboard: function(data, hashId, keyString, keyCode) {
|
||||
if (keyString == "esc")
|
||||
return {command: this.command};
|
||||
},
|
||||
command: {
|
||||
exec: function(editor) {
|
||||
var self = editor.$mouseHandler;
|
||||
self.dragCursor = null
|
||||
self.dragEnd();
|
||||
self.startSelect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor.keyBinding.addKeyboardHandler(this.$dragKeybinding);
|
||||
};
|
||||
|
||||
this.dragWait = function() {
|
||||
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
|
||||
var time = (new Date()).getTime();
|
||||
var editor = this.editor;
|
||||
|
||||
if (distance > DRAG_OFFSET) {
|
||||
this.startSelect();
|
||||
} else if ((time - this.mousedownEvent.time) > editor.getDragDelay()) {
|
||||
this.startDrag()
|
||||
}
|
||||
};
|
||||
|
||||
this.dragWaitEnd = function(e) {
|
||||
this.mousedownEvent.domEvent = e;
|
||||
this.startSelect();
|
||||
};
|
||||
|
||||
this.drag = function() {
|
||||
var editor = this.editor;
|
||||
this.dragCursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
|
||||
editor.moveCursorToPosition(this.dragCursor);
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
};
|
||||
|
||||
this.dragEnd = function(e) {
|
||||
var editor = this.editor;
|
||||
var dragCursor = this.dragCursor;
|
||||
var dragRange = this.dragRange;
|
||||
dom.removeCssClass(editor.container, "ace_dragging");
|
||||
editor.session.removeMarker(this.dragSelectionMarker);
|
||||
editor.keyBinding.removeKeyboardHandler(this.$dragKeybinding);
|
||||
|
||||
if (!dragCursor)
|
||||
return;
|
||||
|
||||
editor.clearSelection();
|
||||
if (e && (e.ctrlKey || e.altKey)) {
|
||||
var session = editor.session;
|
||||
var newRange = dragRange;
|
||||
newRange.end = session.insert(dragCursor, session.getTextRange(dragRange));
|
||||
newRange.start = dragCursor;
|
||||
} else if (dragRange.contains(dragCursor.row, dragCursor.column)) {
|
||||
return;
|
||||
} else {
|
||||
var newRange = editor.moveText(dragRange, dragCursor);
|
||||
}
|
||||
|
||||
if (!newRange)
|
||||
return;
|
||||
|
||||
editor.selection.setSelectionRange(newRange);
|
||||
};
|
||||
|
||||
this.onDoubleClick = function(ev) {
|
||||
var pos = ev.getDocumentPosition();
|
||||
var editor = this.editor;
|
||||
|
||||
|
||||
this.setState("selectByWords");
|
||||
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.selectWord();
|
||||
this.$clickSelection = editor.getSelectionRange();
|
||||
};
|
||||
|
||||
|
||||
this.onTripleClick = function(ev) {
|
||||
var pos = ev.getDocumentPosition();
|
||||
var editor = this.editor;
|
||||
|
||||
|
||||
this.setState("selectByLines");
|
||||
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.selectLine();
|
||||
this.$clickSelection = editor.getSelectionRange();
|
||||
};
|
||||
|
||||
|
||||
this.onQuadClick = function(ev) {
|
||||
var editor = this.editor;
|
||||
|
||||
|
||||
editor.selectAll();
|
||||
this.$clickSelection = editor.getSelectionRange();
|
||||
this.setState("select");
|
||||
};
|
||||
|
||||
|
||||
this.onScroll = function(ev) {
|
||||
var editor = this.editor;
|
||||
|
||||
var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
|
||||
if (isScrolable) {
|
||||
this.$passScrollEvent = false;
|
||||
} else {
|
||||
if (this.$passScrollEvent)
|
||||
return;
|
||||
|
||||
if (!this.$scrollStopTimeout) {
|
||||
var self = this;
|
||||
this.$scrollStopTimeout = setTimeout(function() {
|
||||
self.$passScrollEvent = true;
|
||||
self.$scrollStopTimeout = null;
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
|
||||
if (editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed))
|
||||
return ev.preventDefault();
|
||||
return ev.preventDefault();
|
||||
};
|
||||
|
||||
|
||||
}).call(DefaultHandlers.prototype);
|
||||
|
||||
exports.DefaultHandlers = DefaultHandlers;
|
||||
|
|
|
|||
|
|
@ -68,4 +68,4 @@ function FoldHandler(editor) {
|
|||
|
||||
exports.FoldHandler = FoldHandler;
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,18 +41,15 @@ define(function(require, exports, module) {
|
|||
|
||||
var event = require("../lib/event");
|
||||
|
||||
/**
|
||||
/*
|
||||
* Custom Ace mouse event
|
||||
*/
|
||||
var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
||||
this.domEvent = domEvent;
|
||||
this.editor = editor;
|
||||
|
||||
this.pageX = event.getDocumentX(domEvent);
|
||||
this.pageY = event.getDocumentY(domEvent);
|
||||
|
||||
this.clientX = domEvent.clientX;
|
||||
this.clientY = domEvent.clientY;
|
||||
this.x = this.clientX = domEvent.clientX;
|
||||
this.y = this.clientY = domEvent.clientY;
|
||||
|
||||
this.$pos = null;
|
||||
this.$inSelection = null;
|
||||
|
|
@ -78,7 +75,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
|||
this.preventDefault();
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Get the document position below the mouse cursor
|
||||
*
|
||||
* @return {Object} 'row' and 'column' of the document position
|
||||
|
|
@ -86,14 +83,12 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
|||
this.getDocumentPosition = function() {
|
||||
if (this.$pos)
|
||||
return this.$pos;
|
||||
|
||||
var pageX = event.getDocumentX(this.domEvent);
|
||||
var pageY = event.getDocumentY(this.domEvent);
|
||||
this.$pos = this.editor.renderer.screenToTextCoordinates(pageX, pageY);
|
||||
|
||||
this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
|
||||
return this.$pos;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Check if the mouse cursor is inside of the text selection
|
||||
*
|
||||
* @return {Boolean} whether the mouse cursor is inside of the selection
|
||||
|
|
@ -119,7 +114,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
|||
return this.$inSelection;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Get the clicked mouse button
|
||||
*
|
||||
* @return {Number} 0 for left button, 1 for middle button, 2 for right button
|
||||
|
|
@ -128,7 +123,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
|||
return event.getButton(this.domEvent);
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* @return {Boolean} whether the shift key was pressed when the event was emitted
|
||||
*/
|
||||
this.getShiftKey = function() {
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@ var MouseEvent = require("./mouse_event").MouseEvent;
|
|||
|
||||
var MouseHandler = function(editor) {
|
||||
this.editor = editor;
|
||||
|
||||
new DefaultHandlers(editor);
|
||||
new DefaultGutterHandler(editor);
|
||||
|
||||
|
||||
new DefaultHandlers(this);
|
||||
new DefaultGutterHandler(this);
|
||||
|
||||
event.addListener(editor.container, "mousedown", function(e) {
|
||||
editor.focus();
|
||||
return event.preventDefault(e);
|
||||
|
|
@ -67,7 +67,7 @@ var MouseHandler = function(editor) {
|
|||
event.addMultiMouseDownListener(mouseTarget, 0, 3, 600, this.onMouseEvent.bind(this, "tripleclick"));
|
||||
event.addMultiMouseDownListener(mouseTarget, 0, 4, 600, this.onMouseEvent.bind(this, "quadclick"));
|
||||
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
|
||||
|
||||
|
||||
var gutterEl = editor.renderer.$gutter;
|
||||
event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
|
||||
event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
|
||||
|
|
@ -89,7 +89,7 @@ var MouseHandler = function(editor) {
|
|||
this.onMouseEvent = function(name, e) {
|
||||
this.editor._emit(name, new MouseEvent(e, this.editor));
|
||||
};
|
||||
|
||||
|
||||
this.$dragDelay = 250;
|
||||
this.setDragDelay = function(dragDelay) {
|
||||
this.$dragDelay = dragDelay;
|
||||
|
|
@ -113,10 +113,48 @@ var MouseHandler = function(editor) {
|
|||
mouseEvent.speed = this.$scrollSpeed * 2;
|
||||
mouseEvent.wheelX = e.wheelX;
|
||||
mouseEvent.wheelY = e.wheelY;
|
||||
|
||||
|
||||
this.editor._emit(name, mouseEvent);
|
||||
};
|
||||
|
||||
this.setState = function(state) {
|
||||
this.state = state;
|
||||
};
|
||||
|
||||
this.captureMouse = function(ev, state) {
|
||||
if (state)
|
||||
this.setState(state);
|
||||
|
||||
this.x = ev.x;
|
||||
this.y = ev.y;
|
||||
|
||||
// do not move textarea during selection
|
||||
var kt = this.editor.renderer.$keepTextAreaAtCursor;
|
||||
this.editor.renderer.$keepTextAreaAtCursor = false;
|
||||
|
||||
var self = this;
|
||||
var onMouseSelection = function(e) {
|
||||
self.x = e.clientX;
|
||||
self.y = e.clientY;
|
||||
};
|
||||
|
||||
var onMouseSelectionEnd = function(e) {
|
||||
clearInterval(timerId);
|
||||
self[self.state + "End"] && self[self.state + "End"](e);
|
||||
self.$clickSelection = null;
|
||||
self.editor.renderer.$keepTextAreaAtCursor = kt;
|
||||
self.editor.renderer.$moveTextAreaToCursor();
|
||||
};
|
||||
|
||||
var onSelectionInterval = function() {
|
||||
self[self.state] && self[self.state]();
|
||||
}
|
||||
|
||||
event.capture(this.editor.container, onMouseSelection, onMouseSelectionEnd);
|
||||
var timerId = setInterval(onSelectionInterval, 20);
|
||||
|
||||
ev.preventDefault();
|
||||
};
|
||||
}).call(MouseHandler.prototype);
|
||||
|
||||
exports.MouseHandler = MouseHandler;
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ function onMouseDown(e) {
|
|||
var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
|
||||
|
||||
|
||||
var mouseX = e.pageX, mouseY = e.pageY;
|
||||
var mouseX = e.x, mouseY = e.y;
|
||||
var onMouseSelection = function(e) {
|
||||
mouseX = event.getDocumentX(e);
|
||||
mouseY = event.getDocumentY(e);
|
||||
mouseX = e.clientX;
|
||||
mouseY = e.clientY;
|
||||
};
|
||||
|
||||
var blockSelect = function() {
|
||||
|
|
@ -164,4 +164,4 @@ function onMouseDown(e) {
|
|||
|
||||
exports.onMouseDown = onMouseDown;
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ var RangeList = require("./range_list").RangeList;
|
|||
var Range = require("./range").Range;
|
||||
var Selection = require("./selection").Selection;
|
||||
var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
|
||||
var event = require("./lib/event");
|
||||
exports.commands = require("./commands/multi_select_commands");
|
||||
|
||||
// Todo: session.find or editor.findVolatile that returns range
|
||||
|
|
@ -71,10 +72,12 @@ var EditSession = require("./edit_session").EditSession;
|
|||
// automatically sorted list of ranges
|
||||
this.rangeList = null;
|
||||
|
||||
/**
|
||||
* Selection.addRange(Range) -> Void
|
||||
/** extension
|
||||
* Selection.addRange(range, $blockChangeEvents)
|
||||
* - range (Range): The new range to add
|
||||
* - $blockChangeEvents (Boolean): Whether or not to block changing events
|
||||
*
|
||||
* adds a range to selection entering multiselect mode if necessary
|
||||
* Adds a range to a selection by entering multiselect mode, if necessary.
|
||||
**/
|
||||
this.addRange = function(range, $blockChangeEvents) {
|
||||
if (!range)
|
||||
|
|
@ -118,11 +121,11 @@ var EditSession = require("./edit_session").EditSession;
|
|||
range && this.fromOrientedRange(range);
|
||||
};
|
||||
|
||||
/**
|
||||
* Selection.addRange(pos) -> Range
|
||||
* pos: {row, column}
|
||||
/** extension
|
||||
* Selection.substractPoint(pos) -> Range
|
||||
* - pos (Range): The position to remove, as a `{row, column}` object
|
||||
*
|
||||
* removes range containing pos (if exists)
|
||||
* Removes a Range containing pos (if it exists).
|
||||
**/
|
||||
this.substractPoint = function(pos) {
|
||||
var removed = this.rangeList.substractPoint(pos);
|
||||
|
|
@ -132,10 +135,10 @@ var EditSession = require("./edit_session").EditSession;
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Selection.mergeOverlappingRanges() -> Void
|
||||
/** extension
|
||||
* Selection.mergeOverlappingRanges()
|
||||
*
|
||||
* merges overlapping ranges ensuring consistency after changes
|
||||
* Merges overlapping ranges ensuring consistency after changes
|
||||
**/
|
||||
this.mergeOverlappingRanges = function() {
|
||||
var removed = this.rangeList.merge();
|
||||
|
|
@ -193,6 +196,37 @@ var EditSession = require("./edit_session").EditSession;
|
|||
};
|
||||
|
||||
this.splitIntoLines = function () {
|
||||
if (this.rangeCount > 1) {
|
||||
var ranges = this.rangeList.ranges;
|
||||
var lastRange = ranges[ranges.length - 1];
|
||||
var range = Range.fromPoints(ranges[0].start, lastRange.end);
|
||||
|
||||
this.toSingleRange();
|
||||
this.setSelectionRange(range, lastRange.cursor == lastRange.start);
|
||||
} else {
|
||||
var range = this.getRange();
|
||||
var startRow = range.start.row;
|
||||
var endRow = range.end.row;
|
||||
if (startRow == endRow)
|
||||
return;
|
||||
|
||||
var rectSel = [];
|
||||
var r = this.getLineRange(startRow, true);
|
||||
r.start.column = range.start.column;
|
||||
rectSel.push(r);
|
||||
|
||||
for (var i = startRow + 1; i < endRow; i++)
|
||||
rectSel.push(this.getLineRange(i, true));
|
||||
|
||||
r = this.getLineRange(endRow, true);
|
||||
r.end.column = range.end.column;
|
||||
rectSel.push(r);
|
||||
|
||||
rectSel.forEach(this.addRange, this);
|
||||
}
|
||||
};
|
||||
|
||||
this.toggleBlockSelection = function () {
|
||||
if (this.rangeCount > 1) {
|
||||
var ranges = this.rangeList.ranges;
|
||||
var lastRange = ranges[ranges.length - 1];
|
||||
|
|
@ -209,11 +243,14 @@ var EditSession = require("./edit_session").EditSession;
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Selection.rectangularRangeBlock(screenCursor, screenAnchor, includeEmptyLines) -> [Range]
|
||||
* gets list of ranges composing rectangular block on the screen
|
||||
* @includeEmptyLines if true includes ranges inside the block which
|
||||
* are empty becuase of the clipping
|
||||
/** extension
|
||||
* Selection.rectangularRangeBlock(screenCursor, screenAnchor, includeEmptyLines) -> Range
|
||||
* - screenCursor (Cursor): The cursor to use
|
||||
* - screenAnchor (Anchor): The anchor to use
|
||||
* - includeEmptyLins (Boolean): If true, this includes ranges inside the block which are empty due to clipping
|
||||
*
|
||||
* Gets list of ranges composing rectangular block on the screen
|
||||
*
|
||||
*/
|
||||
this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
|
||||
var rectSel = [];
|
||||
|
|
@ -283,21 +320,22 @@ var EditSession = require("./edit_session").EditSession;
|
|||
// extend Editor
|
||||
var Editor = require("./editor").Editor;
|
||||
(function() {
|
||||
/**
|
||||
* Editor.updateSelectionMarkers() -> Void
|
||||
|
||||
/** extension
|
||||
* Editor.updateSelectionMarkers()
|
||||
*
|
||||
* updates cursor and marker layers
|
||||
* Updates the cursor and marker layers.
|
||||
**/
|
||||
this.updateSelectionMarkers = function() {
|
||||
this.renderer.updateCursor();
|
||||
this.renderer.updateBackMarkers();
|
||||
};
|
||||
|
||||
/**
|
||||
/** extension
|
||||
* Editor.addSelectionMarker(orientedRange) -> Range
|
||||
* - orientedRange: range with cursor
|
||||
* - orientedRange (Range): A range containing a cursor
|
||||
*
|
||||
* adds selection and cursor
|
||||
* Adds the selection and cursor.
|
||||
**/
|
||||
this.addSelectionMarker = function(orientedRange) {
|
||||
if (!orientedRange.cursor)
|
||||
|
|
@ -311,11 +349,11 @@ var Editor = require("./editor").Editor;
|
|||
return orientedRange;
|
||||
};
|
||||
|
||||
/**
|
||||
* Editor.removeSelectionMarker(range) -> Void
|
||||
* - range: selection range added with addSelectionMarker
|
||||
/** extension
|
||||
* Editor.removeSelectionMarker(range)
|
||||
* - range (Range): The selection range added with [[Editor.addSelectionMarker `addSelectionMarker()`]].
|
||||
*
|
||||
* removes selection marker
|
||||
* Removes the selection marker.
|
||||
**/
|
||||
this.removeSelectionMarker = function(range) {
|
||||
if (!range.marker)
|
||||
|
|
@ -346,13 +384,13 @@ var Editor = require("./editor").Editor;
|
|||
this.renderer.updateCursor();
|
||||
this.renderer.updateBackMarkers();
|
||||
};
|
||||
|
||||
|
||||
this.$onRemoveRange = function(e) {
|
||||
this.removeSelectionMarkers(e.ranges);
|
||||
this.renderer.updateCursor();
|
||||
this.renderer.updateBackMarkers();
|
||||
};
|
||||
|
||||
|
||||
this.$onMultiSelect = function(e) {
|
||||
if (this.inMultiSelectMode)
|
||||
return;
|
||||
|
|
@ -365,7 +403,7 @@ var Editor = require("./editor").Editor;
|
|||
this.renderer.updateCursor();
|
||||
this.renderer.updateBackMarkers();
|
||||
};
|
||||
|
||||
|
||||
this.$onSingleSelect = function(e) {
|
||||
if (this.session.multiSelect.inVirtualMode)
|
||||
return;
|
||||
|
|
@ -397,12 +435,12 @@ var Editor = require("./editor").Editor;
|
|||
e.preventDefault();
|
||||
};
|
||||
|
||||
/**
|
||||
* Editor.forEachSelection(cmd, args) -> Void
|
||||
* - cmd: command to execute
|
||||
* - args: arguments to the command
|
||||
/** extension
|
||||
* Editor.forEachSelection(cmd, args)
|
||||
* - cmd (String): The command to execute
|
||||
* - args (String): Any arguments for the command
|
||||
*
|
||||
* executes command for each selection range
|
||||
* Executes a command for each selection range.
|
||||
**/
|
||||
this.forEachSelection = function(cmd, args) {
|
||||
if (this.inVirtualSelectionMode)
|
||||
|
|
@ -433,11 +471,11 @@ var Editor = require("./editor").Editor;
|
|||
this.onCursorChange();
|
||||
this.onSelectionChange();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
/** extension
|
||||
* Editor.exitMultiSelectMode() -> Void
|
||||
*
|
||||
* removes all selections except the last added one.
|
||||
* Removes all the selections except the last added one.
|
||||
**/
|
||||
this.exitMultiSelectMode = function() {
|
||||
if (this.inVirtualSelectionMode)
|
||||
|
|
@ -461,14 +499,35 @@ var Editor = require("./editor").Editor;
|
|||
return text;
|
||||
};
|
||||
|
||||
/**
|
||||
this.onPaste = function(text) {
|
||||
this._emit("paste", text);
|
||||
if (!this.inMultiSelectMode)
|
||||
return this.insert(text);
|
||||
|
||||
var lines = text.split(this.session.getDocument().getNewLineCharacter());
|
||||
var ranges = this.selection.rangeList.ranges;
|
||||
|
||||
if (lines.length > ranges.length) {
|
||||
this.commands.exec("insertstring", this, text);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = ranges.length; i--; ) {
|
||||
var range = ranges[i];
|
||||
if (!range.isEmpty())
|
||||
this.session.remove(range);
|
||||
|
||||
this.session.insert(range.start, lines[i]);
|
||||
}
|
||||
};
|
||||
|
||||
/** extension
|
||||
* Editor.findAll(dir, options) -> Number
|
||||
* - needle: text to find
|
||||
* - options: search options
|
||||
* - additive: keeps
|
||||
* - additive: keeps
|
||||
*
|
||||
* finds and selects all the occurencies of needle
|
||||
* returns number of found ranges
|
||||
* Finds and selects all the occurences of `needle`.
|
||||
**/
|
||||
this.findAll = function(needle, options, additive) {
|
||||
options = options || {};
|
||||
|
|
@ -481,10 +540,10 @@ var Editor = require("./editor").Editor;
|
|||
|
||||
this.$blockScrolling += 1;
|
||||
var selection = this.multiSelect;
|
||||
|
||||
|
||||
if (!additive)
|
||||
selection.toSingleRange(ranges[0]);
|
||||
|
||||
|
||||
for (var i = ranges.length; i--; )
|
||||
selection.addRange(ranges[i], true);
|
||||
|
||||
|
|
@ -494,12 +553,12 @@ var Editor = require("./editor").Editor;
|
|||
};
|
||||
|
||||
// commands
|
||||
/**
|
||||
* Editor.selectMoreLines(dir, skip) -> Void
|
||||
* - dir: -1 up, 1 down
|
||||
* - skip: remove active selection range if true
|
||||
/** extension
|
||||
* Editor.selectMoreLines(dir, skip)
|
||||
* - dir (Number): The direction of lines to select: -1 for up, 1 for down
|
||||
* - skip (Boolean): If `true`, removes the active selection range
|
||||
*
|
||||
* adds cursor above or bellow active cursor
|
||||
* Adds a cursor above or below the active cursor.
|
||||
**/
|
||||
this.selectMoreLines = function(dir, skip) {
|
||||
var range = this.selection.toOrientedRange();
|
||||
|
|
@ -539,12 +598,11 @@ var Editor = require("./editor").Editor;
|
|||
this.selection.substractPoint(toRemove);
|
||||
};
|
||||
|
||||
/**
|
||||
* Editor.transposeSelections(dir) -> Void
|
||||
* - dir: direction to rotate selections
|
||||
/** extension
|
||||
* Editor.transposeSelections(dir)
|
||||
* - dir (Number): The direction to rotate selections
|
||||
*
|
||||
* contents
|
||||
* empty ranges are expanded to word
|
||||
* Transposes the selected ranges.
|
||||
**/
|
||||
this.transposeSelections = function(dir) {
|
||||
var session = this.session;
|
||||
|
|
@ -562,7 +620,7 @@ var Editor = require("./editor").Editor;
|
|||
}
|
||||
}
|
||||
sel.mergeOverlappingRanges();
|
||||
|
||||
|
||||
var words = [];
|
||||
for (var i = all.length; i--; ) {
|
||||
var range = all[i];
|
||||
|
|
@ -583,13 +641,12 @@ var Editor = require("./editor").Editor;
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor.selectMore(dir, skip) -> Void
|
||||
* - dir: 1 next, -1 previous
|
||||
* - skip: remove active selection range if true
|
||||
/** extension
|
||||
* Editor.selectMore(dir, skip)
|
||||
* - dir (Number): The direction of lines to select: -1 for up, 1 for down
|
||||
* - skip (Boolean): If `true`, removes the active selection range
|
||||
*
|
||||
* finds next occurence of text in active selection
|
||||
* and adds it to the selections
|
||||
* Finds the next occurence of text in an active selection and adds it to the selections.
|
||||
**/
|
||||
this.selectMore = function (dir, skip) {
|
||||
var session = this.session;
|
||||
|
|
@ -656,12 +713,9 @@ exports.onSessionChange = function(e) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* MultiSelect(editor) -> Void
|
||||
*
|
||||
* adds multiple selection support to the editor
|
||||
* (note: should be called only once for each editor instance)
|
||||
**/
|
||||
// MultiSelect(editor)
|
||||
// adds multiple selection support to the editor
|
||||
// (note: should be called only once for each editor instance)
|
||||
function MultiSelect(editor) {
|
||||
editor.$onAddRange = editor.$onAddRange.bind(editor);
|
||||
editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
|
||||
|
|
@ -673,7 +727,7 @@ function MultiSelect(editor) {
|
|||
|
||||
editor.on("mousedown", onMouseDown);
|
||||
editor.commands.addCommands(exports.commands.defaultCommands);
|
||||
|
||||
|
||||
addAltCursorListeners(editor);
|
||||
}
|
||||
|
||||
|
|
@ -681,7 +735,7 @@ function addAltCursorListeners(editor){
|
|||
var el = editor.textInput.getElement();
|
||||
var altCursor = false;
|
||||
var contentEl = editor.renderer.content;
|
||||
el.addEventListener("keydown", function(e) {
|
||||
event.addListener(el, "keydown", function(e) {
|
||||
if (e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey)) {
|
||||
if (!altCursor) {
|
||||
contentEl.style.cursor = "crosshair";
|
||||
|
|
@ -691,9 +745,9 @@ function addAltCursorListeners(editor){
|
|||
contentEl.style.cursor = "";
|
||||
}
|
||||
});
|
||||
|
||||
el.addEventListener("keyup", reset);
|
||||
el.addEventListener("blur", reset);
|
||||
|
||||
event.addListener(el, "keyup", reset);
|
||||
event.addListener(el, "blur", reset);
|
||||
function reset() {
|
||||
if (altCursor) {
|
||||
contentEl.style.cursor = "";
|
||||
|
|
@ -704,4 +758,4 @@ function addAltCursorListeners(editor){
|
|||
|
||||
exports.MultiSelect = MultiSelect;
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ module.exports = {
|
|||
]);
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
MultiSelect(editor);
|
||||
var selection = editor.selection;
|
||||
var selection = editor.selection;
|
||||
|
||||
var range1 = new Range(0, 2, 0, 4);
|
||||
editor.selection.fromOrientedRange(range1);
|
||||
|
|
@ -168,4 +168,4 @@ module.exports = {
|
|||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue