Changeset 48687 in spip-zone


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

ne trimballons plus cette version pour spip 2.0 dans le trunk. Ce dernier utilisera probablement les iterateurs donc reserve a SPIP2.1+iterateurs ou SPIP3.
Maj de codemirror dans sa version 2.1, probablement d'autres corrections a apportees mais ca semble a peu pres fonctionnel en l'etat.

Location:
_plugins_/skeleditor/trunk
Files:
25 added
7 deleted
38 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/skeleditor/trunk/plugin.xml

    r48680 r48687  
    11<plugin>
    2         <nom> <!-- Nom du plugin -->
    3         <multi>
    4         [fr]Squelette editeur
    5   [en]Template editor
    6         [it]Redattore di scheletro
    7         [es]Redactor esquel&#233;tico
    8         [de]Skeleton Herausgeber
    9         </multi>
    10         </nom>
    11         <icon>spip_200/img_pack/logo_skeleditor.png</icon>
    12         <auteur>[erational->http://www.erational.org]</auteur>
    13         <licence>GNU/GPL v3</licence>
    14         <version>0.11</version>
    15         <etat>dev</etat>
    16         <description>
    17         <multi>
    18         [fr]Dans l'espace priv&#233;, permet d'&#233;diter les fichiers squelettes
    19   [en]Edit template files in the backoffice
    20         [it]Nello spazio riservato, concede a redattore gli scheletri delle lime
    21         [es]En espacio privado, no prohibe a redactor los esqueletos de los archivos
    22         [de] Im privaten Raum erlaubt Herausgeber die Aktenskelette
    23         </multi>
    24         </description>
    25         <lien>http://www.spip-contrib.net/Editeur-de-squelettes-Skel-editor</lien>
    26         <prefix>skeleditor</prefix>
    27         <fonctions>spip_200/skeleditor_fonctions.php</fonctions>
    28         <!-- bouton prive -->
    29   <bouton id="skeleditor" parent="naviguer">
    30       <icone>img_pack/icon.png</icone>
    31       <titre>skeleditor:editer_skel</titre>   
    32       <url>skeleditor</url>   
    33   </bouton>
    34   <bouton id="skeleditor21" parent="bando_squelette" position="0">
    35       <icone>img_pack/icon.png</icone>
    36       <titre>skeleditor:editer_skel</titre>
    37       <url>skeleditor</url>
    38   </bouton>
    39   <!-- pipeline -->
    40   <pipeline>
    41       <nom>autoriser</nom>
    42       <inclure>spip_200/inc/skeleditor_autoriser.php</inclure>
    43   </pipeline>
    44   <!-- necessite -->
    45         <chemin dir="spip_200" />
    46         <necessite id="SPIP" version="[2.0.0;]" />
    47         <categorie>outil</categorie>
    48 </plugin>
    49 <plugin version="[2.1.0;]" >
    502        <nom>SkelEditor</nom>
    513        <icon>spip_210/img_pack/skeleditor-32.png</icon>
    524        <auteur>[erational->http://www.erational.org], [C&eacute;dric Morin->http://www.yterium.net]</auteur>
    535        <licence>GNU/GPL v3</licence>
    54         <version>2.5.3</version>
     6        <version>2.5.4</version>
    557        <etat>test</etat>
    568        <description><multi>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/compress.html

    r46386 r48687  
    33  <head>
    44    <title>CodeMirror: Compression Helper</title>
     5    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
    56    <link rel="stylesheet" type="text/css" href="css/docs.css"/>
    67    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     
    1718    <p>To optimize loading CodeMirror, especially when including a
    1819    bunch of different modes, it is recommended that you combine and
    19     minify (and preferably also gzip) the scrips. This page makes
     20    minify (and preferably also gzip) the scripts. This page makes
    2021    those first two steps very easy. Simply select the version and
    2122    scripts you need in the form below, and
     
    2627      <input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
    2728      <p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px">
    28         <option value="http://codemirror.net/2/">HEAD</option>
     29        <option value="http://codemirror.net/">HEAD</option>
     30        <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=v2.1;f=">2.1</option>
     31        <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=v2.02;f=">2.02</option>
     32        <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=v2.01;f=">2.01</option>
    2933        <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=v2.0;f=">2.0</option>
    3034        <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=beta2;f=">beta2</option>
     
    3438      <select multiple="multiple" name="code_url" style="width: 40em;" class="field" id="files">
    3539        <optgroup label="CodeMirror Library">
    36           <option value="http://codemirror.net/2/lib/codemirror.js" selected>codemirror.js</option>
    37           <option value="http://codemirror.net/2/lib/overlay.js">overlay.js</option>
     40          <option value="http://codemirror.net/lib/codemirror.js" selected>codemirror.js</option>
     41          <option value="http://codemirror.net/lib/overlay.js">overlay.js</option>
     42          <option value="http://codemirror.net/lib/runmode.js">runmode.js</option>
    3843        </optgroup>
    3944        <optgroup label="Modes">
    40           <option value="http://codemirror.net/2/mode/javascript/javascript.js">javascript.js</option>
    41           <option value="http://codemirror.net/2/mode/xml/xml.js">xml.js</option>
    42           <option value="http://codemirror.net/2/mode/css/css.js">css.js</option>
    43           <option value="http://codemirror.net/2/mode/htmlmixed/htmlmixed.js">htmlmixed.js</option>
    44           <option value="http://codemirror.net/2/mode/clike/clike.js">clike.js</option>
    45           <option value="http://codemirror.net/2/mode/php/php.js">php.js</option>
    46           <option value="http://codemirror.net/2/mode/haskell/haskell.js">haskell.js</option>
    47           <option value="http://codemirror.net/2/mode/diff/diff.js">diff.js</option>
    48           <option value="http://codemirror.net/2/mode/stex/stex.js">stex.js</option>
     45          <option value="http://codemirror.net/mode/javascript/javascript.js">javascript.js</option>
     46          <option value="http://codemirror.net/mode/xml/xml.js">xml.js</option>
     47          <option value="http://codemirror.net/mode/css/css.js">css.js</option>
     48          <option value="http://codemirror.net/mode/htmlmixed/htmlmixed.js">htmlmixed.js</option>
     49          <option value="http://codemirror.net/mode/clike/clike.js">clike.js</option>
     50          <option value="http://codemirror.net/mode/python/python.js">python.js</option>
     51          <option value="http://codemirror.net/mode/php/php.js">php.js</option>
     52          <option value="http://codemirror.net/mode/haskell/haskell.js">haskell.js</option>
     53          <option value="http://codemirror.net/mode/diff/diff.js">diff.js</option>
     54          <option value="http://codemirror.net/mode/stex/stex.js">stex.js</option>
     55          <option value="http://codemirror.net/mode/smalltalk/smalltalk.js">smalltalk.js</option>
     56          <option value="http://codemirror.net/mode/rst/rst.js">rst.js</option>
     57          <option value="http://codemirror.net/mode/plsql/plsql.js">plsql.js</option>
     58          <option value="http://codemirror.net/mode/lua/lua.js">lua.js</option>
    4959        </optgroup>
    5060      </select></p>
     
    7282       }
    7383    </script>
    74     <script type="text/javascript" src="css/font.js"></script>
    7584
    7685  </body>
    7786</html>
     87
  • _plugins_/skeleditor/trunk/spip_210/codemirror/css/docs.css

    r46386 r48687  
    11body {
    2   font-family: Arial, sans-serif;
     2  font-family: Droid Sans, Arial, sans-serif;
    33  line-height: 1.5;
    44  max-width: 64.3em;
    55  margin: 3em auto;
    66  padding: 0 1em;
    7 }
    8 body.droid {
    9   font-family: Droid Sans, Arial, sans-serif;
    107}
    118
     
    3128
    3229pre {
    33   font-family: Courier New, monospaced;
    3430  background-color: #eee;
    3531  -moz-border-radius: 6px;
     
    4440
    4541.grey {
    46   font-size: 2em;
     42  font-size: 2.2em;
    4743  padding: .5em 1em;
    4844  line-height: 1.2em;
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/activeline.html

    r46386 r48687  
    55    <link rel="stylesheet" href="../lib/codemirror.css">
    66    <script src="../lib/codemirror.js"></script>
    7     <link rel="stylesheet" href="../mode/xml/xml.css">
     7    <link rel="stylesheet" href="../theme/default.css">
    88    <script src="../mode/xml/xml.js"></script>
    99    <link rel="stylesheet" href="../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/complete.html

    r46386 r48687  
    55    <link rel="stylesheet" href="../lib/codemirror.css">
    66    <script src="../lib/codemirror.js"></script>
    7     <link rel="stylesheet" href="../mode/javascript/javascript.css">
     7    <link rel="stylesheet" href="../theme/night.css">
    88    <script src="../mode/javascript/javascript.js"></script>
    99    <link rel="stylesheet" href="../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/complete.js

    r46386 r48687  
    2323  var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
    2424    lineNumbers: true,
     25    theme: "night",
    2526    onKeyEvent: function(i, e) {
    2627      // Hook into ctrl-space
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/marker.html

    r46386 r48687  
    55    <link rel="stylesheet" href="../lib/codemirror.css">
    66    <script src="../lib/codemirror.js"></script>
    7     <link rel="stylesheet" href="../mode/javascript/javascript.css">
     7    <link rel="stylesheet" href="../theme/default.css">
    88    <script src="../mode/javascript/javascript.js"></script>
    99    <link rel="stylesheet" href="../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/mustache.html

    r46386 r48687  
    66    <script src="../lib/codemirror.js"></script>
    77    <script src="../lib/overlay.js"></script>
    8     <link rel="stylesheet" href="../mode/xml/xml.css">
     8    <link rel="stylesheet" href="../theme/default.css">
    99    <script src="../mode/xml/xml.js"></script>
    1010    <link rel="stylesheet" href="../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/resize.html

    r46386 r48687  
    55    <link rel="stylesheet" href="../lib/codemirror.css">
    66    <script src="../lib/codemirror.js"></script>
    7     <link rel="stylesheet" href="../mode/css/css.css">
     7    <link rel="stylesheet" href="../theme/default.css">
    88    <script src="../mode/css/css.js"></script>
    99    <link rel="stylesheet" href="../css/docs.css">
     
    1212      .CodeMirror {
    1313        border: 1px solid #eee;
     14      }
     15      .CodeMirror-scroll {
    1416        height: auto;
     17        overflow-y: hidden;
     18        overflow-x: auto;
    1519      }
    1620    </style>
     
    2024
    2125    <form><textarea id="code" name="code">
    22 .CodeMirror {
     26.CodeMirror-scroll {
    2327  height: auto;
     28  overflow-y: hidden;
     29  overflow-x: auto;
    2430}</textarea></form>
    2531
  • _plugins_/skeleditor/trunk/spip_210/codemirror/demo/search.html

    r46386 r48687  
    55    <link rel="stylesheet" href="../lib/codemirror.css">
    66    <script src="../lib/codemirror.js"></script>
    7     <link rel="stylesheet" href="../mode/xml/xml.css">
     7    <link rel="stylesheet" href="../theme/default.css">
    88    <script src="../mode/xml/xml.js"></script>
    99    <link rel="stylesheet" href="../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/index.html

    r46386 r48687  
    33  <head>
    44    <title>CodeMirror</title>
     5    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
    56    <link rel="stylesheet" type="text/css" href="css/docs.css"/>
    67    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     
    2930  version. <a href="1/index.html">CodeMirror 1</a> is still available
    3031  from here.</p>
    31  
     32
    3233  <div class="clear"><div class="left1 blk">
    3334
     
    3940      <li><a href="mode/css/index.html">CSS</a></li>
    4041      <li><a href="mode/htmlmixed/index.html">HTML mixed-mode</a></li>
     42      <li><a href="mode/python/index.html">Python</a></li>
    4143      <li><a href="mode/php/index.html">PHP</a></li>
    4244      <li><a href="mode/diff/index.html">diff</a></li>
     
    4446      <li><a href="mode/stex/index.html">sTeX, LaTeX</a></li>
    4547      <li><a href="mode/haskell/index.html">Haskell</a></li>
     48      <li><a href="mode/smalltalk/index.html">Smalltalk</a></li>
     49      <li><a href="mode/rst/index.html">reStructuredText</a></li>
     50      <li><a href="mode/plsql/index.html">PL/SQL</a></li>
     51      <li><a href="mode/lua/index.html">Lua</a></li>
    4652    </ul>
    4753
     
    5763      <li><a href="demo/marker.html">Setting breakpoints</a></li>
    5864      <li><a href="demo/activeline.html">Highlighting the current line</a></li>
     65      <li><a href="demo/theme.html">Theming</a></li>
     66      <li><a href="demo/runmode.html">Stand-alone highlighting</a></li>
    5967    </ul>
    6068
     
    6775  the <a href="http://codemirror.net/codemirror.zip">latest
    6876  release</a> or the current <a
    69   href="http://codemirror.net/codemirror-latest.zip">development
     77  href="http://codemirror.net/codemirror2-latest.zip">development
    7078  snapshot</a> as zip files. To create a custom minified script file,
    7179  you can use the <a href="compress.html">compression API</a>.</p>
     
    119127  vendors have a habit of introducing bugs all the time, so I am
    120128  relying on the community to tell me when something breaks.
    121   See <a href="#support">below</a> for information on how to contact
     129  See <a href="#support">here</a> for information on how to contact
    122130  me.</p>
    123131
     
    146154  <h2>Releases:</h2>
    147155
     156  <p class="rel">07-06-2011: <a href="http://codemirror.net/codemirror-2.02.zip">Version 2.1</a>:</p>
     157  <p class="rel-note">Add
     158  a <a href="manual.html#option_theme">theme</a> system
     159  (<a href="demo/theme.html">demo</a>). Note that this is not
     160  backwards-compatible—you'll have to update your styles and
     161  modes!</p>
     162
     163  <p class="rel">07-06-2011: <a href="http://codemirror.net/codemirror-2.02.zip">Version 2.02</a>:</p>
     164  <ul class="rel-note">
     165    <li>Add a <a href="mode/lua/index.html">Lua mode</a>.</li>
     166    <li>Fix reverse-searching for a regexp.</li>
     167    <li>Empty lines can no longer break highlighting.</li>
     168    <li>Rework scrolling model (the outer wrapper no longer does the scrolling).</li>
     169    <li>Solve horizontal jittering on long lines.</li>
     170    <li>Add <a href="demo/runmode.html">runmode.js</a>.</li>
     171    <li>Immediately re-highlight text when typing.</li>
     172    <li>Fix problem with 'sticking' horizontal scrollbar.</li>
     173  </ul>
     174
     175  <p class="rel">26-05-2011: <a href="http://codemirror.net/codemirror-2.01.zip">Version 2.01</a>:</p>
     176  <ul class="rel-note">
     177    <li>Add a <a href="mode/smalltalk/index.html">Smalltalk mode</a>.</li>
     178    <li>Add a <a href="mode/rst/index.html">reStructuredText mode</a>.</li>
     179    <li>Add a <a href="mode/python/index.html">Python mode</a>.</li>
     180    <li>Add a <a href="mode/plsql/index.html">PL/SQL mode</a>.</li>
     181    <li><code>coordsChar</code> now works</li>
     182    <li>Fix a problem where <code>onCursorActivity</code> interfered with <code>onChange</code>.</li>
     183    <li>Fix a number of scrolling and mouse-click-position glitches.</li>
     184    <li>Pass information about the changed lines to <code>onChange</code>.</li>
     185    <li>Support cmd-up/down on OS X.</li>
     186    <li>Add triple-click line selection.</li>
     187    <li>Don't handle shift when changing the selection through the API.</li>
     188    <li>Support <code>"nocursor"</code> mode for <code>readOnly</code> option.</li>
     189    <li>Add an <code>onHighlightComplete</code> option.</li>
     190    <li>Fix the context menu for Firefox.</li>
     191  </ul>
     192
    148193  <p class="rel">28-03-2011: <a href="http://codemirror.net/codemirror-2.0.zip">Version 2.0</a>:</p>
    149194  <p class="rel-note">CodeMirror 2 is a complete rewrite that's
     
    174219  CodeMirror, no longer depending on an editable frame.</p>
    175220
    176   <p class="rel">19-01-2011: <a href="http://codemirror.net/codemirror-0.93.zip">Version 0.93</a>:</p>
    177   <ul class="rel-note">
    178     <li>Added a <a href="contrib/regex/index.html">Regular Expression</a> parser.</li>
    179     <li>Fixes to the PHP parser.</li>
    180     <li>Support for regular expression in search/replace.</li>
    181     <li>Add <code>save</code> method to instances created with <code>fromTextArea</code>.</li>
    182     <li>Add support for MS T-SQL in the SQL parser.</li>
    183     <li>Support use of CSS classes for highlighting brackets.</li>
    184     <li>Fix yet another hang with line-numbering in hidden editors.</li>
    185   </ul>
    186 
    187   <p class="rel">17-12-2010: <a href="http://codemirror.net/codemirror-0.92.zip">Version 0.92</a>:</p>
    188   <ul class="rel-note">
    189     <li>Make CodeMirror work in XHTML documents.</li>
    190     <li>Fix bug in handling of backslashes in Python strings.</li>
    191     <li>The <code>styleNumbers</code> option is now officially
    192     supported and documented.</li>
    193     <li><code>onLineNumberClick</code> option added.</li>
    194     <li>More consistent names <code>onLoad</code> and
    195     <code>onCursorActivity</code> callbacks. Old names still work, but
    196     are deprecated.</li>
    197     <li>Add a <a href="contrib/freemarker/index.html">Freemarker</a> mode.</li>
    198   </ul>
    199 
    200   <p class="rel">11-11-2010: <a
    201   href="http://codemirror.net/codemirror-0.91.zip">Version 0.91</a>:</p>
    202   <ul class="rel-note">
    203     <li>Adds support for <a href="contrib/java">Java</a>.</li>
    204     <li>Small additions to the <a href="contrib/php">PHP</a> and <a href="contrib/sql">SQL</a> parsers.</li>
    205     <li>Work around various <a href="https://bugs.webkit.org/show_bug.cgi?id=47806">Webkit</a> <a href="https://bugs.webkit.org/show_bug.cgi?id=23474">issues</a>.</li>
    206     <li>Fix <code>toTextArea</code> to update the code in the textarea.</li>
    207     <li>Add a <code>noScriptCaching</code> option (hack to ease development).</li>
    208     <li>Make sub-modes of <a href="mixedtest.html">HTML mixed</a> mode configurable.</li>
    209   </ul>
    210 
    211221  <p><a href="oldrelease.html">Older releases...</a></p>
    212222
     
    220230  </form>
    221231
    222   <script type="text/javascript" src="css/font.js"></script>
    223 
    224232  </body>
    225233</html>
     234
  • _plugins_/skeleditor/trunk/spip_210/codemirror/internals.html

    r46386 r48687  
    11<!doctype html>
    2 <html><head>
    3 <title>CodeMirror 2: (Re-) Implementing A Syntax-Highlighting Editor in JavaScript</title>
    4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    5 <link rel="stylesheet" href="docs.css">
    6 </head><body>
    7 
    8 <h1>(Re-) Implementing A Syntax-Highlighting Editor in JavaScript</h1>
    9 
    10 <p style="font-size: 85%">
     2<html>
     3  <head>
     4    <title>CodeMirror: Internals</title>
     5    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
     6    <link rel="stylesheet" type="text/css" href="css/docs.css"/>
     7    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     8    <style>dl dl {margin: 0;}</style>
     9  </head>
     10  <body>
     11
     12<h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMirror</a></h1>
     13
     14<pre class="grey">
     15<img src="css/baboon.png" class="logo" alt="logo"/>/* (Re-) Implementing A Syntax-
     16   Highlighting Editor in JavaScript */
     17</pre>
     18
     19<div class="clear"><div class="leftbig blk">
     20
     21<p style="font-size: 85%" id="intro">
    1122  <strong>Topic:</strong> JavaScript, code editor implementation<br>
    1223  <strong>Author:</strong> Marijn Haverbeke<br>
     
    8293to lose its appeal.</p>
    8394
    84 <h2>General Approach</h2>
     95<h2 id="approach">General Approach</h2>
    8596
    8697<p>What CodeMirror 2 does is try to sidestep most of the hairy hacks
     
    115126displaying things only as they are scrolled into view.)</p>
    116127
    117 <h2>Input</h2>
     128<h2 id="input">Input</h2>
    118129
    119130<p>ACE uses its hidden textarea only as a text input shim, and does
     
    143154CodeMirror is catching those events and handling them itself.</p>
    144155
    145 <h2>Selection</h2>
     156<h2 id="selection">Selection</h2>
    146157
    147158<p>Getting and setting the selection range of a textarea in modern
     
    191202time.</p>
    192203
    193 <h2>Intelligent Updating</h2>
     204<h2 id="update">Intelligent Updating</h2>
    194205
    195206<p>One thing that always comes up when you have a complicated internal
     
    249260single <code>innerHTML</code> update to do the refresh.</p>
    250261
    251 <h2>Parsers can be Simple</h2>
     262<h2 id="parse">Parsers can be Simple</h2>
    252263
    253264<p>When I wrote CodeMirror 1, I
     
    290301anymore.</p>
    291302
    292 <h2>What Gives?</h2>
     303<h2 id="summary">What Gives?</h2>
    293304
    294305<p>Given all this, what can you expect from CodeMirror 2? First, the
     
    350361</ul>
    351362
     363</div><div class="rightsmall blk">
     364
     365    <h2>Contents</h2>
     366
     367    <ul>
     368      <li><a href="#intro">Introduction</a></li>
     369      <li><a href="#approach">General Approach</a></li>
     370      <li><a href="#input">Input</a></li>
     371      <li><a href="#selection">Selection</a></li>
     372      <li><a href="#update">Intelligent Updating</a></li>
     373      <li><a href="#parse">Parsing</a></li>
     374      <li><a href="#summary">What Gives?</a></li>
     375    </ul>
     376
     377</div></div>
     378
     379<div style="height: 2em">&nbsp;</div>
     380
    352381</body></html>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/lib/codemirror.css

    r46386 r48687  
    11.CodeMirror {
     2  line-height: 1em;
     3  font-family: monospace;
     4}
     5
     6.CodeMirror-scroll {
    27  overflow: auto;
    38  height: 300px;
    4   line-height: 1em;
    5   font-family: monospace;
    6   _position: relative; /* IE6 hack */
    79}
    810
     
    3032  border-width: 0; margin: 0; padding: 0; background: transparent;
    3133  font-family: inherit;
     34  font-size: inherit;
     35  padding: 0; margin: 0;
     36  white-space: pre;
     37  word-wrap: normal;
     38}
     39
     40.CodeMirror textarea {
     41  font-family: inherit !important;
     42  font-size: inherit !important;
    3243}
    3344
  • _plugins_/skeleditor/trunk/spip_210/codemirror/lib/codemirror.js

    r46386 r48687  
    1414        options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
    1515
    16     // The element in which the editor lives. Takes care of scrolling
    17     // (if enabled).
    18     var wrapper = document.createElement("div");
     16    var targetDocument = options["document"];
     17    // The element in which the editor lives.
     18    var wrapper = targetDocument.createElement("div");
    1919    wrapper.className = "CodeMirror";
    2020    // This mess creates the base DOM structure for the editor.
    2121    wrapper.innerHTML =
    22       '<div style="position: relative">' + // Set to the height of the text, causes scrolling
    23         '<pre style="position: relative; height: 0; visibility: hidden; overflow: hidden;">' + // To measure line/char size
    24            '<span>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span></pre>' +
    25         '<div style="position: relative">' + // Moved around its parent to cover visible view
    26           '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
    27           '<div style="overflow: hidden; position: absolute; width: 0; left: 0">' + // Wraps and hides input textarea
    28             '<textarea style="height: 1px; position: absolute; width: 1px;" wrap="off"></textarea></div>' +
    29           // Provides positioning relative to (visible) text origin
    30           '<div class="CodeMirror-lines"><div style="position: relative">' +
    31             '<pre class="CodeMirror-cursor">&#160;</pre>' + // Absolutely positioned blinky cursor
    32             '<div></div></div></div></div></div>'; // This DIV contains the actual code
     22      '<div style="overflow: hidden; position: relative; width: 1px; height: 0px;">' + // Wraps and hides input textarea
     23        '<textarea style="position: absolute; width: 2px;" wrap="off"></textarea></div>' +
     24      '<div class="CodeMirror-scroll cm-s-' + options.theme + '">' +
     25        '<div style="position: relative">' + // Set to the height of the text, causes scrolling
     26          '<div style="position: absolute; height: 0; width: 0; overflow: hidden;"></div>' +
     27          '<div style="position: relative">' + // Moved around its parent to cover visible view
     28            '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
     29            // Provides positioning relative to (visible) text origin
     30            '<div class="CodeMirror-lines"><div style="position: relative">' +
     31              '<pre class="CodeMirror-cursor">&#160;</pre>' + // Absolutely positioned blinky cursor
     32              '<div></div>' + // This DIV contains the actual code
     33            '</div></div></div></div></div>';
    3334    if (place.appendChild) place.appendChild(wrapper); else place(wrapper);
    3435    // I've never seen more elegant code in my life.
    35     var code = wrapper.firstChild, measure = code.firstChild, mover = measure.nextSibling,
     36    var inputDiv = wrapper.firstChild, input = inputDiv.firstChild,
     37        scroller = wrapper.lastChild, code = scroller.firstChild,
     38        measure = code.firstChild, mover = measure.nextSibling,
    3639        gutter = mover.firstChild, gutterText = gutter.firstChild,
    37         inputDiv = gutter.nextSibling, input = inputDiv.firstChild,
    38         lineSpace = inputDiv.nextSibling.firstChild, cursor = lineSpace.firstChild, lineDiv = cursor.nextSibling;
     40        lineSpace = gutter.nextSibling.firstChild,
     41        cursor = lineSpace.firstChild, lineDiv = cursor.nextSibling;
    3942    if (options.tabindex != null) input.tabindex = options.tabindex;
    4043    if (!options.gutter && !options.lineNumbers) gutter.style.display = "none";
     
    5760    // to get around the fact that we can't create inverted
    5861    // selections. See below.
    59     var shiftSelecting, reducedSelection;
     62    var shiftSelecting, reducedSelection, lastDoubleClick;
    6063    // Variables used by startOperation/endOperation to track what
    6164    // happened during the operation.
     
    6871    // marked.
    6972    var editing, bracketHighlighted;
     73    // Tracks the maximum line length so that the horizontal scrollbar
     74    // can be kept static when scrolling.
     75    var maxLine = "";
    7076
    7177    // Initialize the content. Somewhat hacky (delayed prepareInput)
     
    7581
    7682    // Register our event handlers.
    77     connect(wrapper, "mousedown", operation(onMouseDown));
     83    connect(scroller, "mousedown", operation(onMouseDown));
    7884    // Gecko browsers fire contextmenu *after* opening the menu, at
    7985    // which point we can't mess with it anymore. Context menu is
    8086    // handled in onMouseDown for Gecko.
    81     if (!gecko) connect(wrapper, "contextmenu", operation(onContextMenu));
     87    if (!gecko) connect(scroller, "contextmenu", operation(onContextMenu));
    8288    connect(code, "dblclick", operation(onDblClick));
    83     connect(wrapper, "scroll", function() {updateDisplay([]); if (options.onScroll) options.onScroll(instance);});
     89    connect(scroller, "scroll", function() {updateDisplay([]); if (options.onScroll) options.onScroll(instance);});
    8490    connect(window, "resize", function() {updateDisplay(true);});
    8591    connect(input, "keyup", operation(onKeyUp));
     
    8995    connect(input, "blur", onBlur);
    9096
    91     connect(wrapper, "dragenter", function(e){e.stop();});
    92     connect(wrapper, "dragover", function(e){e.stop();});
    93     connect(wrapper, "drop", operation(onDrop));
    94     connect(wrapper, "paste", function(){input.focus(); fastPoll();});
     97    connect(scroller, "dragenter", function(e){e.stop();});
     98    connect(scroller, "dragover", function(e){e.stop();});
     99    connect(scroller, "drop", operation(onDrop));
     100    connect(scroller, "paste", function(){focusInput(); fastPoll();});
    95101    connect(input, "paste", function(){fastPoll();});
    96102    connect(input, "cut", function(){fastPoll();});
    97 
    98     if (document.activeElement == input) onFocus();
     103   
     104    // IE throws unspecified error in certain cases, when
     105    // trying to access activeElement before onload
     106    var hasFocus; try { hasFocus = (targetDocument.activeElement == input); } catch(e) { }
     107    if (hasFocus) onFocus();
    99108    else onBlur();
    100109
     
    110119      getSelection: getSelection,
    111120      replaceSelection: operation(replaceSelection),
    112       focus: function(){input.focus(); onFocus(); fastPoll();},
     121      focus: function(){focusInput(); onFocus(); prepareInput(); fastPoll();},
    113122      setOption: function(option, value) {
    114123        options[option] = value;
    115124        if (option == "lineNumbers" || option == "gutter") gutterChanged();
    116125        else if (option == "mode" || option == "indentUnit") loadMode();
     126        else if (option == "readOnly" && value == "nocursor") input.blur();
     127        else if (option == "theme") scroller.className = scroller.className.replace(/cm-s-\w+/, "cm-s-" + value);
    117128      },
    118129      getOption: function(option) {return options[option];},
     
    133144      coordsChar: function(coords) {
    134145        var off = eltOffset(lineSpace);
    135         var line = Math.min(showingTo - 1, showingFrom + Math.floor(coords.y / lineHeight()));
    136         return clipPos({line: line, ch: charFromX(clipLine(line), coords.x)});
     146        var line = clipLine(Math.min(lines.length - 1, showingFrom + Math.floor((coords.y - off.top) / lineHeight())));
     147        return clipPos({line: line, ch: charFromX(clipLine(line), coords.x - off.left)});
    137148      },
    138149      getSearchCursor: function(query, pos, caseFold) {return new SearchCursor(query, pos, caseFold);},
     
    193204
    194205    function onMouseDown(e) {
     206      var ld = lastDoubleClick; lastDoubleClick = null;
    195207      // First, see if this is a click in the gutter
    196208      for (var n = e.target(); n != wrapper; n = n.parentNode)
     
    207219      // selection.
    208220      var start = posFromMouse(e), last = start, going;
    209       if (!start) {if (e.target() == wrapper) e.stop(); return;}
    210       setCursor(start.line, start.ch, false);
     221      if (!start) {if (e.target() == scroller) e.stop(); return;}
    211222
    212223      if (!focused) onFocus();
    213224      e.stop();
     225      if (ld && +new Date - ld < 400) return selectLine(start.line);
     226
     227      setCursor(start.line, start.ch, true);
    214228      // And then we have to see if it's a drag event, in which case
    215229      // the dragged-over text must be selected.
    216230      function end() {
    217         input.focus();
     231        focusInput();
    218232        updateInput = true;
    219233        move(); up();
     
    224238          if (!focused) onFocus();
    225239          last = cur;
    226           setSelection(start, cur);
     240          setSelectionUser(start, cur);
    227241          updateInput = false;
    228242          var visible = visibleLines();
     
    232246      }
    233247
    234       var move = connect(document, "mousemove", operation(function(e) {
     248      var move = connect(targetDocument, "mousemove", operation(function(e) {
    235249        clearTimeout(going);
    236250        e.stop();
    237251        extend(e);
    238252      }), true);
    239       var up = connect(document, "mouseup", operation(function(e) {
     253      var up = connect(targetDocument, "mouseup", operation(function(e) {
    240254        clearTimeout(going);
    241255        var cur = posFromMouse(e);
    242         if (cur) setSelection(start, cur);
     256        if (cur) setSelectionUser(start, cur);
    243257        e.stop();
    244258        end();
     
    250264      selectWordAt(pos);
    251265      e.stop();
     266      lastDoubleClick = +new Date;
    252267    }
    253268    function onDrop(e) {
     
    278293
    279294      var code = e.e.keyCode;
     295      // IE does strange things with escape.
     296      if (ie && code == 27) { e.e.returnValue = false; }
    280297      // Tries to detect ctrl on non-mac, cmd on mac.
    281298      var mod = (mac ? e.e.metaKey : e.e.ctrlKey) && !e.e.altKey, anyMod = e.e.ctrlKey || e.e.altKey || e.e.metaKey;
     
    286303
    287304      if (code == 33 || code == 34) {scrollPage(code == 34); return e.stop();} // page up/down
    288       if (mod && (code == 36 || code == 35)) {scrollEnd(code == 36); return e.stop();} // ctrl-home/end
     305      if (mod && ((code == 36 || code == 35) || // ctrl-home/end
     306                  mac && (code == 38 || code == 40))) { // cmd-up/down
     307        scrollEnd(code == 36 || code == 38); return e.stop();
     308      }
    289309      if (mod && code == 65) {selectAll(); return e.stop();} // ctrl-a
    290310      if (!options.readOnly) {
     
    312332    }
    313333    function onKeyUp(e) {
     334      if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e.e))) return;
    314335      if (reducedSelection) {
    315336        reducedSelection = null;
     
    327348      var code = e.e.keyCode;
    328349      // Re-stop tab and enter. Necessary on some browsers.
    329       if (code == 13) {handleEnter(); e.stop();}
    330       else if (code == 9 && options.tabMode != "default") e.stop();
     350      if (code == 13) {if (!options.readOnly) handleEnter(); e.stop();}
     351      else if (!e.e.ctrlKey && !e.e.altKey && !e.e.metaKey && code == 9 && options.tabMode != "default") e.stop();
    331352      else fastPoll(curKeyId);
    332353    }
    333354
    334355    function onFocus() {
     356      if (options.readOnly == "nocursor") return;
    335357      if (!focused && options.onFocus) options.onFocus(instance);
    336358      focused = true;
     
    358380      }
    359381      updateLinesNoUndo(from, to, newText, selFrom, selTo);
     382      if (newText.length < 5)
     383        highlightLines(from.line, from.line + newText.length)
    360384    }
    361385    function unredoHelper(from, to) {
     
    374398
    375399    function updateLinesNoUndo(from, to, newText, selFrom, selTo) {
     400      var recomputeMaxLength = false, maxLineLength = maxLine.length;
     401      for (var i = from.line; i <= to.line; ++i) {
     402        if (lines[i].text.length == maxLineLength) {recomputeMaxLength = true; break;}
     403      }
     404
    376405      var nlines = to.line - from.line, firstLine = lines[from.line], lastLine = lines[to.line];
    377406      // First adjust the line structure, taking some care to leave highlighting intact.
     
    400429      }
    401430
     431
     432      for (var i = from.line, e = i + newText.length; i < e; ++i) {
     433        var l = lines[i].text;
     434        if (l.length > maxLineLength) {
     435          maxLine = l; maxLineLength = l.length;
     436          recomputeMaxLength = false;
     437        }
     438      }
     439      if (recomputeMaxLength) {
     440        maxLineLength = 0; maxLine = "";
     441        for (var i = 0, e = lines.length; i < e; ++i) {
     442          var l = lines[i].text;
     443          if (l.length > maxLineLength) {
     444            maxLineLength = l.length; maxLine = l;
     445          }
     446        }
     447      }
     448
    402449      // Add these lines to the work array, so that they will be
    403450      // highlighted. Adjust work lines if lines were added/removed.
     
    413460      // Remember that these lines changed, for updating the display
    414461      changes.push({from: from.line, to: to.line + 1, diff: lendiff});
    415       textChanged = true;
     462      textChanged = {from: from, to: to, text: newText};
    416463
    417464      // Update the selection
     
    496543    // content or cursor if something changed.
    497544    function readInput() {
     545      if (leaveInputAlone) return;
    498546      var changed = false, text = input.value, sr = selRange(input);
    499547      if (!sr) return false;
    500548      var changed = editing.text != text, rs = reducedSelection;
    501549      var moved = changed || sr.start != editing.start || sr.end != (rs ? editing.start : editing.end);
    502       if (reducedSelection && !moved && sel.from.line == 0 && sel.from.ch == 0)
    503         reducedSelection = null;
    504       else if (!moved) return false;
     550      if (!moved && !rs) return false;
    505551      if (changed) {
    506552        shiftSelecting = reducedSelection = null;
     
    525571      // your selection and have the right thing happen.
    526572      if (rs) {
    527         from = sr.start == rs.anchor ? to : from;
    528         to = shiftSelecting ? sel.to : sr.start == rs.anchor ? from : to;
    529         if (!posLess(from, to)) {
    530           reducedSelection = null;
    531           sel.inverted = false;
    532           var tmp = from; from = to; to = tmp;
    533         }
     573        var head = sr.start == rs.anchor ? to : from;
     574        var tail = shiftSelecting ? sel.to : sr.start == rs.anchor ? from : to;
     575        if (sel.inverted = posLess(head, tail)) { from = head; to = tail; }
     576        else { reducedSelection = null; from = tail; to = head; }
    534577      }
    535578
     
    551594        for (;;) {
    552595          c = editing.text.charAt(edend);
     596          if (text.charAt(end) != c) {++end; ++edend; break;}
    553597          if (c == "\n") endline--;
    554           if (text.charAt(end) != c) {++end; ++edend; break;}
    555598          if (edend <= start || end <= start) break;
    556599          --end; --edend;
     
    581624      setSelRange(input, startch, reducedSelection ? startch : endch);
    582625    }
     626    function focusInput() {
     627      if (options.readOnly != "nocursor") input.focus();
     628    }
    583629
    584630    function scrollCursorIntoView() {
     
    587633    }
    588634    function scrollIntoView(x1, y1, x2, y2) {
    589       var pl = paddingLeft(), pt = paddingTop();
     635      var pl = paddingLeft(), pt = paddingTop(), lh = lineHeight();
    590636      y1 += pt; y2 += pt; x1 += pl; x2 += pl;
    591       var screen = wrapper.clientHeight, screentop = wrapper.scrollTop, scrolled = false, result = true;
    592       if (y1 < screentop) {wrapper.scrollTop = Math.max(0, y1 - 10); scrolled = true;}
    593       else if (y2 > screentop + screen) {wrapper.scrollTop = y2 + 10 - screen; scrolled = true;}
    594 
    595       var screenw = wrapper.clientWidth, screenleft = wrapper.scrollLeft;
    596       if (x1 < screenleft) {wrapper.scrollLeft = Math.max(0, x1 - 10); scrolled = true;}
     637      var screen = scroller.clientHeight, screentop = scroller.scrollTop, scrolled = false, result = true;
     638      if (y1 < screentop) {scroller.scrollTop = Math.max(0, y1 - 2*lh); scrolled = true;}
     639      else if (y2 > screentop + screen) {scroller.scrollTop = y2 + lh - screen; scrolled = true;}
     640
     641      var screenw = scroller.clientWidth, screenleft = scroller.scrollLeft;
     642      if (x1 < screenleft) {
     643        if (x1 < 50) x1 = 0;
     644        scroller.scrollLeft = Math.max(0, x1 - 10);
     645        scrolled = true;
     646      }
    597647      else if (x2 > screenw + screenleft) {
    598         wrapper.scrollLeft = x2 + 10 - screenw;
     648        scroller.scrollLeft = x2 + 10 - screenw;
    599649        scrolled = true;
    600650        if (x2 > code.clientWidth) result = false;
     
    605655
    606656    function visibleLines() {
    607       var lh = lineHeight(), top = wrapper.scrollTop - paddingTop();
     657      var lh = lineHeight(), top = scroller.scrollTop - paddingTop();
    608658      return {from: Math.min(lines.length, Math.max(0, Math.floor(top / lh))),
    609               to: Math.min(lines.length, Math.ceil((top + wrapper.clientHeight) / lh))};
     659              to: Math.min(lines.length, Math.ceil((top + scroller.clientHeight) / lh))};
    610660    }
    611661    // Uses a set of changes plus the current scroll position to
     
    613663    // updates.
    614664    function updateDisplay(changes) {
    615       if (!wrapper.clientWidth) {
     665      if (!scroller.clientWidth) {
    616666        showingFrom = showingTo = 0;
    617667        return;
     
    675725      // Position the mover div to align with the lines it's supposed
    676726      // to be showing (which will cover the visible display)
    677       var different = from != showingFrom || to != showingTo || lastHeight != wrapper.clientHeight;
     727      var different = from != showingFrom || to != showingTo || lastHeight != scroller.clientHeight;
    678728      showingFrom = from; showingTo = to;
    679729      mover.style.top = (from * lineHeight()) + "px";
    680730      if (different) {
    681         lastHeight = wrapper.clientHeight;
     731        lastHeight = scroller.clientHeight;
    682732        code.style.height = (lines.length * lineHeight() + 2 * paddingTop()) + "px";
    683733        updateGutter();
    684734      }
     735
     736      var textWidth = stringWidth(maxLine);
     737      lineSpace.style.width = textWidth > scroller.clientWidth ? textWidth + "px" : "";
    685738
    686739      // Since this is all rather error prone, it is honoured with the
     
    713766      // whitespace.
    714767      var sfrom = sel.from.line, sto = sel.to.line, off = 0,
    715           scratch = badInnerHTML && document.createElement("div");
     768          scratch = badInnerHTML && targetDocument.createElement("div");
    716769      for (var i = 0, e = updates.length; i < e; ++i) {
    717770        var rec = updates[i];
     
    723776        else if (extra) {
    724777          for (var j = Math.max(0, extra); j > 0; --j)
    725             lineDiv.insertBefore(document.createElement("pre"), nodeAfter);
     778            lineDiv.insertBefore(targetDocument.createElement("pre"), nodeAfter);
    726779          for (var j = Math.max(0, -extra); j > 0; --j)
    727780            lineDiv.removeChild(nodeAfter ? nodeAfter.previousSibling : lineDiv.lastChild);
     
    754807    function updateGutter() {
    755808      if (!options.gutter && !options.lineNumbers) return;
    756       var hText = mover.offsetHeight, hEditor = wrapper.clientHeight;
     809      var hText = mover.offsetHeight, hEditor = scroller.clientHeight;
    757810      gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px";
    758811      var html = [];
    759       for (var i = showingFrom; i < showingTo; ++i) {
     812      for (var i = showingFrom; i < Math.max(showingTo, showingFrom + 1); ++i) {
    760813        var marker = lines[i].gutterMarker;
    761814        var text = options.lineNumbers ? i + options.firstLineNumber : null;
     
    770823      var minwidth = String(lines.length).length, firstNode = gutterText.firstChild, val = eltText(firstNode), pad = "";
    771824      while (val.length + pad.length < minwidth) pad += "\u00a0";
    772       if (pad) firstNode.insertBefore(document.createTextNode(pad), firstNode.firstChild);
     825      if (pad) firstNode.insertBefore(targetDocument.createTextNode(pad), firstNode.firstChild);
    773826      gutter.style.display = "";
    774827      lineSpace.style.marginLeft = gutter.offsetWidth + "px";
    775828    }
    776829    function updateCursor() {
    777       var head = sel.inverted ? sel.from : sel.to;
    778       var x = charX(head.line, head.ch) + "px", y = (head.line - showingFrom) * lineHeight() + "px";
    779       inputDiv.style.top = y; inputDiv.style.left = x;
     830      var head = sel.inverted ? sel.from : sel.to, lh = lineHeight();
     831      var x = charX(head.line, head.ch) + "px", y = (head.line - showingFrom) * lh + "px";
     832      inputDiv.style.top = (head.line * lh - scroller.scrollTop) + "px";
    780833      if (posEq(sel.from, sel.to)) {
    781834        cursor.style.top = y; cursor.style.left = x;
     
    785838    }
    786839
     840    function setSelectionUser(from, to) {
     841      var sh = shiftSelecting && clipPos(shiftSelecting);
     842      if (sh) {
     843        if (posLess(sh, from)) from = sh;
     844        else if (posLess(to, sh)) to = sh;
     845      }
     846      setSelection(from, to);
     847    }
    787848    // Update the selection. Last two args are only used by
    788849    // updateLines, since they have to be expressed in the line
     
    790851    function setSelection(from, to, oldFrom, oldTo) {
    791852      if (posEq(sel.from, from) && posEq(sel.to, to)) return;
    792       var sh = shiftSelecting && clipPos(shiftSelecting);
    793853      if (posLess(to, from)) {var tmp = to; to = from; from = tmp;}
    794       if (sh) {
    795         if (posLess(sh, from)) from = sh;
    796         else if (posLess(to, sh)) to = sh;
    797       }
    798 
    799       var startEq = posEq(sel.to, to), endEq = posEq(sel.from, from);
     854
    800855      if (posEq(from, to)) sel.inverted = false;
    801       else if (startEq && !endEq) sel.inverted = true;
    802       else if (endEq && !startEq) sel.inverted = false;
     856      else if (posEq(from, sel.to)) sel.inverted = false;
     857      else if (posEq(to, sel.from)) sel.inverted = true;
    803858
    804859      // Some ugly logic used to only mark the lines that actually did
     
    830885      selectionChanged = true;
    831886    }
    832     function setCursor(line, ch) {
     887    function setCursor(line, ch, user) {
    833888      var pos = clipPos({line: line, ch: ch || 0});
    834       setSelection(pos, pos);
     889      (user ? setSelectionUser : setSelection)(pos, pos);
    835890    }
    836891
     
    846901
    847902    function scrollPage(down) {
    848       var linesPerPage = Math.floor(wrapper.clientHeight / lineHeight()), head = sel.inverted ? sel.from : sel.to;
    849       setCursor(head.line + (Math.max(linesPerPage - 1, 1) * (down ? 1 : -1)), head.ch);
     903      var linesPerPage = Math.floor(scroller.clientHeight / lineHeight()), head = sel.inverted ? sel.from : sel.to;
     904      setCursor(head.line + (Math.max(linesPerPage - 1, 1) * (down ? 1 : -1)), head.ch, true);
    850905    }
    851906    function scrollEnd(top) {
    852       setCursor(top ? 0 : lines.length - 1);
     907      var pos = top ? {line: 0, ch: 0} : {line: lines.length - 1, ch: lines[lines.length-1].text.length};
     908      setSelectionUser(pos, pos);
    853909    }
    854910    function selectAll() {
     
    860916      var start = pos.ch, end = pos.ch;
    861917      while (start > 0 && /\w/.test(line.charAt(start - 1))) --start;
    862       while (end < line.length - 1 && /\w/.test(line.charAt(end))) ++end;
    863       setSelection({line: pos.line, ch: start}, {line: pos.line, ch: end});
     918      while (end < line.length && /\w/.test(line.charAt(end))) ++end;
     919      setSelectionUser({line: pos.line, ch: start}, {line: pos.line, ch: end});
     920    }
     921    function selectLine(line) {
     922      setSelectionUser({line: line, ch: 0}, {line: line, ch: lines[line].text.length});
    864923    }
    865924    function handleEnter() {
     
    925984        lines[i].stateAfter = null;
    926985      work = [0];
     986      startWorker();
    927987    }
    928988    function gutterChanged() {
     
    9831043        if (no == -1) return null;
    9841044      }
    985       line.className = className;
    986       changes.push({from: no, to: no + 1});
     1045      if (line.className != className) {
     1046        line.className = className;
     1047        changes.push({from: no, to: no + 1});
     1048      }
    9871049      return line;
    9881050    }
     
    10021064    }
    10031065
     1066    function stringWidth(str) {
     1067      measure.innerHTML = "<pre><span>x</span></pre>";
     1068      measure.firstChild.firstChild.firstChild.nodeValue = str;
     1069      return measure.firstChild.firstChild.offsetWidth || 10;
     1070    }
    10041071    // These are used to go from pixel positions to character
    1005     // positions, taking tabs into account.
     1072    // positions, taking varying character widths into account.
    10061073    function charX(line, pos) {
    1007       var text = lines[line].text, span = measure.firstChild;
    1008       if (text.lastIndexOf("\t", pos) == -1) return pos * charWidth();
    1009       var old = span.firstChild.nodeValue;
    1010       try {
    1011         span.firstChild.nodeValue = text.slice(0, pos);
    1012         return span.offsetWidth;
    1013       } finally {span.firstChild.nodeValue = old;}
     1074      if (pos == 0) return 0;
     1075      measure.innerHTML = "<pre><span>" + lines[line].getHTML(null, null, false, pos) + "</span></pre>";
     1076      return measure.firstChild.firstChild.offsetWidth;
    10141077    }
    10151078    function charFromX(line, x) {
    1016       var text = lines[line].text, cw = charWidth();
    10171079      if (x <= 0) return 0;
    1018       if (text.indexOf("\t") == -1) return Math.min(text.length, Math.round(x / cw));
    1019       var mspan = measure.firstChild, mtext = mspan.firstChild, old = mtext.nodeValue;
    1020       try {
    1021         mtext.nodeValue = text;
    1022         var from = 0, fromX = 0, to = text.length, toX = mspan.offsetWidth;
    1023         if (x > toX) return to;
    1024         for (;;) {
    1025           if (to - from <= 1) return (toX - x > x - fromX) ? from : to;
    1026           var middle = Math.ceil((from + to) / 2);
    1027           mtext.nodeValue = text.slice(0, middle);
    1028           var curX = mspan.offsetWidth;
    1029           if (curX > x) {to = middle; toX = curX;}
    1030           else {from = middle; fromX = curX;}
    1031         }
    1032       } finally {mtext.nodeValue = old;}
     1080      var lineObj = lines[line], text = lineObj.text;
     1081      function getX(len) {
     1082        measure.innerHTML = "<pre><span>" + lineObj.getHTML(null, null, false, len) + "</span></pre>";
     1083        return measure.firstChild.firstChild.offsetWidth;
     1084      }
     1085      var from = 0, fromX = 0, to = text.length, toX;
     1086      // Guess a suitable upper bound for our search.
     1087      var estimated = Math.min(to, Math.ceil(x / stringWidth("x")));
     1088      for (;;) {
     1089        var estX = getX(estimated);
     1090        if (estX <= x && estimated < to) estimated = Math.min(to, Math.ceil(estimated * 1.2));
     1091        else {toX = estX; to = estimated; break;}
     1092      }
     1093      if (x > toX) return to;
     1094      // Try to guess a suitable lower bound as well.
     1095      estimated = Math.floor(to * 0.8); estX = getX(estimated);
     1096      if (estX < x) {from = estimated; fromX = estX;}
     1097      // Do a binary search between these bounds.
     1098      for (;;) {
     1099        if (to - from <= 1) return (toX - x > x - fromX) ? from : to;
     1100        var middle = Math.ceil((from + to) / 2), middleX = getX(middle);
     1101        if (middleX > x) {to = middle; toX = middleX;}
     1102        else {from = middle; fromX = middleX;}
     1103      }
    10331104    }
    10341105
     
    10441115    function lineHeight() {
    10451116      var nlines = lineDiv.childNodes.length;
    1046       if (nlines) return lineDiv.offsetHeight / nlines;
    1047       else return measure.firstChild.offsetHeight || 1;
    1048     }
    1049     function charWidth() {return (measure.firstChild.offsetWidth || 320) / 40;}
     1117      if (nlines) return (lineDiv.offsetHeight / nlines) || 1;
     1118      measure.innerHTML = "<pre>x</pre>";
     1119      return measure.firstChild.offsetHeight || 1;
     1120    }
    10501121    function paddingTop() {return lineSpace.offsetTop;}
    10511122    function paddingLeft() {return lineSpace.offsetLeft;}
    10521123
    10531124    function posFromMouse(e, liberal) {
    1054       var off = eltOffset(lineSpace),
    1055           x = e.pageX() - off.left,
    1056           y = e.pageY() - off.top;
    1057       if (!liberal && e.target() != lineSpace.parentNode && !(e.target() == wrapper && y > (lines.length * lineHeight())))
    1058         for (var n = e.target(); n != lineDiv && n != cursor; n = n.parentNode)
    1059           if (!n || n == wrapper) return null;
    1060       var line = showingFrom + Math.floor(y / lineHeight());
    1061       return clipPos({line: line, ch: charFromX(clipLine(line), x)});
     1125      var offW = eltOffset(scroller, true), x = e.e.clientX, y = e.e.clientY;
     1126      // This is a mess of a heuristic to try and determine whether a
     1127      // scroll-bar was clicked or not, and to return null if one was
     1128      // (and !liberal).
     1129      if (!liberal && (x - offW.left > scroller.clientWidth || y - offW.top > scroller.clientHeight))
     1130        return null;
     1131      var offL = eltOffset(lineSpace, true);
     1132      var line = showingFrom + Math.floor((y - offL.top) / lineHeight());
     1133      return clipPos({line: line, ch: charFromX(clipLine(line), x - offL.left)});
    10621134    }
    10631135    function onContextMenu(e) {
     
    10701142      input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.pageY() - 1) +
    10711143        "px; left: " + (e.pageX() - 1) + "px; z-index: 1000; background: white; " +
    1072         "border-width: 0; outline: none; overflow: hidden;";
     1144        "border-width: 0; outline: none; overflow: hidden; opacity: .05;";
    10731145      var val = input.value = getSelection();
    1074       input.focus();
    1075       setSelRange(input, 0, val.length);
    1076       if (gecko) e.stop();
     1146      focusInput();
     1147      setSelRange(input, 0, input.value.length);
    10771148      leaveInputAlone = true;
    1078       setTimeout(function() {
     1149      function rehide() {
    10791150        if (input.value != val) operation(replaceSelection)(input.value, "end");
    10801151        input.style.cssText = oldCSS;
     
    10821153        prepareInput();
    10831154        slowPoll();
    1084       }, 50);
     1155      }
     1156     
     1157      if (gecko) {
     1158        e.stop()
     1159        var mouseup = connect(window, "mouseup", function() {
     1160          mouseup();
     1161          setTimeout(rehide, 20);
     1162        }, true);
     1163      }
     1164      else {
     1165        setTimeout(rehide, 50);
     1166      }
    10851167    }
    10861168
     
    11211203        }
    11221204      }
    1123       for (var i = head.line, e = forward ? Math.min(i + 50, lines.length) : Math.max(0, i - 50); i != e; i+=d) {
     1205      for (var i = head.line, e = forward ? Math.min(i + 50, lines.length) : Math.max(-1, i - 50); i != e; i+=d) {
    11241206        var line = lines[i], first = i == head.line;
    11251207        var found = scan(line, first && forward ? pos + 1 : 0, first && !forward ? pos : line.text.length);
     
    11671249      return state;
    11681250    }
     1251    function highlightLines(start, end) {
     1252      var state = getStateBefore(start);
     1253      for (var i = start; i < end; ++i) {
     1254        var line = lines[i];
     1255        line.highlight(mode, state);
     1256        line.stateAfter = copyState(mode, state);
     1257      }
     1258    }
    11691259    function highlightWorker() {
    11701260      var end = +new Date + options.workTime;
     1261      var foundWork = work.length;
    11711262      while (work.length) {
    11721263        if (!lines[showingFrom].stateAfter) var task = showingFrom;
     
    11771268        else state = startState(mode);
    11781269
     1270        var unchanged = 0;
    11791271        for (var i = start, l = lines.length; i < l; ++i) {
    11801272          var line = lines[i], hadState = line.stateAfter;
     
    11871279          var changed = line.highlight(mode, state);
    11881280          line.stateAfter = copyState(mode, state);
    1189           if (hadState && !changed && line.text) break;
     1281          if (changed || !hadState) unchanged = 0;
     1282          else if (++unchanged > 3) break;
    11901283        }
    11911284        changes.push({from: task, to: i});
    11921285      }
     1286      if (foundWork && options.onHighlightComplete)
     1287        options.onHighlightComplete(instance);
    11931288    }
    11941289    function startWorker(time) {
     
    12171312        prepareInput();
    12181313
    1219       if (selectionChanged && options.onCursorActivity)
    1220         options.onCursorActivity(instance);
    1221       if (textChanged && options.onChange)
    1222         options.onChange(instance);
    12231314      if (selectionChanged && options.matchBrackets)
    12241315        setTimeout(operation(function() {
     
    12261317          matchBrackets(false);
    12271318        }), 20);
     1319      var tc = textChanged; // textChanged can be reset by cursoractivity callback
     1320      if (selectionChanged && options.onCursorActivity)
     1321        options.onCursorActivity(instance);
     1322      if (tc && options.onChange && instance)
     1323        options.onChange(instance, tc);
    12281324    }
    12291325    var nestedOperation = 0;
     
    12601356              if (newmatch) match = newmatch;
    12611357              else break;
     1358              start++;
    12621359            }
    12631360          }
     
    13421439    };
    13431440
     1441    for (var ext in extensions)
     1442      if (extensions.propertyIsEnumerable(ext) &&
     1443          !instance.propertyIsEnumerable(ext))
     1444        instance[ext] = extensions[ext];
    13441445    return instance;
    13451446  } // (end of function CodeMirror)
     
    13491450    value: "",
    13501451    mode: null,
     1452    theme: "default",
    13511453    indentUnit: 2,
    13521454    indentWithTabs: false,
     
    13621464    onCursorActivity: null,
    13631465    onGutterClick: null,
     1466    onHighlightComplete: null,
    13641467    onFocus: null, onBlur: null, onScroll: null,
    13651468    matchBrackets: false,
     
    13671470    workDelay: 200,
    13681471    undoDepth: 40,
    1369     tabindex: null
     1472    tabindex: null,
     1473    document: window.document
    13701474  };
    13711475
     
    13841488    if (typeof spec == "string")
    13851489      var mname = spec, config = {};
    1386     else
     1490    else if (spec != null)
    13871491      var mname = spec.name, config = spec;
    13881492    var mfactory = modes[mname];
     
    13911495      return CodeMirror.getMode(options, "text/plain");
    13921496    }
    1393     return mfactory(options, config);
     1497    return mfactory(options, config || {});
    13941498  }
    13951499  CodeMirror.listModes = function() {
     
    14041508      if (mimeModes.propertyIsEnumerable(m)) list.push(m);
    14051509    return list;
     1510  };
     1511
     1512  var extensions = {};
     1513  CodeMirror.defineExtension = function(name, func) {
     1514    extensions[name] = func;
    14061515  };
    14071516
     
    15181627    current: function(){return this.string.slice(this.start, this.pos);}
    15191628  };
     1629  CodeMirror.StringStream = StringStream;
    15201630
    15211631  // Line objects. These hold state related to a line, including
     
    15711681    // classes.
    15721682    highlight: function(mode, state) {
    1573       var stream = new StringStream(this.text), st = this.styles, pos = 0, changed = false;
     1683      var stream = new StringStream(this.text), st = this.styles, pos = 0;
     1684      var changed = false, curWord = st[0], prevWord;
     1685      if (this.text == "" && mode.blankLine) mode.blankLine(state);
    15741686      while (!stream.eol()) {
    15751687        var style = mode.token(stream, state);
     
    15791691          st[pos-2] += substr;
    15801692        else if (substr) {
    1581           if (!changed && st[pos] != substr || st[pos+1] != style) changed = true;
     1693          if (!changed && (st[pos+1] != style || (pos && st[pos-2] != prevWord))) changed = true;
    15821694          st[pos++] = substr; st[pos++] = style;
     1695          prevWord = curWord; curWord = st[pos];
    15831696        }
    15841697        // Give up when line is ridiculously long
     
    15891702      }
    15901703      if (st.length != pos) {st.length = pos; changed = true;}
    1591       return changed;
     1704      if (pos && st[pos-2] != prevWord) changed = true;
     1705      // Short lines with simple highlights always count as changed,
     1706      // because they are likely to highlight the same way in various
     1707      // contexts.
     1708      return changed || (st.length < 5 && this.text.length < 10);
    15921709    },
    15931710    // Fetch the parser token for a given character. Useful for hacks
     
    16081725    // Produces an HTML fragment for the line, taking selection,
    16091726    // marking, and highlighting into account.
    1610     getHTML: function(sfrom, sto, includePre) {
     1727    getHTML: function(sfrom, sto, includePre, endAt) {
    16111728      var html = [];
    16121729      if (includePre)
     
    16141731      function span(text, style) {
    16151732        if (!text) return;
    1616         if (style) html.push('<span class="', style, '">', htmlEscape(text), "</span>");
     1733        if (style) html.push('<span class="cm-', style, '">', htmlEscape(text), "</span>");
    16171734        else html.push(htmlEscape(text));
    16181735      }
    16191736      var st = this.styles, allText = this.text, marked = this.marked;
    16201737      if (sfrom == sto) sfrom = null;
    1621 
    1622       if (!allText)
     1738      var len = allText.length;
     1739      if (endAt != null) len = Math.min(endAt, len);
     1740
     1741      if (!allText && endAt == null)
    16231742        span(" ", sfrom != null && sto == null ? "CodeMirror-selected" : null);
    16241743      else if (!marked && sfrom == null)
    1625         for (var i = 0, e = st.length; i < e; i+=2) span(st[i], st[i+1]);
     1744        for (var i = 0, ch = 0; ch < len; i+=2) {
     1745          var str = st[i], l = str.length;
     1746          if (ch + l > len) str = str.slice(0, len - ch);
     1747          ch += l;
     1748          span(str, st[i+1]);
     1749        }
    16261750      else {
    16271751        var pos = 0, i = 0, text = "", style, sg = 0;
     
    16331757          }
    16341758        }
    1635         nextMark();       
    1636         while (pos < allText.length) {
    1637           var upto = allText.length;
     1759        nextMark();
     1760        while (pos < len) {
     1761          var upto = len;
    16381762          var extraStyle = "";
    16391763          if (sfrom != null) {
     
    17411865    pageX: function() {
    17421866      if (this.e.pageX != null) return this.e.pageX;
    1743       else return this.e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
     1867      var doc = this.target().ownerDocument;
     1868      return this.e.clientX + doc.body.scrollLeft + doc.documentElement.scrollLeft;
    17441869    },
    17451870    pageY: function() {
    17461871      if (this.e.pageY != null) return this.e.pageY;
    1747       else return this.e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
     1872      var doc = this.target().ownerDocument;
     1873      return this.e.clientY + doc.body.scrollTop + doc.documentElement.scrollTop;
    17481874    }
    17491875  };
     
    17741900
    17751901  var gecko = /gecko\/\d{7}/i.test(navigator.userAgent);
     1902  var ie = /MSIE \d/.test(navigator.userAgent);
     1903  var safari = /Apple Computer/.test(navigator.vendor);
    17761904
    17771905  var lineSep = "\n";
     
    18041932
    18051933  // Find the position of an element by following the offsetParent chain.
    1806   function eltOffset(node) {
    1807     var x = 0, y = 0, n2 = node;
    1808     for (var n = node; n; n = n.offsetParent) {x += n.offsetLeft; y += n.offsetTop;}
    1809     for (var n = node; n != document.body; n = n.parentNode) {x -= n.scrollLeft; y -= n.scrollTop;}
     1934  // If screen==true, it returns screen (rather than page) coordinates.
     1935  function eltOffset(node, screen) {
     1936    var doc = node.ownerDocument.body;
     1937    var x = 0, y = 0, hitDoc = false;
     1938    for (var n = node; n; n = n.offsetParent) {
     1939      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;
     1944    for (var n = node.parentNode; n != e; n = n.parentNode)
     1945      if (n.scrollLeft != null) { x -= n.scrollLeft; y -= n.scrollTop;}
    18101946    return {left: x, top: y};
    18111947  }
     
    18211957
    18221958  function htmlEscape(str) {
    1823     return str.replace(/[<&]/g, function(str) {return str == "&" ? "&amp;" : "&lt;";});
     1959    return str.replace(/[<>&]/g, function(str) {
     1960      return str == "&" ? "&amp;" : str == "<" ? "&lt;" : "&gt;";
     1961    });
    18241962  }
     1963  CodeMirror.htmlEscape = htmlEscape;
    18251964
    18261965  // Used to position the cursor after an undo/redo by finding the
     
    18551994  else
    18561995    var splitLines = function(string){return string.split(/\r?\n/);};
     1996  CodeMirror.splitLines = splitLines;
    18571997
    18581998  // Sane model of finding and setting the selection in a textarea
     
    18622002      catch(e) {return null;}
    18632003    };
    1864     var setSelRange = function(te, start, end) {
    1865       try {te.setSelectionRange(start, end);}
    1866       catch(e) {} // Fails on Firefox when textarea isn't part of the document
    1867     };
     2004    if (safari)
     2005      // On Safari, selection set with setSelectionRange are in a sort
     2006      // of limbo wrt their anchor. If you press shift-left in them,
     2007      // the anchor is put at the end, and the selection expanded to
     2008      // the left. If you press shift-right, the anchor ends up at the
     2009      // front. This is not what CodeMirror wants, so it does a
     2010      // spurious modify() call to get out of limbo.
     2011      var setSelRange = function(te, start, end) {
     2012        if (start == end)
     2013          te.setSelectionRange(start, end);
     2014        else {
     2015          te.setSelectionRange(start, end - 1);
     2016          window.getSelection().modify("extend", "forward", "character");
     2017        }
     2018      };
     2019    else
     2020      var setSelRange = function(te, start, end) {
     2021        try {te.setSelectionRange(start, end);}
     2022        catch(e) {} // Fails on Firefox when textarea isn't part of the document
     2023      };
    18682024  }
    18692025  // IE model. Don't ask.
    18702026  else {
    18712027    var selRange = function(te) {
    1872       try {var range = document.selection.createRange();}
     2028      try {var range = te.ownerDocument.selection.createRange();}
    18732029      catch(e) {return null;}
    18742030      if (!range || range.parentElement() != te) return null;
  • _plugins_/skeleditor/trunk/spip_210/codemirror/manual.html

    r46386 r48687  
    33  <head>
    44    <title>CodeMirror: User Manual</title>
     5    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
    56    <link rel="stylesheet" type="text/css" href="css/docs.css"/>
    67    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     
    2223    <p>CodeMirror is a code-editor component that can be embedded in
    2324    Web pages. It provides <em>only</em> the editor component, no
    24     accompanying buttons, auto-completion, or other IDE functionality.
    25     It does provide a rich API on top of which such functionality can
    26     be straightforwardly implemented.</p>
     25    accompanying buttons
     26    (see <a href="http://www.octolabs.com/javascripts/codemirror-ui/">CodeMirror
     27    UI</a> for a drop-in button bar), auto-completion, or other IDE
     28    functionality. It does provide a rich API on top of which such
     29    functionality can be straightforwardly implemented.</p>
    2730
    2831    <p>CodeMirror works with language-specific modes. Modes are
     
    3639    <p>The easiest way to use CodeMirror is to simply load the script
    3740    and style sheet found under <code>lib/</code> in the distribution,
    38     plus the script and style sheet for the mode(s) you want to use.
    39     (See also <a href="compress.html">the compresion helper</a>.) For
     41    plus a mode script from one of the <code>mode/</code> directories
     42    and a theme stylesheet from <code>theme/</code>. (See
     43    also <a href="compress.html">the compresion helper</a>.) For
    4044    example:</p>
    4145
     
    4347&lt;link rel="stylesheet" href="lib/codemirror.css">
    4448&lt;script src="mode/javascript/javascript.js">&lt;/script>
    45 &lt;link rel="stylesheet" href="mode/javascript/javascript.css"></pre>
    46 
    47     <p>Having done this, an editor instance can be created like
    48     this:</p>
     49&lt;link rel="stylesheet" href="theme/default.css"></pre>
     50
     51    <p>(If you use a them other than <code>default.css</code>, you
     52    also have to specify the
     53    <a href="#option_theme"><code>theme</code></a> option.) Having
     54    done this, an editor instance can be created like this:</p>
    4955
    5056    <pre>var myCodeMirror = CodeMirror(document.body);</pre>
     
    7480
    7581    <pre>var myCodeMirror = CodeMirror(function(elt) {
    76   myTextArea.parentNode.replaceChild(myTextArea, elt);
     82  myTextArea.parentNode.replaceChild(elt, myTextArea);
    7783}, {value: myTextArea.value});</pre>
    7884
     
    98104    on your page.</p>
    99105
    100     <p>Options are not checked in any way, so setting bogus options is
    101     bound to lead to odd errors.</p>
     106    <p>Options are not checked in any way, so setting bogus option
     107    values is bound to lead to odd errors.</p>
     108
     109    <p><em>Note:</em> CodeMirror
     110    2 <a href="internals.html#summary">does not support</a>
     111    line-wrapping. I would have very much liked to support it, but it
     112    combines extremely poorly with the way the editor is
     113    implemented.</p>
    102114
    103115    <p>These are the supported options:</p>
     
    121133      the <code>CodeMirror.listModes</code>
    122134      and <code>CodeMirror.listMIMEs</code> functions.</dd>
     135
     136      <dt id="option_theme"><code>theme (string)</code></dt>
     137      <dd>The theme to style the editor with. You must make sure the
     138      CSS file defining the corresponding <code>.cm-s-[name]</code>
     139      styles is loaded (see
     140      the <a href="theme/"><code>theme</code></a> directory in the
     141      distribution).</dd>
    123142
    124143      <dt id="option_indentUnit"><code>indentUnit (integer)</code></dt>
     
    185204      <dt id="option_readOnly"><code>readOnly (boolean)</code></dt>
    186205      <dd>This disables editing of the editor content by the user.
    187       (Changes through API functions will still be possible.)</dd>
     206      (Changes through API functions will still be possible.) If you
     207      also want to disable the cursor, use <code>"nocursor"</code> as
     208      a value for this option, instead of <code>true</code>.</dd>
    188209
    189210      <dt id="option_onChange"><code>onChange (function)</code></dt>
     
    209230      <dd>When given, will be called whenever the editor is
    210231      scrolled.</dd>
     232
     233      <dt id="option_onHighlightComplete"><code>onHighlightComplete (function)</code></dt>
     234      <dd>Whenever the editor's content has been fully highlighted,
     235      this function (if given) will be called. It'll be given a single
     236      argument, the editor instance.</dd>
    211237
    212238      <dt id="option_matchBrackets"><code>matchBrackets (boolean)</code></dt>
     
    230256      will be assigned.</dd>
    231257
     258      <dt id="option_document"><code>document (DOM document)</code></dt>
     259      <dd>Use this if you want to display the editor in another DOM.
     260      By default it will use the global <code>document</code>
     261      object.</dd>
     262
    232263      <dt id="option_onKeyEvent"><code>onKeyEvent (function)</code></dt>
    233264      <dd>This provides a rather low-level hook into CodeMirror's key
    234265      handling. If provided, this function will be called on
    235       every <code>keydown</code> and <code>keypress</code> event that
    236       CodeMirror captures. It will be passed two arguments, the editor
    237       instance and the key event. This key event is pretty much the
    238       raw key event, except that a <code>stop()</code> method is
    239       always added to it. You could feed it to, for
    240       example, <code>jQuery.Event</code> to further normalize
    241       it.<br>This function can inspect the key event, and handle it if
    242       it wants to. It may return true to tell CodeMirror to ignore the
    243       event. Be wary that, on some browsers, stopping
    244       a <code>keydown</code> does not stop the <code>keypress</code>
    245       from firing, whereas on others it does. If you respond to an
    246       event, you should probably inspect its <code>type</code>
    247       property and only do something when it is <code>keydown</code>
    248       (or <code>keypress</code> for actions that need character
    249       data).</dd>
     266      every <code>keydown</code>, <code>keyup</code>,
     267      and <code>keypress</code> event that CodeMirror captures. It
     268      will be passed two arguments, the editor instance and the key
     269      event. This key event is pretty much the raw key event, except
     270      that a <code>stop()</code> method is always added to it. You
     271      could feed it to, for example, <code>jQuery.Event</code> to
     272      further normalize it.<br>This function can inspect the key
     273      event, and handle it if it wants to. It may return true to tell
     274      CodeMirror to ignore the event. Be wary that, on some browsers,
     275      stopping a <code>keydown</code> does not stop
     276      the <code>keypress</code> from firing, whereas on others it
     277      does. If you respond to an event, you should probably inspect
     278      its <code>type</code> property and only do something when it
     279      is <code>keydown</code> (or <code>keypress</code> for actions
     280      that need character data).</dd>
    250281    </dl>
    251282
     
    267298    <dl>
    268299      <dt id="class_CodeMirror"><code>CodeMirror</code></dt>
    269       <dd>The outer element of the editor. This determines whether the
    270       editor scrolls (<code>overflow: auto</code> + fixed height). Can
    271       also be used to set styles that should hold for everything
    272       inside the editor, or to set a background.</dd>
     300      <dd>The outer element of the editor. This should be used for
     301      borders and positioning. Can also be used to set styles that
     302      should hold for everything inside the editor, or to set a
     303      background.</dd>
     304
     305      <dt id="class_CodeMirror_scroll"><code>CodeMirror-scroll</code></dt>
     306      <dd>This determines whether the editor scrolls (<code>overflow:
     307      auto</code> + fixed height). By default, it does. Giving
     308      this <code>height: auto; overflow: visible;</code> will cause
     309      the editor to resize to fit its content.</dd>
    273310
    274311      <dt id="class_CodeMirror_focused"><code>CodeMirror-focused</code></dt>
     
    305342
    306343      <dt id="class_CodeMirror_matchingbracket"><code>CodeMirror-matchingbracket</code>,
    307         <code>CodeMirror-matchingbracket</code></dt>
     344        <code>CodeMirror-nonmatchingbracket</code></dt>
    308345      <dd>These are used to style matched (or unmatched) brackets.</dd>
    309346    </dl>
     
    555592    </dl>
    556593
     594    <p id="defineExtension">If you want define extra methods in terms
     595    of the CodeMirror API, is it possible to
     596    use <code>CodeMirror.defineExtension(name, value)</code>. This
     597    will cause the given value (usually a method) to be added to all
     598    CodeMirror instances created from then on.</p>
     599
    557600    <h2 id="modeapi">Writing CodeMirror Modes</h2>
    558601
     
    605648    define this method. It should read one token from the stream it is
    606649    given as an argument, optionally update its state, and return a
    607     CSS class string, or <code>null</code> for tokens that do not have
    608     to be styled.<p>
     650    style string, or <code>null</code> for tokens that do not have to
     651    be styled. For your styles, you can either use the 'standard' ones
     652    defined in the themes (without the <code>cm-</code> prefix), or
     653    define your own (as the <a href="../mode/diff/index.html">diff</a>
     654    mode does) and have people include a custom theme for your
     655    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>
    609662
    610663    <p id="StringStream">The stream object encapsulates a line of code
     
    766819<div style="height: 2em">&nbsp;</div>
    767820
    768 <script type="text/javascript" src="css/font.js"></script>
    769 
    770821  </body>
    771822</html>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/clike/clike.css

    r46386 r48687  
    55span.c-like-preprocessor {color: #049;}
    66span.c-like-var {color: #22b;}
     7span.c-like-annotation {color: #666;}
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/clike/clike.js

    r46386 r48687  
    11CodeMirror.defineMode("clike", function(config, parserConfig) {
    22  var indentUnit = config.indentUnit, keywords = parserConfig.keywords,
    3       cpp = parserConfig.useCPP, multiLineStrings = parserConfig.multiLineStrings, $vars = parserConfig.$vars;
     3      cpp = parserConfig.useCPP, multiLineStrings = parserConfig.multiLineStrings,
     4      $vars = parserConfig.$vars, atAnnotations = parserConfig.atAnnotations;
    45  var isOperatorChar = /[+\-*&%=<>!?|]/;
    56
     
    2324    else if (ch == "#" && cpp && state.startOfLine) {
    2425      stream.skipToEnd();
    25       return ret("directive", "c-like-preprocessor");
     26      return ret("directive", "meta");
    2627    }
    2728    else if (/\d/.test(ch)) {
    2829      stream.eatWhile(/[\w\.]/)
    29       return ret("number", "c-like-number");
     30      return ret("number", "number");
    3031    }
    3132    else if (ch == "/") {
     
    3536      else if (stream.eat("/")) {
    3637        stream.skipToEnd();
    37         return ret("comment", "c-like-comment");
     38        return ret("comment", "comment");
    3839      }
    3940      else {
     
    4647      return ret("operator");
    4748    }
     49    else if (atAnnotations && ch == "@") {
     50        stream.eatWhile(/[\w\$_]/);
     51        return ret("annotation", "meta");
     52    }
    4853    else if ($vars && ch == "$") {
    4954      stream.eatWhile(/[\w\$_]/);
    50       return ret("word", "c-like-var");
     55      return ret("word", "variable");
    5156    }
    5257    else {
    5358      stream.eatWhile(/[\w\$_]/);
    54       if (keywords && keywords.propertyIsEnumerable(stream.current())) return ret("keyword", "c-like-keyword");
    55       return ret("word", "c-like-word");
     59      if (keywords && keywords.propertyIsEnumerable(stream.current())) return ret("keyword", "keyword");
     60      return ret("word");
    5661    }
    5762  }
     
    6671      if (end || !(escaped || multiLineStrings))
    6772        state.tokenize = tokenBase;
    68       return ret("string", "c-like-string");
     73      return ret("string", "string");
    6974    };
    7075  }
     
    7984      maybeEnd = (ch == "*");
    8085    }
    81     return ret("comment", "c-like-comment");
     86    return ret("comment", "comment");
    8287  }
    8388
     
    131136      }
    132137      else if (type == ctx.type) popContext(state);
    133       else if (ctx.type == "}") pushContext(state, stream.column(), "statement");
     138      else if (ctx.type == "}" || ctx.type == "top") pushContext(state, stream.column(), "statement");
    134139      state.startOfLine = false;
    135140      return style;
     
    173178  CodeMirror.defineMIME("text/x-java", {
    174179    name: "clike",
     180    atAnnotations: true,
    175181    keywords: keywords("abstract assert boolean break byte case catch char class const continue default " +
    176182                       "do double else enum extends false final finally float for goto if implements import " +
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/clike/index.html

    r46386 r48687  
    66    <script src="../../lib/codemirror.js"></script>
    77    <script src="clike.js"></script>
    8     <link rel="stylesheet" href="clike.css">
     8    <link rel="stylesheet" href="../../theme/default.css">
    99    <link rel="stylesheet" href="../../css/docs.css">
    1010    <style>.CodeMirror {border: 2px inset #dee;}</style>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/css/css.js

    r46386 r48687  
    55  function tokenBase(stream, state) {
    66    var ch = stream.next();
    7     if (ch == "@") {stream.eatWhile(/\w/); return ret("css-at", stream.current());}
     7    if (ch == "@") {stream.eatWhile(/\w/); return ret("meta", stream.current());}
    88    else if (ch == "/" && stream.eat("*")) {
    99      state.tokenize = tokenCComment;
     
    2222    else if (ch == "#") {
    2323      stream.eatWhile(/\w/);
    24       return ret("css-selector", "hash");
     24      return ret("atom", "hash");
    2525    }
    2626    else if (ch == "!") {
    2727      stream.match(/^\s*\w*/);
    28       return ret("css-important", "important");
     28      return ret("keyword", "important");
    2929    }
    3030    else if (/\d/.test(ch)) {
    3131      stream.eatWhile(/[\w.%]/);
    32       return ret("css-unit", "unit");
     32      return ret("number", "unit");
    3333    }
    3434    else if (/[,.+>*\/]/.test(ch)) {
     
    4040    else {
    4141      stream.eatWhile(/[\w\\\-_]/);
    42       return ret("css-identifier", "identifier");
     42      return ret("variable", "variable");
    4343    }
    4444  }
     
    5353      maybeEnd = (ch == "*");
    5454    }
    55     return ret("css-comment", "comment");
     55    return ret("comment", "comment");
    5656  }
    5757
     
    6565      dashes = (ch == "-") ? dashes + 1 : 0;
    6666    }
    67     return ret("css-comment", "comment");
     67    return ret("comment", "comment");
    6868  }
    6969
     
    7777      }
    7878      if (!escaped) state.tokenize = tokenBase;
    79       return ret("css-string", "string");
     79      return ret("string", "string");
    8080    };
    8181  }
     
    9393
    9494      var context = state.stack[state.stack.length-1];
    95       if (type == "hash" && context == "rule") style = "css-colorcode";
    96       else if (style == "css-identifier") {
    97         if (context == "rule") style = "css-value";
    98         else if (!context || context == "@media{") style = "css-selector";
     95      if (type == "hash" && context == "rule") style = "atom";
     96      else if (style == "variable") {
     97        if (context == "rule") style = "number";
     98        else if (!context || context == "@media{") style = "tag";
    9999      }
    100100
     
    107107      else if (type == "}") state.stack.pop();
    108108      else if (type == "@media") state.stack.push("@media");
    109       else if (context != "rule" && context != "@media" && type != "comment") state.stack.push("rule");
     109      else if (context == "{" && type != "comment") state.stack.push("rule");
    110110      return style;
    111111    },
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/css/index.html

    r46386 r48687  
    66    <script src="../../lib/codemirror.js"></script>
    77    <script src="css.js"></script>
    8     <link rel="stylesheet" href="css.css">
     8    <link rel="stylesheet" href="../../theme/default.css">
    99    <style>.CodeMirror {background: #f8f8f8;}</style>
    1010    <link rel="stylesheet" href="../../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/diff/diff.css

    r46386 r48687  
    1 span.diff-rangeinfo {color: #a0b;}
    2 span.diff-minus {color: #a22;}
    3 span.diff-plus {color: #2b2;}
     1.cm-s-default span.cm-rangeinfo {color: #a0b;}
     2.cm-s-default span.cm-minus {color: #a22;}
     3.cm-s-default span.cm-plus {color: #2b2;}
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/diff/diff.js

    r46386 r48687  
    44      var ch = stream.next();
    55      stream.skipToEnd();
    6       if (ch == "+") return "diff-plus";
    7       if (ch == "-") return "diff-minus";
    8       if (ch == "@") return "diff-rangeinfo";
     6      if (ch == "+") return "plus";
     7      if (ch == "-") return "minus";
     8      if (ch == "@") return "rangeinfo";
    99    }
    1010  };
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/haskell/haskell.js

    r46386 r48687  
    2525    if (specialRE.test(ch)) {
    2626      if (ch == '{' && source.eat('-')) {
    27         var t = "hs-comment";
     27        var t = "comment";
    2828        if (source.eat('#')) {
    29           t = "hs-pragma";
     29          t = "meta";
    3030        }
    3131        return switchState(source, setState, ncomment(t, 1));
    3232      }
    33       return "hs-special";
     33      return null;
    3434    }
    3535   
     
    4242      }
    4343      if (source.eat('\'')) {
    44         return "hs-char";
    45       }
    46       return "hs-error";
     44        return "string";
     45      }
     46      return "error";
    4747    }
    4848   
     
    5454      source.eatWhile(idRE);
    5555      if (source.eat('.')) {
    56         return "hs-qualifier";
    57       }
    58       return "hs-conid";
     56        return "qualifier";
     57      }
     58      return "variable-2";
    5959    }
    6060     
    6161    if (smallRE.test(ch)) {
    6262      source.eatWhile(idRE);
    63       return "hs-varid";
     63      return "variable";
    6464    }
    6565     
     
    6868        if (source.eat(/[xX]/)) {
    6969          source.eatWhile(hexitRE); // should require at least 1
    70           return "hs-integer";
     70          return "integer";
    7171        }
    7272        if (source.eat(/[oO]/)) {
    7373          source.eatWhile(octitRE); // should require at least 1
    74           return "hs-integer";
     74          return "number";
    7575        }
    7676      }
    7777      source.eatWhile(digitRE);
    78       var t = "hs-integer";
     78      var t = "number";
    7979      if (source.eat('.')) {
    80         t = "hs-float";
     80        t = "number";
    8181        source.eatWhile(digitRE); // should require at least 1
    8282      }
    8383      if (source.eat(/[eE]/)) {
    84         t = "hs-float";
     84        t = "number";
    8585        source.eat(/[-+]/);
    8686        source.eatWhile(digitRE); // should require at least 1
     
    9494        if (!source.eat(symbolRE)) {
    9595          source.skipToEnd();
    96           return "hs-comment";
    97         }
    98       }
    99       var t = "hs-varsym";
     96          return "comment";
     97        }
     98      }
     99      var t = "variable";
    100100      if (ch == ':') {
    101         t = "hs-consym";
     101        t = "variable-2";
    102102      }
    103103      source.eatWhile(symbolRE);
     
    105105    }
    106106     
    107     return "hs-error";
     107    return "error";
    108108  }
    109109   
     
    115115      var currNest = nest;
    116116      while (!source.eol()) {
    117         ch = source.next();
     117        var ch = source.next();
    118118        if (ch == '{' && source.eat('-')) {
    119119          ++currNest;
     
    137137      if (ch == '"') {
    138138        setState(normal);
    139         return "hs-string";
     139        return "string";
    140140      }
    141141      if (ch == '\\') {
    142142        if (source.eol() || source.eat(whiteCharRE)) {
    143143          setState(stringGap);
    144           return "hs-string";
     144          return "string";
    145145        }
    146146        if (source.eat('&')) {
     
    152152    }
    153153    setState(normal);
    154     return "hs-error";
     154    return "error";
    155155  }
    156156 
     
    161161    source.next();
    162162    setState(normal);
    163     return "hs-error";
     163    return "error";
    164164  }
    165165 
     
    174174    }
    175175   
    176     setType("hs-reservedid")(
     176    setType("keyword")(
    177177      "case", "class", "data", "default", "deriving", "do", "else", "foreign",
    178178      "if", "import", "in", "infix", "infixl", "infixr", "instance", "let",
    179179      "module", "newtype", "of", "then", "type", "where", "_");
    180180     
    181     setType("hs-reservedop")(
     181    setType("keyword")(
    182182      "\.\.", ":", "::", "=", "\\", "\"", "<-", "->", "@", "~", "=>");
    183183     
    184     setType("hs-prelude-varsym")(
     184    setType("builtin")(
    185185      "!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", "=<<",
    186186      "==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "**");
    187187     
    188     setType("hs-prelude-conid")(
     188    setType("builtin")(
    189189      "Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq",
    190190      "False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT",
     
    194194      "String", "True");
    195195     
    196     setType("hs-prelude-varid")(
     196    setType("builtin")(
    197197      "abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf",
    198198      "asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling",
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/haskell/index.html

    r46386 r48687  
    66    <script src="../../lib/codemirror.js"></script>
    77    <script src="haskell.js"></script>
    8     <link rel="stylesheet" href="haskell.css">
     8    <link rel="stylesheet" href="../../theme/elegant.css">
    99    <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
    1010    <link rel="stylesheet" href="../../css/docs.css">
     
    5151      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
    5252        lineNumbers: true,
    53         matchBrackets: true
     53        matchBrackets: true,
     54        theme: "elegant"
    5455      });
    5556    </script>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/htmlmixed/htmlmixed.js

    r46386 r48687  
    66  function html(stream, state) {
    77    var style = htmlMode.token(stream, state.htmlState);
    8     if (style == "xml-tag" && stream.current() == ">" && state.htmlState.context) {
     8    if (style == "tag" && stream.current() == ">" && state.htmlState.context) {
    99      if (/^script$/i.test(state.htmlState.context.tagName)) {
    1010        state.token = javascript;
     
    1818    return style;
    1919  }
     20  function maybeBackup(stream, pat, style) {
     21    var cur = stream.current();
     22    var close = cur.search(pat);
     23    if (close > -1) stream.backUp(cur.length - close);
     24    return style;
     25  }
    2026  function javascript(stream, state) {
    2127    if (stream.match(/^<\/\s*script\s*>/i, false)) {
     
    2430      return html(stream, state);
    2531    }
    26     return jsMode.token(stream, state.localState);
     32    return maybeBackup(stream, /<\/\s*script\s*>/,
     33                       jsMode.token(stream, state.localState));
    2734  }
    2835  function css(stream, state) {
     
    3239      return html(stream, state);
    3340    }
    34     return cssMode.token(stream, state.localState);
     41    return maybeBackup(stream, /<\/\s*style\s*>/,
     42                       cssMode.token(stream, state.localState));
    3543  }
    3644
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/htmlmixed/index.html

    r46386 r48687  
    66    <script src="../../lib/codemirror.js"></script>
    77    <script src="../xml/xml.js"></script>
    8     <link rel="stylesheet" href="../xml/xml.css">
    98    <script src="../javascript/javascript.js"></script>
    10     <link rel="stylesheet" href="../javascript/javascript.css">
    119    <script src="../css/css.js"></script>
    12     <link rel="stylesheet" href="../css/css.css">
     10    <link rel="stylesheet" href="../../theme/default.css">
    1311    <script src="htmlmixed.js"></script>
    1412    <link rel="stylesheet" href="../../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/javascript/index.html

    r46386 r48687  
    66    <script src="../../lib/codemirror.js"></script>
    77    <script src="javascript.js"></script>
    8     <link rel="stylesheet" href="javascript.css">
     8    <link rel="stylesheet" href="../../theme/default.css">
    99    <link rel="stylesheet" href="../../css/docs.css">
    1010    <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/javascript/javascript.js

    r46386 r48687  
    66
    77  var keywords = function(){
    8     function kw(type) {return {type: type, style: "js-keyword"};}
     8    function kw(type) {return {type: type, style: "keyword"};}
    99    var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
    10     var operator = kw("operator"), atom = {type: "atom", style: "js-atom"};
     10    var operator = kw("operator"), atom = {type: "atom", style: "atom"};
    1111    return {
    1212      "if": A, "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
     
    5252    else if (ch == "0" && stream.eat(/x/i)) {
    5353      stream.eatWhile(/[\da-f]/i);
    54       return ret("number", "js-atom");
     54      return ret("number", "atom");
    5555    }     
    5656    else if (/\d/.test(ch)) {
    5757      stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
    58       return ret("number", "js-atom");
     58      return ret("number", "atom");
    5959    }
    6060    else if (ch == "/") {
     
    6464      else if (stream.eat("/")) {
    6565        stream.skipToEnd();
    66         return ret("comment", "js-comment");
     66        return ret("comment", "comment");
    6767      }
    6868      else if (state.reAllowed) {
    6969        nextUntilUnescaped(stream, "/");
    7070        stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
    71         return ret("regexp", "js-string");
     71        return ret("regexp", "string");
    7272      }
    7373      else {
     
    8484      var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
    8585      return known ? ret(known.type, known.style, word) :
    86                      ret("variable", "js-variable", word);
     86                     ret("variable", "variable", word);
    8787    }
    8888  }
     
    9292      if (!nextUntilUnescaped(stream, quote))
    9393        state.tokenize = jsTokenBase;
    94       return ret("string", "js-string");
     94      return ret("string", "string");
    9595    };
    9696  }
     
    105105      maybeEnd = (ch == "*");
    106106    }
    107     return ret("comment", "js-comment");
     107    return ret("comment", "comment");
    108108  }
    109109
     
    141141          cc.pop()();
    142142        if (cx.marked) return cx.marked;
    143         if (type == "variable" && inScope(state, content)) return "js-localvariable";
     143        if (type == "variable" && inScope(state, content)) return "variable-2";
    144144        return style;
    145145      }
     
    160160    var state = cx.state;
    161161    if (state.context) {
    162       cx.marked = "js-variabledef";
     162      cx.marked = "def";
    163163      for (var v = state.localVars; v; v = v.next)
    164164        if (v.name == varname) return;
     
    245245  }
    246246  function property(type) {
    247     if (type == "variable") {cx.marked = "js-property"; return cont();}
     247    if (type == "variable") {cx.marked = "property"; return cont();}
    248248  }
    249249  function objprop(type) {
    250     if (type == "variable") cx.marked = "js-property";
     250    if (type == "variable") cx.marked = "property";
    251251    if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
    252252  }
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/php/index.html

    r46386 r48687  
    66    <script src="../../lib/codemirror.js"></script>
    77    <script src="../xml/xml.js"></script>
    8     <link rel="stylesheet" href="../xml/xml.css">
    98    <script src="../javascript/javascript.js"></script>
    10     <link rel="stylesheet" href="../javascript/javascript.css">
    119    <script src="../css/css.js"></script>
    12     <link rel="stylesheet" href="../css/css.css">
    1310    <script src="../clike/clike.js"></script>
    14     <link rel="stylesheet" href="../clike/clike.css">
    1511    <script src="php.js"></script>
     12    <link rel="stylesheet" href="../../theme/default.css">
    1613    <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
    1714    <link rel="stylesheet" href="../../css/docs.css">
     
    4845    JavaScript, CSS, and C-like modes.</p>
    4946
    50     <p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code>.</p>
     47    <p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
    5148  </body>
    5249</html>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/php/php.js

    r46386 r48687  
    1010             "final for foreach function global goto if implements interface instanceof namespace " +
    1111             "new or private protected public static switch throw try use var while xor");
     12  var phpConfig = {name: "clike", keywords: phpKeywords, multiLineStrings: true, $vars: true};
    1213
    1314  CodeMirror.defineMode("php", function(config, parserConfig) {
     
    1516    var jsMode = CodeMirror.getMode(config, "text/javascript");
    1617    var cssMode = CodeMirror.getMode(config, "text/css");
    17     var phpMode = CodeMirror.getMode(config, {name: "clike", keywords: phpKeywords, multiLineStrings: true, $vars: true});
     18    var phpMode = CodeMirror.getMode(config, phpConfig);
    1819
    1920    function dispatch(stream, state) { // TODO open PHP inside text/css
    2021      if (state.curMode == htmlMode) {
    2122        var style = htmlMode.token(stream, state.curState);
    22         if (style == "xml-processing" && /^<\?/.test(stream.current())) {
     23        if (style == "meta" && /^<\?/.test(stream.current())) {
    2324          state.curMode = phpMode;
    2425          state.curState = state.php;
    2526          state.curClose = /^\?>/;
    2627        }
    27         else if (style == "xml-tag" && stream.current() == ">" && state.curState.context) {
     28        else if (style == "tag" && stream.current() == ">" && state.curState.context) {
    2829          if (/^script$/i.test(state.curState.context.tagName)) {
    2930            state.curMode = jsMode;
     
    7980    }
    8081  });
     82  CodeMirror.defineMIME("application/x-httpd-php", "php");
     83  CodeMirror.defineMIME("text/x-php", phpConfig);
    8184})();
    82 
    83 CodeMirror.defineMIME("application/x-httpd-php", "php");
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/stex/index.html

    r46386 r48687  
    66    <script src="../../lib/codemirror.js"></script>
    77    <script src="stex.js"></script>
    8     <link rel="stylesheet" href="stex.css">
     8    <link rel="stylesheet" href="../../theme/default.css">
    99    <style>.CodeMirror {background: #f8f8f8;}</style>
    1010    <link rel="stylesheet" href="../../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/stex/stex.js

    r46386 r48687  
    2525
    2626    function applyMostPowerful(state) {
    27       context = state.cmdState;
     27      var context = state.cmdState;
    2828      for (var i = context.length - 1; i >= 0; i--) {
    2929          var plug = context[i];
     
    3232          return plug.styleIdentifier();
    3333      }
    34       return "stex-identifier";
     34      return null;
    3535    }
    3636
     
    5151            this.openBracket = function(content) {
    5252                this.bracketNo++;
    53                 return "stex-bracket";
     53                return "bracket";
    5454            };
    5555            this.closeBracket = function(content) {
     
    6060    var plugins = new Array();
    6161   
    62     plugins["importmodule"] = addPluginPattern("importmodule", "stex-command", "{[", ["stex-filepath", "stex-module"]);
    63     plugins["documentclass"] = addPluginPattern("documentclass", "stex-command", "{[", ["", "stex-unit"]);
    64     plugins["usepackage"] = addPluginPattern("documentclass", "stex-command", "[", ["stex-unit"]);
    65     plugins["begin"] = addPluginPattern("documentclass", "stex-command", "[", ["stex-unit"]);
    66     plugins["end"] = addPluginPattern("documentclass", "stex-command", "[", ["stex-unit"]);
     62    plugins["importmodule"] = addPluginPattern("importmodule", "tag", "{[", ["string", "builtin"]);
     63    plugins["documentclass"] = addPluginPattern("documentclass", "tag", "{[", ["", "atom"]);
     64    plugins["usepackage"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
     65    plugins["begin"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
     66    plugins["end"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
    6767
    6868    plugins["DEFAULT"] = function () {
    6969        this.name="DEFAULT";
    70         this.style="stex-command";
     70        this.style="tag";
    7171
    7272        this.styleIdentifier = function(content) {
     
    8484    function normal(source, state) {
    8585        if (source.match(/^\\[a-z]+/)) {
    86             cmdName = source.current();
     86            var cmdName = source.current();
    8787            cmdName = cmdName.substr(1, cmdName.length-1);
    8888            var plug = plugins[cmdName];
     
    9999        if (ch == "%") {
    100100            setState(state, inCComment);
    101             return "stex-comment";
     101            return "comment";
    102102        }
    103103        else if (ch=='}' || ch==']') {
     
    107107                setState(state, beginParams);
    108108            } else
    109                 return "stex-error";
    110             return "stex-bracket";
     109                return "error";
     110            return "bracket";
    111111        } else if (ch=='{' || ch=='[') {
    112112            plug = plugins["DEFAULT"];     
    113113            plug = new plug();
    114114            pushCommand(state, plug);
    115             return "stex-bracket";         
     115            return "bracket";       
    116116        }
    117117        else if (/\d/.test(ch)) {
    118118            source.eatWhile(/[\w.%]/);
    119             return "stex-unit";
     119            return "atom";
    120120        }
    121121        else {
     
    128128        source.skipToEnd();
    129129        setState(state, normal);
    130         return "css-comment";
     130        return "comment";
    131131    }
    132132
     
    134134        var ch = source.peek();
    135135        if (ch == '{' || ch == '[') {
    136            lastPlug = peekCommand(state);
    137            style = lastPlug.openBracket(ch);
     136           var lastPlug = peekCommand(state);
     137           var style = lastPlug.openBracket(ch);
    138138           source.eat(ch);
    139139           setState(state, normal);
    140            return "stex-bracket";
     140           return "bracket";
    141141        }
    142142        if (/[ \t\r]/.test(ch)) {
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/xml/index.html

    r46386 r48687  
    66    <script src="../../lib/codemirror.js"></script>
    77    <script src="xml.js"></script>
    8     <link rel="stylesheet" href="xml.css">
     8    <link rel="stylesheet" href="../../theme/default.css">
    99    <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
    1010    <link rel="stylesheet" href="../../css/docs.css">
  • _plugins_/skeleditor/trunk/spip_210/codemirror/mode/xml/xml.js

    r46386 r48687  
    2222      if (stream.eat("!")) {
    2323        if (stream.eat("[")) {
    24           if (stream.match("[CDATA[")) return chain(inBlock("xml-cdata", "]]>"));
     24          if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
    2525          else return null;
    2626        }
    27         else if (stream.match("--")) return chain(inBlock("xml-comment", "-->"));
     27        else if (stream.match("--")) return chain(inBlock("comment", "-->"));
    2828        else if (stream.match("DOCTYPE")) {
    2929          stream.eatWhile(/[\w\._\-]/);
    30           return chain(inBlock("xml-doctype", ">"));
     30          return chain(inBlock("meta", ">"));
    3131        }
    3232        else return null;
     
    3434      else if (stream.eat("?")) {
    3535        stream.eatWhile(/[\w\._\-]/);
    36         state.tokenize = inBlock("xml-processing", "?>");
    37         return "xml-processing";
     36        state.tokenize = inBlock("meta", "?>");
     37        return "meta";
    3838      }
    3939      else {
     
    4444        while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
    4545        state.tokenize = inTag;
    46         return "xml-tag";
     46        return "tag";
    4747      }
    4848    }
     
    5050      stream.eatWhile(/[^;]/);
    5151      stream.eat(";");
    52       return "xml-entity";
     52      return "atom";
    5353    }
    5454    else {
     
    6363      state.tokenize = inText;
    6464      type = ch == ">" ? "endTag" : "selfcloseTag";
    65       return "xml-tag";
     65      return "tag";
    6666    }
    6767    else if (ch == "=") {
     
    7575    else {
    7676      stream.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);
    77       return "xml-word";
     77      return "word";
    7878    }
    7979  }
     
    8787        }
    8888      }
    89       return "xml-attribute";
     89      return "string";
    9090    };
    9191  }
     
    130130    if (type == "openTag") {curState.tagName = tagName; return cont(attributes, endtag(curState.startOfLine));}
    131131    else if (type == "closeTag") {popContext(); return cont(endclosetag);}
    132     else if (type == "xml-cdata") {
     132    else if (type == "string") {
    133133      if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata");
    134134      if (curState.tokenize == inText) popContext();
     
    152152
    153153  function attributes(type) {
    154     if (type == "xml-word") {setStyle = "xml-attname"; return cont(attributes);}
     154    if (type == "word") {setStyle = "attribute"; return cont(attributes);}
    155155    if (type == "equals") return cont(attvalue, attributes);
    156156    return pass();
    157157  }
    158158  function attvalue(type) {
    159     if (type == "xml-word" && Kludges.allowUnquoted) {setStyle = "xml-attribute"; return cont();}
    160     if (type == "xml-attribute") return cont();
     159    if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
     160    if (type == "string") return cont();
    161161    return pass();
    162162  }
  • _plugins_/skeleditor/trunk/spip_210/codemirror/oldrelease.html

    r46386 r48687  
    33  <head>
    44    <title>CodeMirror</title>
     5    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
    56    <link rel="stylesheet" type="text/css" href="css/docs.css"/>
    67    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     
    1516
    1617</pre>
     18
     19  <p class="rel">19-01-2011: <a href="http://codemirror.net/codemirror-0.93.zip">Version 0.93</a>:</p>
     20  <ul class="rel-note">
     21    <li>Added a <a href="contrib/regex/index.html">Regular Expression</a> parser.</li>
     22    <li>Fixes to the PHP parser.</li>
     23    <li>Support for regular expression in search/replace.</li>
     24    <li>Add <code>save</code> method to instances created with <code>fromTextArea</code>.</li>
     25    <li>Add support for MS T-SQL in the SQL parser.</li>
     26    <li>Support use of CSS classes for highlighting brackets.</li>
     27    <li>Fix yet another hang with line-numbering in hidden editors.</li>
     28  </ul>
     29
     30  <p class="rel">17-12-2010: <a href="http://codemirror.net/codemirror-0.92.zip">Version 0.92</a>:</p>
     31  <ul class="rel-note">
     32    <li>Make CodeMirror work in XHTML documents.</li>
     33    <li>Fix bug in handling of backslashes in Python strings.</li>
     34    <li>The <code>styleNumbers</code> option is now officially
     35    supported and documented.</li>
     36    <li><code>onLineNumberClick</code> option added.</li>
     37    <li>More consistent names <code>onLoad</code> and
     38    <code>onCursorActivity</code> callbacks. Old names still work, but
     39    are deprecated.</li>
     40    <li>Add a <a href="contrib/freemarker/index.html">Freemarker</a> mode.</li>
     41  </ul>
     42
     43  <p class="rel">11-11-2010: <a
     44  href="http://codemirror.net/codemirror-0.91.zip">Version 0.91</a>:</p>
     45  <ul class="rel-note">
     46    <li>Adds support for <a href="contrib/java">Java</a>.</li>
     47    <li>Small additions to the <a href="contrib/php">PHP</a> and <a href="contrib/sql">SQL</a> parsers.</li>
     48    <li>Work around various <a href="https://bugs.webkit.org/show_bug.cgi?id=47806">Webkit</a> <a href="https://bugs.webkit.org/show_bug.cgi?id=23474">issues</a>.</li>
     49    <li>Fix <code>toTextArea</code> to update the code in the textarea.</li>
     50    <li>Add a <code>noScriptCaching</code> option (hack to ease development).</li>
     51    <li>Make sub-modes of <a href="mixedtest.html">HTML mixed</a> mode configurable.</li>
     52  </ul>
    1753
    1854  <p class="rel">02-10-2010: <a
     
    112148instead of lines-based (see the <code>passTime</code> option).</p>
    113149
    114   <script type="text/javascript" src="css/font.js"></script>
    115 
    116150</body></html>
  • _plugins_/skeleditor/trunk/spip_210/codemirror/test/index.html

    r46386 r48687  
    55    <link rel="stylesheet" href="../lib/codemirror.css">
    66    <script src="../lib/codemirror.js"></script>
    7     <link rel="stylesheet" href="../mode/javascript/javascript.css">
     7    <link rel="stylesheet" href="../theme/default.css">
    88    <script src="../mode/javascript/javascript.js"></script>
    99
    10     <link rel="stylesheet" href="../docs.css">
    1110    <style type="text/css">
    1211      .ok {color: #0e0;}
  • _plugins_/skeleditor/trunk/spip_210/codemirror/test/test.js

    r46386 r48687  
    117117
    118118testCM("coords", function(cm) {
    119   cm.getWrapperElement().style.height = "100px";
     119  var scroller = cm.getWrapperElement().getElementsByClassName("CodeMirror-scroll")[0];
     120  scroller.style.height = "100px";
    120121  var content = [];
    121122  for (var i = 0; i < 200; ++i) content.push("------------------------------" + i);
     
    126127  is(top.y < bot.y);
    127128  is(top.y < top.yBot);
    128   cm.getWrapperElement().scrollTop = 100;
     129  scroller.scrollTop = 100;
    129130  cm.refresh();
    130131  var top2 = cm.charCoords({line: 0, ch: 0});
    131132  is(top.y > top2.y);
    132133  eq(top.x, top2.x);
     134});
     135
     136testCM("coordsChar", function(cm) {
     137  var content = [];
     138  for (var i = 0; i < 70; ++i) content.push("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
     139  cm.setValue(content.join("\n"));
     140  for (var x = 0; x < 35; x += 2) {
     141    for (var y = 0; y < 70; y += 5) {
     142      cm.setCursor(y, x);
     143      var pos = cm.coordsChar(cm.charCoords({line: y, ch: x}));
     144      eq(pos.line, y);
     145      eq(pos.ch, x);
     146    }
     147  }
    133148});
    134149
  • _plugins_/skeleditor/trunk/spip_210/skeleditor_pipelines.php

    r47088 r48687  
    7171        $files .= "
    7272        <link rel='stylesheet' href='".$dir."codemirror/lib/codemirror.css' type='text/css' />
     73        <link rel='stylesheet' href='".$dir."codemirror/theme/default.css' type='text/css' />
    7374        <link rel='stylesheet' href='".$dir."css/skeleditor.css' type='text/css' />";   
    7475        }
Note: See TracChangeset for help on using the changeset viewer.