Merge pull request #1449 from ajaxorg/newclient_update

changes from newclient
This commit is contained in:
Lennart Kats 2013-05-30 02:49:46 -07:00
commit cb6fce18b3
10 changed files with 46 additions and 104 deletions

View file

@ -627,9 +627,9 @@ var Document = function(text) {
var index = 0;
var row = Math.min(pos.row, lines.length);
for (var i = startRow || 0; i < row; ++i)
index += lines[i].length;
index += lines[i].length + newlineLength;
return index + newlineLength * i + pos.column;
return index + pos.column;
};
}).call(Document.prototype);

View file

@ -332,7 +332,7 @@ function Folding() {
// Notify that fold data has changed.
this.$modified = true;
this._emit("changeFold", { data: fold });
this._emit("changeFold", { data: fold, action: "add" });
return fold;
};
@ -393,7 +393,7 @@ function Folding() {
// Notify that fold data has changed.
this.$modified = true;
this._emit("changeFold", { data: fold });
this._emit("changeFold", { data: fold, action: "remove" });
};
this.removeFolds = function(folds) {

View file

@ -51,6 +51,8 @@ AceEmmetEditor.prototype = {
setupContext: function(editor) {
this.ace = editor;
this.indentation = editor.session.getTabString();
if (!emmet)
emmet = window.emmet;
emmet.require("resources").setVariable("indentation", this.indentation);
this.$syntax = null;
this.$syntax = this.getSyntax();
@ -161,7 +163,7 @@ AceEmmetEditor.prototype = {
*/
replaceContent: function(value, start, end, noIndent) {
if (end == null)
end = start == null ? content.length : start;
end = start == null ? this.getContent().length : start;
if (start == null)
start = 0;
var utils = emmet.require("utils");
@ -228,7 +230,7 @@ AceEmmetEditor.prototype = {
if (state.length > 1)
syntax = state[0];
else if (syntax == "php")
syntax = "html"
syntax = "html";
}
}
return syntax;
@ -309,12 +311,13 @@ var keymap = {
// update_image_size: {"mac": "shift+ctrl+i", "win": "ctrl+u"},
// expand_as_you_type: "ctrl+alt+enter",
// wrap_as_you_type: {"mac": "shift+ctrl+g", "win": "shift+ctrl+g"},
expand_abbreviation_with_tab: "Tab"
expand_abbreviation_with_tab: "Tab",
wrap_with_abbreviation: {"mac": "shift+ctrl+a", "win": "shift+ctrl+a"}
};
var editorProxy = new AceEmmetEditor();
exports.commands = new HashHandler();
function runEmmetCommand(editor) {
exports.runEmmetCommand = function(editor) {
editorProxy.setupContext(editor);
if (editorProxy.getSyntax() == "php")
return false;
@ -325,6 +328,13 @@ function runEmmetCommand(editor) {
return false;
}
if (this.action == "wrap_with_abbreviation") {
// without setTimeout prompt doesn't work on firefox
return setTimeout(function() {
actions.run("wrap_with_abbreviation", editorProxy);
}, 0);
}
try {
var result = actions.run(this.action, editorProxy);
} catch(e) {
@ -332,14 +342,14 @@ function runEmmetCommand(editor) {
console.log(e);
}
return result;
}
};
for (var command in keymap) {
exports.commands.addCommand({
name: "emmet:" + command,
action: command,
bindKey: keymap[command],
exec: runEmmetCommand,
exec: exports.runEmmetCommand,
multiSelectAction: "forEach"
});
}
@ -359,7 +369,7 @@ var onChangeMode = function(e, target) {
};
exports.AceEmmetEditor = AceEmmetEditor
exports.AceEmmetEditor = AceEmmetEditor;
require("ace/config").defineOptions(Editor.prototype, "editor", {
enableEmmet: {
set: function(val) {

View file

@ -70,7 +70,7 @@ oop.inherits(Mode, TextMode);
);
this.lineCommentStart = ["#", "//"];
this.lineCommentStart = ["//", "#"];
this.blockComment = {start: "/*", end: "*/"};
this.getNextLineIndent = function(state, line, tab) {

View file

@ -75,7 +75,7 @@ oop.inherits(Mode, TextMode);
};
this.checkOutdent = function(state, line, input) {
return /\s+end$/.test(line + input) || /\s+}$/.test(line + input) || /\s+else$/.test(line + input);
return /^\s+end$/.test(line + input) || /^\s+}$/.test(line + input) || /^\s+else$/.test(line + input);
};
this.autoOutdent = function(state, doc, row) {

View file

@ -54,7 +54,7 @@ var VelocityHighlightRules = function() {
next : "style"
}, {
token : "meta.tag", // opening tag
regex : "<\\/?(?:[a-z])",
regex : "<\\/?(?=[a-z])",
next : "tag"
}, {
token : "comment",

View file

@ -283,7 +283,7 @@ var Search = function() {
};
};
this.$assembleRegExp = function(options) {
this.$assembleRegExp = function(options, $disableFakeMultiline) {
if (options.needle instanceof RegExp)
return options.re = options.needle;
@ -300,7 +300,7 @@ var Search = function() {
var modifier = options.caseSensitive ? "g" : "gi";
options.$isMultiLine = /[\n\r]/.test(needle);
options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
if (options.$isMultiLine)
return options.re = this.$assembleMultilineRegExp(needle, modifier);

View file

@ -349,6 +349,8 @@ var VirtualRenderer = function(container, theme) {
if (this.session.getUseWrapMode() && this.adjustWrapLimit())
this.$loop.schedule(this.CHANGE_FULL);
else
this.$loop.schedule(this.CHANGE_MARKER);
};
/**
@ -1270,12 +1272,14 @@ var VirtualRenderer = function(container, theme) {
afterLoad(theme);
}
function afterLoad(theme) {
if (!theme.cssClass)
function afterLoad(module) {
if (_self.$themeValue != theme)
return;
if (!module.cssClass)
return;
dom.importCssString(
theme.cssText,
theme.cssClass,
module.cssText,
module.cssClass,
_self.container.ownerDocument
);
@ -1283,13 +1287,13 @@ var VirtualRenderer = function(container, theme) {
dom.removeCssClass(_self.container, _self.theme.cssClass);
// this is kept only for backwards compatibility
_self.$theme = theme.cssClass;
_self.$theme = module.cssClass;
_self.theme = theme;
dom.addCssClass(_self.container, theme.cssClass);
dom.setCssClass(_self.container, "ace_dark", theme.isDark);
_self.theme = module;
dom.addCssClass(_self.container, module.cssClass);
dom.setCssClass(_self.container, "ace_dark", module.isDark);
var padding = theme.padding || 4;
var padding = module.padding || 4;
if (_self.$padding && padding != _self.$padding)
_self.setPadding(padding);
@ -1299,7 +1303,7 @@ var VirtualRenderer = function(container, theme) {
_self.onResize();
}
_self._dispatchEvent('themeLoaded',{theme:theme});
_self._dispatchEvent('themeLoaded',{theme:module});
}
};

View file

@ -41,14 +41,15 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) {
this.onMessage = this.onMessage.bind(this);
this.onError = this.onError.bind(this);
// nameToUrl is renamed to toUrl in requirejs 2
if (require.nameToUrl && !require.toUrl)
require.toUrl = require.nameToUrl;
var workerUrl;
if (config.get("packaged")) {
if (config.get("packaged") || !require.toUrl) {
workerUrl = config.moduleUrl(mod, "worker");
} else {
var normalizePath = this.$normalizePath;
// nameToUrl is renamed to toUrl in requirejs 2
if (require.nameToUrl && !require.toUrl)
require.toUrl = require.nameToUrl;
workerUrl = normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
var tlns = {};
@ -184,7 +185,7 @@ var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
var sender = Object.create(EventEmitter);
var _self = this;
this.$worker = {}
this.$worker = {};
this.$worker.terminate = function() {};
this.$worker.postMessage = function(e) {
_self.messageBuffer.push(e);

View file

@ -1,73 +0,0 @@
define(function(require, exports, module) {
"no use strict";
exports.main = function()
{
var console = {
log: function(msg) {
postMessage({type: "log", data: msg});
}
};
// NOTE: This sets the global `window` object used by workers.
// TODO: Pass into worker what it needs and don't set global here.
window = {
console: console
};
function initSender() {
var EventEmitter = require("ace/lib/event_emitter").EventEmitter;
var oop = require("ace/lib/oop");
var Sender = function() {};
(function() {
oop.implement(this, EventEmitter);
this.callback = function(data, callbackId) {
postMessage({
type: "call",
id: callbackId,
data: data
});
};
this.emit = function(name, data) {
postMessage({
type: "event",
name: name,
data: data
});
};
}).call(Sender.prototype);
return new Sender();
}
var main;
var sender;
onmessage = function(e) {
var msg = e.data;
if (msg.command) {
main[msg.command].apply(main, msg.args);
}
else if (msg.init) {
require("ace/lib/fixoldbrowsers");
sender = initSender();
require.async(msg.module, function(WORKER) {
var clazz = WORKER[msg.classname];
main = new clazz(sender);
});
}
else if (msg.event && sender) {
sender._emit(msg.event, msg.data);
}
};
}
});