Vergleich admin/jscripts/codemirror/addon/search/match-highlighter.js - 1.8.1 - 1.8.8

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 8Zeile 8
// document.
//
// The option can be set to true to simply enable it, or to a

// document.
//
// The option can be set to true to simply enable it, or to a

// {minChars, style, showToken} object to explicitly configure it.
// minChars is the minimum amount of characters that should be

// {minChars, style, wordsOnly, showToken, delay} object to explicitly
// configure it. minChars is the minimum amount of characters that should be

// selected for the behavior to occur, and style is the token style to
// apply to the matches. This will be prefixed by "cm-" to create an

// selected for the behavior to occur, and style is the token style to
// apply to the matches. This will be prefixed by "cm-" to create an

// actual CSS class name. showToken, when enabled, will cause the
// current token to be highlighted when nothing is selected.




// actual CSS class name. If wordsOnly is enabled, the matches will be
// highlighted only if the selected text is a word. showToken, when enabled,
// will cause the current token to be highlighted when nothing is selected.
// delay is used to specify how much time to wait, in milliseconds, before
// highlighting the matches.


(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS


(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS

Zeile 28Zeile 31
  var DEFAULT_MIN_CHARS = 2;
var DEFAULT_TOKEN_STYLE = "matchhighlight";
var DEFAULT_DELAY = 100;

  var DEFAULT_MIN_CHARS = 2;
var DEFAULT_TOKEN_STYLE = "matchhighlight";
var DEFAULT_DELAY = 100;

 
  var DEFAULT_WORDS_ONLY = false;


function State(options) {
if (typeof options == "object") {


function State(options) {
if (typeof options == "object") {

Zeile 35Zeile 39
      this.style = options.style;
this.showToken = options.showToken;
this.delay = options.delay;

      this.style = options.style;
this.showToken = options.showToken;
this.delay = options.delay;

 
      this.wordsOnly = options.wordsOnly;

    }
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
if (this.delay == null) this.delay = DEFAULT_DELAY;

    }
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
if (this.delay == null) this.delay = DEFAULT_DELAY;

 
    if (this.wordsOnly == null) this.wordsOnly = DEFAULT_WORDS_ONLY;

    this.overlay = this.timeout = null;
}


    this.overlay = this.timeout = null;
}


Zeile 81Zeile 87
      }
var from = cm.getCursor("from"), to = cm.getCursor("to");
if (from.line != to.line) return;

      }
var from = cm.getCursor("from"), to = cm.getCursor("to");
if (from.line != to.line) return;

 
      if (state.wordsOnly && !isWord(cm, from, to)) return;

      var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
if (selection.length >= state.minChars)
cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style));
});

      var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
if (selection.length >= state.minChars)
cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style));
});

 
  }

function isWord(cm, from, to) {
var str = cm.getRange(from, to);
if (str.match(/^\w+$/) !== null) {
if (from.ch > 0) {
var pos = {line: from.line, ch: from.ch - 1};
var chr = cm.getRange(pos, from);
if (chr.match(/\W/) === null) return false;
}
if (to.ch < cm.getLine(from.line).length) {
var pos = {line: to.line, ch: to.ch + 1};
var chr = cm.getRange(to, pos);
if (chr.match(/\W/) === null) return false;
}
return true;
} else return false;

  }

function boundariesAround(stream, re) {

  }

function boundariesAround(stream, re) {