Skip to content

Commit e54dc3f

Browse files
Added all the CodeMirror-demos, and modes python and php
1 parent 2110607 commit e54dc3f

53 files changed

Lines changed: 4769 additions & 7 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CodeMirror/demo/activeline.html

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!doctype html>
2+
3+
<title>CodeMirror: Active Line Demo</title>
4+
<meta charset="utf-8"/>
5+
<link rel=stylesheet href="../doc/docs.css">
6+
7+
<link rel="stylesheet" href="../lib/codemirror.css">
8+
<script src="../lib/codemirror.js"></script>
9+
<script src="../mode/xml/xml.js"></script>
10+
<script src="../addon/selection/active-line.js"></script>
11+
<style type="text/css">
12+
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
13+
</style>
14+
<div id=nav>
15+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
16+
17+
<ul>
18+
<li><a href="../index.html">Home</a>
19+
<li><a href="../doc/manual.html">Manual</a>
20+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
21+
</ul>
22+
<ul>
23+
<li><a class=active href="#">Active Line</a>
24+
</ul>
25+
</div>
26+
27+
<article>
28+
<h2>Active Line Demo</h2>
29+
<form><textarea id="code" name="code">
30+
<?xml version="1.0" encoding="UTF-8"?>
31+
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"
32+
xmlns:georss="http://www.georss.org/georss"
33+
xmlns:twitter="http://api.twitter.com">
34+
<channel>
35+
<title>Twitter / codemirror</title>
36+
<link>http://twitter.com/codemirror</link>
37+
<atom:link type="application/rss+xml"
38+
href="http://twitter.com/statuses/user_timeline/242283288.rss" rel="self"/>
39+
<description>Twitter updates from CodeMirror / codemirror.</description>
40+
<language>en-us</language>
41+
<ttl>40</ttl>
42+
<item>
43+
<title>codemirror: http://cloud-ide.com &#8212; they're springing up like mushrooms. This one
44+
uses CodeMirror as its editor.</title>
45+
<description>codemirror: http://cloud-ide.com &#8212; they're springing up like mushrooms. This
46+
one uses CodeMirror as its editor.</description>
47+
<pubDate>Thu, 17 Mar 2011 23:34:47 +0000</pubDate>
48+
<guid>http://twitter.com/codemirror/statuses/48527733722058752</guid>
49+
<link>http://twitter.com/codemirror/statuses/48527733722058752</link>
50+
<twitter:source>web</twitter:source>
51+
<twitter:place/>
52+
</item>
53+
<item>
54+
<title>codemirror: Posted a description of the CodeMirror 2 internals at
55+
http://codemirror.net/2/internals.html</title>
56+
<description>codemirror: Posted a description of the CodeMirror 2 internals at
57+
http://codemirror.net/2/internals.html</description>
58+
<pubDate>Wed, 02 Mar 2011 12:15:09 +0000</pubDate>
59+
<guid>http://twitter.com/codemirror/statuses/42920879788789760</guid>
60+
<link>http://twitter.com/codemirror/statuses/42920879788789760</link>
61+
<twitter:source>web</twitter:source>
62+
<twitter:place/>
63+
</item>
64+
</channel>
65+
</rss></textarea></form>
66+
67+
<script>
68+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
69+
mode: "application/xml",
70+
styleActiveLine: true,
71+
lineNumbers: true,
72+
lineWrapping: true
73+
});
74+
</script>
75+
76+
<p>Styling the current cursor line.</p>
77+
78+
</article>

CodeMirror/demo/anywordhint.html

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!doctype html>
2+
3+
<title>CodeMirror: Any Word Completion Demo</title>
4+
<meta charset="utf-8"/>
5+
<link rel=stylesheet href="../doc/docs.css">
6+
7+
<link rel="stylesheet" href="../lib/codemirror.css">
8+
<link rel="stylesheet" href="../addon/hint/show-hint.css">
9+
<script src="../lib/codemirror.js"></script>
10+
<script src="../addon/hint/show-hint.js"></script>
11+
<script src="../addon/hint/anyword-hint.js"></script>
12+
<script src="../mode/javascript/javascript.js"></script>
13+
<div id=nav>
14+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
15+
16+
<ul>
17+
<li><a href="../index.html">Home</a>
18+
<li><a href="../doc/manual.html">Manual</a>
19+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
20+
</ul>
21+
<ul>
22+
<li><a class=active href="#">Any Word Completion</a>
23+
</ul>
24+
</div>
25+
26+
<article>
27+
<h2>Any Word Completion Demo</h2>
28+
<form><textarea id="code" name="code">
29+
(function() {
30+
"use strict";
31+
32+
var WORD = /[\w$]+/g, RANGE = 500;
33+
34+
CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
35+
var word = options && options.word || WORD;
36+
var range = options && options.range || RANGE;
37+
var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
38+
var start = cur.ch, end = start;
39+
while (end < curLine.length && word.test(curLine.charAt(end))) ++end;
40+
while (start && word.test(curLine.charAt(start - 1))) --start;
41+
var curWord = start != end && curLine.slice(start, end);
42+
43+
var list = [], seen = {};
44+
function scan(dir) {
45+
var line = cur.line, end = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
46+
for (; line != end; line += dir) {
47+
var text = editor.getLine(line), m;
48+
word.lastIndex = 0;
49+
while (m = word.exec(text)) {
50+
if ((!curWord || m[0].indexOf(curWord) == 0) && !seen.hasOwnProperty(m[0])) {
51+
seen[m[0]] = true;
52+
list.push(m[0]);
53+
}
54+
}
55+
}
56+
}
57+
scan(-1);
58+
scan(1);
59+
return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
60+
});
61+
})();
62+
</textarea></form>
63+
64+
<p>Press <strong>ctrl-space</strong> to activate autocompletion. The
65+
completion uses
66+
the <a href="../doc/manual.html#addon_anyword-hint">anyword-hint.js</a>
67+
module, which simply looks at nearby words in the buffer and completes
68+
to those.</p>
69+
70+
<script>
71+
CodeMirror.commands.autocomplete = function(cm) {
72+
cm.showHint({hint: CodeMirror.hint.anyword});
73+
}
74+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
75+
lineNumbers: true,
76+
extraKeys: {"Ctrl-Space": "autocomplete"}
77+
});
78+
</script>
79+
</article>

CodeMirror/demo/bidi.html

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!doctype html>
2+
3+
<title>CodeMirror: Bi-directional Text Demo</title>
4+
<meta charset="utf-8"/>
5+
<link rel=stylesheet href="../doc/docs.css">
6+
7+
<link rel="stylesheet" href="../lib/codemirror.css">
8+
<script src="../lib/codemirror.js"></script>
9+
<script src="../mode/xml/xml.js"></script>
10+
<style type="text/css">
11+
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
12+
</style>
13+
<div id=nav>
14+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
15+
16+
<ul>
17+
<li><a href="../index.html">Home</a>
18+
<li><a href="../doc/manual.html">Manual</a>
19+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
20+
</ul>
21+
<ul>
22+
<li><a class=active href="#">Bi-directional Text</a>
23+
</ul>
24+
</div>
25+
26+
<article>
27+
<h2>Bi-directional Text Demo</h2>
28+
<form><textarea id="code" name="code"><!-- Piece of the CodeMirror manual, 'translated' into Arabic by
29+
Google Translate -->
30+
31+
<dl>
32+
<dt id=option_value><code>value (string or Doc)</code></dt>
33+
<dd>قيمة البداية المحرر. يمكن أن تكون سلسلة، أو. كائن مستند.</dd>
34+
<dt id=option_mode><code>mode (string or object)</code></dt>
35+
<dd>وضع الاستخدام. عندما لا تعطى، وهذا الافتراضي إلى الطريقة الاولى
36+
التي تم تحميلها. قد يكون من سلسلة، والتي إما أسماء أو ببساطة هو وضع
37+
MIME نوع المرتبطة اسطة. بدلا من ذلك، قد يكون من كائن يحتوي على
38+
خيارات التكوين لواسطة، مع <code>name</code> الخاصية التي وضع أسماء
39+
(على سبيل المثال <code>{name: "javascript", json: true}</code>).
40+
صفحات التجريبي لكل وضع تحتوي على معلومات حول ما معلمات تكوين وضع
41+
يدعمها. يمكنك أن تطلب CodeMirror التي تم تعريفها طرق وأنواع MIME
42+
الكشف على <code>CodeMirror.modes</code>
43+
و <code>CodeMirror.mimeModes</code> الكائنات. وضع خرائط الأسماء
44+
الأولى لمنشئات الخاصة بهم، وخرائط لأنواع MIME 2 المواصفات
45+
واسطة.</dd>
46+
<dt id=option_theme><code>theme (string)</code></dt>
47+
<dd>موضوع لنمط المحرر مع. يجب عليك التأكد من الملف CSS تحديد
48+
المقابلة <code>.cm-s-[name]</code> يتم تحميل أنماط (انظر
49+
<a href="../theme/"><code>theme</code></a> الدليل في التوزيع).
50+
الافتراضي هو <code>"default"</code> ، والتي تم تضمينها في
51+
الألوان <code>codemirror.css</code>. فمن الممكن استخدام فئات متعددة
52+
في تطبيق السمات مرة واحدة على سبيل المثال <code>"foo bar"</code>
53+
سيتم تعيين كل من <code>cm-s-foo</code> و <code>cm-s-bar</code>
54+
الطبقات إلى المحرر.</dd>
55+
</dl>
56+
</textarea></form>
57+
58+
<script>
59+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
60+
mode: "text/html",
61+
lineNumbers: true
62+
});
63+
</script>
64+
65+
<p>Demonstration of bi-directional text support. See
66+
the <a href="http://marijnhaverbeke.nl/blog/cursor-in-bidi-text.html">related
67+
blog post</a> for more background.</p>
68+
69+
<p><strong>Note:</strong> There is
70+
a <a href="https://github.com/codemirror/CodeMirror/issues/1757">known
71+
bug</a> with cursor motion and mouse clicks in bi-directional lines
72+
that are line wrapped.</p>
73+
74+
</article>

CodeMirror/demo/btree.html

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!doctype html>
2+
3+
<title>CodeMirror: B-Tree visualization</title>
4+
<meta charset="utf-8"/>
5+
<link rel=stylesheet href="../doc/docs.css">
6+
7+
<link rel="stylesheet" href="../lib/codemirror.css">
8+
<script src="../lib/codemirror.js"></script>
9+
<style type="text/css">
10+
.lineblock { display: inline-block; margin: 1px; height: 5px; }
11+
.CodeMirror {border: 1px solid #aaa; height: 400px}
12+
</style>
13+
<div id=nav>
14+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
15+
16+
<ul>
17+
<li><a href="../index.html">Home</a>
18+
<li><a href="../doc/manual.html">Manual</a>
19+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
20+
</ul>
21+
<ul>
22+
<li><a class=active href="#">B-Tree visualization</a>
23+
</ul>
24+
</div>
25+
26+
<article>
27+
<h2>B-Tree visualization</h2>
28+
<form><textarea id="code" name="code">type here, see a summary of the document b-tree below</textarea></form>
29+
<div style="display: inline-block; height: 402px; overflow-y: auto" id="output"></div>
30+
31+
<script id="me">
32+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
33+
lineNumbers: true,
34+
lineWrapping: true
35+
});
36+
var updateTimeout;
37+
editor.on("change", function(cm) {
38+
clearTimeout(updateTimeout);
39+
updateTimeout = setTimeout(updateVisual, 200);
40+
});
41+
updateVisual();
42+
43+
function updateVisual() {
44+
var out = document.getElementById("output");
45+
out.innerHTML = "";
46+
47+
function drawTree(out, node) {
48+
if (node.lines) {
49+
out.appendChild(document.createElement("div")).innerHTML =
50+
"<b>leaf</b>: " + node.lines.length + " lines, " + Math.round(node.height) + " px";
51+
var lines = out.appendChild(document.createElement("div"));
52+
lines.style.lineHeight = "6px"; lines.style.marginLeft = "10px";
53+
for (var i = 0; i < node.lines.length; ++i) {
54+
var line = node.lines[i], lineElt = lines.appendChild(document.createElement("div"));
55+
lineElt.className = "lineblock";
56+
var gray = Math.min(line.text.length * 3, 230), col = gray.toString(16);
57+
if (col.length == 1) col = "0" + col;
58+
lineElt.style.background = "#" + col + col + col;
59+
lineElt.style.width = Math.max(Math.round(line.height / 3), 1) + "px";
60+
}
61+
} else {
62+
out.appendChild(document.createElement("div")).innerHTML =
63+
"<b>node</b>: " + node.size + " lines, " + Math.round(node.height) + " px";
64+
var sub = out.appendChild(document.createElement("div"));
65+
sub.style.paddingLeft = "20px";
66+
for (var i = 0; i < node.children.length; ++i)
67+
drawTree(sub, node.children[i]);
68+
}
69+
}
70+
drawTree(out, editor.getDoc());
71+
}
72+
73+
function fillEditor() {
74+
var sc = document.getElementById("me");
75+
var doc = (sc.textContent || sc.innerText || sc.innerHTML).replace(/^\s*/, "") + "\n";
76+
doc += doc; doc += doc; doc += doc; doc += doc; doc += doc; doc += doc;
77+
editor.setValue(doc);
78+
}
79+
</script>
80+
81+
<p><button onclick="fillEditor()">Add a lot of content</button></p>
82+
83+
</article>

0 commit comments

Comments
 (0)