Sha256: 790a3e0f4c3713c66800639812ba29c701962db65165b8c61e3da38e187cafff

Contents?: true

Size: 1.98 KB

Versions: 159

Compression:

Stored size: 1.98 KB

Contents

// Utility function that allows modes to be combined. The mode given
// as the base argument takes care of most of the normal mode
// functionality, but a second (typically simple) mode is used, which
// can override the style of text. Both modes get to parse all of the
// text, but when both assign a non-null style to a piece of code, the
// overlay wins, unless the combine argument was true, in which case
// the styles are combined.

// overlayParser is the old, deprecated name
CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, combine) {
  return {
    startState: function() {
      return {
        base: CodeMirror.startState(base),
        overlay: CodeMirror.startState(overlay),
        basePos: 0, baseCur: null,
        overlayPos: 0, overlayCur: null
      };
    },
    copyState: function(state) {
      return {
        base: CodeMirror.copyState(base, state.base),
        overlay: CodeMirror.copyState(overlay, state.overlay),
        basePos: state.basePos, baseCur: null,
        overlayPos: state.overlayPos, overlayCur: null
      };
    },

    token: function(stream, state) {
      if (stream.start == state.basePos) {
        state.baseCur = base.token(stream, state.base);
        state.basePos = stream.pos;
      }
      if (stream.start == state.overlayPos) {
        stream.pos = stream.start;
        state.overlayCur = overlay.token(stream, state.overlay);
        state.overlayPos = stream.pos;
      }
      stream.pos = Math.min(state.basePos, state.overlayPos);
      if (stream.eol()) state.basePos = state.overlayPos = 0;

      if (state.overlayCur == null) return state.baseCur;
      if (state.baseCur != null && combine) return state.baseCur + " " + state.overlayCur;
      else return state.overlayCur;
    },
    
    indent: base.indent && function(state, textAfter) {
      return base.indent(state.base, textAfter);
    },
    electricChars: base.electricChars,

    innerMode: function(state) { return {state: state.base, mode: base}; }
  };
};

Version data entries

159 entries across 159 versions & 4 rubygems

Version Path
marty-2.4.7 app/components/marty/script_form/client/util/overlay.js
marty-2.4.6 app/components/marty/script_form/client/util/overlay.js
marty-2.4.5 app/components/marty/script_form/client/util/overlay.js
marty-2.4.4 app/components/marty/script_form/client/util/overlay.js
marty-2.4.3 app/components/marty/script_form/client/util/overlay.js
marty-2.4.2 app/components/marty/script_form/client/util/overlay.js
marty-2.4.1 app/components/marty/script_form/client/util/overlay.js
marty-2.4.0 app/components/marty/script_form/client/util/overlay.js
marty-2.3.15 app/components/marty/script_form/client/util/overlay.js
marty-2.3.14 app/components/marty/script_form/client/util/overlay.js
marty-2.3.13 app/components/marty/script_form/client/util/overlay.js
marty-2.3.12 app/components/marty/script_form/client/util/overlay.js
marty-2.3.11 app/components/marty/script_form/client/util/overlay.js
marty-2.3.10 app/components/marty/script_form/client/util/overlay.js
marty-2.3.9 app/components/marty/script_form/client/util/overlay.js
marty-2.3.8 app/components/marty/script_form/client/util/overlay.js
marty-2.3.7 app/components/marty/script_form/client/util/overlay.js
marty-2.3.5 app/components/marty/script_form/client/util/overlay.js
marty-2.3.4 app/components/marty/script_form/client/util/overlay.js
marty-2.1.5 app/components/marty/script_form/client/util/overlay.js