add support for inline mode in php worker
This commit is contained in:
parent
10e2c3049c
commit
3a864c6056
2 changed files with 11 additions and 3 deletions
|
|
@ -44,8 +44,8 @@ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||||
var unicode = require("../unicode");
|
var unicode = require("../unicode");
|
||||||
|
|
||||||
var Mode = function(opts) {
|
var Mode = function(opts) {
|
||||||
var inline = opts && opts.inline;
|
this.inlinePhp = opts && opts.inline;
|
||||||
var HighlightRules = inline ? PhpLangHighlightRules : PhpHighlightRules;
|
var HighlightRules = this.inlinePhp ? PhpLangHighlightRules : PhpHighlightRules;
|
||||||
this.HighlightRules = HighlightRules;
|
this.HighlightRules = HighlightRules;
|
||||||
this.$outdent = new MatchingBraceOutdent();
|
this.$outdent = new MatchingBraceOutdent();
|
||||||
this.$behaviour = new CstyleBehaviour();
|
this.$behaviour = new CstyleBehaviour();
|
||||||
|
|
@ -118,6 +118,9 @@ oop.inherits(Mode, TextMode);
|
||||||
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
|
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
|
||||||
worker.attachToDocument(session.getDocument());
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
||||||
|
if (this.inlinePhp)
|
||||||
|
worker.call("setOptions", [{inline: true}]);
|
||||||
|
|
||||||
worker.on("error", function(e) {
|
worker.on("error", function(e) {
|
||||||
session.setAnnotations(e.data);
|
session.setAnnotations(e.data);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,17 @@ var PhpWorker = exports.PhpWorker = function(sender) {
|
||||||
oop.inherits(PhpWorker, Mirror);
|
oop.inherits(PhpWorker, Mirror);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
this.setOptions = function(opts) {
|
||||||
|
this.inlinePhp = opts && opts.inline;
|
||||||
|
};
|
||||||
|
|
||||||
this.onUpdate = function() {
|
this.onUpdate = function() {
|
||||||
var value = this.doc.getValue();
|
var value = this.doc.getValue();
|
||||||
var errors = [];
|
var errors = [];
|
||||||
|
|
||||||
// var start = new Date();
|
// var start = new Date();
|
||||||
|
if (this.inlinePhp)
|
||||||
|
value = "<?" + value + "?>";
|
||||||
|
|
||||||
var tokens = PHP.Lexer(value, {short_open_tag: 1});
|
var tokens = PHP.Lexer(value, {short_open_tag: 1});
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue