Changeset 48687 in spip-zone
- Timestamp:
- Jun 10, 2011, 12:54:58 PM (10 years ago)
- Location:
- _plugins_/skeleditor/trunk
- Files:
-
- 25 added
- 7 deleted
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/skeleditor/trunk/plugin.xml
r48680 r48687 1 1 <plugin> 2 <nom> <!-- Nom du plugin -->3 <multi>4 [fr]Squelette editeur5 [en]Template editor6 [it]Redattore di scheletro7 [es]Redactor esquelético8 [de]Skeleton Herausgeber9 </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é, permet d'éditer les fichiers squelettes19 [en]Edit template files in the backoffice20 [it]Nello spazio riservato, concede a redattore gli scheletri delle lime21 [es]En espacio privado, no prohibe a redactor los esqueletos de los archivos22 [de] Im privaten Raum erlaubt Herausgeber die Aktenskelette23 </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;]" >50 2 <nom>SkelEditor</nom> 51 3 <icon>spip_210/img_pack/skeleditor-32.png</icon> 52 4 <auteur>[erational->http://www.erational.org], [Cédric Morin->http://www.yterium.net]</auteur> 53 5 <licence>GNU/GPL v3</licence> 54 <version>2.5. 3</version>6 <version>2.5.4</version> 55 7 <etat>test</etat> 56 8 <description><multi> -
_plugins_/skeleditor/trunk/spip_210/codemirror/compress.html
r46386 r48687 3 3 <head> 4 4 <title>CodeMirror: Compression Helper</title> 5 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/> 5 6 <link rel="stylesheet" type="text/css" href="css/docs.css"/> 6 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> … … 17 18 <p>To optimize loading CodeMirror, especially when including a 18 19 bunch of different modes, it is recommended that you combine and 19 minify (and preferably also gzip) the scrip s. This page makes20 minify (and preferably also gzip) the scripts. This page makes 20 21 those first two steps very easy. Simply select the version and 21 22 scripts you need in the form below, and … … 26 27 <input type="hidden" id="download" name="download" value="codemirror-compressed.js"/> 27 28 <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> 29 33 <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=v2.0;f=">2.0</option> 30 34 <option value="http://marijnhaverbeke.nl/git/codemirror2?a=blob_plain;hb=beta2;f=">beta2</option> … … 34 38 <select multiple="multiple" name="code_url" style="width: 40em;" class="field" id="files"> 35 39 <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> 38 43 </optgroup> 39 44 <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> 49 59 </optgroup> 50 60 </select></p> … … 72 82 } 73 83 </script> 74 <script type="text/javascript" src="css/font.js"></script>75 84 76 85 </body> 77 86 </html> 87 -
_plugins_/skeleditor/trunk/spip_210/codemirror/css/docs.css
r46386 r48687 1 1 body { 2 font-family: Arial, sans-serif;2 font-family: Droid Sans, Arial, sans-serif; 3 3 line-height: 1.5; 4 4 max-width: 64.3em; 5 5 margin: 3em auto; 6 6 padding: 0 1em; 7 }8 body.droid {9 font-family: Droid Sans, Arial, sans-serif;10 7 } 11 8 … … 31 28 32 29 pre { 33 font-family: Courier New, monospaced;34 30 background-color: #eee; 35 31 -moz-border-radius: 6px; … … 44 40 45 41 .grey { 46 font-size: 2 em;42 font-size: 2.2em; 47 43 padding: .5em 1em; 48 44 line-height: 1.2em; -
_plugins_/skeleditor/trunk/spip_210/codemirror/demo/activeline.html
r46386 r48687 5 5 <link rel="stylesheet" href="../lib/codemirror.css"> 6 6 <script src="../lib/codemirror.js"></script> 7 <link rel="stylesheet" href="../ mode/xml/xml.css">7 <link rel="stylesheet" href="../theme/default.css"> 8 8 <script src="../mode/xml/xml.js"></script> 9 9 <link rel="stylesheet" href="../css/docs.css"> -
_plugins_/skeleditor/trunk/spip_210/codemirror/demo/complete.html
r46386 r48687 5 5 <link rel="stylesheet" href="../lib/codemirror.css"> 6 6 <script src="../lib/codemirror.js"></script> 7 <link rel="stylesheet" href="../ mode/javascript/javascript.css">7 <link rel="stylesheet" href="../theme/night.css"> 8 8 <script src="../mode/javascript/javascript.js"></script> 9 9 <link rel="stylesheet" href="../css/docs.css"> -
_plugins_/skeleditor/trunk/spip_210/codemirror/demo/complete.js
r46386 r48687 23 23 var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 24 24 lineNumbers: true, 25 theme: "night", 25 26 onKeyEvent: function(i, e) { 26 27 // Hook into ctrl-space -
_plugins_/skeleditor/trunk/spip_210/codemirror/demo/marker.html
r46386 r48687 5 5 <link rel="stylesheet" href="../lib/codemirror.css"> 6 6 <script src="../lib/codemirror.js"></script> 7 <link rel="stylesheet" href="../ mode/javascript/javascript.css">7 <link rel="stylesheet" href="../theme/default.css"> 8 8 <script src="../mode/javascript/javascript.js"></script> 9 9 <link rel="stylesheet" href="../css/docs.css"> -
_plugins_/skeleditor/trunk/spip_210/codemirror/demo/mustache.html
r46386 r48687 6 6 <script src="../lib/codemirror.js"></script> 7 7 <script src="../lib/overlay.js"></script> 8 <link rel="stylesheet" href="../ mode/xml/xml.css">8 <link rel="stylesheet" href="../theme/default.css"> 9 9 <script src="../mode/xml/xml.js"></script> 10 10 <link rel="stylesheet" href="../css/docs.css"> -
_plugins_/skeleditor/trunk/spip_210/codemirror/demo/resize.html
r46386 r48687 5 5 <link rel="stylesheet" href="../lib/codemirror.css"> 6 6 <script src="../lib/codemirror.js"></script> 7 <link rel="stylesheet" href="../ mode/css/css.css">7 <link rel="stylesheet" href="../theme/default.css"> 8 8 <script src="../mode/css/css.js"></script> 9 9 <link rel="stylesheet" href="../css/docs.css"> … … 12 12 .CodeMirror { 13 13 border: 1px solid #eee; 14 } 15 .CodeMirror-scroll { 14 16 height: auto; 17 overflow-y: hidden; 18 overflow-x: auto; 15 19 } 16 20 </style> … … 20 24 21 25 <form><textarea id="code" name="code"> 22 .CodeMirror {26 .CodeMirror-scroll { 23 27 height: auto; 28 overflow-y: hidden; 29 overflow-x: auto; 24 30 }</textarea></form> 25 31 -
_plugins_/skeleditor/trunk/spip_210/codemirror/demo/search.html
r46386 r48687 5 5 <link rel="stylesheet" href="../lib/codemirror.css"> 6 6 <script src="../lib/codemirror.js"></script> 7 <link rel="stylesheet" href="../ mode/xml/xml.css">7 <link rel="stylesheet" href="../theme/default.css"> 8 8 <script src="../mode/xml/xml.js"></script> 9 9 <link rel="stylesheet" href="../css/docs.css"> -
_plugins_/skeleditor/trunk/spip_210/codemirror/index.html
r46386 r48687 3 3 <head> 4 4 <title>CodeMirror</title> 5 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/> 5 6 <link rel="stylesheet" type="text/css" href="css/docs.css"/> 6 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> … … 29 30 version. <a href="1/index.html">CodeMirror 1</a> is still available 30 31 from here.</p> 31 32 32 33 <div class="clear"><div class="left1 blk"> 33 34 … … 39 40 <li><a href="mode/css/index.html">CSS</a></li> 40 41 <li><a href="mode/htmlmixed/index.html">HTML mixed-mode</a></li> 42 <li><a href="mode/python/index.html">Python</a></li> 41 43 <li><a href="mode/php/index.html">PHP</a></li> 42 44 <li><a href="mode/diff/index.html">diff</a></li> … … 44 46 <li><a href="mode/stex/index.html">sTeX, LaTeX</a></li> 45 47 <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> 46 52 </ul> 47 53 … … 57 63 <li><a href="demo/marker.html">Setting breakpoints</a></li> 58 64 <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> 59 67 </ul> 60 68 … … 67 75 the <a href="http://codemirror.net/codemirror.zip">latest 68 76 release</a> or the current <a 69 href="http://codemirror.net/codemirror -latest.zip">development77 href="http://codemirror.net/codemirror2-latest.zip">development 70 78 snapshot</a> as zip files. To create a custom minified script file, 71 79 you can use the <a href="compress.html">compression API</a>.</p> … … 119 127 vendors have a habit of introducing bugs all the time, so I am 120 128 relying on the community to tell me when something breaks. 121 See <a href="#support"> below</a> for information on how to contact129 See <a href="#support">here</a> for information on how to contact 122 130 me.</p> 123 131 … … 146 154 <h2>Releases:</h2> 147 155 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 148 193 <p class="rel">28-03-2011: <a href="http://codemirror.net/codemirror-2.0.zip">Version 2.0</a>:</p> 149 194 <p class="rel-note">CodeMirror 2 is a complete rewrite that's … … 174 219 CodeMirror, no longer depending on an editable frame.</p> 175 220 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 officially192 supported and documented.</li>193 <li><code>onLineNumberClick</code> option added.</li>194 <li>More consistent names <code>onLoad</code> and195 <code>onCursorActivity</code> callbacks. Old names still work, but196 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: <a201 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 211 221 <p><a href="oldrelease.html">Older releases...</a></p> 212 222 … … 220 230 </form> 221 231 222 <script type="text/javascript" src="css/font.js"></script>223 224 232 </body> 225 233 </html> 234 -
_plugins_/skeleditor/trunk/spip_210/codemirror/internals.html
r46386 r48687 1 1 <!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"> 11 22 <strong>Topic:</strong> JavaScript, code editor implementation<br> 12 23 <strong>Author:</strong> Marijn Haverbeke<br> … … 82 93 to lose its appeal.</p> 83 94 84 <h2 >General Approach</h2>95 <h2 id="approach">General Approach</h2> 85 96 86 97 <p>What CodeMirror 2 does is try to sidestep most of the hairy hacks … … 115 126 displaying things only as they are scrolled into view.)</p> 116 127 117 <h2 >Input</h2>128 <h2 id="input">Input</h2> 118 129 119 130 <p>ACE uses its hidden textarea only as a text input shim, and does … … 143 154 CodeMirror is catching those events and handling them itself.</p> 144 155 145 <h2 >Selection</h2>156 <h2 id="selection">Selection</h2> 146 157 147 158 <p>Getting and setting the selection range of a textarea in modern … … 191 202 time.</p> 192 203 193 <h2 >Intelligent Updating</h2>204 <h2 id="update">Intelligent Updating</h2> 194 205 195 206 <p>One thing that always comes up when you have a complicated internal … … 249 260 single <code>innerHTML</code> update to do the refresh.</p> 250 261 251 <h2 >Parsers can be Simple</h2>262 <h2 id="parse">Parsers can be Simple</h2> 252 263 253 264 <p>When I wrote CodeMirror 1, I … … 290 301 anymore.</p> 291 302 292 <h2 >What Gives?</h2>303 <h2 id="summary">What Gives?</h2> 293 304 294 305 <p>Given all this, what can you expect from CodeMirror 2? First, the … … 350 361 </ul> 351 362 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"> </div> 380 352 381 </body></html> -
_plugins_/skeleditor/trunk/spip_210/codemirror/lib/codemirror.css
r46386 r48687 1 1 .CodeMirror { 2 line-height: 1em; 3 font-family: monospace; 4 } 5 6 .CodeMirror-scroll { 2 7 overflow: auto; 3 8 height: 300px; 4 line-height: 1em;5 font-family: monospace;6 _position: relative; /* IE6 hack */7 9 } 8 10 … … 30 32 border-width: 0; margin: 0; padding: 0; background: transparent; 31 33 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; 32 43 } 33 44 -
_plugins_/skeleditor/trunk/spip_210/codemirror/lib/codemirror.js
r46386 r48687 14 14 options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt]; 15 15 16 // The element in which the editor lives. Takes care of scrolling17 // (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"); 19 19 wrapper.className = "CodeMirror"; 20 20 // This mess creates the base DOM structure for the editor. 21 21 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"> </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"> </pre>' + // Absolutely positioned blinky cursor 32 '<div></div>' + // This DIV contains the actual code 33 '</div></div></div></div></div>'; 33 34 if (place.appendChild) place.appendChild(wrapper); else place(wrapper); 34 35 // 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, 36 39 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; 39 42 if (options.tabindex != null) input.tabindex = options.tabindex; 40 43 if (!options.gutter && !options.lineNumbers) gutter.style.display = "none"; … … 57 60 // to get around the fact that we can't create inverted 58 61 // selections. See below. 59 var shiftSelecting, reducedSelection ;62 var shiftSelecting, reducedSelection, lastDoubleClick; 60 63 // Variables used by startOperation/endOperation to track what 61 64 // happened during the operation. … … 68 71 // marked. 69 72 var editing, bracketHighlighted; 73 // Tracks the maximum line length so that the horizontal scrollbar 74 // can be kept static when scrolling. 75 var maxLine = ""; 70 76 71 77 // Initialize the content. Somewhat hacky (delayed prepareInput) … … 75 81 76 82 // Register our event handlers. 77 connect( wrapper, "mousedown", operation(onMouseDown));83 connect(scroller, "mousedown", operation(onMouseDown)); 78 84 // Gecko browsers fire contextmenu *after* opening the menu, at 79 85 // which point we can't mess with it anymore. Context menu is 80 86 // handled in onMouseDown for Gecko. 81 if (!gecko) connect( wrapper, "contextmenu", operation(onContextMenu));87 if (!gecko) connect(scroller, "contextmenu", operation(onContextMenu)); 82 88 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);}); 84 90 connect(window, "resize", function() {updateDisplay(true);}); 85 91 connect(input, "keyup", operation(onKeyUp)); … … 89 95 connect(input, "blur", onBlur); 90 96 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();}); 95 101 connect(input, "paste", function(){fastPoll();}); 96 102 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(); 99 108 else onBlur(); 100 109 … … 110 119 getSelection: getSelection, 111 120 replaceSelection: operation(replaceSelection), 112 focus: function(){ input.focus(); onFocus(); fastPoll();},121 focus: function(){focusInput(); onFocus(); prepareInput(); fastPoll();}, 113 122 setOption: function(option, value) { 114 123 options[option] = value; 115 124 if (option == "lineNumbers" || option == "gutter") gutterChanged(); 116 125 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); 117 128 }, 118 129 getOption: function(option) {return options[option];}, … … 133 144 coordsChar: function(coords) { 134 145 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)}); 137 148 }, 138 149 getSearchCursor: function(query, pos, caseFold) {return new SearchCursor(query, pos, caseFold);}, … … 193 204 194 205 function onMouseDown(e) { 206 var ld = lastDoubleClick; lastDoubleClick = null; 195 207 // First, see if this is a click in the gutter 196 208 for (var n = e.target(); n != wrapper; n = n.parentNode) … … 207 219 // selection. 208 220 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;} 211 222 212 223 if (!focused) onFocus(); 213 224 e.stop(); 225 if (ld && +new Date - ld < 400) return selectLine(start.line); 226 227 setCursor(start.line, start.ch, true); 214 228 // And then we have to see if it's a drag event, in which case 215 229 // the dragged-over text must be selected. 216 230 function end() { 217 input.focus();231 focusInput(); 218 232 updateInput = true; 219 233 move(); up(); … … 224 238 if (!focused) onFocus(); 225 239 last = cur; 226 setSelection (start, cur);240 setSelectionUser(start, cur); 227 241 updateInput = false; 228 242 var visible = visibleLines(); … … 232 246 } 233 247 234 var move = connect( document, "mousemove", operation(function(e) {248 var move = connect(targetDocument, "mousemove", operation(function(e) { 235 249 clearTimeout(going); 236 250 e.stop(); 237 251 extend(e); 238 252 }), true); 239 var up = connect( document, "mouseup", operation(function(e) {253 var up = connect(targetDocument, "mouseup", operation(function(e) { 240 254 clearTimeout(going); 241 255 var cur = posFromMouse(e); 242 if (cur) setSelection (start, cur);256 if (cur) setSelectionUser(start, cur); 243 257 e.stop(); 244 258 end(); … … 250 264 selectWordAt(pos); 251 265 e.stop(); 266 lastDoubleClick = +new Date; 252 267 } 253 268 function onDrop(e) { … … 278 293 279 294 var code = e.e.keyCode; 295 // IE does strange things with escape. 296 if (ie && code == 27) { e.e.returnValue = false; } 280 297 // Tries to detect ctrl on non-mac, cmd on mac. 281 298 var mod = (mac ? e.e.metaKey : e.e.ctrlKey) && !e.e.altKey, anyMod = e.e.ctrlKey || e.e.altKey || e.e.metaKey; … … 286 303 287 304 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 } 289 309 if (mod && code == 65) {selectAll(); return e.stop();} // ctrl-a 290 310 if (!options.readOnly) { … … 312 332 } 313 333 function onKeyUp(e) { 334 if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e.e))) return; 314 335 if (reducedSelection) { 315 336 reducedSelection = null; … … 327 348 var code = e.e.keyCode; 328 349 // 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(); 331 352 else fastPoll(curKeyId); 332 353 } 333 354 334 355 function onFocus() { 356 if (options.readOnly == "nocursor") return; 335 357 if (!focused && options.onFocus) options.onFocus(instance); 336 358 focused = true; … … 358 380 } 359 381 updateLinesNoUndo(from, to, newText, selFrom, selTo); 382 if (newText.length < 5) 383 highlightLines(from.line, from.line + newText.length) 360 384 } 361 385 function unredoHelper(from, to) { … … 374 398 375 399 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 376 405 var nlines = to.line - from.line, firstLine = lines[from.line], lastLine = lines[to.line]; 377 406 // First adjust the line structure, taking some care to leave highlighting intact. … … 400 429 } 401 430 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 402 449 // Add these lines to the work array, so that they will be 403 450 // highlighted. Adjust work lines if lines were added/removed. … … 413 460 // Remember that these lines changed, for updating the display 414 461 changes.push({from: from.line, to: to.line + 1, diff: lendiff}); 415 textChanged = true;462 textChanged = {from: from, to: to, text: newText}; 416 463 417 464 // Update the selection … … 496 543 // content or cursor if something changed. 497 544 function readInput() { 545 if (leaveInputAlone) return; 498 546 var changed = false, text = input.value, sr = selRange(input); 499 547 if (!sr) return false; 500 548 var changed = editing.text != text, rs = reducedSelection; 501 549 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; 505 551 if (changed) { 506 552 shiftSelecting = reducedSelection = null; … … 525 571 // your selection and have the right thing happen. 526 572 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; } 534 577 } 535 578 … … 551 594 for (;;) { 552 595 c = editing.text.charAt(edend); 596 if (text.charAt(end) != c) {++end; ++edend; break;} 553 597 if (c == "\n") endline--; 554 if (text.charAt(end) != c) {++end; ++edend; break;}555 598 if (edend <= start || end <= start) break; 556 599 --end; --edend; … … 581 624 setSelRange(input, startch, reducedSelection ? startch : endch); 582 625 } 626 function focusInput() { 627 if (options.readOnly != "nocursor") input.focus(); 628 } 583 629 584 630 function scrollCursorIntoView() { … … 587 633 } 588 634 function scrollIntoView(x1, y1, x2, y2) { 589 var pl = paddingLeft(), pt = paddingTop() ;635 var pl = paddingLeft(), pt = paddingTop(), lh = lineHeight(); 590 636 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 } 597 647 else if (x2 > screenw + screenleft) { 598 wrapper.scrollLeft = x2 + 10 - screenw;648 scroller.scrollLeft = x2 + 10 - screenw; 599 649 scrolled = true; 600 650 if (x2 > code.clientWidth) result = false; … … 605 655 606 656 function visibleLines() { 607 var lh = lineHeight(), top = wrapper.scrollTop - paddingTop();657 var lh = lineHeight(), top = scroller.scrollTop - paddingTop(); 608 658 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))}; 610 660 } 611 661 // Uses a set of changes plus the current scroll position to … … 613 663 // updates. 614 664 function updateDisplay(changes) { 615 if (! wrapper.clientWidth) {665 if (!scroller.clientWidth) { 616 666 showingFrom = showingTo = 0; 617 667 return; … … 675 725 // Position the mover div to align with the lines it's supposed 676 726 // 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; 678 728 showingFrom = from; showingTo = to; 679 729 mover.style.top = (from * lineHeight()) + "px"; 680 730 if (different) { 681 lastHeight = wrapper.clientHeight;731 lastHeight = scroller.clientHeight; 682 732 code.style.height = (lines.length * lineHeight() + 2 * paddingTop()) + "px"; 683 733 updateGutter(); 684 734 } 735 736 var textWidth = stringWidth(maxLine); 737 lineSpace.style.width = textWidth > scroller.clientWidth ? textWidth + "px" : ""; 685 738 686 739 // Since this is all rather error prone, it is honoured with the … … 713 766 // whitespace. 714 767 var sfrom = sel.from.line, sto = sel.to.line, off = 0, 715 scratch = badInnerHTML && document.createElement("div");768 scratch = badInnerHTML && targetDocument.createElement("div"); 716 769 for (var i = 0, e = updates.length; i < e; ++i) { 717 770 var rec = updates[i]; … … 723 776 else if (extra) { 724 777 for (var j = Math.max(0, extra); j > 0; --j) 725 lineDiv.insertBefore( document.createElement("pre"), nodeAfter);778 lineDiv.insertBefore(targetDocument.createElement("pre"), nodeAfter); 726 779 for (var j = Math.max(0, -extra); j > 0; --j) 727 780 lineDiv.removeChild(nodeAfter ? nodeAfter.previousSibling : lineDiv.lastChild); … … 754 807 function updateGutter() { 755 808 if (!options.gutter && !options.lineNumbers) return; 756 var hText = mover.offsetHeight, hEditor = wrapper.clientHeight;809 var hText = mover.offsetHeight, hEditor = scroller.clientHeight; 757 810 gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px"; 758 811 var html = []; 759 for (var i = showingFrom; i < showingTo; ++i) {812 for (var i = showingFrom; i < Math.max(showingTo, showingFrom + 1); ++i) { 760 813 var marker = lines[i].gutterMarker; 761 814 var text = options.lineNumbers ? i + options.firstLineNumber : null; … … 770 823 var minwidth = String(lines.length).length, firstNode = gutterText.firstChild, val = eltText(firstNode), pad = ""; 771 824 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); 773 826 gutter.style.display = ""; 774 827 lineSpace.style.marginLeft = gutter.offsetWidth + "px"; 775 828 } 776 829 function updateCursor() { 777 var head = sel.inverted ? sel.from : sel.to ;778 var x = charX(head.line, head.ch) + "px", y = (head.line - showingFrom) * l ineHeight()+ "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"; 780 833 if (posEq(sel.from, sel.to)) { 781 834 cursor.style.top = y; cursor.style.left = x; … … 785 838 } 786 839 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 } 787 848 // Update the selection. Last two args are only used by 788 849 // updateLines, since they have to be expressed in the line … … 790 851 function setSelection(from, to, oldFrom, oldTo) { 791 852 if (posEq(sel.from, from) && posEq(sel.to, to)) return; 792 var sh = shiftSelecting && clipPos(shiftSelecting);793 853 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 800 855 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; 803 858 804 859 // Some ugly logic used to only mark the lines that actually did … … 830 885 selectionChanged = true; 831 886 } 832 function setCursor(line, ch ) {887 function setCursor(line, ch, user) { 833 888 var pos = clipPos({line: line, ch: ch || 0}); 834 setSelection(pos, pos);889 (user ? setSelectionUser : setSelection)(pos, pos); 835 890 } 836 891 … … 846 901 847 902 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); 850 905 } 851 906 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); 853 909 } 854 910 function selectAll() { … … 860 916 var start = pos.ch, end = pos.ch; 861 917 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}); 864 923 } 865 924 function handleEnter() { … … 925 984 lines[i].stateAfter = null; 926 985 work = [0]; 986 startWorker(); 927 987 } 928 988 function gutterChanged() { … … 983 1043 if (no == -1) return null; 984 1044 } 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 } 987 1049 return line; 988 1050 } … … 1002 1064 } 1003 1065 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 } 1004 1071 // These are used to go from pixel positions to character 1005 // positions, taking tabs into account.1072 // positions, taking varying character widths into account. 1006 1073 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; 1014 1077 } 1015 1078 function charFromX(line, x) { 1016 var text = lines[line].text, cw = charWidth();1017 1079 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 } 1033 1104 } 1034 1105 … … 1044 1115 function lineHeight() { 1045 1116 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 } 1050 1121 function paddingTop() {return lineSpace.offsetTop;} 1051 1122 function paddingLeft() {return lineSpace.offsetLeft;} 1052 1123 1053 1124 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)}); 1062 1134 } 1063 1135 function onContextMenu(e) { … … 1070 1142 input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.pageY() - 1) + 1071 1143 "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;"; 1073 1145 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); 1077 1148 leaveInputAlone = true; 1078 setTimeout(function() {1149 function rehide() { 1079 1150 if (input.value != val) operation(replaceSelection)(input.value, "end"); 1080 1151 input.style.cssText = oldCSS; … … 1082 1153 prepareInput(); 1083 1154 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 } 1085 1167 } 1086 1168 … … 1121 1203 } 1122 1204 } 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) { 1124 1206 var line = lines[i], first = i == head.line; 1125 1207 var found = scan(line, first && forward ? pos + 1 : 0, first && !forward ? pos : line.text.length); … … 1167 1249 return state; 1168 1250 } 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 } 1169 1259 function highlightWorker() { 1170 1260 var end = +new Date + options.workTime; 1261 var foundWork = work.length; 1171 1262 while (work.length) { 1172 1263 if (!lines[showingFrom].stateAfter) var task = showingFrom; … … 1177 1268 else state = startState(mode); 1178 1269 1270 var unchanged = 0; 1179 1271 for (var i = start, l = lines.length; i < l; ++i) { 1180 1272 var line = lines[i], hadState = line.stateAfter; … … 1187 1279 var changed = line.highlight(mode, state); 1188 1280 line.stateAfter = copyState(mode, state); 1189 if (hadState && !changed && line.text) break; 1281 if (changed || !hadState) unchanged = 0; 1282 else if (++unchanged > 3) break; 1190 1283 } 1191 1284 changes.push({from: task, to: i}); 1192 1285 } 1286 if (foundWork && options.onHighlightComplete) 1287 options.onHighlightComplete(instance); 1193 1288 } 1194 1289 function startWorker(time) { … … 1217 1312 prepareInput(); 1218 1313 1219 if (selectionChanged && options.onCursorActivity)1220 options.onCursorActivity(instance);1221 if (textChanged && options.onChange)1222 options.onChange(instance);1223 1314 if (selectionChanged && options.matchBrackets) 1224 1315 setTimeout(operation(function() { … … 1226 1317 matchBrackets(false); 1227 1318 }), 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); 1228 1324 } 1229 1325 var nestedOperation = 0; … … 1260 1356 if (newmatch) match = newmatch; 1261 1357 else break; 1358 start++; 1262 1359 } 1263 1360 } … … 1342 1439 }; 1343 1440 1441 for (var ext in extensions) 1442 if (extensions.propertyIsEnumerable(ext) && 1443 !instance.propertyIsEnumerable(ext)) 1444 instance[ext] = extensions[ext]; 1344 1445 return instance; 1345 1446 } // (end of function CodeMirror) … … 1349 1450 value: "", 1350 1451 mode: null, 1452 theme: "default", 1351 1453 indentUnit: 2, 1352 1454 indentWithTabs: false, … … 1362 1464 onCursorActivity: null, 1363 1465 onGutterClick: null, 1466 onHighlightComplete: null, 1364 1467 onFocus: null, onBlur: null, onScroll: null, 1365 1468 matchBrackets: false, … … 1367 1470 workDelay: 200, 1368 1471 undoDepth: 40, 1369 tabindex: null 1472 tabindex: null, 1473 document: window.document 1370 1474 }; 1371 1475 … … 1384 1488 if (typeof spec == "string") 1385 1489 var mname = spec, config = {}; 1386 else 1490 else if (spec != null) 1387 1491 var mname = spec.name, config = spec; 1388 1492 var mfactory = modes[mname]; … … 1391 1495 return CodeMirror.getMode(options, "text/plain"); 1392 1496 } 1393 return mfactory(options, config );1497 return mfactory(options, config || {}); 1394 1498 } 1395 1499 CodeMirror.listModes = function() { … … 1404 1508 if (mimeModes.propertyIsEnumerable(m)) list.push(m); 1405 1509 return list; 1510 }; 1511 1512 var extensions = {}; 1513 CodeMirror.defineExtension = function(name, func) { 1514 extensions[name] = func; 1406 1515 }; 1407 1516 … … 1518 1627 current: function(){return this.string.slice(this.start, this.pos);} 1519 1628 }; 1629 CodeMirror.StringStream = StringStream; 1520 1630 1521 1631 // Line objects. These hold state related to a line, including … … 1571 1681 // classes. 1572 1682 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); 1574 1686 while (!stream.eol()) { 1575 1687 var style = mode.token(stream, state); … … 1579 1691 st[pos-2] += substr; 1580 1692 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; 1582 1694 st[pos++] = substr; st[pos++] = style; 1695 prevWord = curWord; curWord = st[pos]; 1583 1696 } 1584 1697 // Give up when line is ridiculously long … … 1589 1702 } 1590 1703 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); 1592 1709 }, 1593 1710 // Fetch the parser token for a given character. Useful for hacks … … 1608 1725 // Produces an HTML fragment for the line, taking selection, 1609 1726 // marking, and highlighting into account. 1610 getHTML: function(sfrom, sto, includePre ) {1727 getHTML: function(sfrom, sto, includePre, endAt) { 1611 1728 var html = []; 1612 1729 if (includePre) … … 1614 1731 function span(text, style) { 1615 1732 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>"); 1617 1734 else html.push(htmlEscape(text)); 1618 1735 } 1619 1736 var st = this.styles, allText = this.text, marked = this.marked; 1620 1737 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) 1623 1742 span(" ", sfrom != null && sto == null ? "CodeMirror-selected" : null); 1624 1743 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 } 1626 1750 else { 1627 1751 var pos = 0, i = 0, text = "", style, sg = 0; … … 1633 1757 } 1634 1758 } 1635 nextMark(); 1636 while (pos < allText.length) {1637 var upto = allText.length;1759 nextMark(); 1760 while (pos < len) { 1761 var upto = len; 1638 1762 var extraStyle = ""; 1639 1763 if (sfrom != null) { … … 1741 1865 pageX: function() { 1742 1866 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; 1744 1869 }, 1745 1870 pageY: function() { 1746 1871 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; 1748 1874 } 1749 1875 }; … … 1774 1900 1775 1901 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); 1776 1904 1777 1905 var lineSep = "\n"; … … 1804 1932 1805 1933 // 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;} 1810 1946 return {left: x, top: y}; 1811 1947 } … … 1821 1957 1822 1958 function htmlEscape(str) { 1823 return str.replace(/[<&]/g, function(str) {return str == "&" ? "&" : "<";}); 1959 return str.replace(/[<>&]/g, function(str) { 1960 return str == "&" ? "&" : str == "<" ? "<" : ">"; 1961 }); 1824 1962 } 1963 CodeMirror.htmlEscape = htmlEscape; 1825 1964 1826 1965 // Used to position the cursor after an undo/redo by finding the … … 1855 1994 else 1856 1995 var splitLines = function(string){return string.split(/\r?\n/);}; 1996 CodeMirror.splitLines = splitLines; 1857 1997 1858 1998 // Sane model of finding and setting the selection in a textarea … … 1862 2002 catch(e) {return null;} 1863 2003 }; 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 }; 1868 2024 } 1869 2025 // IE model. Don't ask. 1870 2026 else { 1871 2027 var selRange = function(te) { 1872 try {var range = document.selection.createRange();}2028 try {var range = te.ownerDocument.selection.createRange();} 1873 2029 catch(e) {return null;} 1874 2030 if (!range || range.parentElement() != te) return null; -
_plugins_/skeleditor/trunk/spip_210/codemirror/manual.html
r46386 r48687 3 3 <head> 4 4 <title>CodeMirror: User Manual</title> 5 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/> 5 6 <link rel="stylesheet" type="text/css" href="css/docs.css"/> 6 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> … … 22 23 <p>CodeMirror is a code-editor component that can be embedded in 23 24 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> 27 30 28 31 <p>CodeMirror works with language-specific modes. Modes are … … 36 39 <p>The easiest way to use CodeMirror is to simply load the script 37 40 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 40 44 example:</p> 41 45 … … 43 47 <link rel="stylesheet" href="lib/codemirror.css"> 44 48 <script src="mode/javascript/javascript.js"></script> 45 <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 <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> 49 55 50 56 <pre>var myCodeMirror = CodeMirror(document.body);</pre> … … 74 80 75 81 <pre>var myCodeMirror = CodeMirror(function(elt) { 76 myTextArea.parentNode.replaceChild( myTextArea, elt);82 myTextArea.parentNode.replaceChild(elt, myTextArea); 77 83 }, {value: myTextArea.value});</pre> 78 84 … … 98 104 on your page.</p> 99 105 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> 102 114 103 115 <p>These are the supported options:</p> … … 121 133 the <code>CodeMirror.listModes</code> 122 134 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> 123 142 124 143 <dt id="option_indentUnit"><code>indentUnit (integer)</code></dt> … … 185 204 <dt id="option_readOnly"><code>readOnly (boolean)</code></dt> 186 205 <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> 188 209 189 210 <dt id="option_onChange"><code>onChange (function)</code></dt> … … 209 230 <dd>When given, will be called whenever the editor is 210 231 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> 211 237 212 238 <dt id="option_matchBrackets"><code>matchBrackets (boolean)</code></dt> … … 230 256 will be assigned.</dd> 231 257 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 232 263 <dt id="option_onKeyEvent"><code>onKeyEvent (function)</code></dt> 233 264 <dd>This provides a rather low-level hook into CodeMirror's key 234 265 handling. If provided, this function will be called on 235 every <code>keydown</code> and <code>keypress</code> event that236 CodeMirror captures. It will be passed two arguments, the editor237 instance and the key event. This key event is pretty much the238 raw key event, except that a <code>stop()</code> method is239 always added to it. You could feed it to, for240 example, <code>jQuery.Event</code> to further normalize241 it.<br>This function can inspect the key event, and handle it if242 it wants to. It may return true to tell CodeMirror to ignore the243 event. Be wary that, on some browsers, stopping244 a <code>keydown</code> does not stop the <code>keypress</code>245 from firing, whereas on others it does. If you respond to an246 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 character249 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> 250 281 </dl> 251 282 … … 267 298 <dl> 268 299 <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> 273 310 274 311 <dt id="class_CodeMirror_focused"><code>CodeMirror-focused</code></dt> … … 305 342 306 343 <dt id="class_CodeMirror_matchingbracket"><code>CodeMirror-matchingbracket</code>, 307 <code>CodeMirror- matchingbracket</code></dt>344 <code>CodeMirror-nonmatchingbracket</code></dt> 308 345 <dd>These are used to style matched (or unmatched) brackets.</dd> 309 346 </dl> … … 555 592 </dl> 556 593 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 557 600 <h2 id="modeapi">Writing CodeMirror Modes</h2> 558 601 … … 605 648 define this method. It should read one token from the stream it is 606 649 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> 609 662 610 663 <p id="StringStream">The stream object encapsulates a line of code … … 766 819 <div style="height: 2em"> </div> 767 820 768 <script type="text/javascript" src="css/font.js"></script>769 770 821 </body> 771 822 </html> -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/clike/clike.css
r46386 r48687 5 5 span.c-like-preprocessor {color: #049;} 6 6 span.c-like-var {color: #22b;} 7 span.c-like-annotation {color: #666;} -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/clike/clike.js
r46386 r48687 1 1 CodeMirror.defineMode("clike", function(config, parserConfig) { 2 2 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; 4 5 var isOperatorChar = /[+\-*&%=<>!?|]/; 5 6 … … 23 24 else if (ch == "#" && cpp && state.startOfLine) { 24 25 stream.skipToEnd(); 25 return ret("directive", " c-like-preprocessor");26 return ret("directive", "meta"); 26 27 } 27 28 else if (/\d/.test(ch)) { 28 29 stream.eatWhile(/[\w\.]/) 29 return ret("number", " c-like-number");30 return ret("number", "number"); 30 31 } 31 32 else if (ch == "/") { … … 35 36 else if (stream.eat("/")) { 36 37 stream.skipToEnd(); 37 return ret("comment", "c -like-comment");38 return ret("comment", "comment"); 38 39 } 39 40 else { … … 46 47 return ret("operator"); 47 48 } 49 else if (atAnnotations && ch == "@") { 50 stream.eatWhile(/[\w\$_]/); 51 return ret("annotation", "meta"); 52 } 48 53 else if ($vars && ch == "$") { 49 54 stream.eatWhile(/[\w\$_]/); 50 return ret("word", " c-like-var");55 return ret("word", "variable"); 51 56 } 52 57 else { 53 58 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"); 56 61 } 57 62 } … … 66 71 if (end || !(escaped || multiLineStrings)) 67 72 state.tokenize = tokenBase; 68 return ret("string", " c-like-string");73 return ret("string", "string"); 69 74 }; 70 75 } … … 79 84 maybeEnd = (ch == "*"); 80 85 } 81 return ret("comment", "c -like-comment");86 return ret("comment", "comment"); 82 87 } 83 88 … … 131 136 } 132 137 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"); 134 139 state.startOfLine = false; 135 140 return style; … … 173 178 CodeMirror.defineMIME("text/x-java", { 174 179 name: "clike", 180 atAnnotations: true, 175 181 keywords: keywords("abstract assert boolean break byte case catch char class const continue default " + 176 182 "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 6 6 <script src="../../lib/codemirror.js"></script> 7 7 <script src="clike.js"></script> 8 <link rel="stylesheet" href=" clike.css">8 <link rel="stylesheet" href="../../theme/default.css"> 9 9 <link rel="stylesheet" href="../../css/docs.css"> 10 10 <style>.CodeMirror {border: 2px inset #dee;}</style> -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/css/css.js
r46386 r48687 5 5 function tokenBase(stream, state) { 6 6 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());} 8 8 else if (ch == "/" && stream.eat("*")) { 9 9 state.tokenize = tokenCComment; … … 22 22 else if (ch == "#") { 23 23 stream.eatWhile(/\w/); 24 return ret(" css-selector", "hash");24 return ret("atom", "hash"); 25 25 } 26 26 else if (ch == "!") { 27 27 stream.match(/^\s*\w*/); 28 return ret(" css-important", "important");28 return ret("keyword", "important"); 29 29 } 30 30 else if (/\d/.test(ch)) { 31 31 stream.eatWhile(/[\w.%]/); 32 return ret(" css-unit", "unit");32 return ret("number", "unit"); 33 33 } 34 34 else if (/[,.+>*\/]/.test(ch)) { … … 40 40 else { 41 41 stream.eatWhile(/[\w\\\-_]/); 42 return ret(" css-identifier", "identifier");42 return ret("variable", "variable"); 43 43 } 44 44 } … … 53 53 maybeEnd = (ch == "*"); 54 54 } 55 return ret("c ss-comment", "comment");55 return ret("comment", "comment"); 56 56 } 57 57 … … 65 65 dashes = (ch == "-") ? dashes + 1 : 0; 66 66 } 67 return ret("c ss-comment", "comment");67 return ret("comment", "comment"); 68 68 } 69 69 … … 77 77 } 78 78 if (!escaped) state.tokenize = tokenBase; 79 return ret(" css-string", "string");79 return ret("string", "string"); 80 80 }; 81 81 } … … 93 93 94 94 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"; 99 99 } 100 100 … … 107 107 else if (type == "}") state.stack.pop(); 108 108 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"); 110 110 return style; 111 111 }, -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/css/index.html
r46386 r48687 6 6 <script src="../../lib/codemirror.js"></script> 7 7 <script src="css.js"></script> 8 <link rel="stylesheet" href=" css.css">8 <link rel="stylesheet" href="../../theme/default.css"> 9 9 <style>.CodeMirror {background: #f8f8f8;}</style> 10 10 <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 4 4 var ch = stream.next(); 5 5 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"; 9 9 } 10 10 }; -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/haskell/haskell.js
r46386 r48687 25 25 if (specialRE.test(ch)) { 26 26 if (ch == '{' && source.eat('-')) { 27 var t = " hs-comment";27 var t = "comment"; 28 28 if (source.eat('#')) { 29 t = " hs-pragma";29 t = "meta"; 30 30 } 31 31 return switchState(source, setState, ncomment(t, 1)); 32 32 } 33 return "hs-special";33 return null; 34 34 } 35 35 … … 42 42 } 43 43 if (source.eat('\'')) { 44 return " hs-char";45 } 46 return " hs-error";44 return "string"; 45 } 46 return "error"; 47 47 } 48 48 … … 54 54 source.eatWhile(idRE); 55 55 if (source.eat('.')) { 56 return " hs-qualifier";57 } 58 return " hs-conid";56 return "qualifier"; 57 } 58 return "variable-2"; 59 59 } 60 60 61 61 if (smallRE.test(ch)) { 62 62 source.eatWhile(idRE); 63 return " hs-varid";63 return "variable"; 64 64 } 65 65 … … 68 68 if (source.eat(/[xX]/)) { 69 69 source.eatWhile(hexitRE); // should require at least 1 70 return " hs-integer";70 return "integer"; 71 71 } 72 72 if (source.eat(/[oO]/)) { 73 73 source.eatWhile(octitRE); // should require at least 1 74 return " hs-integer";74 return "number"; 75 75 } 76 76 } 77 77 source.eatWhile(digitRE); 78 var t = " hs-integer";78 var t = "number"; 79 79 if (source.eat('.')) { 80 t = " hs-float";80 t = "number"; 81 81 source.eatWhile(digitRE); // should require at least 1 82 82 } 83 83 if (source.eat(/[eE]/)) { 84 t = " hs-float";84 t = "number"; 85 85 source.eat(/[-+]/); 86 86 source.eatWhile(digitRE); // should require at least 1 … … 94 94 if (!source.eat(symbolRE)) { 95 95 source.skipToEnd(); 96 return " hs-comment";97 } 98 } 99 var t = " hs-varsym";96 return "comment"; 97 } 98 } 99 var t = "variable"; 100 100 if (ch == ':') { 101 t = " hs-consym";101 t = "variable-2"; 102 102 } 103 103 source.eatWhile(symbolRE); … … 105 105 } 106 106 107 return " hs-error";107 return "error"; 108 108 } 109 109 … … 115 115 var currNest = nest; 116 116 while (!source.eol()) { 117 ch = source.next();117 var ch = source.next(); 118 118 if (ch == '{' && source.eat('-')) { 119 119 ++currNest; … … 137 137 if (ch == '"') { 138 138 setState(normal); 139 return " hs-string";139 return "string"; 140 140 } 141 141 if (ch == '\\') { 142 142 if (source.eol() || source.eat(whiteCharRE)) { 143 143 setState(stringGap); 144 return " hs-string";144 return "string"; 145 145 } 146 146 if (source.eat('&')) { … … 152 152 } 153 153 setState(normal); 154 return " hs-error";154 return "error"; 155 155 } 156 156 … … 161 161 source.next(); 162 162 setState(normal); 163 return " hs-error";163 return "error"; 164 164 } 165 165 … … 174 174 } 175 175 176 setType(" hs-reservedid")(176 setType("keyword")( 177 177 "case", "class", "data", "default", "deriving", "do", "else", "foreign", 178 178 "if", "import", "in", "infix", "infixl", "infixr", "instance", "let", 179 179 "module", "newtype", "of", "then", "type", "where", "_"); 180 180 181 setType(" hs-reservedop")(181 setType("keyword")( 182 182 "\.\.", ":", "::", "=", "\\", "\"", "<-", "->", "@", "~", "=>"); 183 183 184 setType(" hs-prelude-varsym")(184 setType("builtin")( 185 185 "!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", "=<<", 186 186 "==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "**"); 187 187 188 setType(" hs-prelude-conid")(188 setType("builtin")( 189 189 "Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq", 190 190 "False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT", … … 194 194 "String", "True"); 195 195 196 setType(" hs-prelude-varid")(196 setType("builtin")( 197 197 "abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf", 198 198 "asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling", -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/haskell/index.html
r46386 r48687 6 6 <script src="../../lib/codemirror.js"></script> 7 7 <script src="haskell.js"></script> 8 <link rel="stylesheet" href=" haskell.css">8 <link rel="stylesheet" href="../../theme/elegant.css"> 9 9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> 10 10 <link rel="stylesheet" href="../../css/docs.css"> … … 51 51 var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 52 52 lineNumbers: true, 53 matchBrackets: true 53 matchBrackets: true, 54 theme: "elegant" 54 55 }); 55 56 </script> -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/htmlmixed/htmlmixed.js
r46386 r48687 6 6 function html(stream, state) { 7 7 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) { 9 9 if (/^script$/i.test(state.htmlState.context.tagName)) { 10 10 state.token = javascript; … … 18 18 return style; 19 19 } 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 } 20 26 function javascript(stream, state) { 21 27 if (stream.match(/^<\/\s*script\s*>/i, false)) { … … 24 30 return html(stream, state); 25 31 } 26 return jsMode.token(stream, state.localState); 32 return maybeBackup(stream, /<\/\s*script\s*>/, 33 jsMode.token(stream, state.localState)); 27 34 } 28 35 function css(stream, state) { … … 32 39 return html(stream, state); 33 40 } 34 return cssMode.token(stream, state.localState); 41 return maybeBackup(stream, /<\/\s*style\s*>/, 42 cssMode.token(stream, state.localState)); 35 43 } 36 44 -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/htmlmixed/index.html
r46386 r48687 6 6 <script src="../../lib/codemirror.js"></script> 7 7 <script src="../xml/xml.js"></script> 8 <link rel="stylesheet" href="../xml/xml.css">9 8 <script src="../javascript/javascript.js"></script> 10 <link rel="stylesheet" href="../javascript/javascript.css">11 9 <script src="../css/css.js"></script> 12 <link rel="stylesheet" href="../ css/css.css">10 <link rel="stylesheet" href="../../theme/default.css"> 13 11 <script src="htmlmixed.js"></script> 14 12 <link rel="stylesheet" href="../../css/docs.css"> -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/javascript/index.html
r46386 r48687 6 6 <script src="../../lib/codemirror.js"></script> 7 7 <script src="javascript.js"></script> 8 <link rel="stylesheet" href=" javascript.css">8 <link rel="stylesheet" href="../../theme/default.css"> 9 9 <link rel="stylesheet" href="../../css/docs.css"> 10 10 <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 6 6 7 7 var keywords = function(){ 8 function kw(type) {return {type: type, style: " js-keyword"};}8 function kw(type) {return {type: type, style: "keyword"};} 9 9 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"}; 11 11 return { 12 12 "if": A, "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, … … 52 52 else if (ch == "0" && stream.eat(/x/i)) { 53 53 stream.eatWhile(/[\da-f]/i); 54 return ret("number", " js-atom");54 return ret("number", "atom"); 55 55 } 56 56 else if (/\d/.test(ch)) { 57 57 stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/); 58 return ret("number", " js-atom");58 return ret("number", "atom"); 59 59 } 60 60 else if (ch == "/") { … … 64 64 else if (stream.eat("/")) { 65 65 stream.skipToEnd(); 66 return ret("comment", " js-comment");66 return ret("comment", "comment"); 67 67 } 68 68 else if (state.reAllowed) { 69 69 nextUntilUnescaped(stream, "/"); 70 70 stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla 71 return ret("regexp", " js-string");71 return ret("regexp", "string"); 72 72 } 73 73 else { … … 84 84 var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; 85 85 return known ? ret(known.type, known.style, word) : 86 ret("variable", " js-variable", word);86 ret("variable", "variable", word); 87 87 } 88 88 } … … 92 92 if (!nextUntilUnescaped(stream, quote)) 93 93 state.tokenize = jsTokenBase; 94 return ret("string", " js-string");94 return ret("string", "string"); 95 95 }; 96 96 } … … 105 105 maybeEnd = (ch == "*"); 106 106 } 107 return ret("comment", " js-comment");107 return ret("comment", "comment"); 108 108 } 109 109 … … 141 141 cc.pop()(); 142 142 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"; 144 144 return style; 145 145 } … … 160 160 var state = cx.state; 161 161 if (state.context) { 162 cx.marked = " js-variabledef";162 cx.marked = "def"; 163 163 for (var v = state.localVars; v; v = v.next) 164 164 if (v.name == varname) return; … … 245 245 } 246 246 function property(type) { 247 if (type == "variable") {cx.marked = " js-property"; return cont();}247 if (type == "variable") {cx.marked = "property"; return cont();} 248 248 } 249 249 function objprop(type) { 250 if (type == "variable") cx.marked = " js-property";250 if (type == "variable") cx.marked = "property"; 251 251 if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression); 252 252 } -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/php/index.html
r46386 r48687 6 6 <script src="../../lib/codemirror.js"></script> 7 7 <script src="../xml/xml.js"></script> 8 <link rel="stylesheet" href="../xml/xml.css">9 8 <script src="../javascript/javascript.js"></script> 10 <link rel="stylesheet" href="../javascript/javascript.css">11 9 <script src="../css/css.js"></script> 12 <link rel="stylesheet" href="../css/css.css">13 10 <script src="../clike/clike.js"></script> 14 <link rel="stylesheet" href="../clike/clike.css">15 11 <script src="php.js"></script> 12 <link rel="stylesheet" href="../../theme/default.css"> 16 13 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> 17 14 <link rel="stylesheet" href="../../css/docs.css"> … … 48 45 JavaScript, CSS, and C-like modes.</p> 49 46 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> 51 48 </body> 52 49 </html> -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/php/php.js
r46386 r48687 10 10 "final for foreach function global goto if implements interface instanceof namespace " + 11 11 "new or private protected public static switch throw try use var while xor"); 12 var phpConfig = {name: "clike", keywords: phpKeywords, multiLineStrings: true, $vars: true}; 12 13 13 14 CodeMirror.defineMode("php", function(config, parserConfig) { … … 15 16 var jsMode = CodeMirror.getMode(config, "text/javascript"); 16 17 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); 18 19 19 20 function dispatch(stream, state) { // TODO open PHP inside text/css 20 21 if (state.curMode == htmlMode) { 21 22 var style = htmlMode.token(stream, state.curState); 22 if (style == " xml-processing" && /^<\?/.test(stream.current())) {23 if (style == "meta" && /^<\?/.test(stream.current())) { 23 24 state.curMode = phpMode; 24 25 state.curState = state.php; 25 26 state.curClose = /^\?>/; 26 27 } 27 else if (style == " xml-tag" && stream.current() == ">" && state.curState.context) {28 else if (style == "tag" && stream.current() == ">" && state.curState.context) { 28 29 if (/^script$/i.test(state.curState.context.tagName)) { 29 30 state.curMode = jsMode; … … 79 80 } 80 81 }); 82 CodeMirror.defineMIME("application/x-httpd-php", "php"); 83 CodeMirror.defineMIME("text/x-php", phpConfig); 81 84 })(); 82 83 CodeMirror.defineMIME("application/x-httpd-php", "php"); -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/stex/index.html
r46386 r48687 6 6 <script src="../../lib/codemirror.js"></script> 7 7 <script src="stex.js"></script> 8 <link rel="stylesheet" href=" stex.css">8 <link rel="stylesheet" href="../../theme/default.css"> 9 9 <style>.CodeMirror {background: #f8f8f8;}</style> 10 10 <link rel="stylesheet" href="../../css/docs.css"> -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/stex/stex.js
r46386 r48687 25 25 26 26 function applyMostPowerful(state) { 27 context = state.cmdState;27 var context = state.cmdState; 28 28 for (var i = context.length - 1; i >= 0; i--) { 29 29 var plug = context[i]; … … 32 32 return plug.styleIdentifier(); 33 33 } 34 return "stex-identifier";34 return null; 35 35 } 36 36 … … 51 51 this.openBracket = function(content) { 52 52 this.bracketNo++; 53 return " stex-bracket";53 return "bracket"; 54 54 }; 55 55 this.closeBracket = function(content) { … … 60 60 var plugins = new Array(); 61 61 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"]); 67 67 68 68 plugins["DEFAULT"] = function () { 69 69 this.name="DEFAULT"; 70 this.style=" stex-command";70 this.style="tag"; 71 71 72 72 this.styleIdentifier = function(content) { … … 84 84 function normal(source, state) { 85 85 if (source.match(/^\\[a-z]+/)) { 86 cmdName = source.current();86 var cmdName = source.current(); 87 87 cmdName = cmdName.substr(1, cmdName.length-1); 88 88 var plug = plugins[cmdName]; … … 99 99 if (ch == "%") { 100 100 setState(state, inCComment); 101 return " stex-comment";101 return "comment"; 102 102 } 103 103 else if (ch=='}' || ch==']') { … … 107 107 setState(state, beginParams); 108 108 } else 109 return " stex-error";110 return " stex-bracket";109 return "error"; 110 return "bracket"; 111 111 } else if (ch=='{' || ch=='[') { 112 112 plug = plugins["DEFAULT"]; 113 113 plug = new plug(); 114 114 pushCommand(state, plug); 115 return " stex-bracket";115 return "bracket"; 116 116 } 117 117 else if (/\d/.test(ch)) { 118 118 source.eatWhile(/[\w.%]/); 119 return " stex-unit";119 return "atom"; 120 120 } 121 121 else { … … 128 128 source.skipToEnd(); 129 129 setState(state, normal); 130 return "c ss-comment";130 return "comment"; 131 131 } 132 132 … … 134 134 var ch = source.peek(); 135 135 if (ch == '{' || ch == '[') { 136 lastPlug = peekCommand(state);137 style = lastPlug.openBracket(ch);136 var lastPlug = peekCommand(state); 137 var style = lastPlug.openBracket(ch); 138 138 source.eat(ch); 139 139 setState(state, normal); 140 return " stex-bracket";140 return "bracket"; 141 141 } 142 142 if (/[ \t\r]/.test(ch)) { -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/xml/index.html
r46386 r48687 6 6 <script src="../../lib/codemirror.js"></script> 7 7 <script src="xml.js"></script> 8 <link rel="stylesheet" href=" xml.css">8 <link rel="stylesheet" href="../../theme/default.css"> 9 9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> 10 10 <link rel="stylesheet" href="../../css/docs.css"> -
_plugins_/skeleditor/trunk/spip_210/codemirror/mode/xml/xml.js
r46386 r48687 22 22 if (stream.eat("!")) { 23 23 if (stream.eat("[")) { 24 if (stream.match(" [CDATA[")) return chain(inBlock("xml-cdata", "]]>"));24 if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>")); 25 25 else return null; 26 26 } 27 else if (stream.match("--")) return chain(inBlock(" xml-comment", "-->"));27 else if (stream.match("--")) return chain(inBlock("comment", "-->")); 28 28 else if (stream.match("DOCTYPE")) { 29 29 stream.eatWhile(/[\w\._\-]/); 30 return chain(inBlock(" xml-doctype", ">"));30 return chain(inBlock("meta", ">")); 31 31 } 32 32 else return null; … … 34 34 else if (stream.eat("?")) { 35 35 stream.eatWhile(/[\w\._\-]/); 36 state.tokenize = inBlock(" xml-processing", "?>");37 return " xml-processing";36 state.tokenize = inBlock("meta", "?>"); 37 return "meta"; 38 38 } 39 39 else { … … 44 44 while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c; 45 45 state.tokenize = inTag; 46 return " xml-tag";46 return "tag"; 47 47 } 48 48 } … … 50 50 stream.eatWhile(/[^;]/); 51 51 stream.eat(";"); 52 return " xml-entity";52 return "atom"; 53 53 } 54 54 else { … … 63 63 state.tokenize = inText; 64 64 type = ch == ">" ? "endTag" : "selfcloseTag"; 65 return " xml-tag";65 return "tag"; 66 66 } 67 67 else if (ch == "=") { … … 75 75 else { 76 76 stream.eatWhile(/[^\s\u00a0=<>\"\'\/?]/); 77 return " xml-word";77 return "word"; 78 78 } 79 79 } … … 87 87 } 88 88 } 89 return " xml-attribute";89 return "string"; 90 90 }; 91 91 } … … 130 130 if (type == "openTag") {curState.tagName = tagName; return cont(attributes, endtag(curState.startOfLine));} 131 131 else if (type == "closeTag") {popContext(); return cont(endclosetag);} 132 else if (type == " xml-cdata") {132 else if (type == "string") { 133 133 if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata"); 134 134 if (curState.tokenize == inText) popContext(); … … 152 152 153 153 function attributes(type) { 154 if (type == " xml-word") {setStyle = "xml-attname"; return cont(attributes);}154 if (type == "word") {setStyle = "attribute"; return cont(attributes);} 155 155 if (type == "equals") return cont(attvalue, attributes); 156 156 return pass(); 157 157 } 158 158 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(); 161 161 return pass(); 162 162 } -
_plugins_/skeleditor/trunk/spip_210/codemirror/oldrelease.html
r46386 r48687 3 3 <head> 4 4 <title>CodeMirror</title> 5 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/> 5 6 <link rel="stylesheet" type="text/css" href="css/docs.css"/> 6 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> … … 15 16 16 17 </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> 17 53 18 54 <p class="rel">02-10-2010: <a … … 112 148 instead of lines-based (see the <code>passTime</code> option).</p> 113 149 114 <script type="text/javascript" src="css/font.js"></script>115 116 150 </body></html> -
_plugins_/skeleditor/trunk/spip_210/codemirror/test/index.html
r46386 r48687 5 5 <link rel="stylesheet" href="../lib/codemirror.css"> 6 6 <script src="../lib/codemirror.js"></script> 7 <link rel="stylesheet" href="../ mode/javascript/javascript.css">7 <link rel="stylesheet" href="../theme/default.css"> 8 8 <script src="../mode/javascript/javascript.js"></script> 9 9 10 <link rel="stylesheet" href="../docs.css">11 10 <style type="text/css"> 12 11 .ok {color: #0e0;} -
_plugins_/skeleditor/trunk/spip_210/codemirror/test/test.js
r46386 r48687 117 117 118 118 testCM("coords", function(cm) { 119 cm.getWrapperElement().style.height = "100px"; 119 var scroller = cm.getWrapperElement().getElementsByClassName("CodeMirror-scroll")[0]; 120 scroller.style.height = "100px"; 120 121 var content = []; 121 122 for (var i = 0; i < 200; ++i) content.push("------------------------------" + i); … … 126 127 is(top.y < bot.y); 127 128 is(top.y < top.yBot); 128 cm.getWrapperElement().scrollTop = 100;129 scroller.scrollTop = 100; 129 130 cm.refresh(); 130 131 var top2 = cm.charCoords({line: 0, ch: 0}); 131 132 is(top.y > top2.y); 132 133 eq(top.x, top2.x); 134 }); 135 136 testCM("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 } 133 148 }); 134 149 -
_plugins_/skeleditor/trunk/spip_210/skeleditor_pipelines.php
r47088 r48687 71 71 $files .= " 72 72 <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' /> 73 74 <link rel='stylesheet' href='".$dir."css/skeleditor.css' type='text/css' />"; 74 75 }
Note: See TracChangeset
for help on using the changeset viewer.