Conflicts:
	build_support/mini_require.js
	support/cockpit
	support/pilot
This commit is contained in:
Joe Walker 2011-03-17 12:54:50 +00:00
commit a6aa2ec6ee
111 changed files with 7507 additions and 3756 deletions

View file

@ -48,7 +48,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
this.document = doc;
if (typeof column == "undefined")
this.setPosition(row.row, row.column)
this.setPosition(row.row, row.column);
else
this.setPosition(row, column);
@ -130,11 +130,20 @@ var Anchor = exports.Anchor = function(doc, row, column) {
}
}
this.setPosition(row, column);
this.setPosition(row, column, true);
};
this.setPosition = function(row, column) {
pos = this.$clipPositionToDocument(row, column);
this.setPosition = function(row, column, noClip) {
if (noClip) {
pos = {
row: row,
column: column
};
}
else {
pos = this.$clipPositionToDocument(row, column);
}
if (this.row == pos.row && this.column == pos.column)
return;

View file

@ -43,6 +43,14 @@ define(function(require, exports, module) {
var lang = require("pilot/lang");
var canon = require("pilot/canon");
function bindKey(win, mac) {
return {
win: win,
mac: mac,
sender: "editor"
};
}
canon.addCommand({
name: "null",
exec: function(env, args, request) { }
@ -50,14 +58,17 @@ canon.addCommand({
canon.addCommand({
name: "selectall",
bindKey: bindKey("Ctrl-A", "Command-A"),
exec: function(env, args, request) { env.editor.selectAll(); }
});
canon.addCommand({
name: "removeline",
bindKey: bindKey("Ctrl-D", "Command-D"),
exec: function(env, args, request) { env.editor.removeLines(); }
});
canon.addCommand({
name: "gotoline",
bindKey: bindKey("Ctrl-L", "Command-L"),
exec: function(env, args, request) {
var line = parseInt(prompt("Enter line number:"));
if (!isNaN(line)) {
@ -67,18 +78,22 @@ canon.addCommand({
});
canon.addCommand({
name: "togglecomment",
bindKey: bindKey("Ctrl-7", "Command-7"),
exec: function(env, args, request) { env.editor.toggleCommentLines(); }
});
canon.addCommand({
name: "findnext",
bindKey: bindKey("Ctrl-K", "Command-G"),
exec: function(env, args, request) { env.editor.findNext(); }
});
canon.addCommand({
name: "findprevious",
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
exec: function(env, args, request) { env.editor.findPrevious(); }
});
canon.addCommand({
name: "find",
bindKey: bindKey("Ctrl-F", "Command-F"),
exec: function(env, args, request) {
var needle = prompt("Find:");
env.editor.find(needle);
@ -86,6 +101,7 @@ canon.addCommand({
});
canon.addCommand({
name: "replace",
bindKey: bindKey("Ctrl-R", "Command-Option-F"),
exec: function(env, args, request) {
var needle = prompt("Find:");
if (!needle)
@ -98,6 +114,7 @@ canon.addCommand({
});
canon.addCommand({
name: "replaceall",
bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"),
exec: function(env, args, request) {
var needle = prompt("Find:");
if (!needle)
@ -110,186 +127,220 @@ canon.addCommand({
});
canon.addCommand({
name: "undo",
bindKey: bindKey("Ctrl-Z", "Command-Z"),
exec: function(env, args, request) { env.editor.undo(); }
});
canon.addCommand({
name: "redo",
exec: function(env, args, request) { env.editor.redo(); }
});
canon.addCommand({
name: "redo",
bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
exec: function(env, args, request) { env.editor.redo(); }
});
canon.addCommand({
name: "overwrite",
bindKey: bindKey("Insert", "Insert"),
exec: function(env, args, request) { env.editor.toggleOverwrite(); }
});
canon.addCommand({
name: "copylinesup",
bindKey: bindKey("Ctrl-Alt-Up", "Command-Option-Up"),
exec: function(env, args, request) { env.editor.copyLinesUp(); }
});
canon.addCommand({
name: "movelinesup",
bindKey: bindKey("Alt-Up", "Option-Up"),
exec: function(env, args, request) { env.editor.moveLinesUp(); }
});
canon.addCommand({
name: "selecttostart",
bindKey: bindKey("Alt-Shift-Up", "Command-Shift-Up"),
exec: function(env, args, request) { env.editor.getSelection().selectFileStart(); }
});
canon.addCommand({
name: "gotostart",
bindKey: bindKey("Ctrl-Home|Ctrl-Up", "Command-Home|Command-Up"),
exec: function(env, args, request) { env.editor.navigateFileStart(); }
});
canon.addCommand({
name: "selectup",
bindKey: bindKey("Shift-Up", "Shift-Up"),
exec: function(env, args, request) { env.editor.getSelection().selectUp(); }
});
canon.addCommand({
name: "golineup",
bindKey: bindKey("Up", "Up|Ctrl-P"),
exec: function(env, args, request) { env.editor.navigateUp(args.times); }
});
canon.addCommand({
name: "copylinesdown",
bindKey: bindKey("Ctrl-Alt-Down", "Command-Option-Down"),
exec: function(env, args, request) { env.editor.copyLinesDown(); }
});
canon.addCommand({
name: "movelinesdown",
bindKey: bindKey("Alt-Down", "Option-Down"),
exec: function(env, args, request) { env.editor.moveLinesDown(); }
});
canon.addCommand({
name: "selecttoend",
bindKey: bindKey("Alt-Shift-Down", "Command-Shift-Down"),
exec: function(env, args, request) { env.editor.getSelection().selectFileEnd(); }
});
canon.addCommand({
name: "gotoend",
bindKey: bindKey("Ctrl-End|Ctrl-Down", "Command-End|Command-Down"),
exec: function(env, args, request) { env.editor.navigateFileEnd(); }
});
canon.addCommand({
name: "selectdown",
bindKey: bindKey("Shift-Down", "Shift-Down"),
exec: function(env, args, request) { env.editor.getSelection().selectDown(); }
});
canon.addCommand({
name: "golinedown",
bindKey: bindKey("Down", "Down|Ctrl-N"),
exec: function(env, args, request) { env.editor.navigateDown(args.times); }
});
canon.addCommand({
name: "selectwordleft",
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
exec: function(env, args, request) { env.editor.getSelection().selectWordLeft(); }
});
canon.addCommand({
name: "gotowordleft",
bindKey: bindKey("Ctrl-Left", "Option-Left"),
exec: function(env, args, request) { env.editor.navigateWordLeft(); }
});
canon.addCommand({
name: "selecttolinestart",
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
});
canon.addCommand({
name: "gotolinestart",
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
exec: function(env, args, request) { env.editor.navigateLineStart(); }
});
canon.addCommand({
name: "selectleft",
bindKey: bindKey("Shift-Left", "Shift-Left"),
exec: function(env, args, request) { env.editor.getSelection().selectLeft(); }
});
canon.addCommand({
name: "gotoleft",
bindKey: bindKey("Left", "Left|Ctrl-B"),
exec: function(env, args, request) { env.editor.navigateLeft(args.times); }
});
canon.addCommand({
name: "selectwordright",
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
exec: function(env, args, request) { env.editor.getSelection().selectWordRight(); }
});
canon.addCommand({
name: "gotowordright",
bindKey: bindKey("Ctrl-Right", "Option-Right"),
exec: function(env, args, request) { env.editor.navigateWordRight(); }
});
canon.addCommand({
name: "selecttolineend",
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
});
canon.addCommand({
name: "gotolineend",
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
exec: function(env, args, request) { env.editor.navigateLineEnd(); }
});
canon.addCommand({
name: "selectright",
bindKey: bindKey("Shift-Right", "Shift-Right"),
exec: function(env, args, request) { env.editor.getSelection().selectRight(); }
});
canon.addCommand({
name: "gotoright",
bindKey: bindKey("Right", "Right|Ctrl-F"),
exec: function(env, args, request) { env.editor.navigateRight(args.times); }
});
canon.addCommand({
name: "selectpagedown",
bindKey: bindKey("Shift-PageDown", "Shift-PageDown"),
exec: function(env, args, request) { env.editor.selectPageDown(); }
});
canon.addCommand({
name: "pagedown",
bindKey: bindKey(null, "PageDown"),
exec: function(env, args, request) { env.editor.scrollPageDown(); }
});
canon.addCommand({
name: "gotopagedown",
bindKey: bindKey("PageDown", "Option-PageDown|Ctrl-V"),
exec: function(env, args, request) { env.editor.gotoPageDown(); }
});
canon.addCommand({
name: "selectpageup",
bindKey: bindKey("Shift-PageUp", "Shift-PageUp"),
exec: function(env, args, request) { env.editor.selectPageUp(); }
});
canon.addCommand({
name: "pageup",
bindKey: bindKey(null, "PageUp"),
exec: function(env, args, request) { env.editor.scrollPageUp(); }
});
canon.addCommand({
name: "gotopageup",
bindKey: bindKey("PageUp", "Option-PageUp"),
exec: function(env, args, request) { env.editor.gotoPageUp(); }
});
canon.addCommand({
name: "selectlinestart",
bindKey: bindKey("Shift-Home", "Shift-Home"),
exec: function(env, args, request) { env.editor.getSelection().selectLineStart(); }
});
canon.addCommand({
name: "gotolinestart",
exec: function(env, args, request) { env.editor.navigateLineStart(); }
});
canon.addCommand({
name: "selectlineend",
bindKey: bindKey("Shift-End", "Shift-End"),
exec: function(env, args, request) { env.editor.getSelection().selectLineEnd(); }
});
canon.addCommand({
name: "gotolineend",
exec: function(env, args, request) { env.editor.navigateLineEnd(); }
});
canon.addCommand({
name: "del",
bindKey: bindKey("Delete", "Delete|Ctrl-D"),
exec: function(env, args, request) { env.editor.removeRight(); }
});
canon.addCommand({
name: "backspace",
bindKey: bindKey(
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
),
exec: function(env, args, request) { env.editor.removeLeft(); }
});
canon.addCommand({
name: "removetolinestart",
bindKey: bindKey(null, "Option-Backspace"),
exec: function(env, args, request) { env.editor.removeToLineStart(); }
});
canon.addCommand({
name: "removetolineend",
bindKey: bindKey(null, "Ctrl-K"),
exec: function(env, args, request) { env.editor.removeToLineEnd(); }
});
canon.addCommand({
name: "removewordleft",
bindKey: bindKey(null, "Alt-Backspace|Ctrl-Alt-Backspace"),
exec: function(env, args, request) { env.editor.removeWordLeft(); }
});
canon.addCommand({
name: "removewordright",
bindKey: bindKey(null, "Alt-Delete"),
exec: function(env, args, request) { env.editor.removeWordRight(); }
});
canon.addCommand({
name: "outdent",
bindKey: bindKey("Shift-Tab", "Shift-Tab"),
exec: function(env, args, request) { env.editor.blockOutdent(); }
});
canon.addCommand({
name: "indent",
bindKey: bindKey("Tab", "Tab"),
exec: function(env, args, request) { env.editor.indent(); }
});
canon.addCommand({
@ -300,16 +351,18 @@ canon.addCommand({
});
canon.addCommand({
name: "centerselection",
bindKey: bindKey("Ctrl-L", "Ctrl-L"),
exec: function(env, args, request) { env.editor.centerSelection(); }
});
canon.addCommand({
name: "splitline",
bindKey: bindKey(null, "Ctrl-O"),
exec: function(env, args, request) { env.editor.splitLine(); }
});
canon.addCommand({
name: "transposeletters",
bindKey: bindKey("Ctrl-T", "Ctrl-T"),
exec: function(env, args, request) { env.editor.transposeLetters(); }
});
});
});

View file

@ -152,3 +152,7 @@
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.ace_dragging .ace_marker-layer, .ace_dragging .ace_text-layer {
cursor: move;
}

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -20,6 +21,7 @@
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Mihai Sucan <mihai DOT sucan AT gmail DOT com>
*
* 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
@ -84,7 +86,7 @@ var EditSession = function(text, mode) {
this.onChange = function(e) {
var delta = e.data;
this.$modified = true;
if (!this.$fromUndo && this.$undoManager) {
if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
this.$deltas.push(delta);
this.$informUndoManager.schedule();
}
@ -96,7 +98,7 @@ var EditSession = function(text, mode) {
this.setValue = function(text) {
this.doc.setValue(text);
this.$deltas = [];
this.$undoManager.reset();
this.getUndoManager().reset();
};
this.getValue =
@ -175,6 +177,22 @@ var EditSession = function(text, mode) {
return this.$useSoftTabs && (position.column % this.$tabSize == 0);
};
this.$overwrite = false;
this.setOverwrite = function(overwrite) {
if (this.$overwrite == overwrite) return;
this.$overwrite = overwrite;
this._dispatchEvent("changeOverwrite");
};
this.getOverwrite = function() {
return this.$overwrite;
};
this.toggleOverwrite = function() {
this.setOverwrite(!this.$overwrite);
};
this.getBreakpoints = function() {
return this.$breakpoints;
};
@ -326,6 +344,24 @@ var EditSession = function(text, mode) {
return this.doc.getNewLineMode();
};
this.$useWorker = true;
this.setUseWorker = function(useWorker) {
if (this.$useWorker == useWorker)
return;
if (useWorker && !this.$worker && window.Worker)
this.$worker = mode.createWorker(this);
if (!useWorker && this.$worker) {
this.$worker.terminate();
this.$worker = null;
}
};
this.getUseWorker = function() {
return this.$useWorker;
};
this.$mode = null;
this.setMode = function(mode) {
if (this.$mode === mode) return;
@ -333,7 +369,7 @@ var EditSession = function(text, mode) {
if (this.$worker)
this.$worker.terminate();
if (window.Worker && !require.noWorker)
if (this.$useWorker && window.Worker && !require.noWorker)
this.$worker = mode.createWorker(this);
else
this.$worker = null;
@ -599,6 +635,45 @@ var EditSession = function(text, mode) {
return this.doc.replace(range, text);
};
/**
* Move a range of text from the given range to the given position.
*
* @param fromRange {Range} The range of text you want moved within the
* document.
* @param toPosition {Object} The location (row and column) where you want
* to move the text to.
* @return {Range} The new range where the text was moved to.
*/
this.moveText = function(fromRange, toPosition) {
var text = this.getTextRange(fromRange);
this.remove(fromRange);
var toRow = toPosition.row;
var toColumn = toPosition.column;
// Make sure to update the insert location, when text is removed in
// front of the chosen point of insertion.
if (!fromRange.isMultiLine() && fromRange.start.row == toRow &&
fromRange.end.column < toColumn)
toColumn -= text.length;
if (fromRange.isMultiLine() && fromRange.end.row < toRow) {
var lines = this.doc.$split(text);
toRow -= lines.length - 1;
}
var endRow = toRow + fromRange.end.row - fromRange.start.row;
var endColumn = fromRange.isMultiLine() ?
fromRange.end.column :
toColumn + fromRange.end.column - fromRange.start.column;
var toRange = new Range(toRow, toColumn, endRow, endColumn);
this.insert(toRange.start, text);
return toRange;
};
this.indentRows = function(startRow, endRow, indentString) {
indentString = indentString.replace(/\t/g, this.getTabString());
for (var row=startRow; row<=endRow; row++) {

View file

@ -113,7 +113,7 @@ var Editor =function(renderer, session) {
this.getKeyboardHandler = function() {
return this.keyBinding.getKeyboardHandler();
}
};
this.setSession = function(session) {
if (this.session == session) return;
@ -121,14 +121,15 @@ var Editor =function(renderer, session) {
if (this.session) {
var oldSession = this.session;
this.session.removeEventListener("change", this.$onDocumentChange);
this.session.removeEventListener("changeMode", this.$onDocumentModeChange);
this.session.removeEventListener("changeTabSize", this.$onDocumentChangeTabSize);
this.session.removeEventListener("changeWrapLimit", this.$onDocumentChangeWrapLimit);
this.session.removeEventListener("changeWrapMode", this.$onDocumentChangeWrapMode);
this.session.removeEventListener("changeMode", this.$onChangeMode);
this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
this.session.removeEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
this.session.removeEventListener("changeAnnotation", this.$onDocumentChangeAnnotation);
this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
var selection = this.session.getSelection();
selection.removeEventListener("changeCursor", this.$onCursorChange);
@ -143,17 +144,17 @@ var Editor =function(renderer, session) {
session.addEventListener("change", this.$onDocumentChange);
this.renderer.setSession(session);
this.$onDocumentModeChange = this.onDocumentModeChange.bind(this);
session.addEventListener("changeMode", this.$onDocumentModeChange);
this.$onChangeMode = this.onChangeMode.bind(this);
session.addEventListener("changeMode", this.$onChangeMode);
this.$onDocumentChangeTabSize = this.renderer.updateText.bind(this.renderer);
session.addEventListener("changeTabSize", this.$onDocumentChangeTabSize);
this.$onChangeTabSize = this.renderer.updateText.bind(this.renderer);
session.addEventListener("changeTabSize", this.$onChangeTabSize);
this.$onDocumentChangeWrapLimit = this.onDocumentChangeWrapLimit.bind(this);
session.addEventListener("changeWrapLimit", this.$onDocumentChangeWrapLimit);
this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
this.$onDocumentChangeWrapMode = this.onDocumentChangeWrapMode.bind(this);
session.addEventListener("changeWrapMode", this.$onDocumentChangeWrapMode);
this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
@ -161,21 +162,22 @@ var Editor =function(renderer, session) {
this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
this.$onDocumentChangeBreakpoint = this.onDocumentChangeBreakpoint.bind(this);
this.session.addEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
this.$onDocumentChangeAnnotation = this.onDocumentChangeAnnotation.bind(this);
this.session.addEventListener("changeAnnotation", this.$onDocumentChangeAnnotation);
this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
this.$onCursorChange = this.onCursorChange.bind(this);
this.session.addEventListener("changeOverwrite", this.$onCursorChange);
this.selection = session.getSelection();
this.$onCursorChange = this.onCursorChange.bind(this);
this.selection.addEventListener("changeCursor", this.$onCursorChange);
this.$onSelectionChange = this.onSelectionChange.bind(this);
this.selection.addEventListener("changeSelection", this.$onSelectionChange);
this.onDocumentModeChange();
this.onChangeMode();
this.bgTokenizer.setDocument(session.getDocument());
this.bgTokenizer.start(0);
@ -183,8 +185,8 @@ var Editor =function(renderer, session) {
this.onSelectionChange();
this.onChangeFrontMarker();
this.onChangeBackMarker();
this.onDocumentChangeBreakpoint();
this.onDocumentChangeAnnotation();
this.onChangeBreakpoint();
this.onChangeAnnotation();
this.renderer.scrollToRow(session.getScrollTopRow());
this.renderer.updateFull();
@ -243,13 +245,16 @@ var Editor =function(renderer, session) {
};
this.focus = function() {
// Safari need the timeout
// Safari needs the timeout
// iOS and Firefox need it called immediately
// to be on the save side we do both
// except for IE
var _self = this;
setTimeout(function() {
_self.textInput.focus();
});
if (!useragent.isIE) {
setTimeout(function() {
_self.textInput.focus();
});
}
this.textInput.focus();
};
@ -281,7 +286,7 @@ var Editor =function(renderer, session) {
this.renderer.updateLines(range.start.row, lastRow);
// update cursor because tab characters can influence the cursor position
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
this.renderer.updateCursor();
};
this.onTokenizerUpdate = function(e) {
@ -290,7 +295,7 @@ var Editor =function(renderer, session) {
};
this.onCursorChange = function(e) {
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
this.renderer.updateCursor();
if (!this.$blockScrolling) {
this.renderer.scrollCursorIntoView();
@ -347,15 +352,15 @@ var Editor =function(renderer, session) {
this.renderer.updateBackMarkers();
};
this.onDocumentChangeBreakpoint = function() {
this.onChangeBreakpoint = function() {
this.renderer.setBreakpoints(this.session.getBreakpoints());
};
this.onDocumentChangeAnnotation = function() {
this.onChangeAnnotation = function() {
this.renderer.setAnnotations(this.session.getAnnotations());
};
this.onDocumentModeChange = function() {
this.onChangeMode = function() {
var mode = this.session.getMode();
if (this.mode == mode)
return;
@ -374,12 +379,11 @@ var Editor =function(renderer, session) {
this.renderer.setTokenizer(this.bgTokenizer);
};
this.onDocumentChangeWrapLimit = function() {
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
this.onChangeWrapLimit = function() {
this.renderer.updateFull();
};
this.onDocumentChangeWrapMode = function() {
this.onChangeWrapMode = function() {
this.renderer.onResize(true);
};
@ -413,7 +417,8 @@ var Editor =function(renderer, session) {
if (!this.selection.isEmpty()) {
var cursor = this.session.remove(this.getSelectionRange());
this.clearSelection();
} else if (this.$overwrite){
}
else if (this.session.getOverwrite()) {
var range = new Range.fromPoints(cursor, cursor);
range.end.column += text.length;
this.session.remove(range);
@ -481,25 +486,16 @@ var Editor =function(renderer, session) {
this.keyBinding.onCommandKey(e, hashId, keyCode);
};
this.$overwrite = false;
this.setOverwrite = function(overwrite) {
if (this.$overwrite == overwrite) return;
this.$overwrite = overwrite;
this.$blockScrolling += 1;
this.onCursorChange();
this.$blockScrolling -= 1;
this._dispatchEvent("changeOverwrite", {data: overwrite});
this.session.setOverwrite();
};
this.getOverwrite = function() {
return this.$overwrite;
return this.session.getOverwrite();
};
this.toggleOverwrite = function() {
this.setOverwrite(!this.$overwrite);
this.session.toggleOverwrite();
};
this.setScrollSpeed = function(speed) {
@ -762,6 +758,13 @@ var Editor =function(renderer, session) {
});
};
this.moveText = function(range, toPosition) {
if (this.$readOnly)
return null;
return this.session.moveText(range, toPosition);
};
this.copyLinesUp = function() {
if (this.$readOnly)
return;
@ -910,7 +913,7 @@ var Editor =function(renderer, session) {
this.getCursorPositionScreen = function() {
return this.session.documentToScreenPosition(this.getCursorPosition());
}
};
this.getSelectionRange = function() {
return this.selection.getRange();

View file

@ -42,19 +42,13 @@ var useragent = require("pilot/useragent");
var keyUtil = require("pilot/keys");
var event = require("pilot/event");
var settings = require("pilot/settings").settings;
var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
var default_mac = require("ace/keyboard/keybinding/default_mac").bindings;
var default_win = require("ace/keyboard/keybinding/default_win").bindings;
var canon = require("pilot/canon");
require("ace/commands/default_commands");
var KeyBinding = function(editor, config) {
var KeyBinding = function(editor) {
this.$editor = editor;
this.$data = { };
this.$keyboardHandler = null;
this.$defaulKeyboardHandler = new HashHandler(config || (useragent.isMac
? default_mac
: default_win));
};
(function() {
@ -70,7 +64,9 @@ var KeyBinding = function(editor, config) {
};
this.$callKeyboardHandler = function (e, hashId, keyOrText, keyCode) {
var toExecute;
var env = {editor: this.$editor},
toExecute;
if (this.$keyboardHandler) {
toExecute =
this.$keyboardHandler.handleKeyboard(this.$data, hashId, keyOrText, keyCode, e);
@ -78,13 +74,23 @@ var KeyBinding = function(editor, config) {
// If there is nothing to execute yet, then use the default keymapping.
if (!toExecute || !toExecute.command) {
toExecute = this.$defaulKeyboardHandler.
handleKeyboard(this.$data, hashId, keyOrText, keyCode, e);
if (hashId != 0 || keyCode != 0) {
toExecute = {
command: canon.findKeyCommand(env, "editor", hashId, keyOrText)
}
} else {
toExecute = {
command: "inserttext",
args: {
text: keyOrText
}
}
}
}
if (toExecute) {
var success = canon.exec(toExecute.command,
{editor: this.$editor}, toExecute.args);
env, "editor", toExecute.args);
if (success) {
return event.stopEvent(e);
}
@ -92,10 +98,8 @@ var KeyBinding = function(editor, config) {
};
this.onCommandKey = function(e, hashId, keyCode) {
key = (keyUtil[keyCode] ||
String.fromCharCode(keyCode)).toLowerCase();
this.$callKeyboardHandler(e, hashId, key, keyCode);
var keyString = keyUtil.keyCodeToString(keyCode);
this.$callKeyboardHandler(e, hashId, keyString, keyCode);
};
this.onTextInput = function(text) {

View file

@ -1,97 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* 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
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
exports.bindings = {
"selectall": "Command-A",
"removeline": "Command-D",
"gotoline": "Command-L",
"togglecomment": "Command-7",
"findnext": "Command-G",
"findprevious": "Command-Shift-G",
"find": "Command-F",
"replace": "Command-R",
"undo": "Command-Z",
"redo": "Command-Shift-Z|Command-Y",
"overwrite": "Insert",
"copylinesup": "Command-Option-Up",
"movelinesup": "Option-Up",
"selecttostart": "Command-Shift-Up",
"gotostart": "Command-Home|Command-Up",
"selectup": "Shift-Up",
"golineup": "Up|Ctrl-P",
"copylinesdown": "Command-Option-Down",
"movelinesdown": "Option-Down",
"selecttoend": "Command-Shift-Down",
"gotoend": "Command-End|Command-Down",
"selectdown": "Shift-Down",
"golinedown": "Down|Ctrl-N",
"selectwordleft": "Option-Shift-Left",
"gotowordleft": "Option-Left",
"selecttolinestart": "Command-Shift-Left",
"gotolinestart": "Command-Left|Home|Ctrl-A",
"selectleft": "Shift-Left",
"gotoleft": "Left|Ctrl-B",
"selectwordright": "Option-Shift-Right",
"gotowordright": "Option-Right",
"selecttolineend": "Command-Shift-Right",
"gotolineend": "Command-Right|End|Ctrl-E",
"selectright": "Shift-Right",
"gotoright": "Right|Ctrl-F",
"selectpagedown": "Shift-PageDown",
"pagedown": "PageDown",
"gotopagedown": "Option-PageDown|Ctrl-V",
"selectpageup": "Shift-PageUp",
"pageup": "PageUp",
"gotopageup": "Option-PageUp",
"selectlinestart": "Shift-Home",
"selectlineend": "Shift-End",
"del": "Delete|Ctrl-D",
"backspace": "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H",
"removetolineend": "Ctrl-K",
"removetolinestart": "Option-Backspace",
"removewordleft": "Alt-Backspace|Ctrl-Alt-Backspace",
"removewordright": "Alt-Delete",
"outdent": "Shift-Tab",
"indent": "Tab",
"transposeletters": "Ctrl-T",
"splitline": "Ctrl-O",
"centerselection": "Ctrl-L"
};
});

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -39,10 +40,11 @@ define(function(require, exports, module) {
var event = require("pilot/event");
var useragent = require("pilot/useragent");
var dom = require("pilot/dom");
var TextInput = function(parentNode, host) {
var text = document.createElement("textarea");
var text = dom.createElement("textarea");
text.style.left = "-10000px";
parentNode.appendChild(text);

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -41,11 +42,11 @@ define(function(require, exports, module) {
var dom = require("pilot/dom");
var Cursor = function(parentEl) {
this.element = document.createElement("div");
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_cursor-layer";
parentEl.appendChild(this.element);
this.cursor = document.createElement("div");
this.cursor = dom.createElement("div");
this.cursor.className = "ace_cursor";
this.isVisible = false;
@ -57,11 +58,6 @@ var Cursor = function(parentEl) {
this.session = session;
};
this.setCursor = function(position, overwrite) {
this.position = position;
this.overwrite = overwrite;
};
this.hideCursor = function() {
this.isVisible = false;
if (this.cursor.parentNode) {
@ -95,14 +91,15 @@ var Cursor = function(parentEl) {
};
this.getPixelPosition = function(onScreen) {
if (!this.config || !this.position) {
if (!this.config || !this.session) {
return {
left : 0,
top : 0
};
}
var pos = this.session.documentToScreenPosition(this.position);
var position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position);
var cursorLeft = Math.round(pos.column * this.config.characterWidth);
var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
this.config.lineHeight;
@ -114,9 +111,6 @@ var Cursor = function(parentEl) {
};
this.update = function(config) {
if (!this.position)
return;
this.config = config;
this.pixelPos = this.getPixelPosition(true);
@ -130,7 +124,7 @@ var Cursor = function(parentEl) {
this.element.appendChild(this.cursor);
}
if (this.overwrite) {
if (this.session.getOverwrite()) {
dom.addCssClass(this.cursor, "ace_overwrite");
} else {
dom.removeCssClass(this.cursor, "ace_overwrite");

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -41,7 +42,7 @@ define(function(require, exports, module) {
var dom = require("pilot/dom");
var Gutter = function(parentEl) {
this.element = document.createElement("div");
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_gutter-layer";
parentEl.appendChild(this.element);
@ -83,7 +84,7 @@ var Gutter = function(parentEl) {
};
for (var i=0; i<rowAnnotations.length; i++) {
var annotation = rowAnnotations[i];
rowInfo.text.push(annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&rsquo;").replace(/</, "&lt;"));
rowInfo.text.push(annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</, "&lt;"));
var type = annotation.type;
if (type == "error")
rowInfo.className = "ace_error";
@ -110,7 +111,6 @@ var Gutter = function(parentEl) {
annotation.className,
"' title='", annotation.text.join("\n"),
"' style='height:", this.session.getRowHeight(config, i), "px;'>", (i+1), "</div>");
html.push("</div>");
}
this.element = dom.setInnerHtml(this.element, html.join(""));
this.element.style.height = config.minHeight + "px";

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -42,7 +43,7 @@ var Range = require("ace/range").Range;
var dom = require("pilot/dom");
var Marker = function(parentEl) {
this.element = document.createElement("div");
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_marker-layer";
parentEl.appendChild(this.element);
};

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -21,6 +22,7 @@
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian.viereck@gmail.com>
* Mihai Sucan <mihai.sucan@gmail.com>
*
* 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
@ -44,11 +46,11 @@ var lang = require("pilot/lang");
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var Text = function(parentEl) {
this.element = document.createElement("div");
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_text-layer";
parentEl.appendChild(this.element);
this.$characterSize = this.$measureSizes();
this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
this.$pollSizeChanges();
};
@ -73,14 +75,18 @@ var Text = function(parentEl) {
return this.$characterSize.width || 1;
};
this.checkForSizeChanges = function() {
var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$characterSize = size;
this._dispatchEvent("changeCharaterSize", {data: size});
}
};
this.$pollSizeChanges = function() {
var self = this;
setInterval(function() {
var size = self.$measureSizes();
if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) {
self.$characterSize = size;
self._dispatchEvent("changeCharaterSize", {data: size});
}
self.checkForSizeChanges();
}, 500);
};
@ -90,27 +96,36 @@ var Text = function(parentEl) {
fontWeight : 1,
fontStyle : 1,
lineHeight : 1
},
};
this.$measureSizes = function() {
var n = 1000;
if (!this.$measureNode) {
var measureNode = this.$measureNode = document.createElement("div");
var style = measureNode.style;
var measureNode = this.$measureNode = dom.createElement("div");
var style = measureNode.style;
style.width = style.height = "auto";
style.left = style.top = (-n * 40) + "px";
style.width = style.height = "auto";
style.left = style.top = (-n * 40) + "px";
style.visibility = "hidden";
style.position = "absolute";
style.overflow = "visible";
style.whiteSpace = "nowrap";
style.visibility = "hidden";
style.position = "absolute";
style.overflow = "visible";
style.whiteSpace = "nowrap";
// in FF 3.6 monospace fonts can have a fixed sub pixel width.
// that's why we have to measure many characters
// Note: characterWidth can be a float!
measureNode.innerHTML = lang.stringRepeat("Xy", n);
if (document.body) {
document.body.appendChild(measureNode);
} else {
var container = this.element.parentNode;
while (!dom.hasCssClass(container, "ace_editor"))
container = container.parentNode;
container.appendChild(measureNode);
}
// in FF 3.6 monospace fonts can have a fixed sub pixel width.
// that's why we have to measure many characters
// Note: characterWidth can be a float!
measureNode.innerHTML = lang.stringRepeat("Xy", n);
document.body.insertBefore(measureNode, document.body.firstChild);
}
var style = this.$measureNode.style;
@ -123,6 +138,12 @@ var Text = function(parentEl) {
height: this.$measureNode.offsetHeight,
width: this.$measureNode.offsetWidth / (n * 2)
};
// Size and width can be null if the editor is not visible or
// detached from the document
if (size.width == 0 && size.height == 0)
return null;
return size;
};
@ -144,12 +165,12 @@ var Text = function(parentEl) {
if (this.showInvisibles) {
var halfTab = (tabSize) / 2;
this.$tabString = "<span class='ace_invisible'>"
+ new Array(Math.floor(halfTab)).join("&nbsp;")
+ new Array(Math.floor(halfTab)).join("&#160;")
+ this.TAB_CHAR
+ new Array(Math.ceil(halfTab)+1).join("&nbsp;")
+ new Array(Math.ceil(halfTab)+1).join("&#160;")
+ "</span>";
} else {
this.$tabString = new Array(tabSize+1).join("&nbsp;");
this.$tabString = new Array(tabSize+1).join("&#160;");
}
};
@ -220,7 +241,7 @@ var Text = function(parentEl) {
var fragment = document.createDocumentFragment();
var tokens = this.tokenizer.getTokens(firstRow, lastRow);
for (var row=firstRow; row<=lastRow; row++) {
var lineEl = document.createElement("div");
var lineEl = dom.createElement("div");
lineEl.className = "ace_line";
var style = lineEl.style;
style.height = this.session.getRowHeight(config, row) + "px";
@ -228,7 +249,7 @@ var Text = function(parentEl) {
var html = [];
if (tokens.length > row-firstRow)
this.$renderLine(html, row, tokens[row-firstRow].tokens);
this.$renderLine(html, row, tokens[row-firstRow].tokens);
// don't use setInnerHtml since we are working with an empty DIV
lineEl.innerHTML = html.join("");
fragment.appendChild(lineEl);
@ -261,7 +282,7 @@ var Text = function(parentEl) {
var spaceRe = /( +)|([\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000])/g;
var spaceReplace = function(space) {
if (space.charCodeAt(0) == 32)
return new Array(space.length+1).join("&nbsp;");
return new Array(space.length+1).join("&#160;");
else {
var space = new Array(space.length+1).join(self.SPACE_CHAR);
return "<span class='ace_invisible'>" + space + "</span>";
@ -271,7 +292,7 @@ var Text = function(parentEl) {
}
else {
var spaceRe = /[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]/g;
var spaceReplace = "&nbsp;";
var spaceReplace = "&#160;";
}
var _self = this;

54
lib/ace/mode/csharp.js Normal file
View file

@ -0,0 +1,54 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var CSharpHighlightRules = require("ace/mode/csharp_highlight_rules").CSharpHighlightRules;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Mode = function() {
this.$tokenizer = new Tokenizer(new CSharpHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, TextMode);
(function() {
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {
indent += tab;
}
}
return indent;
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
this.createWorker = function(session) {
return null;
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,123 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var lang = require("pilot/lang");
var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var CSharpHighlightRules = function() {
var docComment = new DocCommentHighlightRules();
var keywords = lang.arrayToMap(
("abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic").split("|")
);
var buildinConstants = lang.arrayToMap(
("null|true|false").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
docComment.getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "comment", // multi line comment
regex : "\\/\\*\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
]
};
this.addRules(docComment.getRules(), "doc-");
this.$rules["doc-start"][0].next = "start";
};
oop.inherits(CSharpHighlightRules, TextHighlightRules);
exports.CSharpHighlightRules = CSharpHighlightRules;
});

View file

@ -12,13 +12,13 @@ var JavaHighlightRules = function() {
// taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
var keywords = lang.arrayToMap(
("abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized" +
"boolean|do|if|private|this" +
"break|double|implements|protected|throw" +
"byte|else|import|public|throws" +
"case|enum|instanceof|return|transient" +
"catch|extends|int|short|try" +
"char|final|interface|static|void" +
"assert|default|goto|package|synchronized|" +
"boolean|do|if|private|this|" +
"break|double|implements|protected|throw|" +
"byte|else|import|public|throws|" +
"case|enum|instanceof|return|transient|" +
"catch|extends|int|short|try|" +
"char|final|interface|static|void|" +
"class|finally|long|strictfp|volatile|" +
"const|float|native|super|while").split("|")
);
@ -27,7 +27,36 @@ var JavaHighlightRules = function() {
("null|Infinity|NaN|undefined").split("|")
);
var langClasses = lang.arrayToMap(
("AbstractMethodError|AssertionError|ClassCircularityError|"+
"ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
"ExceptionInInitializerError|IllegalAccessError|"+
"IllegalThreadStateException|InstantiationError|InternalError|"+
"NegativeArraySizeException|NoSuchFieldError|Override|Process|"+
"ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+
"SuppressWarnings|TypeNotPresentException|UnknownError|"+
"UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+
"InstantiationException|IndexOutOfBoundsException|"+
"ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+
"NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+
"SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+
"InterruptedException|NoSuchMethodException|IllegalAccessException|"+
"UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+
"Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+
"NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+
"NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+
"Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+
"Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+
"StackOverflowError|OutOfMemoryError|VirtualMachineError|"+
"ArrayStoreException|ClassCastException|LinkageError|"+
"NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+
"Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+
"Cloneable|Class|CharSequence|Comparable|String|Object").split("|")
);
var importClasses = lang.arrayToMap(
("").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
@ -70,6 +99,10 @@ var JavaHighlightRules = function() {
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (langClasses.hasOwnProperty(value))
return "support.function";
else if (importClasses.hasOwnProperty(value))
return "support.function";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else

View file

@ -65,102 +65,105 @@ var JavaScriptHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
docComment.getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
regex : '["].*\\\\$',
next : "qqstring"
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
regex : "['].*\\\\$",
next : "qstring"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else if (futureReserved.hasOwnProperty(value))
return "invalid.illegal";
else if (value == "debugger")
return "invalid.deprecated";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
{
token : "comment",
regex : "\\/\\/.*$"
},
docComment.getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
regex : '["].*\\\\$',
next : "qqstring"
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
regex : "['].*\\\\$",
next : "qstring"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else if (futureReserved.hasOwnProperty(value))
return "invalid.illegal";
else if (value == "debugger")
return "invalid.deprecated";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token: "comment",
regex: "^#!.*$"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
]
};

View file

@ -449,7 +449,7 @@ var PhpHighlightRules = function() {
);
var builtinVariables = lang.arrayToMap(
('$_GLOBALS|$_SERVER|$_GET|$_POST|$_FILES|$_REQUEST|$_SESSION|$_ENV|$_COOKIE|$php_errormsg|$HTTP_RAW_POST_DATA|' +
('$GLOBALS|$_SERVER|$_GET|$_POST|$_FILES|$_REQUEST|$_SESSION|$_ENV|$_COOKIE|$php_errormsg|$HTTP_RAW_POST_DATA|' +
'$http_response_header|$argc|$argv').split('|')
);

93
lib/ace/mode/svg.js Normal file
View file

@ -0,0 +1,93 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* 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
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var XmlMode = require("ace/mode/text").Mode;
var JavaScriptMode = require("ace/mode/javascript").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var SvgHighlightRules = require("ace/mode/svg_highlight_rules").SvgHighlightRules;
var Mode = function() {
this.$tokenizer = new Tokenizer(new SvgHighlightRules().getRules());
this.$js = new JavaScriptMode();
};
oop.inherits(Mode, XmlMode);
(function() {
this.toggleCommentLines = function(state, doc, startRow, endRow) {
this.$delegate("toggleCommentLines", arguments, function() {
return 0;
});
};
this.getNextLineIndent = function(state, line, tab) {
var self = this;
return this.$delegate("getNextLineIndent", arguments, function() {
return self.$getIndent(line);
});
};
this.checkOutdent = function(state, line, input) {
return this.$delegate("checkOutdent", arguments, function() {
return false;
});
};
this.autoOutdent = function(state, doc, row) {
this.$delegate("autoOutdent", arguments);
};
this.$delegate = function(method, args, defaultHandler) {
var state = args[0];
var split = state.split("js-");
if (!split[0] && split[1]) {
args[0] = split[1];
return this.$js[method].apply(this.$js, args);
}
return defaultHandler ? defaultHandler() : undefined;
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -37,52 +37,51 @@
define(function(require, exports, module) {
exports.bindings = {
"selectall": "Ctrl-A",
"removeline": "Ctrl-D",
"gotoline": "Ctrl-L",
"togglecomment": "Ctrl-7",
"findnext": "Ctrl-K",
"findprevious": "Ctrl-Shift-K",
"find": "Ctrl-F",
"replace": "Ctrl-R",
"undo": "Ctrl-Z",
"redo": "Ctrl-Shift-Z|Ctrl-Y",
"overwrite": "Insert",
"copylinesup": "Ctrl-Alt-Up",
"movelinesup": "Alt-Up",
"selecttostart": "Alt-Shift-Up",
"gotostart": "Ctrl-Home|Ctrl-Up",
"selectup": "Shift-Up",
"golineup": "Up",
"copylinesdown": "Ctrl-Alt-Down",
"movelinesdown": "Alt-Down",
"selecttoend": "Alt-Shift-Down",
"gotoend": "Ctrl-End|Ctrl-Down",
"selectdown": "Shift-Down",
"golinedown": "Down",
"selectwordleft": "Ctrl-Shift-Left",
"gotowordleft": "Ctrl-Left",
"selecttolinestart": "Alt-Shift-Left",
"gotolinestart": "Alt-Left|Home",
"selectleft": "Shift-Left",
"gotoleft": "Left",
"selectwordright": "Ctrl-Shift-Right",
"gotowordright": "Ctrl-Right",
"selecttolineend": "Alt-Shift-Right",
"gotolineend": "Alt-Right|End",
"selectright": "Shift-Right",
"gotoright": "Right",
"selectpagedown": "Shift-PageDown",
"gotopagedown": "PageDown",
"selectpageup": "Shift-PageUp",
"gotopageup": "PageUp",
"selectlinestart": "Shift-Home",
"selectlineend": "Shift-End",
"del": "Delete",
"backspace": "Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
"outdent": "Shift-Tab",
"indent": "Tab"
var oop = require("pilot/oop");
var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
var XmlHighlightRules = require("ace/mode/xml_highlight_rules").XmlHighlightRules;
var SvgHighlightRules = function() {
XmlHighlightRules.call(this);
this.$rules.start.splice(3, 0, {
token : "text",
regex : "<(?=\s*script)",
next : "script"
});
this.$rules.script = [{
token : "text",
regex : ">",
next : "js-start"
}, {
token : "keyword",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "text",
regex : "\\s+"
}, {
token : "string",
regex : '".*?"'
}, {
token : "string",
regex : "'.*?'"
}];
var jsRules = new JavaScriptHighlightRules().getRules();
this.addRules(jsRules, "js-");
this.$rules["js-start"].unshift({
token: "comment",
regex: "\\/\\/.*(?=<\\/script>)",
next: "tag"
}, {
token: "text",
regex: "<\\/(?=script)",
next: "tag"
});
};
oop.inherits(SvgHighlightRules, XmlHighlightRules);
exports.SvgHighlightRules = SvgHighlightRules;
});

76
lib/ace/mode/textile.js Normal file
View file

@ -0,0 +1,76 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kelley van Evert <kelley.vanevert@gmail.com>
*
* 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
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var TextileHighlightRules = require("ace/mode/textile_highlight_rules").TextileHighlightRules;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Range = require("ace/range").Range;
var Mode = function()
{
this.$tokenizer = new Tokenizer(new TextileHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, TextMode);
(function()
{
this.getNextLineIndent = function(state, line, tab)
{
if (state == "intag")
return tab;
return "";
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,110 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kelley van Evert <kelley.vanevert@gmail.com>
*
* 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
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var TextileHighlightRules = function()
{
/*
var phraseModifiers = lang.arrayToMap(
("_|*|__|**|??|-|+|^|%|@").split("|")
);
var blockModifiers = lang.arrayToMap(
("h1|h2|h3|h4|h5|h6|bq|p|bc|pre").split("|")
);
*/
/*
var punctuation = lang.arrayToMap(
("-|--|(tm)|(r)|(c)").split("|")
);
*/
this.$rules = {
"start" : [
{
token : "keyword", // start of block
regex : "h1|h2|h3|h4|h5|h6|bq|p|bc|pre",
next : "blocktag"
},
{
token : "keyword",
regex : "[\\*]+|[#]+"
},
{
token : "text",
regex : ".+"
}
],
"blocktag" : [
{
token : "keyword",
regex : "\\. ",
next : "start",
},
{
token : "keyword",
regex : "\\(",
next : "blocktagproperties"
},
],
"blocktagproperties" : [
{
token : "keyword",
regex : "\\)",
next : "blocktag"
},
{
token : "string",
regex : "[a-zA-Z0-9\\-_]+"
},
{
token : "keyword",
regex : "#"
},
]
};
};
oop.inherits(TextileHighlightRules, TextHighlightRules);
exports.TextileHighlightRules = TextileHighlightRules;
});

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -20,6 +21,7 @@
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Mihai Sucan <mihai DOT sucan AT gmail DOT com>
*
* 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
@ -38,6 +40,14 @@
define(function(require, exports, module) {
var event = require("pilot/event");
var dom = require("pilot/dom");
var STATE_UNKNOWN = 0;
var STATE_SELECT = 1;
var STATE_DRAG = 2;
var DRAG_TIMER = 250; // milliseconds
var DRAG_OFFSET = 5; // pixels
var MouseHandler = function(editor) {
this.editor = editor;
@ -67,40 +77,58 @@ var MouseHandler = function(editor) {
this.getScrollSpeed = function() {
return this.$scrollSpeed;
};
this.$getEventPosition = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
var pos = this.editor.renderer.screenToTextCoordinates(pageX, pageY);
pos.row = Math.max(0, Math.min(pos.row, this.editor.session.getLength()-1));
return pos;
};
this.$distance = function(ax, ay, bx, by) {
return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
};
this.onMouseDown = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
var pos = this.$getEventPosition(e);
var editor = this.editor;
var self = this;
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
var state = STATE_UNKNOWN;
var inSelection = false;
var pos = editor.renderer.screenToTextCoordinates(pageX, pageY);
pos.row = Math.max(0, Math.min(pos.row, editor.session.getLength()-1));
var button = event.getButton(e)
if (button != 0) {
var isEmpty = editor.selection.isEmpty()
if (isEmpty) {
var button = event.getButton(e);
if (button !== 0) {
if (selectionEmpty) {
editor.moveCursorToPosition(pos);
}
if(button == 2) {
editor.textInput.onContextMenu({x: pageX, y: pageY}, isEmpty);
editor.textInput.onContextMenu({x: pageX, y: pageY}, selectionEmpty);
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
}
return;
} else {
inSelection = !editor.getReadOnly()
&& !selectionEmpty
&& selectionRange.contains(pos.row, pos.column);
}
if (e.shiftKey)
editor.selection.selectToPosition(pos)
else {
editor.moveCursorToPosition(pos);
if (!editor.$clickSelection)
editor.selection.clearSelection(pos.row, pos.column);
if (!inSelection) {
// Directly pick STATE_SELECT, since the user is not clicking inside
// a selection.
onStartSelect(pos);
}
editor.renderer.scrollCursorIntoView();
var self = this;
var mousePageX, mousePageY;
var overwrite = editor.getOverwrite();
var mousedownTime = (new Date()).getTime();
var dragCursor, dragRange;
var onMouseSelection = function(e) {
mousePageX = event.getDocumentX(e);
@ -109,17 +137,92 @@ var MouseHandler = function(editor) {
var onMouseSelectionEnd = function() {
clearInterval(timerId);
if (state == STATE_UNKNOWN)
onStartSelect(pos);
else if (state == STATE_DRAG)
onMouseDragSelectionEnd();
self.$clickSelection = null;
state = STATE_UNKNOWN;
};
var onMouseDragSelectionEnd = function() {
dom.removeCssClass(editor.container, "ace_dragging");
editor.session.removeMarker(dragSelectionMarker);
if (!self.$clickSelection) {
if (!dragCursor) {
editor.moveCursorToPosition(pos);
editor.selection.clearSelection(pos.row, pos.column);
}
}
if (!dragCursor)
return;
if (dragRange.contains(dragCursor.row, dragCursor.column)) {
dragCursor = null;
return;
}
editor.clearSelection();
var newRange = editor.moveText(dragRange, dragCursor);
if (!newRange) {
dragCursor = null;
return;
}
editor.selection.setSelectionRange(newRange);
};
var onSelectionInterval = function() {
if (mousePageX === undefined || mousePageY === undefined)
return;
if (state == STATE_UNKNOWN) {
var distance = self.$distance(pageX, pageY, mousePageX, mousePageY);
var time = (new Date()).getTime();
if (distance > DRAG_OFFSET) {
state = STATE_SELECT;
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
onStartSelect(cursor);
} else if ((time - mousedownTime) > DRAG_TIMER) {
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 (e.shiftKey)
editor.selection.selectToPosition(pos)
else {
if (!self.$clickSelection) {
editor.moveCursorToPosition(pos);
editor.selection.clearSelection(pos.row, pos.column);
}
}
state = STATE_SELECT;
}
var onUpdateSelectionInterval = function() {
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
if (self.$clickSelection) {
if (self.$clickSelection) {
if (self.$clickSelection.contains(cursor.row, cursor.column)) {
editor.selection.setSelectionRange(self.$clickSelection);
} else {
@ -138,7 +241,15 @@ var MouseHandler = function(editor) {
editor.renderer.scrollCursorIntoView();
};
var onDragSelectionInterval = function() {
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
dragCursor.row = Math.max(0, Math.min(dragCursor.row,
editor.session.getLength() - 1));
editor.moveCursorToPosition(dragCursor);
};
event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
var timerId = setInterval(onSelectionInterval, 20);
@ -146,11 +257,15 @@ var MouseHandler = function(editor) {
};
this.onMouseDoubleClick = function(e) {
var pos = this.$getEventPosition(e);
this.editor.moveCursorToPosition(pos);
this.editor.selection.selectWord();
this.$clickSelection = this.editor.getSelectionRange();
};
this.onMouseTripleClick = function(e) {
var pos = this.$getEventPosition(e);
this.editor.moveCursorToPosition(pos);
this.editor.selection.selectLine();
this.$clickSelection = this.editor.getSelectionRange();
};

View file

@ -43,10 +43,10 @@ var event = require("pilot/event");
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var ScrollBar = function(parent) {
this.element = document.createElement("div");
this.element = dom.createElement("div");
this.element.className = "ace_sb";
this.inner = document.createElement("div");
this.inner = dom.createElement("div");
this.element.appendChild(this.inner);
parent.appendChild(this.element);

View file

@ -138,7 +138,7 @@ var Test = {
},
"test: should use mode of new document" : function() {
this.editor.onDocumentModeChange = function() {
this.editor.onChangeMode = function() {
called = true;
};
this.editor.setSession(this.session1);

View file

@ -67,11 +67,12 @@ var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
"consectetur";
var Test = {
setUp: function() {
setUp: function(next) {
this.session = new EditSession(lipsum);
this.editor = new Editor(new MockRenderer(), this.session);
this.selection = this.session.getSelection();
this.search = this.editor.$search;
next();
},
"test: highlight selected words by default": function() {

View file

@ -39,11 +39,6 @@ define(function(require, exports, module) {
MockRenderer = function(visibleRowCount) {
this.container = document.createElement("div");
this.cursor = {
row : 0,
column : 0
};
this.visibleRowCount = visibleRowCount || 20;
this.layerConfig = {
@ -89,9 +84,7 @@ MockRenderer.prototype.getSession = function(session) {
MockRenderer.prototype.setTokenizer = function() {
};
MockRenderer.prototype.updateCursor = function(position) {
this.cursor.row = position.row;
this.cursor.column = position.column;
MockRenderer.prototype.updateCursor = function() {
};
MockRenderer.prototype.scrollToLine = function(line, center) {
@ -108,11 +101,12 @@ MockRenderer.prototype.scrollToLine = function(line, center) {
};
MockRenderer.prototype.scrollCursorIntoView = function() {
if (this.cursor.row < this.layerConfig.firstVisibleRow) {
this.scrollToRow(this.cursor.row);
var cursor = this.session.getSelection().getCursor();
if (cursor.row < this.layerConfig.firstVisibleRow) {
this.scrollToRow(cursor.row);
}
else if (this.cursor.row > this.layerConfig.lastVisibleRow) {
this.scrollToRow(this.cursor.row);
else if (cursor.row > this.layerConfig.lastVisibleRow) {
this.scrollToRow(cursor.row);
}
};

View file

@ -98,6 +98,11 @@ var Test = {
assert.equal(1, tokens.length);
assert.equal("rparen", tokens[0].type);
},
"test tokenize regular expressions": function() {
var tokens = this.tokenizer.getLineTokens("a/b/c", "start").tokens;
assert.equal(5, tokens.length);
}
};

View file

@ -53,6 +53,7 @@ var Test = {
document.body.appendChild(el);
var renderer = new VirtualRenderer(el);
renderer.setPadding(0);
renderer.setSession(new EditSession("1234"));
renderer.characterWidth = 10;

197
lib/ace/theme/merbivore.js Normal file
View file

@ -0,0 +1,197 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Schwartz <mr.pants AT gmail DOT com>
*
* 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
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-merbivore .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
.ace-merbivore .ace_editor.ace_focus {\
border: 2px solid #327fbd;\
}\
\
.ace-merbivore .ace_gutter {\
width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
}\
\
.ace-merbivore .ace_gutter-layer {\
width: 100%;\
text-align: right;\
}\
\
.ace-merbivore .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-merbivore .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-merbivore .ace_scroller {\
background-color: #161616;\
}\
\
.ace-merbivore .ace_text-layer {\
cursor: text;\
color: #E6E1DC;\
}\
\
.ace-merbivore .ace_cursor {\
border-left: 2px solid #FFFFFF;\
}\
\
.ace-merbivore .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #FFFFFF;\
}\
\
.ace-merbivore .ace_marker-layer .ace_selection {\
background: #454545;\
}\
\
.ace-merbivore .ace_marker-layer .ace_step {\
background: rgb(198, 219, 174);\
}\
\
.ace-merbivore .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #FCE94F;\
}\
\
.ace-merbivore .ace_marker-layer .ace_active_line {\
background: #333435;\
}\
\
\
.ace-merbivore .ace_invisible {\
color: #404040;\
}\
\
.ace-merbivore .ace_keyword {\
color:#FC6F09;\
}\
\
.ace-merbivore .ace_keyword.ace_operator {\
\
}\
\
.ace-merbivore .ace_constant {\
color:#1EDAFB;\
}\
\
.ace-merbivore .ace_constant.ace_language {\
color:#FDC251;\
}\
\
.ace-merbivore .ace_constant.ace_library {\
color:#8DFF0A;\
}\
\
.ace-merbivore .ace_constant.ace_numeric {\
color:#58C554;\
}\
\
.ace-merbivore .ace_invalid {\
color:#FFFFFF;\
background-color:#990000;\
}\
\
.ace-merbivore .ace_invalid.ace_illegal {\
\
}\
\
.ace-merbivore .ace_invalid.ace_deprecated {\
color:#FFFFFF;\
background-color:#990000;\
}\
\
.ace-merbivore .ace_support {\
\
}\
\
.ace-merbivore .ace_support.ace_function {\
color:#FC6F09;\
}\
\
.ace-merbivore .ace_function.ace_buildin {\
\
}\
\
.ace-merbivore .ace_string {\
color:#8DFF0A;\
}\
\
.ace-merbivore .ace_string.ace_regexp {\
\
}\
\
.ace-merbivore .ace_comment {\
color:#AD2EA4;\
}\
\
.ace-merbivore .ace_comment.ace_doc {\
\
}\
\
.ace-merbivore .ace_comment.ace_doc.ace_tag {\
\
}\
\
.ace-merbivore .ace_variable {\
\
}\
\
.ace-merbivore .ace_variable.ace_language {\
\
}\
\
.ace-merbivore .ace_xml_pe {\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-merbivore";
});

View file

@ -0,0 +1,197 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Schwartz <mr.pants AT gmail DOT com>
*
* 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
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-merbivore-soft .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
.ace-merbivore-soft .ace_editor.ace_focus {\
border: 2px solid #327fbd;\
}\
\
.ace-merbivore-soft .ace_gutter {\
width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
}\
\
.ace-merbivore-soft .ace_gutter-layer {\
width: 100%;\
text-align: right;\
}\
\
.ace-merbivore-soft .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-merbivore-soft .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-merbivore-soft .ace_scroller {\
background-color: #1C1C1C;\
}\
\
.ace-merbivore-soft .ace_text-layer {\
cursor: text;\
color: #E6E1DC;\
}\
\
.ace-merbivore-soft .ace_cursor {\
border-left: 2px solid #FFFFFF;\
}\
\
.ace-merbivore-soft .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #FFFFFF;\
}\
\
.ace-merbivore-soft .ace_marker-layer .ace_selection {\
background: #494949;\
}\
\
.ace-merbivore-soft .ace_marker-layer .ace_step {\
background: rgb(198, 219, 174);\
}\
\
.ace-merbivore-soft .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #FCE94F;\
}\
\
.ace-merbivore-soft .ace_marker-layer .ace_active_line {\
background: #333435;\
}\
\
\
.ace-merbivore-soft .ace_invisible {\
color: #404040;\
}\
\
.ace-merbivore-soft .ace_keyword {\
color:#FC803A;\
}\
\
.ace-merbivore-soft .ace_keyword.ace_operator {\
\
}\
\
.ace-merbivore-soft .ace_constant {\
color:#68C1D8;\
}\
\
.ace-merbivore-soft .ace_constant.ace_language {\
color:#E1C582;\
}\
\
.ace-merbivore-soft .ace_constant.ace_library {\
color:#8EC65F;\
}\
\
.ace-merbivore-soft .ace_constant.ace_numeric {\
color:#7FC578;\
}\
\
.ace-merbivore-soft .ace_invalid {\
color:#FFFFFF;\
background-color:#FE3838;\
}\
\
.ace-merbivore-soft .ace_invalid.ace_illegal {\
\
}\
\
.ace-merbivore-soft .ace_invalid.ace_deprecated {\
color:#FFFFFF;\
background-color:#FE3838;\
}\
\
.ace-merbivore-soft .ace_support {\
\
}\
\
.ace-merbivore-soft .ace_support.ace_function {\
color:#FC803A;\
}\
\
.ace-merbivore-soft .ace_function.ace_buildin {\
\
}\
\
.ace-merbivore-soft .ace_string {\
color:#8EC65F;\
}\
\
.ace-merbivore-soft .ace_string.ace_regexp {\
\
}\
\
.ace-merbivore-soft .ace_comment {\
color:#AC4BB8;\
}\
\
.ace-merbivore-soft .ace_comment.ace_doc {\
\
}\
\
.ace-merbivore-soft .ace_comment.ace_doc.ace_tag {\
\
}\
\
.ace-merbivore-soft .ace_variable {\
\
}\
\
.ace-merbivore-soft .ace_variable.ace_language {\
\
}\
\
.ace-merbivore-soft .ace_xml_pe {\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-merbivore-soft";
});

View file

@ -0,0 +1,197 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Schwartz <mr.pants AT gmail DOT com>
*
* 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
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-vibrant-ink .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
.ace-vibrant-ink .ace_editor.ace_focus {\
border: 2px solid #327fbd;\
}\
\
.ace-vibrant-ink .ace_gutter {\
width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
}\
\
.ace-vibrant-ink .ace_gutter-layer {\
width: 100%;\
text-align: right;\
}\
\
.ace-vibrant-ink .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-vibrant-ink .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-vibrant-ink .ace_scroller {\
background-color: #0F0F0F;\
}\
\
.ace-vibrant-ink .ace_text-layer {\
cursor: text;\
color: #FFFFFF;\
}\
\
.ace-vibrant-ink .ace_cursor {\
border-left: 2px solid #FFFFFF;\
}\
\
.ace-vibrant-ink .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #FFFFFF;\
}\
\
.ace-vibrant-ink .ace_marker-layer .ace_selection {\
background: #6699CC;\
}\
\
.ace-vibrant-ink .ace_marker-layer .ace_step {\
background: rgb(198, 219, 174);\
}\
\
.ace-vibrant-ink .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #99CC99;\
}\
\
.ace-vibrant-ink .ace_marker-layer .ace_active_line {\
background: #333333;\
}\
\
\
.ace-vibrant-ink .ace_invisible {\
color: #404040;\
}\
\
.ace-vibrant-ink .ace_keyword {\
color:#FF6600;\
}\
\
.ace-vibrant-ink .ace_keyword.ace_operator {\
\
}\
\
.ace-vibrant-ink .ace_constant {\
\
}\
\
.ace-vibrant-ink .ace_constant.ace_language {\
color:#339999;\
}\
\
.ace-vibrant-ink .ace_constant.ace_library {\
\
}\
\
.ace-vibrant-ink .ace_constant.ace_numeric {\
color:#99CC99;\
}\
\
.ace-vibrant-ink .ace_invalid {\
color:#CCFF33;\
background-color:#000000;\
}\
\
.ace-vibrant-ink .ace_invalid.ace_illegal {\
\
}\
\
.ace-vibrant-ink .ace_invalid.ace_deprecated {\
color:#CCFF33;\
background-color:#000000;\
}\
\
.ace-vibrant-ink .ace_support {\
\
}\
\
.ace-vibrant-ink .ace_support.ace_function {\
color:#FFCC00;\
}\
\
.ace-vibrant-ink .ace_function.ace_buildin {\
\
}\
\
.ace-vibrant-ink .ace_string {\
color:#66FF00;\
}\
\
.ace-vibrant-ink .ace_string.ace_regexp {\
\
}\
\
.ace-vibrant-ink .ace_comment {\
color:#9933CC;\
}\
\
.ace-vibrant-ink .ace_comment.ace_doc {\
\
}\
\
.ace-vibrant-ink .ace_comment.ace_doc.ace_tag {\
\
}\
\
.ace-vibrant-ink .ace_variable {\
\
}\
\
.ace-vibrant-ink .ace_variable.ace_language {\
\
}\
\
.ace-vibrant-ink .ace_xml_pe {\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-vibrant-ink";
});

View file

@ -42,14 +42,15 @@ var Tokenizer = function(rules) {
this.regExps = {};
for ( var key in this.rules) {
var state = this.rules[key];
var rule = this.rules[key];
var state = rule;
var ruleRegExps = [];
for ( var i = 0; i < state.length; i++) {
for ( var i = 0; i < state.length; i++)
ruleRegExps.push(state[i].regex);
};
this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(") + ")|(.))", "g");
}
};
@ -76,19 +77,19 @@ var Tokenizer = function(rules) {
for ( var i = 0; i < state.length; i++) {
if (match[i + 1]) {
if (typeof state[i].token == "function") {
type = state[i].token(match[0]);
}
else {
type = state[i].token;
}
var rule = state[i];
if (typeof rule.token == "function")
type = rule.token(match[0]);
else
type = rule.token;
if (state[i].next && state[i].next !== currentState) {
currentState = state[i].next;
var state = this.rules[currentState];
var lastIndex = re.lastIndex;
if (rule.next && rule.next !== currentState) {
currentState = rule.next;
state = this.rules[currentState];
lastIndex = re.lastIndex;
var re = this.regExps[currentState];
re = this.regExps[currentState];
re.lastIndex = lastIndex;
}
break;
@ -97,9 +98,9 @@ var Tokenizer = function(rules) {
if (token.type !== type) {
if (token.type) {
if (token.type)
tokens.push(token);
}
token = {
type: type,
value: value
@ -108,16 +109,14 @@ var Tokenizer = function(rules) {
token.value += value;
}
if (lastIndex == line.length) {
break;
}
if (lastIndex == line.length)
break;
lastIndex = re.lastIndex;
};
if (token.type) {
if (token.type)
tokens.push(token);
}
return {
tokens : tokens,

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -20,6 +21,7 @@
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Mihai Sucan <mihai DOT sucan AT gmail DOT com>
*
* 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
@ -70,6 +72,14 @@ var UndoManager = function() {
this.$redoStack = [];
};
this.hasUndo = function() {
return this.$undoStack.length > 0;
};
this.hasRedo = function() {
return this.$redoStack.length > 0;
};
}).call(UndoManager.prototype);
exports.UndoManager = UndoManager;

View file

@ -62,15 +62,15 @@ var VirtualRenderer = function(container, theme) {
this.setTheme(theme);
this.$gutter = document.createElement("div");
this.$gutter = dom.createElement("div");
this.$gutter.className = "ace_gutter";
this.container.appendChild(this.$gutter);
this.scroller = document.createElement("div");
this.scroller = dom.createElement("div");
this.scroller.className = "ace_scroller";
this.container.appendChild(this.scroller);
this.content = document.createElement("div");
this.content = dom.createElement("div");
this.content.className = "ace_content";
this.scroller.appendChild(this.content);
@ -192,6 +192,10 @@ var VirtualRenderer = function(container, theme) {
this.$loop.schedule(this.CHANGE_FULL);
};
this.updateFontSize = function() {
this.$textLayer.checkForSizeChanges();
};
/**
* Triggers resize of the editor
*/
@ -277,6 +281,10 @@ var VirtualRenderer = function(container, theme) {
this.getPrintMarginColumn = function() {
return this.$printMarginColumn;
};
this.getShowGutter = function(){
return this.showGutter;
}
this.setShowGutter = function(show){
if(this.showGutter === show)
@ -293,9 +301,9 @@ var VirtualRenderer = function(container, theme) {
return;
if (!this.$printMarginEl) {
containerEl = document.createElement("div");
containerEl = dom.createElement("div");
containerEl.className = "ace_print_margin_layer";
this.$printMarginEl = document.createElement("div")
this.$printMarginEl = dom.createElement("div")
this.$printMarginEl.className = "ace_print_margin";
containerEl.appendChild(this.$printMarginEl);
this.content.insertBefore(containerEl, this.$textLayer.element);
@ -365,6 +373,10 @@ var VirtualRenderer = function(container, theme) {
this.$updatePrintMargin();
};
this.getHScrollBarAlwaysVisible = function() {
return this.$horizScrollAlwaysVisible;
}
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
if (this.$horizScrollAlwaysVisible != alwaysVisible) {
this.$horizScrollAlwaysVisible = alwaysVisible;
@ -568,8 +580,7 @@ var VirtualRenderer = function(container, theme) {
this.$loop.schedule(this.CHANGE_GUTTER);
};
this.updateCursor = function(position, overwrite) {
this.$cursorLayer.setCursor(position, overwrite);
this.updateCursor = function() {
this.$loop.schedule(this.CHANGE_CURSOR);
};
@ -702,12 +713,12 @@ var VirtualRenderer = function(container, theme) {
this.showComposition = function(position) {
if (!this.$composition) {
this.$composition = document.createElement("div");
this.$composition = dom.createElement("div");
this.$composition.className = "ace_composition";
this.content.appendChild(this.$composition);
}
this.$composition.innerHTML = "&nbsp;";
this.$composition.innerHTML = "&#160;";
var pos = this.$cursorLayer.getPixelPosition();
var style = this.$composition.style;
@ -777,4 +788,4 @@ var VirtualRenderer = function(container, theme) {
}).call(VirtualRenderer.prototype);
exports.VirtualRenderer = VirtualRenderer;
});
});

View file

@ -1,3 +1,4 @@
define(function(require, exports, module) {
/*
* JSHint, by JSHint Community.
*
@ -32,8 +33,6 @@
*
*/
define(function(require, exports, module) {
/*
JSHINT is a global function. It takes two parameters.
@ -160,7 +159,7 @@ define(function(require, exports, module) {
"(begin)", "(breakage)", "(context)", "(error)", "(global)",
"(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
"(params)", "(scope)", "(statement)", "(verb)", "*", "+", "++", "-",
"--", "\/", "<", "<=", "==", "===", ">", ">=", ADSAFE, __filename, __dirname,
"--", "\/", "<", "<=", "==", "===", ">", ">=", $, ADSAFE, __filename, __dirname,
ActiveXObject, Array, Boolean, Buffer, COM, CScript, Canvas, CustomAnimation,
Date, Debug, E, Enumerator, Error, EvalError, FadeAnimation, Flash,
FormField, Frame, Function, HotKey, Image, JSON, LN10, LN2, LOG10E,
@ -172,8 +171,8 @@ define(function(require, exports, module) {
WScript, Web, Window, XMLDOM, XMLHttpRequest, "\\", a, abbr, acronym,
activeborder, activecaption, addEventListener, address, adsafe, alert,
aliceblue, all, animator, antiquewhite, appleScript, applet, apply,
approved, appworkspace, aqua, aquamarine, area, arguments, arity,
article, aside, audio, autocomplete, azure, b, background,
approved, appworkspace, applicationCache, aqua, aquamarine, area, arguments,
arity, article, aside, audio, autocomplete, azure, b, background,
"background-attachment", "background-color", "background-image",
"background-position", "background-repeat", base, bdo, beep, beige, big,
bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
@ -192,22 +191,22 @@ define(function(require, exports, module) {
closeWidget, closed, closure, cm, code, col, colgroup, color, command,
comment, condition, confirm, console, constructor, content,
convertPathToHFS, convertPathToPlatform, coral, cornflowerblue,
cornsilk, "counter-increment", "counter-reset", create, crimson, css, curly,
cursor, cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
cornsilk, couch, "counter-increment", "counter-reset", create, crimson,
css, curly, cursor, cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray,
darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid,
darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
details, devel, dfn, dialog, dimgray, dir, direction, display, div, dl,
document, dodgerblue, dt, edition, else, em, embed, embossed, empty,
document, dodgerblue, dt, edition, else, em, embed, embossed, emit, empty,
"empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq, errors,
es5, escape, eval, event, evidence, evil, ex, exception, exec, exps, exports,
fieldset, figure, filesystem, firebrick, first, float, floor,
fieldset, figure, filesystem, FileReader, firebrick, first, float, floor,
floralwhite, focus, focusWidget, font, "font-family", "font-size",
"font-size-adjust", "font-stretch", "font-style", "font-variant",
"font-weight", footer, forestgreen, forin, form, fragment, frame,
frames, frameset, from, fromCharCode, fuchsia, fud, funct, function,
functions, g, gainsboro, gc, getComputedStyle, ghostwhite, GLOBAL, global,
functions, g, gainsboro, gc, getComputedStyle, getRow, ghostwhite, GLOBAL, global,
globals, gold, goldenrod, gray, graytext, green, greenyellow, h1, h2,
h3, h4, h5, h6, handheld, hasOwnProperty, head, header, height, help,
hgroup, highlight, highlighttext, history, honeydew, hotpink, hr,
@ -215,16 +214,16 @@ define(function(require, exports, module) {
implieds, in, inactiveborder, inactivecaption, inactivecaptiontext,
include, indent, indexOf, indianred, indigo, infobackground, infotext,
init, input, ins, isAlpha, isApplicationRunning, isArray, isDigit,
isFinite, isNaN, ivory, join, jshint, JSHINT, json, kbd, keygen, keys, khaki,
konfabulatorVersion, label, labelled, lang, last, lavender,
lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
isFinite, isNaN, ivory, join, jshint, JSHINT, json, jquery, jQuery, kbd,
keygen, keys, khaki, konfabulatorVersion, label, labelled, lang, last,
lavender, lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
lightseagreen, lightskyblue, lightslategray, lightsteelblue,
lightyellow, lime, limegreen, line, "line-height", linen, link,
"list-style", "list-style-image", "list-style-position",
"list-style-type", load, loadClass, location, log, m, magenta, map,
margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
"list-style-type", load, loadClass, localStorage, location, log, m, magenta,
map, margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
maxlen, md5, mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise,
@ -233,8 +232,8 @@ define(function(require, exports, module) {
moccasin, module, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
newcap, noarg, node, noempty, noframes, nomen, nonew, noscript, nud, object, ol,
oldlace, olive, olivedrab, on, onbeforeunload, onblur, onerror, onevar,
onfocus, onload, onresize, onunload, opacity, open, openURL, opener, opera,
optgroup, option, orange, orangered, orchid, outer, outline, "outline-color",
onfocus, onload, onresize, onunload, opacity, open, openDatabase, openURL, opener,
opera, optgroup, option, orange, orangered, orchid, outer, outline, "outline-color",
"outline-style", "outline-width", output, overflow, "overflow-x",
"overflow-y", p, padding, "padding-bottom", "padding-left",
"padding-right", "padding-top", "page-break-after", "page-break-before",
@ -245,15 +244,15 @@ define(function(require, exports, module) {
prompt, prototype, pt, purple, push, px, q, quit, quotes, random, range,
raw, reach, readFile, readUrl, reason, red, regexp, reloadWidget,
removeEventListener, replace, report, require, reserved, resizeBy, resizeTo,
resolvePath, resumeUpdates, rhino, right, rosybrown, royalblue, rp, rt,
ruby, runCommand, runCommandInBg, saddlebrown, safe, salmon, samp,
resolvePath, resumeUpdates, respond, rhino, right, rosybrown, royalblue,
rp, rt, ruby, runCommand, runCommandInBg, saddlebrown, safe, salmon, samp,
sandybrown, saveAs, savePreferences, screen, script, scroll, scrollBy,
scrollTo, scrollbar, seagreen, seal, search, seashell, section, select,
scrollTo, scrollbar, seagreen, seal, search, seashell, section, send, select,
serialize, setInterval, setTimeout, shift, showWidgetPreferences,
sienna, silver, skyblue, slateblue, slategray, sleep, slice, small,
snow, sort, source, span, spawn, speak, speech, split, springgreen, src,
stack, status, steelblue, strict, strong, style, styleproperty, sub,
substr, sup, supplant, suppressUpdates, sync, system, table,
stack, status, start, steelblue, strict, strong, style, styleproperty, sub,
substr, sum, sup, supplant, suppressUpdates, sync, system, table,
"table-layout", tan, tbody, td, teal, tellWidget, test, "text-align",
"text-decoration", "text-indent", "text-shadow", "text-transform",
textarea, tfoot, th, thead, thistle, threeddarkshadow, threedface,
@ -261,10 +260,10 @@ define(function(require, exports, module) {
toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
tty, turquoise, tv, type, u, ul, undef, unescape, "unicode-bidi",
unused, unwatch, updateNow, urls, value, valueOf, var, version,
"vertical-align", video, violet, visibility, watch, wheat, white,
"vertical-align", video, violet, visibility, watch, WebSocket, wheat, white,
"white-space", whitesmoke, widget, width, window, windowframe, windows,
windowtext, "word-spacing", "word-wrap", yahooCheckLogin, yahooLogin,
yahooLogout, yellow, yellowgreen, "z-index"
windowtext, Worker, "word-spacing", "word-wrap", yahooCheckLogin,
yahooLogin, yahooLogout, yellow, yellowgreen, "z-index"
*/
/*global exports: false */
@ -321,9 +320,10 @@ var JSHINT = (function () {
boolOptions = {
adsafe : true, // if ADsafe should be enforced
bitwise : true, // if bitwise operators should not be allowed
boss : true, // if assignments inside if/for/while/do should be allowed
boss : true, // if advanced usage of assignments and == should be allowed
browser : true, // if the standard browser globals should be predefined
cap : true, // if upper case HTML should be allowed
couch : true, // if CouchDB globals should be predefined
css : true, // if CSS workarounds should be tolerated
curly : true, // if curly braces around blocks should be required (even in if/for/while)
debug : true, // if debugger statements should be allowed
@ -334,6 +334,7 @@ var JSHINT = (function () {
forin : true, // if for in statements must filter
fragment : true, // if HTML fragments should be allowed
immed : true, // if immediate invocations must be wrapped in parens
jquery : true, // if jQuery globals should be predefined
laxbreak : true, // if line breaks should not be checked
newcap : true, // if constructor names must be capitalized
noarg : true, // if arguments.caller and arguments.callee should be disallowed
@ -361,6 +362,7 @@ var JSHINT = (function () {
browser = {
addEventListener: false,
applicationCache: false,
blur : false,
clearInterval : false,
clearTimeout : false,
@ -369,12 +371,14 @@ var JSHINT = (function () {
defaultStatus : false,
document : false,
event : false,
FileReader : false,
focus : false,
frames : false,
getComputedStyle: false,
history : false,
Image : false,
length : false,
localStorage : false,
location : false,
moveBy : false,
moveTo : false,
@ -388,6 +392,7 @@ var JSHINT = (function () {
onresize : true,
onunload : true,
open : false,
openDatabase : false,
opener : false,
Option : false,
parent : false,
@ -403,10 +408,25 @@ var JSHINT = (function () {
setTimeout : false,
status : false,
top : false,
WebSocket : false,
window : false,
Worker : false,
XMLHttpRequest : false
},
couch = {
"require" : false,
respond : false,
getRow : false,
emit : false,
send : false,
start : false,
sum : false,
log : false,
exports : false,
module : false
},
cssAttributeData,
cssAny,
@ -752,6 +772,12 @@ var JSHINT = (function () {
inblock,
indent,
jsonmode,
jquery = {
'$' : false,
jQuery : false
},
lines,
lookahead,
member,
@ -1102,26 +1128,32 @@ var JSHINT = (function () {
}
function assume() {
if (!option.safe) {
if (option.rhino) {
combine(predefined, rhino);
}
if (option.node) {
combine(predefined, node);
}
if (option.devel) {
combine(predefined, devel);
}
if (option.browser) {
combine(predefined, browser);
}
if (option.windows) {
combine(predefined, windows);
}
if (option.widget) {
combine(predefined, widget);
}
}
if (option.safe)
return;
if (option.couch)
combine(predefined, couch);
if (option.rhino)
combine(predefined, rhino);
if (option.node)
combine(predefined, node);
if (option.devel)
combine(predefined, devel);
if (option.browser)
combine(predefined, browser);
if (option.jquery)
combine(predefined, jquery);
if (option.windows)
combine(predefined, windows);
if (option.widget)
combine(predefined, widget);
}
@ -2429,10 +2461,10 @@ loop: for (;;) {
return node &&
((node.type === '(number)' && +node.value === 0) ||
(node.type === '(string)' && node.value === '') ||
(node.type === 'null' && !option.boss) ||
node.type === 'true' ||
node.type === 'false' ||
node.type === 'undefined' ||
node.type === 'null');
node.type === 'undefined');
}
@ -2538,22 +2570,30 @@ loop: for (;;) {
}
function optionalidentifier() {
// fnparam means that this identifier is being defined as a function
// argument (see identifier())
function optionalidentifier(fnparam) {
if (nexttoken.identifier) {
advance();
if (option.safe && banned[token.value]) {
warning("ADsafe violation: '{a}'.", token, token.value);
} else if (token.reserved && !option.es5) {
warning("Expected an identifier and instead saw '{a}' (a reserved word).",
token, token.id);
// `undefined` as a function param is a common pattern to protect
// against the case when somebody does `undefined = true` and
// help with minification. More info: https://gist.github.com/315916
if (!fnparam || token.value != 'undefined') {
warning("Expected an identifier and instead saw '{a}' (a reserved word).",
token, token.id);
}
}
return token.value;
}
}
function identifier() {
var i = optionalidentifier();
// fnparam means that this identifier is being defined as a function
// argument
function identifier(fnparam) {
var i = optionalidentifier(fnparam);
if (i) {
return i;
}
@ -2746,10 +2786,10 @@ loop: for (;;) {
/*
* Parses a single block. A block is a sequence of statements wrapped in
* braces.
*
* ordinary - true for everything but function bodies and try blocks.
* stmt - true if block can be a single statement (e.g. in if/for/while).
*/
*
* ordinary - true for everything but function bodies and try blocks.
* stmt - true if block can be a single statement (e.g. in if/for/while).
*/
function block(ordinary, stmt) {
var a,
b = inblock,
@ -4176,9 +4216,14 @@ loop: for (;;) {
// The name is not defined in the function. If we are in the global scope,
// then we have an undefined variable.
//
// Operators typeof and delete do not raise runtime errors even if the base
// object of a reference is null so no need to display warning if we're
// inside of typeof or delete.
} else if (funct['(global)']) {
if (option.undef && typeof predefined[v] !== 'boolean') {
if (anonname != 'typeof' && anonname != 'delete' &&
option.undef && typeof predefined[v] !== 'boolean') {
warning("'{a}' is not defined.", token, v);
}
note_implied(token);
@ -4211,7 +4256,11 @@ loop: for (;;) {
warning("'{a}' is not allowed.", token, v);
note_implied(token);
} else if (typeof s !== 'object') {
if (option.undef) {
// Operators typeof and delete do not raise runtime errors even if the base object of
// a reference is null so no need to display warning if we're inside of typeof or delete.
if (anonname != 'typeof' && anonname != 'delete' && option.undef) {
warning("'{a}' is not defined.", token, v);
} else {
funct[v] = true;
@ -4772,7 +4821,7 @@ loop: for (;;) {
return;
}
for (;;) {
i = identifier();
i = identifier(true);
p.push(i);
addlabel(i, 'parameter');
if (nexttoken.id === ',') {
@ -5846,6 +5895,8 @@ loop: for (;;) {
};
itself.jshint = itself;
itself.edition = '2011-02-19';
return itself;
}());

View file

@ -30,11 +30,14 @@ var require = function(id) {
require.modules = {};
require.tlns = {};
var define = function(id, factory) {
if (!factory) {
var define = function(id, deps, factory) {
if (arguments.length == 2) {
factory = deps;
} else if (arguments.length == 1) {
factory = id;
id = require.id;
}
if (id.indexOf("text!") === 0)
return;

View file

@ -1,4 +1,5 @@
/**
/* vim:ts=4:sts=4:sw=4:
*
* Ajax.org Code Editor (ACE)
*
* @copyright 2010, Ajax.org Services B.V.
@ -42,7 +43,7 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
var _self = this;
this.$worker.onerror = function(e) {
console.log(e);
window.console && console.log && console.log(e);
throw e;
};
this.$worker.onmessage = function(e) {
@ -72,10 +73,17 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
oop.implement(this, EventEmitter);
this.$guessBasePath = function() {
if (require.aceBaseUrl)
return require.aceBaseUrl;
var scripts = document.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) {
var m = scripts[i].src.
match(/^(.*\/)ace\.js$|^(.*\/)ace-uncompressed\.js$/);
var src = scripts[i].src || scripts[i].getAttribute("src");
if (!src) {
continue;
}
var m = src.match(/^(.*\/)ace\.js$|^(.*\/)ace-uncompressed\.js$/);
if (m) {
return m[1] || m[2];
}