Changeset 212751
- Timestamp:
- 03/04/2010 12:42:36 AM (16 years ago)
- Location:
- power-code-editor/trunk
- Files:
-
- 2 added
- 17 edited
-
css/csscolors.css (modified) (1 diff)
-
css/jscolors.css (modified) (1 diff)
-
css/phpcolors.css (modified) (1 diff)
-
css/xmlcolors.css (modified) (2 diffs)
-
js/LICENSE_PHP (added)
-
js/codemirror.js (modified) (5 diffs)
-
js/editor.js (modified) (21 diffs)
-
js/highlight.js (modified) (1 diff)
-
js/parsejavascript.js (modified) (1 diff)
-
js/parsephp.js (modified) (4 diffs)
-
js/parsesparql.js (added)
-
js/parsexml.js (modified) (7 diffs)
-
js/select.js (modified) (4 diffs)
-
js/stringstream.js (modified) (1 diff)
-
js/tokenizejavascript.js (modified) (1 diff)
-
js/tokenizephp.js (modified) (1 diff)
-
js/util.js (modified) (1 diff)
-
power-code-editor.php (modified) (4 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
power-code-editor/trunk/css/csscolors.css
r179914 r212751 1 html { 2 cursor: text; 3 } 4 1 5 .editbox { 2 6 margin: .4em; -
power-code-editor/trunk/css/jscolors.css
r179914 r212751 1 html { 2 cursor: text; 3 } 4 1 5 .editbox { 2 6 margin: .4em; -
power-code-editor/trunk/css/phpcolors.css
r179914 r212751 6 6 @author Dan Vlad Dascalescu <[email protected]> 7 7 */ 8 9 html { 10 cursor: text; 11 } 8 12 9 13 .editbox { -
power-code-editor/trunk/css/xmlcolors.css
r179914 r212751 1 html { 2 cursor: text; 3 } 4 1 5 .editbox { 2 6 margin: .4em; … … 44 48 45 49 span.xml-error { 46 color: #F00;50 color: #F00 !important; 47 51 } 48 52 -
power-code-editor/trunk/js/codemirror.js
r179914 r212751 207 207 lineContent: function(line) {return this.editor.lineContent(line);}, 208 208 setLineContent: function(line, content) {this.editor.setLineContent(line, content);}, 209 removeLine: function(line){this.editor.removeLine(line);}, 209 210 insertIntoLine: function(line, position, content) {this.editor.insertIntoLine(line, position, content);}, 210 211 selectLines: function(startLine, startOffset, endLine, endOffset) { … … 242 243 243 244 function sizeBar() { 245 if (frame.offsetWidth == 0) return; 244 246 for (var root = frame; root.parentNode; root = root.parentNode); 245 247 if (!nums.parentNode || root != document || !win.Editor) { … … 261 263 var clear = function(){}; 262 264 sizeBar(); 263 sizeInterval = setInterval(sizeBar, 500);265 var sizeInterval = setInterval(sizeBar, 500); 264 266 265 267 function nonWrapping() { … … 276 278 onResize = win.addEventHandler(win, "resize", update, true); 277 279 clear = function(){onScroll(); onResize();}; 280 update(); 278 281 } 279 282 function wrapping() { … … 320 323 function update() { 321 324 if (pending) clearTimeout(pending); 322 start(); 325 if (self.editor.allClean()) start(); 326 else pending = setTimeout(update, 200); 323 327 } 324 328 self.updateNumbers = update; -
power-code-editor/trunk/js/editor.js
r179914 r212751 4 4 * plain sequences of <span> and <br> elements 5 5 */ 6 7 var internetExplorer = document.selection && window.ActiveXObject && /MSIE/.test(navigator.userAgent); 8 var webkit = /AppleWebKit/.test(navigator.userAgent); 9 var safari = /Apple Computers, Inc/.test(navigator.vendor); 10 var gecko = /gecko\/(\d{8})/i.test(navigator.userAgent); 6 11 7 12 // Make sure a string does not contain two consecutive 'collapseable' … … 107 112 // continuation-passing style in this iterator. 108 113 function traverseDOM(start){ 109 function yield(value, c){cc = c; return value;}114 function _yield(value, c){cc = c; return value;} 110 115 function push(fun, arg, c){return function(){return fun(arg, c);};} 111 116 function stop(){cc = stop; throw StopIteration;}; … … 163 168 toYield.push(insertPart(part)); 164 169 }); 165 return yield(toYield.join(""), c);170 return _yield(toYield.join(""), c); 166 171 } 167 172 … … 186 191 nodeQueue.push(node); 187 192 afterBR = false; 188 return yield(node.currentText, c);193 return _yield(node.currentText, c); 189 194 } 190 195 else if (isBR(node)) { … … 193 198 nodeQueue.push(node); 194 199 afterBR = true; 195 return yield("\n", c);200 return _yield("\n", c); 196 201 } 197 202 else { … … 285 290 var line = self.history.nodeAfter(self.line); 286 291 for (var i = 1; i < target.length - 1; i++) { 287 var line = cleanText(self.history.textAfter(line));288 if ((self.caseFold ? line .toLowerCase() : line) != target[i])292 var lineText = cleanText(self.history.textAfter(line)); 293 if ((self.caseFold ? lineText.toLowerCase() : lineText) != target[i]) 289 294 return false; 290 295 line = self.history.nodeAfter(line); … … 381 386 382 387 this.dirty = []; 383 if (options.content) 384 this.importCode(options.content); 388 this.importCode(options.content || ""); 385 389 this.history.onChange = options.onChange; 386 390 … … 425 429 addEventHandler(document.body, "cut", cursorActivity); 426 430 431 // workaround for a gecko bug [?] where going forward and then 432 // back again breaks designmode (no more cursor) 433 if (gecko) 434 addEventHandler(this.win, "pagehide", function(){self.unloaded = true;}); 435 427 436 addEventHandler(document.body, "paste", function(event) { 428 437 cursorActivity(); … … 436 445 event.stop(); 437 446 self.replaceSelection(text); 438 select.scrollToCursor( this.container);447 select.scrollToCursor(self.container); 439 448 } 440 449 }); … … 518 527 519 528 lineContent: function(line) { 520 this.checkLine(line);521 529 var accum = []; 522 530 for (line = line ? line.nextSibling : this.container.firstChild; … … 531 539 {node: line, offset: this.history.textAfter(line).length}, 532 540 content); 541 this.addDirtyNode(line); 542 this.scheduleHighlight(); 543 }, 544 545 removeLine: function(line) { 546 var node = line ? line.nextSibling : this.container.firstChild; 547 while (node) { 548 var next = node.nextSibling; 549 removeElement(node); 550 if (isBR(node)) break; 551 node = next; 552 } 533 553 this.addDirtyNode(line); 534 554 this.scheduleHighlight(); … … 606 626 te.style.width = "10px"; 607 627 te.style.top = nodeTop(frameElement) + "px"; 608 window.frameElement.CodeMirror.wrapping.appendChild(te); 628 var wrap = window.frameElement.CodeMirror.wrapping; 629 wrap.parentNode.insertBefore(te, wrap); 609 630 parent.focus(); 610 631 te.focus(); … … 845 866 var pos = select.selectionTopNode(this.container, true); 846 867 var to = select.selectionTopNode(this.container, false); 847 if (pos === false || to === false) return ;868 if (pos === false || to === false) return false; 848 869 849 870 select.markSelection(this.win); … … 963 984 // abort, parse them, and re-try. 964 985 function tryFindMatch() { 965 var stack = [], ch, ok = true; ;986 var stack = [], ch, ok = true; 966 987 for (var runner = cursor; runner; runner = dir ? runner.nextSibling : runner.previousSibling) { 967 988 if (runner.className == className && isSpan(runner) && (ch = paren(runner))) { … … 1030 1051 var current = (start = startOfLine(start)), before = start && startOfLine(start.previousSibling); 1031 1052 if (!isBR(end)) end = endOfLine(end, this.container); 1053 this.addDirtyNode(start); 1032 1054 1033 1055 do { … … 1044 1066 // sure a highlight pass is scheduled. 1045 1067 cursorActivity: function(safe) { 1068 // pagehide event hack above 1069 if (this.unloaded) { 1070 this.win.document.designMode = "off"; 1071 this.win.document.designMode = "on"; 1072 this.unloaded = false; 1073 } 1074 1046 1075 if (internetExplorer) { 1047 1076 this.container.createTextRange().execCommand("unlink"); … … 1080 1109 node.dirty = true; 1081 1110 this.dirty.push(node); 1111 }, 1112 1113 allClean: function() { 1114 return !this.dirty.length; 1082 1115 }, 1083 1116 … … 1121 1154 // Prevent FF from raising an error when it is firing timeouts 1122 1155 // on a page that's no longer loaded. 1123 if (!window.select) return ;1156 if (!window.select) return false; 1124 1157 1125 1158 if (!this.options.readOnly) select.markSelection(this.win); … … 1184 1217 1185 1218 if (!container.firstChild) 1186 return ;1219 return false; 1187 1220 // Backtrack to the first node before from that has a partial 1188 1221 // parse stored. … … 1194 1227 // If we are at the end of the document, do nothing. 1195 1228 if (from && !from.nextSibling) 1196 return ;1229 return false; 1197 1230 1198 1231 // Check whether a part (<span> node) and the corresponding token … … 1390 1423 addEventHandler(window, "load", function() { 1391 1424 var CodeMirror = window.frameElement.CodeMirror; 1392 CodeMirror.editor = new Editor(CodeMirror.options);1425 var e = CodeMirror.editor = new Editor(CodeMirror.options); 1393 1426 this.parent.setTimeout(method(CodeMirror, "init"), 0); 1394 1427 }); -
power-code-editor/trunk/js/highlight.js
r179914 r212751 35 35 36 36 window.highlightText = function(string, callback, parser) { 37 varparser = (parser || Editor.Parser).make(stringStream(normaliseString(string)));37 parser = (parser || Editor.Parser).make(stringStream(normaliseString(string))); 38 38 var line = []; 39 39 if (callback.nodeType == 1) { -
power-code-editor/trunk/js/parsejavascript.js
r179914 r212751 286 286 else if (type == end) cont(); 287 287 else cont(expect(end)); 288 } ;288 } 289 289 return function commaSeparated(type) { 290 290 if (type == end) cont(); -
power-code-editor/trunk/js/parsephp.js
r179914 r212751 48 48 return -1; 49 49 }; 50 } ;50 } 51 51 52 52 … … 72 72 this.prev = prev; 73 73 this.info = info; 74 } ;74 } 75 75 76 76 // PHP indentation rules … … 90 90 return lexical.indented + (closing ? 0 : indentUnit); 91 91 }; 92 } ;92 } 93 93 94 94 // The parser-iterator-producing function itself. … … 334 334 function proceed(token) { 335 335 if (token.type == ",") cont(what, proceed); 336 } ;336 } 337 337 return function commaSeparated() { 338 338 pass(what, proceed); -
power-code-editor/trunk/js/parsexml.js
r179914 r212751 126 126 // shared code than I'd like), but it is quite a bit simpler. 127 127 function parseXML(source) { 128 var tokens = tokenizeXML(source) ;128 var tokens = tokenizeXML(source), token; 129 129 var cc = [base]; 130 130 var tokenNr = 0, indented = 0; 131 131 var currentTag = null, context = null; 132 var consume , marked;132 var consume; 133 133 134 134 function push(fs) { … … 145 145 } 146 146 147 function mark (style) {148 marked = style;147 function markErr() { 148 token.style += " xml-error"; 149 149 } 150 150 function expect(text) { 151 151 return function(style, content) { 152 152 if (content == text) cont(); 153 else mark("xml-error") || cont(arguments.callee);153 else {markErr(); cont(arguments.callee);} 154 154 }; 155 155 } … … 193 193 } 194 194 else if (harmlessTokens.hasOwnProperty(style)) cont(); 195 else mark("xml-error") || cont();195 else {markErr(); cont();} 196 196 } 197 197 function tagname(style, content) { 198 198 if (style == "xml-name") { 199 199 currentTag = content.toLowerCase(); 200 mark("xml-tagname");200 token.style = "xml-tagname"; 201 201 cont(); 202 202 } … … 207 207 } 208 208 function closetagname(style, content) { 209 if (style == "xml-name" && context && content.toLowerCase() == context.name) { 210 popContext(); 211 mark("xml-tagname"); 212 } 213 else { 214 mark("xml-error"); 209 if (style == "xml-name") { 210 token.style = "xml-tagname"; 211 if (context && content.toLowerCase() == context.name) popContext(); 212 else markErr(); 215 213 } 216 214 cont(); … … 219 217 return function(style, content) { 220 218 if (content == "/>" || (content == ">" && UseKludges.autoSelfClosers.hasOwnProperty(currentTag))) cont(); 221 else if (content == ">") pushContext(currentTag, startOfLine) || cont();222 else mark("xml-error") || cont(arguments.callee);219 else if (content == ">") {pushContext(currentTag, startOfLine); cont();} 220 else {markErr(); cont(arguments.callee);} 223 221 }; 224 222 } 225 223 function attributes(style) { 226 if (style == "xml-name") mark("xml-attname") || cont(attribute, attributes);224 if (style == "xml-name") {token.style = "xml-attname"; cont(attribute, attributes);} 227 225 else pass(); 228 226 } … … 241 239 242 240 next: function(){ 243 vartoken = tokens.next();241 token = tokens.next(); 244 242 if (token.style == "whitespace" && tokenNr == 0) 245 243 indented = token.value.length; … … 255 253 256 254 while(true){ 257 consume = marked =false;255 consume = false; 258 256 cc.pop()(token.style, token.content); 259 if (consume){ 260 if (marked) 261 token.style = marked; 262 return token; 263 } 257 if (consume) return token; 264 258 } 265 259 }, -
power-code-editor/trunk/js/select.js
r179914 r212751 414 414 select.selectMarked = function () { 415 415 var cs = currentSelection; 416 if (!(cs && (cs.changed || (webkit && cs.start.node == cs.end.node)))) return; 416 // on webkit-based browsers, it is apparently possible that the 417 // selection gets reset even when a node that is not one of the 418 // endpoints get messed with. the most common situation where 419 // this occurs is when a selection is deleted or overwitten. we 420 // check for that here. 421 function focusIssue() { 422 return cs.start.node == cs.end.node && cs.start.offset == 0 && cs.end.offset == 0; 423 } 424 if (!cs || !(cs.changed || (webkit && focusIssue()))) return; 417 425 var win = cs.window, range = win.document.createRange(); 418 426 … … 441 449 selection.removeAllRanges(); 442 450 selection.addRange(range); 443 } ;451 } 444 452 function selectionRange(window) { 445 453 var selection = window.getSelection(); … … 563 571 564 572 function setPoint(node, offset, side) { 573 if (offset == 0 && node && !node.nextSibling) { 574 range["set" + side + "After"](node); 575 return true; 576 } 577 565 578 if (!node) 566 579 node = container.firstChild; … … 568 581 node = node.nextSibling; 569 582 570 if (!node) 571 return; 583 if (!node) return; 572 584 573 585 if (offset == 0) { -
power-code-editor/trunk/js/stringstream.js
r179914 r212751 15 15 // This is applied to the result of traverseDOM (see codemirror.js), 16 16 // and the resulting stream is fed to the parser. 17 window.stringStream = function(source){17 var stringStream = function(source){ 18 18 // String that's currently being iterated over. 19 19 var current = ""; -
power-code-editor/trunk/js/tokenizejavascript.js
r179914 r212751 6 6 function nextUntilUnescaped(source, end) { 7 7 var escaped = false; 8 var next;9 8 while (!source.endOfLine()) { 10 9 var next = source.next(); -
power-code-editor/trunk/js/tokenizephp.js
r179914 r212751 829 829 function nextUntilUnescaped(source, end) { 830 830 var escaped = false; 831 var next;832 831 while(!source.endOfLine()){ 833 832 var next = source.next(); -
power-code-editor/trunk/js/util.js
r179914 r212751 1 1 /* A few useful utility functions. */ 2 3 var internetExplorer = document.selection && window.ActiveXObject && /MSIE/.test(navigator.userAgent);4 var webkit = /AppleWebKit/.test(navigator.userAgent);5 var safari = /Apple Computers, Inc/.test(navigator.vendor);6 2 7 3 // Capture a method on an object. -
power-code-editor/trunk/power-code-editor.php
r179939 r212751 5 5 Description: Helps you more effectively edit your themes or plugins using only a browser, by enabling syntax highlighting in WordPress' integrated source code editors. Supports PHP, HTML, CSS and JavaScript. 6 6 Author: Mayel de Borniol 7 Version: 1. 07 Version: 1.2 8 8 Author URI: http://anetech.eu/ 9 9 */ … … 25 25 26 26 function add_pwe(){ 27 $url = plugin _dir_url(__FILE__);27 $url = plugins_url()."/power-code-editor/"; 28 28 echo <<<DATA 29 <!-- Power Code Editor Plugin -->29 <!-- START Power Code Editor Plugin --> 30 30 <script type="text/javascript" src="{$url}js/codemirror.js"></script> 31 31 <script type="text/javascript"> … … 62 62 parserfile: pwe_parserfile, 63 63 stylesheet: pwe_stylesheet, 64 width: "9 7%",64 width: "95%", 65 65 height: "500px", 66 66 path: "{$url}js/" … … 70 70 /* ]]> */ 71 71 </script> 72 <!-- // Power Code Editor Plugin -->72 <!-- // END Power Code Editor Plugin --> 73 73 DATA; 74 74 } -
power-code-editor/trunk/readme.txt
r179940 r212751 2 2 Plugin URI: http://anetech.eu/power-code-editor/ 3 3 Contributors: Mayel de Borniol 4 Author URI: http:// anetech.eu4 Author URI: http://deborniol.com/ 5 5 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=10234087 6 Version: 1. 07 Stable tag: 1. 08 Tested up to: 2. 8.69 Requires at least: 2. 16 Version: 1.2 7 Stable tag: 1.2 8 Tested up to: 2.9.2 9 Requires at least: 2.6 10 10 Tags: wordpress, blog, coding, source code, source, code, edit, editor, php, html, js, javascript, css, syntax, highlighting, highlight, programmer, programming, developer, development, emacs, vim, admin, theme, themes, plugin, plugins, template, templates 11 11 … … 21 21 22 22 At this time, the following browsers are supported: 23 -Firefox 1.5 or higher24 -Internet Explorer 6 or higher25 -Safari 3 or higher26 -Opera 9.52 or higher27 -Chrome23 * Firefox 1.5 or higher 24 * Internet Explorer 6 or higher 25 * Safari 3 or higher 26 * Opera 9.52 or higher 27 * Chrome 28 28 29 29 Licensed under the GNU GPL v2. … … 39 39 And here is how to install it manually : 40 40 1. Extract the zip file power-code-editor-X.zip 41 1. Upload folder 'power-code-editor' to the '/wp-content/plugins/' directory42 1. Activate the plugin through the 'Plugins' menu in WordPress41 2. Upload folder 'power-code-editor' to the '/wp-content/plugins/' directory 42 3. Activate the plugin through the 'Plugins' menu in WordPress 43 43 44 44 == Changelog == … … 46 46 = 1.0 - 2009-12-03 = 47 47 * initial release 48 = 1.1 - 2009-12-19 = 49 * small fixes 50 = 1.2 - 2010-03-04 = 51 * Improved syntax parsing engine (CodeMirror 0.66) 48 52 49 53 == Screenshots ==
Note: See TracChangeset
for help on using the changeset viewer.