update package

This commit is contained in:
Fabian Jakobs 2011-02-14 08:44:05 +01:00
commit 5518af8da4
3 changed files with 167 additions and 65 deletions

View file

@ -1,3 +1,26 @@
2011.02.14, Version 0.1.6
* Extensive support for Cocoa style keybindings on the Mac <https://github.com/ajaxorg/ace/issues/closed#issue/116/comment/767803>
* New commands:
- center selection in viewport
- remove to end/start of line
- split line
- transpose letters
* Refator markers
- Custom code can be used to render markers
- Markers can be in front or behind the text
- Markers are now stored in the session (was in the renderer)
* Lots of IE8 fixes including copy, cut and selections
* Unit tests can also be run in the browser <https://github.com/ajaxorg/ace/blob/master/lib/ace/test/tests.html>
* Soft wrap can adapt to the width of the editor (Mike Ratcliffe, Joe Cheng)
* Add minimal node server server.js to run the Ace demo in Chrome
* The top level editor.html demo has been renamed to index.html
* Bug fixes
- Fixed gotoLine to consider wrapped lines when calculating where to scroll to (James Allen)
- Fixed isues when the editor was scrolled in the web page (Eric Allam)
- Highlighting of Python string literals
- Syntax rule for PHP comments
2011.02.08, Version 0.1.5 2011.02.08, Version 0.1.5
* Add Coffeescript Mode (Satoshi Murakami) * Add Coffeescript Mode (Satoshi Murakami)

View file

@ -4099,10 +4099,7 @@ var Editor =function(renderer, session) {
this.$mouseHandler = new MouseHandler(this); this.$mouseHandler = new MouseHandler(this);
} }
this.$selectionMarker = null;
this.$highlightLineMarker = null;
this.$blockScrolling = 0; this.$blockScrolling = 0;
this.$search = new Search().set({ this.$search = new Search().set({
wrap: true wrap: true
}); });
@ -4156,6 +4153,8 @@ var Editor =function(renderer, session) {
this.session.removeEventListener("changeTabSize", this.$onDocumentChangeTabSize); this.session.removeEventListener("changeTabSize", this.$onDocumentChangeTabSize);
this.session.removeEventListener("changeWrapLimit", this.$onDocumentChangeWrapLimit); this.session.removeEventListener("changeWrapLimit", this.$onDocumentChangeWrapLimit);
this.session.removeEventListener("changeWrapMode", this.$onDocumentChangeWrapMode); this.session.removeEventListener("changeWrapMode", this.$onDocumentChangeWrapMode);
this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
this.session.removeEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint); this.session.removeEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
this.session.removeEventListener("changeAnnotation", this.$onDocumentChangeAnnotation); this.session.removeEventListener("changeAnnotation", this.$onDocumentChangeAnnotation);
@ -4184,6 +4183,12 @@ var Editor =function(renderer, session) {
this.$onDocumentChangeWrapMode = this.onDocumentChangeWrapMode.bind(this); this.$onDocumentChangeWrapMode = this.onDocumentChangeWrapMode.bind(this);
session.addEventListener("changeWrapMode", this.$onDocumentChangeWrapMode); session.addEventListener("changeWrapMode", this.$onDocumentChangeWrapMode);
this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
this.$onDocumentChangeBreakpoint = this.onDocumentChangeBreakpoint.bind(this); this.$onDocumentChangeBreakpoint = this.onDocumentChangeBreakpoint.bind(this);
this.session.addEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint); this.session.addEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
@ -4204,6 +4209,8 @@ var Editor =function(renderer, session) {
this.onCursorChange(); this.onCursorChange();
this.onSelectionChange(); this.onSelectionChange();
this.onChangeFrontMarker();
this.onChangeBackMarker();
this.onDocumentChangeBreakpoint(); this.onDocumentChangeBreakpoint();
this.onDocumentChangeAnnotation(); this.onDocumentChangeAnnotation();
this.renderer.scrollToRow(session.getScrollTopRow()); this.renderer.scrollToRow(session.getScrollTopRow());
@ -4241,7 +4248,7 @@ var Editor =function(renderer, session) {
this.$highlightBrackets = function() { this.$highlightBrackets = function() {
if (this.$bracketHighlight) { if (this.$bracketHighlight) {
this.renderer.removeMarker(this.$bracketHighlight); this.session.removeMarker(this.$bracketHighlight);
this.$bracketHighlight = null; this.$bracketHighlight = null;
} }
@ -4258,7 +4265,7 @@ var Editor =function(renderer, session) {
var pos = self.session.findMatchingBracket(self.getCursorPosition()); var pos = self.session.findMatchingBracket(self.getCursorPosition());
if (pos) { if (pos) {
var range = new Range(pos.row, pos.column, pos.row, pos.column+1); var range = new Range(pos.row, pos.column, pos.row, pos.column+1);
self.$bracketHighlight = self.renderer.addMarker(range, "ace_bracket"); self.$bracketHighlight = self.session.addMarker(range, "ace_bracket");
} }
}, 10); }, 10);
}; };
@ -4326,33 +4333,45 @@ var Editor =function(renderer, session) {
}; };
this.$updateHighlightActiveLine = function() { this.$updateHighlightActiveLine = function() {
if (this.$highlightLineMarker) { var session = this.getSession();
this.renderer.removeMarker(this.$highlightLineMarker);
if (session.$highlightLineMarker) {
session.removeMarker(session.$highlightLineMarker);
} }
this.$highlightLineMarker = null; session.$highlightLineMarker = null;
if (this.getHighlightActiveLine() && (this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) { if (this.getHighlightActiveLine() && (this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) {
var cursor = this.getCursorPosition(); var cursor = this.getCursorPosition();
var range = new Range(cursor.row, 0, cursor.row+1, 0); var range = new Range(cursor.row, 0, cursor.row+1, 0);
this.$highlightLineMarker = this.renderer.addMarker(range, "ace_active_line", "line"); session.$highlightLineMarker = session.addMarker(range, "ace_active_line", "line");
} }
}; };
this.onSelectionChange = function(e) { this.onSelectionChange = function(e) {
if (this.$selectionMarker) { var session = this.getSession();
this.renderer.removeMarker(this.$selectionMarker);
if (session.$selectionMarker) {
session.removeMarker(session.$selectionMarker);
} }
this.$selectionMarker = null; session.$selectionMarker = null;
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
var range = this.selection.getRange(); var range = this.selection.getRange();
var style = this.getSelectionStyle(); var style = this.getSelectionStyle();
this.$selectionMarker = this.renderer.addMarker(range, "ace_selection", style); session.$selectionMarker = session.addMarker(range, "ace_selection", style);
} }
this.onCursorChange(e); this.onCursorChange(e);
}; };
this.onChangeFrontMarker = function() {
this.renderer.updateFrontMarkers();
};
this.onChangeBackMarker = function() {
this.renderer.updateBackMarkers();
};
this.onDocumentChangeBreakpoint = function() { this.onDocumentChangeBreakpoint = function() {
this.renderer.setBreakpoints(this.session.getBreakpoints()); this.renderer.setBreakpoints(this.session.getBreakpoints());
}; };
@ -4595,6 +4614,39 @@ var Editor =function(renderer, session) {
this.clearSelection(); this.clearSelection();
}; };
this.removeWordRight = function() {
if (this.$readOnly)
return;
if (this.selection.isEmpty())
this.selection.selectWordRight();
this.session.remove(this.getSelectionRange());
this.clearSelection();
};
this.removeWordLeft = function() {
if (this.$readOnly)
return;
if (this.selection.isEmpty())
this.selection.selectWordLeft();
this.session.remove(this.getSelectionRange());
this.clearSelection();
};
this.removeToLineStart = function() {
if (this.$readOnly)
return;
if (this.selection.isEmpty())
this.selection.selectLineStart();
this.session.remove(this.getSelectionRange());
this.clearSelection();
};
this.removeToLineEnd = function() { this.removeToLineEnd = function() {
if (this.$readOnly) if (this.$readOnly)
return; return;
@ -4993,13 +5045,16 @@ var Editor =function(renderer, session) {
if (!ranges.length) if (!ranges.length)
return; return;
var selection = this.getSelectionRange();
this.clearSelection(); this.clearSelection();
this.selection.moveCursorTo(0, 0); this.selection.moveCursorTo(0, 0);
this.$blockScrolling += 1;
for (var i = ranges.length - 1; i >= 0; --i) for (var i = ranges.length - 1; i >= 0; --i)
this.$tryReplace(ranges[i], replacement); this.$tryReplace(ranges[i], replacement);
if (ranges[0] !== null)
this.selection.setSelectionRange(ranges[0]); this.selection.setSelectionRange(selection);
this.$blockScrolling -= 1;
}, },
this.$tryReplace = function(range, replacement) { this.$tryReplace = function(range, replacement) {
@ -6445,8 +6500,11 @@ exports.bindings = {
"selectlinestart": "Shift-Home", "selectlinestart": "Shift-Home",
"selectlineend": "Shift-End", "selectlineend": "Shift-End",
"del": "Delete|Ctrl-D", "del": "Delete|Ctrl-D",
"backspace": "Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace|Ctrl-H", "backspace": "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H",
"removetolineend": "Ctrl-K", "removetolineend": "Ctrl-K",
"removetolinestart": "Option-Backspace",
"removewordleft": "Alt-Backspace|Ctrl-Alt-Backspace",
"removewordright": "Alt-Delete",
"outdent": "Shift-Tab", "outdent": "Shift-Tab",
"indent": "Tab", "indent": "Tab",
"transposeletters": "Ctrl-T", "transposeletters": "Ctrl-T",
@ -6786,10 +6844,22 @@ canon.addCommand({
name: "backspace", name: "backspace",
exec: function(env, args, request) { env.editor.removeLeft(); } exec: function(env, args, request) { env.editor.removeLeft(); }
}); });
canon.addCommand({
name: "removetolinestart",
exec: function(env, args, request) { env.editor.removeToLineStart(); }
});
canon.addCommand({ canon.addCommand({
name: "removetolineend", name: "removetolineend",
exec: function(env, args, request) { env.editor.removeToLineEnd(); } exec: function(env, args, request) { env.editor.removeToLineEnd(); }
}); });
canon.addCommand({
name: "removewordleft",
exec: function(env, args, request) { env.editor.removeWordLeft(); }
});
canon.addCommand({
name: "removewordright",
exec: function(env, args, request) { env.editor.removeWordRight(); }
});
canon.addCommand({ canon.addCommand({
name: "outdent", name: "outdent",
exec: function(env, args, request) { env.editor.blockOutdent(); } exec: function(env, args, request) { env.editor.blockOutdent(); }
@ -6871,6 +6941,9 @@ var NO_CHANGE_DELTAS = {};
var EditSession = function(text, mode) { var EditSession = function(text, mode) {
this.$modified = true; this.$modified = true;
this.$breakpoints = []; this.$breakpoints = [];
this.$frontMarkers = {};
this.$backMarkers = {};
this.$markerId = 1;
this.$wrapData = []; this.$wrapData = [];
this.listeners = []; this.listeners = [];
@ -7025,6 +7098,44 @@ var EditSession = function(text, mode) {
return this.$breakpoints; return this.$breakpoints;
}; };
this.addMarker = function(range, clazz, type, inFront) {
var id = this.$markerId++;
var marker = {
range : range,
type : type || "line",
renderer: typeof type == "function" ? type : null,
clazz : clazz,
inFront: !!inFront
}
if (inFront) {
this.$frontMarkers[id] = marker;
this._dispatchEvent("changeFrontMarker")
} else {
this.$backMarkers[id] = marker;
this._dispatchEvent("changeBackMarker")
}
return id;
};
this.removeMarker = function(markerId) {
var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
if (!marker)
return;
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
if (marker) {
delete (markers[markerId]);
this._dispatchEvent(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
}
};
this.getMarkers = function(inFront) {
return inFront ? this.$frontMarkers : this.$backMarkers;
};
/** /**
* Error: * Error:
* { * {
@ -7931,6 +8042,10 @@ var EditSession = function(text, mode) {
column: column column: column
}; };
} }
var rowData = this.$documentToScreenRow(row, column);
var screenRow = rowData[0];
if (row >= this.getLength()) { if (row >= this.getLength()) {
return { return {
row: screenRow, row: screenRow,
@ -7940,11 +8055,8 @@ var EditSession = function(text, mode) {
var split; var split;
var wrapRowData = this.$wrapData[row]; var wrapRowData = this.$wrapData[row];
var screenRow, screenRowOffset;
var screenColumn; var screenColumn;
var rowData = this.$documentToScreenRow(row, column); var screenRowOffset = rowData[1];
screenRow = rowData[0];
screenRowOffset = rowData[1];
str = this.getLine(row).substring( str = this.getLine(row).substring(
wrapRowData[screenRowOffset - 1] || 0, column); wrapRowData[screenRowOffset - 1] || 0, column);
@ -7971,8 +8083,7 @@ var EditSession = function(text, mode) {
}).call(EditSession.prototype); }).call(EditSession.prototype);
exports.EditSession = EditSession; exports.EditSession = EditSession;
}); });/* ***** BEGIN LICENSE BLOCK *****
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
* The contents of this file are subject to the Mozilla Public License Version * The contents of this file are subject to the Mozilla Public License Version
@ -10640,28 +10751,14 @@ var VirtualRenderer = function(container, theme) {
return Math.max(this.$size.scrollerWidth - this.$padding * 2, Math.round(charCount * this.characterWidth)); return Math.max(this.$size.scrollerWidth - this.$padding * 2, Math.round(charCount * this.characterWidth));
}; };
this.addMarker = function(range, clazz, type, inFront) { this.updateFrontMarkers = function() {
if (inFront) { this.$markerFront.setMarkers(this.session.getMarkers(true));
var id = this.$markerFront.addMarker(range, clazz, type);
this.$loop.schedule(this.CHANGE_MARKER_FRONT); this.$loop.schedule(this.CHANGE_MARKER_FRONT);
}
else {
var id = this.$markerBack.addMarker(range, clazz, type);
this.$loop.schedule(this.CHANGE_MARKER_BACK);
}
return [id, !!inFront];
}; };
this.removeMarker = function(markerId) { this.updateBackMarkers = function() {
if (markerId[1]) { this.$markerBack.setMarkers(this.session.getMarkers());
this.$markerFront.removeMarker(markerId[0]);
this.$loop.schedule(this.CHANGE_MARKER_FRONT);
}
else {
this.$markerBack.removeMarker(markerId[0]);
this.$loop.schedule(this.CHANGE_MARKER_BACK); this.$loop.schedule(this.CHANGE_MARKER_BACK);
}
}; };
this.addGutterDecoration = function(row, className){ this.addGutterDecoration = function(row, className){
@ -11056,9 +11153,6 @@ var Marker = function(parentEl) {
this.element = document.createElement("div"); this.element = document.createElement("div");
this.element.className = "ace_layer ace_marker-layer"; this.element.className = "ace_layer ace_marker-layer";
parentEl.appendChild(this.element); parentEl.appendChild(this.element);
this.markers = {};
this.$markerId = 1;
}; };
(function() { (function() {
@ -11067,23 +11161,8 @@ var Marker = function(parentEl) {
this.session = session; this.session = session;
}; };
this.addMarker = function(range, clazz, type) { this.setMarkers = function(markers) {
var id = this.$markerId++; this.markers = markers;
this.markers[id] = {
range : range,
type : type || "line",
renderer: typeof type == "function" ? type : null,
clazz : clazz
};
return id;
};
this.removeMarker = function(markerId) {
var marker = this.markers[markerId];
if (marker) {
delete (this.markers[markerId]);
}
}; };
this.update = function(config) { this.update = function(config) {

File diff suppressed because one or more lines are too long