revert changes to worker
This commit is contained in:
parent
5c1db2dbcc
commit
dc198344d5
7 changed files with 186 additions and 196 deletions
|
|
@ -46,7 +46,6 @@ var Search = require("./search").Search;
|
||||||
var Range = require("./range").Range;
|
var Range = require("./range").Range;
|
||||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||||
var CommandManager = require("./commands/command_manager").CommandManager;
|
var CommandManager = require("./commands/command_manager").CommandManager;
|
||||||
var Autocomplete = require("./autocomplete").Autocomplete;
|
|
||||||
var defaultCommands = require("./commands/default_commands").commands;
|
var defaultCommands = require("./commands/default_commands").commands;
|
||||||
var config = require("./config");
|
var config = require("./config");
|
||||||
|
|
||||||
|
|
@ -90,7 +89,6 @@ var Editor = function(renderer, session) {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setSession(session || new EditSession(""));
|
this.setSession(session || new EditSession(""));
|
||||||
Autocomplete.addTo(this);
|
|
||||||
config.resetOptions(this);
|
config.resetOptions(this);
|
||||||
config._emit("editor", this);
|
config._emit("editor", this);
|
||||||
};
|
};
|
||||||
|
|
@ -1468,7 +1466,7 @@ var Editor = function(renderer, session) {
|
||||||
if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
|
if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
|
||||||
var range = selection.toOrientedRange();
|
var range = selection.toOrientedRange();
|
||||||
var rows = this.$getSelectedRows(range);
|
var rows = this.$getSelectedRows(range);
|
||||||
var linesMoved = mover.call(this, rows.first, rows.last);
|
var linesMoved = mover.call(this, rows.first, rows.last);
|
||||||
range.moveBy(linesMoved, 0);
|
range.moveBy(linesMoved, 0);
|
||||||
selection.fromOrientedRange(range);
|
selection.fromOrientedRange(range);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1486,14 +1484,14 @@ var Editor = function(renderer, session) {
|
||||||
first = rows.end.row;
|
first = rows.end.row;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
var linesMoved = mover.call(this, first, last);
|
var linesMoved = mover.call(this, first, last);
|
||||||
while (rangeIndex >= i) {
|
while (rangeIndex >= i) {
|
||||||
ranges[rangeIndex].moveBy(linesMoved, 0);
|
ranges[rangeIndex].moveBy(linesMoved, 0);
|
||||||
rangeIndex--;
|
rangeIndex--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selection.fromOrientedRange(selection.ranges[0]);
|
selection.fromOrientedRange(selection.ranges[0]);
|
||||||
selection.rangeList.attach(this.session);
|
selection.rangeList.attach(this.session);
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,58 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules;
|
var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules;
|
||||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
var highlighter = new GolangHighlightRules();
|
var highlighter = new GolangHighlightRules();
|
||||||
|
|
||||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||||
this.$keywordList = highlighter.$keywordList;
|
this.$keywordList = highlighter.$keywordList;
|
||||||
this.$outdent = new MatchingBraceOutdent();
|
this.$outdent = new MatchingBraceOutdent();
|
||||||
this.foldingRules = new CStyleFoldMode();
|
this.foldingRules = new CStyleFoldMode();
|
||||||
};
|
};
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.lineCommentStart = "//";
|
this.lineCommentStart = "//";
|
||||||
this.blockComment = {start: "/*", end: "*/"};
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||||
var tokens = tokenizedLine.tokens;
|
var tokens = tokenizedLine.tokens;
|
||||||
var endState = tokenizedLine.state;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
return indent;
|
return indent;
|
||||||
};//end getNextLineIndent
|
}
|
||||||
|
|
||||||
this.checkOutdent = function(state, line, input) {
|
if (state == "start") {
|
||||||
return this.$outdent.checkOutdent(line, input);
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||||
};
|
if (match) {
|
||||||
|
indent += tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.autoOutdent = function(state, doc, row) {
|
return indent;
|
||||||
this.$outdent.autoOutdent(doc, row);
|
};//end getNextLineIndent
|
||||||
};
|
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
return this.$outdent.checkOutdent(line, input);
|
||||||
|
};
|
||||||
|
|
||||||
exports.Mode = Mode;
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
this.$outdent.autoOutdent(doc, row);
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -30,33 +30,33 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("../mode/text").Mode;
|
var TextMode = require("../mode/text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules;
|
var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
var highlighter = new PgsqlHighlightRules();
|
var highlighter = new PgsqlHighlightRules();
|
||||||
|
|
||||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||||
this.$keywordList = highlighter.$keywordList;
|
this.$keywordList = highlighter.$keywordList;
|
||||||
};
|
};
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
this.lineCommentStart = "--";
|
this.lineCommentStart = "--";
|
||||||
this.blockComment = {start: "/*", end: "*/"};
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
if (state == "start" || state == "keyword.statementEnd") {
|
if (state == "start" || state == "keyword.statementEnd") {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
return this.$getIndent(line); // Keep whatever indent the previous line has
|
return this.$getIndent(line); // Keep whatever indent the previous line has
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,34 +7,26 @@ var lang = require("../lib/lang");
|
||||||
var Mirror = exports.Mirror = function(sender) {
|
var Mirror = exports.Mirror = function(sender) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
var doc = this.doc = new Document("");
|
var doc = this.doc = new Document("");
|
||||||
this.data = {};
|
|
||||||
|
|
||||||
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
|
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
sender.on("change", function(e) {
|
sender.on("change", function(e) {
|
||||||
doc.applyDeltas(e.data);
|
doc.applyDeltas(e.data);
|
||||||
if (_self.$defer)
|
deferredUpdate.schedule(_self.$timeout);
|
||||||
deferredUpdate.schedule(_self.$timeout);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.$timeout = 500;
|
this.$timeout = 500;
|
||||||
this.$defer = true;
|
|
||||||
|
|
||||||
this.setTimeout = function(timeout) {
|
this.setTimeout = function(timeout) {
|
||||||
this.$timeout = timeout;
|
this.$timeout = timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setDeferredUpdate = function(defer) {
|
this.setValue = function(value) {
|
||||||
this.$defer = defer;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setValue = function(value, data) {
|
|
||||||
this.doc.setValue(value);
|
this.doc.setValue(value);
|
||||||
this.data = data;
|
|
||||||
this.deferredUpdate.schedule(this.$timeout);
|
this.deferredUpdate.schedule(this.$timeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,12 +144,12 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) {
|
||||||
catch(ex) {}
|
catch(ex) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.attachToDocument = function(doc, data, ignore) {
|
this.attachToDocument = function(doc) {
|
||||||
if (this.$doc && !ignore)
|
if(this.$doc)
|
||||||
this.terminate();
|
this.terminate();
|
||||||
|
|
||||||
this.$doc = doc;
|
this.$doc = doc;
|
||||||
this.call("setValue", [doc.getValue(), data]);
|
this.call("setValue", [doc.getValue()]);
|
||||||
doc.on("change", this.changeListener);
|
doc.on("change", this.changeListener);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue