pull/483/head
nightwing 2018-01-23 18:59:33 +04:00
rodzic 718f53d835
commit db4123e4f8
20 zmienionych plików z 277 dodań i 269 usunięć

6
plugins/node_modules/ace/lib/ace/ace.js wygenerowano vendored
Wyświetl plik

@ -71,9 +71,10 @@ if (typeof define === "function")
/**
* Embeds the Ace editor into the DOM, at the element provided by `el`.
* @param {String | DOMElement} el Either the id of an element, or the element itself
* @param {Object } options Options for the editor
*
**/
exports.edit = function(el) {
exports.edit = function(el, options) {
if (typeof el == "string") {
var _id = el;
el = document.getElementById(_id);
@ -97,8 +98,7 @@ exports.edit = function(el) {
var doc = exports.createEditSession(value);
var editor = new Editor(new Renderer(el));
editor.setSession(doc);
var editor = new Editor(new Renderer(el), doc, options);
var env = {
document: doc,

Wyświetl plik

@ -22,8 +22,6 @@
.ace_content {
position: absolute;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
min-width: 100%;
}
@ -151,7 +149,6 @@
/*with `pre-line` chrome inserts   instead of space*/
white-space: pre!important;
}
.ace_text-input.ace_composition {
background: inherit;
color: inherit;
@ -159,6 +156,17 @@
opacity: 1;
text-indent: 0;
}
[ace_nocontext=true] {
transform: none!important;
filter: none!important;
perspective: none!important;
clip-path: none!important;
mask : none!important;
contain: none!important;
perspective: none!important;
mix-blend-mode: initial!important;
z-index: auto;
}
.ace_layer {
z-index: 1;
@ -169,8 +177,6 @@
white-space: pre;
height: 100%;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
/* setting pointer-events: auto; on node under the mouse, which changes
during scroll, will break mouse wheel scrolling in Safari */
@ -200,8 +206,6 @@
.ace_cursor {
z-index: 4;
position: absolute;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-left: 2px solid;
/* workaround for smooth cursor repaintng whole screen in chrome */
@ -226,8 +230,7 @@
}
.ace_smooth-blinking .ace_cursor {
-webkit-transition: opacity 0.18s;
transition: opacity 0.18s;
transition: opacity 0.18s;
}
.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {
@ -253,14 +256,10 @@
.ace_marker-layer .ace_selected-word {
position: absolute;
z-index: 4;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.ace_line .ace_fold {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
display: inline-block;
@ -293,7 +292,6 @@
.ace_tooltip {
background-color: #FFF;
background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));
background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));
border: 1px solid gray;
border-radius: 1px;
@ -303,8 +301,6 @@
padding: 3px 4px;
position: fixed;
z-index: 999999;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: default;
white-space: pre;
@ -321,8 +317,6 @@
}
.ace_fold-widget {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0 -12px 0 1px;
@ -383,20 +377,33 @@
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
}
.ace_inline_button {
border: 1px solid lightgray;
display: inline-block;
margin: -1px 8px;
padding: 0 5px;
pointer-events: auto;
cursor: pointer;
}
.ace_inline_button:hover {
border-color: gray;
background: rgba(200,200,200,0.2);
display: inline-block;
pointer-events: auto;
}
.ace_fold-widget.ace_invalid {
background-color: #FFB4B4;
border-color: #DE5555;
}
.ace_fade-fold-widgets .ace_fold-widget {
-webkit-transition: opacity 0.4s ease 0.05s;
transition: opacity 0.4s ease 0.05s;
transition: opacity 0.4s ease 0.05s;
opacity: 0;
}
.ace_fade-fold-widgets:hover .ace_fold-widget {
-webkit-transition: opacity 0.05s ease 0.05s;
transition: opacity 0.05s ease 0.05s;
transition: opacity 0.05s ease 0.05s;
opacity:1;
}
@ -461,7 +468,7 @@ styles.join("\n")
.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_text-input-ios {
position: absolute !important;
top: -100000px !important;
left: -100000px !important;
position: absolute !important;
top: -100000px !important;
left: -100000px !important;
}

Wyświetl plik

@ -70,7 +70,7 @@ var clipboard = require("./clipboard");
*
* @constructor
**/
var Editor = function(renderer, session) {
var Editor = function(renderer, session, options) {
var container = renderer.getContainerElement();
this.container = container;
this.renderer = renderer;
@ -78,7 +78,7 @@ var Editor = function(renderer, session) {
this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
if (typeof document == "object") {
this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
this.renderer.textarea = this.textInput.getElement();
// TODO detect touch event support
this.$mouseHandler = new MouseHandler(this);
@ -106,8 +106,10 @@ var Editor = function(renderer, session) {
_self._$emitInputEvent.schedule(31);
});
this.setSession(session || new EditSession(""));
this.setSession(session || options && options.session || new EditSession(""));
config.resetOptions(this);
if (options)
this.setOptions(options);
config._signal("editor", this);
};
@ -638,13 +640,6 @@ Editor.$uid = 0;
* Brings the current `textInput` into focus.
**/
this.focus = function() {
// Safari needs the timeout
// iOS and Firefox need it called immediately
// to be on the save side we do both
var _self = this;
setTimeout(function() {
_self.textInput.focus();
});
this.textInput.focus();
};
@ -806,7 +801,9 @@ Editor.$uid = 0;
var line = session.getLine(selection.start.row);
var needle = line.substring(startColumn, endColumn);
if (!/[\w\d]/.test(needle))
// maximum allowed size for regular expressions in 32000,
// but getting close to it has significant impact on the performance
if (needle.length > 5000 || !/[\w\d]/.test(needle))
return;
var re = this.$search.$assembleRegExp({
@ -2672,9 +2669,21 @@ config.defineOptions(Editor.prototype, "editor", {
},
keyboardHandler: {
set: function(val) { this.setKeyboardHandler(val); },
get: function() { return this.keybindingId; },
get: function() { return this.$keybindingId; },
handlesSet: true
},
value: {
set: function(val) { this.session.setValue(val); },
get: function() { return this.getValue(); },
handlesSet: true,
hidden: true
},
session: {
set: function(val) { this.setSession(val); },
get: function() { return this.session; },
handlesSet: true,
hidden: true
},
hScrollBarAlwaysVisible: "renderer",
vScrollBarAlwaysVisible: "renderer",

Wyświetl plik

@ -179,7 +179,6 @@ exports.transform = function(iterator, maxPos, context) {
var value = '';
while (token!==null) {
console.log(token);
if( !token ){
token = iterator.stepForward();
@ -363,4 +362,4 @@ exports.transform = function(iterator, maxPos, context) {
});
});

Wyświetl plik

@ -15,7 +15,8 @@ module.exports = {
timeout: 10000,
"test loading in node": function(next) {
assert.equal(typeof window, "undefined");
if (typeof process != "undefined")
assert.equal(typeof window, "undefined");
require("../ace");
next();
},

Wyświetl plik

@ -273,8 +273,6 @@ dom.importCssString && dom.importCssString("\
.ace_marker-layer .ace_isearch-result {\
position: absolute;\
z-index: 6;\
-moz-box-sizing: border-box;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
}\
div.ace_isearch-result {\

Wyświetl plik

@ -65,8 +65,6 @@ exports.handler.attach = function(editor) {
dom.importCssString('\
.emacs-mode .ace_cursor{\
border: 1px rgba(50,250,50,0.8) solid!important;\
-moz-box-sizing: border-box!important;\
-webkit-box-sizing: border-box!important;\
box-sizing: border-box!important;\
background-color: rgba(0,250,0,0.9);\
opacity: 0.5;\

Wyświetl plik

@ -37,6 +37,7 @@ var dom = require("../lib/dom");
var lang = require("../lib/lang");
var BROKEN_SETDATA = useragent.isChrome < 18;
var USE_IE_MIME_TYPE = useragent.isIE;
var HAS_FOCUS_ARGS = useragent.isChrome > 63;
var TextInputIOS = require("./textinput_ios").TextInput;
var TextInput = function(parentNode, host) {
@ -76,12 +77,29 @@ var TextInput = function(parentNode, host) {
host.onFocus(e);
resetSelection();
});
this.$focusScroll = false;
this.focus = function() {
if (tempStyle) return text.focus();
if (tempStyle || HAS_FOCUS_ARGS || this.$focusScroll == "browser")
return text.focus({ preventScroll: true });
var top = text.style.top;
text.style.position = "fixed";
text.style.top = "0px";
text.focus();
var isTransformed = text.getBoundingClientRect().top != 0;
var ancestors = [];
if (isTransformed) {
var t = text.parentElement;
while (t) {
ancestors.push(t);
t.setAttribute("ace_nocontext", true);
t = t.parentElement;
}
}
text.focus({ preventScroll: true });
if (isTransformed) {
ancestors.forEach(function(p) {
p.removeAttribute("ace_nocontext");
});
}
setTimeout(function() {
text.style.position = "";
if (text.style.top == "0px")

Wyświetl plik

@ -55,6 +55,7 @@ var Text = function(parentEl) {
this.TAB_CHAR = "\u2014"; //"\u21E5";
this.SPACE_CHAR = "\xB7";
this.$padding = 0;
this.MAX_LINE_LENGTH = 10000;
this.$updateEolChar = function() {
var doc = this.session.doc;
@ -449,9 +450,19 @@ var Text = function(parentEl) {
for (var i = 1; i < tokens.length; i++) {
token = tokens[i];
value = token.value;
if (screenColumn + value.length > this.MAX_LINE_LENGTH)
return this.$renderOverflowMessage(stringBuilder, screenColumn, token, value);
screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
}
};
this.$renderOverflowMessage = function(stringBuilder, screenColumn, token, value) {
this.$renderToken(stringBuilder, screenColumn, token,
value.slice(0, this.MAX_LINE_LENGTH - screenColumn));
stringBuilder.push(
"<span class='ace_inline_button ace_keyword ace_toggle_wrap'>&lt;click to see more...&gt;</span>"
);
};
// row is either first row of foldline or not in fold
this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {

Wyświetl plik

@ -43,7 +43,10 @@ var optionsProvider = {
getOptions: function(optionNames) {
var result = {};
if (!optionNames) {
optionNames = Object.keys(this.$options);
var options = this.$options;
optionNames = Object.keys(options).filter(function(key) {
return !options[key].hidden;
});
} else if (!Array.isArray(optionNames)) {
result = optionNames;
optionNames = Object.keys(result);

Wyświetl plik

@ -177,6 +177,8 @@ define(function(require, exports, module) {
} else {
break;
}
} else if (ch == "\n" || ch == "\r") {
break;
} else {
string += ch;
}

Wyświetl plik

@ -1702,7 +1702,7 @@ var functionMap = {
],
"enchant_broker_dict_exists": [
"bool enchant_broker_dict_exists(resource broker, string tag)",
"Wether a dictionary exists or not. Using non-empty tag"
"Whether a dictionary exists or not. Using non-empty tag"
],
"enchant_broker_free": [
"boolean enchant_broker_free(resource broker)",
@ -4702,7 +4702,7 @@ var functionMap = {
],
"msg_queue_exists": [
"bool msg_queue_exists(int key)",
"Check wether a message queue exists"
"Check whether a message queue exists"
],
"msg_receive": [
"mixed msg_receive(resource queue, int desiredmsgtype, int &msgtype, int maxsize, mixed message [, bool unserialize=true [, int flags=0 [, int errorcode]]])",
@ -8190,7 +8190,7 @@ var functionMap = {
],
"stream_supports_lock": [
"bool stream_supports_lock(resource stream)",
"Tells wether the stream supports locking through flock()."
"Tells whether the stream supports locking through flock()."
],
"stream_wrapper_register": [
"bool stream_wrapper_register(string protocol, string classname[, integer flags])",

Wyświetl plik

@ -250,8 +250,8 @@ function DefaultHandlers(mouseHandler) {
var prevScroll = this.$lastScroll;
var t = ev.domEvent.timeStamp;
var dt = t - prevScroll.t;
var vx = ev.wheelX / dt;
var vy = ev.wheelY / dt;
var vx = dt ? ev.wheelX / dt : prevScroll.vx;
var vy = dt ? ev.wheelY / dt : prevScroll.vy;
// touchbar keeps sending scroll events after touchend, if we do not stop these events,
// users can't scrol editor without scrolling the parent node

Wyświetl plik

@ -30,6 +30,7 @@
define(function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
function FoldHandler(editor) {
@ -47,6 +48,14 @@ function FoldHandler(editor) {
e.stop();
}
var target = e.domEvent && e.domEvent.target;
if (target && dom.hasCssClass(target, "ace_inline_button")) {
if (dom.hasCssClass(target, "ace_toggle_wrap")) {
session.setOption("wrap", true);
editor.renderer.scrollCursorIntoView();
}
}
});
editor.on("gutterclick", function(e) {

Wyświetl plik

@ -256,8 +256,8 @@ var EditSession = require("./edit_session").EditSession;
this.toSingleRange();
this.setSelectionRange(range, lastRange.cursor == lastRange.start);
} else {
var cursor = this.session.documentToScreenPosition(this.selectionLead);
var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
var cursor = this.session.documentToScreenPosition(this.cursor);
var anchor = this.session.documentToScreenPosition(this.anchor);
var rectSel = this.rectangularRangeBlock(cursor, anchor);
rectSel.forEach(this.addRange, this);

Wyświetl plik

@ -178,8 +178,6 @@ dom.importCssString(".ace_occur-highlight {\n\
background-color: rgba(87, 255, 8, 0.25);\n\
position: absolute;\n\
z-index: 4;\n\
-moz-box-sizing: border-box;\n\
-webkit-box-sizing: border-box;\n\
box-sizing: border-box;\n\
box-shadow: 0 0 4px rgb(91, 255, 50);\n\
}\n\

Wyświetl plik

@ -48,12 +48,12 @@ var Range = require("./range").Range;
* Emitted when the cursor position changes.
* @event changeCursor
*
**/
**/
/**
* Emitted when the cursor selection changes.
*
* @event changeSelection
**/
**/
/**
* Creates a new `Selection` object.
* @param {EditSession} session The session to use
@ -65,11 +65,11 @@ var Selection = function(session) {
this.doc = session.getDocument();
this.clearSelection();
this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
this.cursor = this.lead = this.doc.createAnchor(0, 0);
this.anchor = this.doc.createAnchor(0, 0);
var self = this;
this.lead.on("change", function(e) {
this.cursor.on("change", function(e) {
self._emit("changeCursor");
if (!self.$isEmpty)
self._emit("changeSelection");
@ -77,7 +77,7 @@ var Selection = function(session) {
self.$desiredColumn = null;
});
this.selectionAnchor.on("change", function() {
this.anchor.on("change", function() {
if (!self.$isEmpty)
self._emit("changeSelection");
});
@ -88,82 +88,68 @@ var Selection = function(session) {
oop.implement(this, EventEmitter);
/**
*
* Returns `true` if the selection is empty.
* @returns {Boolean}
**/
* Returns `true` if the selection is empty.
* @returns {Boolean}
**/
this.isEmpty = function() {
return (this.$isEmpty || (
return this.$isEmpty || (
this.anchor.row == this.lead.row &&
this.anchor.column == this.lead.column
));
);
};
/**
* Returns `true` if the selection is a multi-line.
* @returns {Boolean}
**/
* Returns `true` if the selection is a multi-line.
* @returns {Boolean}
**/
this.isMultiLine = function() {
if (this.isEmpty()) {
return false;
}
return this.getRange().isMultiLine();
return !this.$isEmpty && this.anchor.row != this.cursor.row;
};
/**
* Returns an object containing the `row` and `column` current position of the cursor.
* @returns {Object}
**/
* Returns an object containing the `row` and `column` current position of the cursor.
* @returns {Object}
**/
this.getCursor = function() {
return this.lead.getPosition();
};
/**
* Sets the row and column position of the anchor. This function also emits the `'changeSelection'` event.
* @param {Number} row The new row
* @param {Number} column The new column
*
*
**/
* Sets the row and column position of the anchor. This function also emits the `'changeSelection'` event.
* @param {Number} row The new row
* @param {Number} column The new column
*
**/
this.setSelectionAnchor = function(row, column) {
this.$isEmpty = false;
this.anchor.setPosition(row, column);
if (this.$isEmpty) {
this.$isEmpty = false;
this._emit("changeSelection");
}
};
/**
* Returns an object containing the `row` and `column` of the calling selection anchor.
*
* @returns {Object}
* @related Anchor.getPosition
**/
* Returns an object containing the `row` and `column` of the calling selection anchor.
*
* @returns {Object}
* @related Anchor.getPosition
**/
this.getSelectionAnchor = function() {
if (this.$isEmpty)
return this.getSelectionLead();
else
return this.anchor.getPosition();
return this.anchor.getPosition();
};
/**
*
* Returns an object containing the `row` and `column` of the calling selection lead.
* @returns {Object}
**/
* Returns an object containing the `row` and `column` of the calling selection lead.
* @returns {Object}
**/
this.getSelectionLead = function() {
return this.lead.getPosition();
};
/**
* Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns.
* @param {Number} columns The number of columns to shift by
*
*
*
**/
* Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns.
* @param {Number} columns The number of columns to shift by
**/
this.shiftSelection = function(columns) {
if (this.$isEmpty) {
this.moveCursorTo(this.lead.row, this.lead.column + columns);
@ -186,9 +172,9 @@ var Selection = function(session) {
};
/**
* Returns `true` if the selection is going backwards in the document.
* @returns {Boolean}
**/
* Returns `true` if the selection is going backwards in the document.
* @returns {Boolean}
**/
this.isBackwards = function() {
var anchor = this.anchor;
var lead = this.lead;
@ -196,27 +182,24 @@ var Selection = function(session) {
};
/**
* [Returns the [[Range]] for the selected text.]{: #Selection.getRange}
* @returns {Range}
**/
* [Returns the [[Range]] for the selected text.]{: #Selection.getRange}
* @returns {Range}
**/
this.getRange = function() {
var anchor = this.anchor;
var lead = this.lead;
if (this.isEmpty())
if (this.$isEmpty)
return Range.fromPoints(lead, lead);
if (this.isBackwards()) {
return Range.fromPoints(lead, anchor);
}
else {
return Range.fromPoints(anchor, lead);
}
return this.isBackwards()
? Range.fromPoints(lead, anchor)
: Range.fromPoints(anchor, lead);
};
/**
* [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.]{: #Selection.clearSelection}
**/
* [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.]{: #Selection.clearSelection}
**/
this.clearSelection = function() {
if (!this.$isEmpty) {
this.$isEmpty = true;
@ -225,35 +208,29 @@ var Selection = function(session) {
};
/**
* Selects all the text in the document.
**/
* Selects all the text in the document.
**/
this.selectAll = function() {
var lastRow = this.doc.getLength() - 1;
this.setSelectionAnchor(0, 0);
this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
this.anchor.setPosition(0, 0);
this.cursor.setPosition(Number.MAX_VALUE, Number.MAX_VALUE);
};
/**
* Sets the selection to the provided range.
* @param {Range} range The range of text to select
* @param {Boolean} reverse Indicates if the range should go backwards (`true`) or not
*
*
* @method setSelectionRange
* @alias setRange
**/
* Sets the selection to the provided range.
* @param {Range} range The range of text to select
* @param {Boolean} reverse Indicates if the range should go backwards (`true`) or not
*
* @method setSelectionRange
* @alias setRange
**/
this.setRange =
this.setSelectionRange = function(range, reverse) {
if (reverse) {
this.setSelectionAnchor(range.end.row, range.end.column);
this.selectTo(range.start.row, range.start.column);
} else {
this.setSelectionAnchor(range.start.row, range.start.column);
this.selectTo(range.end.row, range.end.column);
}
if (this.getRange().isEmpty())
this.$isEmpty = true;
this.$desiredColumn = null;
var start = reverse ? range.end : range.start;
var end = reverse ? range.start : range.end;
this.$isEmpty = !Range.comparePoints(start, end);
this.anchor.setPosition(start.row, start.column);
this.cursor.setPosition(end.row, end.column);
this.$isEmpty = !Range.comparePoints(this.anchor, this.cursor);
};
this.$moveSelection = function(mover) {
@ -265,13 +242,10 @@ var Selection = function(session) {
};
/**
* Moves the selection cursor to the indicated row and column.
* @param {Number} row The row to select to
* @param {Number} column The column to select to
*
*
*
**/
* Moves the selection cursor to the indicated row and column.
* @param {Number} row The row to select to
* @param {Number} column The column to select to
**/
this.selectTo = function(row, column) {
this.$moveSelection(function() {
this.moveCursorTo(row, column);
@ -279,12 +253,9 @@ var Selection = function(session) {
};
/**
* Moves the selection cursor to the row and column indicated by `pos`.
* @param {Object} pos An object containing the row and column
*
*
*
**/
* Moves the selection cursor to the row and column indicated by `pos`.
* @param {Object} pos An object containing the row and column
**/
this.selectToPosition = function(pos) {
this.$moveSelection(function() {
this.moveCursorToPosition(pos);
@ -292,20 +263,20 @@ var Selection = function(session) {
};
/**
* Moves the selection cursor to the indicated row and column.
* @param {Number} row The row to select to
* @param {Number} column The column to select to
*
**/
* Moves the selection cursor to the indicated row and column.
* @param {Number} row The row to select to
* @param {Number} column The column to select to
*
**/
this.moveTo = function(row, column) {
this.clearSelection();
this.moveCursorTo(row, column);
};
/**
* Moves the selection cursor to the row and column indicated by `pos`.
* @param {Object} pos An object containing the row and column
**/
* Moves the selection cursor to the row and column indicated by `pos`.
* @param {Object} pos An object containing the row and column
**/
this.moveToPosition = function(pos) {
this.clearSelection();
this.moveCursorToPosition(pos);
@ -313,90 +284,79 @@ var Selection = function(session) {
/**
*
* Moves the selection up one row.
**/
* Moves the selection up one row.
**/
this.selectUp = function() {
this.$moveSelection(this.moveCursorUp);
};
/**
*
* Moves the selection down one row.
**/
* Moves the selection down one row.
**/
this.selectDown = function() {
this.$moveSelection(this.moveCursorDown);
};
/**
*
*
* Moves the selection right one column.
**/
* Moves the selection right one column.
**/
this.selectRight = function() {
this.$moveSelection(this.moveCursorRight);
};
/**
*
* Moves the selection left one column.
**/
* Moves the selection left one column.
**/
this.selectLeft = function() {
this.$moveSelection(this.moveCursorLeft);
};
/**
*
* Moves the selection to the beginning of the current line.
**/
* Moves the selection to the beginning of the current line.
**/
this.selectLineStart = function() {
this.$moveSelection(this.moveCursorLineStart);
};
/**
*
* Moves the selection to the end of the current line.
**/
* Moves the selection to the end of the current line.
**/
this.selectLineEnd = function() {
this.$moveSelection(this.moveCursorLineEnd);
};
/**
*
* Moves the selection to the end of the file.
**/
* Moves the selection to the end of the file.
**/
this.selectFileEnd = function() {
this.$moveSelection(this.moveCursorFileEnd);
};
/**
*
* Moves the selection to the start of the file.
**/
* Moves the selection to the start of the file.
**/
this.selectFileStart = function() {
this.$moveSelection(this.moveCursorFileStart);
};
/**
*
* Moves the selection to the first word on the right.
**/
* Moves the selection to the first word on the right.
**/
this.selectWordRight = function() {
this.$moveSelection(this.moveCursorWordRight);
};
/**
*
* Moves the selection to the first word on the left.
**/
* Moves the selection to the first word on the left.
**/
this.selectWordLeft = function() {
this.$moveSelection(this.moveCursorWordLeft);
};
/**
* Moves the selection to highlight the entire word.
* @related EditSession.getWordRange
**/
* Moves the selection to highlight the entire word.
* @related EditSession.getWordRange
**/
this.getWordRange = function(row, column) {
if (typeof column == "undefined") {
var cursor = row || this.lead;
@ -407,17 +367,16 @@ var Selection = function(session) {
};
/**
*
* Selects an entire word boundary.
**/
* Selects an entire word boundary.
**/
this.selectWord = function() {
this.setSelectionRange(this.getWordRange());
};
/**
* Selects a word, including its right whitespace.
* @related EditSession.getAWordRange
**/
* Selects a word, including its right whitespace.
* @related EditSession.getAWordRange
**/
this.selectAWord = function() {
var cursor = this.getCursor();
var range = this.session.getAWordRange(cursor.row, cursor.column);
@ -442,24 +401,22 @@ var Selection = function(session) {
};
/**
* Selects the entire line.
**/
* Selects the entire line.
**/
this.selectLine = function() {
this.setSelectionRange(this.getLineRange());
};
/**
*
* Moves the cursor up one row.
**/
* Moves the cursor up one row.
**/
this.moveCursorUp = function() {
this.moveCursorBy(-1, 0);
};
/**
*
* Moves the cursor down one row.
**/
* Moves the cursor down one row.
**/
this.moveCursorDown = function() {
this.moveCursorBy(1, 0);
};
@ -470,7 +427,7 @@ var Selection = function(session) {
* @param {Object} cursor the current cursor position
* @param {Number} tabSize the tab size
* @param {Number} direction 1 for right, -1 for left
*/
*/
this.wouldMoveIntoSoftTab = function(cursor, tabSize, direction) {
var start = cursor.column;
var end = cursor.column + tabSize;
@ -483,9 +440,8 @@ var Selection = function(session) {
};
/**
*
* Moves the cursor left one column.
**/
* Moves the cursor left one column.
**/
this.moveCursorLeft = function() {
var cursor = this.lead.getPosition(),
fold;
@ -509,9 +465,8 @@ var Selection = function(session) {
};
/**
*
* Moves the cursor right one column.
**/
* Moves the cursor right one column.
**/
this.moveCursorRight = function() {
var cursor = this.lead.getPosition(),
fold;
@ -535,9 +490,8 @@ var Selection = function(session) {
};
/**
*
* Moves the cursor to the start of the line.
**/
* Moves the cursor to the start of the line.
**/
this.moveCursorLineStart = function() {
var row = this.lead.row;
var column = this.lead.column;
@ -560,9 +514,8 @@ var Selection = function(session) {
};
/**
*
* Moves the cursor to the end of the line.
**/
* Moves the cursor to the end of the line.
**/
this.moveCursorLineEnd = function() {
var lead = this.lead;
var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
@ -579,9 +532,8 @@ var Selection = function(session) {
};
/**
*
* Moves the cursor to the end of the file.
**/
* Moves the cursor to the end of the file.
**/
this.moveCursorFileEnd = function() {
var row = this.doc.getLength() - 1;
var column = this.doc.getLine(row).length;
@ -589,24 +541,21 @@ var Selection = function(session) {
};
/**
*
* Moves the cursor to the start of the file.
**/
* Moves the cursor to the start of the file.
**/
this.moveCursorFileStart = function() {
this.moveCursorTo(0, 0);
};
/**
*
* Moves the cursor to the word on the right.
**/
* Moves the cursor to the word on the right.
**/
this.moveCursorLongWordRight = function() {
var row = this.lead.row;
var column = this.lead.column;
var line = this.doc.getLine(row);
var rightOfCursor = line.substring(column);
var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
@ -618,7 +567,7 @@ var Selection = function(session) {
}
// first skip space
if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
if (this.session.nonTokenRe.exec(rightOfCursor)) {
column += this.session.nonTokenRe.lastIndex;
this.session.nonTokenRe.lastIndex = 0;
rightOfCursor = line.substring(column);
@ -634,7 +583,7 @@ var Selection = function(session) {
}
// advance to the end of the next token
if (match = this.session.tokenRe.exec(rightOfCursor)) {
if (this.session.tokenRe.exec(rightOfCursor)) {
column += this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
@ -663,12 +612,11 @@ var Selection = function(session) {
}
var leftOfCursor = lang.stringReverse(str);
var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
// skip whitespace
if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
if (this.session.nonTokenRe.exec(leftOfCursor)) {
column -= this.session.nonTokenRe.lastIndex;
leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
this.session.nonTokenRe.lastIndex = 0;
@ -684,7 +632,7 @@ var Selection = function(session) {
}
// move to the begin of the word
if (match = this.session.tokenRe.exec(leftOfCursor)) {
if (this.session.tokenRe.exec(leftOfCursor)) {
column -= this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
@ -693,12 +641,12 @@ var Selection = function(session) {
};
this.$shortWordEndIndex = function(rightOfCursor) {
var match, index = 0, ch;
var index = 0, ch;
var whitespaceRe = /\s/;
var tokenRe = this.session.tokenRe;
tokenRe.lastIndex = 0;
if (match = this.session.tokenRe.exec(rightOfCursor)) {
if (this.session.tokenRe.exec(rightOfCursor)) {
index = this.session.tokenRe.lastIndex;
} else {
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
@ -796,13 +744,12 @@ var Selection = function(session) {
};
/**
* Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document.
* @param {Number} rows The number of rows to move by
* @param {Number} chars The number of characters to move by
*
*
* @related EditSession.documentToScreenPosition
**/
* Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document.
* @param {Number} rows The number of rows to move by
* @param {Number} chars The number of characters to move by
*
* @related EditSession.documentToScreenPosition
**/
this.moveCursorBy = function(rows, chars) {
var screenPos = this.session.documentToScreenPosition(
this.lead.row,
@ -841,11 +788,9 @@ var Selection = function(session) {
};
/**
* Moves the selection to the position indicated by its `row` and `column`.
* @param {Object} position The position to move to
*
*
**/
* Moves the selection to the position indicated by its `row` and `column`.
* @param {Object} position The position to move to
**/
this.moveCursorToPosition = function(position) {
this.moveCursorTo(position.row, position.column);
};
@ -934,9 +879,9 @@ var Selection = function(session) {
try {
func(this);
var end = this.getCursor();
return Range.fromPoints(start,end);
return Range.fromPoints(start, end);
} catch(e) {
return Range.fromPoints(start,start);
return Range.fromPoints(start, start);
} finally {
this.moveCursorToPosition(start);
}
@ -967,8 +912,9 @@ var Selection = function(session) {
this.addRange(r, true);
}
return;
} else
} else {
data = data[0];
}
}
if (this.rangeList)
this.toSingleRange(data);

Wyświetl plik

@ -37,6 +37,7 @@ define(function(require, exports, module) {
var EditSession = require("./edit_session").EditSession;
var assert = require("./test/assertions");
var Range = require("./range").Range;
module.exports = {
createSession : function(rows, cols) {
@ -470,6 +471,16 @@ module.exports = {
selection.fromJSON(data);
assert.position(selection.getCursor(), 1, 4);
assert.ok(selection.isEqual(data));
},
"test setRange inside fold": function() {
var session = new EditSession("-\n-fold-\n-");
var selection = session.getSelection();
session.addFold(".", new Range(0, 1, 2, 0));
selection.setRange(new Range(1, 1, 1, 5));
assert.equal(session.getTextRange(), "fold");
}
};

Wyświetl plik

@ -1,10 +1,5 @@
.ace-ambiance .ace_gutter {
background-color: #3d3d3d;
background-image: -moz-linear-gradient(left, #3D3D3D, #333);
background-image: -ms-linear-gradient(left, #3D3D3D, #333);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#3D3D3D), to(#333));
background-image: -webkit-linear-gradient(left, #3D3D3D, #333);
background-image: -o-linear-gradient(left, #3D3D3D, #333);
background-image: linear-gradient(left, #3D3D3D, #333);
background-repeat: repeat-x;
border-right: 1px solid #4d4d4d;

Wyświetl plik

@ -593,7 +593,7 @@ var VirtualRenderer = function(container, theme) {
}
var style = this.$printMarginEl.style;
style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
style.left = Math.round(this.characterWidth * this.$printMarginColumn + this.$padding) + "px";
style.visibility = this.$showPrintMargin ? "visible" : "hidden";
if (this.session && this.session.$wrap == -1)
@ -1018,7 +1018,7 @@ var VirtualRenderer = function(container, theme) {
offset = this.scrollTop - firstRowScreen * lineHeight;
var changes = 0;
if (this.layerConfig.width != longestLine)
if (this.layerConfig.width != longestLine || hScrollChanged)
changes = this.CHANGE_H_SCROLL;
// Horizontal scrollbar visibility may have changed, which changes
// the client height of the scroller
@ -1078,6 +1078,9 @@ var VirtualRenderer = function(container, theme) {
var charCount = this.session.getScreenWidth();
if (this.showInvisibles && !this.session.$useWrapMode)
charCount += 1;
if (this.$textLayer && charCount > this.$textLayer.MAX_LINE_LENGTH)
charCount = this.$textLayer.MAX_LINE_LENGTH + 30;
return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
};