Changeset 49339 in spip-zone


Ignore:
Timestamp:
Jul 4, 2011, 10:58:54 PM (10 years ago)
Author:
guy.cesaro@…
Message:

up de la lib codemirror en 2.11 avec des nouveautes sympas voir http://codemirror.net/ (mode fullscreen, YAML...)

Location:
_plugins_/skeleditor/trunk/spip_210/codemirror
Files:
8 added
16 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/skeleditor/trunk/spip_210/codemirror/README.md

    r46386 r49339  
    33CodeMirror 2 is a rewrite of [CodeMirror
    441](http://github.com/marijnh/CodeMirror). The docs live
    5 [here](http://codemirror.net/2/manual.html), and the project page is
    6 [http://codemirror.net/2/](http://codemirror.net/2/).
     5[here](http://codemirror.net/manual.html), and the project page is
     6[http://codemirror.net/](http://codemirror.net/).
  • _plugins_/skeleditor/trunk/spip_210/codemirror/compress.html

    r48687 r49339  
    2828      <p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px">
    2929        <option value="http://codemirror.net/">HEAD</option>
     30        <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=v2.11;f=">2.11</option>
    3031        <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=v2.1;f=">2.1</option>
    3132        <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=v2.02;f=">2.02</option>
     
    5758          <option value="http://codemirror.net/mode/plsql/plsql.js">plsql.js</option>
    5859          <option value="http://codemirror.net/mode/lua/lua.js">lua.js</option>
     60          <option value="http://codemirror.net/mode/scheme/scheme.js">scheme.js</option>
     61          <option value="http://codemirror.net/mode/yaml/yaml.js">scheme.js</option>
    5962        </optgroup>
    6063      </select></p>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/search.html

    r48687 r49339  
    9696  if (!text) return;
    9797  for (var cursor = editor.getSearchCursor(text); cursor.findNext();)
    98     editor.replaceRange(replace, cursor.from(), cursor.to());
     98    cursor.replace(replace);
    9999}
    100100</script>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/theme.html

    r48687 r49339  
    3333}</textarea></form>
    3434
    35 <p>Select a theme: <select onchange="selectTheme(this.value)">
     35<p>Select a theme: <select onchange="selectTheme(this)">
    3636    <option selected>default</option>
    3737    <option>night</option>
     
    4545    lineNumbers: true
    4646  });
    47   function selectTheme(theme) {
     47  function selectTheme(node) {
     48    var theme = node.options[node.selectedIndex].innerHTML;
    4849    editor.setOption("theme", theme);
    4950  }
  • _plugins_/skeleditor/trunk/spip_210/codemirror/index.html

    r48687 r49339  
    4343      <li><a href="mode/php/index.html">PHP</a></li>
    4444      <li><a href="mode/diff/index.html">diff</a></li>
    45       <li><a href="mode/clike/index.html">C, Java, and similar</a></li>
     45      <li><a href="mode/clike/index.html">C, Java, C#, and similar</a></li>
    4646      <li><a href="mode/stex/index.html">sTeX, LaTeX</a></li>
    4747      <li><a href="mode/haskell/index.html">Haskell</a></li>
    4848      <li><a href="mode/smalltalk/index.html">Smalltalk</a></li>
    49       <li><a href="mode/rst/index.html">reStructuredText</a></li>
    5049      <li><a href="mode/plsql/index.html">PL/SQL</a></li>
    5150      <li><a href="mode/lua/index.html">Lua</a></li>
     51      <li><a href="mode/scheme/index.html">Scheme</a></li>
     52      <li><a href="mode/rst/index.html">reStructuredText</a></li>
     53      <li><a href="mode/yaml/index.html">YAML</a></li>
    5254    </ul>
    5355
     
    6567      <li><a href="demo/theme.html">Theming</a></li>
    6668      <li><a href="demo/runmode.html">Stand-alone highlighting</a></li>
     69      <li><a href="demo/fullscreen.html">Full-screen editing</a></li>
     70      <li><a href="demo/changemode.html">Mode auto-changing</a></li>
    6771    </ul>
    6872
     
    154158  <h2>Releases:</h2>
    155159
    156   <p class="rel">07-06-2011: <a href="http://codemirror.net/codemirror-2.02.zip">Version 2.1</a>:</p>
     160  <p class="rel">04-07-2011: <a href="http://codemirror.net/codemirror-2.11.zip">Version 2.11</a>:</p>
     161  <ul class="rel-note">
     162    <li>Add a <a href="mode/scheme/index.html">Scheme mode</a>.</li>
     163    <li>Add a <code>replace</code> method to search cursors, for cursor-preserving replacements.</li>
     164    <li>Make the <a href="mode/clike/index.html">C-like mode</a> mode more customizeable.</li>
     165    <li>Update XML mode to spot mismatched tags.</li>
     166    <li>Add <code>getStateAfter</code> API and <code>compareState</code> mode API methods for finer-grained mode magic.</li>
     167    <li>Add a <code>getScrollerElement</code> API method to manipulate the scrolling DIV.</li>
     168    <li>Fix drag-and-drop for Firefox.</li>
     169    <li>Add a C# configuration for the <a href="mode/clike/index.html">C-like mode</a>.</li>
     170    <li>Add <a href="demo/fullscreen.html">full-screen editing</a> and <a href="demo/changemode.html">mode-changing</a> demos.</li>
     171  </ul>
     172
     173  <p class="rel">07-06-2011: <a href="http://codemirror.net/codemirror-2.1.zip">Version 2.1</a>:</p>
    157174  <p class="rel-note">Add
    158175  a <a href="manual.html#option_theme">theme</a> system
     
    208225  <p class="rel-note">Somewhate more mature API, lots of bugs shaken out.</a>
    209226
    210   <p class="rel">17-02-2011: <a href="http://codemirror.net/codemirror-0.94.zip">Version 0.94</a>:</p>
    211   <ul class="rel-note">
    212     <li><code>tabMode: "spaces"</code> was modified slightly (now indents when something is selected).</li>
    213     <li>Fixes a bug that would cause the selection code to break on some IE versions.</li>
    214     <li>Disabling spell-check on WebKit browsers now works.</li>
    215   </ul>
    216 
    217   <p class="rel">08-02-2011: <a href="http://codemirror.net/2/">Version 2.0 beta 1</a>:</p>
    218   <p class="rel-note">CodeMirror 2 is a complete rewrite of
    219   CodeMirror, no longer depending on an editable frame.</p>
    220 
    221227  <p><a href="oldrelease.html">Older releases...</a></p>
    222228
  • _plugins_/skeleditor/trunk/spip_210/codemirror/internals.html

    r48687 r49339  
    359359I haven't put much energy into that yet.</li>
    360360
     361<li><strong>Limited interaction with the editable panel.</strong>
     362Since the element you're looking at is not a real editable panel,
     363native browser behaviour for editable controls doesn't work
     364automatically. Through a lot of event glue code, I've managed to make
     365drag and drop work pretty well, have context menus work on most
     366browsers (except Opera). Middle-click paste on Firefox in Linux is
     367broken until someone finds a way to intercept it.</li>
     368
    361369</ul>
    362370
  • _plugins_/skeleditor/trunk/spip_210/codemirror/lib/codemirror.css

    r48687 r49339  
    77  overflow: auto;
    88  height: 300px;
     9  /* This is needed to prevent an IE[67] bug where the scrolled content
     10     is visible outside of the scrolling box. */
     11  position: relative;
    912}
    1013
  • _plugins_/skeleditor/trunk/spip_210/codemirror/lib/codemirror.js

    r48687 r49339  
    7575    var maxLine = "";
    7676
    77     // Initialize the content. Somewhat hacky (delayed prepareInput)
    78     // to work around browser issues.
     77    // Initialize the content.
    7978    operation(function(){setValue(options.value || ""); updateInput = false;})();
    80     setTimeout(prepareInput, 20);
    8179
    8280    // Register our event handlers.
     
    8583    // which point we can't mess with it anymore. Context menu is
    8684    // handled in onMouseDown for Gecko.
    87     if (!gecko) connect(scroller, "contextmenu", operation(onContextMenu));
     85    if (!gecko) connect(scroller, "contextmenu", onContextMenu);
    8886    connect(code, "dblclick", operation(onDblClick));
    8987    connect(scroller, "scroll", function() {updateDisplay([]); if (options.onScroll) options.onScroll(instance);});
     
    105103    // trying to access activeElement before onload
    106104    var hasFocus; try { hasFocus = (targetDocument.activeElement == input); } catch(e) { }
    107     if (hasFocus) onFocus();
     105    if (hasFocus) setTimeout(onFocus, 20);
    108106    else onBlur();
    109107
     
    119117      getSelection: getSelection,
    120118      replaceSelection: operation(replaceSelection),
    121       focus: function(){focusInput(); onFocus(); prepareInput(); fastPoll();},
     119      focus: function(){focusInput(); onFocus(); fastPoll();},
    122120      setOption: function(option, value) {
    123121        options[option] = value;
     
    137135        return lines[pos.line].getTokenAt(mode, getStateBefore(pos.line), pos.ch);
    138136      },
     137      getStateAfter: function(line) {
     138        line = clipLine(line == null ? lines.length - 1: line);
     139        return getStateBefore(line + 1);
     140      },
    139141      cursorCoords: function(start){
    140142        if (start == null) start = sel.inverted;
     
    153155      setLineClass: operation(setLineClass),
    154156      lineInfo: lineInfo,
    155       addWidget: function(pos, node, scroll) {
    156         var pos = localCoords(clipPos(pos), true);
    157         node.style.top = (showingFrom * lineHeight() + pos.yBot + paddingTop()) + "px";
    158         node.style.left = (pos.x + paddingLeft()) + "px";
     157      addWidget: function(pos, node, scroll, where) {
     158        pos = localCoords(clipPos(pos));
     159        var top = pos.yBot, left = pos.x;
     160        node.style.position = "absolute";
    159161        code.appendChild(node);
     162        node.style.left = left + "px";
     163        if (where == "over") top = pos.y;
     164        else if (where == "fit") {
     165          var vspace = lines.length * lineHeight(), hspace = code.clientWidth - paddingLeft();
     166          top = pos.y + node.offsetHeight > vspace ? vspace - node.offsetHeight : pos.y;
     167          if (left + node.offsetWidth > hspace) left = hspace - node.offsetWidth;
     168        }
     169        node.style.top = (top + paddingTop()) + "px";
     170        node.style.left = (left + paddingLeft()) + "px";
    160171        if (scroll)
    161           scrollIntoView(pos.x, pos.yBot, pos.x + node.offsetWidth, pos.yBot + node.offsetHeight);
     172          scrollIntoView(left, top, left + node.offsetWidth, top + node.offsetHeight);
    162173      },
    163174
     
    186197      refresh: function(){updateDisplay(true);},
    187198      getInputField: function(){return input;},
    188       getWrapperElement: function(){return wrapper;}
     199      getWrapperElement: function(){return wrapper;},
     200      getScrollerElement: function(){return scroller;}
    189201    };
    190202
     
    213225        }
    214226
    215       if (gecko && e.button() == 3) onContextMenu(e);
    216       if (e.button() != 1) return;
     227      var start = posFromMouse(e);
     228      switch (e.button()) {
     229      case 3:
     230        if (gecko && !mac) onContextMenu(e);
     231        return;
     232      case 2:
     233        if (start) setCursor(start.line, start.ch, true);
     234        return;
     235      }
    217236      // For button 1, if it was clicked inside the editor
    218237      // (posFromMouse returning non-null), we have to adjust the
    219238      // selection.
    220       var start = posFromMouse(e), last = start, going;
    221239      if (!start) {if (e.target() == scroller) e.stop(); return;}
    222240
     
    226244
    227245      setCursor(start.line, start.ch, true);
     246      var last = start, going;
    228247      // And then we have to see if it's a drag event, in which case
    229248      // the dragged-over text must be selected.
     
    267286    }
    268287    function onDrop(e) {
     288      e.e.preventDefault();
    269289      var pos = posFromMouse(e, true), files = e.e.dataTransfer.files;
    270290      if (!pos || options.readOnly) return;
    271291      if (files && files.length && window.FileReader && window.File) {
    272         var n = files.length, text = Array(n), read = 0;
    273         for (var i = 0; i < n; ++i) loadFile(files[i], i);
    274292        function loadFile(file, i) {
    275293          var reader = new FileReader;
     
    280298          reader.readAsText(file);
    281299        }
     300        var n = files.length, text = Array(n), read = 0;
     301        for (var i = 0; i < n; ++i) loadFile(files[i], i);
    282302      }
    283303      else {
     
    355375    function onFocus() {
    356376      if (options.readOnly == "nocursor") return;
    357       if (!focused && options.onFocus) options.onFocus(instance);
    358       focused = true;
     377      if (!focused) {
     378        if (options.onFocus) options.onFocus(instance);
     379        focused = true;
     380        if (wrapper.className.search(/\bCodeMirror-focused\b/) == -1)
     381          wrapper.className += " CodeMirror-focused";
     382        if (!leaveInputAlone) prepareInput();
     383      }
    359384      slowPoll();
    360       if (wrapper.className.search(/\bCodeMirror-focused\b/) == -1)
    361         wrapper.className += " CodeMirror-focused";
    362385      restartBlink();
    363386    }
    364387    function onBlur() {
    365       if (focused && options.onBlur) options.onBlur(instance);
     388      if (focused) {
     389        if (options.onBlur) options.onBlur(instance);
     390        focused = false;
     391        wrapper.className = wrapper.className.replace(" CodeMirror-focused", "");
     392      }
    366393      clearInterval(blinker);
    367       shiftSelecting = null;
    368       focused = false;
    369       wrapper.className = wrapper.className.replace(" CodeMirror-focused", "");
     394      setTimeout(function() {if (!focused) shiftSelecting = null;}, 150);
    370395    }
    371396
     
    380405      }
    381406      updateLinesNoUndo(from, to, newText, selFrom, selTo);
    382       if (newText.length < 5)
    383         highlightLines(from.line, from.line + newText.length)
    384407    }
    385408    function unredoHelper(from, to) {
     
    455478        else if (task > to.line) newWork.push(task + lendiff);
    456479      }
    457       if (newText.length) newWork.push(from.line);
     480      if (newText.length < 5) {
     481        highlightLines(from.line, from.line + newText.length);
     482        newWork.push(from.line + newText.length);
     483      } else {
     484        newWork.push(from.line);
     485      }
    458486      work = newWork;
    459487      startWorker(100);
     
    736764      var textWidth = stringWidth(maxLine);
    737765      lineSpace.style.width = textWidth > scroller.clientWidth ? textWidth + "px" : "";
     766      // Needed to prevent odd wrapping/hiding of widgets placed in here.
     767      code.style.width = (lineSpace.offsetWidth + lineSpace.offsetLeft) + "px";
    738768
    739769      // Since this is all rather error prone, it is honoured with the
     
    928958    }
    929959    function handleTab(shift) {
     960      function indentSelected(mode) {
     961        if (posEq(sel.from, sel.to)) return indentLine(sel.from.line, mode);
     962        var e = sel.to.line - (sel.to.ch ? 1 : 0);
     963        for (var i = sel.from.line; i < e; ++i) indentLine(i, mode);
     964      }
    930965      shiftSelecting = null;
    931966      switch (options.tabMode) {
     
    933968        return false;
    934969      case "indent":
    935         for (var i = sel.from.line, e = sel.to.line; i <= e; ++i) indentLine(i, "smart");
     970        indentSelected("smart");
    936971        break;
    937972      case "classic":
     
    942977        }
    943978      case "shift":
    944         for (var i = sel.from.line, e = sel.to.line; i <= e; ++i) indentLine(i, shift ? "subtract" : "add");
     979        indentSelected(shift ? "subtract" : "add");
    945980        break;
    946981      }
     
    11231158
    11241159    function posFromMouse(e, liberal) {
    1125       var offW = eltOffset(scroller, true), x = e.e.clientX, y = e.e.clientY;
     1160      var offW = eltOffset(scroller, true), x, y;
     1161      // Fails unpredictably on IE[67] when mouse is dragged around quickly.
     1162      try { x = e.e.clientX; y = e.e.clientY; } catch (e) { return null; }
    11261163      // This is a mess of a heuristic to try and determine whether a
    11271164      // scroll-bar was clicked or not, and to return null if one was
     
    11371174      if (!pos || window.opera) return; // Opera is difficult.
    11381175      if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))
    1139         setCursor(pos.line, pos.ch);
     1176        operation(setCursor)(pos.line, pos.ch);
    11401177
    11411178      var oldCSS = input.style.cssText;
     1179      inputDiv.style.position = "absolute";
    11421180      input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.pageY() - 1) +
    11431181        "px; left: " + (e.pageX() - 1) + "px; z-index: 1000; background: white; " +
    1144         "border-width: 0; outline: none; overflow: hidden; opacity: .05;";
     1182        "border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
     1183      leaveInputAlone = true;
    11451184      var val = input.value = getSelection();
    11461185      focusInput();
    11471186      setSelRange(input, 0, input.value.length);
    1148       leaveInputAlone = true;
    11491187      function rehide() {
    1150         if (input.value != val) operation(replaceSelection)(input.value, "end");
     1188        var newVal = splitLines(input.value).join("\n");
     1189        if (newVal != val) operation(replaceSelection)(newVal, "end");
     1190        inputDiv.style.position = "relative";
    11511191        input.style.cssText = oldCSS;
    11521192        leaveInputAlone = false;
     
    11561196     
    11571197      if (gecko) {
    1158         e.stop()
     1198        e.stop();
    11591199        var mouseup = connect(window, "mouseup", function() {
    11601200          mouseup();
     
    12031243        }
    12041244      }
    1205       for (var i = head.line, e = forward ? Math.min(i + 50, lines.length) : Math.max(-1, i - 50); i != e; i+=d) {
     1245      for (var i = head.line, e = forward ? Math.min(i + 100, lines.length) : Math.max(-1, i - 100); i != e; i+=d) {
    12061246        var line = lines[i], first = i == head.line;
    12071247        var found = scan(line, first && forward ? pos + 1 : 0, first && !forward ? pos : line.text.length);
    1208         if (found) {
    1209           var style = found.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
    1210           var one = markText({line: head.line, ch: pos}, {line: head.line, ch: pos+1}, style),
    1211               two = markText({line: i, ch: found.pos}, {line: i, ch: found.pos + 1}, style);
    1212           var clear = operation(function(){one(); two();});
    1213           if (autoclear) setTimeout(clear, 800);
    1214           else bracketHighlighted = clear;
    1215           break;
    1216         }
    1217       }
     1248        if (found) break;
     1249      }
     1250      if (!found) found = {pos: null, match: false};
     1251      var style = found.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
     1252      var one = markText({line: head.line, ch: pos}, {line: head.line, ch: pos+1}, style),
     1253          two = found.pos != null
     1254            ? markText({line: i, ch: found.pos}, {line: i, ch: found.pos + 1}, style)
     1255            : function() {};
     1256      var clear = operation(function(){one(); two();});
     1257      if (autoclear) setTimeout(clear, 800);
     1258      else bracketHighlighted = clear;
    12181259    }
    12191260
     
    12681309        else state = startState(mode);
    12691310
    1270         var unchanged = 0;
     1311        var unchanged = 0, compare = mode.compareStates;
    12711312        for (var i = start, l = lines.length; i < l; ++i) {
    12721313          var line = lines[i], hadState = line.stateAfter;
     
    12791320          var changed = line.highlight(mode, state);
    12801321          line.stateAfter = copyState(mode, state);
    1281           if (changed || !hadState) unchanged = 0;
    1282           else if (++unchanged > 3) break;
     1322          if (compare) {
     1323            if (hadState && compare(hadState, state)) break;
     1324          } else {
     1325            if (changed || !hadState) unchanged = 0;
     1326            else if (++unchanged > 3) break;
     1327          }
    12831328        }
    12841329        changes.push({from: task, to: i});
     
    13091354      // updateInput can be set to a boolean value to force/prevent an
    13101355      // update.
    1311       if (!leaveInputAlone && (updateInput === true || (updateInput !== false && selectionChanged)))
     1356      if (focused && !leaveInputAlone &&
     1357          (updateInput === true || (updateInput !== false && selectionChanged)))
    13121358        prepareInput();
    13131359
     
    14361482
    14371483      from: function() {if (this.atOccurrence) return copyPos(this.pos.from);},
    1438       to: function() {if (this.atOccurrence) return copyPos(this.pos.to);}
     1484      to: function() {if (this.atOccurrence) return copyPos(this.pos.to);},
     1485
     1486      replace: function(newText) {
     1487        var self = this;
     1488        if (this.atOccurrence)
     1489          operation(function() {
     1490            self.pos.to = replaceRange(newText, self.pos.from, self.pos.to);
     1491          })();
     1492      }
    14391493    };
    14401494
     
    14961550    }
    14971551    return mfactory(options, config || {});
    1498   }
     1552  };
    14991553  CodeMirror.listModes = function() {
    15001554    var list = [];
     
    19311985  }
    19321986
     1987  function computedStyle(elt) {
     1988    if (elt.currentStyle) return elt.currentStyle;
     1989    return window.getComputedStyle(elt, null);
     1990  }
    19331991  // Find the position of an element by following the offsetParent chain.
    19341992  // If screen==true, it returns screen (rather than page) coordinates.
    19351993  function eltOffset(node, screen) {
    19361994    var doc = node.ownerDocument.body;
    1937     var x = 0, y = 0, hitDoc = false;
     1995    var x = 0, y = 0, skipDoc = false;
    19381996    for (var n = node; n; n = n.offsetParent) {
    19391997      x += n.offsetLeft; y += n.offsetTop;
    1940       // Fixed-position elements don't have the document in their offset chain
    1941       if (n == doc) hitDoc = true;
    1942     }
    1943     var e = screen && hitDoc ? null : doc;
     1998      if (screen && computedStyle(n).position == "fixed")
     1999        skipDoc = true;
     2000    }
     2001    var e = screen && !skipDoc ? null : doc;
    19442002    for (var n = node.parentNode; n != e; n = n.parentNode)
    19452003      if (n.scrollLeft != null) { x -= n.scrollLeft; y -= n.scrollTop;}
     
    19822040  // See if "".split is the broken IE version, if so, provide an
    19832041  // alternative way to split lines.
     2042  var splitLines, selRange, setSelRange;
    19842043  if ("\n\nb".split(/\n/).length != 3)
    1985     var splitLines = function(string) {
     2044    splitLines = function(string) {
    19862045      var pos = 0, nl, result = [];
    19872046      while ((nl = string.indexOf("\n", pos)) > -1) {
     
    19932052    };
    19942053  else
    1995     var splitLines = function(string){return string.split(/\r?\n/);};
     2054    splitLines = function(string){return string.split(/\r?\n/);};
    19962055  CodeMirror.splitLines = splitLines;
    19972056
    19982057  // Sane model of finding and setting the selection in a textarea
    19992058  if (window.getSelection) {
    2000     var selRange = function(te) {
     2059    selRange = function(te) {
    20012060      try {return {start: te.selectionStart, end: te.selectionEnd};}
    20022061      catch(e) {return null;}
     
    20092068      // front. This is not what CodeMirror wants, so it does a
    20102069      // spurious modify() call to get out of limbo.
    2011       var setSelRange = function(te, start, end) {
     2070      setSelRange = function(te, start, end) {
    20122071        if (start == end)
    20132072          te.setSelectionRange(start, end);
     
    20182077      };
    20192078    else
    2020       var setSelRange = function(te, start, end) {
     2079      setSelRange = function(te, start, end) {
    20212080        try {te.setSelectionRange(start, end);}
    20222081        catch(e) {} // Fails on Firefox when textarea isn't part of the document
     
    20252084  // IE model. Don't ask.
    20262085  else {
    2027     var selRange = function(te) {
     2086    selRange = function(te) {
    20282087      try {var range = te.ownerDocument.selection.createRange();}
    20292088      catch(e) {return null;}
     
    20472106      return {start: start, end: end};
    20482107    };
    2049     var setSelRange = function(te, start, end) {
     2108    setSelRange = function(te, start, end) {
    20502109      var range = te.createTextRange();
    20512110      range.collapse(true);
  • _plugins_/skeleditor/trunk/spip_210/codemirror/manual.html

    r48687 r49339  
    448448          not return false. They will return <code>{line, ch}</code>
    449449          objects pointing at the start and end of the match.</dd>
     450          <dt><code>replace(text)</code></dt>
     451          <dd>Replaces the currently found match with the given text
     452          and adjusts the cursor position to reflect the
     453          replacement.</dd>
    450454        </dl></dd>
    451455
     
    460464        <dt><code>className</code></dt><dd>The class the mode assigned
    461465        to the token. (Can be null when no class was assigned.)</dd>
     466        <dt><code>state</code></dt><dd>The mode's state at the end of this token.</dd>
    462467      </dl></dd>
    463468
     
    572577      <dd>Returns the DOM node that represents the editor. Remove this
    573578      from your tree to delete an editor instance.</dd>
     579      <dt id="getScrollerElement"><code>getScrollerElement() → node</code></dt>
     580      <dd>Returns the DOM node that is responsible for the sizing and
     581      the scrolling of the editor. You can change
     582      the <code>height</code> and <code>width</code> styles of this
     583      element to resize an editor. (You might have to call
     584      the <a href="#refresh"><code>refresh</code></a> method
     585      afterwards.)</dd>
     586
     587      <dt id="getStateAfter"><code>getStateAfter(line) → state</code></dt>
     588      <dd>Returns the mode's parser state, if any, at the end of the
     589      given line number. If no line number is given, the state at the
     590      end of the document is returned. This can be useful for storing
     591      parsing errors in the state, or getting other kinds of
     592      contextual information for a line.</dd>
    574593    </dl>
    575594
     
    654673    mode does) and have people include a custom theme for your
    655674    mode.<p>
    656 
    657     <p id="blankLine">By default, blank lines are simply skipped when
    658     tokenizing a document. For languages that have significant blank
    659     lines, you can define a <code>blankLine(state)</code> method on
    660     your mode that will get called whenever a blank line is passed
    661     over, so that it can update the parser state.</p>
    662675
    663676    <p id="StringStream">The stream object encapsulates a line of code
     
    728741    </dl>
    729742
     743    <p id="blankLine">By default, blank lines are simply skipped when
     744    tokenizing a document. For languages that have significant blank
     745    lines, you can define a <code>blankLine(state)</code> method on
     746    your mode that will get called whenever a blank line is passed
     747    over, so that it can update the parser state.</p>
     748
    730749    <p id="copyState">Because state object are mutated, and CodeMirror
    731750    needs to keep valid versions of a state around so that it can
     
    739758    which is given a state and should return a safe copy of that
    740759    state.</p>
     760
     761    <p id="compareStates">By default, CodeMirror will stop re-parsing
     762    a document as soon as it encounters a few lines that were
     763    highlighted the same in the old parse as in the new one. It is
     764    possible to provide an explicit way to test whether a state is
     765    equivalent to another one, which CodeMirror will use (instead of
     766    the unchanged-lines heuristic) to decide when to stop
     767    highlighting. You do this by providing
     768    a <code>compareStates</code> method on your mode object, which
     769    takes two state arguments and returns a boolean indicating whether
     770    they are equivalent. See the XML mode, which uses this to provide
     771    reliable highlighting of bad closing tags, as an example.</p>
    741772
    742773    <p id="indent">If you want your mode to provide smart indentation
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/clike/clike.js

    r48687 r49339  
    11CodeMirror.defineMode("clike", function(config, parserConfig) {
    2   var indentUnit = config.indentUnit, keywords = parserConfig.keywords,
    3       cpp = parserConfig.useCPP, multiLineStrings = parserConfig.multiLineStrings,
    4       $vars = parserConfig.$vars, atAnnotations = parserConfig.atAnnotations;
    5   var isOperatorChar = /[+\-*&%=<>!?|]/;
    6 
    7   function chain(stream, state, f) {
    8     state.tokenize = f;
    9     return f(stream, state);
    10   }
    11 
    12   var type;
    13   function ret(tp, style) {
    14     type = tp;
    15     return style;
    16   }
     2  var indentUnit = config.indentUnit,
     3      keywords = parserConfig.keywords || {},
     4      atoms = parserConfig.atoms || {},
     5      hooks = parserConfig.hooks || {},
     6      multiLineStrings = parserConfig.multiLineStrings;
     7  var isOperatorChar = /[+\-*&%=<>!?|\/]/;
     8
     9  var curPunc;
    1710
    1811  function tokenBase(stream, state) {
    1912    var ch = stream.next();
    20     if (ch == '"' || ch == "'")
    21       return chain(stream, state, tokenString(ch));
    22     else if (/[\[\]{}\(\),;\:\.]/.test(ch))
    23       return ret(ch);
    24     else if (ch == "#" && cpp && state.startOfLine) {
    25       stream.skipToEnd();
    26       return ret("directive", "meta");
    27     }
    28     else if (/\d/.test(ch)) {
    29       stream.eatWhile(/[\w\.]/)
    30       return ret("number", "number");
    31     }
    32     else if (ch == "/") {
     13    if (hooks[ch]) {
     14      var result = hooks[ch](stream, state);
     15      if (result !== false) return result;
     16    }
     17    if (ch == '"' || ch == "'") {
     18      state.tokenize = tokenString(ch);
     19      return state.tokenize(stream, state);
     20    }
     21    if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
     22      curPunc = ch;
     23      return null
     24    }
     25    if (/\d/.test(ch)) {
     26      stream.eatWhile(/[\w\.]/);
     27      return "number";
     28    }
     29    if (ch == "/") {
    3330      if (stream.eat("*")) {
    34         return chain(stream, state, tokenComment);
    35       }
    36       else if (stream.eat("/")) {
     31        state.tokenize = tokenComment;
     32        return tokenComment(stream, state);
     33      }
     34      if (stream.eat("/")) {
    3735        stream.skipToEnd();
    38         return ret("comment", "comment");
    39       }
    40       else {
    41         stream.eatWhile(isOperatorChar);
    42         return ret("operator");
    43       }
    44     }
    45     else if (isOperatorChar.test(ch)) {
     36        return "comment";
     37      }
     38    }
     39    if (isOperatorChar.test(ch)) {
    4640      stream.eatWhile(isOperatorChar);
    47       return ret("operator");
    48     }
    49     else if (atAnnotations && ch == "@") {
    50         stream.eatWhile(/[\w\$_]/);
    51         return ret("annotation", "meta");
    52     }
    53     else if ($vars && ch == "$") {
    54       stream.eatWhile(/[\w\$_]/);
    55       return ret("word", "variable");
    56     }
    57     else {
    58       stream.eatWhile(/[\w\$_]/);
    59       if (keywords && keywords.propertyIsEnumerable(stream.current())) return ret("keyword", "keyword");
    60       return ret("word");
    61     }
     41      return "operator";
     42    }
     43    stream.eatWhile(/[\w\$_]/);
     44    var cur = stream.current();
     45    if (keywords.propertyIsEnumerable(cur)) return "keyword";
     46    if (atoms.propertyIsEnumerable(cur)) return "atom";
     47    return "word";
    6248  }
    6349
     
    7157      if (end || !(escaped || multiLineStrings))
    7258        state.tokenize = tokenBase;
    73       return ret("string", "string");
     59      return "string";
    7460    };
    7561  }
     
    8470      maybeEnd = (ch == "*");
    8571    }
    86     return ret("comment", "comment");
     72    return "comment";
    8773  }
    8874
     
    10793    startState: function(basecolumn) {
    10894      return {
    109         tokenize: tokenBase,
     95        tokenize: null,
    11096        context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
    11197        indented: 0,
     
    122108      }
    123109      if (stream.eatSpace()) return null;
    124       var style = state.tokenize(stream, state);
    125       if (type == "comment") return style;
     110      curPunc = null;
     111      var style = (state.tokenize || tokenBase)(stream, state);
     112      if (style == "comment") return style;
    126113      if (ctx.align == null) ctx.align = true;
    127114
    128       if ((type == ";" || type == ":") && ctx.type == "statement") popContext(state);
    129       else if (type == "{") pushContext(state, stream.column(), "}");
    130       else if (type == "[") pushContext(state, stream.column(), "]");
    131       else if (type == "(") pushContext(state, stream.column(), ")");
    132       else if (type == "}") {
     115      if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
     116      else if (curPunc == "{") pushContext(state, stream.column(), "}");
     117      else if (curPunc == "[") pushContext(state, stream.column(), "]");
     118      else if (curPunc == "(") pushContext(state, stream.column(), ")");
     119      else if (curPunc == "}") {
    133120        if (ctx.type == "statement") ctx = popContext(state);
    134121        if (ctx.type == "}") ctx = popContext(state);
    135122        if (ctx.type == "statement") ctx = popContext(state);
    136123      }
    137       else if (type == ctx.type) popContext(state);
     124      else if (curPunc == ctx.type) popContext(state);
    138125      else if (ctx.type == "}" || ctx.type == "top") pushContext(state, stream.column(), "statement");
    139126      state.startOfLine = false;
     
    142129
    143130    indent: function(state, textAfter) {
    144       if (state.tokenize != tokenBase) return 0;
     131      if (state.tokenize != tokenBase && state.tokenize != null) return 0;
    145132      var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
    146133      if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
     
    154141
    155142(function() {
    156   function keywords(str) {
     143  function words(str) {
    157144    var obj = {}, words = str.split(" ");
    158145    for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
     
    163150    "goto while enum void const signed volatile";
    164151
     152  function cppHook(stream, state) {
     153    if (!state.startOfLine) return false;
     154    stream.skipToEnd();
     155    return "meta";
     156  }
     157
     158  // C#-style strings where "" escapes a quote.
     159  function tokenAtString(stream, state) {
     160    var next;
     161    while ((next = stream.next()) != null) {
     162      if (next == '"' && !stream.eat('"')) {
     163        state.tokenize = null;
     164        break;
     165      }
     166    }
     167    return "string";
     168  }
     169
    165170  CodeMirror.defineMIME("text/x-csrc", {
    166171    name: "clike",
    167     useCPP: true,
    168     keywords: keywords(cKeywords)
     172    keywords: words(cKeywords),
     173    atoms: words("null"),
     174    hooks: {"#": cppHook}
    169175  });
    170176  CodeMirror.defineMIME("text/x-c++src", {
    171177    name: "clike",
    172     useCPP: true,
    173     keywords: keywords(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
    174                        "static_cast typeid catch false operator template typename class friend private " +
    175                        "this using const_cast inline public throw virtual delete mutable protected true " +
    176                        "wchar_t")
     178    keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
     179                    "static_cast typeid catch operator template typename class friend private " +
     180                    "this using const_cast inline public throw virtual delete mutable protected " +
     181                    "wchar_t"),
     182    atoms: words("true false null"),
     183    hooks: {"#": cppHook}
    177184  });
    178185  CodeMirror.defineMIME("text/x-java", {
    179186    name: "clike",
    180     atAnnotations: true,
    181     keywords: keywords("abstract assert boolean break byte case catch char class const continue default " +
    182                        "do double else enum extends false final finally float for goto if implements import " +
    183                        "instanceof int interface long native new null package private protected public " +
    184                        "return short static strictfp super switch synchronized this throw throws transient " +
    185                        "true try void volatile while")
     187    keywords: words("abstract assert boolean break byte case catch char class const continue default " +
     188                    "do double else enum extends final finally float for goto if implements import " +
     189                    "instanceof int interface long native new package private protected public " +
     190                    "return short static strictfp super switch synchronized this throw throws transient " +
     191                    "try void volatile while"),
     192    atoms: words("true false null"),
     193    hooks: {
     194      "@": function(stream, state) {
     195        stream.eatWhile(/[\w\$_]/);
     196        return "meta";
     197      }
     198    }
     199  });
     200  CodeMirror.defineMIME("text/x-csharp", {
     201    name: "clike",
     202    keywords: words("abstract as base bool break byte case catch char checked class const continue decimal" +
     203                    " default delegate do double else enum event explicit extern finally fixed float for" +
     204                    " foreach goto if implicit in int interface internal is lock long namespace new object" +
     205                    " operator out override params private protected public readonly ref return sbyte sealed short" +
     206                    " sizeof stackalloc static string struct switch this throw try typeof uint ulong unchecked" +
     207                    " unsafe ushort using virtual void volatile while add alias ascending descending dynamic from get" +
     208                    " global group into join let orderby partial remove select set value var yield"),
     209    atoms: words("true false null"),
     210    hooks: {
     211      "@": function(stream, state) {
     212        if (stream.eat('"')) {
     213          state.tokenize = tokenAtString;
     214          return tokenAtString(stream, state);
     215        }
     216        stream.eatWhile(/[\w\$_]/);
     217        return "meta";
     218      }
     219    }
    186220  });
    187221}());
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/htmlmixed/htmlmixed.js

    r48687 r49339  
    1010        state.token = javascript;
    1111        state.localState = jsMode.startState(htmlMode.indent(state.htmlState, ""));
     12        state.mode = "javascript";
    1213      }
    1314      else if (/^style$/i.test(state.htmlState.context.tagName)) {
    1415        state.token = css;
    1516        state.localState = cssMode.startState(htmlMode.indent(state.htmlState, ""));
     17        state.mode = "css";
    1618      }
    1719    }
     
    2830      state.token = html;
    2931      state.curState = null;
     32      state.mode = "html";
    3033      return html(stream, state);
    3134    }
     
    3740      state.token = html;
    3841      state.localState = null;
     42      state.mode = "html";
    3943      return html(stream, state);
    4044    }
     
    4650    startState: function() {
    4751      var state = htmlMode.startState();
    48       return {token: html, localState: null, htmlState: state};
     52      return {token: html, localState: null, mode: "html", htmlState: state};
    4953    },
    5054
     
    5256      if (state.localState)
    5357        var local = CodeMirror.copyState(state.token == css ? cssMode : jsMode, state.localState);
    54       return {token: state.token, localState: local, htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
     58      return {token: state.token, localState: local, mode: state.mode,
     59              htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
    5560    },
    5661
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/php/php.js

    r48687 r49339  
    99             "default do else elseif enddeclare endfor endforeach endif endswitch endwhile extends " +
    1010             "final for foreach function global goto if implements interface instanceof namespace " +
    11              "new or private protected public static switch throw try use var while xor");
    12   var phpConfig = {name: "clike", keywords: phpKeywords, multiLineStrings: true, $vars: true};
     11             "new or private protected public static switch throw try use var while xor return");
     12  function heredoc(delim) {
     13    return function(stream, state) {
     14      if (stream.match(delim)) state.tokenize = null;
     15      else stream.skipToEnd();
     16      return "string";
     17    }
     18  }
     19  var phpConfig = {
     20    name: "clike",
     21    keywords: phpKeywords,
     22    atoms: keywords("true false null"),
     23    multiLineStrings: true,
     24    hooks: {
     25      "$": function(stream, state) {
     26        stream.eatWhile(/[\w\$_]/);
     27        return "variable-2";
     28      },
     29      "<": function(stream, state) {
     30        if (stream.match(/<</)) {
     31          stream.eatWhile(/[\w\.]/);
     32          state.tokenize = heredoc(stream.current().slice(3));
     33          return state.tokenize(stream, state);
     34        }
     35        return false;
     36      }
     37    }
     38  };
    1339
    1440  CodeMirror.defineMode("php", function(config, parserConfig) {
     
    5480        return {html: html,
    5581                php: phpMode.startState(),
    56                 curMode: htmlMode,
    57                 curState: html,
    58                 curClose: null}
     82                curMode:        parserConfig.startOpen ? phpMode : htmlMode,
     83                curState:       parserConfig.startOpen ? phpMode.startState() : html,
     84                curClose:       parserConfig.startOpen ? /^\?>/ : null}
    5985      },
    6086
     
    81107  });
    82108  CodeMirror.defineMIME("application/x-httpd-php", "php");
     109  CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
    83110  CodeMirror.defineMIME("text/x-php", phpConfig);
    84111})();
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/plsql/plsql.js

    r48687 r49339  
    2828    // start of a number value?
    2929    else if (/\d/.test(ch)) {
    30       stream.eatWhile(/[\w\.]/)
     30      stream.eatWhile(/[\w\.]/);
    3131      return ret("number", "number");
    3232    }
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/xml/xml.js

    r48687 r49339  
    129129  function element(type) {
    130130    if (type == "openTag") {curState.tagName = tagName; return cont(attributes, endtag(curState.startOfLine));}
    131     else if (type == "closeTag") {popContext(); return cont(endclosetag);}
     131    else if (type == "closeTag") {
     132      var err = false;
     133      if (curState.context) {
     134        err = curState.context.tagName != tagName;
     135        popContext();
     136      } else {
     137        err = true;
     138      }
     139      if (err) setStyle = "error";
     140      return cont(endclosetag(err));
     141    }
    132142    else if (type == "string") {
    133143      if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata");
     
    146156    };
    147157  }
    148   function endclosetag(type) {
    149     if (type == "endTag") return cont();
    150     return pass();
     158  function endclosetag(err) {
     159    return function(type) {
     160      if (err) setStyle = "error";
     161      if (type == "endTag") return cont();
     162      return pass();
     163    }
    151164  }
    152165
     
    176189      setStyle = type = tagName = null;
    177190      var style = state.tokenize(stream, state);
    178       if ((style || type) && style != "xml-comment") {
     191      if ((style || type) && style != "comment") {
    179192        curState = state;
    180193        while (true) {
     
    199212    },
    200213
     214    compareStates: function(a, b) {
     215      if (a.indented != b.indented || a.tagName != b.tagName) return false;
     216      for (var ca = a.context, cb = b.context; ; ca = ca.prev, cb = cb.prev) {
     217        if (!ca || !cb) return ca == cb;
     218        if (ca.tagName != cb.tagName) return false;
     219      }
     220    },
     221
    201222    electricChars: "/"
    202223  };
  • _plugins_/skeleditor/trunk/spip_210/codemirror/oldrelease.html

    r48687 r49339  
    1616
    1717</pre>
     18
     19  <p class="rel">17-02-2011: <a href="http://codemirror.net/codemirror-0.94.zip">Version 0.94</a>:</p>
     20  <ul class="rel-note">
     21    <li><code>tabMode: "spaces"</code> was modified slightly (now indents when something is selected).</li>
     22    <li>Fixes a bug that would cause the selection code to break on some IE versions.</li>
     23    <li>Disabling spell-check on WebKit browsers now works.</li>
     24  </ul>
     25
     26  <p class="rel">08-02-2011: <a href="http://codemirror.net/2/">Version 2.0 beta 1</a>:</p>
     27  <p class="rel-note">CodeMirror 2 is a complete rewrite of
     28  CodeMirror, no longer depending on an editable frame.</p>
    1829
    1930  <p class="rel">19-01-2011: <a href="http://codemirror.net/codemirror-0.93.zip">Version 0.93</a>:</p>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/theme/night.css

    r48687 r49339  
    99.cm-s-night span.cm-comment { color: #6900a1; }
    1010.cm-s-night span.cm-atom { color: #845dc4; }
    11 .cm-s-night span.cm-number { color: #ffd500; }
     11.cm-s-night span.cm-number, .cm-s-night span.cm-attribute { color: #ffd500; }
    1212.cm-s-night span.cm-keyword { color: #599eff; }
    1313.cm-s-night span.cm-string { color: #37f14a; }
    1414.cm-s-night span.cm-meta { color: #7678e2; }
    15 .cm-s-night span.cm-variable-2 { color: #99b2ff; }
    16 .cm-s-night span.cm-variable-3, .cm-s-night span.cm-def { white; }
     15.cm-s-night span.cm-variable-2, .cm-s-night span.cm-tag { color: #99b2ff; }
     16.cm-s-night span.cm-variable-3, .cm-s-night span.cm-def { color: white; }
    1717.cm-s-night span.cm-error { color: #9d1e15; }
    1818.cm-s-night span.cm-bracket { color: #8da6ce; }
Note: See TracChangeset for help on using the changeset viewer.