Plugin Directory

Changeset 524544


Ignore:
Timestamp:
03/28/2012 12:31:03 AM (14 years ago)
Author:
redcocker
Message:

release 0.5.6.1

Location:
codemirror-for-codeeditor/trunk
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • codemirror-for-codeeditor/trunk/codemirror-for-codeeditor.php

    r512706 r524544  
    44Plugin URI: http://www.near-mint.com/blog/software/codemirror-for-codeeditor
    55Description: Just another code syntaxhighligher for the theme and plugin editor with CodeMirror. This plugin can highlight sourcecodes in theme/plugin editor and provide a useful toolbar.
    6 Version: 0.5.6
     6Version: 0.5.6.1
    77Author: redcocker
    88Author URI: http://www.near-mint.com/blog/
     
    1111*/
    1212/*
    13 Last modified: 2012/3/1
     13Last modified: 2012/3/28
    1414License: GPL v2(Except "CodeMirror" libraries)
    1515*/
     
    3838class CodeMirror_for_CodeEditor {
    3939    var $cfc_plugin_url;
    40     var $cfc_ver = "0.5.6";
     40    var $cfc_ver = "0.5.6.1";
    4141    var $cfc_db_ver = "0.5.6";
    42     var $cfc_lib_ver = "2.22";
     42    var $cfc_lib_ver = "2.23";
    4343    var $cfc_setting_opt;
    4444
     
    182182        wp_enqueue_style('codemirror-theme-elegant', $this->cfc_plugin_url.'codemirror/theme/elegant.css', false, $this->cfc_lib_ver);
    183183        wp_enqueue_style('codemirror-theme-monokai', $this->cfc_plugin_url.'codemirror/theme/monokai.css', false, $this->cfc_lib_ver);
     184        wp_enqueue_style('codemirror-theme-lesser-dark', $this->cfc_plugin_url.'codemirror/theme/lesser-dark.css', false, $this->cfc_lib_ver);
     185        wp_enqueue_style('codemirror-theme-xq-dark', $this->cfc_plugin_url.'codemirror/theme/xq-dark.css', false, $this->cfc_lib_ver);
    184186        wp_enqueue_style('codemirror-theme-neat', $this->cfc_plugin_url.'codemirror/theme/neat.css', false, $this->cfc_lib_ver);
    185187        wp_enqueue_style('codemirror-theme-night', $this->cfc_plugin_url.'codemirror/theme/night.css', false, $this->cfc_lib_ver);
     
    397399        echo 'jQuery("#newcontent").after("<div id =\"cfc-toolbar\"><label>'.__("Theme: ", "cfc_lang").'</label><select id=\"cfc-theme\" onchange=\"selectTheme(this)\">';
    398400
    399         $theme_list = array("Default", "Cobalt", "Eclipse", "Elegant", "Monokai", "Neat", "Night", "Rubyblue");
     401        $theme_list = array("Default", "Cobalt", "Eclipse", "Elegant", "Lesser-Dark", "Monokai", "Neat", "Night", "Rubyblue", "XQ-Dark");
    400402        foreach ($theme_list as $val) {
    401403            if ($val == $this->cfc_setting_opt['theme']) {
     
    589591                        <option value="eclipse" <?php if ($this->cfc_setting_opt['theme'] == "eclipse") {echo 'selected="selected"';} ?>><?php _e("Eclipse", "cfc_lang") ?></option>
    590592                        <option value="elegant" <?php if ($this->cfc_setting_opt['theme'] == "elegant") {echo 'selected="selected"';} ?>><?php _e("Elegant", "cfc_lang") ?></option>
     593                        <option value="lesser-dark" <?php if ($this->cfc_setting_opt['theme'] == "lesser-dark") {echo 'selected="selected"';} ?>><?php _e("Lesser-Dark", "cfc_lang") ?></option>
    591594                        <option value="monokai" <?php if ($this->cfc_setting_opt['theme'] == "monokai") {echo 'selected="selected"';} ?>><?php _e("Monokai", "cfc_lang") ?></option>
    592595                        <option value="neat" <?php if ($this->cfc_setting_opt['theme'] == "neat") {echo 'selected="selected"';} ?>><?php _e("Neat", "cfc_lang") ?></option>
    593596                        <option value="night" <?php if ($this->cfc_setting_opt['theme'] == "night") {echo 'selected="selected"';} ?>><?php _e("Night", "cfc_lang") ?></option>
    594597                        <option value="rubyblue" <?php if ($this->cfc_setting_opt['theme'] == "rubyblue") {echo 'selected="selected"';} ?>><?php _e("Rubyblue", "cfc_lang") ?></option>
     598                        <option value="xq-dark" <?php if ($this->cfc_setting_opt['theme'] == "xq-dark") {echo 'selected="selected"';} ?>><?php _e("XQ-Dark", "cfc_lang") ?></option>
    595599                    </select>
    596600                    <p><small><?php _e("Select a theme.<br />You can also select another theme on the editor.", "cfc_lang") ?></small></p>
  • codemirror-for-codeeditor/trunk/codemirror/lib/codemirror.css

    r512124 r524544  
    1010     is visible outside of the scrolling box. */
    1111  position: relative;
     12  outline: none;
    1213}
    1314
     
    2829.CodeMirror-lines {
    2930  padding: .4em;
     31  white-space: pre;
    3032}
    3133
  • codemirror-for-codeeditor/trunk/codemirror/lib/codemirror.js

    r512124 r524544  
    1 // CodeMirror version 2.22
     1// CodeMirror version 2.23
    22//
    33// All functions that need access to the editor's state live inside
     
    1616        options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
    1717
    18     var targetDocument = options["document"];
    1918    // The element in which the editor lives.
    20     var wrapper = targetDocument.createElement("div");
     19    var wrapper = document.createElement("div");
    2120    wrapper.className = "CodeMirror" + (options.lineWrapping ? " CodeMirror-wrap" : "");
    2221    // This mess creates the base DOM structure for the editor.
     
    4948    lineSpace.style.outline = "none";
    5049    if (options.tabindex != null) input.tabIndex = options.tabindex;
     50    if (options.autofocus) focusInput();
    5151    if (!options.gutter && !options.lineNumbers) gutter.style.display = "none";
     52    // Needed to handle Tab key in KHTML
     53    if (khtml) inputDiv.style.height = "1px", inputDiv.style.position = "absolute";
    5254
    5355    // Check for problem with IE innerHTML not working when we have a
     
    8284    // Current visible range (may be bigger than the view window).
    8385    var displayOffset = 0, showingFrom = 0, showingTo = 0, lastSizeC = 0;
    84     // bracketHighlighted is used to remember that a backet has been
     86    // bracketHighlighted is used to remember that a bracket has been
    8587    // marked.
    8688    var bracketHighlighted;
     
    8890    // can be kept static when scrolling.
    8991    var maxLine = "", maxWidth;
     92    var tabCache = {};
    9093
    9194    // Initialize the content.
     
    125128    }));
    126129
     130    // Needed to handle Tab key in KHTML
     131    if (khtml) connect(code, "mouseup", function() {
     132        if (document.activeElement == input) input.blur();
     133        focusInput();
     134    });
     135
    127136    // IE throws unspecified error in certain cases, when
    128137    // trying to access activeElement before onload
    129     var hasFocus; try { hasFocus = (targetDocument.activeElement == input); } catch(e) { }
    130     if (hasFocus) setTimeout(onFocus, 20);
     138    var hasFocus; try { hasFocus = (document.activeElement == input); } catch(e) { }
     139    if (hasFocus || options.autofocus) setTimeout(onFocus, 20);
    131140    else onBlur();
    132141
     
    179188        return getStateBefore(line + 1);
    180189      },
    181       cursorCoords: function(start){
     190      cursorCoords: function(start, mode) {
    182191        if (start == null) start = sel.inverted;
    183         return pageCoords(start ? sel.from : sel.to);
     192        return this.charCoords(start ? sel.from : sel.to, mode);
    184193      },
    185       charCoords: function(pos){return pageCoords(clipPos(pos));},
     194      charCoords: function(pos, mode) {
     195        pos = clipPos(pos);
     196        if (mode == "local") return localCoords(pos, false);
     197        if (mode == "div") return localCoords(pos, true);
     198        return pageCoords(pos);
     199      },
    186200      coordsChar: function(coords) {
    187201        var off = eltOffset(lineSpace);
     
    190204      markText: operation(markText),
    191205      setBookmark: setBookmark,
     206      findMarksAt: findMarksAt,
    192207      setMarker: operation(addGutterMarker),
    193208      clearMarker: operation(removeGutterMarker),
     
    257272      getRange: function(from, to) {return getRange(clipPos(from), clipPos(to));},
    258273
     274      triggerOnKeyDown: operation(onKeyDown),
    259275      execCommand: function(cmd) {return commands[cmd](instance);},
    260276      // Stuff used by commands, probably not much use to outside code.
     
    374390        // Let the drag handler handle this.
    375391        if (webkit) lineSpace.draggable = true;
    376         var up = connect(targetDocument, "mouseup", operation(function(e2) {
     392        var up = connect(document, "mouseup", operation(function(e2) {
    377393          if (webkit) lineSpace.draggable = false;
    378394          draggingText = false;
     
    385401        }), true);
    386402        draggingText = true;
     403        // IE's approach to draggable
     404        if (lineSpace.dragDrop) lineSpace.dragDrop();
    387405        return;
    388406      }
     
    403421      }
    404422
    405       var move = connect(targetDocument, "mousemove", operation(function(e) {
    406         clearTimeout(going);
    407         e_preventDefault(e);
    408         extend(e);
    409       }), true);
    410       var up = connect(targetDocument, "mouseup", operation(function(e) {
     423      function done(e) {
    411424        clearTimeout(going);
    412425        var cur = posFromMouse(e);
     
    416429        updateInput = true;
    417430        move(); up();
     431      }
     432      var move = connect(document, "mousemove", operation(function(e) {
     433        clearTimeout(going);
     434        e_preventDefault(e);
     435        if (!ie && !e_button(e)) done(e);
     436        else extend(e);
    418437      }), true);
     438      var up = connect(document, "mouseup", operation(done), true);
    419439    }
    420440    function onDoubleClick(e) {
     
    465485    function onDragStart(e) {
    466486      var txt = getSelection();
    467       // Disabled until further notice. Doesn't work on most browsers,
    468       // and crashes Safari (issue #332).
    469       //htmlEscape(txt);
    470       //e.dataTransfer.setDragImage(escapeElement, 0, 0);
    471487      e.dataTransfer.setData("Text", txt);
     488     
     489      // Use dummy image instead of default browsers image.
     490      if (gecko || chrome) {
     491        var img = document.createElement('img');
     492        img.scr = 'data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs='; //1x1 image
     493        e.dataTransfer.setDragImage(img, 0, 0);
     494      }
    472495    }
    473496
     
    507530      if (e_prop(e, "metaKey")) name = "Cmd-" + name;
    508531
    509       if (e_prop(e, "shiftKey"))
     532      if (e_prop(e, "shiftKey")) {
    510533        handled = lookupKey("Shift-" + name, options.extraKeys, options.keyMap,
    511                             function(b) {return doHandleBinding(b, true);});
    512       if (!handled)
     534                            function(b) {return doHandleBinding(b, true);})
     535               || lookupKey(name, options.extraKeys, options.keyMap, function(b) {
     536                 if (typeof b == "string" && /^go[A-Z]/.test(b)) return doHandleBinding(b);
     537               });
     538      } else {
    513539        handled = lookupKey(name, options.extraKeys, options.keyMap, doHandleBinding);
    514 
    515       if (handled) e_preventDefault(e);
     540      }
     541      if (handled) {
     542        e_preventDefault(e);
     543        if (ie) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
     544      }
    516545      return handled;
    517546    }
     
    546575      var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode");
    547576      if (window.opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
    548       if (window.opera && !e.which && handleKeyBinding(e)) return;
     577      if (((window.opera && !e.which) || khtml) && handleKeyBinding(e)) return;
    549578      var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
    550579      if (options.electricChars && mode.electricChars && options.smartIndent && !options.readOnly) {
     
    838867    }
    839868    function scrollIntoView(x1, y1, x2, y2) {
    840       var pl = paddingLeft(), pt = paddingTop(), lh = textHeight();
     869      var pl = paddingLeft(), pt = paddingTop();
    841870      y1 += pt; y2 += pt; x1 += pl; x2 += pl;
    842871      var screen = scroller.clientHeight, screentop = scroller.scrollTop, scrolled = false, result = true;
    843       if (y1 < screentop) {scroller.scrollTop = Math.max(0, y1 - 2*lh); scrolled = true;}
    844       else if (y2 > screentop + screen) {scroller.scrollTop = y2 + lh - screen; scrolled = true;}
     872      if (y1 < screentop) {scroller.scrollTop = Math.max(0, y1); scrolled = true;}
     873      else if (y2 > screentop + screen) {scroller.scrollTop = y2 - screen; scrolled = true;}
    845874
    846875      var screenw = scroller.clientWidth, screenleft = scroller.scrollLeft;
     
    922951                        " nodes=" + lineDiv.childNodes.length);
    923952
    924       if (options.lineWrapping) {
     953      function checkHeights() {
    925954        maxWidth = scroller.clientWidth;
    926955        var curNode = lineDiv.firstChild, heightChanged = false;
     
    937966        if (heightChanged)
    938967          code.style.height = (doc.height * th + 2 * paddingTop()) + "px";
     968        return heightChanged;
     969      }
     970
     971      if (options.lineWrapping) {
     972        checkHeights();
    939973      } else {
    940974        if (maxWidth == null) maxWidth = stringWidth(maxLine);
     
    948982        }
    949983      }
     984
    950985      gutter.style.display = gutterDisplay;
    951       if (different || gutterDirty) updateGutter();
     986      if (different || gutterDirty) {
     987        // If the gutter grew in size, re-check heights. If those changed, re-draw gutter.
     988        updateGutter() && options.lineWrapping && checkHeights() && updateGutter();
     989      }
    952990      updateSelection();
    953991      if (!suppressCallback && options.onUpdate) options.onUpdate(instance);
     
    9971035      // This pass fills in the lines that actually changed.
    9981036      var nextIntact = intact.shift(), curNode = lineDiv.firstChild, j = from;
    999       var scratch = targetDocument.createElement("div"), newElt;
     1037      var scratch = document.createElement("div");
    10001038      doc.iter(from, to, function(line) {
    10011039        if (nextIntact && nextIntact.to == j) nextIntact = intact.shift();
     
    10031041          if (line.hidden) var html = scratch.innerHTML = "<pre></pre>";
    10041042          else {
    1005             var html = '<pre>' + line.getHTML(makeTab) + '</pre>';
     1043            var html = '<pre' + (line.className ? ' class="' + line.className + '"' : '') + '>'
     1044              + line.getHTML(makeTab) + '</pre>';
    10061045            // Kludge to make sure the styled element lies behind the selection (by z-index)
    1007             if (line.className)
    1008               html = '<div style="position: relative"><pre class="' + line.className +
     1046            if (line.bgClassName)
     1047              html = '<div style="position: relative"><pre class="' + line.bgClassName +
    10091048              '" style="position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2">&#160;</pre>' + html + "</div>";
    10101049          }
     
    10221061      var hText = mover.offsetHeight, hEditor = scroller.clientHeight;
    10231062      gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px";
    1024       var html = [], i = showingFrom;
     1063      var html = [], i = showingFrom, normalNode;
    10251064      doc.iter(showingFrom, Math.max(showingTo, showingFrom + 1), function(line) {
    10261065        if (line.hidden) {
     
    10361075          for (var j = 1; j < line.height; ++j) html.push("<br/>&#160;");
    10371076          html.push("</pre>");
     1077          if (!marker) normalNode = i;
    10381078        }
    10391079        ++i;
     
    10411081      gutter.style.display = "none";
    10421082      gutterText.innerHTML = html.join("");
    1043       var minwidth = String(doc.size).length, firstNode = gutterText.firstChild, val = eltText(firstNode), pad = "";
    1044       while (val.length + pad.length < minwidth) pad += "\u00a0";
    1045       if (pad) firstNode.insertBefore(targetDocument.createTextNode(pad), firstNode.firstChild);
     1083      // Make sure scrolling doesn't cause number gutter size to pop
     1084      if (normalNode != null) {
     1085        var node = gutterText.childNodes[normalNode - showingFrom];
     1086        var minwidth = String(doc.size).length, val = eltText(node), pad = "";
     1087        while (val.length + pad.length < minwidth) pad += "\u00a0";
     1088        if (pad) node.insertBefore(document.createTextNode(pad), node.firstChild);
     1089      }
    10461090      gutter.style.display = "";
     1091      var resized = Math.abs((parseInt(lineSpace.style.marginLeft) || 0) - gutter.offsetWidth) > 2;
    10471092      lineSpace.style.marginLeft = gutter.offsetWidth + "px";
    10481093      gutterDirty = false;
     1094      return resized;
    10491095    }
    10501096    function updateSelection() {
     
    10671113            'px; top: ' + top + 'px; right: ' + right + 'px; height: ' + height + 'px"></div>';
    10681114        }
     1115        var clientWidth = lineSpace.clientWidth || lineSpace.offsetWidth;
     1116        var clientHeight = lineSpace.clientHeight || lineSpace.offsetHeight;
    10691117        if (sel.from.ch && fromPos.y >= 0) {
    1070           var right = sameLine ? lineSpace.clientWidth - toPos.x : 0;
     1118          var right = sameLine ? clientWidth - toPos.x : 0;
    10711119          add(fromPos.x, fromPos.y, right, th);
    10721120        }
    10731121        var middleStart = Math.max(0, fromPos.y + (sel.from.ch ? th : 0));
    1074         var middleHeight = Math.min(toPos.y, lineSpace.clientHeight) - middleStart;
     1122        var middleHeight = Math.min(toPos.y, clientHeight) - middleStart;
    10751123        if (middleHeight > 0.2 * th)
    10761124          add(0, middleStart, 0, middleHeight);
    1077         if ((!sameLine || !sel.from.ch) && toPos.y < lineSpace.clientHeight - .5 * th)
    1078           add(0, toPos.y, lineSpace.clientWidth - toPos.x, th);
     1125        if ((!sameLine || !sel.from.ch) && toPos.y < clientHeight - .5 * th)
     1126          add(0, toPos.y, clientWidth - toPos.x, th);
    10791127        selectionDiv.innerHTML = html;
    10801128        cursor.style.display = "none";
     
    11061154
    11071155      // Skip over hidden lines.
    1108       if (from.line != oldFrom) from = skipHidden(from, oldFrom, sel.from.ch);
     1156      if (from.line != oldFrom) {
     1157        var from1 = skipHidden(from, oldFrom, sel.from.ch);
     1158        // If there is no non-hidden line left, force visibility on current line
     1159        if (!from1) setLineHidden(from.line, false);
     1160        else from = from1;
     1161      }
    11091162      if (to.line != oldTo) to = skipHidden(to, oldTo, sel.to.ch);
    11101163
     
    11151168      if (options.autoClearEmptyLines && posEq(sel.from, sel.to)) {
    11161169        var head = sel.inverted ? from : to;
    1117         if (head.line != sel.from.line) {
     1170        if (head.line != sel.from.line && sel.from.line < doc.size) {
    11181171          var oldLine = getLine(sel.from.line);
    11191172          if (/^\s+$/.test(oldLine.text))
     
    12101263      else if (unit == "line") dist = textHeight();
    12111264      var target = coordsChar(pos.x, pos.y + dist * dir + 2);
     1265      if (unit == "page") scroller.scrollTop += localCoords(target, true).y - pos.y;
    12121266      setCursor(target.line, target.ch, true);
    12131267      goalColumn = pos.x;
     
    12961350    }
    12971351    function makeTab(col) {
    1298       var w = options.tabSize - col % options.tabSize;
     1352      var w = options.tabSize - col % options.tabSize, cached = tabCache[w];
     1353      if (cached) return cached;
    12991354      for (var str = '<span class="cm-tab">', i = 0; i < w; ++i) str += " ";
    1300       return {html: str + "</span>", width: w};
     1355      return (tabCache[w] = {html: str + "</span>", width: w});
    13011356    }
    13021357    function themeChanged() {
     
    13141369        min = Math.min(min, lineN); max = Math.max(max, lineN);
    13151370        for (var j = 0; j < mk.length; ++j)
    1316           if (mk[j].set == this.set) mk.splice(j--, 1);
     1371          if (mk[j].marker == this) mk.splice(j--, 1);
    13171372      }
    13181373      if (min != Infinity)
     
    13251380        for (var j = 0; j < mk.length; ++j) {
    13261381          var mark = mk[j];
    1327           if (mark.set == this.set) {
     1382          if (mark.marker == this) {
    13281383            if (mark.from != null || mark.to != null) {
    13291384              var found = lineNo(line);
     
    13421397      from = clipPos(from); to = clipPos(to);
    13431398      var tm = new TextMarker();
     1399      if (!posLess(from, to)) return tm;
    13441400      function add(line, from, to, className) {
    1345         getLine(line).addMark(new MarkedText(from, to, className, tm.set));
     1401        getLine(line).addMark(new MarkedText(from, to, className, tm));
    13461402      }
    13471403      if (from.line == to.line) add(from.line, from.ch, to.ch, className);
     
    13611417      getLine(pos.line).addMark(bm);
    13621418      return bm;
     1419    }
     1420
     1421    function findMarksAt(pos) {
     1422      pos = clipPos(pos);
     1423      var markers = [], marked = getLine(pos.line).marked;
     1424      if (!marked) return markers;
     1425      for (var i = 0, e = marked.length; i < e; ++i) {
     1426        var m = marked[i];
     1427        if ((m.from == null || m.from <= pos.ch) &&
     1428            (m.to == null || m.to >= pos.ch))
     1429          markers.push(m.marker || m);
     1430      }
     1431      return markers;
    13631432    }
    13641433
     
    13841453      return line;
    13851454    }
    1386     function setLineClass(handle, className) {
     1455    function setLineClass(handle, className, bgClassName) {
    13871456      return changeLine(handle, function(line) {
    1388         if (line.className != className) {
     1457        if (line.className != className || line.bgClassName != bgClassName) {
    13891458          line.className = className;
     1459          line.bgClassName = bgClassName;
    13901460          return true;
    13911461        }
     
    14011471            var from = fline == no ? skipHidden({line: fline, ch: 0}, fline, 0) : sel.from;
    14021472            var to = tline == no ? skipHidden({line: tline, ch: 0}, tline, 0) : sel.to;
     1473            // Can't hide the last visible line, we'd have no place to put the cursor
     1474            if (!to) return;
    14031475            setSelection(from, to);
    14041476          }
     
    14211493      var marker = line.gutterMarker;
    14221494      return {line: n, handle: line, text: line.text, markerText: marker && marker.text,
    1423               markerClass: marker && marker.style, lineClass: line.className};
     1495              markerClass: marker && marker.style, lineClass: line.className, bgClass: line.bgClassName};
    14241496    }
    14251497
     
    14651537      // Include extra text at the end to make sure the measured line is wrapped in the right way.
    14661538      if (options.lineWrapping) {
    1467         var end = line.text.indexOf(" ", ch + 2);
     1539        var end = line.text.indexOf(" ", ch + 6);
    14681540        extra = htmlEscape(line.text.slice(ch + 1, end < 0 ? line.text.length : end + (ie ? 5 : 0)));
    14691541      }
     
    18241896    undoDepth: 40,
    18251897    tabindex: null,
    1826     document: window.document
     1898    autofocus: null
    18271899  };
    18281900
     
    18321904
    18331905  // Known modes, by name and by MIME
    1834   var modes = {}, mimeModes = {};
     1906  var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
    18351907  CodeMirror.defineMode = function(name, mode) {
    18361908    if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
     
    18431915    if (typeof spec == "string" && mimeModes.hasOwnProperty(spec))
    18441916      spec = mimeModes[spec];
     1917    else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec))
     1918      return CodeMirror.resolveMode("application/xml");
    18451919    if (typeof spec == "string") return {name: spec};
    18461920    else return spec || {name: "null"};
     
    19272001    "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
    19282002    "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
    1929     "Delete": "delCharRight", "Backspace": "delCharLeft", "Tab": "indentMore", "Shift-Tab": "indentLess",
     2003    "Delete": "delCharRight", "Backspace": "delCharLeft", "Tab": "insertTab", "Shift-Tab": "indentAuto",
    19302004    "Enter": "newlineAndIndent", "Insert": "toggleOverwrite"
    19312005  };
     
    19382012    "Ctrl-Backspace": "delWordLeft", "Ctrl-Delete": "delWordRight", "Ctrl-S": "save", "Ctrl-F": "find",
    19392013    "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
     2014    "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
    19402015    fallthrough: "basic"
    19412016  };
     
    19462021    "Ctrl-Alt-Backspace": "delWordRight", "Alt-Delete": "delWordRight", "Cmd-S": "save", "Cmd-F": "find",
    19472022    "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
     2023    "Cmd-[": "indentLess", "Cmd-]": "indentMore",
    19482024    fallthrough: ["basic", "emacsy"]
    19492025  };
     
    19882064    if (!options.tabindex && textarea.tabindex)
    19892065      options.tabindex = textarea.tabindex;
     2066    if (options.autofocus == null && textarea.getAttribute("autofocus") != null)
     2067      options.autofocus = true;
    19902068
    19912069    function save() {textarea.value = instance.getValue();}
     
    20992177  CodeMirror.StringStream = StringStream;
    21002178
    2101   function MarkedText(from, to, className, set) {
    2102     this.from = from; this.to = to; this.style = className; this.set = set;
     2179  function MarkedText(from, to, className, marker) {
     2180    this.from = from; this.to = to; this.style = className; this.marker = marker;
    21032181  }
    21042182  MarkedText.prototype = {
    2105     attach: function(line) { this.set.push(line); },
     2183    attach: function(line) { this.marker.set.push(line); },
    21062184    detach: function(line) {
    2107       var ix = indexOf(this.set, line);
    2108       if (ix > -1) this.set.splice(ix, 1);
     2185      var ix = indexOf(this.marker.set, line);
     2186      if (ix > -1) this.marker.set.splice(ix, 1);
    21092187    },
    21102188    split: function(pos, lenBefore) {
     
    21122190      var from = this.from < pos || this.from == null ? null : this.from - pos + lenBefore;
    21132191      var to = this.to == null ? null : this.to - pos + lenBefore;
    2114       return new MarkedText(from, to, this.style, this.set);
    2115     },
    2116     dup: function() { return new MarkedText(null, null, this.style, this.set); },
     2192      return new MarkedText(from, to, this.style, this.marker);
     2193    },
     2194    dup: function() { return new MarkedText(null, null, this.style, this.marker); },
    21172195    clipTo: function(fromOpen, from, toOpen, to, diff) {
    2118       if (this.from != null && this.from >= from)
    2119         this.from = Math.max(to, this.from) + diff;
    2120       if (this.to != null && this.to > from)
    2121         this.to = to < this.to ? this.to + diff : from;
    21222196      if (fromOpen && to > this.from && (to < this.to || this.to == null))
    21232197        this.from = null;
     2198      else if (this.from != null && this.from >= from)
     2199        this.from = Math.max(to, this.from) + diff;
    21242200      if (toOpen && (from < this.to || this.to == null) && (from > this.from || this.from == null))
    21252201        this.to = null;
     2202      else if (this.to != null && this.to > from)
     2203        this.to = to < this.to ? this.to + diff : from;
    21262204    },
    21272205    isDead: function() { return this.from != null && this.to != null && this.from >= this.to; },
    2128     sameSet: function(x) { return this.set == x.set; }
     2206    sameSet: function(x) { return this.marker == x.marker; }
    21292207  };
    21302208
     
    21692247    this.text = text;
    21702248    this.height = 1;
    2171     this.marked = this.gutterMarker = this.className = this.handlers = null;
     2249    this.marked = this.gutterMarker = this.className = this.bgClassName = this.handlers = null;
    21722250    this.stateAfter = this.parent = this.hidden = null;
    21732251  }
     
    22152293            if (!taken.marked) taken.marked = [];
    22162294            taken.marked.push(newmark); newmark.attach(taken);
     2295            if (newmark == mark) mk.splice(i--, 1);
    22172296          }
    22182297        }
     
    26382717          for (var i = last.start - start - 1; i >= 0; --i)
    26392718            last.old.unshift(old[i]);
    2640           last.added += last.start - start;
     2719          oldoff = Math.min(0, added - old.length);
     2720          last.added += last.start - start + oldoff;
    26412721          last.start = start;
    2642         }
    2643         else if (last.start < start) {
     2722        } else if (last.start < start) {
    26442723          oldoff = start - last.start;
    26452724          added += oldoff;
     
    27082787  var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
    27092788
    2710   // Detect drag-and-drop
    2711   var dragAndDrop = function() {
    2712     // IE8 has ondragstart and ondrop properties, but doesn't seem to
    2713     // actually support ondragstart the way it's supposed to work.
    2714     if (/MSIE [1-8]\b/.test(navigator.userAgent)) return false;
    2715     var div = document.createElement('div');
    2716     return "draggable" in div;
    2717   }();
    2718 
    27192789  var gecko = /gecko\/\d{7}/i.test(navigator.userAgent);
    27202790  var ie = /MSIE \d/.test(navigator.userAgent);
    27212791  var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent);
    27222792  var webkit = /WebKit\//.test(navigator.userAgent);
     2793  var chrome = /Chrome\//.test(navigator.userAgent);
     2794  var khtml = /KHTML\//.test(navigator.userAgent);
     2795
     2796  // Detect drag-and-drop
     2797  var dragAndDrop = function() {
     2798    // There is *some* kind of drag-and-drop support in IE6-8, but I
     2799    // couldn't get it to work yet.
     2800    if (ie_lt9) return false;
     2801    var div = document.createElement('div');
     2802    return "draggable" in div || "dragDrop" in div;
     2803  }();
    27232804
    27242805  var lineSep = "\n";
     
    28742955                  19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
    28752956                  36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
    2876                   46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 186: ";", 187: "=", 188: ",",
     2957                  46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 127: "Delete", 186: ";", 187: "=", 188: ",",
    28772958                  189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 63276: "PageUp",
    28782959                  63277: "PageDown", 63275: "End", 63273: "Home", 63234: "Left", 63232: "Up", 63235: "Right",
  • codemirror-for-codeeditor/trunk/codemirror/lib/util/simple-hint.js

    r488558 r524544  
    3030    complete.style.top = pos.yBot + "px";
    3131    document.body.appendChild(complete);
     32    // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
     33    var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
     34    if(winW - pos.x < sel.clientWidth)
     35      complete.style.left = (pos.x - sel.clientWidth) + "px";
    3236    // Hack to hide the scrollbar.
    3337    if (completions.length <= 10)
     
    5458      else if (code != 38 && code != 40) {
    5559        close(); editor.focus();
     60        // Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
     61        editor.triggerOnKeyDown(event);
    5662        setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50);
    5763      }
  • codemirror-for-codeeditor/trunk/codemirror/mode/clike/index.html

    r499975 r524544  
    9797    (C code), <code>text/x-c++src</code> (C++
    9898    code), <code>text/x-java</code> (Java
    99     code).</p>
     99    code), <code>text/x-csharp</code> (C#).</p>
    100100  </body>
    101101</html>
  • codemirror-for-codeeditor/trunk/codemirror/mode/css/css.js

    r445953 r524544  
    9393
    9494      var context = state.stack[state.stack.length-1];
    95       if (type == "hash" && context == "rule") style = "atom";
     95      if (type == "hash" && context != "rule") style = "string-2";
    9696      else if (style == "variable") {
    9797        if (context == "rule") style = "number";
  • codemirror-for-codeeditor/trunk/codemirror/mode/htmlmixed/htmlmixed.js

    r457293 r524544  
    2929    if (stream.match(/^<\/\s*script\s*>/i, false)) {
    3030      state.token = html;
    31       state.curState = null;
     31      state.localState = null;
    3232      state.mode = "html";
    3333      return html(stream, state);
  • codemirror-for-codeeditor/trunk/codemirror/mode/javascript/javascript.js

    r499975 r524544  
    320320        cc: [],
    321321        lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
    322         localVars: null,
    323         context: null,
     322        localVars: parserConfig.localVars,
     323        context: parserConfig.localVars && {vars: parserConfig.localVars},
    324324        indented: 0
    325325      };
     
    335335      var style = state.tokenize(stream, state);
    336336      if (type == "comment") return style;
    337       state.reAllowed = type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/);
     337      state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
    338338      state.kwAllowed = type != '.';
    339339      return parseJS(state, style, type, content, stream);
  • codemirror-for-codeeditor/trunk/codemirror/mode/xml/xml.js

    r512124 r524544  
    265265
    266266CodeMirror.defineMIME("application/xml", "xml");
    267 CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
     267if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
     268  CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
  • codemirror-for-codeeditor/trunk/codemirror/theme/eclipse.css

    r488558 r524544  
    11.cm-s-eclipse span.cm-meta {color: #FF1717;}
    2 .cm-s-eclipse span.cm-keyword { font-weight: bold; color: #7F0055; }
     2.cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
    33.cm-s-eclipse span.cm-atom {color: #219;}
    44.cm-s-eclipse span.cm-number {color: #164;}
  • codemirror-for-codeeditor/trunk/codemirror/theme/elegant.css

    r488558 r524544  
    11.cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
    2 .cm-s-elegant span.cm-comment {color: #262;font-style: italic;}
    3 .cm-s-elegant span.cm-meta {color: #555;font-style: italic;}
     2.cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
     3.cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
    44.cm-s-elegant span.cm-variable {color: black;}
    55.cm-s-elegant span.cm-variable-2 {color: #b11;}
  • codemirror-for-codeeditor/trunk/codemirror/theme/neat.css

    r488558 r524544  
    11.cm-s-neat span.cm-comment { color: #a86; }
    2 .cm-s-neat span.cm-keyword { font-weight: bold; color: blue; }
     2.cm-s-neat span.cm-keyword { line-height: 1em; font-weight: bold; color: blue; }
    33.cm-s-neat span.cm-string { color: #a22; }
    4 .cm-s-neat span.cm-builtin { font-weight: bold; color: #077; }
    5 .cm-s-neat span.cm-special { font-weight: bold; color: #0aa; }
     4.cm-s-neat span.cm-builtin { line-height: 1em; font-weight: bold; color: #077; }
     5.cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
    66.cm-s-neat span.cm-variable { color: black; }
    77.cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
  • codemirror-for-codeeditor/trunk/codemirror/theme/rubyblue.css

    r512124 r524544  
    77.cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
    88
    9 .cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; }
     9.cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
    1010.cm-s-rubyblue span.cm-atom { color: #F4C20B; }
    1111.cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; }
  • codemirror-for-codeeditor/trunk/japanese.txt

    r512706 r524544  
    1111・テーマエディター、プラグインエディター上のソースコードをハイライト表示。
    1212・Marijn Haverbeke氏の「CodeMirror」をJavaスクリプトライブラリを採用。
    13 8つのテーマ。
     1310個のテーマ。
    1414・検索、置換機能を備えた便利なツールバー。
    1515・フルスクリーンモード。
     
    6161・「Ctrl」と「Z」キーを同時に押すと、1つ前の変更を取り消すことが出来ます。
    6262・「Ctrl」と「Y」キーを同時に押すと、変更を取り消す直前の状態に戻ります。
     63・「Shift」と「Tab」キーを同時に押すと、インデントが元の様態に戻ります。
     64・「Ctrl/Cmd」と「[」キーを同時に押すと、インデントが消去されます。
     65・「Ctrl/Cmd」と「]」キーを同時に押すと、インデントが追加されます。
    6366
    6467検索、置換は、下記のショートカットで行うことも出来ます。
     
    8689
    87908.履歴
     91
     922012/3/28 バージョン 0.5.6.1 リリース
     93※ CodeMirrorライブラリをver.2.23にバージョンアップ。
     94※ テーマ「Lesser-Dark」、「XQ-Dark」を追加。
    8895
    89962012/3/1 バージョン 0.5.6 リリース
  • codemirror-for-codeeditor/trunk/readme.txt

    r512706 r524544  
    55Requires at least: 2.8
    66Tested up to: 3.3.1
    7 Stable tag: 0.5.6
     7Stable tag: 0.5.6.1
    88
    99Just another code syntaxhighligher for the theme and plugin editor with CodeMirror.
     
    1717* Highlight sourcecodes in theme and plugin editor on the dashboard.
    1818* Based on Marijn Haverbeke's "[CodeMirror](http://codemirror.net/ "CodeMirrorr")" JavaScript library.
    19 * Built-in 8 themes.
     19* Built-in 10 themes.
    2020* Useful toolbar which includes search/replace features.
    2121* Full-screen editing.
     
    4646* You can select a theme, run search and replace on the toolbar.
    4747* Place the cursor in the textarea and press "Esc" or "F11" key to chage to the "fullscreen mode".
    48 * Press "Ctrl - Space" to activate Auto-omplete.
    49 * Press "Ctrl" - Z" to undo the previous change.
    50 * Press "Ctrl" - Y" to redo.
     48* Press "Ctrl" - "Space" to activate Auto-omplete.
     49* Press "Ctrl" - "Z" to undo the previous change.
     50* Press "Ctrl" - "Y" to redo.
     51* Press "Shift" - "Tab" to reset line indentation to default.
     52* Press "Ctrl/Cmd" - "[" to reduce line indentation.
     53* Press "Ctrl/Cmd" - "]" to increase line indentation.
    5154
    5255You can also use following shortcuts to search and replace.
     
    6871
    6972== Changelog ==
     73
     74= 0.5.6.1 =
     75* Updated CodeMirror to ver. 2.23.
     76* Add new themes(Lesser-Dark, XQ-Dark).
    7077
    7178= 0.5.6 =
     
    127134== Upgrade Notice ==
    128135
     136= 0.5.6.1 =
     137This version has new features.
     138
    129139= 0.5.6 =
    130140This version has a new feature.
Note: See TracChangeset for help on using the changeset viewer.