129 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
ace.define("ace/mode/diff_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
 | 
						|
var oop = require("../lib/oop");
 | 
						|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 | 
						|
var DiffHighlightRules = function () {
 | 
						|
    this.$rules = {
 | 
						|
        "start": [{
 | 
						|
                regex: "^(?:\\*{15}|={67}|-{3}|\\+{3})$",
 | 
						|
                token: "punctuation.definition.separator.diff",
 | 
						|
                "name": "keyword"
 | 
						|
            }, {
 | 
						|
                regex: "^(@@)(\\s*.+?\\s*)(@@)(.*)$",
 | 
						|
                token: [
 | 
						|
                    "constant",
 | 
						|
                    "constant.numeric",
 | 
						|
                    "constant",
 | 
						|
                    "comment.doc.tag"
 | 
						|
                ]
 | 
						|
            }, {
 | 
						|
                regex: "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$",
 | 
						|
                token: [
 | 
						|
                    "constant.numeric",
 | 
						|
                    "punctuation.definition.range.diff",
 | 
						|
                    "constant.function",
 | 
						|
                    "constant.numeric",
 | 
						|
                    "punctuation.definition.range.diff",
 | 
						|
                    "invalid"
 | 
						|
                ],
 | 
						|
                "name": "meta."
 | 
						|
            }, {
 | 
						|
                regex: "^(\\-{3}|\\+{3}|\\*{3})( .+)$",
 | 
						|
                token: [
 | 
						|
                    "constant.numeric",
 | 
						|
                    "meta.tag"
 | 
						|
                ]
 | 
						|
            }, {
 | 
						|
                regex: "^([!+>])(.*?)(\\s*)$",
 | 
						|
                token: [
 | 
						|
                    "support.constant",
 | 
						|
                    "text",
 | 
						|
                    "invalid"
 | 
						|
                ]
 | 
						|
            }, {
 | 
						|
                regex: "^([<\\-])(.*?)(\\s*)$",
 | 
						|
                token: [
 | 
						|
                    "support.function",
 | 
						|
                    "string",
 | 
						|
                    "invalid"
 | 
						|
                ]
 | 
						|
            }, {
 | 
						|
                regex: "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
 | 
						|
                token: ["variable", "variable", "keyword", "variable"]
 | 
						|
            }, {
 | 
						|
                regex: "^Index.+$",
 | 
						|
                token: "variable"
 | 
						|
            }, {
 | 
						|
                regex: "^\\s+$",
 | 
						|
                token: "text"
 | 
						|
            }, {
 | 
						|
                regex: "\\s*$",
 | 
						|
                token: "invalid"
 | 
						|
            }, {
 | 
						|
                defaultToken: "invisible",
 | 
						|
                caseInsensitive: true
 | 
						|
            }
 | 
						|
        ]
 | 
						|
    };
 | 
						|
};
 | 
						|
oop.inherits(DiffHighlightRules, TextHighlightRules);
 | 
						|
exports.DiffHighlightRules = DiffHighlightRules;
 | 
						|
 | 
						|
});
 | 
						|
 | 
						|
ace.define("ace/mode/folding/diff",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){"use strict";
 | 
						|
var oop = require("../../lib/oop");
 | 
						|
var BaseFoldMode = require("./fold_mode").FoldMode;
 | 
						|
var Range = require("../../range").Range;
 | 
						|
var FoldMode = exports.FoldMode = function (levels, flag) {
 | 
						|
    this.regExpList = levels;
 | 
						|
    this.flag = flag;
 | 
						|
    this.foldingStartMarker = RegExp("^(" + levels.join("|") + ")", this.flag);
 | 
						|
};
 | 
						|
oop.inherits(FoldMode, BaseFoldMode);
 | 
						|
(function () {
 | 
						|
    this.getFoldWidgetRange = function (session, foldStyle, row) {
 | 
						|
        var line = session.getLine(row);
 | 
						|
        var start = { row: row, column: line.length };
 | 
						|
        var regList = this.regExpList;
 | 
						|
        for (var i = 1; i <= regList.length; i++) {
 | 
						|
            var re = RegExp("^(" + regList.slice(0, i).join("|") + ")", this.flag);
 | 
						|
            if (re.test(line))
 | 
						|
                break;
 | 
						|
        }
 | 
						|
        for (var l = session.getLength(); ++row < l;) {
 | 
						|
            line = session.getLine(row);
 | 
						|
            if (re.test(line))
 | 
						|
                break;
 | 
						|
        }
 | 
						|
        if (row == start.row + 1)
 | 
						|
            return;
 | 
						|
        return new Range(start.row, start.column, row - 1, line.length);
 | 
						|
    };
 | 
						|
}).call(FoldMode.prototype);
 | 
						|
 | 
						|
});
 | 
						|
 | 
						|
ace.define("ace/mode/diff",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/diff_highlight_rules","ace/mode/folding/diff"], function(require, exports, module){"use strict";
 | 
						|
var oop = require("../lib/oop");
 | 
						|
var TextMode = require("./text").Mode;
 | 
						|
var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules;
 | 
						|
var FoldMode = require("./folding/diff").FoldMode;
 | 
						|
var Mode = function () {
 | 
						|
    this.HighlightRules = HighlightRules;
 | 
						|
    this.foldingRules = new FoldMode(["diff", "@@|\\*{5}"], "i");
 | 
						|
};
 | 
						|
oop.inherits(Mode, TextMode);
 | 
						|
(function () {
 | 
						|
    this.$id = "ace/mode/diff";
 | 
						|
    this.snippetFileId = "ace/snippets/diff";
 | 
						|
}).call(Mode.prototype);
 | 
						|
exports.Mode = Mode;
 | 
						|
 | 
						|
});                (function() {
 | 
						|
                    ace.require(["ace/mode/diff"], function(m) {
 | 
						|
                        if (typeof module == "object" && typeof exports == "object" && module) {
 | 
						|
                            module.exports = m;
 | 
						|
                        }
 | 
						|
                    });
 | 
						|
                })();
 | 
						|
            
 |