GPQAPP
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function(mod) {5if (typeof exports == "object" && typeof module == "object") // CommonJS6mod(require("../../lib/codemirror"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14CodeMirror.defineMode("diff", function() {15
16var TOKEN_NAMES = {17'+': 'positive',18'-': 'negative',19'@': 'meta'20};21
22return {23token: function(stream) {24var tw_pos = stream.string.search(/[\t ]+?$/);25
26if (!stream.sol() || tw_pos === 0) {27stream.skipToEnd();28return ("error " + (29TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');30}31
32var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();33
34if (tw_pos === -1) {35stream.skipToEnd();36} else {37stream.pos = tw_pos;38}39
40return token_name;41}42};43});44
45CodeMirror.defineMIME("text/x-diff", "diff");46
47});48