Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/addon/mode/overlay.js
1293 views
// Utility function that allows modes to be combined. The mode given1// as the base argument takes care of most of the normal mode2// functionality, but a second (typically simple) mode is used, which3// can override the style of text. Both modes get to parse all of the4// text, but when both assign a non-null style to a piece of code, the5// overlay wins, unless the combine argument was true, in which case6// the styles are combined.78// overlayParser is the old, deprecated name9CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, combine) {10return {11startState: function() {12return {13base: CodeMirror.startState(base),14overlay: CodeMirror.startState(overlay),15basePos: 0, baseCur: null,16overlayPos: 0, overlayCur: null17};18},19copyState: function(state) {20return {21base: CodeMirror.copyState(base, state.base),22overlay: CodeMirror.copyState(overlay, state.overlay),23basePos: state.basePos, baseCur: null,24overlayPos: state.overlayPos, overlayCur: null25};26},2728token: function(stream, state) {29if (stream.start == state.basePos) {30state.baseCur = base.token(stream, state.base);31state.basePos = stream.pos;32}33if (stream.start == state.overlayPos) {34stream.pos = stream.start;35state.overlayCur = overlay.token(stream, state.overlay);36state.overlayPos = stream.pos;37}38stream.pos = Math.min(state.basePos, state.overlayPos);39if (stream.eol()) state.basePos = state.overlayPos = 0;4041if (state.overlayCur == null) return state.baseCur;42if (state.baseCur != null && combine) return state.baseCur + " " + state.overlayCur;43else return state.overlayCur;44},4546indent: base.indent && function(state, textAfter) {47return base.indent(state.base, textAfter);48},49electricChars: base.electricChars,5051innerMode: function(state) { return {state: state.base, mode: base}; },5253blankLine: function(state) {54if (base.blankLine) base.blankLine(state.base);55if (overlay.blankLine) overlay.blankLine(state.overlay);56}57};58};596061