Plugin Directory

Changeset 212751


Ignore:
Timestamp:
03/04/2010 12:42:36 AM (16 years ago)
Author:
mayel2b
Message:

new CodeMirror engine

Location:
power-code-editor/trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • power-code-editor/trunk/css/csscolors.css

    r179914 r212751  
     1html {
     2  cursor: text;
     3}
     4
    15.editbox {
    26  margin: .4em;
  • power-code-editor/trunk/css/jscolors.css

    r179914 r212751  
     1html {
     2  cursor: text;
     3}
     4
    15.editbox {
    26  margin: .4em;
  • power-code-editor/trunk/css/phpcolors.css

    r179914 r212751  
    66@author Dan Vlad Dascalescu <[email protected]>
    77*/
     8
     9html {
     10  cursor: text;
     11}
    812
    913.editbox {
  • power-code-editor/trunk/css/xmlcolors.css

    r179914 r212751  
     1html {
     2  cursor: text;
     3}
     4
    15.editbox {
    26  margin: .4em;
     
    4448
    4549span.xml-error {
    46   color: #F00;
     50 color: #F00 !important;
    4751}
    4852
  • power-code-editor/trunk/js/codemirror.js

    r179914 r212751  
    207207    lineContent: function(line) {return this.editor.lineContent(line);},
    208208    setLineContent: function(line, content) {this.editor.setLineContent(line, content);},
     209    removeLine: function(line){this.editor.removeLine(line);},
    209210    insertIntoLine: function(line, position, content) {this.editor.insertIntoLine(line, position, content);},
    210211    selectLines: function(startLine, startOffset, endLine, endOffset) {
     
    242243
    243244      function sizeBar() {
     245        if (frame.offsetWidth == 0) return;
    244246        for (var root = frame; root.parentNode; root = root.parentNode);
    245247        if (!nums.parentNode || root != document || !win.Editor) {
     
    261263      var clear = function(){};
    262264      sizeBar();
    263       sizeInterval = setInterval(sizeBar, 500);
     265      var sizeInterval = setInterval(sizeBar, 500);
    264266
    265267      function nonWrapping() {
     
    276278            onResize = win.addEventHandler(win, "resize", update, true);
    277279        clear = function(){onScroll(); onResize();};
     280        update();
    278281      }
    279282      function wrapping() {
     
    320323        function update() {
    321324          if (pending) clearTimeout(pending);
    322           start();
     325          if (self.editor.allClean()) start();
     326          else pending = setTimeout(update, 200);
    323327        }
    324328        self.updateNumbers = update;
  • power-code-editor/trunk/js/editor.js

    r179914 r212751  
    44 * plain sequences of <span> and <br> elements
    55 */
     6
     7var internetExplorer = document.selection && window.ActiveXObject && /MSIE/.test(navigator.userAgent);
     8var webkit = /AppleWebKit/.test(navigator.userAgent);
     9var safari = /Apple Computers, Inc/.test(navigator.vendor);
     10var gecko = /gecko\/(\d{8})/i.test(navigator.userAgent);
    611
    712// Make sure a string does not contain two consecutive 'collapseable'
     
    107112  // continuation-passing style in this iterator.
    108113  function traverseDOM(start){
    109     function yield(value, c){cc = c; return value;}
     114    function _yield(value, c){cc = c; return value;}
    110115    function push(fun, arg, c){return function(){return fun(arg, c);};}
    111116    function stop(){cc = stop; throw StopIteration;};
     
    163168        toYield.push(insertPart(part));
    164169      });
    165       return yield(toYield.join(""), c);
     170      return _yield(toYield.join(""), c);
    166171    }
    167172
     
    186191        nodeQueue.push(node);
    187192        afterBR = false;
    188         return yield(node.currentText, c);
     193        return _yield(node.currentText, c);
    189194      }
    190195      else if (isBR(node)) {
     
    193198        nodeQueue.push(node);
    194199        afterBR = true;
    195         return yield("\n", c);
     200        return _yield("\n", c);
    196201      }
    197202      else {
     
    285290        var line = self.history.nodeAfter(self.line);
    286291        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])
    289294            return false;
    290295          line = self.history.nodeAfter(line);
     
    381386
    382387    this.dirty = [];
    383     if (options.content)
    384       this.importCode(options.content);
     388    this.importCode(options.content || "");
    385389    this.history.onChange = options.onChange;
    386390
     
    425429      addEventHandler(document.body, "cut", cursorActivity);
    426430
     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
    427436      addEventHandler(document.body, "paste", function(event) {
    428437        cursorActivity();
     
    436445          event.stop();
    437446          self.replaceSelection(text);
    438           select.scrollToCursor(this.container);
     447          select.scrollToCursor(self.container);
    439448        }
    440449      });
     
    518527
    519528    lineContent: function(line) {
    520       this.checkLine(line);
    521529      var accum = [];
    522530      for (line = line ? line.nextSibling : this.container.firstChild;
     
    531539                        {node: line, offset: this.history.textAfter(line).length},
    532540                        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      }
    533553      this.addDirtyNode(line);
    534554      this.scheduleHighlight();
     
    606626      te.style.width = "10px";
    607627      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);
    609630      parent.focus();
    610631      te.focus();
     
    845866      var pos = select.selectionTopNode(this.container, true);
    846867      var to = select.selectionTopNode(this.container, false);
    847       if (pos === false || to === false) return;
     868      if (pos === false || to === false) return false;
    848869
    849870      select.markSelection(this.win);
     
    963984      // abort, parse them, and re-try.
    964985      function tryFindMatch() {
    965         var stack = [], ch, ok = true;;
     986        var stack = [], ch, ok = true;
    966987        for (var runner = cursor; runner; runner = dir ? runner.nextSibling : runner.previousSibling) {
    967988          if (runner.className == className && isSpan(runner) && (ch = paren(runner))) {
     
    10301051      var current = (start = startOfLine(start)), before = start && startOfLine(start.previousSibling);
    10311052      if (!isBR(end)) end = endOfLine(end, this.container);
     1053      this.addDirtyNode(start);
    10321054
    10331055      do {
     
    10441066    // sure a highlight pass is scheduled.
    10451067    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
    10461075      if (internetExplorer) {
    10471076        this.container.createTextRange().execCommand("unlink");
     
    10801109        node.dirty = true;
    10811110      this.dirty.push(node);
     1111    },
     1112
     1113    allClean: function() {
     1114      return !this.dirty.length;
    10821115    },
    10831116
     
    11211154      // Prevent FF from raising an error when it is firing timeouts
    11221155      // on a page that's no longer loaded.
    1123       if (!window.select) return;
     1156      if (!window.select) return false;
    11241157
    11251158      if (!this.options.readOnly) select.markSelection(this.win);
     
    11841217
    11851218      if (!container.firstChild)
    1186         return;
     1219        return false;
    11871220      // Backtrack to the first node before from that has a partial
    11881221      // parse stored.
     
    11941227      // If we are at the end of the document, do nothing.
    11951228      if (from && !from.nextSibling)
    1196         return;
     1229        return false;
    11971230
    11981231      // Check whether a part (<span> node) and the corresponding token
     
    13901423addEventHandler(window, "load", function() {
    13911424  var CodeMirror = window.frameElement.CodeMirror;
    1392   CodeMirror.editor = new Editor(CodeMirror.options);
     1425  var e = CodeMirror.editor = new Editor(CodeMirror.options);
    13931426  this.parent.setTimeout(method(CodeMirror, "init"), 0);
    13941427});
  • power-code-editor/trunk/js/highlight.js

    r179914 r212751  
    3535
    3636  window.highlightText = function(string, callback, parser) {
    37     var parser = (parser || Editor.Parser).make(stringStream(normaliseString(string)));
     37    parser = (parser || Editor.Parser).make(stringStream(normaliseString(string)));
    3838    var line = [];
    3939    if (callback.nodeType == 1) {
  • power-code-editor/trunk/js/parsejavascript.js

    r179914 r212751  
    286286        else if (type == end) cont();
    287287        else cont(expect(end));
    288       };
     288      }
    289289      return function commaSeparated(type) {
    290290        if (type == end) cont();
  • power-code-editor/trunk/js/parsephp.js

    r179914 r212751  
    4848    return -1;
    4949  };
    50 };
     50}
    5151
    5252
     
    7272    this.prev = prev;
    7373    this.info = info;
    74   };
     74  }
    7575
    7676  // PHP indentation rules
     
    9090        return lexical.indented + (closing ? 0 : indentUnit);
    9191    };
    92   };
     92  }
    9393
    9494  // The parser-iterator-producing function itself.
     
    334334      function proceed(token) {
    335335        if (token.type == ",") cont(what, proceed);
    336       };
     336      }
    337337      return function commaSeparated() {
    338338        pass(what, proceed);
  • power-code-editor/trunk/js/parsexml.js

    r179914 r212751  
    126126  // shared code than I'd like), but it is quite a bit simpler.
    127127  function parseXML(source) {
    128     var tokens = tokenizeXML(source);
     128    var tokens = tokenizeXML(source), token;
    129129    var cc = [base];
    130130    var tokenNr = 0, indented = 0;
    131131    var currentTag = null, context = null;
    132     var consume, marked;
     132    var consume;
    133133   
    134134    function push(fs) {
     
    145145    }
    146146
    147     function mark(style) {
    148       marked = style;
     147    function markErr() {
     148      token.style += " xml-error";
    149149    }
    150150    function expect(text) {
    151151      return function(style, content) {
    152152        if (content == text) cont();
    153         else mark("xml-error") || cont(arguments.callee);
     153        else {markErr(); cont(arguments.callee);}
    154154      };
    155155    }
     
    193193      }
    194194      else if (harmlessTokens.hasOwnProperty(style)) cont();
    195       else mark("xml-error") || cont();
     195      else {markErr(); cont();}
    196196    }
    197197    function tagname(style, content) {
    198198      if (style == "xml-name") {
    199199        currentTag = content.toLowerCase();
    200         mark("xml-tagname");
     200        token.style = "xml-tagname";
    201201        cont();
    202202      }
     
    207207    }
    208208    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();
    215213      }
    216214      cont();
     
    219217      return function(style, content) {
    220218        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);}
    223221      };
    224222    }
    225223    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);}
    227225      else pass();
    228226    }
     
    241239
    242240      next: function(){
    243         var token = tokens.next();
     241        token = tokens.next();
    244242        if (token.style == "whitespace" && tokenNr == 0)
    245243          indented = token.value.length;
     
    255253
    256254        while(true){
    257           consume = marked = false;
     255          consume = false;
    258256          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;
    264258        }
    265259      },
  • power-code-editor/trunk/js/select.js

    r179914 r212751  
    414414    select.selectMarked = function () {
    415415      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;
    417425      var win = cs.window, range = win.document.createRange();
    418426
     
    441449      selection.removeAllRanges();
    442450      selection.addRange(range);
    443     };
     451    }
    444452    function selectionRange(window) {
    445453      var selection = window.getSelection();
     
    563571
    564572      function setPoint(node, offset, side) {
     573        if (offset == 0 && node && !node.nextSibling) {
     574          range["set" + side + "After"](node);
     575          return true;
     576        }
     577
    565578        if (!node)
    566579          node = container.firstChild;
     
    568581          node = node.nextSibling;
    569582
    570         if (!node)
    571           return;
     583        if (!node) return;
    572584
    573585        if (offset == 0) {
  • power-code-editor/trunk/js/stringstream.js

    r179914 r212751  
    1515// This is applied to the result of traverseDOM (see codemirror.js),
    1616// and the resulting stream is fed to the parser.
    17 window.stringStream = function(source){
     17var stringStream = function(source){
    1818  // String that's currently being iterated over.
    1919  var current = "";
  • power-code-editor/trunk/js/tokenizejavascript.js

    r179914 r212751  
    66  function nextUntilUnescaped(source, end) {
    77    var escaped = false;
    8     var next;
    98    while (!source.endOfLine()) {
    109      var next = source.next();
  • power-code-editor/trunk/js/tokenizephp.js

    r179914 r212751  
    829829    function nextUntilUnescaped(source, end) {
    830830      var escaped = false;
    831       var next;
    832831      while(!source.endOfLine()){
    833832        var next = source.next();
  • power-code-editor/trunk/js/util.js

    r179914 r212751  
    11/* 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);
    62
    73// Capture a method on an object.
  • power-code-editor/trunk/power-code-editor.php

    r179939 r212751  
    55Description: 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.
    66Author: Mayel de Borniol
    7 Version: 1.0
     7Version: 1.2
    88Author URI: http://anetech.eu/
    99*/
     
    2525 
    2626  function add_pwe(){
    27     $url = plugin_dir_url(__FILE__);
     27    $url = plugins_url()."/power-code-editor/";
    2828    echo <<<DATA
    29 <!-- Power Code Editor Plugin -->
     29<!-- START Power Code Editor Plugin -->
    3030<script type="text/javascript" src="{$url}js/codemirror.js"></script>
    3131<script type="text/javascript">
     
    6262      parserfile: pwe_parserfile,
    6363       stylesheet: pwe_stylesheet,
    64        width: "97%",
     64       width: "95%",
    6565       height: "500px",
    6666      path: "{$url}js/"
     
    7070/* ]]> */
    7171</script>
    72 <!-- // Power Code Editor Plugin -->
     72<!-- // END Power Code Editor Plugin -->
    7373DATA;
    7474  }
  • power-code-editor/trunk/readme.txt

    r179940 r212751  
    22Plugin URI: http://anetech.eu/power-code-editor/
    33Contributors: Mayel de Borniol
    4 Author URI: http://anetech.eu
     4Author URI: http://deborniol.com/
    55Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=10234087
    6 Version: 1.0
    7 Stable tag: 1.0
    8 Tested up to: 2.8.6
    9 Requires at least: 2.1
     6Version: 1.2
     7Stable tag: 1.2
     8Tested up to: 2.9.2
     9Requires at least: 2.6
    1010Tags: 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
    1111
     
    2121
    2222At this time, the following browsers are supported:
    23 - Firefox 1.5 or higher
    24 - Internet Explorer 6 or higher
    25 - Safari 3 or higher
    26 - Opera 9.52 or higher
    27 - Chrome
     23* Firefox 1.5 or higher
     24* Internet Explorer 6 or higher
     25* Safari 3 or higher
     26* Opera 9.52 or higher
     27* Chrome
    2828
    2929Licensed under the GNU GPL v2.
     
    3939And here is how to install it manually :
    40401. Extract the zip file power-code-editor-X.zip
    41 1. Upload folder 'power-code-editor' to the '/wp-content/plugins/' directory
    42 1. Activate the plugin through the 'Plugins' menu in WordPress
     412. Upload folder 'power-code-editor' to the '/wp-content/plugins/' directory
     423. Activate the plugin through the 'Plugins' menu in WordPress
    4343
    4444== Changelog ==
     
    4646= 1.0 - 2009-12-03 =
    4747* 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)
    4852
    4953== Screenshots ==
Note: See TracChangeset for help on using the changeset viewer.