Skip to content

Commit

Permalink
add support for inline mode in php worker
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Dec 16, 2013
1 parent 10e2c30 commit 3a864c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/ace/mode/php.js
Expand Up @@ -44,8 +44,8 @@ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var unicode = require("../unicode");

var Mode = function(opts) {
var inline = opts && opts.inline;
var HighlightRules = inline ? PhpLangHighlightRules : PhpHighlightRules;
this.inlinePhp = opts && opts.inline;
var HighlightRules = this.inlinePhp ? PhpLangHighlightRules : PhpHighlightRules;
this.HighlightRules = HighlightRules;
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
Expand Down Expand Up @@ -117,6 +117,9 @@ oop.inherits(Mode, TextMode);
this.createWorker = function(session) {
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
worker.attachToDocument(session.getDocument());

if (this.inlinePhp)
worker.call("setOptions", [{inline: true}]);

worker.on("error", function(e) {
session.setAnnotations(e.data);
Expand Down
7 changes: 6 additions & 1 deletion lib/ace/mode/php_worker.js
Expand Up @@ -43,12 +43,17 @@ var PhpWorker = exports.PhpWorker = function(sender) {
oop.inherits(PhpWorker, Mirror);

(function() {

this.setOptions = function(opts) {
this.inlinePhp = opts && opts.inline;
};

this.onUpdate = function() {
var value = this.doc.getValue();
var errors = [];

// var start = new Date();
if (this.inlinePhp)
value = "<?" + value + "?>";

var tokens = PHP.Lexer(value, {short_open_tag: 1});
try {
Expand Down

0 comments on commit 3a864c6

Please sign in to comment.