Changeset 524544
- Timestamp:
- 03/28/2012 12:31:03 AM (14 years ago)
- Location:
- codemirror-for-codeeditor/trunk
- Files:
-
- 2 added
- 15 edited
-
codemirror-for-codeeditor.php (modified) (6 diffs)
-
codemirror/lib/codemirror.css (modified) (2 diffs)
-
codemirror/lib/codemirror.js (modified) (52 diffs)
-
codemirror/lib/util/simple-hint.js (modified) (2 diffs)
-
codemirror/mode/clike/index.html (modified) (1 diff)
-
codemirror/mode/css/css.js (modified) (1 diff)
-
codemirror/mode/htmlmixed/htmlmixed.js (modified) (1 diff)
-
codemirror/mode/javascript/javascript.js (modified) (2 diffs)
-
codemirror/mode/xml/xml.js (modified) (1 diff)
-
codemirror/theme/eclipse.css (modified) (1 diff)
-
codemirror/theme/elegant.css (modified) (1 diff)
-
codemirror/theme/lesser-dark.css (added)
-
codemirror/theme/neat.css (modified) (1 diff)
-
codemirror/theme/rubyblue.css (modified) (1 diff)
-
codemirror/theme/xq-dark.css (added)
-
japanese.txt (modified) (3 diffs)
-
readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
codemirror-for-codeeditor/trunk/codemirror-for-codeeditor.php
r512706 r524544 4 4 Plugin URI: http://www.near-mint.com/blog/software/codemirror-for-codeeditor 5 5 Description: 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 6 Version: 0.5.6.1 7 7 Author: redcocker 8 8 Author URI: http://www.near-mint.com/blog/ … … 11 11 */ 12 12 /* 13 Last modified: 2012/3/ 113 Last modified: 2012/3/28 14 14 License: GPL v2(Except "CodeMirror" libraries) 15 15 */ … … 38 38 class CodeMirror_for_CodeEditor { 39 39 var $cfc_plugin_url; 40 var $cfc_ver = "0.5.6 ";40 var $cfc_ver = "0.5.6.1"; 41 41 var $cfc_db_ver = "0.5.6"; 42 var $cfc_lib_ver = "2.2 2";42 var $cfc_lib_ver = "2.23"; 43 43 var $cfc_setting_opt; 44 44 … … 182 182 wp_enqueue_style('codemirror-theme-elegant', $this->cfc_plugin_url.'codemirror/theme/elegant.css', false, $this->cfc_lib_ver); 183 183 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); 184 186 wp_enqueue_style('codemirror-theme-neat', $this->cfc_plugin_url.'codemirror/theme/neat.css', false, $this->cfc_lib_ver); 185 187 wp_enqueue_style('codemirror-theme-night', $this->cfc_plugin_url.'codemirror/theme/night.css', false, $this->cfc_lib_ver); … … 397 399 echo 'jQuery("#newcontent").after("<div id =\"cfc-toolbar\"><label>'.__("Theme: ", "cfc_lang").'</label><select id=\"cfc-theme\" onchange=\"selectTheme(this)\">'; 398 400 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"); 400 402 foreach ($theme_list as $val) { 401 403 if ($val == $this->cfc_setting_opt['theme']) { … … 589 591 <option value="eclipse" <?php if ($this->cfc_setting_opt['theme'] == "eclipse") {echo 'selected="selected"';} ?>><?php _e("Eclipse", "cfc_lang") ?></option> 590 592 <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> 591 594 <option value="monokai" <?php if ($this->cfc_setting_opt['theme'] == "monokai") {echo 'selected="selected"';} ?>><?php _e("Monokai", "cfc_lang") ?></option> 592 595 <option value="neat" <?php if ($this->cfc_setting_opt['theme'] == "neat") {echo 'selected="selected"';} ?>><?php _e("Neat", "cfc_lang") ?></option> 593 596 <option value="night" <?php if ($this->cfc_setting_opt['theme'] == "night") {echo 'selected="selected"';} ?>><?php _e("Night", "cfc_lang") ?></option> 594 597 <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> 595 599 </select> 596 600 <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 10 10 is visible outside of the scrolling box. */ 11 11 position: relative; 12 outline: none; 12 13 } 13 14 … … 28 29 .CodeMirror-lines { 29 30 padding: .4em; 31 white-space: pre; 30 32 } 31 33 -
codemirror-for-codeeditor/trunk/codemirror/lib/codemirror.js
r512124 r524544 1 // CodeMirror version 2.2 21 // CodeMirror version 2.23 2 2 // 3 3 // All functions that need access to the editor's state live inside … … 16 16 options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt]; 17 17 18 var targetDocument = options["document"];19 18 // The element in which the editor lives. 20 var wrapper = targetDocument.createElement("div");19 var wrapper = document.createElement("div"); 21 20 wrapper.className = "CodeMirror" + (options.lineWrapping ? " CodeMirror-wrap" : ""); 22 21 // This mess creates the base DOM structure for the editor. … … 49 48 lineSpace.style.outline = "none"; 50 49 if (options.tabindex != null) input.tabIndex = options.tabindex; 50 if (options.autofocus) focusInput(); 51 51 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"; 52 54 53 55 // Check for problem with IE innerHTML not working when we have a … … 82 84 // Current visible range (may be bigger than the view window). 83 85 var displayOffset = 0, showingFrom = 0, showingTo = 0, lastSizeC = 0; 84 // bracketHighlighted is used to remember that a b acket has been86 // bracketHighlighted is used to remember that a bracket has been 85 87 // marked. 86 88 var bracketHighlighted; … … 88 90 // can be kept static when scrolling. 89 91 var maxLine = "", maxWidth; 92 var tabCache = {}; 90 93 91 94 // Initialize the content. … … 125 128 })); 126 129 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 127 136 // IE throws unspecified error in certain cases, when 128 137 // 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); 131 140 else onBlur(); 132 141 … … 179 188 return getStateBefore(line + 1); 180 189 }, 181 cursorCoords: function(start ){190 cursorCoords: function(start, mode) { 182 191 if (start == null) start = sel.inverted; 183 return pageCoords(start ? sel.from : sel.to);192 return this.charCoords(start ? sel.from : sel.to, mode); 184 193 }, 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 }, 186 200 coordsChar: function(coords) { 187 201 var off = eltOffset(lineSpace); … … 190 204 markText: operation(markText), 191 205 setBookmark: setBookmark, 206 findMarksAt: findMarksAt, 192 207 setMarker: operation(addGutterMarker), 193 208 clearMarker: operation(removeGutterMarker), … … 257 272 getRange: function(from, to) {return getRange(clipPos(from), clipPos(to));}, 258 273 274 triggerOnKeyDown: operation(onKeyDown), 259 275 execCommand: function(cmd) {return commands[cmd](instance);}, 260 276 // Stuff used by commands, probably not much use to outside code. … … 374 390 // Let the drag handler handle this. 375 391 if (webkit) lineSpace.draggable = true; 376 var up = connect( targetDocument, "mouseup", operation(function(e2) {392 var up = connect(document, "mouseup", operation(function(e2) { 377 393 if (webkit) lineSpace.draggable = false; 378 394 draggingText = false; … … 385 401 }), true); 386 402 draggingText = true; 403 // IE's approach to draggable 404 if (lineSpace.dragDrop) lineSpace.dragDrop(); 387 405 return; 388 406 } … … 403 421 } 404 422 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) { 411 424 clearTimeout(going); 412 425 var cur = posFromMouse(e); … … 416 429 updateInput = true; 417 430 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); 418 437 }), true); 438 var up = connect(document, "mouseup", operation(done), true); 419 439 } 420 440 function onDoubleClick(e) { … … 465 485 function onDragStart(e) { 466 486 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);471 487 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 } 472 495 } 473 496 … … 507 530 if (e_prop(e, "metaKey")) name = "Cmd-" + name; 508 531 509 if (e_prop(e, "shiftKey")) 532 if (e_prop(e, "shiftKey")) { 510 533 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 { 513 539 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 } 516 545 return handled; 517 546 } … … 546 575 var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode"); 547 576 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; 549 578 var ch = String.fromCharCode(charCode == null ? keyCode : charCode); 550 579 if (options.electricChars && mode.electricChars && options.smartIndent && !options.readOnly) { … … 838 867 } 839 868 function scrollIntoView(x1, y1, x2, y2) { 840 var pl = paddingLeft(), pt = paddingTop() , lh = textHeight();869 var pl = paddingLeft(), pt = paddingTop(); 841 870 y1 += pt; y2 += pt; x1 += pl; x2 += pl; 842 871 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;} 845 874 846 875 var screenw = scroller.clientWidth, screenleft = scroller.scrollLeft; … … 922 951 " nodes=" + lineDiv.childNodes.length); 923 952 924 if (options.lineWrapping) {953 function checkHeights() { 925 954 maxWidth = scroller.clientWidth; 926 955 var curNode = lineDiv.firstChild, heightChanged = false; … … 937 966 if (heightChanged) 938 967 code.style.height = (doc.height * th + 2 * paddingTop()) + "px"; 968 return heightChanged; 969 } 970 971 if (options.lineWrapping) { 972 checkHeights(); 939 973 } else { 940 974 if (maxWidth == null) maxWidth = stringWidth(maxLine); … … 948 982 } 949 983 } 984 950 985 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 } 952 990 updateSelection(); 953 991 if (!suppressCallback && options.onUpdate) options.onUpdate(instance); … … 997 1035 // This pass fills in the lines that actually changed. 998 1036 var nextIntact = intact.shift(), curNode = lineDiv.firstChild, j = from; 999 var scratch = targetDocument.createElement("div"), newElt;1037 var scratch = document.createElement("div"); 1000 1038 doc.iter(from, to, function(line) { 1001 1039 if (nextIntact && nextIntact.to == j) nextIntact = intact.shift(); … … 1003 1041 if (line.hidden) var html = scratch.innerHTML = "<pre></pre>"; 1004 1042 else { 1005 var html = '<pre>' + line.getHTML(makeTab) + '</pre>'; 1043 var html = '<pre' + (line.className ? ' class="' + line.className + '"' : '') + '>' 1044 + line.getHTML(makeTab) + '</pre>'; 1006 1045 // 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 + 1009 1048 '" style="position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2"> </pre>' + html + "</div>"; 1010 1049 } … … 1022 1061 var hText = mover.offsetHeight, hEditor = scroller.clientHeight; 1023 1062 gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px"; 1024 var html = [], i = showingFrom ;1063 var html = [], i = showingFrom, normalNode; 1025 1064 doc.iter(showingFrom, Math.max(showingTo, showingFrom + 1), function(line) { 1026 1065 if (line.hidden) { … … 1036 1075 for (var j = 1; j < line.height; ++j) html.push("<br/> "); 1037 1076 html.push("</pre>"); 1077 if (!marker) normalNode = i; 1038 1078 } 1039 1079 ++i; … … 1041 1081 gutter.style.display = "none"; 1042 1082 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 } 1046 1090 gutter.style.display = ""; 1091 var resized = Math.abs((parseInt(lineSpace.style.marginLeft) || 0) - gutter.offsetWidth) > 2; 1047 1092 lineSpace.style.marginLeft = gutter.offsetWidth + "px"; 1048 1093 gutterDirty = false; 1094 return resized; 1049 1095 } 1050 1096 function updateSelection() { … … 1067 1113 'px; top: ' + top + 'px; right: ' + right + 'px; height: ' + height + 'px"></div>'; 1068 1114 } 1115 var clientWidth = lineSpace.clientWidth || lineSpace.offsetWidth; 1116 var clientHeight = lineSpace.clientHeight || lineSpace.offsetHeight; 1069 1117 if (sel.from.ch && fromPos.y >= 0) { 1070 var right = sameLine ? lineSpace.clientWidth - toPos.x : 0;1118 var right = sameLine ? clientWidth - toPos.x : 0; 1071 1119 add(fromPos.x, fromPos.y, right, th); 1072 1120 } 1073 1121 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; 1075 1123 if (middleHeight > 0.2 * th) 1076 1124 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); 1079 1127 selectionDiv.innerHTML = html; 1080 1128 cursor.style.display = "none"; … … 1106 1154 1107 1155 // 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 } 1109 1162 if (to.line != oldTo) to = skipHidden(to, oldTo, sel.to.ch); 1110 1163 … … 1115 1168 if (options.autoClearEmptyLines && posEq(sel.from, sel.to)) { 1116 1169 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) { 1118 1171 var oldLine = getLine(sel.from.line); 1119 1172 if (/^\s+$/.test(oldLine.text)) … … 1210 1263 else if (unit == "line") dist = textHeight(); 1211 1264 var target = coordsChar(pos.x, pos.y + dist * dir + 2); 1265 if (unit == "page") scroller.scrollTop += localCoords(target, true).y - pos.y; 1212 1266 setCursor(target.line, target.ch, true); 1213 1267 goalColumn = pos.x; … … 1296 1350 } 1297 1351 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; 1299 1354 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}); 1301 1356 } 1302 1357 function themeChanged() { … … 1314 1369 min = Math.min(min, lineN); max = Math.max(max, lineN); 1315 1370 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); 1317 1372 } 1318 1373 if (min != Infinity) … … 1325 1380 for (var j = 0; j < mk.length; ++j) { 1326 1381 var mark = mk[j]; 1327 if (mark. set == this.set) {1382 if (mark.marker == this) { 1328 1383 if (mark.from != null || mark.to != null) { 1329 1384 var found = lineNo(line); … … 1342 1397 from = clipPos(from); to = clipPos(to); 1343 1398 var tm = new TextMarker(); 1399 if (!posLess(from, to)) return tm; 1344 1400 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)); 1346 1402 } 1347 1403 if (from.line == to.line) add(from.line, from.ch, to.ch, className); … … 1361 1417 getLine(pos.line).addMark(bm); 1362 1418 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; 1363 1432 } 1364 1433 … … 1384 1453 return line; 1385 1454 } 1386 function setLineClass(handle, className ) {1455 function setLineClass(handle, className, bgClassName) { 1387 1456 return changeLine(handle, function(line) { 1388 if (line.className != className ) {1457 if (line.className != className || line.bgClassName != bgClassName) { 1389 1458 line.className = className; 1459 line.bgClassName = bgClassName; 1390 1460 return true; 1391 1461 } … … 1401 1471 var from = fline == no ? skipHidden({line: fline, ch: 0}, fline, 0) : sel.from; 1402 1472 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; 1403 1475 setSelection(from, to); 1404 1476 } … … 1421 1493 var marker = line.gutterMarker; 1422 1494 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}; 1424 1496 } 1425 1497 … … 1465 1537 // Include extra text at the end to make sure the measured line is wrapped in the right way. 1466 1538 if (options.lineWrapping) { 1467 var end = line.text.indexOf(" ", ch + 2);1539 var end = line.text.indexOf(" ", ch + 6); 1468 1540 extra = htmlEscape(line.text.slice(ch + 1, end < 0 ? line.text.length : end + (ie ? 5 : 0))); 1469 1541 } … … 1824 1896 undoDepth: 40, 1825 1897 tabindex: null, 1826 document: window.document1898 autofocus: null 1827 1899 }; 1828 1900 … … 1832 1904 1833 1905 // Known modes, by name and by MIME 1834 var modes = {},mimeModes = {};1906 var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {}; 1835 1907 CodeMirror.defineMode = function(name, mode) { 1836 1908 if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name; … … 1843 1915 if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) 1844 1916 spec = mimeModes[spec]; 1917 else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) 1918 return CodeMirror.resolveMode("application/xml"); 1845 1919 if (typeof spec == "string") return {name: spec}; 1846 1920 else return spec || {name: "null"}; … … 1927 2001 "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", 1928 2002 "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", 1929 "Delete": "delCharRight", "Backspace": "delCharLeft", "Tab": "in dentMore", "Shift-Tab": "indentLess",2003 "Delete": "delCharRight", "Backspace": "delCharLeft", "Tab": "insertTab", "Shift-Tab": "indentAuto", 1930 2004 "Enter": "newlineAndIndent", "Insert": "toggleOverwrite" 1931 2005 }; … … 1938 2012 "Ctrl-Backspace": "delWordLeft", "Ctrl-Delete": "delWordRight", "Ctrl-S": "save", "Ctrl-F": "find", 1939 2013 "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", 2014 "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", 1940 2015 fallthrough: "basic" 1941 2016 }; … … 1946 2021 "Ctrl-Alt-Backspace": "delWordRight", "Alt-Delete": "delWordRight", "Cmd-S": "save", "Cmd-F": "find", 1947 2022 "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", 2023 "Cmd-[": "indentLess", "Cmd-]": "indentMore", 1948 2024 fallthrough: ["basic", "emacsy"] 1949 2025 }; … … 1988 2064 if (!options.tabindex && textarea.tabindex) 1989 2065 options.tabindex = textarea.tabindex; 2066 if (options.autofocus == null && textarea.getAttribute("autofocus") != null) 2067 options.autofocus = true; 1990 2068 1991 2069 function save() {textarea.value = instance.getValue();} … … 2099 2177 CodeMirror.StringStream = StringStream; 2100 2178 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; 2103 2181 } 2104 2182 MarkedText.prototype = { 2105 attach: function(line) { this. set.push(line); },2183 attach: function(line) { this.marker.set.push(line); }, 2106 2184 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); 2109 2187 }, 2110 2188 split: function(pos, lenBefore) { … … 2112 2190 var from = this.from < pos || this.from == null ? null : this.from - pos + lenBefore; 2113 2191 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); }, 2117 2195 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;2122 2196 if (fromOpen && to > this.from && (to < this.to || this.to == null)) 2123 2197 this.from = null; 2198 else if (this.from != null && this.from >= from) 2199 this.from = Math.max(to, this.from) + diff; 2124 2200 if (toOpen && (from < this.to || this.to == null) && (from > this.from || this.from == null)) 2125 2201 this.to = null; 2202 else if (this.to != null && this.to > from) 2203 this.to = to < this.to ? this.to + diff : from; 2126 2204 }, 2127 2205 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; } 2129 2207 }; 2130 2208 … … 2169 2247 this.text = text; 2170 2248 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; 2172 2250 this.stateAfter = this.parent = this.hidden = null; 2173 2251 } … … 2215 2293 if (!taken.marked) taken.marked = []; 2216 2294 taken.marked.push(newmark); newmark.attach(taken); 2295 if (newmark == mark) mk.splice(i--, 1); 2217 2296 } 2218 2297 } … … 2638 2717 for (var i = last.start - start - 1; i >= 0; --i) 2639 2718 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; 2641 2721 last.start = start; 2642 } 2643 else if (last.start < start) { 2722 } else if (last.start < start) { 2644 2723 oldoff = start - last.start; 2645 2724 added += oldoff; … … 2708 2787 var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}}; 2709 2788 2710 // Detect drag-and-drop2711 var dragAndDrop = function() {2712 // IE8 has ondragstart and ondrop properties, but doesn't seem to2713 // 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 2719 2789 var gecko = /gecko\/\d{7}/i.test(navigator.userAgent); 2720 2790 var ie = /MSIE \d/.test(navigator.userAgent); 2721 2791 var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent); 2722 2792 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 }(); 2723 2804 2724 2805 var lineSep = "\n"; … … 2874 2955 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 2875 2956 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", 2876 46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 1 86: ";", 187: "=", 188: ",",2957 46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 127: "Delete", 186: ";", 187: "=", 188: ",", 2877 2958 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 63276: "PageUp", 2878 2959 63277: "PageDown", 63275: "End", 63273: "Home", 63234: "Left", 63232: "Up", 63235: "Right", -
codemirror-for-codeeditor/trunk/codemirror/lib/util/simple-hint.js
r488558 r524544 30 30 complete.style.top = pos.yBot + "px"; 31 31 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"; 32 36 // Hack to hide the scrollbar. 33 37 if (completions.length <= 10) … … 54 58 else if (code != 38 && code != 40) { 55 59 close(); editor.focus(); 60 // Pass the event to the CodeMirror instance so that it can handle things like backspace properly. 61 editor.triggerOnKeyDown(event); 56 62 setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50); 57 63 } -
codemirror-for-codeeditor/trunk/codemirror/mode/clike/index.html
r499975 r524544 97 97 (C code), <code>text/x-c++src</code> (C++ 98 98 code), <code>text/x-java</code> (Java 99 code) .</p>99 code), <code>text/x-csharp</code> (C#).</p> 100 100 </body> 101 101 </html> -
codemirror-for-codeeditor/trunk/codemirror/mode/css/css.js
r445953 r524544 93 93 94 94 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"; 96 96 else if (style == "variable") { 97 97 if (context == "rule") style = "number"; -
codemirror-for-codeeditor/trunk/codemirror/mode/htmlmixed/htmlmixed.js
r457293 r524544 29 29 if (stream.match(/^<\/\s*script\s*>/i, false)) { 30 30 state.token = html; 31 state. curState = null;31 state.localState = null; 32 32 state.mode = "html"; 33 33 return html(stream, state); -
codemirror-for-codeeditor/trunk/codemirror/mode/javascript/javascript.js
r499975 r524544 320 320 cc: [], 321 321 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}, 324 324 indented: 0 325 325 }; … … 335 335 var style = state.tokenize(stream, state); 336 336 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(/^[\[{}\(,;:]$/)); 338 338 state.kwAllowed = type != '.'; 339 339 return parseJS(state, style, type, content, stream); -
codemirror-for-codeeditor/trunk/codemirror/mode/xml/xml.js
r512124 r524544 265 265 266 266 CodeMirror.defineMIME("application/xml", "xml"); 267 CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true}); 267 if (!CodeMirror.mimeModes.hasOwnProperty("text/html")) 268 CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true}); -
codemirror-for-codeeditor/trunk/codemirror/theme/eclipse.css
r488558 r524544 1 1 .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; } 3 3 .cm-s-eclipse span.cm-atom {color: #219;} 4 4 .cm-s-eclipse span.cm-number {color: #164;} -
codemirror-for-codeeditor/trunk/codemirror/theme/elegant.css
r488558 r524544 1 1 .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;} 4 4 .cm-s-elegant span.cm-variable {color: black;} 5 5 .cm-s-elegant span.cm-variable-2 {color: #b11;} -
codemirror-for-codeeditor/trunk/codemirror/theme/neat.css
r488558 r524544 1 1 .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; } 3 3 .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; } 6 6 .cm-s-neat span.cm-variable { color: black; } 7 7 .cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; } -
codemirror-for-codeeditor/trunk/codemirror/theme/rubyblue.css
r512124 r524544 7 7 .cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; } 8 8 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; } 10 10 .cm-s-rubyblue span.cm-atom { color: #F4C20B; } 11 11 .cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; } -
codemirror-for-codeeditor/trunk/japanese.txt
r512706 r524544 11 11 ・テーマエディター、プラグインエディター上のソースコードをハイライト表示。 12 12 ・Marijn Haverbeke氏の「CodeMirror」をJavaスクリプトライブラリを採用。 13 ・ 8つのテーマ。13 ・10個のテーマ。 14 14 ・検索、置換機能を備えた便利なツールバー。 15 15 ・フルスクリーンモード。 … … 61 61 ・「Ctrl」と「Z」キーを同時に押すと、1つ前の変更を取り消すことが出来ます。 62 62 ・「Ctrl」と「Y」キーを同時に押すと、変更を取り消す直前の状態に戻ります。 63 ・「Shift」と「Tab」キーを同時に押すと、インデントが元の様態に戻ります。 64 ・「Ctrl/Cmd」と「[」キーを同時に押すと、インデントが消去されます。 65 ・「Ctrl/Cmd」と「]」キーを同時に押すと、インデントが追加されます。 63 66 64 67 検索、置換は、下記のショートカットで行うことも出来ます。 … … 86 89 87 90 8.履歴 91 92 2012/3/28 バージョン 0.5.6.1 リリース 93 ※ CodeMirrorライブラリをver.2.23にバージョンアップ。 94 ※ テーマ「Lesser-Dark」、「XQ-Dark」を追加。 88 95 89 96 2012/3/1 バージョン 0.5.6 リリース -
codemirror-for-codeeditor/trunk/readme.txt
r512706 r524544 5 5 Requires at least: 2.8 6 6 Tested up to: 3.3.1 7 Stable tag: 0.5.6 7 Stable tag: 0.5.6.1 8 8 9 9 Just another code syntaxhighligher for the theme and plugin editor with CodeMirror. … … 17 17 * Highlight sourcecodes in theme and plugin editor on the dashboard. 18 18 * Based on Marijn Haverbeke's "[CodeMirror](http://codemirror.net/ "CodeMirrorr")" JavaScript library. 19 * Built-in 8themes.19 * Built-in 10 themes. 20 20 * Useful toolbar which includes search/replace features. 21 21 * Full-screen editing. … … 46 46 * You can select a theme, run search and replace on the toolbar. 47 47 * 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. 51 54 52 55 You can also use following shortcuts to search and replace. … … 68 71 69 72 == Changelog == 73 74 = 0.5.6.1 = 75 * Updated CodeMirror to ver. 2.23. 76 * Add new themes(Lesser-Dark, XQ-Dark). 70 77 71 78 = 0.5.6 = … … 127 134 == Upgrade Notice == 128 135 136 = 0.5.6.1 = 137 This version has new features. 138 129 139 = 0.5.6 = 130 140 This version has a new feature.
Note: See TracChangeset
for help on using the changeset viewer.