/
source.html
137 lines (135 loc) · 335 KB
/
source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<p>(<a href="http://unhosted.bencharp.com/page/2-editeur,2.html">en Français</a>)</p>
<p>Welcome to the second episode of Unhosted Adventures! If you log out of all websites, and close all desktop applications, putting
your browser fullscreen, you will not be able to do many things. In order to get some work done, you will most likely need at least a
text editor. So that is the first thing we will build. We will use <a href="http://codemirror.net/">CodeMirror</a> as the basis. This
is a client-side text editor component, developed by Marijn Haverbeke, which can easily be embedded
in web apps, whether hosted or unhosted. But since it requires no hosted code, it is especially useful for use in unhosted web apps.
The following code allows you to edit javascript, html and markdown right inside your browser:</p><pre><code>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>codemirror</title>
<script
src="http://codemirror.net/lib/codemirror.js">
</script>
<link rel="stylesheet"
href="http://codemirror.net/lib/codemirror.css" />
<script
src="http://codemirror.net/mode/xml/xml.js">
</script>
<script
src="http://codemirror.net/mode/javascript/javascript.js">
</script>
<script
src="http://codemirror.net/mode/css/css.js">
</script>
<script
src="http://codemirror.net/mode/htmlmixed/htmlmixed.js">
</script>
<script
src="http://codemirror.net/mode/markdown/markdown.js">
</script>
</head>
<body>
<div id="editor"></div>
<div>
<input type="submit" value="js"
onclick="myCodeMirror.setOption('mode', 'javascript');">
<input type="submit" value="html"
onclick="myCodeMirror.setOption('mode', 'htmlmixed');">
<input type="submit" value="markdown"
onclick="myCodeMirror.setOption('mode', 'markdown');">
</div>
</body>
<script>
var myCodeMirror = CodeMirror(
document.getElementById('editor'),
{ lineNumbers: true }
);
</script>
</html>
</code></pre>
<p>Funny fact is, I wrote this example without having an editor. The way I did it was to visit example.com, and then open the web console
and type</p><pre><code>
document.body.innerHTML = ''
</code></pre>
<p>to clear the screen. That way I could use the console to add code to the page, and bootstrap myself
into my first editor, which I could then save to a file with "Save Page As" from the "File" menu.
Once I had it displaying a CodeMirror component, I could start using that to type in, and from there write more
editor versions and then other things. But since I already went through that first bootstrap phase, you don't have to and can simply use this
<a href="data:text/html;charset=utf-8,%3C!DOCTYPE%20html%3E%20%3Chtml%20lang%3D%22en%22%3E%20%3Chead%3E%20%3Cmeta%20charset%3D%22utf-8%22%3E%20%3Ctitle%3Ecodemirror%3C%2Ftitle%3E%20%3Cscript%20src%3D%22http%3A%2F%2Fcodemirror.net%2Flib%2Fcodemirror.js%22%3E%20%3C%2Fscript%3E%20%3Clink%20rel%3D%22stylesheet%22%20href%3D%22http%3A%2F%2Fcodemirror.net%2Flib%2Fcodemirror.css%22%20%2F%3E%20%3Cscript%20src%3D%22http%3A%2F%2Fcodemirror.net%2Fmode%2Fxml%2Fxml.js%22%3E%20%3C%2Fscript%3E%20%3Cscript%20src%3D%22http%3A%2F%2Fcodemirror.net%2Fmode%2Fjavascript%2Fjavascript.js%22%3E%20%3C%2Fscript%3E%20%3Cscript%20src%3D%22http%3A%2F%2Fcodemirror.net%2Fmode%2Fcss%2Fcss.js%22%3E%20%3C%2Fscript%3E%20%3Cscript%20src%3D%22http%3A%2F%2Fcodemirror.net%2Fmode%2Fhtmlmixed%2Fhtmlmixed.js%22%3E%20%3C%2Fscript%3E%20%3Cscript%20src%3D%22http%3A%2F%2Fcodemirror.net%2Fmode%2Fmarkdown%2Fmarkdown.js%22%3E%20%3C%2Fscript%3E%20%3C%2Fhead%3E%20%3Cbody%3E%20%3Cdiv%20id%3D%22editor%22%3E%3C%2Fdiv%3E%20%3Cdiv%3E%20%3Cinput%20type%3D%22submit%22%20value%3D%22js%22%20onclick%3D%22myCodeMirror.setOption('mode'%2C%20'javascript')%3B%22%3E%20%3Cinput%20type%3D%22submit%22%20value%3D%22html%22%20onclick%3D%22myCodeMirror.setOption('mode'%2C%20'htmlmixed')%3B%22%3E%20%3Cinput%20type%3D%22submit%22%20value%3D%22markdown%22%20onclick%3D%22myCodeMirror.setOption('mode'%2C%20'markdown')%3B%22%3E%20%3C%2Fdiv%3E%20%3C%2Fbody%3E%20%3Cscript%3E%20var%20myCodeMirror%20%3D%20CodeMirror(%20document.getElementById('editor')%2C%20%7B%20lineNumbers%3A%20true%20%7D)%3B%20%3C%2Fscript%3E%20%3C%2Fhtml%3E"
target="_blank">data url</a> (in Firefox you may have to click the small "shield" icon to unblock the content, or copy the link location and paste it into another tab's URL bar). Type some markdown or javascript in there to try out what the different syntax
highlightings look like. You can bookmark this data URL, or click 'Save Page As...' from the 'File' menu of your browser.
Then you can browse to your device's file system by typing "file:///" into
the address bar, and clicking through the directories until you find the file you saved. To view the source code,
an easy trick is to replace the first part of the data URL:</p><pre><code>
data:text/html;charset=utf-8,
</code></pre>
<p>with:</p><pre><code>
data:text/plain;charset=utf-8,
</code></pre>
<p>Also fun is opening the web console while viewing the editor (Ctrl-Shift-K, Cmd-Alt-K, Ctrl-Shift-I, or Cmd-Alt-I
depending on your OS and browser), and pasting the following line in there:</p><pre><code>
myCodeMirror.setValue(decodeURIComponent(location.href
.substring('data:text/html;charset=utf-8,'.length)));
</code></pre>
<p>This will decode the data URL and load the editor into itself. Now you can edit your editor. :) To update it, use the "opposite" line,
which will take you to the new version you just created:</p><pre><code>
location.href = 'data:text/html;charset=utf-8,'
+ encodeURIComponent(myCodeMirror.getValue());
</code></pre>
<p>Try it, by adding some text at the end of the document body and executing that second line. After that you can execute the first line again
to load
your modified version of the editor back into itself (use the up-arrow to see your command history in the web console).</p>
<p>The next step is to add some buttons to make loading and saving the files you edit from and to the local filesystem easier. For that, we add
the following code into the document body:</p><pre><code>
<input type="file" onchange="localLoad(this.files);" />
<input type="submit" value="save"
onclick="window.open(localSave());">
</code></pre>
<p>And we add the following functions to the script tag at the end:</p><pre><code>
//LOCAL
function localSave() {
return 'data:text/plain;charset=utf-8,'
+ encodeURIComponent(myCodeMirror.getValue());
}
function localLoad(files) {
if (files.length === 1) {
document.title = escape(files[0].name);
var reader = new FileReader();
reader.onload = function(e) {
myCodeMirror.setValue(e.target.result);
};
reader.readAsText(files[0]);
}
}
</code></pre>
<p>The 'localLoad' code is copied from MDN; you should also check out the
<a href="http://www.html5rocks.com/en/tutorials/file/dndfiles/">html5rocks tutorial</a>, which describes how you can add nice drag-and-drop.
But since I use no desktop applications, I usually have Firefox fullscreen and have no other place to drag any items from, so that
is useless in my case.</p>
<p>The 'save' button is not ideal. It opens the editor contents in a new window so that you can save it with "Save Page As...", but that dialog then is
not prefilled with
the file path to which you saved the file the last time, and also it asks you to confirm if you really want to replace the file, and you
need to close the
extra window again, meaning saving the current file takes five clicks instead of one. But it is the best I could get working. The reason
the window.open()
call is in the button element and not in a function as it would normally be, is that popup blockers may block that if it is too deep in
the call stack.</p>
<p><strong>UPDATE:</strong> nowadays, you can use the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a">download attribute</a> to do this in a much nicer way. At the time of writing, that still only existed as a Chrome feature; it arrived in Firefox in spring 2013. Thanks to <a href="https://groups.google.com/d/msg/unhosted/ANz3ofSyfmc/BkeL6sL7Mf8J">Felix</a> for pointing this out!</p>
<p>You may have noticed that these examples include some js and css files from http://codemirror.net/ which don't load if you have no network
connection. So here is the full code of this tutorial, with all the CodeMirror files copied into it from version 2.34:
<a href="data:text/html;charset=utf-8,%3C!DOCTYPE%20html%20lang%3D%22en%22%3E%0A%3Chtml%3E%0A%20%20%3Chead%3E%0A%20%20%20%20%3Cmeta%20charset%3D%22utf-8%22%3E%0A%20%20%20%20%3Ctitle%3Ecodemirror%3C%2Ftitle%3E%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%3C!--%20http%3A%2F%2Fcodemirror.net%2Flib%2Fcodemirror.js%20--%3E%3Cscript%3E%0A%2F%2F%20CodeMirror%20version%202.34%0A%0A%2F%2F%20All%20functions%20that%20need%20access%20to%20the%20editor's%20state%20live%20inside%0A%2F%2F%20the%20CodeMirror%20function.%20Below%20that%2C%20at%20the%20bottom%20of%20the%20file%2C%0A%2F%2F%20some%20utilities%20are%20defined.%0A%0A%2F%2F%20CodeMirror%20is%20the%20only%20global%20var%20we%20claim%0Awindow.CodeMirror%20%3D%20(function()%20%7B%0A%20%20%22use%20strict%22%3B%0A%20%20%2F%2F%20This%20is%20the%20function%20that%20produces%20an%20editor%20instance.%20Its%0A%20%20%2F%2F%20closure%20is%20used%20to%20store%20the%20editor%20state.%0A%20%20function%20CodeMirror(place%2C%20givenOptions)%20%7B%0A%20%20%20%20%2F%2F%20Determine%20effective%20options%20based%20on%20given%20values%20and%20defaults.%0A%20%20%20%20var%20options%20%3D%20%7B%7D%2C%20defaults%20%3D%20CodeMirror.defaults%3B%0A%20%20%20%20for%20(var%20opt%20in%20defaults)%0A%20%20%20%20%20%20if%20(defaults.hasOwnProperty(opt))%0A%20%20%20%20%20%20%20%20options%5Bopt%5D%20%3D%20(givenOptions%20%26%26%20givenOptions.hasOwnProperty(opt)%20%3F%20givenOptions%20%3A%20defaults)%5Bopt%5D%3B%0A%0A%20%20%20%20var%20input%20%3D%20elt(%22textarea%22%2C%20null%2C%20null%2C%20%22position%3A%20absolute%3B%20padding%3A%200%3B%20width%3A%201px%3B%20height%3A%201em%22)%3B%0A%20%20%20%20input.setAttribute(%22wrap%22%2C%20%22off%22)%3B%20input.setAttribute(%22autocorrect%22%2C%20%22off%22)%3B%20input.setAttribute(%22autocapitalize%22%2C%20%22off%22)%3B%0A%20%20%20%20%2F%2F%20Wraps%20and%20hides%20input%20textarea%0A%20%20%20%20var%20inputDiv%20%3D%20elt(%22div%22%2C%20%5Binput%5D%2C%20null%2C%20%22overflow%3A%20hidden%3B%20position%3A%20relative%3B%20width%3A%203px%3B%20height%3A%200px%3B%22)%3B%0A%20%20%20%20%2F%2F%20The%20empty%20scrollbar%20content%2C%20used%20solely%20for%20managing%20the%20scrollbar%20thumb.%0A%20%20%20%20var%20scrollbarInner%20%3D%20elt(%22div%22%2C%20null%2C%20%22CodeMirror-scrollbar-inner%22)%3B%0A%20%20%20%20%2F%2F%20The%20vertical%20scrollbar.%20Horizontal%20scrolling%20is%20handled%20by%20the%20scroller%20itself.%0A%20%20%20%20var%20scrollbar%20%3D%20elt(%22div%22%2C%20%5BscrollbarInner%5D%2C%20%22CodeMirror-scrollbar%22)%3B%0A%20%20%20%20%2F%2F%20DIVs%20containing%20the%20selection%20and%20the%20actual%20code%0A%20%20%20%20var%20lineDiv%20%3D%20elt(%22div%22)%2C%20selectionDiv%20%3D%20elt(%22div%22%2C%20null%2C%20null%2C%20%22position%3A%20relative%3B%20z-index%3A%20-1%22)%3B%0A%20%20%20%20%2F%2F%20Blinky%20cursor%2C%20and%20element%20used%20to%20ensure%20cursor%20fits%20at%20the%20end%20of%20a%20line%0A%20%20%20%20var%20cursor%20%3D%20elt(%22pre%22%2C%20%22%5Cu00a0%22%2C%20%22CodeMirror-cursor%22)%2C%20widthForcer%20%3D%20elt(%22pre%22%2C%20%22%5Cu00a0%22%2C%20%22CodeMirror-cursor%22%2C%20%22visibility%3A%20hidden%22)%3B%0A%20%20%20%20%2F%2F%20Used%20to%20measure%20text%20size%0A%20%20%20%20var%20measure%20%3D%20elt(%22div%22%2C%20null%2C%20null%2C%20%22position%3A%20absolute%3B%20width%3A%20100%25%3B%20height%3A%200px%3B%20overflow%3A%20hidden%3B%20visibility%3A%20hidden%3B%22)%3B%0A%20%20%20%20var%20lineSpace%20%3D%20elt(%22div%22%2C%20%5Bmeasure%2C%20cursor%2C%20widthForcer%2C%20selectionDiv%2C%20lineDiv%5D%2C%20null%2C%20%22position%3A%20relative%3B%20z-index%3A%200%22)%3B%0A%20%20%20%20var%20gutterText%20%3D%20elt(%22div%22%2C%20null%2C%20%22CodeMirror-gutter-text%22)%2C%20gutter%20%3D%20elt(%22div%22%2C%20%5BgutterText%5D%2C%20%22CodeMirror-gutter%22)%3B%0A%20%20%20%20%2F%2F%20Moved%20around%20its%20parent%20to%20cover%20visible%20view%0A%20%20%20%20var%20mover%20%3D%20elt(%22div%22%2C%20%5Bgutter%2C%20elt(%22div%22%2C%20%5BlineSpace%5D%2C%20%22CodeMirror-lines%22)%5D%2C%20null%2C%20%22position%3A%20relative%22)%3B%0A%20%20%20%20%2F%2F%20Set%20to%20the%20height%20of%20the%20text%2C%20causes%20scrolling%0A%20%20%20%20var%20sizer%20%3D%20elt(%22div%22%2C%20%5Bmover%5D%2C%20null%2C%20%22position%3A%20relative%22)%3B%0A%20%20%20%20%2F%2F%20Provides%20scrolling%0A%20%20%20%20var%20scroller%20%3D%20elt(%22div%22%2C%20%5Bsizer%5D%2C%20%22CodeMirror-scroll%22)%3B%0A%20%20%20%20scroller.setAttribute(%22tabIndex%22%2C%20%22-1%22)%3B%0A%20%20%20%20%2F%2F%20The%20element%20in%20which%20the%20editor%20lives.%0A%20%20%20%20var%20wrapper%20%3D%20elt(%22div%22%2C%20%5BinputDiv%2C%20scrollbar%2C%20scroller%5D%2C%20%22CodeMirror%22%20%2B%20(options.lineWrapping%20%3F%20%22%20CodeMirror-wrap%22%20%3A%20%22%22))%3B%0A%20%20%20%20if%20(place.appendChild)%20place.appendChild(wrapper)%3B%20else%20place(wrapper)%3B%0A%0A%20%20%20%20themeChanged()%3B%20keyMapChanged()%3B%0A%20%20%20%20%2F%2F%20Needed%20to%20hide%20big%20blue%20blinking%20cursor%20on%20Mobile%20Safari%0A%20%20%20%20if%20(ios)%20input.style.width%20%3D%20%220px%22%3B%0A%20%20%20%20if%20(!webkit)%20scroller.draggable%20%3D%20true%3B%0A%20%20%20%20lineSpace.style.outline%20%3D%20%22none%22%3B%0A%20%20%20%20if%20(options.tabindex%20!%3D%20null)%20input.tabIndex%20%3D%20options.tabindex%3B%0A%20%20%20%20if%20(options.autofocus)%20focusInput()%3B%0A%20%20%20%20if%20(!options.gutter%20%26%26%20!options.lineNumbers)%20gutter.style.display%20%3D%20%22none%22%3B%0A%20%20%20%20%2F%2F%20Needed%20to%20handle%20Tab%20key%20in%20KHTML%0A%20%20%20%20if%20(khtml)%20inputDiv.style.height%20%3D%20%221px%22%2C%20inputDiv.style.position%20%3D%20%22absolute%22%3B%0A%0A%20%20%20%20%2F%2F%20Check%20for%20OS%20X%20%3E%3D%2010.7.%20This%20has%20transparent%20scrollbars%2C%20so%20the%0A%20%20%20%20%2F%2F%20overlaying%20of%20one%20scrollbar%20with%20another%20won't%20work.%20This%20is%20a%0A%20%20%20%20%2F%2F%20temporary%20hack%20to%20simply%20turn%20off%20the%20overlay%20scrollbar.%20See%0A%20%20%20%20%2F%2F%20issue%20%23727.%0A%20%20%20%20if%20(mac_geLion)%20%7B%20scrollbar.style.zIndex%20%3D%20-2%3B%20scrollbar.style.visibility%20%3D%20%22hidden%22%3B%20%7D%0A%20%20%20%20%2F%2F%20Need%20to%20set%20a%20minimum%20width%20to%20see%20the%20scrollbar%20on%20IE7%20(but%20must%20not%20set%20it%20on%20IE8).%0A%20%20%20%20else%20if%20(ie_lt8)%20scrollbar.style.minWidth%20%3D%20%2218px%22%3B%0A%0A%20%20%20%20%2F%2F%20Delayed%20object%20wrap%20timeouts%2C%20making%20sure%20only%20one%20is%20active.%20blinker%20holds%20an%20interval.%0A%20%20%20%20var%20poll%20%3D%20new%20Delayed()%2C%20highlight%20%3D%20new%20Delayed()%2C%20blinker%3B%0A%0A%20%20%20%20%2F%2F%20mode%20holds%20a%20mode%20API%20object.%20doc%20is%20the%20tree%20of%20Line%20objects%2C%0A%20%20%20%20%2F%2F%20frontier%20is%20the%20point%20up%20to%20which%20the%20content%20has%20been%20parsed%2C%0A%20%20%20%20%2F%2F%20and%20history%20the%20undo%20history%20(instance%20of%20History%20constructor).%0A%20%20%20%20var%20mode%2C%20doc%20%3D%20new%20BranchChunk(%5Bnew%20LeafChunk(%5Bnew%20Line(%22%22)%5D)%5D)%2C%20frontier%20%3D%200%2C%20focused%3B%0A%20%20%20%20loadMode()%3B%0A%20%20%20%20%2F%2F%20The%20selection.%20These%20are%20always%20maintained%20to%20point%20at%20valid%0A%20%20%20%20%2F%2F%20positions.%20Inverted%20is%20used%20to%20remember%20that%20the%20user%20is%0A%20%20%20%20%2F%2F%20selecting%20bottom-to-top.%0A%20%20%20%20var%20sel%20%3D%20%7Bfrom%3A%20%7Bline%3A%200%2C%20ch%3A%200%7D%2C%20to%3A%20%7Bline%3A%200%2C%20ch%3A%200%7D%2C%20inverted%3A%20false%7D%3B%0A%20%20%20%20%2F%2F%20Selection-related%20flags.%20shiftSelecting%20obviously%20tracks%0A%20%20%20%20%2F%2F%20whether%20the%20user%20is%20holding%20shift.%0A%20%20%20%20var%20shiftSelecting%2C%20lastClick%2C%20lastDoubleClick%2C%20lastScrollTop%20%3D%200%2C%20draggingText%2C%0A%20%20%20%20%20%20%20%20overwrite%20%3D%20false%2C%20suppressEdits%20%3D%20false%3B%0A%20%20%20%20%2F%2F%20Variables%20used%20by%20startOperation%2FendOperation%20to%20track%20what%0A%20%20%20%20%2F%2F%20happened%20during%20the%20operation.%0A%20%20%20%20var%20updateInput%2C%20userSelChange%2C%20changes%2C%20textChanged%2C%20selectionChanged%2C%0A%20%20%20%20%20%20%20%20gutterDirty%2C%20callbacks%3B%0A%20%20%20%20%2F%2F%20Current%20visible%20range%20(may%20be%20bigger%20than%20the%20view%20window).%0A%20%20%20%20var%20displayOffset%20%3D%200%2C%20showingFrom%20%3D%200%2C%20showingTo%20%3D%200%2C%20lastSizeC%20%3D%200%3B%0A%20%20%20%20%2F%2F%20bracketHighlighted%20is%20used%20to%20remember%20that%20a%20bracket%20has%20been%0A%20%20%20%20%2F%2F%20marked.%0A%20%20%20%20var%20bracketHighlighted%3B%0A%20%20%20%20%2F%2F%20Tracks%20the%20maximum%20line%20length%20so%20that%20the%20horizontal%20scrollbar%0A%20%20%20%20%2F%2F%20can%20be%20kept%20static%20when%20scrolling.%0A%20%20%20%20var%20maxLine%20%3D%20getLine(0)%2C%20updateMaxLine%20%3D%20false%2C%20maxLineChanged%20%3D%20true%3B%0A%20%20%20%20var%20pollingFast%20%3D%20false%3B%20%2F%2F%20Ensures%20slowPoll%20doesn't%20cancel%20fastPoll%0A%20%20%20%20var%20goalColumn%20%3D%20null%3B%0A%0A%20%20%20%20%2F%2F%20Initialize%20the%20content.%0A%20%20%20%20operation(function()%7BsetValue(options.value%20%7C%7C%20%22%22)%3B%20updateInput%20%3D%20false%3B%7D)()%3B%0A%20%20%20%20var%20history%20%3D%20new%20History()%3B%0A%0A%20%20%20%20%2F%2F%20Register%20our%20event%20handlers.%0A%20%20%20%20connect(scroller%2C%20%22mousedown%22%2C%20operation(onMouseDown))%3B%0A%20%20%20%20connect(scroller%2C%20%22dblclick%22%2C%20operation(onDoubleClick))%3B%0A%20%20%20%20connect(lineSpace%2C%20%22selectstart%22%2C%20e_preventDefault)%3B%0A%20%20%20%20%2F%2F%20Gecko%20browsers%20fire%20contextmenu%20*after*%20opening%20the%20menu%2C%20at%0A%20%20%20%20%2F%2F%20which%20point%20we%20can't%20mess%20with%20it%20anymore.%20Context%20menu%20is%0A%20%20%20%20%2F%2F%20handled%20in%20onMouseDown%20for%20Gecko.%0A%20%20%20%20if%20(!gecko)%20connect(scroller%2C%20%22contextmenu%22%2C%20onContextMenu)%3B%0A%20%20%20%20connect(scroller%2C%20%22scroll%22%2C%20onScrollMain)%3B%0A%20%20%20%20connect(scrollbar%2C%20%22scroll%22%2C%20onScrollBar)%3B%0A%20%20%20%20connect(scrollbar%2C%20%22mousedown%22%2C%20function()%20%7Bif%20(focused)%20setTimeout(focusInput%2C%200)%3B%7D)%3B%0A%20%20%20%20var%20resizeHandler%20%3D%20connect(window%2C%20%22resize%22%2C%20function()%20%7B%0A%20%20%20%20%20%20if%20(wrapper.parentNode)%20updateDisplay(true)%3B%0A%20%20%20%20%20%20else%20resizeHandler()%3B%0A%20%20%20%20%7D%2C%20true)%3B%0A%20%20%20%20connect(input%2C%20%22keyup%22%2C%20operation(onKeyUp))%3B%0A%20%20%20%20connect(input%2C%20%22input%22%2C%20fastPoll)%3B%0A%20%20%20%20connect(input%2C%20%22keydown%22%2C%20operation(onKeyDown))%3B%0A%20%20%20%20connect(input%2C%20%22keypress%22%2C%20operation(onKeyPress))%3B%0A%20%20%20%20connect(input%2C%20%22focus%22%2C%20onFocus)%3B%0A%20%20%20%20connect(input%2C%20%22blur%22%2C%20onBlur)%3B%0A%0A%20%20%20%20function%20drag_(e)%20%7B%0A%20%20%20%20%20%20if%20(options.onDragEvent%20%26%26%20options.onDragEvent(instance%2C%20addStop(e)))%20return%3B%0A%20%20%20%20%20%20e_stop(e)%3B%0A%20%20%20%20%7D%0A%20%20%20%20if%20(options.dragDrop)%20%7B%0A%20%20%20%20%20%20connect(scroller%2C%20%22dragstart%22%2C%20onDragStart)%3B%0A%20%20%20%20%20%20connect(scroller%2C%20%22dragenter%22%2C%20drag_)%3B%0A%20%20%20%20%20%20connect(scroller%2C%20%22dragover%22%2C%20drag_)%3B%0A%20%20%20%20%20%20connect(scroller%2C%20%22drop%22%2C%20operation(onDrop))%3B%0A%20%20%20%20%7D%0A%20%20%20%20connect(scroller%2C%20%22paste%22%2C%20function()%7BfocusInput()%3B%20fastPoll()%3B%7D)%3B%0A%20%20%20%20connect(input%2C%20%22paste%22%2C%20fastPoll)%3B%0A%20%20%20%20connect(input%2C%20%22cut%22%2C%20operation(function()%7B%0A%20%20%20%20%20%20if%20(!options.readOnly)%20replaceSelection(%22%22)%3B%0A%20%20%20%20%7D))%3B%0A%0A%20%20%20%20%2F%2F%20Needed%20to%20handle%20Tab%20key%20in%20KHTML%0A%20%20%20%20if%20(khtml)%20connect(sizer%2C%20%22mouseup%22%2C%20function()%20%7B%0A%20%20%20%20%20%20%20%20if%20(document.activeElement%20%3D%3D%20input)%20input.blur()%3B%0A%20%20%20%20%20%20%20%20focusInput()%3B%0A%20%20%20%20%7D)%3B%0A%0A%20%20%20%20%2F%2F%20IE%20throws%20unspecified%20error%20in%20certain%20cases%2C%20when%0A%20%20%20%20%2F%2F%20trying%20to%20access%20activeElement%20before%20onload%0A%20%20%20%20var%20hasFocus%3B%20try%20%7B%20hasFocus%20%3D%20(document.activeElement%20%3D%3D%20input)%3B%20%7D%20catch(e)%20%7B%20%7D%0A%20%20%20%20if%20(hasFocus%20%7C%7C%20options.autofocus)%20setTimeout(onFocus%2C%2020)%3B%0A%20%20%20%20else%20onBlur()%3B%0A%0A%20%20%20%20function%20isLine(l)%20%7Breturn%20l%20%3E%3D%200%20%26%26%20l%20%3C%20doc.size%3B%7D%0A%20%20%20%20%2F%2F%20The%20instance%20object%20that%20we'll%20return.%20Mostly%20calls%20out%20to%0A%20%20%20%20%2F%2F%20local%20functions%20in%20the%20CodeMirror%20function.%20Some%20do%20some%20extra%0A%20%20%20%20%2F%2F%20range%20checking%20and%2For%20clipping.%20operation%20is%20used%20to%20wrap%20the%0A%20%20%20%20%2F%2F%20call%20so%20that%20changes%20it%20makes%20are%20tracked%2C%20and%20the%20display%20is%0A%20%20%20%20%2F%2F%20updated%20afterwards.%0A%20%20%20%20var%20instance%20%3D%20wrapper.CodeMirror%20%3D%20%7B%0A%20%20%20%20%20%20getValue%3A%20getValue%2C%0A%20%20%20%20%20%20setValue%3A%20operation(setValue)%2C%0A%20%20%20%20%20%20getSelection%3A%20getSelection%2C%0A%20%20%20%20%20%20replaceSelection%3A%20operation(replaceSelection)%2C%0A%20%20%20%20%20%20focus%3A%20function()%7Bwindow.focus()%3B%20focusInput()%3B%20onFocus()%3B%20fastPoll()%3B%7D%2C%0A%20%20%20%20%20%20setOption%3A%20function(option%2C%20value)%20%7B%0A%20%20%20%20%20%20%20%20var%20oldVal%20%3D%20options%5Boption%5D%3B%0A%20%20%20%20%20%20%20%20options%5Boption%5D%20%3D%20value%3B%0A%20%20%20%20%20%20%20%20if%20(option%20%3D%3D%20%22mode%22%20%7C%7C%20option%20%3D%3D%20%22indentUnit%22)%20loadMode()%3B%0A%20%20%20%20%20%20%20%20else%20if%20(option%20%3D%3D%20%22readOnly%22%20%26%26%20value%20%3D%3D%20%22nocursor%22)%20%7BonBlur()%3B%20input.blur()%3B%7D%0A%20%20%20%20%20%20%20%20else%20if%20(option%20%3D%3D%20%22readOnly%22%20%26%26%20!value)%20%7BresetInput(true)%3B%7D%0A%20%20%20%20%20%20%20%20else%20if%20(option%20%3D%3D%20%22theme%22)%20themeChanged()%3B%0A%20%20%20%20%20%20%20%20else%20if%20(option%20%3D%3D%20%22lineWrapping%22%20%26%26%20oldVal%20!%3D%20value)%20operation(wrappingChanged)()%3B%0A%20%20%20%20%20%20%20%20else%20if%20(option%20%3D%3D%20%22tabSize%22)%20updateDisplay(true)%3B%0A%20%20%20%20%20%20%20%20else%20if%20(option%20%3D%3D%20%22keyMap%22)%20keyMapChanged()%3B%0A%20%20%20%20%20%20%20%20if%20(option%20%3D%3D%20%22lineNumbers%22%20%7C%7C%20option%20%3D%3D%20%22gutter%22%20%7C%7C%20option%20%3D%3D%20%22firstLineNumber%22%20%7C%7C%0A%20%20%20%20%20%20%20%20%20%20%20%20option%20%3D%3D%20%22theme%22%20%7C%7C%20option%20%3D%3D%20%22lineNumberFormatter%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20gutterChanged()%3B%0A%20%20%20%20%20%20%20%20%20%20updateDisplay(true)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20getOption%3A%20function(option)%20%7Breturn%20options%5Boption%5D%3B%7D%2C%0A%20%20%20%20%20%20getMode%3A%20function()%20%7Breturn%20mode%3B%7D%2C%0A%20%20%20%20%20%20undo%3A%20operation(undo)%2C%0A%20%20%20%20%20%20redo%3A%20operation(redo)%2C%0A%20%20%20%20%20%20indentLine%3A%20operation(function(n%2C%20dir)%20%7B%0A%20%20%20%20%20%20%20%20if%20(typeof%20dir%20!%3D%20%22string%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(dir%20%3D%3D%20null)%20dir%20%3D%20options.smartIndent%20%3F%20%22smart%22%20%3A%20%22prev%22%3B%0A%20%20%20%20%20%20%20%20%20%20else%20dir%20%3D%20dir%20%3F%20%22add%22%20%3A%20%22subtract%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if%20(isLine(n))%20indentLine(n%2C%20dir)%3B%0A%20%20%20%20%20%20%7D)%2C%0A%20%20%20%20%20%20indentSelection%3A%20operation(indentSelected)%2C%0A%20%20%20%20%20%20historySize%3A%20function()%20%7Breturn%20%7Bundo%3A%20history.done.length%2C%20redo%3A%20history.undone.length%7D%3B%7D%2C%0A%20%20%20%20%20%20clearHistory%3A%20function()%20%7Bhistory%20%3D%20new%20History()%3B%7D%2C%0A%20%20%20%20%20%20setHistory%3A%20function(histData)%20%7B%0A%20%20%20%20%20%20%20%20history%20%3D%20new%20History()%3B%0A%20%20%20%20%20%20%20%20history.done%20%3D%20histData.done%3B%0A%20%20%20%20%20%20%20%20history.undone%20%3D%20histData.undone%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20getHistory%3A%20function()%20%7B%0A%20%20%20%20%20%20%20%20function%20cp(arr)%20%7B%0A%20%20%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20nw%20%3D%20%5B%5D%2C%20nwelt%3B%20i%20%3C%20arr.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20nw.push(nwelt%20%3D%20%5B%5D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20(var%20j%20%3D%200%2C%20elt%20%3D%20arr%5Bi%5D%3B%20j%20%3C%20elt.length%3B%20%2B%2Bj)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20old%20%3D%20%5B%5D%2C%20cur%20%3D%20elt%5Bj%5D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20nwelt.push(%7Bstart%3A%20cur.start%2C%20added%3A%20cur.added%2C%20old%3A%20old%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20(var%20k%20%3D%200%3B%20k%20%3C%20cur.old.length%3B%20%2B%2Bk)%20old.push(hlText(cur.old%5Bk%5D))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20return%20nw%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20return%20%7Bdone%3A%20cp(history.done)%2C%20undone%3A%20cp(history.undone)%7D%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20matchBrackets%3A%20operation(function()%7BmatchBrackets(true)%3B%7D)%2C%0A%20%20%20%20%20%20getTokenAt%3A%20operation(function(pos)%20%7B%0A%20%20%20%20%20%20%20%20pos%20%3D%20clipPos(pos)%3B%0A%20%20%20%20%20%20%20%20return%20getLine(pos.line).getTokenAt(mode%2C%20getStateBefore(pos.line)%2C%20options.tabSize%2C%20pos.ch)%3B%0A%20%20%20%20%20%20%7D)%2C%0A%20%20%20%20%20%20getStateAfter%3A%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20line%20%3D%20clipLine(line%20%3D%3D%20null%20%3F%20doc.size%20-%201%3A%20line)%3B%0A%20%20%20%20%20%20%20%20return%20getStateBefore(line%20%2B%201)%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20cursorCoords%3A%20function(start%2C%20mode)%20%7B%0A%20%20%20%20%20%20%20%20if%20(start%20%3D%3D%20null)%20start%20%3D%20sel.inverted%3B%0A%20%20%20%20%20%20%20%20return%20this.charCoords(start%20%3F%20sel.from%20%3A%20sel.to%2C%20mode)%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20charCoords%3A%20function(pos%2C%20mode)%20%7B%0A%20%20%20%20%20%20%20%20pos%20%3D%20clipPos(pos)%3B%0A%20%20%20%20%20%20%20%20if%20(mode%20%3D%3D%20%22local%22)%20return%20localCoords(pos%2C%20false)%3B%0A%20%20%20%20%20%20%20%20if%20(mode%20%3D%3D%20%22div%22)%20return%20localCoords(pos%2C%20true)%3B%0A%20%20%20%20%20%20%20%20return%20pageCoords(pos)%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20coordsChar%3A%20function(coords)%20%7B%0A%20%20%20%20%20%20%20%20var%20off%20%3D%20eltOffset(lineSpace)%3B%0A%20%20%20%20%20%20%20%20return%20coordsChar(coords.x%20-%20off.left%2C%20coords.y%20-%20off.top)%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20markText%3A%20operation(markText)%2C%0A%20%20%20%20%20%20setBookmark%3A%20setBookmark%2C%0A%20%20%20%20%20%20findMarksAt%3A%20findMarksAt%2C%0A%20%20%20%20%20%20setMarker%3A%20operation(addGutterMarker)%2C%0A%20%20%20%20%20%20clearMarker%3A%20operation(removeGutterMarker)%2C%0A%20%20%20%20%20%20setLineClass%3A%20operation(setLineClass)%2C%0A%20%20%20%20%20%20hideLine%3A%20operation(function(h)%20%7Breturn%20setLineHidden(h%2C%20true)%3B%7D)%2C%0A%20%20%20%20%20%20showLine%3A%20operation(function(h)%20%7Breturn%20setLineHidden(h%2C%20false)%3B%7D)%2C%0A%20%20%20%20%20%20onDeleteLine%3A%20function(line%2C%20f)%20%7B%0A%20%20%20%20%20%20%20%20if%20(typeof%20line%20%3D%3D%20%22number%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(!isLine(line))%20return%20null%3B%0A%20%20%20%20%20%20%20%20%20%20line%20%3D%20getLine(line)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20(line.handlers%20%7C%7C%20(line.handlers%20%3D%20%5B%5D)).push(f)%3B%0A%20%20%20%20%20%20%20%20return%20line%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20lineInfo%3A%20lineInfo%2C%0A%20%20%20%20%20%20getViewport%3A%20function()%20%7B%20return%20%7Bfrom%3A%20showingFrom%2C%20to%3A%20showingTo%7D%3B%7D%2C%0A%20%20%20%20%20%20addWidget%3A%20function(pos%2C%20node%2C%20scroll%2C%20vert%2C%20horiz)%20%7B%0A%20%20%20%20%20%20%20%20pos%20%3D%20localCoords(clipPos(pos))%3B%0A%20%20%20%20%20%20%20%20var%20top%20%3D%20pos.yBot%2C%20left%20%3D%20pos.x%3B%0A%20%20%20%20%20%20%20%20node.style.position%20%3D%20%22absolute%22%3B%0A%20%20%20%20%20%20%20%20sizer.appendChild(node)%3B%0A%20%20%20%20%20%20%20%20if%20(vert%20%3D%3D%20%22over%22)%20top%20%3D%20pos.y%3B%0A%20%20%20%20%20%20%20%20else%20if%20(vert%20%3D%3D%20%22near%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20vspace%20%3D%20Math.max(scroller.offsetHeight%2C%20doc.height%20*%20textHeight())%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20hspace%20%3D%20Math.max(sizer.clientWidth%2C%20lineSpace.clientWidth)%20-%20paddingLeft()%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(pos.yBot%20%2B%20node.offsetHeight%20%3E%20vspace%20%26%26%20pos.y%20%3E%20node.offsetHeight)%0A%20%20%20%20%20%20%20%20%20%20%20%20top%20%3D%20pos.y%20-%20node.offsetHeight%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(left%20%2B%20node.offsetWidth%20%3E%20hspace)%0A%20%20%20%20%20%20%20%20%20%20%20%20left%20%3D%20hspace%20-%20node.offsetWidth%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20node.style.top%20%3D%20(top%20%2B%20paddingTop())%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20node.style.left%20%3D%20node.style.right%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20if%20(horiz%20%3D%3D%20%22right%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20left%20%3D%20sizer.clientWidth%20-%20node.offsetWidth%3B%0A%20%20%20%20%20%20%20%20%20%20node.style.right%20%3D%20%220px%22%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(horiz%20%3D%3D%20%22left%22)%20left%20%3D%200%3B%0A%20%20%20%20%20%20%20%20%20%20else%20if%20(horiz%20%3D%3D%20%22middle%22)%20left%20%3D%20(sizer.clientWidth%20-%20node.offsetWidth)%20%2F%202%3B%0A%20%20%20%20%20%20%20%20%20%20node.style.left%20%3D%20(left%20%2B%20paddingLeft())%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if%20(scroll)%0A%20%20%20%20%20%20%20%20%20%20scrollIntoView(left%2C%20top%2C%20left%20%2B%20node.offsetWidth%2C%20top%20%2B%20node.offsetHeight)%3B%0A%20%20%20%20%20%20%7D%2C%0A%0A%20%20%20%20%20%20lineCount%3A%20function()%20%7Breturn%20doc.size%3B%7D%2C%0A%20%20%20%20%20%20clipPos%3A%20clipPos%2C%0A%20%20%20%20%20%20getCursor%3A%20function(start)%20%7B%0A%20%20%20%20%20%20%20%20if%20(start%20%3D%3D%20null)%20start%20%3D%20sel.inverted%3B%0A%20%20%20%20%20%20%20%20return%20copyPos(start%20%3F%20sel.from%20%3A%20sel.to)%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20somethingSelected%3A%20function()%20%7Breturn%20!posEq(sel.from%2C%20sel.to)%3B%7D%2C%0A%20%20%20%20%20%20setCursor%3A%20operation(function(line%2C%20ch%2C%20user)%20%7B%0A%20%20%20%20%20%20%20%20if%20(ch%20%3D%3D%20null%20%26%26%20typeof%20line.line%20%3D%3D%20%22number%22)%20setCursor(line.line%2C%20line.ch%2C%20user)%3B%0A%20%20%20%20%20%20%20%20else%20setCursor(line%2C%20ch%2C%20user)%3B%0A%20%20%20%20%20%20%7D)%2C%0A%20%20%20%20%20%20setSelection%3A%20operation(function(from%2C%20to%2C%20user)%20%7B%0A%20%20%20%20%20%20%20%20(user%20%3F%20setSelectionUser%20%3A%20setSelection)(clipPos(from)%2C%20clipPos(to%20%7C%7C%20from))%3B%0A%20%20%20%20%20%20%7D)%2C%0A%20%20%20%20%20%20getLine%3A%20function(line)%20%7Bif%20(isLine(line))%20return%20getLine(line).text%3B%7D%2C%0A%20%20%20%20%20%20getLineHandle%3A%20function(line)%20%7Bif%20(isLine(line))%20return%20getLine(line)%3B%7D%2C%0A%20%20%20%20%20%20setLine%3A%20operation(function(line%2C%20text)%20%7B%0A%20%20%20%20%20%20%20%20if%20(isLine(line))%20replaceRange(text%2C%20%7Bline%3A%20line%2C%20ch%3A%200%7D%2C%20%7Bline%3A%20line%2C%20ch%3A%20getLine(line).text.length%7D)%3B%0A%20%20%20%20%20%20%7D)%2C%0A%20%20%20%20%20%20removeLine%3A%20operation(function(line)%20%7B%0A%20%20%20%20%20%20%20%20if%20(isLine(line))%20replaceRange(%22%22%2C%20%7Bline%3A%20line%2C%20ch%3A%200%7D%2C%20clipPos(%7Bline%3A%20line%2B1%2C%20ch%3A%200%7D))%3B%0A%20%20%20%20%20%20%7D)%2C%0A%20%20%20%20%20%20replaceRange%3A%20operation(replaceRange)%2C%0A%20%20%20%20%20%20getRange%3A%20function(from%2C%20to%2C%20lineSep)%20%7Breturn%20getRange(clipPos(from)%2C%20clipPos(to)%2C%20lineSep)%3B%7D%2C%0A%0A%20%20%20%20%20%20triggerOnKeyDown%3A%20operation(onKeyDown)%2C%0A%20%20%20%20%20%20execCommand%3A%20function(cmd)%20%7Breturn%20commands%5Bcmd%5D(instance)%3B%7D%2C%0A%20%20%20%20%20%20%2F%2F%20Stuff%20used%20by%20commands%2C%20probably%20not%20much%20use%20to%20outside%20code.%0A%20%20%20%20%20%20moveH%3A%20operation(moveH)%2C%0A%20%20%20%20%20%20deleteH%3A%20operation(deleteH)%2C%0A%20%20%20%20%20%20moveV%3A%20operation(moveV)%2C%0A%20%20%20%20%20%20toggleOverwrite%3A%20function()%20%7B%0A%20%20%20%20%20%20%20%20if(overwrite)%7B%0A%20%20%20%20%20%20%20%20%20%20overwrite%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20cursor.className%20%3D%20cursor.className.replace(%22%20CodeMirror-overwrite%22%2C%20%22%22)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20overwrite%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%20%20cursor.className%20%2B%3D%20%22%20CodeMirror-overwrite%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%2C%0A%0A%20%20%20%20%20%20posFromIndex%3A%20function(off)%20%7B%0A%20%20%20%20%20%20%20%20var%20lineNo%20%3D%200%2C%20ch%3B%0A%20%20%20%20%20%20%20%20doc.iter(0%2C%20doc.size%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20sz%20%3D%20line.text.length%20%2B%201%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(sz%20%3E%20off)%20%7B%20ch%20%3D%20off%3B%20return%20true%3B%20%7D%0A%20%20%20%20%20%20%20%20%20%20off%20-%3D%20sz%3B%0A%20%20%20%20%20%20%20%20%20%20%2B%2BlineNo%3B%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20return%20clipPos(%7Bline%3A%20lineNo%2C%20ch%3A%20ch%7D)%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20indexFromPos%3A%20function%20(coords)%20%7B%0A%20%20%20%20%20%20%20%20if%20(coords.line%20%3C%200%20%7C%7C%20coords.ch%20%3C%200)%20return%200%3B%0A%20%20%20%20%20%20%20%20var%20index%20%3D%20coords.ch%3B%0A%20%20%20%20%20%20%20%20doc.iter(0%2C%20coords.line%2C%20function%20(line)%20%7B%0A%20%20%20%20%20%20%20%20%20%20index%20%2B%3D%20line.text.length%20%2B%201%3B%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20return%20index%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20scrollTo%3A%20function(x%2C%20y)%20%7B%0A%20%20%20%20%20%20%20%20if%20(x%20!%3D%20null)%20scroller.scrollLeft%20%3D%20x%3B%0A%20%20%20%20%20%20%20%20if%20(y%20!%3D%20null)%20scrollbar.scrollTop%20%3D%20scroller.scrollTop%20%3D%20y%3B%0A%20%20%20%20%20%20%20%20updateDisplay(%5B%5D)%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20getScrollInfo%3A%20function()%20%7B%0A%20%20%20%20%20%20%20%20return%20%7Bx%3A%20scroller.scrollLeft%2C%20y%3A%20scrollbar.scrollTop%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20height%3A%20scrollbar.scrollHeight%2C%20width%3A%20scroller.scrollWidth%7D%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20setSize%3A%20function(width%2C%20height)%20%7B%0A%20%20%20%20%20%20%20%20function%20interpret(val)%20%7B%0A%20%20%20%20%20%20%20%20%20%20val%20%3D%20String(val)%3B%0A%20%20%20%20%20%20%20%20%20%20return%20%2F%5E%5Cd%2B%24%2F.test(val)%20%3F%20val%20%2B%20%22px%22%20%3A%20val%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if%20(width%20!%3D%20null)%20wrapper.style.width%20%3D%20interpret(width)%3B%0A%20%20%20%20%20%20%20%20if%20(height%20!%3D%20null)%20scroller.style.height%20%3D%20interpret(height)%3B%0A%20%20%20%20%20%20%20%20instance.refresh()%3B%0A%20%20%20%20%20%20%7D%2C%0A%0A%20%20%20%20%20%20operation%3A%20function(f)%7Breturn%20operation(f)()%3B%7D%2C%0A%20%20%20%20%20%20compoundChange%3A%20function(f)%7Breturn%20compoundChange(f)%3B%7D%2C%0A%20%20%20%20%20%20refresh%3A%20function()%7B%0A%20%20%20%20%20%20%20%20updateDisplay(true%2C%20null%2C%20lastScrollTop)%3B%0A%20%20%20%20%20%20%20%20if%20(scrollbar.scrollHeight%20%3E%20lastScrollTop)%0A%20%20%20%20%20%20%20%20%20%20scrollbar.scrollTop%20%3D%20lastScrollTop%3B%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20getInputField%3A%20function()%7Breturn%20input%3B%7D%2C%0A%20%20%20%20%20%20getWrapperElement%3A%20function()%7Breturn%20wrapper%3B%7D%2C%0A%20%20%20%20%20%20getScrollerElement%3A%20function()%7Breturn%20scroller%3B%7D%2C%0A%20%20%20%20%20%20getGutterElement%3A%20function()%7Breturn%20gutter%3B%7D%0A%20%20%20%20%7D%3B%0A%0A%20%20%20%20function%20getLine(n)%20%7B%20return%20getLineAt(doc%2C%20n)%3B%20%7D%0A%20%20%20%20function%20updateLineHeight(line%2C%20height)%20%7B%0A%20%20%20%20%20%20gutterDirty%20%3D%20true%3B%0A%20%20%20%20%20%20var%20diff%20%3D%20height%20-%20line.height%3B%0A%20%20%20%20%20%20for%20(var%20n%20%3D%20line%3B%20n%3B%20n%20%3D%20n.parent)%20n.height%20%2B%3D%20diff%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20lineContent(line%2C%20wrapAt)%20%7B%0A%20%20%20%20%20%20if%20(!line.styles)%0A%20%20%20%20%20%20%20%20line.highlight(mode%2C%20line.stateAfter%20%3D%20getStateBefore(lineNo(line))%2C%20options.tabSize)%3B%0A%20%20%20%20%20%20return%20line.getContent(options.tabSize%2C%20wrapAt%2C%20options.lineWrapping)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20setValue(code)%20%7B%0A%20%20%20%20%20%20var%20top%20%3D%20%7Bline%3A%200%2C%20ch%3A%200%7D%3B%0A%20%20%20%20%20%20updateLines(top%2C%20%7Bline%3A%20doc.size%20-%201%2C%20ch%3A%20getLine(doc.size-1).text.length%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20splitLines(code)%2C%20top%2C%20top)%3B%0A%20%20%20%20%20%20updateInput%20%3D%20true%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20getValue(lineSep)%20%7B%0A%20%20%20%20%20%20var%20text%20%3D%20%5B%5D%3B%0A%20%20%20%20%20%20doc.iter(0%2C%20doc.size%2C%20function(line)%20%7B%20text.push(line.text)%3B%20%7D)%3B%0A%20%20%20%20%20%20return%20text.join(lineSep%20%7C%7C%20%22%5Cn%22)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20onScrollBar(e)%20%7B%0A%20%20%20%20%20%20if%20(scrollbar.scrollTop%20!%3D%20lastScrollTop)%20%7B%0A%20%20%20%20%20%20%20%20lastScrollTop%20%3D%20scroller.scrollTop%20%3D%20scrollbar.scrollTop%3B%0A%20%20%20%20%20%20%20%20updateDisplay(%5B%5D)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20onScrollMain(e)%20%7B%0A%20%20%20%20%20%20if%20(options.fixedGutter%20%26%26%20gutter.style.left%20!%3D%20scroller.scrollLeft%20%2B%20%22px%22)%0A%20%20%20%20%20%20%20%20gutter.style.left%20%3D%20scroller.scrollLeft%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20if%20(scroller.scrollTop%20!%3D%20lastScrollTop)%20%7B%0A%20%20%20%20%20%20%20%20lastScrollTop%20%3D%20scroller.scrollTop%3B%0A%20%20%20%20%20%20%20%20if%20(scrollbar.scrollTop%20!%3D%20lastScrollTop)%0A%20%20%20%20%20%20%20%20%20%20scrollbar.scrollTop%20%3D%20lastScrollTop%3B%0A%20%20%20%20%20%20%20%20updateDisplay(%5B%5D)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(options.onScroll)%20options.onScroll(instance)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20onMouseDown(e)%20%7B%0A%20%20%20%20%20%20setShift(e_prop(e%2C%20%22shiftKey%22))%3B%0A%20%20%20%20%20%20%2F%2F%20Check%20whether%20this%20is%20a%20click%20in%20a%20widget%0A%20%20%20%20%20%20for%20(var%20n%20%3D%20e_target(e)%3B%20n%20!%3D%20wrapper%3B%20n%20%3D%20n.parentNode)%0A%20%20%20%20%20%20%20%20if%20(n.parentNode%20%3D%3D%20sizer%20%26%26%20n%20!%3D%20mover)%20return%3B%0A%0A%20%20%20%20%20%20%2F%2F%20See%20if%20this%20is%20a%20click%20in%20the%20gutter%0A%20%20%20%20%20%20for%20(var%20n%20%3D%20e_target(e)%3B%20n%20!%3D%20wrapper%3B%20n%20%3D%20n.parentNode)%0A%20%20%20%20%20%20%20%20if%20(n.parentNode%20%3D%3D%20gutterText)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(options.onGutterClick)%0A%20%20%20%20%20%20%20%20%20%20%20%20options.onGutterClick(instance%2C%20indexOf(gutterText.childNodes%2C%20n)%20%2B%20showingFrom%2C%20e)%3B%0A%20%20%20%20%20%20%20%20%20%20return%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20var%20start%20%3D%20posFromMouse(e)%3B%0A%0A%20%20%20%20%20%20switch%20(e_button(e))%20%7B%0A%20%20%20%20%20%20case%203%3A%0A%20%20%20%20%20%20%20%20if%20(gecko)%20onContextMenu(e)%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20case%202%3A%0A%20%20%20%20%20%20%20%20if%20(start)%20setCursor(start.line%2C%20start.ch%2C%20true)%3B%0A%20%20%20%20%20%20%20%20setTimeout(focusInput%2C%2020)%3B%0A%20%20%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%2F%2F%20For%20button%201%2C%20if%20it%20was%20clicked%20inside%20the%20editor%0A%20%20%20%20%20%20%2F%2F%20(posFromMouse%20returning%20non-null)%2C%20we%20have%20to%20adjust%20the%0A%20%20%20%20%20%20%2F%2F%20selection.%0A%20%20%20%20%20%20if%20(!start)%20%7Bif%20(e_target(e)%20%3D%3D%20scroller)%20e_preventDefault(e)%3B%20return%3B%7D%0A%0A%20%20%20%20%20%20if%20(!focused)%20onFocus()%3B%0A%0A%20%20%20%20%20%20var%20now%20%3D%20%2Bnew%20Date%2C%20type%20%3D%20%22single%22%3B%0A%20%20%20%20%20%20if%20(lastDoubleClick%20%26%26%20lastDoubleClick.time%20%3E%20now%20-%20400%20%26%26%20posEq(lastDoubleClick.pos%2C%20start))%20%7B%0A%20%20%20%20%20%20%20%20type%20%3D%20%22triple%22%3B%0A%20%20%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20%20%20setTimeout(focusInput%2C%2020)%3B%0A%20%20%20%20%20%20%20%20selectLine(start.line)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(lastClick%20%26%26%20lastClick.time%20%3E%20now%20-%20400%20%26%26%20posEq(lastClick.pos%2C%20start))%20%7B%0A%20%20%20%20%20%20%20%20type%20%3D%20%22double%22%3B%0A%20%20%20%20%20%20%20%20lastDoubleClick%20%3D%20%7Btime%3A%20now%2C%20pos%3A%20start%7D%3B%0A%20%20%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20%20%20var%20word%20%3D%20findWordAt(start)%3B%0A%20%20%20%20%20%20%20%20setSelectionUser(word.from%2C%20word.to)%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%20lastClick%20%3D%20%7Btime%3A%20now%2C%20pos%3A%20start%7D%3B%20%7D%0A%0A%20%20%20%20%20%20function%20dragEnd(e2)%20%7B%0A%20%20%20%20%20%20%20%20if%20(webkit)%20scroller.draggable%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20draggingText%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20up()%3B%20drop()%3B%0A%20%20%20%20%20%20%20%20if%20(Math.abs(e.clientX%20-%20e2.clientX)%20%2B%20Math.abs(e.clientY%20-%20e2.clientY)%20%3C%2010)%20%7B%0A%20%20%20%20%20%20%20%20%20%20e_preventDefault(e2)%3B%0A%20%20%20%20%20%20%20%20%20%20setCursor(start.line%2C%20start.ch%2C%20true)%3B%0A%20%20%20%20%20%20%20%20%20%20focusInput()%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20last%20%3D%20start%2C%20going%3B%0A%20%20%20%20%20%20if%20(options.dragDrop%20%26%26%20dragAndDrop%20%26%26%20!options.readOnly%20%26%26%20!posEq(sel.from%2C%20sel.to)%20%26%26%0A%20%20%20%20%20%20%20%20%20%20!posLess(start%2C%20sel.from)%20%26%26%20!posLess(sel.to%2C%20start)%20%26%26%20type%20%3D%3D%20%22single%22)%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20Let%20the%20drag%20handler%20handle%20this.%0A%20%20%20%20%20%20%20%20if%20(webkit)%20scroller.draggable%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20var%20up%20%3D%20connect(document%2C%20%22mouseup%22%2C%20operation(dragEnd)%2C%20true)%3B%0A%20%20%20%20%20%20%20%20var%20drop%20%3D%20connect(scroller%2C%20%22drop%22%2C%20operation(dragEnd)%2C%20true)%3B%0A%20%20%20%20%20%20%20%20draggingText%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20IE's%20approach%20to%20draggable%0A%20%20%20%20%20%20%20%20if%20(scroller.dragDrop)%20scroller.dragDrop()%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20%22single%22)%20setCursor(start.line%2C%20start.ch%2C%20true)%3B%0A%0A%20%20%20%20%20%20var%20startstart%20%3D%20sel.from%2C%20startend%20%3D%20sel.to%3B%0A%0A%20%20%20%20%20%20function%20doSelect(cur)%20%7B%0A%20%20%20%20%20%20%20%20if%20(type%20%3D%3D%20%22single%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20setSelectionUser(start%2C%20cur)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(type%20%3D%3D%20%22double%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20word%20%3D%20findWordAt(cur)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(posLess(cur%2C%20startstart))%20setSelectionUser(word.from%2C%20startend)%3B%0A%20%20%20%20%20%20%20%20%20%20else%20setSelectionUser(startstart%2C%20word.to)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(type%20%3D%3D%20%22triple%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(posLess(cur%2C%20startstart))%20setSelectionUser(startend%2C%20clipPos(%7Bline%3A%20cur.line%2C%20ch%3A%200%7D))%3B%0A%20%20%20%20%20%20%20%20%20%20else%20setSelectionUser(startstart%2C%20clipPos(%7Bline%3A%20cur.line%20%2B%201%2C%20ch%3A%200%7D))%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20function%20extend(e)%20%7B%0A%20%20%20%20%20%20%20%20var%20cur%20%3D%20posFromMouse(e%2C%20true)%3B%0A%20%20%20%20%20%20%20%20if%20(cur%20%26%26%20!posEq(cur%2C%20last))%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(!focused)%20onFocus()%3B%0A%20%20%20%20%20%20%20%20%20%20last%20%3D%20cur%3B%0A%20%20%20%20%20%20%20%20%20%20doSelect(cur)%3B%0A%20%20%20%20%20%20%20%20%20%20updateInput%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20var%20visible%20%3D%20visibleLines()%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(cur.line%20%3E%3D%20visible.to%20%7C%7C%20cur.line%20%3C%20visible.from)%0A%20%20%20%20%20%20%20%20%20%20%20%20going%20%3D%20setTimeout(operation(function()%7Bextend(e)%3B%7D)%2C%20150)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20function%20done(e)%20%7B%0A%20%20%20%20%20%20%20%20clearTimeout(going)%3B%0A%20%20%20%20%20%20%20%20var%20cur%20%3D%20posFromMouse(e)%3B%0A%20%20%20%20%20%20%20%20if%20(cur)%20doSelect(cur)%3B%0A%20%20%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20%20%20focusInput()%3B%0A%20%20%20%20%20%20%20%20updateInput%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20move()%3B%20up()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20move%20%3D%20connect(document%2C%20%22mousemove%22%2C%20operation(function(e)%20%7B%0A%20%20%20%20%20%20%20%20clearTimeout(going)%3B%0A%20%20%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20%20%20if%20(!ie%20%26%26%20!e_button(e))%20done(e)%3B%0A%20%20%20%20%20%20%20%20else%20extend(e)%3B%0A%20%20%20%20%20%20%7D)%2C%20true)%3B%0A%20%20%20%20%20%20var%20up%20%3D%20connect(document%2C%20%22mouseup%22%2C%20operation(done)%2C%20true)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20onDoubleClick(e)%20%7B%0A%20%20%20%20%20%20for%20(var%20n%20%3D%20e_target(e)%3B%20n%20!%3D%20wrapper%3B%20n%20%3D%20n.parentNode)%0A%20%20%20%20%20%20%20%20if%20(n.parentNode%20%3D%3D%20gutterText)%20return%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20onDrop(e)%20%7B%0A%20%20%20%20%20%20if%20(options.onDragEvent%20%26%26%20options.onDragEvent(instance%2C%20addStop(e)))%20return%3B%0A%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20var%20pos%20%3D%20posFromMouse(e%2C%20true)%2C%20files%20%3D%20e.dataTransfer.files%3B%0A%20%20%20%20%20%20if%20(!pos%20%7C%7C%20options.readOnly)%20return%3B%0A%20%20%20%20%20%20if%20(files%20%26%26%20files.length%20%26%26%20window.FileReader%20%26%26%20window.File)%20%7B%0A%20%20%20%20%20%20%20%20var%20n%20%3D%20files.length%2C%20text%20%3D%20Array(n)%2C%20read%20%3D%200%3B%0A%20%20%20%20%20%20%20%20var%20loadFile%20%3D%20function(file%2C%20i)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20reader%20%3D%20new%20FileReader%3B%0A%20%20%20%20%20%20%20%20%20%20reader.onload%20%3D%20function()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20text%5Bi%5D%20%3D%20reader.result%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(%2B%2Bread%20%3D%3D%20n)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20pos%20%3D%20clipPos(pos)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20operation(function()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20end%20%3D%20replaceRange(text.join(%22%22)%2C%20pos%2C%20pos)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20setSelectionUser(pos%2C%20end)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%20%20%20%20reader.readAsText(file)%3B%0A%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20n%3B%20%2B%2Bi)%20loadFile(files%5Bi%5D%2C%20i)%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20Don't%20do%20a%20replace%20if%20the%20drop%20happened%20inside%20of%20the%20selected%20text.%0A%20%20%20%20%20%20%20%20if%20(draggingText%20%26%26%20!(posLess(pos%2C%20sel.from)%20%7C%7C%20posLess(sel.to%2C%20pos)))%20return%3B%0A%20%20%20%20%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20text%20%3D%20e.dataTransfer.getData(%22Text%22)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(text)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20compoundChange(function()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20curFrom%20%3D%20sel.from%2C%20curTo%20%3D%20sel.to%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20setSelectionUser(pos%2C%20pos)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(draggingText)%20replaceRange(%22%22%2C%20curFrom%2C%20curTo)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20replaceSelection(text)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20focusInput()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20catch(e)%7B%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20function%20onDragStart(e)%20%7B%0A%20%20%20%20%20%20var%20txt%20%3D%20getSelection()%3B%0A%20%20%20%20%20%20e.dataTransfer.setData(%22Text%22%2C%20txt)%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Use%20dummy%20image%20instead%20of%20default%20browsers%20image.%0A%20%20%20%20%20%20if%20(e.dataTransfer.setDragImage)%0A%20%20%20%20%20%20%20%20e.dataTransfer.setDragImage(elt('img')%2C%200%2C%200)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20doHandleBinding(bound%2C%20dropShift)%20%7B%0A%20%20%20%20%20%20if%20(typeof%20bound%20%3D%3D%20%22string%22)%20%7B%0A%20%20%20%20%20%20%20%20bound%20%3D%20commands%5Bbound%5D%3B%0A%20%20%20%20%20%20%20%20if%20(!bound)%20return%20false%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20prevShift%20%3D%20shiftSelecting%3B%0A%20%20%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%20%20if%20(options.readOnly)%20suppressEdits%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20if%20(dropShift)%20shiftSelecting%20%3D%20null%3B%0A%20%20%20%20%20%20%20%20bound(instance)%3B%0A%20%20%20%20%20%20%7D%20catch(e)%20%7B%0A%20%20%20%20%20%20%20%20if%20(e%20!%3D%20Pass)%20throw%20e%3B%0A%20%20%20%20%20%20%20%20return%20false%3B%0A%20%20%20%20%20%20%7D%20finally%20%7B%0A%20%20%20%20%20%20%20%20shiftSelecting%20%3D%20prevShift%3B%0A%20%20%20%20%20%20%20%20suppressEdits%20%3D%20false%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%7D%0A%20%20%20%20var%20maybeTransition%3B%0A%20%20%20%20function%20handleKeyBinding(e)%20%7B%0A%20%20%20%20%20%20%2F%2F%20Handle%20auto%20keymap%20transitions%0A%20%20%20%20%20%20var%20startMap%20%3D%20getKeyMap(options.keyMap)%2C%20next%20%3D%20startMap.auto%3B%0A%20%20%20%20%20%20clearTimeout(maybeTransition)%3B%0A%20%20%20%20%20%20if%20(next%20%26%26%20!isModifierKey(e))%20maybeTransition%20%3D%20setTimeout(function()%20%7B%0A%20%20%20%20%20%20%20%20if%20(getKeyMap(options.keyMap)%20%3D%3D%20startMap)%20%7B%0A%20%20%20%20%20%20%20%20%20%20options.keyMap%20%3D%20(next.call%20%3F%20next.call(null%2C%20instance)%20%3A%20next)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%2C%2050)%3B%0A%0A%20%20%20%20%20%20var%20name%20%3D%20keyNames%5Be_prop(e%2C%20%22keyCode%22)%5D%2C%20handled%20%3D%20false%3B%0A%20%20%20%20%20%20var%20flipCtrlCmd%20%3D%20opera%20%26%26%20mac%3B%0A%20%20%20%20%20%20if%20(name%20%3D%3D%20null%20%7C%7C%20e.altGraphKey)%20return%20false%3B%0A%20%20%20%20%20%20if%20(e_prop(e%2C%20%22altKey%22))%20name%20%3D%20%22Alt-%22%20%2B%20name%3B%0A%20%20%20%20%20%20if%20(e_prop(e%2C%20flipCtrlCmd%20%3F%20%22metaKey%22%20%3A%20%22ctrlKey%22))%20name%20%3D%20%22Ctrl-%22%20%2B%20name%3B%0A%20%20%20%20%20%20if%20(e_prop(e%2C%20flipCtrlCmd%20%3F%20%22ctrlKey%22%20%3A%20%22metaKey%22))%20name%20%3D%20%22Cmd-%22%20%2B%20name%3B%0A%0A%20%20%20%20%20%20var%20stopped%20%3D%20false%3B%0A%20%20%20%20%20%20function%20stop()%20%7B%20stopped%20%3D%20true%3B%20%7D%0A%0A%20%20%20%20%20%20if%20(e_prop(e%2C%20%22shiftKey%22))%20%7B%0A%20%20%20%20%20%20%20%20handled%20%3D%20lookupKey(%22Shift-%22%20%2B%20name%2C%20options.extraKeys%2C%20options.keyMap%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20function(b)%20%7Breturn%20doHandleBinding(b%2C%20true)%3B%7D%2C%20stop)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7C%7C%20lookupKey(name%2C%20options.extraKeys%2C%20options.keyMap%2C%20function(b)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(typeof%20b%20%3D%3D%20%22string%22%20%26%26%20%2F%5Ego%5BA-Z%5D%2F.test(b))%20return%20doHandleBinding(b)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%20stop)%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20handled%20%3D%20lookupKey(name%2C%20options.extraKeys%2C%20options.keyMap%2C%20doHandleBinding%2C%20stop)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(stopped)%20handled%20%3D%20false%3B%0A%20%20%20%20%20%20if%20(handled)%20%7B%0A%20%20%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20%20%20restartBlink()%3B%0A%20%20%20%20%20%20%20%20if%20(ie)%20%7B%20e.oldKeyCode%20%3D%20e.keyCode%3B%20e.keyCode%20%3D%200%3B%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20handled%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20handleCharBinding(e%2C%20ch)%20%7B%0A%20%20%20%20%20%20var%20handled%20%3D%20lookupKey(%22'%22%20%2B%20ch%20%2B%20%22'%22%2C%20options.extraKeys%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20options.keyMap%2C%20function(b)%20%7B%20return%20doHandleBinding(b%2C%20true)%3B%20%7D)%3B%0A%20%20%20%20%20%20if%20(handled)%20%7B%0A%20%20%20%20%20%20%20%20e_preventDefault(e)%3B%0A%20%20%20%20%20%20%20%20restartBlink()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20handled%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20var%20lastStoppedKey%20%3D%20null%3B%0A%20%20%20%20function%20onKeyDown(e)%20%7B%0A%20%20%20%20%20%20if%20(!focused)%20onFocus()%3B%0A%20%20%20%20%20%20if%20(ie%20%26%26%20e.keyCode%20%3D%3D%2027)%20%7B%20e.returnValue%20%3D%20false%3B%20%7D%0A%20%20%20%20%20%20if%20(pollingFast)%20%7B%20if%20(readInput())%20pollingFast%20%3D%20false%3B%20%7D%0A%20%20%20%20%20%20if%20(options.onKeyEvent%20%26%26%20options.onKeyEvent(instance%2C%20addStop(e)))%20return%3B%0A%20%20%20%20%20%20var%20code%20%3D%20e_prop(e%2C%20%22keyCode%22)%3B%0A%20%20%20%20%20%20%2F%2F%20IE%20does%20strange%20things%20with%20escape.%0A%20%20%20%20%20%20setShift(code%20%3D%3D%2016%20%7C%7C%20e_prop(e%2C%20%22shiftKey%22))%3B%0A%20%20%20%20%20%20%2F%2F%20First%20give%20onKeyEvent%20option%20a%20chance%20to%20handle%20this.%0A%20%20%20%20%20%20var%20handled%20%3D%20handleKeyBinding(e)%3B%0A%20%20%20%20%20%20if%20(opera)%20%7B%0A%20%20%20%20%20%20%20%20lastStoppedKey%20%3D%20handled%20%3F%20code%20%3A%20null%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20Opera%20has%20no%20cut%20event...%20we%20try%20to%20at%20least%20catch%20the%20key%20combo%0A%20%20%20%20%20%20%20%20if%20(!handled%20%26%26%20code%20%3D%3D%2088%20%26%26%20e_prop(e%2C%20mac%20%3F%20%22metaKey%22%20%3A%20%22ctrlKey%22))%0A%20%20%20%20%20%20%20%20%20%20replaceSelection(%22%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20function%20onKeyPress(e)%20%7B%0A%20%20%20%20%20%20if%20(pollingFast)%20readInput()%3B%0A%20%20%20%20%20%20if%20(options.onKeyEvent%20%26%26%20options.onKeyEvent(instance%2C%20addStop(e)))%20return%3B%0A%20%20%20%20%20%20var%20keyCode%20%3D%20e_prop(e%2C%20%22keyCode%22)%2C%20charCode%20%3D%20e_prop(e%2C%20%22charCode%22)%3B%0A%20%20%20%20%20%20if%20(opera%20%26%26%20keyCode%20%3D%3D%20lastStoppedKey)%20%7BlastStoppedKey%20%3D%20null%3B%20e_preventDefault(e)%3B%20return%3B%7D%0A%20%20%20%20%20%20if%20(((opera%20%26%26%20(!e.which%20%7C%7C%20e.which%20%3C%2010))%20%7C%7C%20khtml)%20%26%26%20handleKeyBinding(e))%20return%3B%0A%20%20%20%20%20%20var%20ch%20%3D%20String.fromCharCode(charCode%20%3D%3D%20null%20%3F%20keyCode%20%3A%20charCode)%3B%0A%20%20%20%20%20%20if%20(options.electricChars%20%26%26%20mode.electricChars%20%26%26%20options.smartIndent%20%26%26%20!options.readOnly)%20%7B%0A%20%20%20%20%20%20%20%20if%20(mode.electricChars.indexOf(ch)%20%3E%20-1)%0A%20%20%20%20%20%20%20%20%20%20setTimeout(operation(function()%20%7BindentLine(sel.to.line%2C%20%22smart%22)%3B%7D)%2C%2075)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(handleCharBinding(e%2C%20ch))%20return%3B%0A%20%20%20%20%20%20fastPoll()%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20onKeyUp(e)%20%7B%0A%20%20%20%20%20%20if%20(options.onKeyEvent%20%26%26%20options.onKeyEvent(instance%2C%20addStop(e)))%20return%3B%0A%20%20%20%20%20%20if%20(e_prop(e%2C%20%22keyCode%22)%20%3D%3D%2016)%20shiftSelecting%20%3D%20null%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20onFocus()%20%7B%0A%20%20%20%20%20%20if%20(options.readOnly%20%3D%3D%20%22nocursor%22)%20return%3B%0A%20%20%20%20%20%20if%20(!focused)%20%7B%0A%20%20%20%20%20%20%20%20if%20(options.onFocus)%20options.onFocus(instance)%3B%0A%20%20%20%20%20%20%20%20focused%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20if%20(scroller.className.search(%2F%5CbCodeMirror-focused%5Cb%2F)%20%3D%3D%20-1)%0A%20%20%20%20%20%20%20%20%20%20scroller.className%20%2B%3D%20%22%20CodeMirror-focused%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20slowPoll()%3B%0A%20%20%20%20%20%20restartBlink()%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20onBlur()%20%7B%0A%20%20%20%20%20%20if%20(focused)%20%7B%0A%20%20%20%20%20%20%20%20if%20(options.onBlur)%20options.onBlur(instance)%3B%0A%20%20%20%20%20%20%20%20focused%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20if%20(bracketHighlighted)%0A%20%20%20%20%20%20%20%20%20%20operation(function()%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(bracketHighlighted)%20%7B%20bracketHighlighted()%3B%20bracketHighlighted%20%3D%20null%3B%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D)()%3B%0A%20%20%20%20%20%20%20%20scroller.className%20%3D%20scroller.className.replace(%22%20CodeMirror-focused%22%2C%20%22%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20clearInterval(blinker)%3B%0A%20%20%20%20%20%20setTimeout(function()%20%7Bif%20(!focused)%20shiftSelecting%20%3D%20null%3B%7D%2C%20150)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20%2F%2F%20Replace%20the%20range%20from%20from%20to%20to%20by%20the%20strings%20in%20newText.%0A%20%20%20%20%2F%2F%20Afterwards%2C%20set%20the%20selection%20to%20selFrom%2C%20selTo.%0A%20%20%20%20function%20updateLines(from%2C%20to%2C%20newText%2C%20selFrom%2C%20selTo)%20%7B%0A%20%20%20%20%20%20if%20(suppressEdits)%20return%3B%0A%20%20%20%20%20%20var%20old%20%3D%20%5B%5D%3B%0A%20%20%20%20%20%20doc.iter(from.line%2C%20to.line%20%2B%201%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20old.push(newHL(line.text%2C%20line.markedSpans))%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20if%20(history)%20%7B%0A%20%20%20%20%20%20%20%20history.addChange(from.line%2C%20newText.length%2C%20old)%3B%0A%20%20%20%20%20%20%20%20while%20(history.done.length%20%3E%20options.undoDepth)%20history.done.shift()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20lines%20%3D%20updateMarkedSpans(hlSpans(old%5B0%5D)%2C%20hlSpans(lst(old))%2C%20from.ch%2C%20to.ch%2C%20newText)%3B%0A%20%20%20%20%20%20updateLinesNoUndo(from%2C%20to%2C%20lines%2C%20selFrom%2C%20selTo)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20unredoHelper(from%2C%20to)%20%7B%0A%20%20%20%20%20%20if%20(!from.length)%20return%3B%0A%20%20%20%20%20%20var%20set%20%3D%20from.pop()%2C%20out%20%3D%20%5B%5D%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%20set.length%20-%201%3B%20i%20%3E%3D%200%3B%20i%20-%3D%201)%20%7B%0A%20%20%20%20%20%20%20%20var%20change%20%3D%20set%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20var%20replaced%20%3D%20%5B%5D%2C%20end%20%3D%20change.start%20%2B%20change.added%3B%0A%20%20%20%20%20%20%20%20doc.iter(change.start%2C%20end%2C%20function(line)%20%7B%20replaced.push(newHL(line.text%2C%20line.markedSpans))%3B%20%7D)%3B%0A%20%20%20%20%20%20%20%20out.push(%7Bstart%3A%20change.start%2C%20added%3A%20change.old.length%2C%20old%3A%20replaced%7D)%3B%0A%20%20%20%20%20%20%20%20var%20pos%20%3D%20%7Bline%3A%20change.start%20%2B%20change.old.length%20-%201%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ch%3A%20editEnd(hlText(lst(replaced))%2C%20hlText(lst(change.old)))%7D%3B%0A%20%20%20%20%20%20%20%20updateLinesNoUndo(%7Bline%3A%20change.start%2C%20ch%3A%200%7D%2C%20%7Bline%3A%20end%20-%201%2C%20ch%3A%20getLine(end-1).text.length%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20change.old%2C%20pos%2C%20pos)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20updateInput%20%3D%20true%3B%0A%20%20%20%20%20%20to.push(out)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20undo()%20%7BunredoHelper(history.done%2C%20history.undone)%3B%7D%0A%20%20%20%20function%20redo()%20%7BunredoHelper(history.undone%2C%20history.done)%3B%7D%0A%0A%20%20%20%20function%20updateLinesNoUndo(from%2C%20to%2C%20lines%2C%20selFrom%2C%20selTo)%20%7B%0A%20%20%20%20%20%20if%20(suppressEdits)%20return%3B%0A%20%20%20%20%20%20var%20recomputeMaxLength%20%3D%20false%2C%20maxLineLength%20%3D%20maxLine.text.length%3B%0A%20%20%20%20%20%20if%20(!options.lineWrapping)%0A%20%20%20%20%20%20%20%20doc.iter(from.line%2C%20to.line%20%2B%201%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(!line.hidden%20%26%26%20line.text.length%20%3D%3D%20maxLineLength)%20%7BrecomputeMaxLength%20%3D%20true%3B%20return%20true%3B%7D%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20if%20(from.line%20!%3D%20to.line%20%7C%7C%20lines.length%20%3E%201)%20gutterDirty%20%3D%20true%3B%0A%0A%20%20%20%20%20%20var%20nlines%20%3D%20to.line%20-%20from.line%2C%20firstLine%20%3D%20getLine(from.line)%2C%20lastLine%20%3D%20getLine(to.line)%3B%0A%20%20%20%20%20%20var%20lastHL%20%3D%20lst(lines)%3B%0A%0A%20%20%20%20%20%20%2F%2F%20First%20adjust%20the%20line%20structure%0A%20%20%20%20%20%20if%20(from.ch%20%3D%3D%200%20%26%26%20to.ch%20%3D%3D%200%20%26%26%20hlText(lastHL)%20%3D%3D%20%22%22)%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20This%20is%20a%20whole-line%20replace.%20Treated%20specially%20to%20make%0A%20%20%20%20%20%20%20%20%2F%2F%20sure%20line%20objects%20move%20the%20way%20they%20are%20supposed%20to.%0A%20%20%20%20%20%20%20%20var%20added%20%3D%20%5B%5D%2C%20prevLine%20%3D%20null%3B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20lines.length%20-%201%3B%20i%20%3C%20e%3B%20%2B%2Bi)%0A%20%20%20%20%20%20%20%20%20%20added.push(new%20Line(hlText(lines%5Bi%5D)%2C%20hlSpans(lines%5Bi%5D)))%3B%0A%20%20%20%20%20%20%20%20lastLine.update(lastLine.text%2C%20hlSpans(lastHL))%3B%0A%20%20%20%20%20%20%20%20if%20(nlines)%20doc.remove(from.line%2C%20nlines%2C%20callbacks)%3B%0A%20%20%20%20%20%20%20%20if%20(added.length)%20doc.insert(from.line%2C%20added)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(firstLine%20%3D%3D%20lastLine)%20%7B%0A%20%20%20%20%20%20%20%20if%20(lines.length%20%3D%3D%201)%20%7B%0A%20%20%20%20%20%20%20%20%20%20firstLine.update(firstLine.text.slice(0%2C%20from.ch)%20%2B%20hlText(lines%5B0%5D)%20%2B%20firstLine.text.slice(to.ch)%2C%20hlSpans(lines%5B0%5D))%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20for%20(var%20added%20%3D%20%5B%5D%2C%20i%20%3D%201%2C%20e%20%3D%20lines.length%20-%201%3B%20i%20%3C%20e%3B%20%2B%2Bi)%0A%20%20%20%20%20%20%20%20%20%20%20%20added.push(new%20Line(hlText(lines%5Bi%5D)%2C%20hlSpans(lines%5Bi%5D)))%3B%0A%20%20%20%20%20%20%20%20%20%20added.push(new%20Line(hlText(lastHL)%20%2B%20firstLine.text.slice(to.ch)%2C%20hlSpans(lastHL)))%3B%0A%20%20%20%20%20%20%20%20%20%20firstLine.update(firstLine.text.slice(0%2C%20from.ch)%20%2B%20hlText(lines%5B0%5D)%2C%20hlSpans(lines%5B0%5D))%3B%0A%20%20%20%20%20%20%20%20%20%20doc.insert(from.line%20%2B%201%2C%20added)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%20else%20if%20(lines.length%20%3D%3D%201)%20%7B%0A%20%20%20%20%20%20%20%20firstLine.update(firstLine.text.slice(0%2C%20from.ch)%20%2B%20hlText(lines%5B0%5D)%20%2B%20lastLine.text.slice(to.ch)%2C%20hlSpans(lines%5B0%5D))%3B%0A%20%20%20%20%20%20%20%20doc.remove(from.line%20%2B%201%2C%20nlines%2C%20callbacks)%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20added%20%3D%20%5B%5D%3B%0A%20%20%20%20%20%20%20%20firstLine.update(firstLine.text.slice(0%2C%20from.ch)%20%2B%20hlText(lines%5B0%5D)%2C%20hlSpans(lines%5B0%5D))%3B%0A%20%20%20%20%20%20%20%20lastLine.update(hlText(lastHL)%20%2B%20lastLine.text.slice(to.ch)%2C%20hlSpans(lastHL))%3B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%201%2C%20e%20%3D%20lines.length%20-%201%3B%20i%20%3C%20e%3B%20%2B%2Bi)%0A%20%20%20%20%20%20%20%20%20%20added.push(new%20Line(hlText(lines%5Bi%5D)%2C%20hlSpans(lines%5Bi%5D)))%3B%0A%20%20%20%20%20%20%20%20if%20(nlines%20%3E%201)%20doc.remove(from.line%20%2B%201%2C%20nlines%20-%201%2C%20callbacks)%3B%0A%20%20%20%20%20%20%20%20doc.insert(from.line%20%2B%201%2C%20added)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(options.lineWrapping)%20%7B%0A%20%20%20%20%20%20%20%20var%20perLine%20%3D%20Math.max(5%2C%20scroller.clientWidth%20%2F%20charWidth()%20-%203)%3B%0A%20%20%20%20%20%20%20%20doc.iter(from.line%2C%20from.line%20%2B%20lines.length%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(line.hidden)%20return%3B%0A%20%20%20%20%20%20%20%20%20%20var%20guess%20%3D%20Math.ceil(line.text.length%20%2F%20perLine)%20%7C%7C%201%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(guess%20!%3D%20line.height)%20updateLineHeight(line%2C%20guess)%3B%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20doc.iter(from.line%2C%20from.line%20%2B%20lines.length%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20l%20%3D%20line.text%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(!line.hidden%20%26%26%20l.length%20%3E%20maxLineLength)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20maxLine%20%3D%20line%3B%20maxLineLength%20%3D%20l.length%3B%20maxLineChanged%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20recomputeMaxLength%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20if%20(recomputeMaxLength)%20updateMaxLine%20%3D%20true%3B%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%2F%2F%20Adjust%20frontier%2C%20schedule%20worker%0A%20%20%20%20%20%20frontier%20%3D%20Math.min(frontier%2C%20from.line)%3B%0A%20%20%20%20%20%20startWorker(400)%3B%0A%0A%20%20%20%20%20%20var%20lendiff%20%3D%20lines.length%20-%20nlines%20-%201%3B%0A%20%20%20%20%20%20%2F%2F%20Remember%20that%20these%20lines%20changed%2C%20for%20updating%20the%20display%0A%20%20%20%20%20%20changes.push(%7Bfrom%3A%20from.line%2C%20to%3A%20to.line%20%2B%201%2C%20diff%3A%20lendiff%7D)%3B%0A%20%20%20%20%20%20if%20(options.onChange)%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20Normalize%20lines%20to%20contain%20only%20strings%2C%20since%20that's%20what%0A%20%20%20%20%20%20%20%20%2F%2F%20the%20change%20event%20handler%20expects%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20lines.length%3B%20%2B%2Bi)%0A%20%20%20%20%20%20%20%20%20%20if%20(typeof%20lines%5Bi%5D%20!%3D%20%22string%22)%20lines%5Bi%5D%20%3D%20lines%5Bi%5D.text%3B%0A%20%20%20%20%20%20%20%20var%20changeObj%20%3D%20%7Bfrom%3A%20from%2C%20to%3A%20to%2C%20text%3A%20lines%7D%3B%0A%20%20%20%20%20%20%20%20if%20(textChanged)%20%7B%0A%20%20%20%20%20%20%20%20%20%20for%20(var%20cur%20%3D%20textChanged%3B%20cur.next%3B%20cur%20%3D%20cur.next)%20%7B%7D%0A%20%20%20%20%20%20%20%20%20%20cur.next%20%3D%20changeObj%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20textChanged%20%3D%20changeObj%3B%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%2F%2F%20Update%20the%20selection%0A%20%20%20%20%20%20function%20updateLine(n)%20%7Breturn%20n%20%3C%3D%20Math.min(to.line%2C%20to.line%20%2B%20lendiff)%20%3F%20n%20%3A%20n%20%2B%20lendiff%3B%7D%0A%20%20%20%20%20%20setSelection(clipPos(selFrom)%2C%20clipPos(selTo)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20updateLine(sel.from.line)%2C%20updateLine(sel.to.line))%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20needsScrollbar()%20%7B%0A%20%20%20%20%20%20var%20realHeight%20%3D%20doc.height%20*%20textHeight()%20%2B%202%20*%20paddingTop()%3B%0A%20%20%20%20%20%20return%20realHeight%20*%20.99%20%3E%20scroller.offsetHeight%20%3F%20realHeight%20%3A%20false%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20updateVerticalScroll(scrollTop)%20%7B%0A%20%20%20%20%20%20var%20scrollHeight%20%3D%20needsScrollbar()%3B%0A%20%20%20%20%20%20scrollbar.style.display%20%3D%20scrollHeight%20%3F%20%22block%22%20%3A%20%22none%22%3B%0A%20%20%20%20%20%20if%20(scrollHeight)%20%7B%0A%20%20%20%20%20%20%20%20scrollbarInner.style.height%20%3D%20sizer.style.minHeight%20%3D%20scrollHeight%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20scrollbar.style.height%20%3D%20scroller.clientHeight%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20if%20(scrollTop%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20scrollbar.scrollTop%20%3D%20scroller.scrollTop%20%3D%20scrollTop%3B%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20'Nudge'%20the%20scrollbar%20to%20work%20around%20a%20Webkit%20bug%20where%2C%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20in%20some%20situations%2C%20we'd%20end%20up%20with%20a%20scrollbar%20that%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20reported%20its%20scrollTop%20(and%20looked)%20as%20expected%2C%20but%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20*behaved*%20as%20if%20it%20was%20still%20in%20a%20previous%20state%20(i.e.%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20couldn't%20scroll%20up%2C%20even%20though%20it%20appeared%20to%20be%20at%20the%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20bottom).%0A%20%20%20%20%20%20%20%20%20%20if%20(webkit)%20setTimeout(function()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(scrollbar.scrollTop%20!%3D%20scrollTop)%20return%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20scrollbar.scrollTop%20%3D%20scrollTop%20%2B%20(scrollTop%20%3F%20-1%20%3A%201)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20scrollbar.scrollTop%20%3D%20scrollTop%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%2C%200)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20sizer.style.minHeight%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%2F%2F%20Position%20the%20mover%20div%20to%20align%20with%20the%20current%20virtual%20scroll%20position%0A%20%20%20%20%20%20mover.style.top%20%3D%20displayOffset%20*%20textHeight()%20%2B%20%22px%22%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20computeMaxLength()%20%7B%0A%20%20%20%20%20%20maxLine%20%3D%20getLine(0)%3B%20maxLineChanged%20%3D%20true%3B%0A%20%20%20%20%20%20var%20maxLineLength%20%3D%20maxLine.text.length%3B%0A%20%20%20%20%20%20doc.iter(1%2C%20doc.size%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20var%20l%20%3D%20line.text%3B%0A%20%20%20%20%20%20%20%20if%20(!line.hidden%20%26%26%20l.length%20%3E%20maxLineLength)%20%7B%0A%20%20%20%20%20%20%20%20%20%20maxLineLength%20%3D%20l.length%3B%20maxLine%20%3D%20line%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20updateMaxLine%20%3D%20false%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20replaceRange(code%2C%20from%2C%20to)%20%7B%0A%20%20%20%20%20%20from%20%3D%20clipPos(from)%3B%0A%20%20%20%20%20%20if%20(!to)%20to%20%3D%20from%3B%20else%20to%20%3D%20clipPos(to)%3B%0A%20%20%20%20%20%20code%20%3D%20splitLines(code)%3B%0A%20%20%20%20%20%20function%20adjustPos(pos)%20%7B%0A%20%20%20%20%20%20%20%20if%20(posLess(pos%2C%20from))%20return%20pos%3B%0A%20%20%20%20%20%20%20%20if%20(!posLess(to%2C%20pos))%20return%20end%3B%0A%20%20%20%20%20%20%20%20var%20line%20%3D%20pos.line%20%2B%20code.length%20-%20(to.line%20-%20from.line)%20-%201%3B%0A%20%20%20%20%20%20%20%20var%20ch%20%3D%20pos.ch%3B%0A%20%20%20%20%20%20%20%20if%20(pos.line%20%3D%3D%20to.line)%0A%20%20%20%20%20%20%20%20%20%20ch%20%2B%3D%20lst(code).length%20-%20(to.ch%20-%20(to.line%20%3D%3D%20from.line%20%3F%20from.ch%20%3A%200))%3B%0A%20%20%20%20%20%20%20%20return%20%7Bline%3A%20line%2C%20ch%3A%20ch%7D%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20end%3B%0A%20%20%20%20%20%20replaceRange1(code%2C%20from%2C%20to%2C%20function(end1)%20%7B%0A%20%20%20%20%20%20%20%20end%20%3D%20end1%3B%0A%20%20%20%20%20%20%20%20return%20%7Bfrom%3A%20adjustPos(sel.from)%2C%20to%3A%20adjustPos(sel.to)%7D%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20return%20end%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20replaceSelection(code%2C%20collapse)%20%7B%0A%20%20%20%20%20%20replaceRange1(splitLines(code)%2C%20sel.from%2C%20sel.to%2C%20function(end)%20%7B%0A%20%20%20%20%20%20%20%20if%20(collapse%20%3D%3D%20%22end%22)%20return%20%7Bfrom%3A%20end%2C%20to%3A%20end%7D%3B%0A%20%20%20%20%20%20%20%20else%20if%20(collapse%20%3D%3D%20%22start%22)%20return%20%7Bfrom%3A%20sel.from%2C%20to%3A%20sel.from%7D%3B%0A%20%20%20%20%20%20%20%20else%20return%20%7Bfrom%3A%20sel.from%2C%20to%3A%20end%7D%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20replaceRange1(code%2C%20from%2C%20to%2C%20computeSel)%20%7B%0A%20%20%20%20%20%20var%20endch%20%3D%20code.length%20%3D%3D%201%20%3F%20code%5B0%5D.length%20%2B%20from.ch%20%3A%20lst(code).length%3B%0A%20%20%20%20%20%20var%20newSel%20%3D%20computeSel(%7Bline%3A%20from.line%20%2B%20code.length%20-%201%2C%20ch%3A%20endch%7D)%3B%0A%20%20%20%20%20%20updateLines(from%2C%20to%2C%20code%2C%20newSel.from%2C%20newSel.to)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20getRange(from%2C%20to%2C%20lineSep)%20%7B%0A%20%20%20%20%20%20var%20l1%20%3D%20from.line%2C%20l2%20%3D%20to.line%3B%0A%20%20%20%20%20%20if%20(l1%20%3D%3D%20l2)%20return%20getLine(l1).text.slice(from.ch%2C%20to.ch)%3B%0A%20%20%20%20%20%20var%20code%20%3D%20%5BgetLine(l1).text.slice(from.ch)%5D%3B%0A%20%20%20%20%20%20doc.iter(l1%20%2B%201%2C%20l2%2C%20function(line)%20%7B%20code.push(line.text)%3B%20%7D)%3B%0A%20%20%20%20%20%20code.push(getLine(l2).text.slice(0%2C%20to.ch))%3B%0A%20%20%20%20%20%20return%20code.join(lineSep%20%7C%7C%20%22%5Cn%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20getSelection(lineSep)%20%7B%0A%20%20%20%20%20%20return%20getRange(sel.from%2C%20sel.to%2C%20lineSep)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20slowPoll()%20%7B%0A%20%20%20%20%20%20if%20(pollingFast)%20return%3B%0A%20%20%20%20%20%20poll.set(options.pollInterval%2C%20function()%20%7B%0A%20%20%20%20%20%20%20%20readInput()%3B%0A%20%20%20%20%20%20%20%20if%20(focused)%20slowPoll()%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20fastPoll()%20%7B%0A%20%20%20%20%20%20var%20missed%20%3D%20false%3B%0A%20%20%20%20%20%20pollingFast%20%3D%20true%3B%0A%20%20%20%20%20%20function%20p()%20%7B%0A%20%20%20%20%20%20%20%20var%20changed%20%3D%20readInput()%3B%0A%20%20%20%20%20%20%20%20if%20(!changed%20%26%26%20!missed)%20%7Bmissed%20%3D%20true%3B%20poll.set(60%2C%20p)%3B%7D%0A%20%20%20%20%20%20%20%20else%20%7BpollingFast%20%3D%20false%3B%20slowPoll()%3B%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20poll.set(20%2C%20p)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20%2F%2F%20Previnput%20is%20a%20hack%20to%20work%20with%20IME.%20If%20we%20reset%20the%20textarea%0A%20%20%20%20%2F%2F%20on%20every%20change%2C%20that%20breaks%20IME.%20So%20we%20look%20for%20changes%0A%20%20%20%20%2F%2F%20compared%20to%20the%20previous%20content%20instead.%20(Modern%20browsers%20have%0A%20%20%20%20%2F%2F%20events%20that%20indicate%20IME%20taking%20place%2C%20but%20these%20are%20not%20widely%0A%20%20%20%20%2F%2F%20supported%20or%20compatible%20enough%20yet%20to%20rely%20on.)%0A%20%20%20%20var%20prevInput%20%3D%20%22%22%3B%0A%20%20%20%20function%20readInput()%20%7B%0A%20%20%20%20%20%20if%20(!focused%20%7C%7C%20hasSelection(input)%20%7C%7C%20options.readOnly)%20return%20false%3B%0A%20%20%20%20%20%20var%20text%20%3D%20input.value%3B%0A%20%20%20%20%20%20if%20(text%20%3D%3D%20prevInput)%20return%20false%3B%0A%20%20%20%20%20%20if%20(!nestedOperation)%20startOperation()%3B%0A%20%20%20%20%20%20shiftSelecting%20%3D%20null%3B%0A%20%20%20%20%20%20var%20same%20%3D%200%2C%20l%20%3D%20Math.min(prevInput.length%2C%20text.length)%3B%0A%20%20%20%20%20%20while%20(same%20%3C%20l%20%26%26%20prevInput%5Bsame%5D%20%3D%3D%20text%5Bsame%5D)%20%2B%2Bsame%3B%0A%20%20%20%20%20%20if%20(same%20%3C%20prevInput.length)%0A%20%20%20%20%20%20%20%20sel.from%20%3D%20%7Bline%3A%20sel.from.line%2C%20ch%3A%20sel.from.ch%20-%20(prevInput.length%20-%20same)%7D%3B%0A%20%20%20%20%20%20else%20if%20(overwrite%20%26%26%20posEq(sel.from%2C%20sel.to))%0A%20%20%20%20%20%20%20%20sel.to%20%3D%20%7Bline%3A%20sel.to.line%2C%20ch%3A%20Math.min(getLine(sel.to.line).text.length%2C%20sel.to.ch%20%2B%20(text.length%20-%20same))%7D%3B%0A%20%20%20%20%20%20replaceSelection(text.slice(same)%2C%20%22end%22)%3B%0A%20%20%20%20%20%20if%20(text.length%20%3E%201000)%20%7B%20input.value%20%3D%20prevInput%20%3D%20%22%22%3B%20%7D%0A%20%20%20%20%20%20else%20prevInput%20%3D%20text%3B%0A%20%20%20%20%20%20if%20(!nestedOperation)%20endOperation()%3B%0A%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20resetInput(user)%20%7B%0A%20%20%20%20%20%20if%20(!posEq(sel.from%2C%20sel.to))%20%7B%0A%20%20%20%20%20%20%20%20prevInput%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20input.value%20%3D%20getSelection()%3B%0A%20%20%20%20%20%20%20%20if%20(focused)%20selectInput(input)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(user)%20prevInput%20%3D%20input.value%20%3D%20%22%22%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20focusInput()%20%7B%0A%20%20%20%20%20%20if%20(options.readOnly%20!%3D%20%22nocursor%22)%20input.focus()%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20scrollCursorIntoView()%20%7B%0A%20%20%20%20%20%20var%20coords%20%3D%20calculateCursorCoords()%3B%0A%20%20%20%20%20%20scrollIntoView(coords.x%2C%20coords.y%2C%20coords.x%2C%20coords.yBot)%3B%0A%20%20%20%20%20%20if%20(!focused)%20return%3B%0A%20%20%20%20%20%20var%20box%20%3D%20sizer.getBoundingClientRect()%2C%20doScroll%20%3D%20null%3B%0A%20%20%20%20%20%20if%20(coords.y%20%2B%20box.top%20%3C%200)%20doScroll%20%3D%20true%3B%0A%20%20%20%20%20%20else%20if%20(coords.y%20%2B%20box.top%20%2B%20textHeight()%20%3E%20(window.innerHeight%20%7C%7C%20document.documentElement.clientHeight))%20doScroll%20%3D%20false%3B%0A%20%20%20%20%20%20if%20(doScroll%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20var%20hidden%20%3D%20cursor.style.display%20%3D%3D%20%22none%22%3B%0A%20%20%20%20%20%20%20%20if%20(hidden)%20%7B%0A%20%20%20%20%20%20%20%20%20%20cursor.style.display%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%20%20cursor.style.left%20%3D%20coords.x%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20%20%20cursor.style.top%20%3D%20(coords.y%20-%20displayOffset)%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20cursor.scrollIntoView(doScroll)%3B%0A%20%20%20%20%20%20%20%20if%20(hidden)%20cursor.style.display%20%3D%20%22none%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20function%20calculateCursorCoords()%20%7B%0A%20%20%20%20%20%20var%20cursor%20%3D%20localCoords(sel.inverted%20%3F%20sel.from%20%3A%20sel.to)%3B%0A%20%20%20%20%20%20var%20x%20%3D%20options.lineWrapping%20%3F%20Math.min(cursor.x%2C%20lineSpace.offsetWidth)%20%3A%20cursor.x%3B%0A%20%20%20%20%20%20return%20%7Bx%3A%20x%2C%20y%3A%20cursor.y%2C%20yBot%3A%20cursor.yBot%7D%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20scrollIntoView(x1%2C%20y1%2C%20x2%2C%20y2)%20%7B%0A%20%20%20%20%20%20var%20scrollPos%20%3D%20calculateScrollPos(x1%2C%20y1%2C%20x2%2C%20y2)%3B%0A%20%20%20%20%20%20if%20(scrollPos.scrollLeft%20!%3D%20null)%20%7Bscroller.scrollLeft%20%3D%20scrollPos.scrollLeft%3B%7D%0A%20%20%20%20%20%20if%20(scrollPos.scrollTop%20!%3D%20null)%20%7Bscrollbar.scrollTop%20%3D%20scroller.scrollTop%20%3D%20scrollPos.scrollTop%3B%7D%0A%20%20%20%20%7D%0A%20%20%20%20function%20calculateScrollPos(x1%2C%20y1%2C%20x2%2C%20y2)%20%7B%0A%20%20%20%20%20%20var%20pl%20%3D%20paddingLeft()%2C%20pt%20%3D%20paddingTop()%3B%0A%20%20%20%20%20%20y1%20%2B%3D%20pt%3B%20y2%20%2B%3D%20pt%3B%20x1%20%2B%3D%20pl%3B%20x2%20%2B%3D%20pl%3B%0A%20%20%20%20%20%20var%20screen%20%3D%20scroller.clientHeight%2C%20screentop%20%3D%20scrollbar.scrollTop%2C%20result%20%3D%20%7B%7D%3B%0A%20%20%20%20%20%20var%20docBottom%20%3D%20needsScrollbar()%20%7C%7C%20Infinity%3B%0A%20%20%20%20%20%20var%20atTop%20%3D%20y1%20%3C%20pt%20%2B%2010%2C%20atBottom%20%3D%20y2%20%2B%20pt%20%3E%20docBottom%20-%2010%3B%0A%20%20%20%20%20%20if%20(y1%20%3C%20screentop)%20result.scrollTop%20%3D%20atTop%20%3F%200%20%3A%20Math.max(0%2C%20y1)%3B%0A%20%20%20%20%20%20else%20if%20(y2%20%3E%20screentop%20%2B%20screen)%20result.scrollTop%20%3D%20(atBottom%20%3F%20docBottom%20%3A%20y2)%20-%20screen%3B%0A%0A%20%20%20%20%20%20var%20screenw%20%3D%20scroller.clientWidth%2C%20screenleft%20%3D%20scroller.scrollLeft%3B%0A%20%20%20%20%20%20var%20gutterw%20%3D%20options.fixedGutter%20%3F%20gutter.clientWidth%20%3A%200%3B%0A%20%20%20%20%20%20var%20atLeft%20%3D%20x1%20%3C%20gutterw%20%2B%20pl%20%2B%2010%3B%0A%20%20%20%20%20%20if%20(x1%20%3C%20screenleft%20%2B%20gutterw%20%7C%7C%20atLeft)%20%7B%0A%20%20%20%20%20%20%20%20if%20(atLeft)%20x1%20%3D%200%3B%0A%20%20%20%20%20%20%20%20result.scrollLeft%20%3D%20Math.max(0%2C%20x1%20-%2010%20-%20gutterw)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(x2%20%3E%20screenw%20%2B%20screenleft%20-%203)%20%7B%0A%20%20%20%20%20%20%20%20result.scrollLeft%20%3D%20x2%20%2B%2010%20-%20screenw%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20result%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20visibleLines(scrollTop)%20%7B%0A%20%20%20%20%20%20var%20lh%20%3D%20textHeight()%2C%20top%20%3D%20(scrollTop%20!%3D%20null%20%3F%20scrollTop%20%3A%20scrollbar.scrollTop)%20-%20paddingTop()%3B%0A%20%20%20%20%20%20var%20fromHeight%20%3D%20Math.max(0%2C%20Math.floor(top%20%2F%20lh))%3B%0A%20%20%20%20%20%20var%20toHeight%20%3D%20Math.ceil((top%20%2B%20scroller.clientHeight)%20%2F%20lh)%3B%0A%20%20%20%20%20%20return%20%7Bfrom%3A%20lineAtHeight(doc%2C%20fromHeight)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20to%3A%20lineAtHeight(doc%2C%20toHeight)%7D%3B%0A%20%20%20%20%7D%0A%20%20%20%20%2F%2F%20Uses%20a%20set%20of%20changes%20plus%20the%20current%20scroll%20position%20to%0A%20%20%20%20%2F%2F%20determine%20which%20DOM%20updates%20have%20to%20be%20made%2C%20and%20makes%20the%0A%20%20%20%20%2F%2F%20updates.%0A%20%20%20%20function%20updateDisplay(changes%2C%20suppressCallback%2C%20scrollTop)%20%7B%0A%20%20%20%20%20%20if%20(!scroller.clientWidth)%20%7B%0A%20%20%20%20%20%20%20%20showingFrom%20%3D%20showingTo%20%3D%20displayOffset%20%3D%200%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%2F%2F%20Compute%20the%20new%20visible%20window%0A%20%20%20%20%20%20%2F%2F%20If%20scrollTop%20is%20specified%2C%20use%20that%20to%20determine%20which%20lines%0A%20%20%20%20%20%20%2F%2F%20to%20render%20instead%20of%20the%20current%20scrollbar%20position.%0A%20%20%20%20%20%20var%20visible%20%3D%20visibleLines(scrollTop)%3B%0A%20%20%20%20%20%20%2F%2F%20Bail%20out%20if%20the%20visible%20area%20is%20already%20rendered%20and%20nothing%20changed.%0A%20%20%20%20%20%20if%20(changes%20!%3D%3D%20true%20%26%26%20changes.length%20%3D%3D%200%20%26%26%20visible.from%20%3E%20showingFrom%20%26%26%20visible.to%20%3C%20showingTo)%20%7B%0A%20%20%20%20%20%20%20%20updateVerticalScroll(scrollTop)%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20from%20%3D%20Math.max(visible.from%20-%20100%2C%200)%2C%20to%20%3D%20Math.min(doc.size%2C%20visible.to%20%2B%20100)%3B%0A%20%20%20%20%20%20if%20(showingFrom%20%3C%20from%20%26%26%20from%20-%20showingFrom%20%3C%2020)%20from%20%3D%20showingFrom%3B%0A%20%20%20%20%20%20if%20(showingTo%20%3E%20to%20%26%26%20showingTo%20-%20to%20%3C%2020)%20to%20%3D%20Math.min(doc.size%2C%20showingTo)%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Create%20a%20range%20of%20theoretically%20intact%20lines%2C%20and%20punch%20holes%0A%20%20%20%20%20%20%2F%2F%20in%20that%20using%20the%20change%20info.%0A%20%20%20%20%20%20var%20intact%20%3D%20changes%20%3D%3D%3D%20true%20%3F%20%5B%5D%20%3A%0A%20%20%20%20%20%20%20%20computeIntact(%5B%7Bfrom%3A%20showingFrom%2C%20to%3A%20showingTo%2C%20domStart%3A%200%7D%5D%2C%20changes)%3B%0A%20%20%20%20%20%20%2F%2F%20Clip%20off%20the%20parts%20that%20won't%20be%20visible%0A%20%20%20%20%20%20var%20intactLines%20%3D%200%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20intact.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20range%20%3D%20intact%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20if%20(range.from%20%3C%20from)%20%7Brange.domStart%20%2B%3D%20(from%20-%20range.from)%3B%20range.from%20%3D%20from%3B%7D%0A%20%20%20%20%20%20%20%20if%20(range.to%20%3E%20to)%20range.to%20%3D%20to%3B%0A%20%20%20%20%20%20%20%20if%20(range.from%20%3E%3D%20range.to)%20intact.splice(i--%2C%201)%3B%0A%20%20%20%20%20%20%20%20else%20intactLines%20%2B%3D%20range.to%20-%20range.from%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(intactLines%20%3D%3D%20to%20-%20from%20%26%26%20from%20%3D%3D%20showingFrom%20%26%26%20to%20%3D%3D%20showingTo)%20%7B%0A%20%20%20%20%20%20%20%20updateVerticalScroll(scrollTop)%3B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20intact.sort(function(a%2C%20b)%20%7Breturn%20a.domStart%20-%20b.domStart%3B%7D)%3B%0A%0A%20%20%20%20%20%20var%20th%20%3D%20textHeight()%2C%20gutterDisplay%20%3D%20gutter.style.display%3B%0A%20%20%20%20%20%20lineDiv.style.display%20%3D%20%22none%22%3B%0A%20%20%20%20%20%20patchDisplay(from%2C%20to%2C%20intact)%3B%0A%20%20%20%20%20%20lineDiv.style.display%20%3D%20gutter.style.display%20%3D%20%22%22%3B%0A%0A%20%20%20%20%20%20var%20different%20%3D%20from%20!%3D%20showingFrom%20%7C%7C%20to%20!%3D%20showingTo%20%7C%7C%20lastSizeC%20!%3D%20scroller.clientHeight%20%2B%20th%3B%0A%20%20%20%20%20%20%2F%2F%20This%20is%20just%20a%20bogus%20formula%20that%20detects%20when%20the%20editor%20is%0A%20%20%20%20%20%20%2F%2F%20resized%20or%20the%20font%20size%20changes.%0A%20%20%20%20%20%20if%20(different)%20lastSizeC%20%3D%20scroller.clientHeight%20%2B%20th%3B%0A%20%20%20%20%20%20if%20(from%20!%3D%20showingFrom%20%7C%7C%20to%20!%3D%20showingTo%20%26%26%20options.onViewportChange)%0A%20%20%20%20%20%20%20%20setTimeout(function()%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(options.onViewportChange)%20options.onViewportChange(instance%2C%20from%2C%20to)%3B%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20showingFrom%20%3D%20from%3B%20showingTo%20%3D%20to%3B%0A%20%20%20%20%20%20displayOffset%20%3D%20heightAtLine(doc%2C%20from)%3B%0A%20%20%20%20%20%20startWorker(100)%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Since%20this%20is%20all%20rather%20error%20prone%2C%20it%20is%20honoured%20with%20the%0A%20%20%20%20%20%20%2F%2F%20only%20assertion%20in%20the%20whole%20file.%0A%20%20%20%20%20%20if%20(lineDiv.childNodes.length%20!%3D%20showingTo%20-%20showingFrom)%0A%20%20%20%20%20%20%20%20throw%20new%20Error(%22BAD%20PATCH!%20%22%20%2B%20JSON.stringify(intact)%20%2B%20%22%20size%3D%22%20%2B%20(showingTo%20-%20showingFrom)%20%2B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22%20nodes%3D%22%20%2B%20lineDiv.childNodes.length)%3B%0A%0A%20%20%20%20%20%20function%20checkHeights()%20%7B%0A%20%20%20%20%20%20%20%20var%20curNode%20%3D%20lineDiv.firstChild%2C%20heightChanged%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20doc.iter(showingFrom%2C%20showingTo%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20Work%20around%20bizarro%20IE7%20bug%20where%2C%20sometimes%2C%20our%20curNode%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20is%20magically%20replaced%20with%20a%20new%20node%20in%20the%20DOM%2C%20leaving%0A%20%20%20%20%20%20%20%20%20%20%2F%2F%20us%20with%20a%20reference%20to%20an%20orphan%20(nextSibling-less)%20node.%0A%20%20%20%20%20%20%20%20%20%20if%20(!curNode)%20return%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(!line.hidden)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20height%20%3D%20Math.round(curNode.offsetHeight%20%2F%20th)%20%7C%7C%201%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(line.height%20!%3D%20height)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20updateLineHeight(line%2C%20height)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20gutterDirty%20%3D%20heightChanged%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20curNode%20%3D%20curNode.nextSibling%3B%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20return%20heightChanged%3B%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20if%20(options.lineWrapping)%20checkHeights()%3B%0A%0A%20%20%20%20%20%20gutter.style.display%20%3D%20gutterDisplay%3B%0A%20%20%20%20%20%20if%20(different%20%7C%7C%20gutterDirty)%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20If%20the%20gutter%20grew%20in%20size%2C%20re-check%20heights.%20If%20those%20changed%2C%20re-draw%20gutter.%0A%20%20%20%20%20%20%20%20updateGutter()%20%26%26%20options.lineWrapping%20%26%26%20checkHeights()%20%26%26%20updateGutter()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20updateVerticalScroll(scrollTop)%3B%0A%20%20%20%20%20%20updateSelection()%3B%0A%20%20%20%20%20%20if%20(!suppressCallback%20%26%26%20options.onUpdate)%20options.onUpdate(instance)%3B%0A%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20computeIntact(intact%2C%20changes)%20%7B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20l%20%3D%20changes.length%20%7C%7C%200%3B%20i%20%3C%20l%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20change%20%3D%20changes%5Bi%5D%2C%20intact2%20%3D%20%5B%5D%2C%20diff%20%3D%20change.diff%20%7C%7C%200%3B%0A%20%20%20%20%20%20%20%20for%20(var%20j%20%3D%200%2C%20l2%20%3D%20intact.length%3B%20j%20%3C%20l2%3B%20%2B%2Bj)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20range%20%3D%20intact%5Bj%5D%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(change.to%20%3C%3D%20range.from%20%26%26%20change.diff)%0A%20%20%20%20%20%20%20%20%20%20%20%20intact2.push(%7Bfrom%3A%20range.from%20%2B%20diff%2C%20to%3A%20range.to%20%2B%20diff%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20domStart%3A%20range.domStart%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20else%20if%20(change.to%20%3C%3D%20range.from%20%7C%7C%20change.from%20%3E%3D%20range.to)%0A%20%20%20%20%20%20%20%20%20%20%20%20intact2.push(range)%3B%0A%20%20%20%20%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(change.from%20%3E%20range.from)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20intact2.push(%7Bfrom%3A%20range.from%2C%20to%3A%20change.from%2C%20domStart%3A%20range.domStart%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(change.to%20%3C%20range.to)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20intact2.push(%7Bfrom%3A%20change.to%20%2B%20diff%2C%20to%3A%20range.to%20%2B%20diff%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20domStart%3A%20range.domStart%20%2B%20(change.to%20-%20range.from)%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20intact%20%3D%20intact2%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20intact%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20patchDisplay(from%2C%20to%2C%20intact)%20%7B%0A%20%20%20%20%20%20function%20killNode(node)%20%7B%0A%20%20%20%20%20%20%20%20var%20tmp%20%3D%20node.nextSibling%3B%0A%20%20%20%20%20%20%20%20node.parentNode.removeChild(node)%3B%0A%20%20%20%20%20%20%20%20return%20tmp%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%2F%2F%20The%20first%20pass%20removes%20the%20DOM%20nodes%20that%20aren't%20intact.%0A%20%20%20%20%20%20if%20(!intact.length)%20removeChildren(lineDiv)%3B%0A%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20domPos%20%3D%200%2C%20curNode%20%3D%20lineDiv.firstChild%2C%20n%3B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20intact.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20cur%20%3D%20intact%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20%20%20while%20(cur.domStart%20%3E%20domPos)%20%7BcurNode%20%3D%20killNode(curNode)%3B%20domPos%2B%2B%3B%7D%0A%20%20%20%20%20%20%20%20%20%20for%20(var%20j%20%3D%200%2C%20e%20%3D%20cur.to%20-%20cur.from%3B%20j%20%3C%20e%3B%20%2B%2Bj)%20%7BcurNode%20%3D%20curNode.nextSibling%3B%20domPos%2B%2B%3B%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20while%20(curNode)%20curNode%20%3D%20killNode(curNode)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%2F%2F%20This%20pass%20fills%20in%20the%20lines%20that%20actually%20changed.%0A%20%20%20%20%20%20var%20nextIntact%20%3D%20intact.shift()%2C%20curNode%20%3D%20lineDiv.firstChild%2C%20j%20%3D%20from%3B%0A%20%20%20%20%20%20doc.iter(from%2C%20to%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20if%20(nextIntact%20%26%26%20nextIntact.to%20%3D%3D%20j)%20nextIntact%20%3D%20intact.shift()%3B%0A%20%20%20%20%20%20%20%20if%20(!nextIntact%20%7C%7C%20nextIntact.from%20%3E%20j)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(line.hidden)%20var%20lineElement%20%3D%20elt(%22pre%22)%3B%0A%20%20%20%20%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20lineElement%20%3D%20lineContent(line)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(line.className)%20lineElement.className%20%3D%20line.className%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Kludge%20to%20make%20sure%20the%20styled%20element%20lies%20behind%20the%20selection%20(by%20z-index)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(line.bgClassName)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20pre%20%3D%20elt(%22pre%22%2C%20%22%5Cu00a0%22%2C%20line.bgClassName%2C%20%22position%3A%20absolute%3B%20left%3A%200%3B%20right%3A%200%3B%20top%3A%200%3B%20bottom%3A%200%3B%20z-index%3A%20-2%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20lineElement%20%3D%20elt(%22div%22%2C%20%5Bpre%2C%20lineElement%5D%2C%20null%2C%20%22position%3A%20relative%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20lineDiv.insertBefore(lineElement%2C%20curNode)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20curNode%20%3D%20curNode.nextSibling%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%2B%2Bj%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20updateGutter()%20%7B%0A%20%20%20%20%20%20if%20(!options.gutter%20%26%26%20!options.lineNumbers)%20return%3B%0A%20%20%20%20%20%20var%20hText%20%3D%20mover.offsetHeight%2C%20hEditor%20%3D%20scroller.clientHeight%3B%0A%20%20%20%20%20%20gutter.style.height%20%3D%20(hText%20-%20hEditor%20%3C%202%20%3F%20hEditor%20%3A%20hText)%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20var%20fragment%20%3D%20document.createDocumentFragment()%2C%20i%20%3D%20showingFrom%2C%20normalNode%3B%0A%20%20%20%20%20%20doc.iter(showingFrom%2C%20Math.max(showingTo%2C%20showingFrom%20%2B%201)%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20if%20(line.hidden)%20%7B%0A%20%20%20%20%20%20%20%20%20%20fragment.appendChild(elt(%22pre%22))%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20marker%20%3D%20line.gutterMarker%3B%0A%20%20%20%20%20%20%20%20%20%20var%20text%20%3D%20options.lineNumbers%20%3F%20options.lineNumberFormatter(i%20%2B%20options.firstLineNumber)%20%3A%20null%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(marker%20%26%26%20marker.text)%0A%20%20%20%20%20%20%20%20%20%20%20%20text%20%3D%20marker.text.replace(%22%25N%25%22%2C%20text%20!%3D%20null%20%3F%20text%20%3A%20%22%22)%3B%0A%20%20%20%20%20%20%20%20%20%20else%20if%20(text%20%3D%3D%20null)%0A%20%20%20%20%20%20%20%20%20%20%20%20text%20%3D%20%22%5Cu00a0%22%3B%0A%20%20%20%20%20%20%20%20%20%20var%20markerElement%20%3D%20fragment.appendChild(elt(%22pre%22%2C%20null%2C%20marker%20%26%26%20marker.style))%3B%0A%20%20%20%20%20%20%20%20%20%20markerElement.innerHTML%20%3D%20text%3B%0A%20%20%20%20%20%20%20%20%20%20for%20(var%20j%20%3D%201%3B%20j%20%3C%20line.height%3B%20%2B%2Bj)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20markerElement.appendChild(elt(%22br%22))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20markerElement.appendChild(document.createTextNode(%22%5Cu00a0%22))%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20if%20(!marker)%20normalNode%20%3D%20i%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%2B%2Bi%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20gutter.style.display%20%3D%20%22none%22%3B%0A%20%20%20%20%20%20removeChildrenAndAdd(gutterText%2C%20fragment)%3B%0A%20%20%20%20%20%20%2F%2F%20Make%20sure%20scrolling%20doesn't%20cause%20number%20gutter%20size%20to%20pop%0A%20%20%20%20%20%20if%20(normalNode%20!%3D%20null%20%26%26%20options.lineNumbers)%20%7B%0A%20%20%20%20%20%20%20%20var%20node%20%3D%20gutterText.childNodes%5BnormalNode%20-%20showingFrom%5D%3B%0A%20%20%20%20%20%20%20%20var%20minwidth%20%3D%20String(doc.size).length%2C%20val%20%3D%20eltText(node.firstChild)%2C%20pad%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20while%20(val.length%20%2B%20pad.length%20%3C%20minwidth)%20pad%20%2B%3D%20%22%5Cu00a0%22%3B%0A%20%20%20%20%20%20%20%20if%20(pad)%20node.insertBefore(document.createTextNode(pad)%2C%20node.firstChild)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20gutter.style.display%20%3D%20%22%22%3B%0A%20%20%20%20%20%20var%20resized%20%3D%20Math.abs((parseInt(lineSpace.style.marginLeft)%20%7C%7C%200)%20-%20gutter.offsetWidth)%20%3E%202%3B%0A%20%20%20%20%20%20lineSpace.style.marginLeft%20%3D%20gutter.offsetWidth%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20gutterDirty%20%3D%20false%3B%0A%20%20%20%20%20%20return%20resized%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20updateSelection()%20%7B%0A%20%20%20%20%20%20var%20collapsed%20%3D%20posEq(sel.from%2C%20sel.to)%3B%0A%20%20%20%20%20%20var%20fromPos%20%3D%20localCoords(sel.from%2C%20true)%3B%0A%20%20%20%20%20%20var%20toPos%20%3D%20collapsed%20%3F%20fromPos%20%3A%20localCoords(sel.to%2C%20true)%3B%0A%20%20%20%20%20%20var%20headPos%20%3D%20sel.inverted%20%3F%20fromPos%20%3A%20toPos%2C%20th%20%3D%20textHeight()%3B%0A%20%20%20%20%20%20var%20wrapOff%20%3D%20eltOffset(wrapper)%2C%20lineOff%20%3D%20eltOffset(lineDiv)%3B%0A%20%20%20%20%20%20inputDiv.style.top%20%3D%20Math.max(0%2C%20Math.min(scroller.offsetHeight%2C%20headPos.y%20%2B%20lineOff.top%20-%20wrapOff.top))%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20inputDiv.style.left%20%3D%20Math.max(0%2C%20Math.min(scroller.offsetWidth%2C%20headPos.x%20%2B%20lineOff.left%20-%20wrapOff.left))%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20if%20(collapsed)%20%7B%0A%20%20%20%20%20%20%20%20cursor.style.top%20%3D%20headPos.y%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20cursor.style.left%20%3D%20(options.lineWrapping%20%3F%20Math.min(headPos.x%2C%20lineSpace.offsetWidth)%20%3A%20headPos.x)%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20cursor.style.display%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20selectionDiv.style.display%20%3D%20%22none%22%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20sameLine%20%3D%20fromPos.y%20%3D%3D%20toPos.y%2C%20fragment%20%3D%20document.createDocumentFragment()%3B%0A%20%20%20%20%20%20%20%20var%20clientWidth%20%3D%20lineSpace.clientWidth%20%7C%7C%20lineSpace.offsetWidth%3B%0A%20%20%20%20%20%20%20%20var%20clientHeight%20%3D%20lineSpace.clientHeight%20%7C%7C%20lineSpace.offsetHeight%3B%0A%20%20%20%20%20%20%20%20var%20add%20%3D%20function(left%2C%20top%2C%20right%2C%20height)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20rstyle%20%3D%20quirksMode%20%3F%20%22width%3A%20%22%20%2B%20(!right%20%3F%20clientWidth%20%3A%20clientWidth%20-%20right%20-%20left)%20%2B%20%22px%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%20%22right%3A%20%22%20%2B%20right%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20%20%20fragment.appendChild(elt(%22div%22%2C%20null%2C%20%22CodeMirror-selected%22%2C%20%22position%3A%20absolute%3B%20left%3A%20%22%20%2B%20left%20%2B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22px%3B%20top%3A%20%22%20%2B%20top%20%2B%20%22px%3B%20%22%20%2B%20rstyle%20%2B%20%22%3B%20height%3A%20%22%20%2B%20height%20%2B%20%22px%22))%3B%0A%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%20%20if%20(sel.from.ch%20%26%26%20fromPos.y%20%3E%3D%200)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20right%20%3D%20sameLine%20%3F%20clientWidth%20-%20toPos.x%20%3A%200%3B%0A%20%20%20%20%20%20%20%20%20%20add(fromPos.x%2C%20fromPos.y%2C%20right%2C%20th)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20var%20middleStart%20%3D%20Math.max(0%2C%20fromPos.y%20%2B%20(sel.from.ch%20%3F%20th%20%3A%200))%3B%0A%20%20%20%20%20%20%20%20var%20middleHeight%20%3D%20Math.min(toPos.y%2C%20clientHeight)%20-%20middleStart%3B%0A%20%20%20%20%20%20%20%20if%20(middleHeight%20%3E%200.2%20*%20th)%0A%20%20%20%20%20%20%20%20%20%20add(0%2C%20middleStart%2C%200%2C%20middleHeight)%3B%0A%20%20%20%20%20%20%20%20if%20((!sameLine%20%7C%7C%20!sel.from.ch)%20%26%26%20toPos.y%20%3C%20clientHeight%20-%20.5%20*%20th)%0A%20%20%20%20%20%20%20%20%20%20add(0%2C%20toPos.y%2C%20clientWidth%20-%20toPos.x%2C%20th)%3B%0A%20%20%20%20%20%20%20%20removeChildrenAndAdd(selectionDiv%2C%20fragment)%3B%0A%20%20%20%20%20%20%20%20cursor.style.display%20%3D%20%22none%22%3B%0A%20%20%20%20%20%20%20%20selectionDiv.style.display%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20setShift(val)%20%7B%0A%20%20%20%20%20%20if%20(val)%20shiftSelecting%20%3D%20shiftSelecting%20%7C%7C%20(sel.inverted%20%3F%20sel.to%20%3A%20sel.from)%3B%0A%20%20%20%20%20%20else%20shiftSelecting%20%3D%20null%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20setSelectionUser(from%2C%20to)%20%7B%0A%20%20%20%20%20%20var%20sh%20%3D%20shiftSelecting%20%26%26%20clipPos(shiftSelecting)%3B%0A%20%20%20%20%20%20if%20(sh)%20%7B%0A%20%20%20%20%20%20%20%20if%20(posLess(sh%2C%20from))%20from%20%3D%20sh%3B%0A%20%20%20%20%20%20%20%20else%20if%20(posLess(to%2C%20sh))%20to%20%3D%20sh%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20setSelection(from%2C%20to)%3B%0A%20%20%20%20%20%20userSelChange%20%3D%20true%3B%0A%20%20%20%20%7D%0A%20%20%20%20%2F%2F%20Update%20the%20selection.%20Last%20two%20args%20are%20only%20used%20by%0A%20%20%20%20%2F%2F%20updateLines%2C%20since%20they%20have%20to%20be%20expressed%20in%20the%20line%0A%20%20%20%20%2F%2F%20numbers%20before%20the%20update.%0A%20%20%20%20function%20setSelection(from%2C%20to%2C%20oldFrom%2C%20oldTo)%20%7B%0A%20%20%20%20%20%20goalColumn%20%3D%20null%3B%0A%20%20%20%20%20%20if%20(oldFrom%20%3D%3D%20null)%20%7BoldFrom%20%3D%20sel.from.line%3B%20oldTo%20%3D%20sel.to.line%3B%7D%0A%20%20%20%20%20%20if%20(posEq(sel.from%2C%20from)%20%26%26%20posEq(sel.to%2C%20to))%20return%3B%0A%20%20%20%20%20%20if%20(posLess(to%2C%20from))%20%7Bvar%20tmp%20%3D%20to%3B%20to%20%3D%20from%3B%20from%20%3D%20tmp%3B%7D%0A%0A%20%20%20%20%20%20%2F%2F%20Skip%20over%20hidden%20lines.%0A%20%20%20%20%20%20if%20(from.line%20!%3D%20oldFrom)%20%7B%0A%20%20%20%20%20%20%20%20var%20from1%20%3D%20skipHidden(from%2C%20oldFrom%2C%20sel.from.ch)%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20If%20there%20is%20no%20non-hidden%20line%20left%2C%20force%20visibility%20on%20current%20line%0A%20%20%20%20%20%20%20%20if%20(!from1)%20setLineHidden(from.line%2C%20false)%3B%0A%20%20%20%20%20%20%20%20else%20from%20%3D%20from1%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(to.line%20!%3D%20oldTo)%20to%20%3D%20skipHidden(to%2C%20oldTo%2C%20sel.to.ch)%3B%0A%0A%20%20%20%20%20%20if%20(posEq(from%2C%20to))%20sel.inverted%20%3D%20false%3B%0A%20%20%20%20%20%20else%20if%20(posEq(from%2C%20sel.to))%20sel.inverted%20%3D%20false%3B%0A%20%20%20%20%20%20else%20if%20(posEq(to%2C%20sel.from))%20sel.inverted%20%3D%20true%3B%0A%0A%20%20%20%20%20%20if%20(options.autoClearEmptyLines%20%26%26%20posEq(sel.from%2C%20sel.to))%20%7B%0A%20%20%20%20%20%20%20%20var%20head%20%3D%20sel.inverted%20%3F%20from%20%3A%20to%3B%0A%20%20%20%20%20%20%20%20if%20(head.line%20!%3D%20sel.from.line%20%26%26%20sel.from.line%20%3C%20doc.size)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20oldLine%20%3D%20getLine(sel.from.line)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(%2F%5E%5Cs%2B%24%2F.test(oldLine.text))%0A%20%20%20%20%20%20%20%20%20%20%20%20setTimeout(operation(function()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(oldLine.parent%20%26%26%20%2F%5E%5Cs%2B%24%2F.test(oldLine.text))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20no%20%3D%20lineNo(oldLine)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20replaceRange(%22%22%2C%20%7Bline%3A%20no%2C%20ch%3A%200%7D%2C%20%7Bline%3A%20no%2C%20ch%3A%20oldLine.text.length%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%2010))%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20sel.from%20%3D%20from%3B%20sel.to%20%3D%20to%3B%0A%20%20%20%20%20%20selectionChanged%20%3D%20true%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20skipHidden(pos%2C%20oldLine%2C%20oldCh)%20%7B%0A%20%20%20%20%20%20function%20getNonHidden(dir)%20%7B%0A%20%20%20%20%20%20%20%20var%20lNo%20%3D%20pos.line%20%2B%20dir%2C%20end%20%3D%20dir%20%3D%3D%201%20%3F%20doc.size%20%3A%20-1%3B%0A%20%20%20%20%20%20%20%20while%20(lNo%20!%3D%20end)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20line%20%3D%20getLine(lNo)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(!line.hidden)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20ch%20%3D%20pos.ch%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(toEnd%20%7C%7C%20ch%20%3E%20oldCh%20%7C%7C%20ch%20%3E%20line.text.length)%20ch%20%3D%20line.text.length%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20%7Bline%3A%20lNo%2C%20ch%3A%20ch%7D%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20lNo%20%2B%3D%20dir%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20line%20%3D%20getLine(pos.line)%3B%0A%20%20%20%20%20%20var%20toEnd%20%3D%20pos.ch%20%3D%3D%20line.text.length%20%26%26%20pos.ch%20!%3D%20oldCh%3B%0A%20%20%20%20%20%20if%20(!line.hidden)%20return%20pos%3B%0A%20%20%20%20%20%20if%20(pos.line%20%3E%3D%20oldLine)%20return%20getNonHidden(1)%20%7C%7C%20getNonHidden(-1)%3B%0A%20%20%20%20%20%20else%20return%20getNonHidden(-1)%20%7C%7C%20getNonHidden(1)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20setCursor(line%2C%20ch%2C%20user)%20%7B%0A%20%20%20%20%20%20var%20pos%20%3D%20clipPos(%7Bline%3A%20line%2C%20ch%3A%20ch%20%7C%7C%200%7D)%3B%0A%20%20%20%20%20%20(user%20%3F%20setSelectionUser%20%3A%20setSelection)(pos%2C%20pos)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20clipLine(n)%20%7Breturn%20Math.max(0%2C%20Math.min(n%2C%20doc.size-1))%3B%7D%0A%20%20%20%20function%20clipPos(pos)%20%7B%0A%20%20%20%20%20%20if%20(pos.line%20%3C%200)%20return%20%7Bline%3A%200%2C%20ch%3A%200%7D%3B%0A%20%20%20%20%20%20if%20(pos.line%20%3E%3D%20doc.size)%20return%20%7Bline%3A%20doc.size-1%2C%20ch%3A%20getLine(doc.size-1).text.length%7D%3B%0A%20%20%20%20%20%20var%20ch%20%3D%20pos.ch%2C%20linelen%20%3D%20getLine(pos.line).text.length%3B%0A%20%20%20%20%20%20if%20(ch%20%3D%3D%20null%20%7C%7C%20ch%20%3E%20linelen)%20return%20%7Bline%3A%20pos.line%2C%20ch%3A%20linelen%7D%3B%0A%20%20%20%20%20%20else%20if%20(ch%20%3C%200)%20return%20%7Bline%3A%20pos.line%2C%20ch%3A%200%7D%3B%0A%20%20%20%20%20%20else%20return%20pos%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20findPosH(dir%2C%20unit)%20%7B%0A%20%20%20%20%20%20var%20end%20%3D%20sel.inverted%20%3F%20sel.from%20%3A%20sel.to%2C%20line%20%3D%20end.line%2C%20ch%20%3D%20end.ch%3B%0A%20%20%20%20%20%20var%20lineObj%20%3D%20getLine(line)%3B%0A%20%20%20%20%20%20function%20findNextLine()%20%7B%0A%20%20%20%20%20%20%20%20for%20(var%20l%20%3D%20line%20%2B%20dir%2C%20e%20%3D%20dir%20%3C%200%20%3F%20-1%20%3A%20doc.size%3B%20l%20!%3D%20e%3B%20l%20%2B%3D%20dir)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20lo%20%3D%20getLine(l)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(!lo.hidden)%20%7B%20line%20%3D%20l%3B%20lineObj%20%3D%20lo%3B%20return%20true%3B%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20function%20moveOnce(boundToLine)%20%7B%0A%20%20%20%20%20%20%20%20if%20(ch%20%3D%3D%20(dir%20%3C%200%20%3F%200%20%3A%20lineObj.text.length))%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(!boundToLine%20%26%26%20findNextLine())%20ch%20%3D%20dir%20%3C%200%20%3F%20lineObj.text.length%20%3A%200%3B%0A%20%20%20%20%20%20%20%20%20%20else%20return%20false%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20ch%20%2B%3D%20dir%3B%0A%20%20%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(unit%20%3D%3D%20%22char%22)%20moveOnce()%3B%0A%20%20%20%20%20%20else%20if%20(unit%20%3D%3D%20%22column%22)%20moveOnce(true)%3B%0A%20%20%20%20%20%20else%20if%20(unit%20%3D%3D%20%22word%22)%20%7B%0A%20%20%20%20%20%20%20%20var%20sawWord%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20for%20(%3B%3B)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(dir%20%3C%200)%20if%20(!moveOnce())%20break%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(isWordChar(lineObj.text.charAt(ch)))%20sawWord%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%20%20else%20if%20(sawWord)%20%7Bif%20(dir%20%3C%200)%20%7Bdir%20%3D%201%3B%20moveOnce()%3B%7D%20break%3B%7D%0A%20%20%20%20%20%20%20%20%20%20if%20(dir%20%3E%200)%20if%20(!moveOnce())%20break%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20%7Bline%3A%20line%2C%20ch%3A%20ch%7D%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20moveH(dir%2C%20unit)%20%7B%0A%20%20%20%20%20%20var%20pos%20%3D%20dir%20%3C%200%20%3F%20sel.from%20%3A%20sel.to%3B%0A%20%20%20%20%20%20if%20(shiftSelecting%20%7C%7C%20posEq(sel.from%2C%20sel.to))%20pos%20%3D%20findPosH(dir%2C%20unit)%3B%0A%20%20%20%20%20%20setCursor(pos.line%2C%20pos.ch%2C%20true)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20deleteH(dir%2C%20unit)%20%7B%0A%20%20%20%20%20%20if%20(!posEq(sel.from%2C%20sel.to))%20replaceRange(%22%22%2C%20sel.from%2C%20sel.to)%3B%0A%20%20%20%20%20%20else%20if%20(dir%20%3C%200)%20replaceRange(%22%22%2C%20findPosH(dir%2C%20unit)%2C%20sel.to)%3B%0A%20%20%20%20%20%20else%20replaceRange(%22%22%2C%20sel.from%2C%20findPosH(dir%2C%20unit))%3B%0A%20%20%20%20%20%20userSelChange%20%3D%20true%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20moveV(dir%2C%20unit)%20%7B%0A%20%20%20%20%20%20var%20dist%20%3D%200%2C%20pos%20%3D%20localCoords(sel.inverted%20%3F%20sel.from%20%3A%20sel.to%2C%20true)%3B%0A%20%20%20%20%20%20if%20(goalColumn%20!%3D%20null)%20pos.x%20%3D%20goalColumn%3B%0A%20%20%20%20%20%20if%20(unit%20%3D%3D%20%22page%22)%20%7B%0A%20%20%20%20%20%20%20%20var%20screen%20%3D%20Math.min(scroller.clientHeight%2C%20window.innerHeight%20%7C%7C%20document.documentElement.clientHeight)%3B%0A%20%20%20%20%20%20%20%20var%20target%20%3D%20coordsChar(pos.x%2C%20pos.y%20%2B%20screen%20*%20dir)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(unit%20%3D%3D%20%22line%22)%20%7B%0A%20%20%20%20%20%20%20%20var%20th%20%3D%20textHeight()%3B%0A%20%20%20%20%20%20%20%20var%20target%20%3D%20coordsChar(pos.x%2C%20pos.y%20%2B%20.5%20*%20th%20%2B%20dir%20*%20th)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(unit%20%3D%3D%20%22page%22)%20scrollbar.scrollTop%20%2B%3D%20localCoords(target%2C%20true).y%20-%20pos.y%3B%0A%20%20%20%20%20%20setCursor(target.line%2C%20target.ch%2C%20true)%3B%0A%20%20%20%20%20%20goalColumn%20%3D%20pos.x%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20findWordAt(pos)%20%7B%0A%20%20%20%20%20%20var%20line%20%3D%20getLine(pos.line).text%3B%0A%20%20%20%20%20%20var%20start%20%3D%20pos.ch%2C%20end%20%3D%20pos.ch%3B%0A%20%20%20%20%20%20if%20(line)%20%7B%0A%20%20%20%20%20%20%20%20if%20(pos.after%20%3D%3D%3D%20false%20%7C%7C%20end%20%3D%3D%20line.length)%20--start%3B%20else%20%2B%2Bend%3B%0A%20%20%20%20%20%20%20%20var%20startChar%20%3D%20line.charAt(start)%3B%0A%20%20%20%20%20%20%20%20var%20check%20%3D%20isWordChar(startChar)%20%3F%20isWordChar%20%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%5Cs%2F.test(startChar)%20%3F%20function(ch)%20%7Breturn%20%2F%5Cs%2F.test(ch)%3B%7D%20%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20function(ch)%20%7Breturn%20!%2F%5Cs%2F.test(ch)%20%26%26%20!isWordChar(ch)%3B%7D%3B%0A%20%20%20%20%20%20%20%20while%20(start%20%3E%200%20%26%26%20check(line.charAt(start%20-%201)))%20--start%3B%0A%20%20%20%20%20%20%20%20while%20(end%20%3C%20line.length%20%26%26%20check(line.charAt(end)))%20%2B%2Bend%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20%7Bfrom%3A%20%7Bline%3A%20pos.line%2C%20ch%3A%20start%7D%2C%20to%3A%20%7Bline%3A%20pos.line%2C%20ch%3A%20end%7D%7D%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20selectLine(line)%20%7B%0A%20%20%20%20%20%20setSelectionUser(%7Bline%3A%20line%2C%20ch%3A%200%7D%2C%20clipPos(%7Bline%3A%20line%20%2B%201%2C%20ch%3A%200%7D))%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20indentSelected(mode)%20%7B%0A%20%20%20%20%20%20if%20(posEq(sel.from%2C%20sel.to))%20return%20indentLine(sel.from.line%2C%20mode)%3B%0A%20%20%20%20%20%20var%20e%20%3D%20sel.to.line%20-%20(sel.to.ch%20%3F%200%20%3A%201)%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%20sel.from.line%3B%20i%20%3C%3D%20e%3B%20%2B%2Bi)%20indentLine(i%2C%20mode)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20indentLine(n%2C%20how)%20%7B%0A%20%20%20%20%20%20if%20(!how)%20how%20%3D%20%22add%22%3B%0A%20%20%20%20%20%20if%20(how%20%3D%3D%20%22smart%22)%20%7B%0A%20%20%20%20%20%20%20%20if%20(!mode.indent)%20how%20%3D%20%22prev%22%3B%0A%20%20%20%20%20%20%20%20else%20var%20state%20%3D%20getStateBefore(n)%3B%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20var%20line%20%3D%20getLine(n)%2C%20curSpace%20%3D%20line.indentation(options.tabSize)%2C%0A%20%20%20%20%20%20%20%20%20%20curSpaceString%20%3D%20line.text.match(%2F%5E%5Cs*%2F)%5B0%5D%2C%20indentation%3B%0A%20%20%20%20%20%20if%20(how%20%3D%3D%20%22smart%22)%20%7B%0A%20%20%20%20%20%20%20%20indentation%20%3D%20mode.indent(state%2C%20line.text.slice(curSpaceString.length)%2C%20line.text)%3B%0A%20%20%20%20%20%20%20%20if%20(indentation%20%3D%3D%20Pass)%20how%20%3D%20%22prev%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(how%20%3D%3D%20%22prev%22)%20%7B%0A%20%20%20%20%20%20%20%20if%20(n)%20indentation%20%3D%20getLine(n-1).indentation(options.tabSize)%3B%0A%20%20%20%20%20%20%20%20else%20indentation%20%3D%200%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20if%20(how%20%3D%3D%20%22add%22)%20indentation%20%3D%20curSpace%20%2B%20options.indentUnit%3B%0A%20%20%20%20%20%20else%20if%20(how%20%3D%3D%20%22subtract%22)%20indentation%20%3D%20curSpace%20-%20options.indentUnit%3B%0A%20%20%20%20%20%20indentation%20%3D%20Math.max(0%2C%20indentation)%3B%0A%20%20%20%20%20%20var%20diff%20%3D%20indentation%20-%20curSpace%3B%0A%0A%20%20%20%20%20%20var%20indentString%20%3D%20%22%22%2C%20pos%20%3D%200%3B%0A%20%20%20%20%20%20if%20(options.indentWithTabs)%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%20Math.floor(indentation%20%2F%20options.tabSize)%3B%20i%3B%20--i)%20%7Bpos%20%2B%3D%20options.tabSize%3B%20indentString%20%2B%3D%20%22%5Ct%22%3B%7D%0A%20%20%20%20%20%20if%20(pos%20%3C%20indentation)%20indentString%20%2B%3D%20spaceStr(indentation%20-%20pos)%3B%0A%0A%20%20%20%20%20%20if%20(indentString%20!%3D%20curSpaceString)%0A%20%20%20%20%20%20%20%20replaceRange(indentString%2C%20%7Bline%3A%20n%2C%20ch%3A%200%7D%2C%20%7Bline%3A%20n%2C%20ch%3A%20curSpaceString.length%7D)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20loadMode()%20%7B%0A%20%20%20%20%20%20mode%20%3D%20CodeMirror.getMode(options%2C%20options.mode)%3B%0A%20%20%20%20%20%20doc.iter(0%2C%20doc.size%2C%20function(line)%20%7B%20line.stateAfter%20%3D%20null%3B%20%7D)%3B%0A%20%20%20%20%20%20frontier%20%3D%200%3B%0A%20%20%20%20%20%20startWorker(100)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20gutterChanged()%20%7B%0A%20%20%20%20%20%20var%20visible%20%3D%20options.gutter%20%7C%7C%20options.lineNumbers%3B%0A%20%20%20%20%20%20gutter.style.display%20%3D%20visible%20%3F%20%22%22%20%3A%20%22none%22%3B%0A%20%20%20%20%20%20if%20(visible)%20gutterDirty%20%3D%20true%3B%0A%20%20%20%20%20%20else%20lineDiv.parentNode.style.marginLeft%20%3D%200%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20wrappingChanged(from%2C%20to)%20%7B%0A%20%20%20%20%20%20if%20(options.lineWrapping)%20%7B%0A%20%20%20%20%20%20%20%20wrapper.className%20%2B%3D%20%22%20CodeMirror-wrap%22%3B%0A%20%20%20%20%20%20%20%20var%20perLine%20%3D%20scroller.clientWidth%20%2F%20charWidth()%20-%203%3B%0A%20%20%20%20%20%20%20%20doc.iter(0%2C%20doc.size%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(line.hidden)%20return%3B%0A%20%20%20%20%20%20%20%20%20%20var%20guess%20%3D%20Math.ceil(line.text.length%20%2F%20perLine)%20%7C%7C%201%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(guess%20!%3D%201)%20updateLineHeight(line%2C%20guess)%3B%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20lineSpace.style.minWidth%20%3D%20widthForcer.style.left%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20wrapper.className%20%3D%20wrapper.className.replace(%22%20CodeMirror-wrap%22%2C%20%22%22)%3B%0A%20%20%20%20%20%20%20%20computeMaxLength()%3B%0A%20%20%20%20%20%20%20%20doc.iter(0%2C%20doc.size%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(line.height%20!%3D%201%20%26%26%20!line.hidden)%20updateLineHeight(line%2C%201)%3B%0A%20%20%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20changes.push(%7Bfrom%3A%200%2C%20to%3A%20doc.size%7D)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20themeChanged()%20%7B%0A%20%20%20%20%20%20scroller.className%20%3D%20scroller.className.replace(%2F%5Cs*cm-s-%5CS%2B%2Fg%2C%20%22%22)%20%2B%0A%20%20%20%20%20%20%20%20options.theme.replace(%2F(%5E%7C%5Cs)%5Cs*%2Fg%2C%20%22%20cm-s-%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20keyMapChanged()%20%7B%0A%20%20%20%20%20%20var%20style%20%3D%20keyMap%5Boptions.keyMap%5D.style%3B%0A%20%20%20%20%20%20wrapper.className%20%3D%20wrapper.className.replace(%2F%5Cs*cm-keymap-%5CS%2B%2Fg%2C%20%22%22)%20%2B%0A%20%20%20%20%20%20%20%20(style%20%3F%20%22%20cm-keymap-%22%20%2B%20style%20%3A%20%22%22)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20TextMarker(type%2C%20style)%20%7B%20this.lines%20%3D%20%5B%5D%3B%20this.type%20%3D%20type%3B%20if%20(style)%20this.style%20%3D%20style%3B%20%7D%0A%20%20%20%20TextMarker.prototype.clear%20%3D%20operation(function()%20%7B%0A%20%20%20%20%20%20var%20min%20%3D%20Infinity%2C%20max%20%3D%20-Infinity%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20this.lines.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20line%20%3D%20this.lines%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20var%20span%20%3D%20getMarkedSpanFor(line.markedSpans%2C%20this%2C%20true)%3B%0A%20%20%20%20%20%20%20%20if%20(span.from%20!%3D%20null%20%7C%7C%20span.to%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20lineN%20%3D%20lineNo(line)%3B%0A%20%20%20%20%20%20%20%20%20%20min%20%3D%20Math.min(min%2C%20lineN)%3B%20max%20%3D%20Math.max(max%2C%20lineN)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(min%20!%3D%20Infinity)%0A%20%20%20%20%20%20%20%20changes.push(%7Bfrom%3A%20min%2C%20to%3A%20max%20%2B%201%7D)%3B%0A%20%20%20%20%20%20this.lines.length%20%3D%200%3B%0A%20%20%20%20%7D)%3B%0A%20%20%20%20TextMarker.prototype.find%20%3D%20function()%20%7B%0A%20%20%20%20%20%20var%20from%2C%20to%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20this.lines.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20line%20%3D%20this.lines%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20var%20span%20%3D%20getMarkedSpanFor(line.markedSpans%2C%20this)%3B%0A%20%20%20%20%20%20%20%20if%20(span.from%20!%3D%20null%20%7C%7C%20span.to%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20found%20%3D%20lineNo(line)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(span.from%20!%3D%20null)%20from%20%3D%20%7Bline%3A%20found%2C%20ch%3A%20span.from%7D%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(span.to%20!%3D%20null)%20to%20%3D%20%7Bline%3A%20found%2C%20ch%3A%20span.to%7D%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(this.type%20%3D%3D%20%22bookmark%22)%20return%20from%3B%0A%20%20%20%20%20%20return%20from%20%26%26%20%7Bfrom%3A%20from%2C%20to%3A%20to%7D%3B%0A%20%20%20%20%7D%3B%0A%0A%20%20%20%20function%20markText(from%2C%20to%2C%20className%2C%20options)%20%7B%0A%20%20%20%20%20%20from%20%3D%20clipPos(from)%3B%20to%20%3D%20clipPos(to)%3B%0A%20%20%20%20%20%20var%20marker%20%3D%20new%20TextMarker(%22range%22%2C%20className)%3B%0A%20%20%20%20%20%20if%20(options)%20for%20(var%20opt%20in%20options)%20if%20(options.hasOwnProperty(opt))%0A%20%20%20%20%20%20%20%20marker%5Bopt%5D%20%3D%20options%5Bopt%5D%3B%0A%20%20%20%20%20%20var%20curLine%20%3D%20from.line%3B%0A%20%20%20%20%20%20doc.iter(curLine%2C%20to.line%20%2B%201%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20var%20span%20%3D%20%7Bfrom%3A%20curLine%20%3D%3D%20from.line%20%3F%20from.ch%20%3A%20null%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20to%3A%20curLine%20%3D%3D%20to.line%20%3F%20to.ch%20%3A%20null%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20marker%3A%20marker%7D%3B%0A%20%20%20%20%20%20%20%20(line.markedSpans%20%7C%7C%20(line.markedSpans%20%3D%20%5B%5D)).push(span)%3B%0A%20%20%20%20%20%20%20%20marker.lines.push(line)%3B%0A%20%20%20%20%20%20%20%20%2B%2BcurLine%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20changes.push(%7Bfrom%3A%20from.line%2C%20to%3A%20to.line%20%2B%201%7D)%3B%0A%20%20%20%20%20%20return%20marker%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20setBookmark(pos)%20%7B%0A%20%20%20%20%20%20pos%20%3D%20clipPos(pos)%3B%0A%20%20%20%20%20%20var%20marker%20%3D%20new%20TextMarker(%22bookmark%22)%2C%20line%20%3D%20getLine(pos.line)%3B%0A%20%20%20%20%20%20var%20span%20%3D%20%7Bfrom%3A%20pos.ch%2C%20to%3A%20pos.ch%2C%20marker%3A%20marker%7D%3B%0A%20%20%20%20%20%20(line.markedSpans%20%7C%7C%20(line.markedSpans%20%3D%20%5B%5D)).push(span)%3B%0A%20%20%20%20%20%20marker.lines.push(line)%3B%0A%20%20%20%20%20%20return%20marker%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20findMarksAt(pos)%20%7B%0A%20%20%20%20%20%20pos%20%3D%20clipPos(pos)%3B%0A%20%20%20%20%20%20var%20markers%20%3D%20%5B%5D%2C%20spans%20%3D%20getLine(pos.line).markedSpans%3B%0A%20%20%20%20%20%20if%20(spans)%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20spans.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20span%20%3D%20spans%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20if%20((span.from%20%3D%3D%20null%20%7C%7C%20span.from%20%3C%3D%20pos.ch)%20%26%26%0A%20%20%20%20%20%20%20%20%20%20%20%20(span.to%20%3D%3D%20null%20%7C%7C%20span.to%20%3E%3D%20pos.ch))%0A%20%20%20%20%20%20%20%20%20%20markers.push(span.marker)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20markers%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20addGutterMarker(line%2C%20text%2C%20className)%20%7B%0A%20%20%20%20%20%20if%20(typeof%20line%20%3D%3D%20%22number%22)%20line%20%3D%20getLine(clipLine(line))%3B%0A%20%20%20%20%20%20line.gutterMarker%20%3D%20%7Btext%3A%20text%2C%20style%3A%20className%7D%3B%0A%20%20%20%20%20%20gutterDirty%20%3D%20true%3B%0A%20%20%20%20%20%20return%20line%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20removeGutterMarker(line)%20%7B%0A%20%20%20%20%20%20if%20(typeof%20line%20%3D%3D%20%22number%22)%20line%20%3D%20getLine(clipLine(line))%3B%0A%20%20%20%20%20%20line.gutterMarker%20%3D%20null%3B%0A%20%20%20%20%20%20gutterDirty%20%3D%20true%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20changeLine(handle%2C%20op)%20%7B%0A%20%20%20%20%20%20var%20no%20%3D%20handle%2C%20line%20%3D%20handle%3B%0A%20%20%20%20%20%20if%20(typeof%20handle%20%3D%3D%20%22number%22)%20line%20%3D%20getLine(clipLine(handle))%3B%0A%20%20%20%20%20%20else%20no%20%3D%20lineNo(handle)%3B%0A%20%20%20%20%20%20if%20(no%20%3D%3D%20null)%20return%20null%3B%0A%20%20%20%20%20%20if%20(op(line%2C%20no))%20changes.push(%7Bfrom%3A%20no%2C%20to%3A%20no%20%2B%201%7D)%3B%0A%20%20%20%20%20%20else%20return%20null%3B%0A%20%20%20%20%20%20return%20line%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20setLineClass(handle%2C%20className%2C%20bgClassName)%20%7B%0A%20%20%20%20%20%20return%20changeLine(handle%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20if%20(line.className%20!%3D%20className%20%7C%7C%20line.bgClassName%20!%3D%20bgClassName)%20%7B%0A%20%20%20%20%20%20%20%20%20%20line.className%20%3D%20className%3B%0A%20%20%20%20%20%20%20%20%20%20line.bgClassName%20%3D%20bgClassName%3B%0A%20%20%20%20%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20setLineHidden(handle%2C%20hidden)%20%7B%0A%20%20%20%20%20%20return%20changeLine(handle%2C%20function(line%2C%20no)%20%7B%0A%20%20%20%20%20%20%20%20if%20(line.hidden%20!%3D%20hidden)%20%7B%0A%20%20%20%20%20%20%20%20%20%20line.hidden%20%3D%20hidden%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(!options.lineWrapping)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(hidden%20%26%26%20line.text.length%20%3D%3D%20maxLine.text.length)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20updateMaxLine%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(!hidden%20%26%26%20line.text.length%20%3E%20maxLine.text.length)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20maxLine%20%3D%20line%3B%20updateMaxLine%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20updateLineHeight(line%2C%20hidden%20%3F%200%20%3A%201)%3B%0A%20%20%20%20%20%20%20%20%20%20var%20fline%20%3D%20sel.from.line%2C%20tline%20%3D%20sel.to.line%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(hidden%20%26%26%20(fline%20%3D%3D%20no%20%7C%7C%20tline%20%3D%3D%20no))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20from%20%3D%20fline%20%3D%3D%20no%20%3F%20skipHidden(%7Bline%3A%20fline%2C%20ch%3A%200%7D%2C%20fline%2C%200)%20%3A%20sel.from%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20to%20%3D%20tline%20%3D%3D%20no%20%3F%20skipHidden(%7Bline%3A%20tline%2C%20ch%3A%200%7D%2C%20tline%2C%200)%20%3A%20sel.to%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Can't%20hide%20the%20last%20visible%20line%2C%20we'd%20have%20no%20place%20to%20put%20the%20cursor%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(!to)%20return%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20setSelection(from%2C%20to)%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20return%20(gutterDirty%20%3D%20true)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20lineInfo(line)%20%7B%0A%20%20%20%20%20%20if%20(typeof%20line%20%3D%3D%20%22number%22)%20%7B%0A%20%20%20%20%20%20%20%20if%20(!isLine(line))%20return%20null%3B%0A%20%20%20%20%20%20%20%20var%20n%20%3D%20line%3B%0A%20%20%20%20%20%20%20%20line%20%3D%20getLine(line)%3B%0A%20%20%20%20%20%20%20%20if%20(!line)%20return%20null%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20n%20%3D%20lineNo(line)%3B%0A%20%20%20%20%20%20%20%20if%20(n%20%3D%3D%20null)%20return%20null%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20marker%20%3D%20line.gutterMarker%3B%0A%20%20%20%20%20%20return%20%7Bline%3A%20n%2C%20handle%3A%20line%2C%20text%3A%20line.text%2C%20markerText%3A%20marker%20%26%26%20marker.text%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20markerClass%3A%20marker%20%26%26%20marker.style%2C%20lineClass%3A%20line.className%2C%20bgClass%3A%20line.bgClassName%7D%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20measureLine(line%2C%20ch)%20%7B%0A%20%20%20%20%20%20if%20(ch%20%3D%3D%200)%20return%20%7Btop%3A%200%2C%20left%3A%200%7D%3B%0A%20%20%20%20%20%20var%20wbr%20%3D%20options.lineWrapping%20%26%26%20ch%20%3C%20line.text.length%20%26%26%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20spanAffectsWrapping.test(line.text.slice(ch%20-%201%2C%20ch%20%2B%201))%3B%0A%20%20%20%20%20%20var%20pre%20%3D%20lineContent(line%2C%20ch)%3B%0A%20%20%20%20%20%20removeChildrenAndAdd(measure%2C%20pre)%3B%0A%20%20%20%20%20%20var%20anchor%20%3D%20pre.anchor%3B%0A%20%20%20%20%20%20var%20top%20%3D%20anchor.offsetTop%2C%20left%20%3D%20anchor.offsetLeft%3B%0A%20%20%20%20%20%20%2F%2F%20Older%20IEs%20report%20zero%20offsets%20for%20spans%20directly%20after%20a%20wrap%0A%20%20%20%20%20%20if%20(ie%20%26%26%20top%20%3D%3D%200%20%26%26%20left%20%3D%3D%200)%20%7B%0A%20%20%20%20%20%20%20%20var%20backup%20%3D%20elt(%22span%22%2C%20%22x%22)%3B%0A%20%20%20%20%20%20%20%20anchor.parentNode.insertBefore(backup%2C%20anchor.nextSibling)%3B%0A%20%20%20%20%20%20%20%20top%20%3D%20backup.offsetTop%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20%7Btop%3A%20top%2C%20left%3A%20left%7D%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20localCoords(pos%2C%20inLineWrap)%20%7B%0A%20%20%20%20%20%20var%20x%2C%20lh%20%3D%20textHeight()%2C%20y%20%3D%20lh%20*%20(heightAtLine(doc%2C%20pos.line)%20-%20(inLineWrap%20%3F%20displayOffset%20%3A%200))%3B%0A%20%20%20%20%20%20if%20(pos.ch%20%3D%3D%200)%20x%20%3D%200%3B%0A%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20sp%20%3D%20measureLine(getLine(pos.line)%2C%20pos.ch)%3B%0A%20%20%20%20%20%20%20%20x%20%3D%20sp.left%3B%0A%20%20%20%20%20%20%20%20if%20(options.lineWrapping)%20y%20%2B%3D%20Math.max(0%2C%20sp.top)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20%7Bx%3A%20x%2C%20y%3A%20y%2C%20yBot%3A%20y%20%2B%20lh%7D%3B%0A%20%20%20%20%7D%0A%20%20%20%20%2F%2F%20Coords%20must%20be%20lineSpace-local%0A%20%20%20%20function%20coordsChar(x%2C%20y)%20%7B%0A%20%20%20%20%20%20var%20th%20%3D%20textHeight()%2C%20cw%20%3D%20charWidth()%2C%20heightPos%20%3D%20displayOffset%20%2B%20Math.floor(y%20%2F%20th)%3B%0A%20%20%20%20%20%20if%20(heightPos%20%3C%200)%20return%20%7Bline%3A%200%2C%20ch%3A%200%7D%3B%0A%20%20%20%20%20%20var%20lineNo%20%3D%20lineAtHeight(doc%2C%20heightPos)%3B%0A%20%20%20%20%20%20if%20(lineNo%20%3E%3D%20doc.size)%20return%20%7Bline%3A%20doc.size%20-%201%2C%20ch%3A%20getLine(doc.size%20-%201).text.length%7D%3B%0A%20%20%20%20%20%20var%20lineObj%20%3D%20getLine(lineNo)%2C%20text%20%3D%20lineObj.text%3B%0A%20%20%20%20%20%20var%20tw%20%3D%20options.lineWrapping%2C%20innerOff%20%3D%20tw%20%3F%20heightPos%20-%20heightAtLine(doc%2C%20lineNo)%20%3A%200%3B%0A%20%20%20%20%20%20if%20(x%20%3C%3D%200%20%26%26%20innerOff%20%3D%3D%200)%20return%20%7Bline%3A%20lineNo%2C%20ch%3A%200%7D%3B%0A%20%20%20%20%20%20var%20wrongLine%20%3D%20false%3B%0A%20%20%20%20%20%20function%20getX(len)%20%7B%0A%20%20%20%20%20%20%20%20var%20sp%20%3D%20measureLine(lineObj%2C%20len)%3B%0A%20%20%20%20%20%20%20%20if%20(tw)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20off%20%3D%20Math.round(sp.top%20%2F%20th)%3B%0A%20%20%20%20%20%20%20%20%20%20wrongLine%20%3D%20off%20!%3D%20innerOff%3B%0A%20%20%20%20%20%20%20%20%20%20return%20Math.max(0%2C%20sp.left%20%2B%20(off%20-%20innerOff)%20*%20scroller.clientWidth)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20return%20sp.left%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20from%20%3D%200%2C%20fromX%20%3D%200%2C%20to%20%3D%20text.length%2C%20toX%3B%0A%20%20%20%20%20%20%2F%2F%20Guess%20a%20suitable%20upper%20bound%20for%20our%20search.%0A%20%20%20%20%20%20var%20estimated%20%3D%20Math.min(to%2C%20Math.ceil((x%20%2B%20innerOff%20*%20scroller.clientWidth%20*%20.9)%20%2F%20cw))%3B%0A%20%20%20%20%20%20for%20(%3B%3B)%20%7B%0A%20%20%20%20%20%20%20%20var%20estX%20%3D%20getX(estimated)%3B%0A%20%20%20%20%20%20%20%20if%20(estX%20%3C%3D%20x%20%26%26%20estimated%20%3C%20to)%20estimated%20%3D%20Math.min(to%2C%20Math.ceil(estimated%20*%201.2))%3B%0A%20%20%20%20%20%20%20%20else%20%7BtoX%20%3D%20estX%3B%20to%20%3D%20estimated%3B%20break%3B%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(x%20%3E%20toX)%20return%20%7Bline%3A%20lineNo%2C%20ch%3A%20to%7D%3B%0A%20%20%20%20%20%20%2F%2F%20Try%20to%20guess%20a%20suitable%20lower%20bound%20as%20well.%0A%20%20%20%20%20%20estimated%20%3D%20Math.floor(to%20*%200.8)%3B%20estX%20%3D%20getX(estimated)%3B%0A%20%20%20%20%20%20if%20(estX%20%3C%20x)%20%7Bfrom%20%3D%20estimated%3B%20fromX%20%3D%20estX%3B%7D%0A%20%20%20%20%20%20%2F%2F%20Do%20a%20binary%20search%20between%20these%20bounds.%0A%20%20%20%20%20%20for%20(%3B%3B)%20%7B%0A%20%20%20%20%20%20%20%20if%20(to%20-%20from%20%3C%3D%201)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20after%20%3D%20x%20-%20fromX%20%3C%20toX%20-%20x%3B%0A%20%20%20%20%20%20%20%20%20%20return%20%7Bline%3A%20lineNo%2C%20ch%3A%20after%20%3F%20from%20%3A%20to%2C%20after%3A%20after%7D%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20var%20middle%20%3D%20Math.ceil((from%20%2B%20to)%20%2F%202)%2C%20middleX%20%3D%20getX(middle)%3B%0A%20%20%20%20%20%20%20%20if%20(middleX%20%3E%20x)%20%7Bto%20%3D%20middle%3B%20toX%20%3D%20middleX%3B%20if%20(wrongLine)%20toX%20%2B%3D%201000%3B%20%7D%0A%20%20%20%20%20%20%20%20else%20%7Bfrom%20%3D%20middle%3B%20fromX%20%3D%20middleX%3B%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20function%20pageCoords(pos)%20%7B%0A%20%20%20%20%20%20var%20local%20%3D%20localCoords(pos%2C%20true)%2C%20off%20%3D%20eltOffset(lineSpace)%3B%0A%20%20%20%20%20%20return%20%7Bx%3A%20off.left%20%2B%20local.x%2C%20y%3A%20off.top%20%2B%20local.y%2C%20yBot%3A%20off.top%20%2B%20local.yBot%7D%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20var%20cachedHeight%2C%20cachedHeightFor%2C%20measurePre%3B%0A%20%20%20%20function%20textHeight()%20%7B%0A%20%20%20%20%20%20if%20(measurePre%20%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20measurePre%20%3D%20elt(%22pre%22)%3B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%2049%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20%20%20measurePre.appendChild(document.createTextNode(%22x%22))%3B%0A%20%20%20%20%20%20%20%20%20%20measurePre.appendChild(elt(%22br%22))%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20measurePre.appendChild(document.createTextNode(%22x%22))%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20offsetHeight%20%3D%20lineDiv.clientHeight%3B%0A%20%20%20%20%20%20if%20(offsetHeight%20%3D%3D%20cachedHeightFor)%20return%20cachedHeight%3B%0A%20%20%20%20%20%20cachedHeightFor%20%3D%20offsetHeight%3B%0A%20%20%20%20%20%20removeChildrenAndAdd(measure%2C%20measurePre.cloneNode(true))%3B%0A%20%20%20%20%20%20cachedHeight%20%3D%20measure.firstChild.offsetHeight%20%2F%2050%20%7C%7C%201%3B%0A%20%20%20%20%20%20removeChildren(measure)%3B%0A%20%20%20%20%20%20return%20cachedHeight%3B%0A%20%20%20%20%7D%0A%20%20%20%20var%20cachedWidth%2C%20cachedWidthFor%20%3D%200%3B%0A%20%20%20%20function%20charWidth()%20%7B%0A%20%20%20%20%20%20if%20(scroller.clientWidth%20%3D%3D%20cachedWidthFor)%20return%20cachedWidth%3B%0A%20%20%20%20%20%20cachedWidthFor%20%3D%20scroller.clientWidth%3B%0A%20%20%20%20%20%20var%20anchor%20%3D%20elt(%22span%22%2C%20%22x%22)%3B%0A%20%20%20%20%20%20var%20pre%20%3D%20elt(%22pre%22%2C%20%5Banchor%5D)%3B%0A%20%20%20%20%20%20removeChildrenAndAdd(measure%2C%20pre)%3B%0A%20%20%20%20%20%20return%20(cachedWidth%20%3D%20anchor.offsetWidth%20%7C%7C%2010)%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20paddingTop()%20%7Breturn%20lineSpace.offsetTop%3B%7D%0A%20%20%20%20function%20paddingLeft()%20%7Breturn%20lineSpace.offsetLeft%3B%7D%0A%0A%20%20%20%20function%20posFromMouse(e%2C%20liberal)%20%7B%0A%20%20%20%20%20%20var%20offW%20%3D%20eltOffset(scroller%2C%20true)%2C%20x%2C%20y%3B%0A%20%20%20%20%20%20%2F%2F%20Fails%20unpredictably%20on%20IE%5B67%5D%20when%20mouse%20is%20dragged%20around%20quickly.%0A%20%20%20%20%20%20try%20%7B%20x%20%3D%20e.clientX%3B%20y%20%3D%20e.clientY%3B%20%7D%20catch%20(e)%20%7B%20return%20null%3B%20%7D%0A%20%20%20%20%20%20%2F%2F%20This%20is%20a%20mess%20of%20a%20heuristic%20to%20try%20and%20determine%20whether%20a%0A%20%20%20%20%20%20%2F%2F%20scroll-bar%20was%20clicked%20or%20not%2C%20and%20to%20return%20null%20if%20one%20was%0A%20%20%20%20%20%20%2F%2F%20(and%20!liberal).%0A%20%20%20%20%20%20if%20(!liberal%20%26%26%20(x%20-%20offW.left%20%3E%20scroller.clientWidth%20%7C%7C%20y%20-%20offW.top%20%3E%20scroller.clientHeight))%0A%20%20%20%20%20%20%20%20return%20null%3B%0A%20%20%20%20%20%20var%20offL%20%3D%20eltOffset(lineSpace%2C%20true)%3B%0A%20%20%20%20%20%20return%20coordsChar(x%20-%20offL.left%2C%20y%20-%20offL.top)%3B%0A%20%20%20%20%7D%0A%20%20%20%20var%20detectingSelectAll%3B%0A%20%20%20%20function%20onContextMenu(e)%20%7B%0A%20%20%20%20%20%20var%20pos%20%3D%20posFromMouse(e)%2C%20scrollPos%20%3D%20scrollbar.scrollTop%3B%0A%20%20%20%20%20%20if%20(!pos%20%7C%7C%20opera)%20return%3B%20%2F%2F%20Opera%20is%20difficult.%0A%20%20%20%20%20%20if%20(posEq(sel.from%2C%20sel.to)%20%7C%7C%20posLess(pos%2C%20sel.from)%20%7C%7C%20!posLess(pos%2C%20sel.to))%0A%20%20%20%20%20%20%20%20operation(setCursor)(pos.line%2C%20pos.ch)%3B%0A%0A%20%20%20%20%20%20var%20oldCSS%20%3D%20input.style.cssText%3B%0A%20%20%20%20%20%20inputDiv.style.position%20%3D%20%22absolute%22%3B%0A%20%20%20%20%20%20input.style.cssText%20%3D%20%22position%3A%20fixed%3B%20width%3A%2030px%3B%20height%3A%2030px%3B%20top%3A%20%22%20%2B%20(e.clientY%20-%205)%20%2B%0A%20%20%20%20%20%20%20%20%22px%3B%20left%3A%20%22%20%2B%20(e.clientX%20-%205)%20%2B%20%22px%3B%20z-index%3A%201000%3B%20background%3A%20white%3B%20%22%20%2B%0A%20%20%20%20%20%20%20%20%22border-width%3A%200%3B%20outline%3A%20none%3B%20overflow%3A%20hidden%3B%20opacity%3A%20.05%3B%20filter%3A%20alpha(opacity%3D5)%3B%22%3B%0A%20%20%20%20%20%20focusInput()%3B%0A%20%20%20%20%20%20resetInput(true)%3B%0A%20%20%20%20%20%20%2F%2F%20Adds%20%22Select%20all%22%20to%20context%20menu%20in%20FF%0A%20%20%20%20%20%20if%20(posEq(sel.from%2C%20sel.to))%20input.value%20%3D%20prevInput%20%3D%20%22%20%22%3B%0A%0A%20%20%20%20%20%20function%20rehide()%20%7B%0A%20%20%20%20%20%20%20%20inputDiv.style.position%20%3D%20%22relative%22%3B%0A%20%20%20%20%20%20%20%20input.style.cssText%20%3D%20oldCSS%3B%0A%20%20%20%20%20%20%20%20if%20(ie_lt9)%20scrollbar.scrollTop%20%3D%20scrollPos%3B%0A%20%20%20%20%20%20%20%20slowPoll()%3B%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20Try%20to%20detect%20the%20user%20choosing%20select-all%20%0A%20%20%20%20%20%20%20%20if%20(input.selectionStart%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20clearTimeout(detectingSelectAll)%3B%0A%20%20%20%20%20%20%20%20%20%20var%20extval%20%3D%20input.value%20%3D%20%22%20%22%20%2B%20(posEq(sel.from%2C%20sel.to)%20%3F%20%22%22%20%3A%20input.value)%2C%20i%20%3D%200%3B%0A%20%20%20%20%20%20%20%20%20%20prevInput%20%3D%20%22%20%22%3B%0A%20%20%20%20%20%20%20%20%20%20input.selectionStart%20%3D%201%3B%20input.selectionEnd%20%3D%20extval.length%3B%0A%20%20%20%20%20%20%20%20%20%20detectingSelectAll%20%3D%20setTimeout(function%20poll()%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(prevInput%20%3D%3D%20%22%20%22%20%26%26%20input.selectionStart%20%3D%3D%200)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20operation(commands.selectAll)(instance)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20if%20(i%2B%2B%20%3C%2010)%20detectingSelectAll%20%3D%20setTimeout(poll%2C%20500)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20resetInput()%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%2C%20200)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20if%20(gecko)%20%7B%0A%20%20%20%20%20%20%20%20e_stop(e)%3B%0A%20%20%20%20%20%20%20%20var%20mouseup%20%3D%20connect(window%2C%20%22mouseup%22%2C%20function()%20%7B%0A%20%20%20%20%20%20%20%20%20%20mouseup()%3B%0A%20%20%20%20%20%20%20%20%20%20setTimeout(rehide%2C%2020)%3B%0A%20%20%20%20%20%20%20%20%7D%2C%20true)%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20setTimeout(rehide%2C%2050)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20%2F%2F%20Cursor-blinking%0A%20%20%20%20function%20restartBlink()%20%7B%0A%20%20%20%20%20%20clearInterval(blinker)%3B%0A%20%20%20%20%20%20var%20on%20%3D%20true%3B%0A%20%20%20%20%20%20cursor.style.visibility%20%3D%20%22%22%3B%0A%20%20%20%20%20%20blinker%20%3D%20setInterval(function()%20%7B%0A%20%20%20%20%20%20%20%20cursor.style.visibility%20%3D%20(on%20%3D%20!on)%20%3F%20%22%22%20%3A%20%22hidden%22%3B%0A%20%20%20%20%20%20%7D%2C%20options.cursorBlinkRate)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20var%20matching%20%3D%20%7B%22(%22%3A%20%22)%3E%22%2C%20%22)%22%3A%20%22(%3C%22%2C%20%22%5B%22%3A%20%22%5D%3E%22%2C%20%22%5D%22%3A%20%22%5B%3C%22%2C%20%22%7B%22%3A%20%22%7D%3E%22%2C%20%22%7D%22%3A%20%22%7B%3C%22%7D%3B%0A%20%20%20%20function%20matchBrackets(autoclear)%20%7B%0A%20%20%20%20%20%20var%20head%20%3D%20sel.inverted%20%3F%20sel.from%20%3A%20sel.to%2C%20line%20%3D%20getLine(head.line)%2C%20pos%20%3D%20head.ch%20-%201%3B%0A%20%20%20%20%20%20var%20match%20%3D%20(pos%20%3E%3D%200%20%26%26%20matching%5Bline.text.charAt(pos)%5D)%20%7C%7C%20matching%5Bline.text.charAt(%2B%2Bpos)%5D%3B%0A%20%20%20%20%20%20if%20(!match)%20return%3B%0A%20%20%20%20%20%20var%20ch%20%3D%20match.charAt(0)%2C%20forward%20%3D%20match.charAt(1)%20%3D%3D%20%22%3E%22%2C%20d%20%3D%20forward%20%3F%201%20%3A%20-1%2C%20st%20%3D%20line.styles%3B%0A%20%20%20%20%20%20for%20(var%20off%20%3D%20pos%20%2B%201%2C%20i%20%3D%200%2C%20e%20%3D%20st.length%3B%20i%20%3C%20e%3B%20i%2B%3D2)%0A%20%20%20%20%20%20%20%20if%20((off%20-%3D%20st%5Bi%5D.length)%20%3C%3D%200)%20%7Bvar%20style%20%3D%20st%5Bi%2B1%5D%3B%20break%3B%7D%0A%0A%20%20%20%20%20%20var%20stack%20%3D%20%5Bline.text.charAt(pos)%5D%2C%20re%20%3D%20%2F%5B()%7B%7D%5B%5C%5D%5D%2F%3B%0A%20%20%20%20%20%20function%20scan(line%2C%20from%2C%20to)%20%7B%0A%20%20%20%20%20%20%20%20if%20(!line.text)%20return%3B%0A%20%20%20%20%20%20%20%20var%20st%20%3D%20line.styles%2C%20pos%20%3D%20forward%20%3F%200%20%3A%20line.text.length%20-%201%2C%20cur%3B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%20forward%20%3F%200%20%3A%20st.length%20-%202%2C%20e%20%3D%20forward%20%3F%20st.length%20%3A%20-2%3B%20i%20!%3D%20e%3B%20i%20%2B%3D%202*d)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20text%20%3D%20st%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(st%5Bi%2B1%5D%20!%3D%20style)%20%7Bpos%20%2B%3D%20d%20*%20text.length%3B%20continue%3B%7D%0A%20%20%20%20%20%20%20%20%20%20for%20(var%20j%20%3D%20forward%20%3F%200%20%3A%20text.length%20-%201%2C%20te%20%3D%20forward%20%3F%20text.length%20%3A%20-1%3B%20j%20!%3D%20te%3B%20j%20%2B%3D%20d%2C%20pos%2B%3Dd)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(pos%20%3E%3D%20from%20%26%26%20pos%20%3C%20to%20%26%26%20re.test(cur%20%3D%20text.charAt(j)))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20match%20%3D%20matching%5Bcur%5D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(match.charAt(1)%20%3D%3D%20%22%3E%22%20%3D%3D%20forward)%20stack.push(cur)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%20if%20(stack.pop()%20!%3D%20match.charAt(0))%20return%20%7Bpos%3A%20pos%2C%20match%3A%20false%7D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%20if%20(!stack.length)%20return%20%7Bpos%3A%20pos%2C%20match%3A%20true%7D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20for%20(var%20i%20%3D%20head.line%2C%20e%20%3D%20forward%20%3F%20Math.min(i%20%2B%20100%2C%20doc.size)%20%3A%20Math.max(-1%2C%20i%20-%20100)%3B%20i%20!%3D%20e%3B%20i%2B%3Dd)%20%7B%0A%20%20%20%20%20%20%20%20var%20line%20%3D%20getLine(i)%2C%20first%20%3D%20i%20%3D%3D%20head.line%3B%0A%20%20%20%20%20%20%20%20var%20found%20%3D%20scan(line%2C%20first%20%26%26%20forward%20%3F%20pos%20%2B%201%20%3A%200%2C%20first%20%26%26%20!forward%20%3F%20pos%20%3A%20line.text.length)%3B%0A%20%20%20%20%20%20%20%20if%20(found)%20break%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(!found)%20found%20%3D%20%7Bpos%3A%20null%2C%20match%3A%20false%7D%3B%0A%20%20%20%20%20%20var%20style%20%3D%20found.match%20%3F%20%22CodeMirror-matchingbracket%22%20%3A%20%22CodeMirror-nonmatchingbracket%22%3B%0A%20%20%20%20%20%20var%20one%20%3D%20markText(%7Bline%3A%20head.line%2C%20ch%3A%20pos%7D%2C%20%7Bline%3A%20head.line%2C%20ch%3A%20pos%2B1%7D%2C%20style)%2C%0A%20%20%20%20%20%20%20%20%20%20two%20%3D%20found.pos%20!%3D%20null%20%26%26%20markText(%7Bline%3A%20i%2C%20ch%3A%20found.pos%7D%2C%20%7Bline%3A%20i%2C%20ch%3A%20found.pos%20%2B%201%7D%2C%20style)%3B%0A%20%20%20%20%20%20var%20clear%20%3D%20operation(function()%7Bone.clear()%3B%20two%20%26%26%20two.clear()%3B%7D)%3B%0A%20%20%20%20%20%20if%20(autoclear)%20setTimeout(clear%2C%20800)%3B%0A%20%20%20%20%20%20else%20bracketHighlighted%20%3D%20clear%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20%2F%2F%20Finds%20the%20line%20to%20start%20with%20when%20starting%20a%20parse.%20Tries%20to%0A%20%20%20%20%2F%2F%20find%20a%20line%20with%20a%20stateAfter%2C%20so%20that%20it%20can%20start%20with%20a%0A%20%20%20%20%2F%2F%20valid%20state.%20If%20that%20fails%2C%20it%20returns%20the%20line%20with%20the%0A%20%20%20%20%2F%2F%20smallest%20indentation%2C%20which%20tends%20to%20need%20the%20least%20context%20to%0A%20%20%20%20%2F%2F%20parse%20correctly.%0A%20%20%20%20function%20findStartLine(n)%20%7B%0A%20%20%20%20%20%20var%20minindent%2C%20minline%3B%0A%20%20%20%20%20%20for%20(var%20search%20%3D%20n%2C%20lim%20%3D%20n%20-%2040%3B%20search%20%3E%20lim%3B%20--search)%20%7B%0A%20%20%20%20%20%20%20%20if%20(search%20%3D%3D%200)%20return%200%3B%0A%20%20%20%20%20%20%20%20var%20line%20%3D%20getLine(search-1)%3B%0A%20%20%20%20%20%20%20%20if%20(line.stateAfter)%20return%20search%3B%0A%20%20%20%20%20%20%20%20var%20indented%20%3D%20line.indentation(options.tabSize)%3B%0A%20%20%20%20%20%20%20%20if%20(minline%20%3D%3D%20null%20%7C%7C%20minindent%20%3E%20indented)%20%7B%0A%20%20%20%20%20%20%20%20%20%20minline%20%3D%20search%20-%201%3B%0A%20%20%20%20%20%20%20%20%20%20minindent%20%3D%20indented%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20minline%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20getStateBefore(n)%20%7B%0A%20%20%20%20%20%20var%20pos%20%3D%20findStartLine(n)%2C%20state%20%3D%20pos%20%26%26%20getLine(pos-1).stateAfter%3B%0A%20%20%20%20%20%20if%20(!state)%20state%20%3D%20startState(mode)%3B%0A%20%20%20%20%20%20else%20state%20%3D%20copyState(mode%2C%20state)%3B%0A%20%20%20%20%20%20doc.iter(pos%2C%20n%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20line.process(mode%2C%20state%2C%20options.tabSize)%3B%0A%20%20%20%20%20%20%20%20line.stateAfter%20%3D%20(pos%20%3D%3D%20n%20-%201%20%7C%7C%20pos%20%25%205%20%3D%3D%200)%20%3F%20copyState(mode%2C%20state)%20%3A%20null%3B%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20return%20state%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20highlightWorker()%20%7B%0A%20%20%20%20%20%20if%20(frontier%20%3E%3D%20showingTo)%20return%3B%0A%20%20%20%20%20%20var%20end%20%3D%20%2Bnew%20Date%20%2B%20options.workTime%2C%20state%20%3D%20copyState(mode%2C%20getStateBefore(frontier))%3B%0A%20%20%20%20%20%20var%20startFrontier%20%3D%20frontier%3B%0A%20%20%20%20%20%20doc.iter(frontier%2C%20showingTo%2C%20function(line)%20%7B%0A%20%20%20%20%20%20%20%20if%20(frontier%20%3E%3D%20showingFrom)%20%7B%20%2F%2F%20Visible%0A%20%20%20%20%20%20%20%20%20%20line.highlight(mode%2C%20state%2C%20options.tabSize)%3B%0A%20%20%20%20%20%20%20%20%20%20line.stateAfter%20%3D%20copyState(mode%2C%20state)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20line.process(mode%2C%20state%2C%20options.tabSize)%3B%0A%20%20%20%20%20%20%20%20%20%20line.stateAfter%20%3D%20frontier%20%25%205%20%3D%3D%200%20%3F%20copyState(mode%2C%20state)%20%3A%20null%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%2B%2Bfrontier%3B%0A%20%20%20%20%20%20%20%20if%20(%2Bnew%20Date%20%3E%20end)%20%7B%0A%20%20%20%20%20%20%20%20%20%20startWorker(options.workDelay)%3B%0A%20%20%20%20%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20if%20(showingTo%20%3E%20startFrontier%20%26%26%20frontier%20%3E%3D%20showingFrom)%0A%20%20%20%20%20%20%20%20operation(function()%20%7Bchanges.push(%7Bfrom%3A%20startFrontier%2C%20to%3A%20frontier%7D)%3B%7D)()%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20startWorker(time)%20%7B%0A%20%20%20%20%20%20if%20(frontier%20%3C%20showingTo)%0A%20%20%20%20%20%20%20%20highlight.set(time%2C%20highlightWorker)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20%2F%2F%20Operations%20are%20used%20to%20wrap%20changes%20in%20such%20a%20way%20that%20each%0A%20%20%20%20%2F%2F%20change%20won't%20have%20to%20update%20the%20cursor%20and%20display%20(which%20would%0A%20%20%20%20%2F%2F%20be%20awkward%2C%20slow%2C%20and%20error-prone)%2C%20but%20instead%20updates%20are%0A%20%20%20%20%2F%2F%20batched%20and%20then%20all%20combined%20and%20executed%20at%20once.%0A%20%20%20%20function%20startOperation()%20%7B%0A%20%20%20%20%20%20updateInput%20%3D%20userSelChange%20%3D%20textChanged%20%3D%20null%3B%0A%20%20%20%20%20%20changes%20%3D%20%5B%5D%3B%20selectionChanged%20%3D%20false%3B%20callbacks%20%3D%20%5B%5D%3B%0A%20%20%20%20%7D%0A%20%20%20%20function%20endOperation()%20%7B%0A%20%20%20%20%20%20if%20(updateMaxLine)%20computeMaxLength()%3B%0A%20%20%20%20%20%20if%20(maxLineChanged%20%26%26%20!options.lineWrapping)%20%7B%0A%20%20%20%20%20%20%20%20var%20cursorWidth%20%3D%20widthForcer.offsetWidth%2C%20left%20%3D%20measureLine(maxLine%2C%20maxLine.text.length).left%3B%0A%20%20%20%20%20%20%20%20if%20(!ie_lt8)%20%7B%0A%20%20%20%20%20%20%20%20%20%20widthForcer.style.left%20%3D%20left%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20%20%20lineSpace.style.minWidth%20%3D%20(left%20%2B%20cursorWidth)%20%2B%20%22px%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20maxLineChanged%20%3D%20false%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20newScrollPos%2C%20updated%3B%0A%20%20%20%20%20%20if%20(selectionChanged)%20%7B%0A%20%20%20%20%20%20%20%20var%20coords%20%3D%20calculateCursorCoords()%3B%0A%20%20%20%20%20%20%20%20newScrollPos%20%3D%20calculateScrollPos(coords.x%2C%20coords.y%2C%20coords.x%2C%20coords.yBot)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(changes.length%20%7C%7C%20newScrollPos%20%26%26%20newScrollPos.scrollTop%20!%3D%20null)%0A%20%20%20%20%20%20%20%20updated%20%3D%20updateDisplay(changes%2C%20true%2C%20newScrollPos%20%26%26%20newScrollPos.scrollTop)%3B%0A%20%20%20%20%20%20if%20(!updated)%20%7B%0A%20%20%20%20%20%20%20%20if%20(selectionChanged)%20updateSelection()%3B%0A%20%20%20%20%20%20%20%20if%20(gutterDirty)%20updateGutter()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(newScrollPos)%20scrollCursorIntoView()%3B%0A%20%20%20%20%20%20if%20(selectionChanged)%20restartBlink()%3B%0A%0A%20%20%20%20%20%20if%20(focused%20%26%26%20(updateInput%20%3D%3D%3D%20true%20%7C%7C%20(updateInput%20!%3D%3D%20false%20%26%26%20selectionChanged)))%0A%20%20%20%20%20%20%20%20resetInput(userSelChange)%3B%0A%0A%20%20%20%20%20%20if%20(selectionChanged%20%26%26%20options.matchBrackets)%0A%20%20%20%20%20%20%20%20setTimeout(operation(function()%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(bracketHighlighted)%20%7BbracketHighlighted()%3B%20bracketHighlighted%20%3D%20null%3B%7D%0A%20%20%20%20%20%20%20%20%20%20if%20(posEq(sel.from%2C%20sel.to))%20matchBrackets(false)%3B%0A%20%20%20%20%20%20%20%20%7D)%2C%2020)%3B%0A%20%20%20%20%20%20var%20sc%20%3D%20selectionChanged%2C%20cbs%20%3D%20callbacks%3B%20%2F%2F%20these%20can%20be%20reset%20by%20callbacks%0A%20%20%20%20%20%20if%20(textChanged%20%26%26%20options.onChange%20%26%26%20instance)%0A%20%20%20%20%20%20%20%20options.onChange(instance%2C%20textChanged)%3B%0A%20%20%20%20%20%20if%20(sc%20%26%26%20options.onCursorActivity)%0A%20%20%20%20%20%20%20%20options.onCursorActivity(instance)%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20cbs.length%3B%20%2B%2Bi)%20cbs%5Bi%5D(instance)%3B%0A%20%20%20%20%20%20if%20(updated%20%26%26%20options.onUpdate)%20options.onUpdate(instance)%3B%0A%20%20%20%20%7D%0A%20%20%20%20var%20nestedOperation%20%3D%200%3B%0A%20%20%20%20function%20operation(f)%20%7B%0A%20%20%20%20%20%20return%20function()%20%7B%0A%20%20%20%20%20%20%20%20if%20(!nestedOperation%2B%2B)%20startOperation()%3B%0A%20%20%20%20%20%20%20%20try%20%7Bvar%20result%20%3D%20f.apply(this%2C%20arguments)%3B%7D%0A%20%20%20%20%20%20%20%20finally%20%7Bif%20(!--nestedOperation)%20endOperation()%3B%7D%0A%20%20%20%20%20%20%20%20return%20result%3B%0A%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20compoundChange(f)%20%7B%0A%20%20%20%20%20%20history.startCompound()%3B%0A%20%20%20%20%20%20try%20%7B%20return%20f()%3B%20%7D%20finally%20%7B%20history.endCompound()%3B%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20for%20(var%20ext%20in%20extensions)%0A%20%20%20%20%20%20if%20(extensions.propertyIsEnumerable(ext)%20%26%26%0A%20%20%20%20%20%20%20%20%20%20!instance.propertyIsEnumerable(ext))%0A%20%20%20%20%20%20%20%20instance%5Bext%5D%20%3D%20extensions%5Bext%5D%3B%0A%20%20%20%20return%20instance%3B%0A%20%20%7D%20%2F%2F%20(end%20of%20function%20CodeMirror)%0A%0A%20%20%2F%2F%20The%20default%20configuration%20options.%0A%20%20CodeMirror.defaults%20%3D%20%7B%0A%20%20%20%20value%3A%20%22%22%2C%0A%20%20%20%20mode%3A%20null%2C%0A%20%20%20%20theme%3A%20%22default%22%2C%0A%20%20%20%20indentUnit%3A%202%2C%0A%20%20%20%20indentWithTabs%3A%20false%2C%0A%20%20%20%20smartIndent%3A%20true%2C%0A%20%20%20%20tabSize%3A%204%2C%0A%20%20%20%20keyMap%3A%20%22default%22%2C%0A%20%20%20%20extraKeys%3A%20null%2C%0A%20%20%20%20electricChars%3A%20true%2C%0A%20%20%20%20autoClearEmptyLines%3A%20false%2C%0A%20%20%20%20onKeyEvent%3A%20null%2C%0A%20%20%20%20onDragEvent%3A%20null%2C%0A%20%20%20%20lineWrapping%3A%20false%2C%0A%20%20%20%20lineNumbers%3A%20false%2C%0A%20%20%20%20gutter%3A%20false%2C%0A%20%20%20%20fixedGutter%3A%20false%2C%0A%20%20%20%20firstLineNumber%3A%201%2C%0A%20%20%20%20readOnly%3A%20false%2C%0A%20%20%20%20dragDrop%3A%20true%2C%0A%20%20%20%20onChange%3A%20null%2C%0A%20%20%20%20onCursorActivity%3A%20null%2C%0A%20%20%20%20onViewportChange%3A%20null%2C%0A%20%20%20%20onGutterClick%3A%20null%2C%0A%20%20%20%20onUpdate%3A%20null%2C%0A%20%20%20%20onFocus%3A%20null%2C%20onBlur%3A%20null%2C%20onScroll%3A%20null%2C%0A%20%20%20%20matchBrackets%3A%20false%2C%0A%20%20%20%20cursorBlinkRate%3A%20530%2C%0A%20%20%20%20workTime%3A%20100%2C%0A%20%20%20%20workDelay%3A%20200%2C%0A%20%20%20%20pollInterval%3A%20100%2C%0A%20%20%20%20undoDepth%3A%2040%2C%0A%20%20%20%20tabindex%3A%20null%2C%0A%20%20%20%20autofocus%3A%20null%2C%0A%20%20%20%20lineNumberFormatter%3A%20function(integer)%20%7B%20return%20integer%3B%20%7D%0A%20%20%7D%3B%0A%0A%20%20var%20ios%20%3D%20%2FAppleWebKit%2F.test(navigator.userAgent)%20%26%26%20%2FMobile%5C%2F%5Cw%2B%2F.test(navigator.userAgent)%3B%0A%20%20var%20mac%20%3D%20ios%20%7C%7C%20%2FMac%2F.test(navigator.platform)%3B%0A%20%20var%20win%20%3D%20%2FWin%2F.test(navigator.platform)%3B%0A%0A%20%20%2F%2F%20Known%20modes%2C%20by%20name%20and%20by%20MIME%0A%20%20var%20modes%20%3D%20CodeMirror.modes%20%3D%20%7B%7D%2C%20mimeModes%20%3D%20CodeMirror.mimeModes%20%3D%20%7B%7D%3B%0A%20%20CodeMirror.defineMode%20%3D%20function(name%2C%20mode)%20%7B%0A%20%20%20%20if%20(!CodeMirror.defaults.mode%20%26%26%20name%20!%3D%20%22null%22)%20CodeMirror.defaults.mode%20%3D%20name%3B%0A%20%20%20%20if%20(arguments.length%20%3E%202)%20%7B%0A%20%20%20%20%20%20mode.dependencies%20%3D%20%5B%5D%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%202%3B%20i%20%3C%20arguments.length%3B%20%2B%2Bi)%20mode.dependencies.push(arguments%5Bi%5D)%3B%0A%20%20%20%20%7D%0A%20%20%20%20modes%5Bname%5D%20%3D%20mode%3B%0A%20%20%7D%3B%0A%20%20CodeMirror.defineMIME%20%3D%20function(mime%2C%20spec)%20%7B%0A%20%20%20%20mimeModes%5Bmime%5D%20%3D%20spec%3B%0A%20%20%7D%3B%0A%20%20CodeMirror.resolveMode%20%3D%20function(spec)%20%7B%0A%20%20%20%20if%20(typeof%20spec%20%3D%3D%20%22string%22%20%26%26%20mimeModes.hasOwnProperty(spec))%0A%20%20%20%20%20%20spec%20%3D%20mimeModes%5Bspec%5D%3B%0A%20%20%20%20else%20if%20(typeof%20spec%20%3D%3D%20%22string%22%20%26%26%20%2F%5E%5B%5Cw%5C-%5D%2B%5C%2F%5B%5Cw%5C-%5D%2B%5C%2Bxml%24%2F.test(spec))%0A%20%20%20%20%20%20return%20CodeMirror.resolveMode(%22application%2Fxml%22)%3B%0A%20%20%20%20if%20(typeof%20spec%20%3D%3D%20%22string%22)%20return%20%7Bname%3A%20spec%7D%3B%0A%20%20%20%20else%20return%20spec%20%7C%7C%20%7Bname%3A%20%22null%22%7D%3B%0A%20%20%7D%3B%0A%20%20CodeMirror.getMode%20%3D%20function(options%2C%20spec)%20%7B%0A%20%20%20%20var%20spec%20%3D%20CodeMirror.resolveMode(spec)%3B%0A%20%20%20%20var%20mfactory%20%3D%20modes%5Bspec.name%5D%3B%0A%20%20%20%20if%20(!mfactory)%20return%20CodeMirror.getMode(options%2C%20%22text%2Fplain%22)%3B%0A%20%20%20%20var%20modeObj%20%3D%20mfactory(options%2C%20spec)%3B%0A%20%20%20%20if%20(modeExtensions.hasOwnProperty(spec.name))%20%7B%0A%20%20%20%20%20%20var%20exts%20%3D%20modeExtensions%5Bspec.name%5D%3B%0A%20%20%20%20%20%20for%20(var%20prop%20in%20exts)%20if%20(exts.hasOwnProperty(prop))%20modeObj%5Bprop%5D%20%3D%20exts%5Bprop%5D%3B%0A%20%20%20%20%7D%0A%20%20%20%20modeObj.name%20%3D%20spec.name%3B%0A%20%20%20%20return%20modeObj%3B%0A%20%20%7D%3B%0A%20%20CodeMirror.listModes%20%3D%20function()%20%7B%0A%20%20%20%20var%20list%20%3D%20%5B%5D%3B%0A%20%20%20%20for%20(var%20m%20in%20modes)%0A%20%20%20%20%20%20if%20(modes.propertyIsEnumerable(m))%20list.push(m)%3B%0A%20%20%20%20return%20list%3B%0A%20%20%7D%3B%0A%20%20CodeMirror.listMIMEs%20%3D%20function()%20%7B%0A%20%20%20%20var%20list%20%3D%20%5B%5D%3B%0A%20%20%20%20for%20(var%20m%20in%20mimeModes)%0A%20%20%20%20%20%20if%20(mimeModes.propertyIsEnumerable(m))%20list.push(%7Bmime%3A%20m%2C%20mode%3A%20mimeModes%5Bm%5D%7D)%3B%0A%20%20%20%20return%20list%3B%0A%20%20%7D%3B%0A%0A%20%20var%20extensions%20%3D%20CodeMirror.extensions%20%3D%20%7B%7D%3B%0A%20%20CodeMirror.defineExtension%20%3D%20function(name%2C%20func)%20%7B%0A%20%20%20%20extensions%5Bname%5D%20%3D%20func%3B%0A%20%20%7D%3B%0A%0A%20%20var%20modeExtensions%20%3D%20CodeMirror.modeExtensions%20%3D%20%7B%7D%3B%0A%20%20CodeMirror.extendMode%20%3D%20function(mode%2C%20properties)%20%7B%0A%20%20%20%20var%20exts%20%3D%20modeExtensions.hasOwnProperty(mode)%20%3F%20modeExtensions%5Bmode%5D%20%3A%20(modeExtensions%5Bmode%5D%20%3D%20%7B%7D)%3B%0A%20%20%20%20for%20(var%20prop%20in%20properties)%20if%20(properties.hasOwnProperty(prop))%0A%20%20%20%20%20%20exts%5Bprop%5D%20%3D%20properties%5Bprop%5D%3B%0A%20%20%7D%3B%0A%0A%20%20var%20commands%20%3D%20CodeMirror.commands%20%3D%20%7B%0A%20%20%20%20selectAll%3A%20function(cm)%20%7Bcm.setSelection(%7Bline%3A%200%2C%20ch%3A%200%7D%2C%20%7Bline%3A%20cm.lineCount()%20-%201%7D)%3B%7D%2C%0A%20%20%20%20killLine%3A%20function(cm)%20%7B%0A%20%20%20%20%20%20var%20from%20%3D%20cm.getCursor(true)%2C%20to%20%3D%20cm.getCursor(false)%2C%20sel%20%3D%20!posEq(from%2C%20to)%3B%0A%20%20%20%20%20%20if%20(!sel%20%26%26%20cm.getLine(from.line).length%20%3D%3D%20from.ch)%20cm.replaceRange(%22%22%2C%20from%2C%20%7Bline%3A%20from.line%20%2B%201%2C%20ch%3A%200%7D)%3B%0A%20%20%20%20%20%20else%20cm.replaceRange(%22%22%2C%20from%2C%20sel%20%3F%20to%20%3A%20%7Bline%3A%20from.line%7D)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20deleteLine%3A%20function(cm)%20%7Bvar%20l%20%3D%20cm.getCursor().line%3B%20cm.replaceRange(%22%22%2C%20%7Bline%3A%20l%2C%20ch%3A%200%7D%2C%20%7Bline%3A%20l%7D)%3B%7D%2C%0A%20%20%20%20undo%3A%20function(cm)%20%7Bcm.undo()%3B%7D%2C%0A%20%20%20%20redo%3A%20function(cm)%20%7Bcm.redo()%3B%7D%2C%0A%20%20%20%20goDocStart%3A%20function(cm)%20%7Bcm.setCursor(0%2C%200%2C%20true)%3B%7D%2C%0A%20%20%20%20goDocEnd%3A%20function(cm)%20%7Bcm.setSelection(%7Bline%3A%20cm.lineCount()%20-%201%7D%2C%20null%2C%20true)%3B%7D%2C%0A%20%20%20%20goLineStart%3A%20function(cm)%20%7Bcm.setCursor(cm.getCursor().line%2C%200%2C%20true)%3B%7D%2C%0A%20%20%20%20goLineStartSmart%3A%20function(cm)%20%7B%0A%20%20%20%20%20%20var%20cur%20%3D%20cm.getCursor()%3B%0A%20%20%20%20%20%20var%20text%20%3D%20cm.getLine(cur.line)%2C%20firstNonWS%20%3D%20Math.max(0%2C%20text.search(%2F%5CS%2F))%3B%0A%20%20%20%20%20%20cm.setCursor(cur.line%2C%20cur.ch%20%3C%3D%20firstNonWS%20%26%26%20cur.ch%20%3F%200%20%3A%20firstNonWS%2C%20true)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20goLineEnd%3A%20function(cm)%20%7Bcm.setSelection(%7Bline%3A%20cm.getCursor().line%7D%2C%20null%2C%20true)%3B%7D%2C%0A%20%20%20%20goLineUp%3A%20function(cm)%20%7Bcm.moveV(-1%2C%20%22line%22)%3B%7D%2C%0A%20%20%20%20goLineDown%3A%20function(cm)%20%7Bcm.moveV(1%2C%20%22line%22)%3B%7D%2C%0A%20%20%20%20goPageUp%3A%20function(cm)%20%7Bcm.moveV(-1%2C%20%22page%22)%3B%7D%2C%0A%20%20%20%20goPageDown%3A%20function(cm)%20%7Bcm.moveV(1%2C%20%22page%22)%3B%7D%2C%0A%20%20%20%20goCharLeft%3A%20function(cm)%20%7Bcm.moveH(-1%2C%20%22char%22)%3B%7D%2C%0A%20%20%20%20goCharRight%3A%20function(cm)%20%7Bcm.moveH(1%2C%20%22char%22)%3B%7D%2C%0A%20%20%20%20goColumnLeft%3A%20function(cm)%20%7Bcm.moveH(-1%2C%20%22column%22)%3B%7D%2C%0A%20%20%20%20goColumnRight%3A%20function(cm)%20%7Bcm.moveH(1%2C%20%22column%22)%3B%7D%2C%0A%20%20%20%20goWordLeft%3A%20function(cm)%20%7Bcm.moveH(-1%2C%20%22word%22)%3B%7D%2C%0A%20%20%20%20goWordRight%3A%20function(cm)%20%7Bcm.moveH(1%2C%20%22word%22)%3B%7D%2C%0A%20%20%20%20delCharLeft%3A%20function(cm)%20%7Bcm.deleteH(-1%2C%20%22char%22)%3B%7D%2C%0A%20%20%20%20delCharRight%3A%20function(cm)%20%7Bcm.deleteH(1%2C%20%22char%22)%3B%7D%2C%0A%20%20%20%20delWordLeft%3A%20function(cm)%20%7Bcm.deleteH(-1%2C%20%22word%22)%3B%7D%2C%0A%20%20%20%20delWordRight%3A%20function(cm)%20%7Bcm.deleteH(1%2C%20%22word%22)%3B%7D%2C%0A%20%20%20%20indentAuto%3A%20function(cm)%20%7Bcm.indentSelection(%22smart%22)%3B%7D%2C%0A%20%20%20%20indentMore%3A%20function(cm)%20%7Bcm.indentSelection(%22add%22)%3B%7D%2C%0A%20%20%20%20indentLess%3A%20function(cm)%20%7Bcm.indentSelection(%22subtract%22)%3B%7D%2C%0A%20%20%20%20insertTab%3A%20function(cm)%20%7Bcm.replaceSelection(%22%5Ct%22%2C%20%22end%22)%3B%7D%2C%0A%20%20%20%20defaultTab%3A%20function(cm)%20%7B%0A%20%20%20%20%20%20if%20(cm.somethingSelected())%20cm.indentSelection(%22add%22)%3B%0A%20%20%20%20%20%20else%20cm.replaceSelection(%22%5Ct%22%2C%20%22end%22)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20transposeChars%3A%20function(cm)%20%7B%0A%20%20%20%20%20%20var%20cur%20%3D%20cm.getCursor()%2C%20line%20%3D%20cm.getLine(cur.line)%3B%0A%20%20%20%20%20%20if%20(cur.ch%20%3E%200%20%26%26%20cur.ch%20%3C%20line.length%20-%201)%0A%20%20%20%20%20%20%20%20cm.replaceRange(line.charAt(cur.ch)%20%2B%20line.charAt(cur.ch%20-%201)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bline%3A%20cur.line%2C%20ch%3A%20cur.ch%20-%201%7D%2C%20%7Bline%3A%20cur.line%2C%20ch%3A%20cur.ch%20%2B%201%7D)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20newlineAndIndent%3A%20function(cm)%20%7B%0A%20%20%20%20%20%20cm.replaceSelection(%22%5Cn%22%2C%20%22end%22)%3B%0A%20%20%20%20%20%20cm.indentLine(cm.getCursor().line)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20toggleOverwrite%3A%20function(cm)%20%7Bcm.toggleOverwrite()%3B%7D%0A%20%20%7D%3B%0A%0A%20%20var%20keyMap%20%3D%20CodeMirror.keyMap%20%3D%20%7B%7D%3B%0A%20%20keyMap.basic%20%3D%20%7B%0A%20%20%20%20%22Left%22%3A%20%22goCharLeft%22%2C%20%22Right%22%3A%20%22goCharRight%22%2C%20%22Up%22%3A%20%22goLineUp%22%2C%20%22Down%22%3A%20%22goLineDown%22%2C%0A%20%20%20%20%22End%22%3A%20%22goLineEnd%22%2C%20%22Home%22%3A%20%22goLineStartSmart%22%2C%20%22PageUp%22%3A%20%22goPageUp%22%2C%20%22PageDown%22%3A%20%22goPageDown%22%2C%0A%20%20%20%20%22Delete%22%3A%20%22delCharRight%22%2C%20%22Backspace%22%3A%20%22delCharLeft%22%2C%20%22Tab%22%3A%20%22defaultTab%22%2C%20%22Shift-Tab%22%3A%20%22indentAuto%22%2C%0A%20%20%20%20%22Enter%22%3A%20%22newlineAndIndent%22%2C%20%22Insert%22%3A%20%22toggleOverwrite%22%0A%20%20%7D%3B%0A%20%20%2F%2F%20Note%20that%20the%20save%20and%20find-related%20commands%20aren't%20defined%20by%0A%20%20%2F%2F%20default.%20Unknown%20commands%20are%20simply%20ignored.%0A%20%20keyMap.pcDefault%20%3D%20%7B%0A%20%20%20%20%22Ctrl-A%22%3A%20%22selectAll%22%2C%20%22Ctrl-D%22%3A%20%22deleteLine%22%2C%20%22Ctrl-Z%22%3A%20%22undo%22%2C%20%22Shift-Ctrl-Z%22%3A%20%22redo%22%2C%20%22Ctrl-Y%22%3A%20%22redo%22%2C%0A%20%20%20%20%22Ctrl-Home%22%3A%20%22goDocStart%22%2C%20%22Alt-Up%22%3A%20%22goDocStart%22%2C%20%22Ctrl-End%22%3A%20%22goDocEnd%22%2C%20%22Ctrl-Down%22%3A%20%22goDocEnd%22%2C%0A%20%20%20%20%22Ctrl-Left%22%3A%20%22goWordLeft%22%2C%20%22Ctrl-Right%22%3A%20%22goWordRight%22%2C%20%22Alt-Left%22%3A%20%22goLineStart%22%2C%20%22Alt-Right%22%3A%20%22goLineEnd%22%2C%0A%20%20%20%20%22Ctrl-Backspace%22%3A%20%22delWordLeft%22%2C%20%22Ctrl-Delete%22%3A%20%22delWordRight%22%2C%20%22Ctrl-S%22%3A%20%22save%22%2C%20%22Ctrl-F%22%3A%20%22find%22%2C%0A%20%20%20%20%22Ctrl-G%22%3A%20%22findNext%22%2C%20%22Shift-Ctrl-G%22%3A%20%22findPrev%22%2C%20%22Shift-Ctrl-F%22%3A%20%22replace%22%2C%20%22Shift-Ctrl-R%22%3A%20%22replaceAll%22%2C%0A%20%20%20%20%22Ctrl-%5B%22%3A%20%22indentLess%22%2C%20%22Ctrl-%5D%22%3A%20%22indentMore%22%2C%0A%20%20%20%20fallthrough%3A%20%22basic%22%0A%20%20%7D%3B%0A%20%20keyMap.macDefault%20%3D%20%7B%0A%20%20%20%20%22Cmd-A%22%3A%20%22selectAll%22%2C%20%22Cmd-D%22%3A%20%22deleteLine%22%2C%20%22Cmd-Z%22%3A%20%22undo%22%2C%20%22Shift-Cmd-Z%22%3A%20%22redo%22%2C%20%22Cmd-Y%22%3A%20%22redo%22%2C%0A%20%20%20%20%22Cmd-Up%22%3A%20%22goDocStart%22%2C%20%22Cmd-End%22%3A%20%22goDocEnd%22%2C%20%22Cmd-Down%22%3A%20%22goDocEnd%22%2C%20%22Alt-Left%22%3A%20%22goWordLeft%22%2C%0A%20%20%20%20%22Alt-Right%22%3A%20%22goWordRight%22%2C%20%22Cmd-Left%22%3A%20%22goLineStart%22%2C%20%22Cmd-Right%22%3A%20%22goLineEnd%22%2C%20%22Alt-Backspace%22%3A%20%22delWordLeft%22%2C%0A%20%20%20%20%22Ctrl-Alt-Backspace%22%3A%20%22delWordRight%22%2C%20%22Alt-Delete%22%3A%20%22delWordRight%22%2C%20%22Cmd-S%22%3A%20%22save%22%2C%20%22Cmd-F%22%3A%20%22find%22%2C%0A%20%20%20%20%22Cmd-G%22%3A%20%22findNext%22%2C%20%22Shift-Cmd-G%22%3A%20%22findPrev%22%2C%20%22
F%22%3A%20%22replace%22%2C%20%22Shift-Cmd-Alt-F%22%3A%20%22replaceAll%22%2C%0A%20%20%20%20%22Cmd-%5B%22%3A%20%22indentLess%22%2C%20%22Cmd-%5D%22%3A%20%22indentMore%22%2C%0A%20%20%20%20fallthrough%3A%20%5B%22basic%22%2C%20%22emacsy%22%5D%0A%20%20%7D%3B%0A%20%20keyMap%5B%22default%22%5D%20%3D%20mac%20%3F%20keyMap.macDefault%20%3A%20keyMap.pcDefault%3B%0A%20%20keyMap.emacsy%20%3D%20%7B%0A%20%20%20%20%22Ctrl-F%22%3A%20%22goCharRight%22%2C%20%22Ctrl-B%22%3A%20%22goCharLeft%22%2C%20%22Ctrl-P%22%3A%20%22goLineUp%22%2C%20%22Ctrl-N%22%3A%20%22goLineDown%22%2C%0A%20%20%20%20%22Alt-F%22%3A%20%22goWordRight%22%2C%20%22Alt-B%22%3A%20%22goWordLeft%22%2C%20%22Ctrl-A%22%3A%20%22goLineStart%22%2C%20%22Ctrl-E%22%3A%20%22goLineEnd%22%2C%0A%20%20%20%20%22Ctrl-V%22%3A%20%22goPageUp%22%2C%20%22Shift-Ctrl-V%22%3A%20%22goPageDown%22%2C%20%22Ctrl-D%22%3A%20%22delCharRight%22%2C%20%22Ctrl-H%22%3A%20%22delCharLeft%22%2C%0A%20%20%20%20%22Alt-D%22%3A%20%22delWordRight%22%2C%20%22Alt-Backspace%22%3A%20%22delWordLeft%22%2C%20%22Ctrl-K%22%3A%20%22killLine%22%2C%20%22Ctrl-T%22%3A%20%22transposeChars%22%0A%20%20%7D%3B%0A%0A%20%20function%20getKeyMap(val)%20%7B%0A%20%20%20%20if%20(typeof%20val%20%3D%3D%20%22string%22)%20return%20keyMap%5Bval%5D%3B%0A%20%20%20%20else%20return%20val%3B%0A%20%20%7D%0A%20%20function%20lookupKey(name%2C%20extraMap%2C%20map%2C%20handle%2C%20stop)%20%7B%0A%20%20%20%20function%20lookup(map)%20%7B%0A%20%20%20%20%20%20map%20%3D%20getKeyMap(map)%3B%0A%20%20%20%20%20%20var%20found%20%3D%20map%5Bname%5D%3B%0A%20%20%20%20%20%20if%20(found%20%3D%3D%3D%20false)%20%7B%0A%20%20%20%20%20%20%20%20if%20(stop)%20stop()%3B%0A%20%20%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(found%20!%3D%20null%20%26%26%20handle(found))%20return%20true%3B%0A%20%20%20%20%20%20if%20(map.nofallthrough)%20%7B%0A%20%20%20%20%20%20%20%20if%20(stop)%20stop()%3B%0A%20%20%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20fallthrough%20%3D%20map.fallthrough%3B%0A%20%20%20%20%20%20if%20(fallthrough%20%3D%3D%20null)%20return%20false%3B%0A%20%20%20%20%20%20if%20(Object.prototype.toString.call(fallthrough)%20!%3D%20%22%5Bobject%20Array%5D%22)%0A%20%20%20%20%20%20%20%20return%20lookup(fallthrough)%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20fallthrough.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20if%20(lookup(fallthrough%5Bi%5D))%20return%20true%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20false%3B%0A%20%20%20%20%7D%0A%20%20%20%20if%20(extraMap%20%26%26%20lookup(extraMap))%20return%20true%3B%0A%20%20%20%20return%20lookup(map)%3B%0A%20%20%7D%0A%20%20function%20isModifierKey(event)%20%7B%0A%20%20%20%20var%20name%20%3D%20keyNames%5Be_prop(event%2C%20%22keyCode%22)%5D%3B%0A%20%20%20%20return%20name%20%3D%3D%20%22Ctrl%22%20%7C%7C%20name%20%3D%3D%20%22Alt%22%20%7C%7C%20name%20%3D%3D%20%22Shift%22%20%7C%7C%20name%20%3D%3D%20%22Mod%22%3B%0A%20%20%7D%0A%0A%20%20CodeMirror.fromTextArea%20%3D%20function(textarea%2C%20options)%20%7B%0A%20%20%20%20if%20(!options)%20options%20%3D%20%7B%7D%3B%0A%20%20%20%20options.value%20%3D%20textarea.value%3B%0A%20%20%20%20if%20(!options.tabindex%20%26%26%20textarea.tabindex)%0A%20%20%20%20%20%20options.tabindex%20%3D%20textarea.tabindex%3B%0A%20%20%20%20%2F%2F%20Set%20autofocus%20to%20true%20if%20this%20textarea%20is%20focused%2C%20or%20if%20it%20has%0A%20%20%20%20%2F%2F%20autofocus%20and%20no%20other%20element%20is%20focused.%0A%20%20%20%20if%20(options.autofocus%20%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20var%20hasFocus%20%3D%20document.body%3B%0A%20%20%20%20%20%20%2F%2F%20doc.activeElement%20occasionally%20throws%20on%20IE%0A%20%20%20%20%20%20try%20%7B%20hasFocus%20%3D%20document.activeElement%3B%20%7D%20catch(e)%20%7B%7D%0A%20%20%20%20%20%20options.autofocus%20%3D%20hasFocus%20%3D%3D%20textarea%20%7C%7C%0A%20%20%20%20%20%20%20%20textarea.getAttribute(%22autofocus%22)%20!%3D%20null%20%26%26%20hasFocus%20%3D%3D%20document.body%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20function%20save()%20%7Btextarea.value%20%3D%20instance.getValue()%3B%7D%0A%20%20%20%20if%20(textarea.form)%20%7B%0A%20%20%20%20%20%20%2F%2F%20Deplorable%20hack%20to%20make%20the%20submit%20method%20do%20the%20right%20thing.%0A%20%20%20%20%20%20var%20rmSubmit%20%3D%20connect(textarea.form%2C%20%22submit%22%2C%20save%2C%20true)%3B%0A%20%20%20%20%20%20if%20(typeof%20textarea.form.submit%20%3D%3D%20%22function%22)%20%7B%0A%20%20%20%20%20%20%20%20var%20realSubmit%20%3D%20textarea.form.submit%3B%0A%20%20%20%20%20%20%20%20textarea.form.submit%20%3D%20function%20wrappedSubmit()%20%7B%0A%20%20%20%20%20%20%20%20%20%20save()%3B%0A%20%20%20%20%20%20%20%20%20%20textarea.form.submit%20%3D%20realSubmit%3B%0A%20%20%20%20%20%20%20%20%20%20textarea.form.submit()%3B%0A%20%20%20%20%20%20%20%20%20%20textarea.form.submit%20%3D%20wrappedSubmit%3B%0A%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20textarea.style.display%20%3D%20%22none%22%3B%0A%20%20%20%20var%20instance%20%3D%20CodeMirror(function(node)%20%7B%0A%20%20%20%20%20%20textarea.parentNode.insertBefore(node%2C%20textarea.nextSibling)%3B%0A%20%20%20%20%7D%2C%20options)%3B%0A%20%20%20%20instance.save%20%3D%20save%3B%0A%20%20%20%20instance.getTextArea%20%3D%20function()%20%7B%20return%20textarea%3B%20%7D%3B%0A%20%20%20%20instance.toTextArea%20%3D%20function()%20%7B%0A%20%20%20%20%20%20save()%3B%0A%20%20%20%20%20%20textarea.parentNode.removeChild(instance.getWrapperElement())%3B%0A%20%20%20%20%20%20textarea.style.display%20%3D%20%22%22%3B%0A%20%20%20%20%20%20if%20(textarea.form)%20%7B%0A%20%20%20%20%20%20%20%20rmSubmit()%3B%0A%20%20%20%20%20%20%20%20if%20(typeof%20textarea.form.submit%20%3D%3D%20%22function%22)%0A%20%20%20%20%20%20%20%20%20%20textarea.form.submit%20%3D%20realSubmit%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%3B%0A%20%20%20%20return%20instance%3B%0A%20%20%7D%3B%0A%0A%20%20var%20gecko%20%3D%20%2Fgecko%5C%2F%5Cd%7B7%7D%2Fi.test(navigator.userAgent)%3B%0A%20%20var%20ie%20%3D%20%2FMSIE%20%5Cd%2F.test(navigator.userAgent)%3B%0A%20%20var%20ie_lt8%20%3D%20%2FMSIE%20%5B1-7%5D%5Cb%2F.test(navigator.userAgent)%3B%0A%20%20var%20ie_lt9%20%3D%20%2FMSIE%20%5B1-8%5D%5Cb%2F.test(navigator.userAgent)%3B%0A%20%20var%20quirksMode%20%3D%20ie%20%26%26%20document.documentMode%20%3D%3D%205%3B%0A%20%20var%20webkit%20%3D%20%2FWebKit%5C%2F%2F.test(navigator.userAgent)%3B%0A%20%20var%20chrome%20%3D%20%2FChrome%5C%2F%2F.test(navigator.userAgent)%3B%0A%20%20var%20opera%20%3D%20%2FOpera%5C%2F%2F.test(navigator.userAgent)%3B%0A%20%20var%20safari%20%3D%20%2FApple%20Computer%2F.test(navigator.vendor)%3B%0A%20%20var%20khtml%20%3D%20%2FKHTML%5C%2F%2F.test(navigator.userAgent)%3B%0A%20%20var%20mac_geLion%20%3D%20%2FMac%20OS%20X%2010%5CD(%5B7-9%5D%7C%5Cd%5Cd)%5CD%2F.test(navigator.userAgent)%3B%0A%0A%20%20%2F%2F%20Utility%20functions%20for%20working%20with%20state.%20Exported%20because%20modes%0A%20%20%2F%2F%20sometimes%20need%20to%20do%20this.%0A%20%20function%20copyState(mode%2C%20state)%20%7B%0A%20%20%20%20if%20(state%20%3D%3D%3D%20true)%20return%20state%3B%0A%20%20%20%20if%20(mode.copyState)%20return%20mode.copyState(state)%3B%0A%20%20%20%20var%20nstate%20%3D%20%7B%7D%3B%0A%20%20%20%20for%20(var%20n%20in%20state)%20%7B%0A%20%20%20%20%20%20var%20val%20%3D%20state%5Bn%5D%3B%0A%20%20%20%20%20%20if%20(val%20instanceof%20Array)%20val%20%3D%20val.concat(%5B%5D)%3B%0A%20%20%20%20%20%20nstate%5Bn%5D%20%3D%20val%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20nstate%3B%0A%20%20%7D%0A%20%20CodeMirror.copyState%20%3D%20copyState%3B%0A%20%20function%20startState(mode%2C%20a1%2C%20a2)%20%7B%0A%20%20%20%20return%20mode.startState%20%3F%20mode.startState(a1%2C%20a2)%20%3A%20true%3B%0A%20%20%7D%0A%20%20CodeMirror.startState%20%3D%20startState%3B%0A%20%20CodeMirror.innerMode%20%3D%20function(mode%2C%20state)%20%7B%0A%20%20%20%20while%20(mode.innerMode)%20%7B%0A%20%20%20%20%20%20var%20info%20%3D%20mode.innerMode(state)%3B%0A%20%20%20%20%20%20state%20%3D%20info.state%3B%0A%20%20%20%20%20%20mode%20%3D%20info.mode%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20info%20%7C%7C%20%7Bmode%3A%20mode%2C%20state%3A%20state%7D%3B%0A%20%20%7D%3B%0A%0A%20%20%2F%2F%20The%20character%20stream%20used%20by%20a%20mode's%20parser.%0A%20%20function%20StringStream(string%2C%20tabSize)%20%7B%0A%20%20%20%20this.pos%20%3D%20this.start%20%3D%200%3B%0A%20%20%20%20this.string%20%3D%20string%3B%0A%20%20%20%20this.tabSize%20%3D%20tabSize%20%7C%7C%208%3B%0A%20%20%7D%0A%20%20StringStream.prototype%20%3D%20%7B%0A%20%20%20%20eol%3A%20function()%20%7Breturn%20this.pos%20%3E%3D%20this.string.length%3B%7D%2C%0A%20%20%20%20sol%3A%20function()%20%7Breturn%20this.pos%20%3D%3D%200%3B%7D%2C%0A%20%20%20%20peek%3A%20function()%20%7Breturn%20this.string.charAt(this.pos)%20%7C%7C%20undefined%3B%7D%2C%0A%20%20%20%20next%3A%20function()%20%7B%0A%20%20%20%20%20%20if%20(this.pos%20%3C%20this.string.length)%0A%20%20%20%20%20%20%20%20return%20this.string.charAt(this.pos%2B%2B)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20eat%3A%20function(match)%20%7B%0A%20%20%20%20%20%20var%20ch%20%3D%20this.string.charAt(this.pos)%3B%0A%20%20%20%20%20%20if%20(typeof%20match%20%3D%3D%20%22string%22)%20var%20ok%20%3D%20ch%20%3D%3D%20match%3B%0A%20%20%20%20%20%20else%20var%20ok%20%3D%20ch%20%26%26%20(match.test%20%3F%20match.test(ch)%20%3A%20match(ch))%3B%0A%20%20%20%20%20%20if%20(ok)%20%7B%2B%2Bthis.pos%3B%20return%20ch%3B%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20eatWhile%3A%20function(match)%20%7B%0A%20%20%20%20%20%20var%20start%20%3D%20this.pos%3B%0A%20%20%20%20%20%20while%20(this.eat(match))%7B%7D%0A%20%20%20%20%20%20return%20this.pos%20%3E%20start%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20eatSpace%3A%20function()%20%7B%0A%20%20%20%20%20%20var%20start%20%3D%20this.pos%3B%0A%20%20%20%20%20%20while%20(%2F%5B%5Cs%5Cu00a0%5D%2F.test(this.string.charAt(this.pos)))%20%2B%2Bthis.pos%3B%0A%20%20%20%20%20%20return%20this.pos%20%3E%20start%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20skipToEnd%3A%20function()%20%7Bthis.pos%20%3D%20this.string.length%3B%7D%2C%0A%20%20%20%20skipTo%3A%20function(ch)%20%7B%0A%20%20%20%20%20%20var%20found%20%3D%20this.string.indexOf(ch%2C%20this.pos)%3B%0A%20%20%20%20%20%20if%20(found%20%3E%20-1)%20%7Bthis.pos%20%3D%20found%3B%20return%20true%3B%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20backUp%3A%20function(n)%20%7Bthis.pos%20-%3D%20n%3B%7D%2C%0A%20%20%20%20column%3A%20function()%20%7Breturn%20countColumn(this.string%2C%20this.start%2C%20this.tabSize)%3B%7D%2C%0A%20%20%20%20indentation%3A%20function()%20%7Breturn%20countColumn(this.string%2C%20null%2C%20this.tabSize)%3B%7D%2C%0A%20%20%20%20match%3A%20function(pattern%2C%20consume%2C%20caseInsensitive)%20%7B%0A%20%20%20%20%20%20if%20(typeof%20pattern%20%3D%3D%20%22string%22)%20%7B%0A%20%20%20%20%20%20%20%20var%20cased%20%3D%20function(str)%20%7Breturn%20caseInsensitive%20%3F%20str.toLowerCase()%20%3A%20str%3B%7D%3B%0A%20%20%20%20%20%20%20%20if%20(cased(this.string).indexOf(cased(pattern)%2C%20this.pos)%20%3D%3D%20this.pos)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(consume%20!%3D%3D%20false)%20this.pos%20%2B%3D%20pattern.length%3B%0A%20%20%20%20%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20match%20%3D%20this.string.slice(this.pos).match(pattern)%3B%0A%20%20%20%20%20%20%20%20if%20(match%20%26%26%20match.index%20%3E%200)%20return%20null%3B%0A%20%20%20%20%20%20%20%20if%20(match%20%26%26%20consume%20!%3D%3D%20false)%20this.pos%20%2B%3D%20match%5B0%5D.length%3B%0A%20%20%20%20%20%20%20%20return%20match%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20current%3A%20function()%7Breturn%20this.string.slice(this.start%2C%20this.pos)%3B%7D%0A%20%20%7D%3B%0A%20%20CodeMirror.StringStream%20%3D%20StringStream%3B%0A%0A%20%20function%20MarkedSpan(from%2C%20to%2C%20marker)%20%7B%0A%20%20%20%20this.from%20%3D%20from%3B%20this.to%20%3D%20to%3B%20this.marker%20%3D%20marker%3B%0A%20%20%7D%0A%0A%20%20function%20getMarkedSpanFor(spans%2C%20marker%2C%20del)%20%7B%0A%20%20%20%20if%20(spans)%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20spans.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20var%20span%20%3D%20spans%5Bi%5D%3B%0A%20%20%20%20%20%20if%20(span.marker%20%3D%3D%20marker)%20%7B%0A%20%20%20%20%20%20%20%20if%20(del)%20spans.splice(i%2C%201)%3B%0A%20%20%20%20%20%20%20%20return%20span%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20function%20markedSpansBefore(old%2C%20startCh%2C%20endCh)%20%7B%0A%20%20%20%20if%20(old)%20for%20(var%20i%20%3D%200%2C%20nw%3B%20i%20%3C%20old.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20var%20span%20%3D%20old%5Bi%5D%2C%20marker%20%3D%20span.marker%3B%0A%20%20%20%20%20%20var%20startsBefore%20%3D%20span.from%20%3D%3D%20null%20%7C%7C%20(marker.inclusiveLeft%20%3F%20span.from%20%3C%3D%20startCh%20%3A%20span.from%20%3C%20startCh)%3B%0A%20%20%20%20%20%20if%20(startsBefore%20%7C%7C%20marker.type%20%3D%3D%20%22bookmark%22%20%26%26%20span.from%20%3D%3D%20startCh%20%26%26%20span.from%20!%3D%20endCh)%20%7B%0A%20%20%20%20%20%20%20%20var%20endsAfter%20%3D%20span.to%20%3D%3D%20null%20%7C%7C%20(marker.inclusiveRight%20%3F%20span.to%20%3E%3D%20startCh%20%3A%20span.to%20%3E%20startCh)%3B%0A%20%20%20%20%20%20%20%20(nw%20%7C%7C%20(nw%20%3D%20%5B%5D)).push(%7Bfrom%3A%20span.from%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20to%3A%20endsAfter%20%3F%20null%20%3A%20span.to%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20marker%3A%20marker%7D)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20nw%3B%0A%20%20%7D%0A%0A%20%20function%20markedSpansAfter(old%2C%20endCh)%20%7B%0A%20%20%20%20if%20(old)%20for%20(var%20i%20%3D%200%2C%20nw%3B%20i%20%3C%20old.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20var%20span%20%3D%20old%5Bi%5D%2C%20marker%20%3D%20span.marker%3B%0A%20%20%20%20%20%20var%20endsAfter%20%3D%20span.to%20%3D%3D%20null%20%7C%7C%20(marker.inclusiveRight%20%3F%20span.to%20%3E%3D%20endCh%20%3A%20span.to%20%3E%20endCh)%3B%0A%20%20%20%20%20%20if%20(endsAfter%20%7C%7C%20marker.type%20%3D%3D%20%22bookmark%22%20%26%26%20span.from%20%3D%3D%20endCh)%20%7B%0A%20%20%20%20%20%20%20%20var%20startsBefore%20%3D%20span.from%20%3D%3D%20null%20%7C%7C%20(marker.inclusiveLeft%20%3F%20span.from%20%3C%3D%20endCh%20%3A%20span.from%20%3C%20endCh)%3B%0A%20%20%20%20%20%20%20%20(nw%20%7C%7C%20(nw%20%3D%20%5B%5D)).push(%7Bfrom%3A%20startsBefore%20%3F%20null%20%3A%20span.from%20-%20endCh%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20to%3A%20span.to%20%3D%3D%20null%20%3F%20null%20%3A%20span.to%20-%20endCh%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20marker%3A%20marker%7D)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20nw%3B%0A%20%20%7D%0A%0A%20%20function%20updateMarkedSpans(oldFirst%2C%20oldLast%2C%20startCh%2C%20endCh%2C%20newText)%20%7B%0A%20%20%20%20if%20(!oldFirst%20%26%26%20!oldLast)%20return%20newText%3B%0A%20%20%20%20%2F%2F%20Get%20the%20spans%20that%20'stick%20out'%20on%20both%20sides%0A%20%20%20%20var%20first%20%3D%20markedSpansBefore(oldFirst%2C%20startCh)%3B%0A%20%20%20%20var%20last%20%3D%20markedSpansAfter(oldLast%2C%20endCh)%3B%0A%0A%20%20%20%20%2F%2F%20Next%2C%20merge%20those%20two%20ends%0A%20%20%20%20var%20sameLine%20%3D%20newText.length%20%3D%3D%201%2C%20offset%20%3D%20lst(newText).length%20%2B%20(sameLine%20%3F%20startCh%20%3A%200)%3B%0A%20%20%20%20if%20(first)%20%7B%0A%20%20%20%20%20%20%2F%2F%20Fix%20up%20.to%20properties%20of%20first%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20first.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20span%20%3D%20first%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20if%20(span.to%20%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20found%20%3D%20getMarkedSpanFor(last%2C%20span.marker)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(!found)%20span.to%20%3D%20startCh%3B%0A%20%20%20%20%20%20%20%20%20%20else%20if%20(sameLine)%20span.to%20%3D%20found.to%20%3D%3D%20null%20%3F%20null%20%3A%20found.to%20%2B%20offset%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20if%20(last)%20%7B%0A%20%20%20%20%20%20%2F%2F%20Fix%20up%20.from%20in%20last%20(or%20move%20them%20into%20first%20in%20case%20of%20sameLine)%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20last.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20span%20%3D%20last%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20if%20(span.to%20!%3D%20null)%20span.to%20%2B%3D%20offset%3B%0A%20%20%20%20%20%20%20%20if%20(span.from%20%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20found%20%3D%20getMarkedSpanFor(first%2C%20span.marker)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(!found)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20span.from%20%3D%20offset%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(sameLine)%20(first%20%7C%7C%20(first%20%3D%20%5B%5D)).push(span)%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20span.from%20%2B%3D%20offset%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(sameLine)%20(first%20%7C%7C%20(first%20%3D%20%5B%5D)).push(span)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20var%20newMarkers%20%3D%20%5BnewHL(newText%5B0%5D%2C%20first)%5D%3B%0A%20%20%20%20if%20(!sameLine)%20%7B%0A%20%20%20%20%20%20%2F%2F%20Fill%20gap%20with%20whole-line-spans%0A%20%20%20%20%20%20var%20gap%20%3D%20newText.length%20-%202%2C%20gapMarkers%3B%0A%20%20%20%20%20%20if%20(gap%20%3E%200%20%26%26%20first)%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20first.length%3B%20%2B%2Bi)%0A%20%20%20%20%20%20%20%20%20%20if%20(first%5Bi%5D.to%20%3D%3D%20null)%0A%20%20%20%20%20%20%20%20%20%20%20%20(gapMarkers%20%7C%7C%20(gapMarkers%20%3D%20%5B%5D)).push(%7Bfrom%3A%20null%2C%20to%3A%20null%2C%20marker%3A%20first%5Bi%5D.marker%7D)%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20gap%3B%20%2B%2Bi)%0A%20%20%20%20%20%20%20%20newMarkers.push(newHL(newText%5Bi%2B1%5D%2C%20gapMarkers))%3B%0A%20%20%20%20%20%20newMarkers.push(newHL(lst(newText)%2C%20last))%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20newMarkers%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20hl%20stands%20for%20history-line%2C%20a%20data%20structure%20that%20can%20be%20either%20a%0A%20%20%2F%2F%20string%20(line%20without%20markers)%20or%20a%20%7Btext%2C%20markedSpans%7D%20object.%0A%20%20function%20hlText(val)%20%7B%20return%20typeof%20val%20%3D%3D%20%22string%22%20%3F%20val%20%3A%20val.text%3B%20%7D%0A%20%20function%20hlSpans(val)%20%7B%20return%20typeof%20val%20%3D%3D%20%22string%22%20%3F%20null%20%3A%20val.markedSpans%3B%20%7D%0A%20%20function%20newHL(text%2C%20spans)%20%7B%20return%20spans%20%3F%20%7Btext%3A%20text%2C%20markedSpans%3A%20spans%7D%20%3A%20text%3B%20%7D%0A%0A%20%20function%20detachMarkedSpans(line)%20%7B%0A%20%20%20%20var%20spans%20%3D%20line.markedSpans%3B%0A%20%20%20%20if%20(!spans)%20return%3B%0A%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20spans.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20var%20lines%20%3D%20spans%5Bi%5D.marker.lines%3B%0A%20%20%20%20%20%20var%20ix%20%3D%20indexOf(lines%2C%20line)%3B%0A%20%20%20%20%20%20lines.splice(ix%2C%201)%3B%0A%20%20%20%20%7D%0A%20%20%20%20line.markedSpans%20%3D%20null%3B%0A%20%20%7D%0A%0A%20%20function%20attachMarkedSpans(line%2C%20spans)%20%7B%0A%20%20%20%20if%20(!spans)%20return%3B%0A%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20spans.length%3B%20%2B%2Bi)%0A%20%20%20%20%20%20var%20marker%20%3D%20spans%5Bi%5D.marker.lines.push(line)%3B%0A%20%20%20%20line.markedSpans%20%3D%20spans%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20When%20measuring%20the%20position%20of%20the%20end%20of%20a%20line%2C%20different%0A%20%20%2F%2F%20browsers%20require%20different%20approaches.%20If%20an%20empty%20span%20is%20added%2C%0A%20%20%2F%2F%20many%20browsers%20report%20bogus%20offsets.%20Of%20those%2C%20some%20(Webkit%2C%0A%20%20%2F%2F%20recent%20IE)%20will%20accept%20a%20space%20without%20moving%20the%20whole%20span%20to%0A%20%20%2F%2F%20the%20next%20line%20when%20wrapping%20it%2C%20others%20work%20with%20a%20zero-width%0A%20%20%2F%2F%20space.%0A%20%20var%20eolSpanContent%20%3D%20%22%20%22%3B%0A%20%20if%20(gecko%20%7C%7C%20(ie%20%26%26%20!ie_lt8))%20eolSpanContent%20%3D%20%22%5Cu200b%22%3B%0A%20%20else%20if%20(opera)%20eolSpanContent%20%3D%20%22%22%3B%0A%0A%20%20%2F%2F%20Line%20objects.%20These%20hold%20state%20related%20to%20a%20line%2C%20including%0A%20%20%2F%2F%20highlighting%20info%20(the%20styles%20array).%0A%20%20function%20Line(text%2C%20markedSpans)%20%7B%0A%20%20%20%20this.text%20%3D%20text%3B%0A%20%20%20%20this.height%20%3D%201%3B%0A%20%20%20%20attachMarkedSpans(this%2C%20markedSpans)%3B%0A%20%20%7D%0A%20%20Line.prototype%20%3D%20%7B%0A%20%20%20%20update%3A%20function(text%2C%20markedSpans)%20%7B%0A%20%20%20%20%20%20this.text%20%3D%20text%3B%0A%20%20%20%20%20%20this.stateAfter%20%3D%20this.styles%20%3D%20null%3B%0A%20%20%20%20%20%20detachMarkedSpans(this)%3B%0A%20%20%20%20%20%20attachMarkedSpans(this%2C%20markedSpans)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20%2F%2F%20Run%20the%20given%20mode's%20parser%20over%20a%20line%2C%20update%20the%20styles%0A%20%20%20%20%2F%2F%20array%2C%20which%20contains%20alternating%20fragments%20of%20text%20and%20CSS%0A%20%20%20%20%2F%2F%20classes.%0A%20%20%20%20highlight%3A%20function(mode%2C%20state%2C%20tabSize)%20%7B%0A%20%20%20%20%20%20var%20stream%20%3D%20new%20StringStream(this.text%2C%20tabSize)%2C%20st%20%3D%20this.styles%20%7C%7C%20(this.styles%20%3D%20%5B%5D)%3B%0A%20%20%20%20%20%20var%20pos%20%3D%20st.length%20%3D%200%3B%0A%20%20%20%20%20%20if%20(this.text%20%3D%3D%20%22%22%20%26%26%20mode.blankLine)%20mode.blankLine(state)%3B%0A%20%20%20%20%20%20while%20(!stream.eol())%20%7B%0A%20%20%20%20%20%20%20%20var%20style%20%3D%20mode.token(stream%2C%20state)%2C%20substr%20%3D%20stream.current()%3B%0A%20%20%20%20%20%20%20%20stream.start%20%3D%20stream.pos%3B%0A%20%20%20%20%20%20%20%20if%20(pos%20%26%26%20st%5Bpos-1%5D%20%3D%3D%20style)%20%7B%0A%20%20%20%20%20%20%20%20%20%20st%5Bpos-2%5D%20%2B%3D%20substr%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(substr)%20%7B%0A%20%20%20%20%20%20%20%20%20%20st%5Bpos%2B%2B%5D%20%3D%20substr%3B%20st%5Bpos%2B%2B%5D%20%3D%20style%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%2F%2F%20Give%20up%20when%20line%20is%20ridiculously%20long%0A%20%20%20%20%20%20%20%20if%20(stream.pos%20%3E%205000)%20%7B%0A%20%20%20%20%20%20%20%20%20%20st%5Bpos%2B%2B%5D%20%3D%20this.text.slice(stream.pos)%3B%20st%5Bpos%2B%2B%5D%20%3D%20null%3B%0A%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20process%3A%20function(mode%2C%20state%2C%20tabSize)%20%7B%0A%20%20%20%20%20%20var%20stream%20%3D%20new%20StringStream(this.text%2C%20tabSize)%3B%0A%20%20%20%20%20%20if%20(this.text%20%3D%3D%20%22%22%20%26%26%20mode.blankLine)%20mode.blankLine(state)%3B%0A%20%20%20%20%20%20while%20(!stream.eol()%20%26%26%20stream.pos%20%3C%3D%205000)%20%7B%0A%20%20%20%20%20%20%20%20mode.token(stream%2C%20state)%3B%0A%20%20%20%20%20%20%20%20stream.start%20%3D%20stream.pos%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%2F%2F%20Fetch%20the%20parser%20token%20for%20a%20given%20character.%20Useful%20for%20hacks%0A%20%20%20%20%2F%2F%20that%20want%20to%20inspect%20the%20mode%20state%20(say%2C%20for%20completion).%0A%20%20%20%20getTokenAt%3A%20function(mode%2C%20state%2C%20tabSize%2C%20ch)%20%7B%0A%20%20%20%20%20%20var%20txt%20%3D%20this.text%2C%20stream%20%3D%20new%20StringStream(txt%2C%20tabSize)%3B%0A%20%20%20%20%20%20while%20(stream.pos%20%3C%20ch%20%26%26%20!stream.eol())%20%7B%0A%20%20%20%20%20%20%20%20stream.start%20%3D%20stream.pos%3B%0A%20%20%20%20%20%20%20%20var%20style%20%3D%20mode.token(stream%2C%20state)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20%7Bstart%3A%20stream.start%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20end%3A%20stream.pos%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20string%3A%20stream.current()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20className%3A%20style%20%7C%7C%20null%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20state%3A%20state%7D%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20indentation%3A%20function(tabSize)%20%7Breturn%20countColumn(this.text%2C%20null%2C%20tabSize)%3B%7D%2C%0A%20%20%20%20%2F%2F%20Produces%20an%20HTML%20fragment%20for%20the%20line%2C%20taking%20selection%2C%0A%20%20%20%20%2F%2F%20marking%2C%20and%20highlighting%20into%20account.%0A%20%20%20%20getContent%3A%20function(tabSize%2C%20wrapAt%2C%20compensateForWrapping)%20%7B%0A%20%20%20%20%20%20var%20first%20%3D%20true%2C%20col%20%3D%200%2C%20specials%20%3D%20%2F%5B%5Ct%5Cu0000-%5Cu0019%5Cu200b%5Cu2028%5Cu2029%5CuFEFF%5D%2Fg%3B%0A%20%20%20%20%20%20var%20pre%20%3D%20elt(%22pre%22)%3B%0A%20%20%20%20%20%20function%20span_(html%2C%20text%2C%20style)%20%7B%0A%20%20%20%20%20%20%20%20if%20(!text)%20return%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20Work%20around%20a%20bug%20where%2C%20in%20some%20compat%20modes%2C%20IE%20ignores%20leading%20spaces%0A%20%20%20%20%20%20%20%20if%20(first%20%26%26%20ie%20%26%26%20text.charAt(0)%20%3D%3D%20%22%20%22)%20text%20%3D%20%22%5Cu00a0%22%20%2B%20text.slice(1)%3B%0A%20%20%20%20%20%20%20%20first%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20if%20(!specials.test(text))%20%7B%0A%20%20%20%20%20%20%20%20%20%20col%20%2B%3D%20text.length%3B%0A%20%20%20%20%20%20%20%20%20%20var%20content%20%3D%20document.createTextNode(text)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20content%20%3D%20document.createDocumentFragment()%2C%20pos%20%3D%200%3B%0A%20%20%20%20%20%20%20%20%20%20while%20(true)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20specials.lastIndex%20%3D%20pos%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20m%20%3D%20specials.exec(text)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20skipped%20%3D%20m%20%3F%20m.index%20-%20pos%20%3A%20text.length%20-%20pos%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(skipped)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20content.appendChild(document.createTextNode(text.slice(pos%2C%20pos%20%2B%20skipped)))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20col%20%2B%3D%20skipped%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(!m)%20break%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20pos%20%2B%3D%20skipped%20%2B%201%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(m%5B0%5D%20%3D%3D%20%22%5Ct%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20tabWidth%20%3D%20tabSize%20-%20col%20%25%20tabSize%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20content.appendChild(elt(%22span%22%2C%20spaceStr(tabWidth)%2C%20%22cm-tab%22))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20col%20%2B%3D%20tabWidth%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20token%20%3D%20elt(%22span%22%2C%20%22%5Cu2022%22%2C%20%22cm-invalidchar%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20token.title%20%3D%20%22%5C%5Cu%22%20%2B%20m%5B0%5D.charCodeAt(0).toString(16)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20content.appendChild(token)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20col%20%2B%3D%201%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if%20(style)%20html.appendChild(elt(%22span%22%2C%20%5Bcontent%5D%2C%20style))%3B%0A%20%20%20%20%20%20%20%20else%20html.appendChild(content)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20var%20span%20%3D%20span_%3B%0A%20%20%20%20%20%20if%20(wrapAt%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20var%20outPos%20%3D%200%2C%20anchor%20%3D%20pre.anchor%20%3D%20elt(%22span%22)%3B%0A%20%20%20%20%20%20%20%20span%20%3D%20function(html%2C%20text%2C%20style)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20l%20%3D%20text.length%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(wrapAt%20%3E%3D%20outPos%20%26%26%20wrapAt%20%3C%20outPos%20%2B%20l)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(wrapAt%20%3E%20outPos)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20span_(html%2C%20text.slice(0%2C%20wrapAt%20-%20outPos)%2C%20style)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20See%20comment%20at%20the%20definition%20of%20spanAffectsWrapping%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(compensateForWrapping)%20html.appendChild(elt(%22wbr%22))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20html.appendChild(anchor)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20cut%20%3D%20wrapAt%20-%20outPos%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20span_(anchor%2C%20opera%20%3F%20text.slice(cut%2C%20cut%20%2B%201)%20%3A%20text.slice(cut)%2C%20style)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(opera)%20span_(html%2C%20text.slice(cut%20%2B%201)%2C%20style)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20wrapAt--%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20outPos%20%2B%3D%20l%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20outPos%20%2B%3D%20l%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20span_(html%2C%20text%2C%20style)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(outPos%20%3D%3D%20wrapAt%20%26%26%20outPos%20%3D%3D%20len)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20setTextContent(anchor%2C%20eolSpanContent)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20html.appendChild(anchor)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Stop%20outputting%20HTML%20when%20gone%20sufficiently%20far%20beyond%20measure%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20if%20(outPos%20%3E%20wrapAt%20%2B%2010%20%26%26%20%2F%5Cs%2F.test(text))%20span%20%3D%20function()%7B%7D%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20var%20st%20%3D%20this.styles%2C%20allText%20%3D%20this.text%2C%20marked%20%3D%20this.markedSpans%3B%0A%20%20%20%20%20%20var%20len%20%3D%20allText.length%3B%0A%20%20%20%20%20%20function%20styleToClass(style)%20%7B%0A%20%20%20%20%20%20%20%20if%20(!style)%20return%20null%3B%0A%20%20%20%20%20%20%20%20return%20%22cm-%22%20%2B%20style.replace(%2F%20%2B%2Fg%2C%20%22%20cm-%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(!allText%20%26%26%20wrapAt%20%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20span(pre%2C%20%22%20%22)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(!marked%20%7C%7C%20!marked.length)%20%7B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20ch%20%3D%200%3B%20ch%20%3C%20len%3B%20i%2B%3D2)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20str%20%3D%20st%5Bi%5D%2C%20style%20%3D%20st%5Bi%2B1%5D%2C%20l%20%3D%20str.length%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(ch%20%2B%20l%20%3E%20len)%20str%20%3D%20str.slice(0%2C%20len%20-%20ch)%3B%0A%20%20%20%20%20%20%20%20%20%20ch%20%2B%3D%20l%3B%0A%20%20%20%20%20%20%20%20%20%20span(pre%2C%20str%2C%20styleToClass(style))%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20marked.sort(function(a%2C%20b)%20%7B%20return%20a.from%20-%20b.from%3B%20%7D)%3B%0A%20%20%20%20%20%20%20%20var%20pos%20%3D%200%2C%20i%20%3D%200%2C%20text%20%3D%20%22%22%2C%20style%2C%20sg%20%3D%200%3B%0A%20%20%20%20%20%20%20%20var%20nextChange%20%3D%20marked%5B0%5D.from%20%7C%7C%200%2C%20marks%20%3D%20%5B%5D%2C%20markpos%20%3D%200%3B%0A%20%20%20%20%20%20%20%20var%20advanceMarks%20%3D%20function()%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20m%3B%0A%20%20%20%20%20%20%20%20%20%20while%20(markpos%20%3C%20marked.length%20%26%26%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20((m%20%3D%20marked%5Bmarkpos%5D).from%20%3D%3D%20pos%20%7C%7C%20m.from%20%3D%3D%20null))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(m.marker.type%20%3D%3D%20%22range%22)%20marks.push(m)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%2B%2Bmarkpos%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20nextChange%20%3D%20markpos%20%3C%20marked.length%20%3F%20marked%5Bmarkpos%5D.from%20%3A%20Infinity%3B%0A%20%20%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20marks.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20to%20%3D%20marks%5Bi%5D.to%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(to%20%3D%3D%20null)%20to%20%3D%20Infinity%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(to%20%3D%3D%20pos)%20marks.splice(i--%2C%201)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20nextChange%20%3D%20Math.min(to%2C%20nextChange)%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%20%20var%20m%20%3D%200%3B%0A%20%20%20%20%20%20%20%20while%20(pos%20%3C%20len)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(nextChange%20%3D%3D%20pos)%20advanceMarks()%3B%0A%20%20%20%20%20%20%20%20%20%20var%20upto%20%3D%20Math.min(len%2C%20nextChange)%3B%0A%20%20%20%20%20%20%20%20%20%20while%20(true)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(text)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20end%20%3D%20pos%20%2B%20text.length%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20appliedStyle%20%3D%20style%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20(var%20j%20%3D%200%3B%20j%20%3C%20marks.length%3B%20%2B%2Bj)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20mark%20%3D%20marks%5Bj%5D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20appliedStyle%20%3D%20(appliedStyle%20%3F%20appliedStyle%20%2B%20%22%20%22%20%3A%20%22%22)%20%2B%20mark.marker.style%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(mark.marker.endStyle%20%26%26%20mark.to%20%3D%3D%3D%20Math.min(end%2C%20upto))%20appliedStyle%20%2B%3D%20%22%20%22%20%2B%20mark.marker.endStyle%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(mark.marker.startStyle%20%26%26%20mark.from%20%3D%3D%3D%20pos)%20appliedStyle%20%2B%3D%20%22%20%22%20%2B%20mark.marker.startStyle%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20span(pre%2C%20end%20%3E%20upto%20%3F%20text.slice(0%2C%20upto%20-%20pos)%20%3A%20text%2C%20appliedStyle)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(end%20%3E%3D%20upto)%20%7Btext%20%3D%20text.slice(upto%20-%20pos)%3B%20pos%20%3D%20upto%3B%20break%3B%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20pos%20%3D%20end%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20text%20%3D%20st%5Bi%2B%2B%5D%3B%20style%20%3D%20styleToClass(st%5Bi%2B%2B%5D)%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20pre%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20cleanUp%3A%20function()%20%7B%0A%20%20%20%20%20%20this.parent%20%3D%20null%3B%0A%20%20%20%20%20%20detachMarkedSpans(this)%3B%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%0A%20%20%2F%2F%20Data%20structure%20that%20holds%20the%20sequence%20of%20lines.%0A%20%20function%20LeafChunk(lines)%20%7B%0A%20%20%20%20this.lines%20%3D%20lines%3B%0A%20%20%20%20this.parent%20%3D%20null%3B%0A%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20lines.length%2C%20height%20%3D%200%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20lines%5Bi%5D.parent%20%3D%20this%3B%0A%20%20%20%20%20%20height%20%2B%3D%20lines%5Bi%5D.height%3B%0A%20%20%20%20%7D%0A%20%20%20%20this.height%20%3D%20height%3B%0A%20%20%7D%0A%20%20LeafChunk.prototype%20%3D%20%7B%0A%20%20%20%20chunkSize%3A%20function()%20%7B%20return%20this.lines.length%3B%20%7D%2C%0A%20%20%20%20remove%3A%20function(at%2C%20n%2C%20callbacks)%20%7B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%20at%2C%20e%20%3D%20at%20%2B%20n%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20line%20%3D%20this.lines%5Bi%5D%3B%0A%20%20%20%20%20%20%20%20this.height%20-%3D%20line.height%3B%0A%20%20%20%20%20%20%20%20line.cleanUp()%3B%0A%20%20%20%20%20%20%20%20if%20(line.handlers)%0A%20%20%20%20%20%20%20%20%20%20for%20(var%20j%20%3D%200%3B%20j%20%3C%20line.handlers.length%3B%20%2B%2Bj)%20callbacks.push(line.handlers%5Bj%5D)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20this.lines.splice(at%2C%20n)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20collapse%3A%20function(lines)%20%7B%0A%20%20%20%20%20%20lines.splice.apply(lines%2C%20%5Blines.length%2C%200%5D.concat(this.lines))%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20insertHeight%3A%20function(at%2C%20lines%2C%20height)%20%7B%0A%20%20%20%20%20%20this.height%20%2B%3D%20height%3B%0A%20%20%20%20%20%20this.lines%20%3D%20this.lines.slice(0%2C%20at).concat(lines).concat(this.lines.slice(at))%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20lines.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20lines%5Bi%5D.parent%20%3D%20this%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20iterN%3A%20function(at%2C%20n%2C%20op)%20%7B%0A%20%20%20%20%20%20for%20(var%20e%20%3D%20at%20%2B%20n%3B%20at%20%3C%20e%3B%20%2B%2Bat)%0A%20%20%20%20%20%20%20%20if%20(op(this.lines%5Bat%5D))%20return%20true%3B%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%20%20function%20BranchChunk(children)%20%7B%0A%20%20%20%20this.children%20%3D%20children%3B%0A%20%20%20%20var%20size%20%3D%200%2C%20height%20%3D%200%3B%0A%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20children.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20var%20ch%20%3D%20children%5Bi%5D%3B%0A%20%20%20%20%20%20size%20%2B%3D%20ch.chunkSize()%3B%20height%20%2B%3D%20ch.height%3B%0A%20%20%20%20%20%20ch.parent%20%3D%20this%3B%0A%20%20%20%20%7D%0A%20%20%20%20this.size%20%3D%20size%3B%0A%20%20%20%20this.height%20%3D%20height%3B%0A%20%20%20%20this.parent%20%3D%20null%3B%0A%20%20%7D%0A%20%20BranchChunk.prototype%20%3D%20%7B%0A%20%20%20%20chunkSize%3A%20function()%20%7B%20return%20this.size%3B%20%7D%2C%0A%20%20%20%20remove%3A%20function(at%2C%20n%2C%20callbacks)%20%7B%0A%20%20%20%20%20%20this.size%20-%3D%20n%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20this.children.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20child%20%3D%20this.children%5Bi%5D%2C%20sz%20%3D%20child.chunkSize()%3B%0A%20%20%20%20%20%20%20%20if%20(at%20%3C%20sz)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20rm%20%3D%20Math.min(n%2C%20sz%20-%20at)%2C%20oldHeight%20%3D%20child.height%3B%0A%20%20%20%20%20%20%20%20%20%20child.remove(at%2C%20rm%2C%20callbacks)%3B%0A%20%20%20%20%20%20%20%20%20%20this.height%20-%3D%20oldHeight%20-%20child.height%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(sz%20%3D%3D%20rm)%20%7B%20this.children.splice(i--%2C%201)%3B%20child.parent%20%3D%20null%3B%20%7D%0A%20%20%20%20%20%20%20%20%20%20if%20((n%20-%3D%20rm)%20%3D%3D%200)%20break%3B%0A%20%20%20%20%20%20%20%20%20%20at%20%3D%200%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20at%20-%3D%20sz%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(this.size%20-%20n%20%3C%2025)%20%7B%0A%20%20%20%20%20%20%20%20var%20lines%20%3D%20%5B%5D%3B%0A%20%20%20%20%20%20%20%20this.collapse(lines)%3B%0A%20%20%20%20%20%20%20%20this.children%20%3D%20%5Bnew%20LeafChunk(lines)%5D%3B%0A%20%20%20%20%20%20%20%20this.children%5B0%5D.parent%20%3D%20this%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20collapse%3A%20function(lines)%20%7B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20this.children.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20this.children%5Bi%5D.collapse(lines)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20insert%3A%20function(at%2C%20lines)%20%7B%0A%20%20%20%20%20%20var%20height%20%3D%200%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20lines.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20height%20%2B%3D%20lines%5Bi%5D.height%3B%0A%20%20%20%20%20%20this.insertHeight(at%2C%20lines%2C%20height)%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20insertHeight%3A%20function(at%2C%20lines%2C%20height)%20%7B%0A%20%20%20%20%20%20this.size%20%2B%3D%20lines.length%3B%0A%20%20%20%20%20%20this.height%20%2B%3D%20height%3B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20this.children.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20child%20%3D%20this.children%5Bi%5D%2C%20sz%20%3D%20child.chunkSize()%3B%0A%20%20%20%20%20%20%20%20if%20(at%20%3C%3D%20sz)%20%7B%0A%20%20%20%20%20%20%20%20%20%20child.insertHeight(at%2C%20lines%2C%20height)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(child.lines%20%26%26%20child.lines.length%20%3E%2050)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20while%20(child.lines.length%20%3E%2050)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20spilled%20%3D%20child.lines.splice(child.lines.length%20-%2025%2C%2025)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20newleaf%20%3D%20new%20LeafChunk(spilled)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20child.height%20-%3D%20newleaf.height%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20this.children.splice(i%20%2B%201%2C%200%2C%20newleaf)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20newleaf.parent%20%3D%20this%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20this.maybeSpill()%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20at%20-%3D%20sz%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20maybeSpill%3A%20function()%20%7B%0A%20%20%20%20%20%20if%20(this.children.length%20%3C%3D%2010)%20return%3B%0A%20%20%20%20%20%20var%20me%20%3D%20this%3B%0A%20%20%20%20%20%20do%20%7B%0A%20%20%20%20%20%20%20%20var%20spilled%20%3D%20me.children.splice(me.children.length%20-%205%2C%205)%3B%0A%20%20%20%20%20%20%20%20var%20sibling%20%3D%20new%20BranchChunk(spilled)%3B%0A%20%20%20%20%20%20%20%20if%20(!me.parent)%20%7B%20%2F%2F%20Become%20the%20parent%20node%0A%20%20%20%20%20%20%20%20%20%20var%20copy%20%3D%20new%20BranchChunk(me.children)%3B%0A%20%20%20%20%20%20%20%20%20%20copy.parent%20%3D%20me%3B%0A%20%20%20%20%20%20%20%20%20%20me.children%20%3D%20%5Bcopy%2C%20sibling%5D%3B%0A%20%20%20%20%20%20%20%20%20%20me%20%3D%20copy%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20me.size%20-%3D%20sibling.size%3B%0A%20%20%20%20%20%20%20%20%20%20me.height%20-%3D%20sibling.height%3B%0A%20%20%20%20%20%20%20%20%20%20var%20myIndex%20%3D%20indexOf(me.parent.children%2C%20me)%3B%0A%20%20%20%20%20%20%20%20%20%20me.parent.children.splice(myIndex%20%2B%201%2C%200%2C%20sibling)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20sibling.parent%20%3D%20me.parent%3B%0A%20%20%20%20%20%20%7D%20while%20(me.children.length%20%3E%2010)%3B%0A%20%20%20%20%20%20me.parent.maybeSpill()%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20iter%3A%20function(from%2C%20to%2C%20op)%20%7B%20this.iterN(from%2C%20to%20-%20from%2C%20op)%3B%20%7D%2C%0A%20%20%20%20iterN%3A%20function(at%2C%20n%2C%20op)%20%7B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20this.children.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20child%20%3D%20this.children%5Bi%5D%2C%20sz%20%3D%20child.chunkSize()%3B%0A%20%20%20%20%20%20%20%20if%20(at%20%3C%20sz)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20used%20%3D%20Math.min(n%2C%20sz%20-%20at)%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(child.iterN(at%2C%20used%2C%20op))%20return%20true%3B%0A%20%20%20%20%20%20%20%20%20%20if%20((n%20-%3D%20used)%20%3D%3D%200)%20break%3B%0A%20%20%20%20%20%20%20%20%20%20at%20%3D%200%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20at%20-%3D%20sz%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%0A%20%20function%20getLineAt(chunk%2C%20n)%20%7B%0A%20%20%20%20while%20(!chunk.lines)%20%7B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%3B%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20child%20%3D%20chunk.children%5Bi%5D%2C%20sz%20%3D%20child.chunkSize()%3B%0A%20%20%20%20%20%20%20%20if%20(n%20%3C%20sz)%20%7B%20chunk%20%3D%20child%3B%20break%3B%20%7D%0A%20%20%20%20%20%20%20%20n%20-%3D%20sz%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20chunk.lines%5Bn%5D%3B%0A%20%20%7D%0A%20%20function%20lineNo(line)%20%7B%0A%20%20%20%20if%20(line.parent%20%3D%3D%20null)%20return%20null%3B%0A%20%20%20%20var%20cur%20%3D%20line.parent%2C%20no%20%3D%20indexOf(cur.lines%2C%20line)%3B%0A%20%20%20%20for%20(var%20chunk%20%3D%20cur.parent%3B%20chunk%3B%20cur%20%3D%20chunk%2C%20chunk%20%3D%20chunk.parent)%20%7B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20chunk.children.length%3B%20%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20if%20(chunk.children%5Bi%5D%20%3D%3D%20cur)%20break%3B%0A%20%20%20%20%20%20%20%20no%20%2B%3D%20chunk.children%5Bi%5D.chunkSize()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20no%3B%0A%20%20%7D%0A%20%20function%20lineAtHeight(chunk%2C%20h)%20%7B%0A%20%20%20%20var%20n%20%3D%200%3B%0A%20%20%20%20outer%3A%20do%20%7B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20chunk.children.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20child%20%3D%20chunk.children%5Bi%5D%2C%20ch%20%3D%20child.height%3B%0A%20%20%20%20%20%20%20%20if%20(h%20%3C%20ch)%20%7B%20chunk%20%3D%20child%3B%20continue%20outer%3B%20%7D%0A%20%20%20%20%20%20%20%20h%20-%3D%20ch%3B%0A%20%20%20%20%20%20%20%20n%20%2B%3D%20child.chunkSize()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20n%3B%0A%20%20%20%20%7D%20while%20(!chunk.lines)%3B%0A%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20chunk.lines.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20var%20line%20%3D%20chunk.lines%5Bi%5D%2C%20lh%20%3D%20line.height%3B%0A%20%20%20%20%20%20if%20(h%20%3C%20lh)%20break%3B%0A%20%20%20%20%20%20h%20-%3D%20lh%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20n%20%2B%20i%3B%0A%20%20%7D%0A%20%20function%20heightAtLine(chunk%2C%20n)%20%7B%0A%20%20%20%20var%20h%20%3D%200%3B%0A%20%20%20%20outer%3A%20do%20%7B%0A%20%20%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20chunk.children.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20%20%20var%20child%20%3D%20chunk.children%5Bi%5D%2C%20sz%20%3D%20child.chunkSize()%3B%0A%20%20%20%20%20%20%20%20if%20(n%20%3C%20sz)%20%7B%20chunk%20%3D%20child%3B%20continue%20outer%3B%20%7D%0A%20%20%20%20%20%20%20%20n%20-%3D%20sz%3B%0A%20%20%20%20%20%20%20%20h%20%2B%3D%20child.height%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20h%3B%0A%20%20%20%20%7D%20while%20(!chunk.lines)%3B%0A%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20n%3B%20%2B%2Bi)%20h%20%2B%3D%20chunk.lines%5Bi%5D.height%3B%0A%20%20%20%20return%20h%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20The%20history%20object%20'chunks'%20changes%20that%20are%20made%20close%20together%0A%20%20%2F%2F%20and%20at%20almost%20the%20same%20time%20into%20bigger%20undoable%20units.%0A%20%20function%20History()%20%7B%0A%20%20%20%20this.time%20%3D%200%3B%0A%20%20%20%20this.done%20%3D%20%5B%5D%3B%20this.undone%20%3D%20%5B%5D%3B%0A%20%20%20%20this.compound%20%3D%200%3B%0A%20%20%20%20this.closed%20%3D%20false%3B%0A%20%20%7D%0A%20%20History.prototype%20%3D%20%7B%0A%20%20%20%20addChange%3A%20function(start%2C%20added%2C%20old)%20%7B%0A%20%20%20%20%20%20this.undone.length%20%3D%200%3B%0A%20%20%20%20%20%20var%20time%20%3D%20%2Bnew%20Date%2C%20cur%20%3D%20lst(this.done)%2C%20last%20%3D%20cur%20%26%26%20lst(cur)%3B%0A%20%20%20%20%20%20var%20dtime%20%3D%20time%20-%20this.time%3B%0A%0A%20%20%20%20%20%20if%20(this.compound%20%26%26%20cur%20%26%26%20!this.closed)%20%7B%0A%20%20%20%20%20%20%20%20cur.push(%7Bstart%3A%20start%2C%20added%3A%20added%2C%20old%3A%20old%7D)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(dtime%20%3E%20400%20%7C%7C%20!last%20%7C%7C%20this.closed%20%7C%7C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20last.start%20%3E%20start%20%2B%20old.length%20%7C%7C%20last.start%20%2B%20last.added%20%3C%20start)%20%7B%0A%20%20%20%20%20%20%20%20this.done.push(%5B%7Bstart%3A%20start%2C%20added%3A%20added%2C%20old%3A%20old%7D%5D)%3B%0A%20%20%20%20%20%20%20%20this.closed%20%3D%20false%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20var%20startBefore%20%3D%20Math.max(0%2C%20last.start%20-%20start)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20endAfter%20%3D%20Math.max(0%2C%20(start%20%2B%20old.length)%20-%20(last.start%20%2B%20last.added))%3B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%20startBefore%3B%20i%20%3E%200%3B%20--i)%20last.old.unshift(old%5Bi%20-%201%5D)%3B%0A%20%20%20%20%20%20%20%20for%20(var%20i%20%3D%20endAfter%3B%20i%20%3E%200%3B%20--i)%20last.old.push(old%5Bold.length%20-%20i%5D)%3B%0A%20%20%20%20%20%20%20%20if%20(startBefore)%20last.start%20%3D%20start%3B%0A%20%20%20%20%20%20%20%20last.added%20%2B%3D%20added%20-%20(old.length%20-%20startBefore%20-%20endAfter)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20this.time%20%3D%20time%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20startCompound%3A%20function()%20%7B%0A%20%20%20%20%20%20if%20(!this.compound%2B%2B)%20this.closed%20%3D%20true%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20endCompound%3A%20function()%20%7B%0A%20%20%20%20%20%20if%20(!--this.compound)%20this.closed%20%3D%20true%3B%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%0A%20%20function%20stopMethod()%20%7Be_stop(this)%3B%7D%0A%20%20%2F%2F%20Ensure%20an%20event%20has%20a%20stop%20method.%0A%20%20function%20addStop(event)%20%7B%0A%20%20%20%20if%20(!event.stop)%20event.stop%20%3D%20stopMethod%3B%0A%20%20%20%20return%20event%3B%0A%20%20%7D%0A%0A%20%20function%20e_preventDefault(e)%20%7B%0A%20%20%20%20if%20(e.preventDefault)%20e.preventDefault()%3B%0A%20%20%20%20else%20e.returnValue%20%3D%20false%3B%0A%20%20%7D%0A%20%20function%20e_stopPropagation(e)%20%7B%0A%20%20%20%20if%20(e.stopPropagation)%20e.stopPropagation()%3B%0A%20%20%20%20else%20e.cancelBubble%20%3D%20true%3B%0A%20%20%7D%0A%20%20function%20e_stop(e)%20%7Be_preventDefault(e)%3B%20e_stopPropagation(e)%3B%7D%0A%20%20CodeMirror.e_stop%20%3D%20e_stop%3B%0A%20%20CodeMirror.e_preventDefault%20%3D%20e_preventDefault%3B%0A%20%20CodeMirror.e_stopPropagation%20%3D%20e_stopPropagation%3B%0A%0A%20%20function%20e_target(e)%20%7Breturn%20e.target%20%7C%7C%20e.srcElement%3B%7D%0A%20%20function%20e_button(e)%20%7B%0A%20%20%20%20var%20b%20%3D%20e.which%3B%0A%20%20%20%20if%20(b%20%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20if%20(e.button%20%26%201)%20b%20%3D%201%3B%0A%20%20%20%20%20%20else%20if%20(e.button%20%26%202)%20b%20%3D%203%3B%0A%20%20%20%20%20%20else%20if%20(e.button%20%26%204)%20b%20%3D%202%3B%0A%20%20%20%20%7D%0A%20%20%20%20if%20(mac%20%26%26%20e.ctrlKey%20%26%26%20b%20%3D%3D%201)%20b%20%3D%203%3B%0A%20%20%20%20return%20b%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20Allow%203rd-party%20code%20to%20override%20event%20properties%20by%20adding%20an%20override%0A%20%20%2F%2F%20object%20to%20an%20event%20object.%0A%20%20function%20e_prop(e%2C%20prop)%20%7B%0A%20%20%20%20var%20overridden%20%3D%20e.override%20%26%26%20e.override.hasOwnProperty(prop)%3B%0A%20%20%20%20return%20overridden%20%3F%20e.override%5Bprop%5D%20%3A%20e%5Bprop%5D%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20Event%20handler%20registration.%20If%20disconnect%20is%20true%2C%20it'll%20return%20a%0A%20%20%2F%2F%20function%20that%20unregisters%20the%20handler.%0A%20%20function%20connect(node%2C%20type%2C%20handler%2C%20disconnect)%20%7B%0A%20%20%20%20if%20(typeof%20node.addEventListener%20%3D%3D%20%22function%22)%20%7B%0A%20%20%20%20%20%20node.addEventListener(type%2C%20handler%2C%20false)%3B%0A%20%20%20%20%20%20if%20(disconnect)%20return%20function()%20%7Bnode.removeEventListener(type%2C%20handler%2C%20false)%3B%7D%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20var%20wrapHandler%20%3D%20function(event)%20%7Bhandler(event%20%7C%7C%20window.event)%3B%7D%3B%0A%20%20%20%20%20%20node.attachEvent(%22on%22%20%2B%20type%2C%20wrapHandler)%3B%0A%20%20%20%20%20%20if%20(disconnect)%20return%20function()%20%7Bnode.detachEvent(%22on%22%20%2B%20type%2C%20wrapHandler)%3B%7D%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20CodeMirror.connect%20%3D%20connect%3B%0A%0A%20%20function%20Delayed()%20%7Bthis.id%20%3D%20null%3B%7D%0A%20%20Delayed.prototype%20%3D%20%7Bset%3A%20function(ms%2C%20f)%20%7BclearTimeout(this.id)%3B%20this.id%20%3D%20setTimeout(f%2C%20ms)%3B%7D%7D%3B%0A%0A%20%20var%20Pass%20%3D%20CodeMirror.Pass%20%3D%20%7BtoString%3A%20function()%7Breturn%20%22CodeMirror.Pass%22%3B%7D%7D%3B%0A%0A%20%20%2F%2F%20Detect%20drag-and-drop%0A%20%20var%20dragAndDrop%20%3D%20function()%20%7B%0A%20%20%20%20%2F%2F%20There%20is%20*some*%20kind%20of%20drag-and-drop%20support%20in%20IE6-8%2C%20but%20I%0A%20%20%20%20%2F%2F%20couldn't%20get%20it%20to%20work%20yet.%0A%20%20%20%20if%20(ie_lt9)%20return%20false%3B%0A%20%20%20%20var%20div%20%3D%20elt('div')%3B%0A%20%20%20%20return%20%22draggable%22%20in%20div%20%7C%7C%20%22dragDrop%22%20in%20div%3B%0A%20%20%7D()%3B%0A%0A%20%20%2F%2F%20Feature-detect%20whether%20newlines%20in%20textareas%20are%20converted%20to%20%5Cr%5Cn%0A%20%20var%20lineSep%20%3D%20function%20()%20%7B%0A%20%20%20%20var%20te%20%3D%20elt(%22textarea%22)%3B%0A%20%20%20%20te.value%20%3D%20%22foo%5Cnbar%22%3B%0A%20%20%20%20if%20(te.value.indexOf(%22%5Cr%22)%20%3E%20-1)%20return%20%22%5Cr%5Cn%22%3B%0A%20%20%20%20return%20%22%5Cn%22%3B%0A%20%20%7D()%3B%0A%0A%20%20%2F%2F%20For%20a%20reason%20I%20have%20yet%20to%20figure%20out%2C%20some%20browsers%20disallow%0A%20%20%2F%2F%20word%20wrapping%20between%20certain%20characters%20*only*%20if%20a%20new%20inline%0A%20%20%2F%2F%20element%20is%20started%20between%20them.%20This%20makes%20it%20hard%20to%20reliably%0A%20%20%2F%2F%20measure%20the%20position%20of%20things%2C%20since%20that%20requires%20inserting%20an%0A%20%20%2F%2F%20extra%20span.%20This%20terribly%20fragile%20set%20of%20regexps%20matches%20the%0A%20%20%2F%2F%20character%20combinations%20that%20suffer%20from%20this%20phenomenon%20on%20the%0A%20%20%2F%2F%20various%20browsers.%0A%20%20var%20spanAffectsWrapping%20%3D%20%2F%5E%24%2F%3B%20%2F%2F%20Won't%20match%20any%20two-character%20string%0A%20%20if%20(gecko)%20spanAffectsWrapping%20%3D%20%2F%24'%2F%3B%0A%20%20else%20if%20(safari)%20spanAffectsWrapping%20%3D%20%2F%5C-%5B%5E%20%5C-%3F%5D%7C%5C%3F%5B%5E%20!'%5C%22%5C)%2C.%5C-%5C%2F%3A%3B%5C%3F%5C%5D%5C%7D%5D%2F%3B%0A%20%20else%20if%20(chrome)%20spanAffectsWrapping%20%3D%20%2F%5C-%5B%5E%20%5C-%5C.%3F%5D%7C%5C%3F%5B%5E%20%5C-%5C.%3F%5C%5D%5C%7D%3A%3B!'%5C%22%5C)%2C%5C%2F%5D%7C%5B%5C.!%5C%22%23%26%25%5C)*%2B%2C%3A%3B%3D%3E%5C%5D%7C%5C%7D~%5D%5B%5C(%5C%7B%5C%5B%3C%5D%7C%5C%24'%2F%3B%0A%0A%20%20%2F%2F%20Counts%20the%20column%20offset%20in%20a%20string%2C%20taking%20tabs%20into%20account.%0A%20%20%2F%2F%20Used%20mostly%20to%20find%20indentation.%0A%20%20function%20countColumn(string%2C%20end%2C%20tabSize)%20%7B%0A%20%20%20%20if%20(end%20%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20end%20%3D%20string.search(%2F%5B%5E%5Cs%5Cu00a0%5D%2F)%3B%0A%20%20%20%20%20%20if%20(end%20%3D%3D%20-1)%20end%20%3D%20string.length%3B%0A%20%20%20%20%7D%0A%20%20%20%20for%20(var%20i%20%3D%200%2C%20n%20%3D%200%3B%20i%20%3C%20end%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20%20%20if%20(string.charAt(i)%20%3D%3D%20%22%5Ct%22)%20n%20%2B%3D%20tabSize%20-%20(n%20%25%20tabSize)%3B%0A%20%20%20%20%20%20else%20%2B%2Bn%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20n%3B%0A%20%20%7D%0A%0A%20%20function%20eltOffset(node%2C%20screen)%20%7B%0A%20%20%20%20%2F%2F%20Take%20the%20parts%20of%20bounding%20client%20rect%20that%20we%20are%20interested%20in%20so%20we%20are%20able%20to%20edit%20if%20need%20be%2C%0A%20%20%20%20%2F%2F%20since%20the%20returned%20value%20cannot%20be%20changed%20externally%20(they%20are%20kept%20in%20sync%20as%20the%20element%20moves%20within%20the%20page)%0A%20%20%20%20try%20%7B%20var%20box%20%3D%20node.getBoundingClientRect()%3B%20box%20%3D%20%7B%20top%3A%20box.top%2C%20left%3A%20box.left%20%7D%3B%20%7D%0A%20%20%20%20catch(e)%20%7B%20box%20%3D%20%7Btop%3A%200%2C%20left%3A%200%7D%3B%20%7D%0A%20%20%20%20if%20(!screen)%20%7B%0A%20%20%20%20%20%20%2F%2F%20Get%20the%20toplevel%20scroll%2C%20working%20around%20browser%20differences.%0A%20%20%20%20%20%20if%20(window.pageYOffset%20%3D%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20var%20t%20%3D%20document.documentElement%20%7C%7C%20document.body.parentNode%3B%0A%20%20%20%20%20%20%20%20if%20(t.scrollTop%20%3D%3D%20null)%20t%20%3D%20document.body%3B%0A%20%20%20%20%20%20%20%20box.top%20%2B%3D%20t.scrollTop%3B%20box.left%20%2B%3D%20t.scrollLeft%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20box.top%20%2B%3D%20window.pageYOffset%3B%20box.left%20%2B%3D%20window.pageXOffset%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20box%3B%0A%20%20%7D%0A%0A%20%20function%20eltText(node)%20%7B%0A%20%20%20%20return%20node.textContent%20%7C%7C%20node.innerText%20%7C%7C%20node.nodeValue%20%7C%7C%20%22%22%3B%0A%20%20%7D%0A%0A%20%20var%20spaceStrs%20%3D%20%5B%22%22%5D%3B%0A%20%20function%20spaceStr(n)%20%7B%0A%20%20%20%20while%20(spaceStrs.length%20%3C%3D%20n)%0A%20%20%20%20%20%20spaceStrs.push(lst(spaceStrs)%20%2B%20%22%20%22)%3B%0A%20%20%20%20return%20spaceStrs%5Bn%5D%3B%0A%20%20%7D%0A%0A%20%20function%20lst(arr)%20%7B%20return%20arr%5Barr.length-1%5D%3B%20%7D%0A%0A%20%20function%20selectInput(node)%20%7B%0A%20%20%20%20if%20(ios)%20%7B%20%2F%2F%20Mobile%20Safari%20apparently%20has%20a%20bug%20where%20select()%20is%20broken.%0A%20%20%20%20%20%20node.selectionStart%20%3D%200%3B%0A%20%20%20%20%20%20node.selectionEnd%20%3D%20node.value.length%3B%0A%20%20%20%20%7D%20else%20node.select()%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20Operations%20on%20%7Bline%2C%20ch%7D%20objects.%0A%20%20function%20posEq(a%2C%20b)%20%7Breturn%20a.line%20%3D%3D%20b.line%20%26%26%20a.ch%20%3D%3D%20b.ch%3B%7D%0A%20%20function%20posLess(a%2C%20b)%20%7Breturn%20a.line%20%3C%20b.line%20%7C%7C%20(a.line%20%3D%3D%20b.line%20%26%26%20a.ch%20%3C%20b.ch)%3B%7D%0A%20%20function%20copyPos(x)%20%7Breturn%20%7Bline%3A%20x.line%2C%20ch%3A%20x.ch%7D%3B%7D%0A%0A%20%20function%20elt(tag%2C%20content%2C%20className%2C%20style)%20%7B%0A%20%20%20%20var%20e%20%3D%20document.createElement(tag)%3B%0A%20%20%20%20if%20(className)%20e.className%20%3D%20className%3B%0A%20%20%20%20if%20(style)%20e.style.cssText%20%3D%20style%3B%0A%20%20%20%20if%20(typeof%20content%20%3D%3D%20%22string%22)%20setTextContent(e%2C%20content)%3B%0A%20%20%20%20else%20if%20(content)%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20content.length%3B%20%2B%2Bi)%20e.appendChild(content%5Bi%5D)%3B%0A%20%20%20%20return%20e%3B%0A%20%20%7D%0A%20%20function%20removeChildren(e)%20%7B%0A%20%20%20%20e.innerHTML%20%3D%20%22%22%3B%0A%20%20%20%20return%20e%3B%0A%20%20%7D%0A%20%20function%20removeChildrenAndAdd(parent%2C%20e)%20%7B%0A%20%20%20%20removeChildren(parent).appendChild(e)%3B%0A%20%20%7D%0A%20%20function%20setTextContent(e%2C%20str)%20%7B%0A%20%20%20%20if%20(ie_lt9)%20%7B%0A%20%20%20%20%20%20e.innerHTML%20%3D%20%22%22%3B%0A%20%20%20%20%20%20e.appendChild(document.createTextNode(str))%3B%0A%20%20%20%20%7D%20else%20e.textContent%20%3D%20str%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20Used%20to%20position%20the%20cursor%20after%20an%20undo%2Fredo%20by%20finding%20the%0A%20%20%2F%2F%20last%20edited%20character.%0A%20%20function%20editEnd(from%2C%20to)%20%7B%0A%20%20%20%20if%20(!to)%20return%200%3B%0A%20%20%20%20if%20(!from)%20return%20to.length%3B%0A%20%20%20%20for%20(var%20i%20%3D%20from.length%2C%20j%20%3D%20to.length%3B%20i%20%3E%3D%200%20%26%26%20j%20%3E%3D%200%3B%20--i%2C%20--j)%0A%20%20%20%20%20%20if%20(from.charAt(i)%20!%3D%20to.charAt(j))%20break%3B%0A%20%20%20%20return%20j%20%2B%201%3B%0A%20%20%7D%0A%0A%20%20function%20indexOf(collection%2C%20elt)%20%7B%0A%20%20%20%20if%20(collection.indexOf)%20return%20collection.indexOf(elt)%3B%0A%20%20%20%20for%20(var%20i%20%3D%200%2C%20e%20%3D%20collection.length%3B%20i%20%3C%20e%3B%20%2B%2Bi)%0A%20%20%20%20%20%20if%20(collection%5Bi%5D%20%3D%3D%20elt)%20return%20i%3B%0A%20%20%20%20return%20-1%3B%0A%20%20%7D%0A%20%20function%20isWordChar(ch)%20%7B%0A%20%20%20%20return%20%2F%5Cw%2F.test(ch)%20%7C%7C%20ch.toUpperCase()%20!%3D%20ch.toLowerCase()%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20See%20if%20%22%22.split%20is%20the%20broken%20IE%20version%2C%20if%20so%2C%20provide%20an%0A%20%20%2F%2F%20alternative%20way%20to%20split%20lines.%0A%20%20var%20splitLines%20%3D%20%22%5Cn%5Cnb%22.split(%2F%5Cn%2F).length%20!%3D%203%20%3F%20function(string)%20%7B%0A%20%20%20%20var%20pos%20%3D%200%2C%20result%20%3D%20%5B%5D%2C%20l%20%3D%20string.length%3B%0A%20%20%20%20while%20(pos%20%3C%3D%20l)%20%7B%0A%20%20%20%20%20%20var%20nl%20%3D%20string.indexOf(%22%5Cn%22%2C%20pos)%3B%0A%20%20%20%20%20%20if%20(nl%20%3D%3D%20-1)%20nl%20%3D%20string.length%3B%0A%20%20%20%20%20%20var%20line%20%3D%20string.slice(pos%2C%20string.charAt(nl%20-%201)%20%3D%3D%20%22%5Cr%22%20%3F%20nl%20-%201%20%3A%20nl)%3B%0A%20%20%20%20%20%20var%20rt%20%3D%20line.indexOf(%22%5Cr%22)%3B%0A%20%20%20%20%20%20if%20(rt%20!%3D%20-1)%20%7B%0A%20%20%20%20%20%20%20%20result.push(line.slice(0%2C%20rt))%3B%0A%20%20%20%20%20%20%20%20pos%20%2B%3D%20rt%20%2B%201%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20result.push(line)%3B%0A%20%20%20%20%20%20%20%20pos%20%3D%20nl%20%2B%201%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20result%3B%0A%20%20%7D%20%3A%20function(string)%7Breturn%20string.split(%2F%5Cr%5Cn%3F%7C%5Cn%2F)%3B%7D%3B%0A%20%20CodeMirror.splitLines%20%3D%20splitLines%3B%0A%0A%20%20var%20hasSelection%20%3D%20window.getSelection%20%3F%20function(te)%20%7B%0A%20%20%20%20try%20%7B%20return%20te.selectionStart%20!%3D%20te.selectionEnd%3B%20%7D%0A%20%20%20%20catch(e)%20%7B%20return%20false%3B%20%7D%0A%20%20%7D%20%3A%20function(te)%20%7B%0A%20%20%20%20try%20%7Bvar%20range%20%3D%20te.ownerDocument.selection.createRange()%3B%7D%0A%20%20%20%20catch(e)%20%7B%7D%0A%20%20%20%20if%20(!range%20%7C%7C%20range.parentElement()%20!%3D%20te)%20return%20false%3B%0A%20%20%20%20return%20range.compareEndPoints(%22StartToEnd%22%2C%20range)%20!%3D%200%3B%0A%20%20%7D%3B%0A%0A%20%20CodeMirror.defineMode(%22null%22%2C%20function()%20%7B%0A%20%20%20%20return%20%7Btoken%3A%20function(stream)%20%7Bstream.skipToEnd()%3B%7D%7D%3B%0A%20%20%7D)%3B%0A%20%20CodeMirror.defineMIME(%22text%2Fplain%22%2C%20%22null%22)%3B%0A%0A%20%20var%20keyNames%20%3D%20%7B3%3A%20%22Enter%22%2C%208%3A%20%22Backspace%22%2C%209%3A%20%22Tab%22%2C%2013%3A%20%22Enter%22%2C%2016%3A%20%22Shift%22%2C%2017%3A%20%22Ctrl%22%2C%2018%3A%20%22Alt%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2019%3A%20%22Pause%22%2C%2020%3A%20%22CapsLock%22%2C%2027%3A%20%22Esc%22%2C%2032%3A%20%22Space%22%2C%2033%3A%20%22PageUp%22%2C%2034%3A%20%22PageDown%22%2C%2035%3A%20%22End%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2036%3A%20%22Home%22%2C%2037%3A%20%22Left%22%2C%2038%3A%20%22Up%22%2C%2039%3A%20%22Right%22%2C%2040%3A%20%22Down%22%2C%2044%3A%20%22PrintScrn%22%2C%2045%3A%20%22Insert%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2046%3A%20%22Delete%22%2C%2059%3A%20%22%3B%22%2C%2091%3A%20%22Mod%22%2C%2092%3A%20%22Mod%22%2C%2093%3A%20%22Mod%22%2C%20109%3A%20%22-%22%2C%20107%3A%20%22%3D%22%2C%20127%3A%20%22Delete%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20186%3A%20%22%3B%22%2C%20187%3A%20%22%3D%22%2C%20188%3A%20%22%2C%22%2C%20189%3A%20%22-%22%2C%20190%3A%20%22.%22%2C%20191%3A%20%22%2F%22%2C%20192%3A%20%22%60%22%2C%20219%3A%20%22%5B%22%2C%20220%3A%20%22%5C%5C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20221%3A%20%22%5D%22%2C%20222%3A%20%22'%22%2C%2063276%3A%20%22PageUp%22%2C%2063277%3A%20%22PageDown%22%2C%2063275%3A%20%22End%22%2C%2063273%3A%20%22Home%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2063234%3A%20%22Left%22%2C%2063232%3A%20%22Up%22%2C%2063235%3A%20%22Right%22%2C%2063233%3A%20%22Down%22%2C%2063302%3A%20%22Insert%22%2C%2063272%3A%20%22Delete%22%7D%3B%0A%20%20CodeMirror.keyNames%20%3D%20keyNames%3B%0A%20%20(function()%20%7B%0A%20%20%20%20%2F%2F%20Number%20keys%0A%20%20%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%2010%3B%20i%2B%2B)%20keyNames%5Bi%20%2B%2048%5D%20%3D%20String(i)%3B%0A%20%20%20%20%2F%2F%20Alphabetic%20keys%0A%20%20%20%20for%20(var%20i%20%3D%2065%3B%20i%20%3C%3D%2090%3B%20i%2B%2B)%20keyNames%5Bi%5D%20%3D%20String.fromCharCode(i)%3B%0A%20%20%20%20%2F%2F%20Function%20keys%0A%20%20%20%20for%20(var%20i%20%3D%201%3B%20i%20%3C%3D%2012%3B%20i%2B%2B)%20keyNames%5Bi%20%2B%20111%5D%20%3D%20keyNames%5Bi%20%2B%2063235%5D%20%3D%20%22F%22%20%2B%20i%3B%0A%20%20%7D)()%3B%0A%0A%20%20CodeMirror.version%20%3D%20%222.34%22%3B%0A%0A%20%20return%20CodeMirror%3B%0A%7D)()%3B%0A%0A%20%20%20%20%3C%2Fscript%3E%0A%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%3C!--%20http%3A%2F%2Fcodemirror.net%2Flib%2Fcodemirror.css%20--%3E%3Cstyle%3E%0A.CodeMirror%20%7B%0A%20%20line-height%3A%201em%3B%0A%20%20font-family%3A%20monospace%3B%0A%0A%20%20%2F*%20Necessary%20so%20the%20scrollbar%20can%20be%20absolutely%20positioned%20within%20the%20wrapper%20on%20Lion.%20*%2F%0A%20%20position%3A%20relative%3B%0A%20%20%2F*%20This%20prevents%20unwanted%20scrollbars%20from%20showing%20up%20on%20the%20body%20and%20wrapper%20in%20IE.%20*%2F%0A%20%20overflow%3A%20hidden%3B%0A%7D%0A%0A.CodeMirror-scroll%20%7B%0A%20%20overflow%3A%20auto%3B%0A%20%20height%3A%20300px%3B%0A%20%20%2F*%20This%20is%20needed%20to%20prevent%20an%20IE%5B67%5D%20bug%20where%20the%20scrolled%20content%0A%20%20%20%20%20is%20visible%20outside%20of%20the%20scrolling%20box.%20*%2F%0A%20%20position%3A%20relative%3B%0A%20%20outline%3A%20none%3B%0A%7D%0A%0A%2F*%20Vertical%20scrollbar%20*%2F%0A.CodeMirror-scrollbar%20%7B%0A%20%20position%3A%20absolute%3B%0A%20%20right%3A%200%3B%20top%3A%200%3B%0A%20%20overflow-x%3A%20hidden%3B%0A%20%20overflow-y%3A%20scroll%3B%0A%20%20z-index%3A%205%3B%0A%7D%0A.CodeMirror-scrollbar-inner%20%7B%0A%20%20%2F*%20This%20needs%20to%20have%20a%20nonzero%20width%20in%20order%20for%20the%20scrollbar%20to%20appear%0A%20%20%20%20%20in%20Firefox%20and%20IE9.%20*%2F%0A%20%20width%3A%201px%3B%0A%7D%0A.CodeMirror-scrollbar.cm-sb-overlap%20%7B%0A%20%20%2F*%20Ensure%20that%20the%20scrollbar%20appears%20in%20Lion%2C%20and%20that%20it%20overlaps%20the%20content%0A%20%20%20%20%20rather%20than%20sitting%20to%20the%20right%20of%20it.%20*%2F%0A%20%20position%3A%20absolute%3B%0A%20%20z-index%3A%201%3B%0A%20%20float%3A%20none%3B%0A%20%20right%3A%200%3B%0A%20%20min-width%3A%2012px%3B%0A%7D%0A.CodeMirror-scrollbar.cm-sb-nonoverlap%20%7B%0A%20%20min-width%3A%2012px%3B%0A%7D%0A.CodeMirror-scrollbar.cm-sb-ie7%20%7B%0A%20%20min-width%3A%2018px%3B%0A%7D%0A%0A.CodeMirror-gutter%20%7B%0A%20%20position%3A%20absolute%3B%20left%3A%200%3B%20top%3A%200%3B%0A%20%20z-index%3A%2010%3B%0A%20%20background-color%3A%20%23f7f7f7%3B%0A%20%20border-right%3A%201px%20solid%20%23eee%3B%0A%20%20min-width%3A%202em%3B%0A%20%20height%3A%20100%25%3B%0A%7D%0A.CodeMirror-gutter-text%20%7B%0A%20%20color%3A%20%23aaa%3B%0A%20%20text-align%3A%20right%3B%0A%20%20padding%3A%20.4em%20.2em%20.4em%20.4em%3B%0A%20%20white-space%3A%20pre%20!important%3B%0A%20%20cursor%3A%20default%3B%0A%7D%0A.CodeMirror-lines%20%7B%0A%20%20padding%3A%20.4em%3B%0A%20%20white-space%3A%20pre%3B%0A%20%20cursor%3A%20text%3B%0A%7D%0A%0A.CodeMirror%20pre%20%7B%0A%20%20-moz-border-radius%3A%200%3B%0A%20%20-webkit-border-radius%3A%200%3B%0A%20%20-o-border-radius%3A%200%3B%0A%20%20border-radius%3A%200%3B%0A%20%20border-width%3A%200%3B%20margin%3A%200%3B%20padding%3A%200%3B%20background%3A%20transparent%3B%0A%20%20font-family%3A%20inherit%3B%0A%20%20font-size%3A%20inherit%3B%0A%20%20padding%3A%200%3B%20margin%3A%200%3B%0A%20%20white-space%3A%20pre%3B%0A%20%20word-wrap%3A%20normal%3B%0A%20%20line-height%3A%20inherit%3B%0A%20%20color%3A%20inherit%3B%0A%7D%0A%0A.CodeMirror-wrap%20pre%20%7B%0A%20%20word-wrap%3A%20break-word%3B%0A%20%20white-space%3A%20pre-wrap%3B%0A%20%20word-break%3A%20normal%3B%0A%7D%0A.CodeMirror-wrap%20.CodeMirror-scroll%20%7B%0A%20%20overflow-x%3A%20hidden%3B%0A%7D%0A%0A.CodeMirror%20textarea%20%7B%0A%20%20outline%3A%20none%20!important%3B%0A%7D%0A%0A.CodeMirror%20pre.CodeMirror-cursor%20%7B%0A%20%20z-index%3A%2010%3B%0A%20%20position%3A%20absolute%3B%0A%20%20visibility%3A%20hidden%3B%0A%20%20border-left%3A%201px%20solid%20black%3B%0A%20%20border-right%3A%20none%3B%0A%20%20width%3A%200%3B%0A%7D%0A.cm-keymap-fat-cursor%20pre.CodeMirror-cursor%20%7B%0A%20%20width%3A%20auto%3B%0A%20%20border%3A%200%3B%0A%20%20background%3A%20transparent%3B%0A%20%20background%3A%20rgba(0%2C%20200%2C%200%2C%20.4)%3B%0A%20%20filter%3A%20progid%3ADXImageTransform.Microsoft.gradient(startColorstr%3D%236600c800%2C%20endColorstr%3D%234c00c800)%3B%0A%7D%0A%2F*%20Kludge%20to%20turn%20off%20filter%20in%20ie9%2B%2C%20which%20also%20accepts%20rgba%20*%2F%0A.cm-keymap-fat-cursor%20pre.CodeMirror-cursor%3Anot(%23nonsense_id)%20%7B%0A%20%20filter%3A%20progid%3ADXImageTransform.Microsoft.gradient(enabled%3Dfalse)%3B%0A%7D%0A.CodeMirror%20pre.CodeMirror-cursor.CodeMirror-overwrite%20%7B%7D%0A.CodeMirror-focused%20pre.CodeMirror-cursor%20%7B%0A%20%20visibility%3A%20visible%3B%0A%7D%0A%0Adiv.CodeMirror-selected%20%7B%20background%3A%20%23d9d9d9%3B%20%7D%0A.CodeMirror-focused%20div.CodeMirror-selected%20%7B%20background%3A%20%23d7d4f0%3B%20%7D%0A%0A.CodeMirror-searching%20%7B%0A%20%20background%3A%20%23ffa%3B%0A%20%20background%3A%20rgba(255%2C%20255%2C%200%2C%20.4)%3B%0A%7D%0A%0A%2F*%20Default%20theme%20*%2F%0A%0A.cm-s-default%20span.cm-keyword%20%7Bcolor%3A%20%23708%3B%7D%0A.cm-s-default%20span.cm-atom%20%7Bcolor%3A%20%23219%3B%7D%0A.cm-s-default%20span.cm-number%20%7Bcolor%3A%20%23164%3B%7D%0A.cm-s-default%20span.cm-def%20%7Bcolor%3A%20%2300f%3B%7D%0A.cm-s-default%20span.cm-variable%20%7Bcolor%3A%20black%3B%7D%0A.cm-s-default%20span.cm-variable-2%20%7Bcolor%3A%20%2305a%3B%7D%0A.cm-s-default%20span.cm-variable-3%20%7Bcolor%3A%20%23085%3B%7D%0A.cm-s-default%20span.cm-property%20%7Bcolor%3A%20black%3B%7D%0A.cm-s-default%20span.cm-operator%20%7Bcolor%3A%20black%3B%7D%0A.cm-s-default%20span.cm-comment%20%7Bcolor%3A%20%23a50%3B%7D%0A.cm-s-default%20span.cm-string%20%7Bcolor%3A%20%23a11%3B%7D%0A.cm-s-default%20span.cm-string-2%20%7Bcolor%3A%20%23f50%3B%7D%0A.cm-s-default%20span.cm-meta%20%7Bcolor%3A%20%23555%3B%7D%0A.cm-s-default%20span.cm-error%20%7Bcolor%3A%20%23f00%3B%7D%0A.cm-s-default%20span.cm-qualifier%20%7Bcolor%3A%20%23555%3B%7D%0A.cm-s-default%20span.cm-builtin%20%7Bcolor%3A%20%2330a%3B%7D%0A.cm-s-default%20span.cm-bracket%20%7Bcolor%3A%20%23997%3B%7D%0A.cm-s-default%20span.cm-tag%20%7Bcolor%3A%20%23170%3B%7D%0A.cm-s-default%20span.cm-attribute%20%7Bcolor%3A%20%2300c%3B%7D%0A.cm-s-default%20span.cm-header%20%7Bcolor%3A%20blue%3B%7D%0A.cm-s-default%20span.cm-quote%20%7Bcolor%3A%20%23090%3B%7D%0A.cm-s-default%20span.cm-hr%20%7Bcolor%3A%20%23999%3B%7D%0A.cm-s-default%20span.cm-link%20%7Bcolor%3A%20%2300c%3B%7D%0A%0Aspan.cm-header%2C%20span.cm-strong%20%7Bfont-weight%3A%20bold%3B%7D%0Aspan.cm-em%20%7Bfont-style%3A%20italic%3B%7D%0Aspan.cm-emstrong%20%7Bfont-style%3A%20italic%3B%20font-weight%3A%20bold%3B%7D%0Aspan.cm-link%20%7Btext-decoration%3A%20underline%3B%7D%0A%0Aspan.cm-invalidchar%20%7Bcolor%3A%20%23f00%3B%7D%0A%0Adiv.CodeMirror%20span.CodeMirror-matchingbracket%20%7Bcolor%3A%20%230f0%3B%7D%0Adiv.CodeMirror%20span.CodeMirror-nonmatchingbracket%20%7Bcolor%3A%20%23f22%3B%7D%0A%0A%40media%20print%20%7B%0A%0A%20%20%2F*%20Hide%20the%20cursor%20when%20printing%20*%2F%0A%20%20.CodeMirror%20pre.CodeMirror-cursor%20%7B%0A%20%20%20%20visibility%3A%20hidden%3B%0A%20%20%7D%0A%0A%7D%0A%20%20%20%20%20%3C%2Fstyle%3E%20%0A%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%3C!--%20%20http%3A%2F%2Fcodemirror.net%2Fmode%2Fxml%2Fxml.js%20--%3E%3Cscript%3E%0ACodeMirror.defineMode(%22xml%22%2C%20function(config%2C%20parserConfig)%20%7B%0A%20%20var%20indentUnit%20%3D%20config.indentUnit%3B%0A%20%20var%20Kludges%20%3D%20parserConfig.htmlMode%20%3F%20%7B%0A%20%20%20%20autoSelfClosers%3A%20%7B'area'%3A%20true%2C%20'base'%3A%20true%2C%20'br'%3A%20true%2C%20'col'%3A%20true%2C%20'command'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20'embed'%3A%20true%2C%20'frame'%3A%20true%2C%20'hr'%3A%20true%2C%20'img'%3A%20true%2C%20'input'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20'keygen'%3A%20true%2C%20'link'%3A%20true%2C%20'meta'%3A%20true%2C%20'param'%3A%20true%2C%20'source'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20'track'%3A%20true%2C%20'wbr'%3A%20true%7D%2C%0A%20%20%20%20implicitlyClosed%3A%20%7B'dd'%3A%20true%2C%20'li'%3A%20true%2C%20'optgroup'%3A%20true%2C%20'option'%3A%20true%2C%20'p'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20'rp'%3A%20true%2C%20'rt'%3A%20true%2C%20'tbody'%3A%20true%2C%20'td'%3A%20true%2C%20'tfoot'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20'th'%3A%20true%2C%20'tr'%3A%20true%7D%2C%0A%20%20%20%20contextGrabbers%3A%20%7B%0A%20%20%20%20%20%20'dd'%3A%20%7B'dd'%3A%20true%2C%20'dt'%3A%20true%7D%2C%0A%20%20%20%20%20%20'dt'%3A%20%7B'dd'%3A%20true%2C%20'dt'%3A%20true%7D%2C%0A%20%20%20%20%20%20'li'%3A%20%7B'li'%3A%20true%7D%2C%0A%20%20%20%20%20%20'option'%3A%20%7B'option'%3A%20true%2C%20'optgroup'%3A%20true%7D%2C%0A%20%20%20%20%20%20'optgroup'%3A%20%7B'optgroup'%3A%20true%7D%2C%0A%20%20%20%20%20%20'p'%3A%20%7B'address'%3A%20true%2C%20'article'%3A%20true%2C%20'aside'%3A%20true%2C%20'blockquote'%3A%20true%2C%20'dir'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20'div'%3A%20true%2C%20'dl'%3A%20true%2C%20'fieldset'%3A%20true%2C%20'footer'%3A%20true%2C%20'form'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20'h1'%3A%20true%2C%20'h2'%3A%20true%2C%20'h3'%3A%20true%2C%20'h4'%3A%20true%2C%20'h5'%3A%20true%2C%20'h6'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20'header'%3A%20true%2C%20'hgroup'%3A%20true%2C%20'hr'%3A%20true%2C%20'menu'%3A%20true%2C%20'nav'%3A%20true%2C%20'ol'%3A%20true%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20'p'%3A%20true%2C%20'pre'%3A%20true%2C%20'section'%3A%20true%2C%20'table'%3A%20true%2C%20'ul'%3A%20true%7D%2C%0A%20%20%20%20%20%20'rp'%3A%20%7B'rp'%3A%20true%2C%20'rt'%3A%20true%7D%2C%0A%20%20%20%20%20%20'rt'%3A%20%7B'rp'%3A%20true%2C%20'rt'%3A%20true%7D%2C%0A%20%20%20%20%20%20'tbody'%3A%20%7B'tbody'%3A%20true%2C%20'tfoot'%3A%20true%7D%2C%0A%20%20%20%20%20%20'td'%3A%20%7B'td'%3A%20true%2C%20'th'%3A%20true%7D%2C%0A%20%20%20%20%20%20'tfoot'%3A%20%7B'tbody'%3A%20true%7D%2C%0A%20%20%20%20%20%20'th'%3A%20%7B'td'%3A%20true%2C%20'th'%3A%20true%7D%2C%0A%20%20%20%20%20%20'thead'%3A%20%7B'tbody'%3A%20true%2C%20'tfoot'%3A%20true%7D%2C%0A%20%20%20%20%20%20'tr'%3A%20%7B'tr'%3A%20true%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20doNotIndent%3A%20%7B%22pre%22%3A%20true%7D%2C%0A%20%20%20%20allowUnquoted%3A%20true%2C%0A%20%20%20%20allowMissing%3A%20true%0A%20%20%7D%20%3A%20%7B%0A%20%20%20%20autoSelfClosers%3A%20%7B%7D%2C%0A%20%20%20%20implicitlyClosed%3A%20%7B%7D%2C%0A%20%20%20%20contextGrabbers%3A%20%7B%7D%2C%0A%20%20%20%20doNotIndent%3A%20%7B%7D%2C%0A%20%20%20%20allowUnquoted%3A%20false%2C%0A%20%20%20%20allowMissing%3A%20false%0A%20%20%7D%3B%0A%20%20var%20alignCDATA%20%3D%20parserConfig.alignCDATA%3B%0A%0A%20%20%2F%2F%20Return%20variables%20for%20tokenizers%0A%20%20var%20tagName%2C%20type%3B%0A%0A%20%20function%20inText(stream%2C%20state)%20%7B%0A%20%20%20%20function%20chain(parser)%20%7B%0A%20%20%20%20%20%20state.tokenize%20%3D%20parser%3B%0A%20%20%20%20%20%20return%20parser(stream%2C%20state)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20var%20ch%20%3D%20stream.next()%3B%0A%20%20%20%20if%20(ch%20%3D%3D%20%22%3C%22)%20%7B%0A%20%20%20%20%20%20if%20(stream.eat(%22!%22))%20%7B%0A%20%20%20%20%20%20%20%20if%20(stream.eat(%22%5B%22))%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(stream.match(%22CDATA%5B%22))%20return%20chain(inBlock(%22atom%22%2C%20%22%5D%5D%3E%22))%3B%0A%20%20%20%20%20%20%20%20%20%20else%20return%20null%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20if%20(stream.match(%22--%22))%20return%20chain(inBlock(%22comment%22%2C%20%22--%3E%22))%3B%0A%20%20%20%20%20%20%20%20else%20if%20(stream.match(%22DOCTYPE%22%2C%20true%2C%20true))%20%7B%0A%20%20%20%20%20%20%20%20%20%20stream.eatWhile(%2F%5B%5Cw%5C._%5C-%5D%2F)%3B%0A%20%20%20%20%20%20%20%20%20%20return%20chain(doctype(1))%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20return%20null%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20if%20(stream.eat(%22%3F%22))%20%7B%0A%20%20%20%20%20%20%20%20stream.eatWhile(%2F%5B%5Cw%5C._%5C-%5D%2F)%3B%0A%20%20%20%20%20%20%20%20state.tokenize%20%3D%20inBlock(%22meta%22%2C%20%22%3F%3E%22)%3B%0A%20%20%20%20%20%20%20%20return%20%22meta%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20type%20%3D%20stream.eat(%22%2F%22)%20%3F%20%22closeTag%22%20%3A%20%22openTag%22%3B%0A%20%20%20%20%20%20%20%20stream.eatSpace()%3B%0A%20%20%20%20%20%20%20%20tagName%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20var%20c%3B%0A%20%20%20%20%20%20%20%20while%20((c%20%3D%20stream.eat(%2F%5B%5E%5Cs%5Cu00a0%3D%3C%3E%5C%22%5C'%5C%2F%3F%5D%2F)))%20tagName%20%2B%3D%20c%3B%0A%20%20%20%20%20%20%20%20state.tokenize%20%3D%20inTag%3B%0A%20%20%20%20%20%20%20%20return%20%22tag%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%26%22)%20%7B%0A%20%20%20%20%20%20var%20ok%3B%0A%20%20%20%20%20%20if%20(stream.eat(%22%23%22))%20%7B%0A%20%20%20%20%20%20%20%20if%20(stream.eat(%22x%22))%20%7B%0A%20%20%20%20%20%20%20%20%20%20ok%20%3D%20stream.eatWhile(%2F%5Ba-fA-F%5Cd%5D%2F)%20%26%26%20stream.eat(%22%3B%22)%3B%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20ok%20%3D%20stream.eatWhile(%2F%5B%5Cd%5D%2F)%20%26%26%20stream.eat(%22%3B%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20ok%20%3D%20stream.eatWhile(%2F%5B%5Cw%5C.%5C-%3A%5D%2F)%20%26%26%20stream.eat(%22%3B%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20ok%20%3F%20%22atom%22%20%3A%20%22error%22%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20%7B%0A%20%20%20%20%20%20stream.eatWhile(%2F%5B%5E%26%3C%5D%2F)%3B%0A%20%20%20%20%20%20return%20null%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20function%20inTag(stream%2C%20state)%20%7B%0A%20%20%20%20var%20ch%20%3D%20stream.next()%3B%0A%20%20%20%20if%20(ch%20%3D%3D%20%22%3E%22%20%7C%7C%20(ch%20%3D%3D%20%22%2F%22%20%26%26%20stream.eat(%22%3E%22)))%20%7B%0A%20%20%20%20%20%20state.tokenize%20%3D%20inText%3B%0A%20%20%20%20%20%20type%20%3D%20ch%20%3D%3D%20%22%3E%22%20%3F%20%22endTag%22%20%3A%20%22selfcloseTag%22%3B%0A%20%20%20%20%20%20return%20%22tag%22%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%3D%22)%20%7B%0A%20%20%20%20%20%20type%20%3D%20%22equals%22%3B%0A%20%20%20%20%20%20return%20null%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(%2F%5B%5C'%5C%22%5D%2F.test(ch))%20%7B%0A%20%20%20%20%20%20state.tokenize%20%3D%20inAttribute(ch)%3B%0A%20%20%20%20%20%20return%20state.tokenize(stream%2C%20state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20%7B%0A%20%20%20%20%20%20stream.eatWhile(%2F%5B%5E%5Cs%5Cu00a0%3D%3C%3E%5C%22%5C'%5C%2F%3F%5D%2F)%3B%0A%20%20%20%20%20%20return%20%22word%22%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20function%20inAttribute(quote)%20%7B%0A%20%20%20%20return%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20while%20(!stream.eol())%20%7B%0A%20%20%20%20%20%20%20%20if%20(stream.next()%20%3D%3D%20quote)%20%7B%0A%20%20%20%20%20%20%20%20%20%20state.tokenize%20%3D%20inTag%3B%0A%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20%22string%22%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%0A%20%20function%20inBlock(style%2C%20terminator)%20%7B%0A%20%20%20%20return%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20while%20(!stream.eol())%20%7B%0A%20%20%20%20%20%20%20%20if%20(stream.match(terminator))%20%7B%0A%20%20%20%20%20%20%20%20%20%20state.tokenize%20%3D%20inText%3B%0A%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20stream.next()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20style%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%20%20function%20doctype(depth)%20%7B%0A%20%20%20%20return%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20var%20ch%3B%0A%20%20%20%20%20%20while%20((ch%20%3D%20stream.next())%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20if%20(ch%20%3D%3D%20%22%3C%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20state.tokenize%20%3D%20doctype(depth%20%2B%201)%3B%0A%20%20%20%20%20%20%20%20%20%20return%20state.tokenize(stream%2C%20state)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(ch%20%3D%3D%20%22%3E%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(depth%20%3D%3D%201)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20state.tokenize%20%3D%20inText%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20state.tokenize%20%3D%20doctype(depth%20-%201)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20state.tokenize(stream%2C%20state)%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20%22meta%22%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%0A%20%20var%20curState%2C%20setStyle%3B%0A%20%20function%20pass()%20%7B%0A%20%20%20%20for%20(var%20i%20%3D%20arguments.length%20-%201%3B%20i%20%3E%3D%200%3B%20i--)%20curState.cc.push(arguments%5Bi%5D)%3B%0A%20%20%7D%0A%20%20function%20cont()%20%7B%0A%20%20%20%20pass.apply(null%2C%20arguments)%3B%0A%20%20%20%20return%20true%3B%0A%20%20%7D%0A%0A%20%20function%20pushContext(tagName%2C%20startOfLine)%20%7B%0A%20%20%20%20var%20noIndent%20%3D%20Kludges.doNotIndent.hasOwnProperty(tagName)%20%7C%7C%20(curState.context%20%26%26%20curState.context.noIndent)%3B%0A%20%20%20%20curState.context%20%3D%20%7B%0A%20%20%20%20%20%20prev%3A%20curState.context%2C%0A%20%20%20%20%20%20tagName%3A%20tagName%2C%0A%20%20%20%20%20%20indent%3A%20curState.indented%2C%0A%20%20%20%20%20%20startOfLine%3A%20startOfLine%2C%0A%20%20%20%20%20%20noIndent%3A%20noIndent%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%20%20function%20popContext()%20%7B%0A%20%20%20%20if%20(curState.context)%20curState.context%20%3D%20curState.context.prev%3B%0A%20%20%7D%0A%0A%20%20function%20element(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22openTag%22)%20%7B%0A%20%20%20%20%20%20curState.tagName%20%3D%20tagName%3B%0A%20%20%20%20%20%20return%20cont(attributes%2C%20endtag(curState.startOfLine))%3B%0A%20%20%20%20%7D%20else%20if%20(type%20%3D%3D%20%22closeTag%22)%20%7B%0A%20%20%20%20%20%20var%20err%20%3D%20false%3B%0A%20%20%20%20%20%20if%20(curState.context)%20%7B%0A%20%20%20%20%20%20%20%20if%20(curState.context.tagName%20!%3D%20tagName)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase()))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20popContext()%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20err%20%3D%20!curState.context%20%7C%7C%20curState.context.tagName%20!%3D%20tagName%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20err%20%3D%20true%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(err)%20setStyle%20%3D%20%22error%22%3B%0A%20%20%20%20%20%20return%20cont(endclosetag(err))%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20cont()%3B%0A%20%20%7D%0A%20%20function%20endtag(startOfLine)%20%7B%0A%20%20%20%20return%20function(type)%20%7B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20%22selfcloseTag%22%20%7C%7C%0A%20%20%20%20%20%20%20%20%20%20(type%20%3D%3D%20%22endTag%22%20%26%26%20Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase())))%20%7B%0A%20%20%20%20%20%20%20%20maybePopContext(curState.tagName.toLowerCase())%3B%0A%20%20%20%20%20%20%20%20return%20cont()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20%22endTag%22)%20%7B%0A%20%20%20%20%20%20%20%20maybePopContext(curState.tagName.toLowerCase())%3B%0A%20%20%20%20%20%20%20%20pushContext(curState.tagName%2C%20startOfLine)%3B%0A%20%20%20%20%20%20%20%20return%20cont()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20cont()%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%20%20function%20endclosetag(err)%20%7B%0A%20%20%20%20return%20function(type)%20%7B%0A%20%20%20%20%20%20if%20(err)%20setStyle%20%3D%20%22error%22%3B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20%22endTag%22)%20%7B%20popContext()%3B%20return%20cont()%3B%20%7D%0A%20%20%20%20%20%20setStyle%20%3D%20%22error%22%3B%0A%20%20%20%20%20%20return%20cont(arguments.callee)%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%20%20function%20maybePopContext(nextTagName)%20%7B%0A%20%20%20%20var%20parentTagName%3B%0A%20%20%20%20while%20(true)%20%7B%0A%20%20%20%20%20%20if%20(!curState.context)%20%7B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20parentTagName%20%3D%20curState.context.tagName.toLowerCase()%3B%0A%20%20%20%20%20%20if%20(!Kludges.contextGrabbers.hasOwnProperty(parentTagName)%20%7C%7C%0A%20%20%20%20%20%20%20%20%20%20!Kludges.contextGrabbers%5BparentTagName%5D.hasOwnProperty(nextTagName))%20%7B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20popContext()%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20function%20attributes(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22word%22)%20%7BsetStyle%20%3D%20%22attribute%22%3B%20return%20cont(attribute%2C%20attributes)%3B%7D%0A%20%20%20%20if%20(type%20%3D%3D%20%22endTag%22%20%7C%7C%20type%20%3D%3D%20%22selfcloseTag%22)%20return%20pass()%3B%0A%20%20%20%20setStyle%20%3D%20%22error%22%3B%0A%20%20%20%20return%20cont(attributes)%3B%0A%20%20%7D%0A%20%20function%20attribute(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22equals%22)%20return%20cont(attvalue%2C%20attributes)%3B%0A%20%20%20%20if%20(!Kludges.allowMissing)%20setStyle%20%3D%20%22error%22%3B%0A%20%20%20%20return%20(type%20%3D%3D%20%22endTag%22%20%7C%7C%20type%20%3D%3D%20%22selfcloseTag%22)%20%3F%20pass()%20%3A%20cont()%3B%0A%20%20%7D%0A%20%20function%20attvalue(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22string%22)%20return%20cont(attvaluemaybe)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22word%22%20%26%26%20Kludges.allowUnquoted)%20%7BsetStyle%20%3D%20%22string%22%3B%20return%20cont()%3B%7D%0A%20%20%20%20setStyle%20%3D%20%22error%22%3B%0A%20%20%20%20return%20(type%20%3D%3D%20%22endTag%22%20%7C%7C%20type%20%3D%3D%20%22selfCloseTag%22)%20%3F%20pass()%20%3A%20cont()%3B%0A%20%20%7D%0A%20%20function%20attvaluemaybe(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22string%22)%20return%20cont(attvaluemaybe)%3B%0A%20%20%20%20else%20return%20pass()%3B%0A%20%20%7D%0A%0A%20%20return%20%7B%0A%20%20%20%20startState%3A%20function()%20%7B%0A%20%20%20%20%20%20return%20%7Btokenize%3A%20inText%2C%20cc%3A%20%5B%5D%2C%20indented%3A%200%2C%20startOfLine%3A%20true%2C%20tagName%3A%20null%2C%20context%3A%20null%7D%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20token%3A%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20if%20(stream.sol())%20%7B%0A%20%20%20%20%20%20%20%20state.startOfLine%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20state.indented%20%3D%20stream.indentation()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(stream.eatSpace())%20return%20null%3B%0A%0A%20%20%20%20%20%20setStyle%20%3D%20type%20%3D%20tagName%20%3D%20null%3B%0A%20%20%20%20%20%20var%20style%20%3D%20state.tokenize(stream%2C%20state)%3B%0A%20%20%20%20%20%20state.type%20%3D%20type%3B%0A%20%20%20%20%20%20if%20((style%20%7C%7C%20type)%20%26%26%20style%20!%3D%20%22comment%22)%20%7B%0A%20%20%20%20%20%20%20%20curState%20%3D%20state%3B%0A%20%20%20%20%20%20%20%20while%20(true)%20%7B%0A%20%20%20%20%20%20%20%20%20%20var%20comb%20%3D%20state.cc.pop()%20%7C%7C%20element%3B%0A%20%20%20%20%20%20%20%20%20%20if%20(comb(type%20%7C%7C%20style))%20break%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20state.startOfLine%20%3D%20false%3B%0A%20%20%20%20%20%20return%20setStyle%20%7C%7C%20style%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20indent%3A%20function(state%2C%20textAfter%2C%20fullLine)%20%7B%0A%20%20%20%20%20%20var%20context%20%3D%20state.context%3B%0A%20%20%20%20%20%20if%20((state.tokenize%20!%3D%20inTag%20%26%26%20state.tokenize%20!%3D%20inText)%20%7C%7C%0A%20%20%20%20%20%20%20%20%20%20context%20%26%26%20context.noIndent)%0A%20%20%20%20%20%20%20%20return%20fullLine%20%3F%20fullLine.match(%2F%5E(%5Cs*)%2F)%5B0%5D.length%20%3A%200%3B%0A%20%20%20%20%20%20if%20(alignCDATA%20%26%26%20%2F%3C!%5C%5BCDATA%5C%5B%2F.test(textAfter))%20return%200%3B%0A%20%20%20%20%20%20if%20(context%20%26%26%20%2F%5E%3C%5C%2F%2F.test(textAfter))%0A%20%20%20%20%20%20%20%20context%20%3D%20context.prev%3B%0A%20%20%20%20%20%20while%20(context%20%26%26%20!context.startOfLine)%0A%20%20%20%20%20%20%20%20context%20%3D%20context.prev%3B%0A%20%20%20%20%20%20if%20(context)%20return%20context.indent%20%2B%20indentUnit%3B%0A%20%20%20%20%20%20else%20return%200%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20electricChars%3A%20%22%2F%22%0A%20%20%7D%3B%0A%7D)%3B%0A%0ACodeMirror.defineMIME(%22text%2Fxml%22%2C%20%22xml%22)%3B%0ACodeMirror.defineMIME(%22application%2Fxml%22%2C%20%22xml%22)%3B%0Aif%20(!CodeMirror.mimeModes.hasOwnProperty(%22text%2Fhtml%22))%0A%20%20CodeMirror.defineMIME(%22text%2Fhtml%22%2C%20%7Bname%3A%20%22xml%22%2C%20htmlMode%3A%20true%7D)%3B%0A%20%20%20%20%3C%2Fscript%3E%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%3C!--%20%20http%3A%2F%2Fcodemirror.net%2Fmode%2Fjavascript%2Fjavascript.js%20--%3E%3Cscript%3E%0ACodeMirror.defineMode(%22javascript%22%2C%20function(config%2C%20parserConfig)%20%7B%0A%20%20var%20indentUnit%20%3D%20config.indentUnit%3B%0A%20%20var%20jsonMode%20%3D%20parserConfig.json%3B%0A%0A%20%20%2F%2F%20Tokenizer%0A%0A%20%20var%20keywords%20%3D%20function()%7B%0A%20%20%20%20function%20kw(type)%20%7Breturn%20%7Btype%3A%20type%2C%20style%3A%20%22keyword%22%7D%3B%7D%0A%20%20%20%20var%20A%20%3D%20kw(%22keyword%20a%22)%2C%20B%20%3D%20kw(%22keyword%20b%22)%2C%20C%20%3D%20kw(%22keyword%20c%22)%3B%0A%20%20%20%20var%20operator%20%3D%20kw(%22operator%22)%2C%20atom%20%3D%20%7Btype%3A%20%22atom%22%2C%20style%3A%20%22atom%22%7D%3B%0A%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%22if%22%3A%20A%2C%20%22while%22%3A%20A%2C%20%22with%22%3A%20A%2C%20%22else%22%3A%20B%2C%20%22do%22%3A%20B%2C%20%22try%22%3A%20B%2C%20%22finally%22%3A%20B%2C%0A%20%20%20%20%20%20%22return%22%3A%20C%2C%20%22break%22%3A%20C%2C%20%22continue%22%3A%20C%2C%20%22new%22%3A%20C%2C%20%22delete%22%3A%20C%2C%20%22throw%22%3A%20C%2C%0A%20%20%20%20%20%20%22var%22%3A%20kw(%22var%22)%2C%20%22const%22%3A%20kw(%22var%22)%2C%20%22let%22%3A%20kw(%22var%22)%2C%0A%20%20%20%20%20%20%22function%22%3A%20kw(%22function%22)%2C%20%22catch%22%3A%20kw(%22catch%22)%2C%0A%20%20%20%20%20%20%22for%22%3A%20kw(%22for%22)%2C%20%22switch%22%3A%20kw(%22switch%22)%2C%20%22case%22%3A%20kw(%22case%22)%2C%20%22default%22%3A%20kw(%22default%22)%2C%0A%20%20%20%20%20%20%22in%22%3A%20operator%2C%20%22typeof%22%3A%20operator%2C%20%22instanceof%22%3A%20operator%2C%0A%20%20%20%20%20%20%22true%22%3A%20atom%2C%20%22false%22%3A%20atom%2C%20%22null%22%3A%20atom%2C%20%22undefined%22%3A%20atom%2C%20%22NaN%22%3A%20atom%2C%20%22Infinity%22%3A%20atom%0A%20%20%20%20%7D%3B%0A%20%20%7D()%3B%0A%0A%20%20var%20isOperatorChar%20%3D%20%2F%5B%2B%5C-*%26%25%3D%3C%3E!%3F%7C%5D%2F%3B%0A%0A%20%20function%20chain(stream%2C%20state%2C%20f)%20%7B%0A%20%20%20%20state.tokenize%20%3D%20f%3B%0A%20%20%20%20return%20f(stream%2C%20state)%3B%0A%20%20%7D%0A%0A%20%20function%20nextUntilUnescaped(stream%2C%20end)%20%7B%0A%20%20%20%20var%20escaped%20%3D%20false%2C%20next%3B%0A%20%20%20%20while%20((next%20%3D%20stream.next())%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20if%20(next%20%3D%3D%20end%20%26%26%20!escaped)%0A%20%20%20%20%20%20%20%20return%20false%3B%0A%20%20%20%20%20%20escaped%20%3D%20!escaped%20%26%26%20next%20%3D%3D%20%22%5C%5C%22%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20escaped%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20Used%20as%20scratch%20variables%20to%20communicate%20multiple%20values%20without%0A%20%20%2F%2F%20consing%20up%20tons%20of%20objects.%0A%20%20var%20type%2C%20content%3B%0A%20%20function%20ret(tp%2C%20style%2C%20cont)%20%7B%0A%20%20%20%20type%20%3D%20tp%3B%20content%20%3D%20cont%3B%0A%20%20%20%20return%20style%3B%0A%20%20%7D%0A%0A%20%20function%20jsTokenBase(stream%2C%20state)%20%7B%0A%20%20%20%20var%20ch%20%3D%20stream.next()%3B%0A%20%20%20%20if%20(ch%20%3D%3D%20'%22'%20%7C%7C%20ch%20%3D%3D%20%22'%22)%0A%20%20%20%20%20%20return%20chain(stream%2C%20state%2C%20jsTokenString(ch))%3B%0A%20%20%20%20else%20if%20(%2F%5B%5C%5B%5C%5D%7B%7D%5C(%5C)%2C%3B%5C%3A%5C.%5D%2F.test(ch))%0A%20%20%20%20%20%20return%20ret(ch)%3B%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%220%22%20%26%26%20stream.eat(%2Fx%2Fi))%20%7B%0A%20%20%20%20%20%20stream.eatWhile(%2F%5B%5Cda-f%5D%2Fi)%3B%0A%20%20%20%20%20%20return%20ret(%22number%22%2C%20%22number%22)%3B%0A%20%20%20%20%7D%20%20%20%20%20%20%0A%20%20%20%20else%20if%20(%2F%5Cd%2F.test(ch)%20%7C%7C%20ch%20%3D%3D%20%22-%22%20%26%26%20stream.eat(%2F%5Cd%2F))%20%7B%0A%20%20%20%20%20%20stream.match(%2F%5E%5Cd*(%3F%3A%5C.%5Cd*)%3F(%3F%3A%5BeE%5D%5B%2B%5C-%5D%3F%5Cd%2B)%3F%2F)%3B%0A%20%20%20%20%20%20return%20ret(%22number%22%2C%20%22number%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%2F%22)%20%7B%0A%20%20%20%20%20%20if%20(stream.eat(%22*%22))%20%7B%0A%20%20%20%20%20%20%20%20return%20chain(stream%2C%20state%2C%20jsTokenComment)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20if%20(stream.eat(%22%2F%22))%20%7B%0A%20%20%20%20%20%20%20%20stream.skipToEnd()%3B%0A%20%20%20%20%20%20%20%20return%20ret(%22comment%22%2C%20%22comment%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20if%20(state.reAllowed)%20%7B%0A%20%20%20%20%20%20%20%20nextUntilUnescaped(stream%2C%20%22%2F%22)%3B%0A%20%20%20%20%20%20%20%20stream.eatWhile(%2F%5Bgimy%5D%2F)%3B%20%2F%2F%20'y'%20is%20%22sticky%22%20option%20in%20Mozilla%0A%20%20%20%20%20%20%20%20return%20ret(%22regexp%22%2C%20%22string-2%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20stream.eatWhile(isOperatorChar)%3B%0A%20%20%20%20%20%20%20%20return%20ret(%22operator%22%2C%20null%2C%20stream.current())%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%23%22)%20%7B%0A%20%20%20%20%20%20%20%20stream.skipToEnd()%3B%0A%20%20%20%20%20%20%20%20return%20ret(%22error%22%2C%20%22error%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(isOperatorChar.test(ch))%20%7B%0A%20%20%20%20%20%20stream.eatWhile(isOperatorChar)%3B%0A%20%20%20%20%20%20return%20ret(%22operator%22%2C%20null%2C%20stream.current())%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20%7B%0A%20%20%20%20%20%20stream.eatWhile(%2F%5B%5Cw%5C%24_%5D%2F)%3B%0A%20%20%20%20%20%20var%20word%20%3D%20stream.current()%2C%20known%20%3D%20keywords.propertyIsEnumerable(word)%20%26%26%20keywords%5Bword%5D%3B%0A%20%20%20%20%20%20return%20(known%20%26%26%20state.kwAllowed)%20%3F%20ret(known.type%2C%20known.style%2C%20word)%20%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ret(%22variable%22%2C%20%22variable%22%2C%20word)%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20function%20jsTokenString(quote)%20%7B%0A%20%20%20%20return%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20if%20(!nextUntilUnescaped(stream%2C%20quote))%0A%20%20%20%20%20%20%20%20state.tokenize%20%3D%20jsTokenBase%3B%0A%20%20%20%20%20%20return%20ret(%22string%22%2C%20%22string%22)%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%0A%20%20function%20jsTokenComment(stream%2C%20state)%20%7B%0A%20%20%20%20var%20maybeEnd%20%3D%20false%2C%20ch%3B%0A%20%20%20%20while%20(ch%20%3D%20stream.next())%20%7B%0A%20%20%20%20%20%20if%20(ch%20%3D%3D%20%22%2F%22%20%26%26%20maybeEnd)%20%7B%0A%20%20%20%20%20%20%20%20state.tokenize%20%3D%20jsTokenBase%3B%0A%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20maybeEnd%20%3D%20(ch%20%3D%3D%20%22*%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20ret(%22comment%22%2C%20%22comment%22)%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20Parser%0A%0A%20%20var%20atomicTypes%20%3D%20%7B%22atom%22%3A%20true%2C%20%22number%22%3A%20true%2C%20%22variable%22%3A%20true%2C%20%22string%22%3A%20true%2C%20%22regexp%22%3A%20true%7D%3B%0A%0A%20%20function%20JSLexical(indented%2C%20column%2C%20type%2C%20align%2C%20prev%2C%20info)%20%7B%0A%20%20%20%20this.indented%20%3D%20indented%3B%0A%20%20%20%20this.column%20%3D%20column%3B%0A%20%20%20%20this.type%20%3D%20type%3B%0A%20%20%20%20this.prev%20%3D%20prev%3B%0A%20%20%20%20this.info%20%3D%20info%3B%0A%20%20%20%20if%20(align%20!%3D%20null)%20this.align%20%3D%20align%3B%0A%20%20%7D%0A%0A%20%20function%20inScope(state%2C%20varname)%20%7B%0A%20%20%20%20for%20(var%20v%20%3D%20state.localVars%3B%20v%3B%20v%20%3D%20v.next)%0A%20%20%20%20%20%20if%20(v.name%20%3D%3D%20varname)%20return%20true%3B%0A%20%20%7D%0A%0A%20%20function%20parseJS(state%2C%20style%2C%20type%2C%20content%2C%20stream)%20%7B%0A%20%20%20%20var%20cc%20%3D%20state.cc%3B%0A%20%20%20%20%2F%2F%20Communicate%20our%20context%20to%20the%20combinators.%0A%20%20%20%20%2F%2F%20(Less%20wasteful%20than%20consing%20up%20a%20hundred%20closures%20on%20every%20call.)%0A%20%20%20%20cx.state%20%3D%20state%3B%20cx.stream%20%3D%20stream%3B%20cx.marked%20%3D%20null%2C%20cx.cc%20%3D%20cc%3B%0A%20%20%0A%20%20%20%20if%20(!state.lexical.hasOwnProperty(%22align%22))%0A%20%20%20%20%20%20state.lexical.align%20%3D%20true%3B%0A%0A%20%20%20%20while(true)%20%7B%0A%20%20%20%20%20%20var%20combinator%20%3D%20cc.length%20%3F%20cc.pop()%20%3A%20jsonMode%20%3F%20expression%20%3A%20statement%3B%0A%20%20%20%20%20%20if%20(combinator(type%2C%20content))%20%7B%0A%20%20%20%20%20%20%20%20while(cc.length%20%26%26%20cc%5Bcc.length%20-%201%5D.lex)%0A%20%20%20%20%20%20%20%20%20%20cc.pop()()%3B%0A%20%20%20%20%20%20%20%20if%20(cx.marked)%20return%20cx.marked%3B%0A%20%20%20%20%20%20%20%20if%20(type%20%3D%3D%20%22variable%22%20%26%26%20inScope(state%2C%20content))%20return%20%22variable-2%22%3B%0A%20%20%20%20%20%20%20%20return%20style%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20%2F%2F%20Combinator%20utils%0A%0A%20%20var%20cx%20%3D%20%7Bstate%3A%20null%2C%20column%3A%20null%2C%20marked%3A%20null%2C%20cc%3A%20null%7D%3B%0A%20%20function%20pass()%20%7B%0A%20%20%20%20for%20(var%20i%20%3D%20arguments.length%20-%201%3B%20i%20%3E%3D%200%3B%20i--)%20cx.cc.push(arguments%5Bi%5D)%3B%0A%20%20%7D%0A%20%20function%20cont()%20%7B%0A%20%20%20%20pass.apply(null%2C%20arguments)%3B%0A%20%20%20%20return%20true%3B%0A%20%20%7D%0A%20%20function%20register(varname)%20%7B%0A%20%20%20%20var%20state%20%3D%20cx.state%3B%0A%20%20%20%20if%20(state.context)%20%7B%0A%20%20%20%20%20%20cx.marked%20%3D%20%22def%22%3B%0A%20%20%20%20%20%20for%20(var%20v%20%3D%20state.localVars%3B%20v%3B%20v%20%3D%20v.next)%0A%20%20%20%20%20%20%20%20if%20(v.name%20%3D%3D%20varname)%20return%3B%0A%20%20%20%20%20%20state.localVars%20%3D%20%7Bname%3A%20varname%2C%20next%3A%20state.localVars%7D%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20%2F%2F%20Combinators%0A%0A%20%20var%20defaultVars%20%3D%20%7Bname%3A%20%22this%22%2C%20next%3A%20%7Bname%3A%20%22arguments%22%7D%7D%3B%0A%20%20function%20pushcontext()%20%7B%0A%20%20%20%20cx.state.context%20%3D%20%7Bprev%3A%20cx.state.context%2C%20vars%3A%20cx.state.localVars%7D%3B%0A%20%20%20%20cx.state.localVars%20%3D%20defaultVars%3B%0A%20%20%7D%0A%20%20function%20popcontext()%20%7B%0A%20%20%20%20cx.state.localVars%20%3D%20cx.state.context.vars%3B%0A%20%20%20%20cx.state.context%20%3D%20cx.state.context.prev%3B%0A%20%20%7D%0A%20%20function%20pushlex(type%2C%20info)%20%7B%0A%20%20%20%20var%20result%20%3D%20function()%20%7B%0A%20%20%20%20%20%20var%20state%20%3D%20cx.state%3B%0A%20%20%20%20%20%20state.lexical%20%3D%20new%20JSLexical(state.indented%2C%20cx.stream.column()%2C%20type%2C%20null%2C%20state.lexical%2C%20info)%3B%0A%20%20%20%20%7D%3B%0A%20%20%20%20result.lex%20%3D%20true%3B%0A%20%20%20%20return%20result%3B%0A%20%20%7D%0A%20%20function%20poplex()%20%7B%0A%20%20%20%20var%20state%20%3D%20cx.state%3B%0A%20%20%20%20if%20(state.lexical.prev)%20%7B%0A%20%20%20%20%20%20if%20(state.lexical.type%20%3D%3D%20%22)%22)%0A%20%20%20%20%20%20%20%20state.indented%20%3D%20state.lexical.indented%3B%0A%20%20%20%20%20%20state.lexical%20%3D%20state.lexical.prev%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20poplex.lex%20%3D%20true%3B%0A%0A%20%20function%20expect(wanted)%20%7B%0A%20%20%20%20return%20function%20expecting(type)%20%7B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20wanted)%20return%20cont()%3B%0A%20%20%20%20%20%20else%20if%20(wanted%20%3D%3D%20%22%3B%22)%20return%20pass()%3B%0A%20%20%20%20%20%20else%20return%20cont(arguments.callee)%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%0A%20%20function%20statement(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22var%22)%20return%20cont(pushlex(%22vardef%22)%2C%20vardef1%2C%20expect(%22%3B%22)%2C%20poplex)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22keyword%20a%22)%20return%20cont(pushlex(%22form%22)%2C%20expression%2C%20statement%2C%20poplex)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22keyword%20b%22)%20return%20cont(pushlex(%22form%22)%2C%20statement%2C%20poplex)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%7B%22)%20return%20cont(pushlex(%22%7D%22)%2C%20block%2C%20poplex)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%3B%22)%20return%20cont()%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22function%22)%20return%20cont(functiondef)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22for%22)%20return%20cont(pushlex(%22form%22)%2C%20expect(%22(%22)%2C%20pushlex(%22)%22)%2C%20forspec1%2C%20expect(%22)%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20poplex%2C%20statement%2C%20poplex)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22variable%22)%20return%20cont(pushlex(%22stat%22)%2C%20maybelabel)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22switch%22)%20return%20cont(pushlex(%22form%22)%2C%20expression%2C%20pushlex(%22%7D%22%2C%20%22switch%22)%2C%20expect(%22%7B%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20block%2C%20poplex%2C%20poplex)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22case%22)%20return%20cont(expression%2C%20expect(%22%3A%22))%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22default%22)%20return%20cont(expect(%22%3A%22))%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22catch%22)%20return%20cont(pushlex(%22form%22)%2C%20pushcontext%2C%20expect(%22(%22)%2C%20funarg%2C%20expect(%22)%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20statement%2C%20poplex%2C%20popcontext)%3B%0A%20%20%20%20return%20pass(pushlex(%22stat%22)%2C%20expression%2C%20expect(%22%3B%22)%2C%20poplex)%3B%0A%20%20%7D%0A%20%20function%20expression(type)%20%7B%0A%20%20%20%20if%20(atomicTypes.hasOwnProperty(type))%20return%20cont(maybeoperator)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22function%22)%20return%20cont(functiondef)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22keyword%20c%22)%20return%20cont(maybeexpression)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22(%22)%20return%20cont(pushlex(%22)%22)%2C%20maybeexpression%2C%20expect(%22)%22)%2C%20poplex%2C%20maybeoperator)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22operator%22)%20return%20cont(expression)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%5B%22)%20return%20cont(pushlex(%22%5D%22)%2C%20commasep(expression%2C%20%22%5D%22)%2C%20poplex%2C%20maybeoperator)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%7B%22)%20return%20cont(pushlex(%22%7D%22)%2C%20commasep(objprop%2C%20%22%7D%22)%2C%20poplex%2C%20maybeoperator)%3B%0A%20%20%20%20return%20cont()%3B%0A%20%20%7D%0A%20%20function%20maybeexpression(type)%20%7B%0A%20%20%20%20if%20(type.match(%2F%5B%3B%5C%7D%5C)%5C%5D%2C%5D%2F))%20return%20pass()%3B%0A%20%20%20%20return%20pass(expression)%3B%0A%20%20%7D%0A%20%20%20%20%0A%20%20function%20maybeoperator(type%2C%20value)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22operator%22%20%26%26%20%2F%5C%2B%5C%2B%7C--%2F.test(value))%20return%20cont(maybeoperator)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22operator%22%20%26%26%20value%20%3D%3D%20%22%3F%22)%20return%20cont(expression%2C%20expect(%22%3A%22)%2C%20expression)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%3B%22)%20return%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22(%22)%20return%20cont(pushlex(%22)%22)%2C%20commasep(expression%2C%20%22)%22)%2C%20poplex%2C%20maybeoperator)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22.%22)%20return%20cont(property%2C%20maybeoperator)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%5B%22)%20return%20cont(pushlex(%22%5D%22)%2C%20expression%2C%20expect(%22%5D%22)%2C%20poplex%2C%20maybeoperator)%3B%0A%20%20%7D%0A%20%20function%20maybelabel(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%3A%22)%20return%20cont(poplex%2C%20statement)%3B%0A%20%20%20%20return%20pass(maybeoperator%2C%20expect(%22%3B%22)%2C%20poplex)%3B%0A%20%20%7D%0A%20%20function%20property(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22variable%22)%20%7Bcx.marked%20%3D%20%22property%22%3B%20return%20cont()%3B%7D%0A%20%20%7D%0A%20%20function%20objprop(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22variable%22)%20cx.marked%20%3D%20%22property%22%3B%0A%20%20%20%20if%20(atomicTypes.hasOwnProperty(type))%20return%20cont(expect(%22%3A%22)%2C%20expression)%3B%0A%20%20%7D%0A%20%20function%20commasep(what%2C%20end)%20%7B%0A%20%20%20%20function%20proceed(type)%20%7B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20%22%2C%22)%20return%20cont(what%2C%20proceed)%3B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20end)%20return%20cont()%3B%0A%20%20%20%20%20%20return%20cont(expect(end))%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20function%20commaSeparated(type)%20%7B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20end)%20return%20cont()%3B%0A%20%20%20%20%20%20else%20return%20pass(what%2C%20proceed)%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%20%20function%20block(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%7D%22)%20return%20cont()%3B%0A%20%20%20%20return%20pass(statement%2C%20block)%3B%0A%20%20%7D%0A%20%20function%20vardef1(type%2C%20value)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22variable%22)%7Bregister(value)%3B%20return%20cont(vardef2)%3B%7D%0A%20%20%20%20return%20cont()%3B%0A%20%20%7D%0A%20%20function%20vardef2(type%2C%20value)%20%7B%0A%20%20%20%20if%20(value%20%3D%3D%20%22%3D%22)%20return%20cont(expression%2C%20vardef2)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%2C%22)%20return%20cont(vardef1)%3B%0A%20%20%7D%0A%20%20function%20forspec1(type)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22var%22)%20return%20cont(vardef1%2C%20forspec2)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%3B%22)%20return%20pass(forspec2)%3B%0A%20%20%20%20if%20(type%20%3D%3D%20%22variable%22)%20return%20cont(formaybein)%3B%0A%20%20%20%20return%20pass(forspec2)%3B%0A%20%20%7D%0A%20%20function%20formaybein(type%2C%20value)%20%7B%0A%20%20%20%20if%20(value%20%3D%3D%20%22in%22)%20return%20cont(expression)%3B%0A%20%20%20%20return%20cont(maybeoperator%2C%20forspec2)%3B%0A%20%20%7D%0A%20%20function%20forspec2(type%2C%20value)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22%3B%22)%20return%20cont(forspec3)%3B%0A%20%20%20%20if%20(value%20%3D%3D%20%22in%22)%20return%20cont(expression)%3B%0A%20%20%20%20return%20cont(expression%2C%20expect(%22%3B%22)%2C%20forspec3)%3B%0A%20%20%7D%0A%20%20function%20forspec3(type)%20%7B%0A%20%20%20%20if%20(type%20!%3D%20%22)%22)%20cont(expression)%3B%0A%20%20%7D%0A%20%20function%20functiondef(type%2C%20value)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22variable%22)%20%7Bregister(value)%3B%20return%20cont(functiondef)%3B%7D%0A%20%20%20%20if%20(type%20%3D%3D%20%22(%22)%20return%20cont(pushlex(%22)%22)%2C%20pushcontext%2C%20commasep(funarg%2C%20%22)%22)%2C%20poplex%2C%20statement%2C%20popcontext)%3B%0A%20%20%7D%0A%20%20function%20funarg(type%2C%20value)%20%7B%0A%20%20%20%20if%20(type%20%3D%3D%20%22variable%22)%20%7Bregister(value)%3B%20return%20cont()%3B%7D%0A%20%20%7D%0A%0A%20%20%2F%2F%20Interface%0A%0A%20%20return%20%7B%0A%20%20%20%20startState%3A%20function(basecolumn)%20%7B%0A%20%20%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%20%20tokenize%3A%20jsTokenBase%2C%0A%20%20%20%20%20%20%20%20reAllowed%3A%20true%2C%0A%20%20%20%20%20%20%20%20kwAllowed%3A%20true%2C%0A%20%20%20%20%20%20%20%20cc%3A%20%5B%5D%2C%0A%20%20%20%20%20%20%20%20lexical%3A%20new%20JSLexical((basecolumn%20%7C%7C%200)%20-%20indentUnit%2C%200%2C%20%22block%22%2C%20false)%2C%0A%20%20%20%20%20%20%20%20localVars%3A%20parserConfig.localVars%2C%0A%20%20%20%20%20%20%20%20context%3A%20parserConfig.localVars%20%26%26%20%7Bvars%3A%20parserConfig.localVars%7D%2C%0A%20%20%20%20%20%20%20%20indented%3A%200%0A%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20token%3A%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20if%20(stream.sol())%20%7B%0A%20%20%20%20%20%20%20%20if%20(!state.lexical.hasOwnProperty(%22align%22))%0A%20%20%20%20%20%20%20%20%20%20state.lexical.align%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20state.indented%20%3D%20stream.indentation()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(stream.eatSpace())%20return%20null%3B%0A%20%20%20%20%20%20var%20style%20%3D%20state.tokenize(stream%2C%20state)%3B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20%22comment%22)%20return%20style%3B%0A%20%20%20%20%20%20state.reAllowed%20%3D%20!!(type%20%3D%3D%20%22operator%22%20%7C%7C%20type%20%3D%3D%20%22keyword%20c%22%20%7C%7C%20type.match(%2F%5E%5B%5C%5B%7B%7D%5C(%2C%3B%3A%5D%24%2F))%3B%0A%20%20%20%20%20%20state.kwAllowed%20%3D%20type%20!%3D%20'.'%3B%0A%20%20%20%20%20%20return%20parseJS(state%2C%20style%2C%20type%2C%20content%2C%20stream)%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20indent%3A%20function(state%2C%20textAfter)%20%7B%0A%20%20%20%20%20%20if%20(state.tokenize%20!%3D%20jsTokenBase)%20return%200%3B%0A%20%20%20%20%20%20var%20firstChar%20%3D%20textAfter%20%26%26%20textAfter.charAt(0)%2C%20lexical%20%3D%20state.lexical%3B%0A%20%20%20%20%20%20if%20(lexical.type%20%3D%3D%20%22stat%22%20%26%26%20firstChar%20%3D%3D%20%22%7D%22)%20lexical%20%3D%20lexical.prev%3B%0A%20%20%20%20%20%20var%20type%20%3D%20lexical.type%2C%20closing%20%3D%20firstChar%20%3D%3D%20type%3B%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20%22vardef%22)%20return%20lexical.indented%20%2B%204%3B%0A%20%20%20%20%20%20else%20if%20(type%20%3D%3D%20%22form%22%20%26%26%20firstChar%20%3D%3D%20%22%7B%22)%20return%20lexical.indented%3B%0A%20%20%20%20%20%20else%20if%20(type%20%3D%3D%20%22stat%22%20%7C%7C%20type%20%3D%3D%20%22form%22)%20return%20lexical.indented%20%2B%20indentUnit%3B%0A%20%20%20%20%20%20else%20if%20(lexical.info%20%3D%3D%20%22switch%22%20%26%26%20!closing)%0A%20%20%20%20%20%20%20%20return%20lexical.indented%20%2B%20(%2F%5E(%3F%3Acase%7Cdefault)%5Cb%2F.test(textAfter)%20%3F%20indentUnit%20%3A%202%20*%20indentUnit)%3B%0A%20%20%20%20%20%20else%20if%20(lexical.align)%20return%20lexical.column%20%2B%20(closing%20%3F%200%20%3A%201)%3B%0A%20%20%20%20%20%20else%20return%20lexical.indented%20%2B%20(closing%20%3F%200%20%3A%20indentUnit)%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20electricChars%3A%20%22%3A%7B%7D%22%0A%20%20%7D%3B%0A%7D)%3B%0A%0ACodeMirror.defineMIME(%22text%2Fjavascript%22%2C%20%22javascript%22)%3B%0ACodeMirror.defineMIME(%22application%2Fjson%22%2C%20%7Bname%3A%20%22javascript%22%2C%20json%3A%20true%7D)%3B%0A%20%20%20%20%3C%2Fscript%3E%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%3C!--%20http%3A%2F%2Fcodemirror.net%2Fmode%2Fcss%2Fcss.js%20--%3E%3Cscript%3E%0ACodeMirror.defineMode(%22css%22%2C%20function(config)%20%7B%0A%20%20var%20indentUnit%20%3D%20config.indentUnit%2C%20type%3B%0A%20%20%0A%20%20var%20atMediaTypes%20%3D%20keySet(%5B%0A%20%20%20%20%22all%22%2C%20%22aural%22%2C%20%22braille%22%2C%20%22handheld%22%2C%20%22print%22%2C%20%22projection%22%2C%20%22screen%22%2C%0A%20%20%20%20%22tty%22%2C%20%22tv%22%2C%20%22embossed%22%0A%20%20%5D)%3B%0A%20%20%0A%20%20var%20atMediaFeatures%20%3D%20keySet(%5B%0A%20%20%20%20%22width%22%2C%20%22min-width%22%2C%20%22max-width%22%2C%20%22height%22%2C%20%22min-height%22%2C%20%22max-height%22%2C%0A%20%20%20%20%22device-width%22%2C%20%22min-device-width%22%2C%20%22max-device-width%22%2C%20%22device-height%22%2C%0A%20%20%20%20%22min-device-height%22%2C%20%22max-device-height%22%2C%20%22aspect-ratio%22%2C%0A%20%20%20%20%22min-aspect-ratio%22%2C%20%22max-aspect-ratio%22%2C%20%22device-aspect-ratio%22%2C%0A%20%20%20%20%22min-device-aspect-ratio%22%2C%20%22max-device-aspect-ratio%22%2C%20%22color%22%2C%20%22min-color%22%2C%0A%20%20%20%20%22max-color%22%2C%20%22color-index%22%2C%20%22min-color-index%22%2C%20%22max-color-index%22%2C%0A%20%20%20%20%22monochrome%22%2C%20%22min-monochrome%22%2C%20%22max-monochrome%22%2C%20%22resolution%22%2C%0A%20%20%20%20%22min-resolution%22%2C%20%22max-resolution%22%2C%20%22scan%22%2C%20%22grid%22%0A%20%20%5D)%3B%0A%0A%20%20var%20propertyKeywords%20%3D%20keySet(%5B%0A%20%20%20%20%22align-content%22%2C%20%22align-items%22%2C%20%22align-self%22%2C%20%22alignment-adjust%22%2C%0A%20%20%20%20%22alignment-baseline%22%2C%20%22anchor-point%22%2C%20%22animation%22%2C%20%22animation-delay%22%2C%0A%20%20%20%20%22animation-direction%22%2C%20%22animation-duration%22%2C%20%22animation-iteration-count%22%2C%0A%20%20%20%20%22animation-name%22%2C%20%22animation-play-state%22%2C%20%22animation-timing-function%22%2C%0A%20%20%20%20%22appearance%22%2C%20%22azimuth%22%2C%20%22backface-visibility%22%2C%20%22background%22%2C%0A%20%20%20%20%22background-attachment%22%2C%20%22background-clip%22%2C%20%22background-color%22%2C%0A%20%20%20%20%22background-image%22%2C%20%22background-origin%22%2C%20%22background-position%22%2C%0A%20%20%20%20%22background-repeat%22%2C%20%22background-size%22%2C%20%22baseline-shift%22%2C%20%22binding%22%2C%0A%20%20%20%20%22bleed%22%2C%20%22bookmark-label%22%2C%20%22bookmark-level%22%2C%20%22bookmark-state%22%2C%0A%20%20%20%20%22bookmark-target%22%2C%20%22border%22%2C%20%22border-bottom%22%2C%20%22border-bottom-color%22%2C%0A%20%20%20%20%22border-bottom-left-radius%22%2C%20%22border-bottom-right-radius%22%2C%0A%20%20%20%20%22border-bottom-style%22%2C%20%22border-bottom-width%22%2C%20%22border-collapse%22%2C%0A%20%20%20%20%22border-color%22%2C%20%22border-image%22%2C%20%22border-image-outset%22%2C%0A%20%20%20%20%22border-image-repeat%22%2C%20%22border-image-slice%22%2C%20%22border-image-source%22%2C%0A%20%20%20%20%22border-image-width%22%2C%20%22border-left%22%2C%20%22border-left-color%22%2C%0A%20%20%20%20%22border-left-style%22%2C%20%22border-left-width%22%2C%20%22border-radius%22%2C%20%22border-right%22%2C%0A%20%20%20%20%22border-right-color%22%2C%20%22border-right-style%22%2C%20%22border-right-width%22%2C%0A%20%20%20%20%22border-spacing%22%2C%20%22border-style%22%2C%20%22border-top%22%2C%20%22border-top-color%22%2C%0A%20%20%20%20%22border-top-left-radius%22%2C%20%22border-top-right-radius%22%2C%20%22border-top-style%22%2C%0A%20%20%20%20%22border-top-width%22%2C%20%22border-width%22%2C%20%22bottom%22%2C%20%22box-decoration-break%22%2C%0A%20%20%20%20%22box-shadow%22%2C%20%22box-sizing%22%2C%20%22break-after%22%2C%20%22break-before%22%2C%20%22break-inside%22%2C%0A%20%20%20%20%22caption-side%22%2C%20%22clear%22%2C%20%22clip%22%2C%20%22color%22%2C%20%22color-profile%22%2C%20%22column-count%22%2C%0A%20%20%20%20%22column-fill%22%2C%20%22column-gap%22%2C%20%22column-rule%22%2C%20%22column-rule-color%22%2C%0A%20%20%20%20%22column-rule-style%22%2C%20%22column-rule-width%22%2C%20%22column-span%22%2C%20%22column-width%22%2C%0A%20%20%20%20%22columns%22%2C%20%22content%22%2C%20%22counter-increment%22%2C%20%22counter-reset%22%2C%20%22crop%22%2C%20%22cue%22%2C%0A%20%20%20%20%22cue-after%22%2C%20%22cue-before%22%2C%20%22cursor%22%2C%20%22direction%22%2C%20%22display%22%2C%0A%20%20%20%20%22dominant-baseline%22%2C%20%22drop-initial-after-adjust%22%2C%0A%20%20%20%20%22drop-initial-after-align%22%2C%20%22drop-initial-before-adjust%22%2C%0A%20%20%20%20%22drop-initial-before-align%22%2C%20%22drop-initial-size%22%2C%20%22drop-initial-value%22%2C%0A%20%20%20%20%22elevation%22%2C%20%22empty-cells%22%2C%20%22fit%22%2C%20%22fit-position%22%2C%20%22flex%22%2C%20%22flex-basis%22%2C%0A%20%20%20%20%22flex-direction%22%2C%20%22flex-flow%22%2C%20%22flex-grow%22%2C%20%22flex-shrink%22%2C%20%22flex-wrap%22%2C%0A%20%20%20%20%22float%22%2C%20%22float-offset%22%2C%20%22font%22%2C%20%22font-feature-settings%22%2C%20%22font-family%22%2C%0A%20%20%20%20%22font-kerning%22%2C%20%22font-language-override%22%2C%20%22font-size%22%2C%20%22font-size-adjust%22%2C%0A%20%20%20%20%22font-stretch%22%2C%20%22font-style%22%2C%20%22font-synthesis%22%2C%20%22font-variant%22%2C%0A%20%20%20%20%22font-variant-alternates%22%2C%20%22font-variant-caps%22%2C%20%22font-variant-east-asian%22%2C%0A%20%20%20%20%22font-variant-ligatures%22%2C%20%22font-variant-numeric%22%2C%20%22font-variant-position%22%2C%0A%20%20%20%20%22font-weight%22%2C%20%22grid-cell%22%2C%20%22grid-column%22%2C%20%22grid-column-align%22%2C%0A%20%20%20%20%22grid-column-sizing%22%2C%20%22grid-column-span%22%2C%20%22grid-columns%22%2C%20%22grid-flow%22%2C%0A%20%20%20%20%22grid-row%22%2C%20%22grid-row-align%22%2C%20%22grid-row-sizing%22%2C%20%22grid-row-span%22%2C%0A%20%20%20%20%22grid-rows%22%2C%20%22grid-template%22%2C%20%22hanging-punctuation%22%2C%20%22height%22%2C%20%22hyphens%22%2C%0A%20%20%20%20%22icon%22%2C%20%22image-orientation%22%2C%20%22image-rendering%22%2C%20%22image-resolution%22%2C%0A%20%20%20%20%22inline-box-align%22%2C%20%22justify-content%22%2C%20%22left%22%2C%20%22letter-spacing%22%2C%0A%20%20%20%20%22line-break%22%2C%20%22line-height%22%2C%20%22line-stacking%22%2C%20%22line-stacking-ruby%22%2C%0A%20%20%20%20%22line-stacking-shift%22%2C%20%22line-stacking-strategy%22%2C%20%22list-style%22%2C%0A%20%20%20%20%22list-style-image%22%2C%20%22list-style-position%22%2C%20%22list-style-type%22%2C%20%22margin%22%2C%0A%20%20%20%20%22margin-bottom%22%2C%20%22margin-left%22%2C%20%22margin-right%22%2C%20%22margin-top%22%2C%0A%20%20%20%20%22marker-offset%22%2C%20%22marks%22%2C%20%22marquee-direction%22%2C%20%22marquee-loop%22%2C%0A%20%20%20%20%22marquee-play-count%22%2C%20%22marquee-speed%22%2C%20%22marquee-style%22%2C%20%22max-height%22%2C%0A%20%20%20%20%22max-width%22%2C%20%22min-height%22%2C%20%22min-width%22%2C%20%22move-to%22%2C%20%22nav-down%22%2C%20%22nav-index%22%2C%0A%20%20%20%20%22nav-left%22%2C%20%22nav-right%22%2C%20%22nav-up%22%2C%20%22opacity%22%2C%20%22order%22%2C%20%22orphans%22%2C%20%22outline%22%2C%0A%20%20%20%20%22outline-color%22%2C%20%22outline-offset%22%2C%20%22outline-style%22%2C%20%22outline-width%22%2C%0A%20%20%20%20%22overflow%22%2C%20%22overflow-style%22%2C%20%22overflow-wrap%22%2C%20%22overflow-x%22%2C%20%22overflow-y%22%2C%0A%20%20%20%20%22padding%22%2C%20%22padding-bottom%22%2C%20%22padding-left%22%2C%20%22padding-right%22%2C%20%22padding-top%22%2C%0A%20%20%20%20%22page%22%2C%20%22page-break-after%22%2C%20%22page-break-before%22%2C%20%22page-break-inside%22%2C%0A%20%20%20%20%22page-policy%22%2C%20%22pause%22%2C%20%22pause-after%22%2C%20%22pause-before%22%2C%20%22perspective%22%2C%0A%20%20%20%20%22perspective-origin%22%2C%20%22pitch%22%2C%20%22pitch-range%22%2C%20%22play-during%22%2C%20%22position%22%2C%0A%20%20%20%20%22presentation-level%22%2C%20%22punctuation-trim%22%2C%20%22quotes%22%2C%20%22rendering-intent%22%2C%0A%20%20%20%20%22resize%22%2C%20%22rest%22%2C%20%22rest-after%22%2C%20%22rest-before%22%2C%20%22richness%22%2C%20%22right%22%2C%0A%20%20%20%20%22rotation%22%2C%20%22rotation-point%22%2C%20%22ruby-align%22%2C%20%22ruby-overhang%22%2C%0A%20%20%20%20%22ruby-position%22%2C%20%22ruby-span%22%2C%20%22size%22%2C%20%22speak%22%2C%20%22speak-as%22%2C%20%22speak-header%22%2C%0A%20%20%20%20%22speak-numeral%22%2C%20%22speak-punctuation%22%2C%20%22speech-rate%22%2C%20%22stress%22%2C%20%22string-set%22%2C%0A%20%20%20%20%22tab-size%22%2C%20%22table-layout%22%2C%20%22target%22%2C%20%22target-name%22%2C%20%22target-new%22%2C%0A%20%20%20%20%22target-position%22%2C%20%22text-align%22%2C%20%22text-align-last%22%2C%20%22text-decoration%22%2C%0A%20%20%20%20%22text-decoration-color%22%2C%20%22text-decoration-line%22%2C%20%22text-decoration-skip%22%2C%0A%20%20%20%20%22text-decoration-style%22%2C%20%22text-emphasis%22%2C%20%22text-emphasis-color%22%2C%0A%20%20%20%20%22text-emphasis-position%22%2C%20%22text-emphasis-style%22%2C%20%22text-height%22%2C%0A%20%20%20%20%22text-indent%22%2C%20%22text-justify%22%2C%20%22text-outline%22%2C%20%22text-shadow%22%2C%0A%20%20%20%20%22text-space-collapse%22%2C%20%22text-transform%22%2C%20%22text-underline-position%22%2C%0A%20%20%20%20%22text-wrap%22%2C%20%22top%22%2C%20%22transform%22%2C%20%22transform-origin%22%2C%20%22transform-style%22%2C%0A%20%20%20%20%22transition%22%2C%20%22transition-delay%22%2C%20%22transition-duration%22%2C%0A%20%20%20%20%22transition-property%22%2C%20%22transition-timing-function%22%2C%20%22unicode-bidi%22%2C%0A%20%20%20%20%22vertical-align%22%2C%20%22visibility%22%2C%20%22voice-balance%22%2C%20%22voice-duration%22%2C%0A%20%20%20%20%22voice-family%22%2C%20%22voice-pitch%22%2C%20%22voice-range%22%2C%20%22voice-rate%22%2C%20%22voice-stress%22%2C%0A%20%20%20%20%22voice-volume%22%2C%20%22volume%22%2C%20%22white-space%22%2C%20%22widows%22%2C%20%22width%22%2C%20%22word-break%22%2C%0A%20%20%20%20%22word-spacing%22%2C%20%22word-wrap%22%2C%20%22z-index%22%0A%20%20%5D)%3B%0A%0A%20%20var%20colorKeywords%20%3D%20keySet(%5B%0A%20%20%20%20%22black%22%2C%20%22silver%22%2C%20%22gray%22%2C%20%22white%22%2C%20%22maroon%22%2C%20%22red%22%2C%20%22purple%22%2C%20%22fuchsia%22%2C%0A%20%20%20%20%22green%22%2C%20%22lime%22%2C%20%22olive%22%2C%20%22yellow%22%2C%20%22navy%22%2C%20%22blue%22%2C%20%22teal%22%2C%20%22aqua%22%0A%20%20%5D)%3B%0A%20%20%0A%20%20var%20valueKeywords%20%3D%20keySet(%5B%0A%20%20%20%20%22above%22%2C%20%22absolute%22%2C%20%22activeborder%22%2C%20%22activecaption%22%2C%20%22afar%22%2C%0A%20%20%20%20%22after-white-space%22%2C%20%22ahead%22%2C%20%22alias%22%2C%20%22all%22%2C%20%22all-scroll%22%2C%20%22alternate%22%2C%0A%20%20%20%20%22always%22%2C%20%22amharic%22%2C%20%22amharic-abegede%22%2C%20%22antialiased%22%2C%20%22appworkspace%22%2C%0A%20%20%20%20%22arabic-indic%22%2C%20%22armenian%22%2C%20%22asterisks%22%2C%20%22auto%22%2C%20%22avoid%22%2C%20%22background%22%2C%0A%20%20%20%20%22backwards%22%2C%20%22baseline%22%2C%20%22below%22%2C%20%22bidi-override%22%2C%20%22binary%22%2C%20%22bengali%22%2C%0A%20%20%20%20%22blink%22%2C%20%22block%22%2C%20%22block-axis%22%2C%20%22bold%22%2C%20%22bolder%22%2C%20%22border%22%2C%20%22border-box%22%2C%0A%20%20%20%20%22both%22%2C%20%22bottom%22%2C%20%22break-all%22%2C%20%22break-word%22%2C%20%22button%22%2C%20%22button-bevel%22%2C%0A%20%20%20%20%22buttonface%22%2C%20%22buttonhighlight%22%2C%20%22buttonshadow%22%2C%20%22buttontext%22%2C%20%22cambodian%22%2C%0A%20%20%20%20%22capitalize%22%2C%20%22caps-lock-indicator%22%2C%20%22caption%22%2C%20%22captiontext%22%2C%20%22caret%22%2C%0A%20%20%20%20%22cell%22%2C%20%22center%22%2C%20%22checkbox%22%2C%20%22circle%22%2C%20%22cjk-earthly-branch%22%2C%0A%20%20%20%20%22cjk-heavenly-stem%22%2C%20%22cjk-ideographic%22%2C%20%22clear%22%2C%20%22clip%22%2C%20%22close-quote%22%2C%0A%20%20%20%20%22col-resize%22%2C%20%22collapse%22%2C%20%22compact%22%2C%20%22condensed%22%2C%20%22contain%22%2C%20%22content%22%2C%0A%20%20%20%20%22content-box%22%2C%20%22context-menu%22%2C%20%22continuous%22%2C%20%22copy%22%2C%20%22cover%22%2C%20%22crop%22%2C%0A%20%20%20%20%22cross%22%2C%20%22crosshair%22%2C%20%22currentcolor%22%2C%20%22cursive%22%2C%20%22dashed%22%2C%20%22decimal%22%2C%0A%20%20%20%20%22decimal-leading-zero%22%2C%20%22default%22%2C%20%22default-button%22%2C%20%22destination-atop%22%2C%0A%20%20%20%20%22destination-in%22%2C%20%22destination-out%22%2C%20%22destination-over%22%2C%20%22devanagari%22%2C%0A%20%20%20%20%22disc%22%2C%20%22discard%22%2C%20%22document%22%2C%20%22dot-dash%22%2C%20%22dot-dot-dash%22%2C%20%22dotted%22%2C%0A%20%20%20%20%22double%22%2C%20%22down%22%2C%20%22e-resize%22%2C%20%22ease%22%2C%20%22ease-in%22%2C%20%22ease-in-out%22%2C%20%22ease-out%22%2C%0A%20%20%20%20%22element%22%2C%20%22ellipsis%22%2C%20%22embed%22%2C%20%22end%22%2C%20%22ethiopic%22%2C%20%22ethiopic-abegede%22%2C%0A%20%20%20%20%22ethiopic-abegede-am-et%22%2C%20%22ethiopic-abegede-gez%22%2C%20%22ethiopic-abegede-ti-er%22%2C%0A%20%20%20%20%22ethiopic-abegede-ti-et%22%2C%20%22ethiopic-halehame-aa-er%22%2C%0A%20%20%20%20%22ethiopic-halehame-aa-et%22%2C%20%22ethiopic-halehame-am-et%22%2C%0A%20%20%20%20%22ethiopic-halehame-gez%22%2C%20%22ethiopic-halehame-om-et%22%2C%0A%20%20%20%20%22ethiopic-halehame-sid-et%22%2C%20%22ethiopic-halehame-so-et%22%2C%0A%20%20%20%20%22ethiopic-halehame-ti-er%22%2C%20%22ethiopic-halehame-ti-et%22%2C%0A%20%20%20%20%22ethiopic-halehame-tig%22%2C%20%22ew-resize%22%2C%20%22expanded%22%2C%20%22extra-condensed%22%2C%0A%20%20%20%20%22extra-expanded%22%2C%20%22fantasy%22%2C%20%22fast%22%2C%20%22fill%22%2C%20%22fixed%22%2C%20%22flat%22%2C%20%22footnotes%22%2C%0A%20%20%20%20%22forwards%22%2C%20%22from%22%2C%20%22geometricPrecision%22%2C%20%22georgian%22%2C%20%22graytext%22%2C%20%22groove%22%2C%0A%20%20%20%20%22gujarati%22%2C%20%22gurmukhi%22%2C%20%22hand%22%2C%20%22hangul%22%2C%20%22hangul-consonant%22%2C%20%22hebrew%22%2C%0A%20%20%20%20%22help%22%2C%20%22hidden%22%2C%20%22hide%22%2C%20%22higher%22%2C%20%22highlight%22%2C%20%22highlighttext%22%2C%0A%20%20%20%20%22hiragana%22%2C%20%22hiragana-iroha%22%2C%20%22horizontal%22%2C%20%22hsl%22%2C%20%22hsla%22%2C%20%22icon%22%2C%20%22ignore%22%2C%0A%20%20%20%20%22inactiveborder%22%2C%20%22inactivecaption%22%2C%20%22inactivecaptiontext%22%2C%20%22infinite%22%2C%0A%20%20%20%20%22infobackground%22%2C%20%22infotext%22%2C%20%22inherit%22%2C%20%22initial%22%2C%20%22inline%22%2C%20%22inline-axis%22%2C%0A%20%20%20%20%22inline-block%22%2C%20%22inline-table%22%2C%20%22inset%22%2C%20%22inside%22%2C%20%22intrinsic%22%2C%20%22invert%22%2C%0A%20%20%20%20%22italic%22%2C%20%22justify%22%2C%20%22kannada%22%2C%20%22katakana%22%2C%20%22katakana-iroha%22%2C%20%22khmer%22%2C%0A%20%20%20%20%22landscape%22%2C%20%22lao%22%2C%20%22large%22%2C%20%22larger%22%2C%20%22left%22%2C%20%22level%22%2C%20%22lighter%22%2C%0A%20%20%20%20%22line-through%22%2C%20%22linear%22%2C%20%22lines%22%2C%20%22list-item%22%2C%20%22listbox%22%2C%20%22listitem%22%2C%0A%20%20%20%20%22local%22%2C%20%22logical%22%2C%20%22loud%22%2C%20%22lower%22%2C%20%22lower-alpha%22%2C%20%22lower-armenian%22%2C%0A%20%20%20%20%22lower-greek%22%2C%20%22lower-hexadecimal%22%2C%20%22lower-latin%22%2C%20%22lower-norwegian%22%2C%0A%20%20%20%20%22lower-roman%22%2C%20%22lowercase%22%2C%20%22ltr%22%2C%20%22malayalam%22%2C%20%22match%22%2C%0A%20%20%20%20%22media-controls-background%22%2C%20%22media-current-time-display%22%2C%0A%20%20%20%20%22media-fullscreen-button%22%2C%20%22media-mute-button%22%2C%20%22media-play-button%22%2C%0A%20%20%20%20%22media-return-to-realtime-button%22%2C%20%22media-rewind-button%22%2C%0A%20%20%20%20%22media-seek-back-button%22%2C%20%22media-seek-forward-button%22%2C%20%22media-slider%22%2C%0A%20%20%20%20%22media-sliderthumb%22%2C%20%22media-time-remaining-display%22%2C%20%22media-volume-slider%22%2C%0A%20%20%20%20%22media-volume-slider-container%22%2C%20%22media-volume-sliderthumb%22%2C%20%22medium%22%2C%0A%20%20%20%20%22menu%22%2C%20%22menulist%22%2C%20%22menulist-button%22%2C%20%22menulist-text%22%2C%0A%20%20%20%20%22menulist-textfield%22%2C%20%22menutext%22%2C%20%22message-box%22%2C%20%22middle%22%2C%20%22min-intrinsic%22%2C%0A%20%20%20%20%22mix%22%2C%20%22mongolian%22%2C%20%22monospace%22%2C%20%22move%22%2C%20%22multiple%22%2C%20%22myanmar%22%2C%20%22n-resize%22%2C%0A%20%20%20%20%22narrower%22%2C%20%22navy%22%2C%20%22ne-resize%22%2C%20%22nesw-resize%22%2C%20%22no-close-quote%22%2C%20%22no-drop%22%2C%0A%20%20%20%20%22no-open-quote%22%2C%20%22no-repeat%22%2C%20%22none%22%2C%20%22normal%22%2C%20%22not-allowed%22%2C%20%22nowrap%22%2C%0A%20%20%20%20%22ns-resize%22%2C%20%22nw-resize%22%2C%20%22nwse-resize%22%2C%20%22oblique%22%2C%20%22octal%22%2C%20%22open-quote%22%2C%0A%20%20%20%20%22optimizeLegibility%22%2C%20%22optimizeSpeed%22%2C%20%22oriya%22%2C%20%22oromo%22%2C%20%22outset%22%2C%0A%20%20%20%20%22outside%22%2C%20%22overlay%22%2C%20%22overline%22%2C%20%22padding%22%2C%20%22padding-box%22%2C%20%22painted%22%2C%0A%20%20%20%20%22paused%22%2C%20%22persian%22%2C%20%22plus-darker%22%2C%20%22plus-lighter%22%2C%20%22pointer%22%2C%20%22portrait%22%2C%0A%20%20%20%20%22pre%22%2C%20%22pre-line%22%2C%20%22pre-wrap%22%2C%20%22preserve-3d%22%2C%20%22progress%22%2C%20%22push-button%22%2C%0A%20%20%20%20%22radio%22%2C%20%22read-only%22%2C%20%22read-write%22%2C%20%22read-write-plaintext-only%22%2C%20%22relative%22%2C%0A%20%20%20%20%22repeat%22%2C%20%22repeat-x%22%2C%20%22repeat-y%22%2C%20%22reset%22%2C%20%22reverse%22%2C%20%22rgb%22%2C%20%22rgba%22%2C%0A%20%20%20%20%22ridge%22%2C%20%22right%22%2C%20%22round%22%2C%20%22row-resize%22%2C%20%22rtl%22%2C%20%22run-in%22%2C%20%22running%22%2C%0A%20%20%20%20%22s-resize%22%2C%20%22sans-serif%22%2C%20%22scroll%22%2C%20%22scrollbar%22%2C%20%22se-resize%22%2C%20%22searchfield%22%2C%0A%20%20%20%20%22searchfield-cancel-button%22%2C%20%22searchfield-decoration%22%2C%0A%20%20%20%20%22searchfield-results-button%22%2C%20%22searchfield-results-decoration%22%2C%0A%20%20%20%20%22semi-condensed%22%2C%20%22semi-expanded%22%2C%20%22separate%22%2C%20%22serif%22%2C%20%22show%22%2C%20%22sidama%22%2C%0A%20%20%20%20%22single%22%2C%20%22skip-white-space%22%2C%20%22slide%22%2C%20%22slider-horizontal%22%2C%0A%20%20%20%20%22slider-vertical%22%2C%20%22sliderthumb-horizontal%22%2C%20%22sliderthumb-vertical%22%2C%20%22slow%22%2C%0A%20%20%20%20%22small%22%2C%20%22small-caps%22%2C%20%22small-caption%22%2C%20%22smaller%22%2C%20%22solid%22%2C%20%22somali%22%2C%0A%20%20%20%20%22source-atop%22%2C%20%22source-in%22%2C%20%22source-out%22%2C%20%22source-over%22%2C%20%22space%22%2C%20%22square%22%2C%0A%20%20%20%20%22square-button%22%2C%20%22start%22%2C%20%22static%22%2C%20%22status-bar%22%2C%20%22stretch%22%2C%20%22stroke%22%2C%0A%20%20%20%20%22sub%22%2C%20%22subpixel-antialiased%22%2C%20%22super%22%2C%20%22sw-resize%22%2C%20%22table%22%2C%0A%20%20%20%20%22table-caption%22%2C%20%22table-cell%22%2C%20%22table-column%22%2C%20%22table-column-group%22%2C%0A%20%20%20%20%22table-footer-group%22%2C%20%22table-header-group%22%2C%20%22table-row%22%2C%20%22table-row-group%22%2C%0A%20%20%20%20%22telugu%22%2C%20%22text%22%2C%20%22text-bottom%22%2C%20%22text-top%22%2C%20%22textarea%22%2C%20%22textfield%22%2C%20%22thai%22%2C%0A%20%20%20%20%22thick%22%2C%20%22thin%22%2C%20%22threeddarkshadow%22%2C%20%22threedface%22%2C%20%22threedhighlight%22%2C%0A%20%20%20%20%22threedlightshadow%22%2C%20%22threedshadow%22%2C%20%22tibetan%22%2C%20%22tigre%22%2C%20%22tigrinya-er%22%2C%0A%20%20%20%20%22tigrinya-er-abegede%22%2C%20%22tigrinya-et%22%2C%20%22tigrinya-et-abegede%22%2C%20%22to%22%2C%20%22top%22%2C%0A%20%20%20%20%22transparent%22%2C%20%22ultra-condensed%22%2C%20%22ultra-expanded%22%2C%20%22underline%22%2C%20%22up%22%2C%0A%20%20%20%20%22upper-alpha%22%2C%20%22upper-armenian%22%2C%20%22upper-greek%22%2C%20%22upper-hexadecimal%22%2C%0A%20%20%20%20%22upper-latin%22%2C%20%22upper-norwegian%22%2C%20%22upper-roman%22%2C%20%22uppercase%22%2C%20%22urdu%22%2C%20%22url%22%2C%0A%20%20%20%20%22vertical%22%2C%20%22vertical-text%22%2C%20%22visible%22%2C%20%22visibleFill%22%2C%20%22visiblePainted%22%2C%0A%20%20%20%20%22visibleStroke%22%2C%20%22visual%22%2C%20%22w-resize%22%2C%20%22wait%22%2C%20%22wave%22%2C%20%22white%22%2C%20%22wider%22%2C%0A%20%20%20%20%22window%22%2C%20%22windowframe%22%2C%20%22windowtext%22%2C%20%22x-large%22%2C%20%22x-small%22%2C%20%22xor%22%2C%0A%20%20%20%20%22xx-large%22%2C%20%22xx-small%22%2C%20%22yellow%22%0A%20%20%5D)%3B%0A%0A%20%20function%20keySet(array)%20%7B%20var%20keys%20%3D%20%7B%7D%3B%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20array.length%3B%20%2B%2Bi)%20keys%5Barray%5Bi%5D%5D%20%3D%20true%3B%20return%20keys%3B%20%7D%0A%20%20function%20ret(style%2C%20tp)%20%7Btype%20%3D%20tp%3B%20return%20style%3B%7D%0A%0A%20%20function%20tokenBase(stream%2C%20state)%20%7B%0A%20%20%20%20var%20ch%20%3D%20stream.next()%3B%0A%20%20%20%20if%20(ch%20%3D%3D%20%22%40%22)%20%7Bstream.eatWhile(%2F%5B%5Cw%5C%5C%5C-%5D%2F)%3B%20return%20ret(%22def%22%2C%20stream.current())%3B%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%2F%22%20%26%26%20stream.eat(%22*%22))%20%7B%0A%20%20%20%20%20%20state.tokenize%20%3D%20tokenCComment%3B%0A%20%20%20%20%20%20return%20tokenCComment(stream%2C%20state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%3C%22%20%26%26%20stream.eat(%22!%22))%20%7B%0A%20%20%20%20%20%20state.tokenize%20%3D%20tokenSGMLComment%3B%0A%20%20%20%20%20%20return%20tokenSGMLComment(stream%2C%20state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%3D%22)%20ret(null%2C%20%22compare%22)%3B%0A%20%20%20%20else%20if%20((ch%20%3D%3D%20%22~%22%20%7C%7C%20ch%20%3D%3D%20%22%7C%22)%20%26%26%20stream.eat(%22%3D%22))%20return%20ret(null%2C%20%22compare%22)%3B%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%5C%22%22%20%7C%7C%20ch%20%3D%3D%20%22'%22)%20%7B%0A%20%20%20%20%20%20state.tokenize%20%3D%20tokenString(ch)%3B%0A%20%20%20%20%20%20return%20state.tokenize(stream%2C%20state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%23%22)%20%7B%0A%20%20%20%20%20%20stream.eatWhile(%2F%5B%5Cw%5C%5C%5C-%5D%2F)%3B%0A%20%20%20%20%20%20return%20ret(%22atom%22%2C%20%22hash%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22!%22)%20%7B%0A%20%20%20%20%20%20stream.match(%2F%5E%5Cs*%5Cw*%2F)%3B%0A%20%20%20%20%20%20return%20ret(%22keyword%22%2C%20%22important%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(%2F%5Cd%2F.test(ch))%20%7B%0A%20%20%20%20%20%20stream.eatWhile(%2F%5B%5Cw.%25%5D%2F)%3B%0A%20%20%20%20%20%20return%20ret(%22number%22%2C%20%22unit%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%3D%20%22-%22)%20%7B%0A%20%20%20%20%20%20if%20(%2F%5Cd%2F.test(stream.peek()))%20%7B%0A%20%20%20%20%20%20%20%20stream.eatWhile(%2F%5B%5Cw.%25%5D%2F)%3B%0A%20%20%20%20%20%20%20%20return%20ret(%22number%22%2C%20%22unit%22)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(stream.match(%2F%5E%5B%5E-%5D%2B-%2F))%20%7B%0A%20%20%20%20%20%20%20%20return%20ret(%22meta%22%2C%20type)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(%2F%5B%2C%2B%3E*%5C%2F%5D%2F.test(ch))%20%7B%0A%20%20%20%20%20%20return%20ret(null%2C%20%22select-op%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22.%22%20%26%26%20stream.match(%2F%5E%5Cw%2B%2F))%20%7B%0A%20%20%20%20%20%20return%20ret(%22qualifier%22%2C%20type)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(ch%20%3D%3D%20%22%3A%22)%20%7B%0A%20%20%20%20%20%20return%20ret(%22operator%22%2C%20ch)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20if%20(%2F%5B%3B%7B%7D%5C%5B%5C%5D%5C(%5C)%5D%2F.test(ch))%20%7B%0A%20%20%20%20%20%20return%20ret(null%2C%20ch)%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%20%7B%0A%20%20%20%20%20%20stream.eatWhile(%2F%5B%5Cw%5C%5C%5C-%5D%2F)%3B%0A%20%20%20%20%20%20return%20ret(%22property%22%2C%20%22variable%22)%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20function%20tokenCComment(stream%2C%20state)%20%7B%0A%20%20%20%20var%20maybeEnd%20%3D%20false%2C%20ch%3B%0A%20%20%20%20while%20((ch%20%3D%20stream.next())%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20if%20(maybeEnd%20%26%26%20ch%20%3D%3D%20%22%2F%22)%20%7B%0A%20%20%20%20%20%20%20%20state.tokenize%20%3D%20tokenBase%3B%0A%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20maybeEnd%20%3D%20(ch%20%3D%3D%20%22*%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20ret(%22comment%22%2C%20%22comment%22)%3B%0A%20%20%7D%0A%0A%20%20function%20tokenSGMLComment(stream%2C%20state)%20%7B%0A%20%20%20%20var%20dashes%20%3D%200%2C%20ch%3B%0A%20%20%20%20while%20((ch%20%3D%20stream.next())%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20if%20(dashes%20%3E%3D%202%20%26%26%20ch%20%3D%3D%20%22%3E%22)%20%7B%0A%20%20%20%20%20%20%20%20state.tokenize%20%3D%20tokenBase%3B%0A%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20dashes%20%3D%20(ch%20%3D%3D%20%22-%22)%20%3F%20dashes%20%2B%201%20%3A%200%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20ret(%22comment%22%2C%20%22comment%22)%3B%0A%20%20%7D%0A%0A%20%20function%20tokenString(quote)%20%7B%0A%20%20%20%20return%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20var%20escaped%20%3D%20false%2C%20ch%3B%0A%20%20%20%20%20%20while%20((ch%20%3D%20stream.next())%20!%3D%20null)%20%7B%0A%20%20%20%20%20%20%20%20if%20(ch%20%3D%3D%20quote%20%26%26%20!escaped)%0A%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%20%20escaped%20%3D%20!escaped%20%26%26%20ch%20%3D%3D%20%22%5C%5C%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20if%20(!escaped)%20state.tokenize%20%3D%20tokenBase%3B%0A%20%20%20%20%20%20return%20ret(%22string%22%2C%20%22string%22)%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%0A%20%20return%20%7B%0A%20%20%20%20startState%3A%20function(base)%20%7B%0A%20%20%20%20%20%20return%20%7Btokenize%3A%20tokenBase%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20baseIndent%3A%20base%20%7C%7C%200%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20stack%3A%20%5B%5D%7D%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20token%3A%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%2F%2F%20Use%20these%20terms%20when%20applicable%20(see%20http%3A%2F%2Fwww.xanthir.com%2Fblog%2Fb4E50)%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20rule**%20or%20**ruleset%3A%0A%20%20%20%20%20%20%2F%2F%20A%20selector%20%2B%20braces%20combo%2C%20or%20an%20at-rule.%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20declaration%20block%3A%0A%20%20%20%20%20%20%2F%2F%20A%20sequence%20of%20declarations.%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20declaration%3A%0A%20%20%20%20%20%20%2F%2F%20A%20property%20%2B%20colon%20%2B%20value%20combo.%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20property%20value%3A%0A%20%20%20%20%20%20%2F%2F%20The%20entire%20value%20of%20a%20property.%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20component%20value%3A%0A%20%20%20%20%20%20%2F%2F%20A%20single%20piece%20of%20a%20property%20value.%20Like%20the%205px%20in%0A%20%20%20%20%20%20%2F%2F%20text-shadow%3A%200%200%205px%20blue%3B.%20Can%20also%20refer%20to%20things%20that%20are%0A%20%20%20%20%20%20%2F%2F%20multiple%20terms%2C%20like%20the%201-4%20terms%20that%20make%20up%20the%20background-size%0A%20%20%20%20%20%20%2F%2F%20portion%20of%20the%20background%20shorthand.%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20term%3A%0A%20%20%20%20%20%20%2F%2F%20The%20basic%20unit%20of%20author-facing%20CSS%2C%20like%20a%20single%20number%20(5)%2C%0A%20%20%20%20%20%20%2F%2F%20dimension%20(5px)%2C%20string%20(%22foo%22)%2C%20or%20function.%20Officially%20defined%0A%20%20%20%20%20%20%2F%2F%20%20by%20the%20CSS%202.1%20grammar%20(look%20for%20the%20'term'%20production)%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20simple%20selector%3A%0A%20%20%20%20%20%20%2F%2F%20A%20single%20atomic%20selector%2C%20like%20a%20type%20selector%2C%20an%20attr%20selector%2C%20a%0A%20%20%20%20%20%20%2F%2F%20class%20selector%2C%20etc.%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20compound%20selector%3A%0A%20%20%20%20%20%20%2F%2F%20One%20or%20more%20simple%20selectors%20without%20a%20combinator.%20div.example%20is%0A%20%20%20%20%20%20%2F%2F%20compound%2C%20div%20%3E%20.example%20is%20not.%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20complex%20selector%3A%0A%20%20%20%20%20%20%2F%2F%20One%20or%20more%20compound%20selectors%20chained%20with%20combinators.%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20combinator%3A%0A%20%20%20%20%20%20%2F%2F%20The%20parts%20of%20selectors%20that%20express%20relationships.%20There%20are%20four%0A%20%20%20%20%20%20%2F%2F%20currently%20-%20the%20space%20(descendant%20combinator)%2C%20the%20greater-than%0A%20%20%20%20%20%20%2F%2F%20bracket%20(child%20combinator)%2C%20the%20plus%20sign%20(next%20sibling%20combinator)%2C%0A%20%20%20%20%20%20%2F%2F%20and%20the%20tilda%20(following%20sibling%20combinator).%0A%20%20%20%20%20%20%2F%2F%20%0A%20%20%20%20%20%20%2F%2F%20sequence%20of%20selectors%3A%0A%20%20%20%20%20%20%2F%2F%20One%20or%20more%20of%20the%20named%20type%20of%20selector%20chained%20with%20commas.%0A%0A%20%20%20%20%20%20if%20(stream.eatSpace())%20return%20null%3B%0A%20%20%20%20%20%20var%20style%20%3D%20state.tokenize(stream%2C%20state)%3B%0A%0A%20%20%20%20%20%20%2F%2F%20Changing%20style%20returned%20based%20on%20context%0A%20%20%20%20%20%20var%20context%20%3D%20state.stack%5Bstate.stack.length-1%5D%3B%0A%20%20%20%20%20%20if%20(style%20%3D%3D%20%22property%22)%20%7B%0A%20%20%20%20%20%20%20%20if%20(context%20%3D%3D%20%22propertyValue%22)%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(valueKeywords%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22string-2%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(colorKeywords%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22keyword%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22variable-2%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(context%20%3D%3D%20%22rule%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(!propertyKeywords%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%2B%3D%20%22%20error%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(!context%20%7C%7C%20context%20%3D%3D%20%22%40media%7B%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22tag%22%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(context%20%3D%3D%20%22%40media%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(atMediaTypes%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22attribute%22%3B%20%2F%2F%20Known%20attribute%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(%2F%5E(only%7Cnot)%24%2Fi.test(stream.current()))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22keyword%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(stream.current().toLowerCase()%20%3D%3D%20%22and%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%20%2F%2F%20%22and%22%20is%20only%20allowed%20in%20%40mediaType%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(atMediaFeatures%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%20%2F%2F%20Known%20property%2C%20should%20be%20in%20%40mediaType(%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Unknown%2C%20expecting%20keyword%20or%20attribute%2C%20assuming%20attribute%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22attribute%20error%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(context%20%3D%3D%20%22%40mediaType%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(atMediaTypes%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22attribute%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(stream.current().toLowerCase()%20%3D%3D%20%22and%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22operator%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(%2F%5E(only%7Cnot)%24%2Fi.test(stream.current()))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%20%2F%2F%20Only%20allowed%20in%20%40media%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(atMediaFeatures%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%20%2F%2F%20Known%20property%2C%20should%20be%20in%20parentheses%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Unknown%20attribute%20or%20property%2C%20but%20expecting%20property%20(preceded%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20by%20%22and%22).%20Should%20be%20in%20parentheses%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(context%20%3D%3D%20%22%40mediaType(%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(propertyKeywords%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20do%20nothing%2C%20remains%20%22property%22%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(atMediaTypes%5Bstream.current()%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%20%2F%2F%20Known%20property%2C%20should%20be%20in%20parentheses%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(stream.current().toLowerCase()%20%3D%3D%20%22and%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22operator%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20if%20(%2F%5E(only%7Cnot)%24%2Fi.test(stream.current()))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%20%2F%2F%20Only%20allowed%20in%20%40media%0A%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%2B%3D%20%22%20error%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%20else%20if%20(style%20%3D%3D%20%22atom%22)%20%7B%0A%20%20%20%20%20%20%20%20if(!context%20%7C%7C%20context%20%3D%3D%20%22%40media%7B%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22builtin%22%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20(context%20%3D%3D%20%22propertyValue%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20if%20(!%2F%5E%23(%5B0-9a-fA-f%5D%7B3%7D%7C%5B0-9a-fA-f%5D%7B6%7D)%24%2F.test(stream.current()))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20style%20%2B%3D%20%22%20error%22%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%20else%20if%20(context%20%3D%3D%20%22%40media%22%20%26%26%20type%20%3D%3D%20%22%7B%22)%20%7B%0A%20%20%20%20%20%20%20%20style%20%3D%20%22error%22%3B%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%2F%2F%20Push%2Fpop%20context%20stack%0A%20%20%20%20%20%20if%20(type%20%3D%3D%20%22%7B%22)%20%7B%0A%20%20%20%20%20%20%20%20if%20(context%20%3D%3D%20%22%40media%22%20%7C%7C%20context%20%3D%3D%20%22%40mediaType%22)%20%7B%0A%20%20%20%20%20%20%20%20%20%20state.stack.pop()%3B%0A%20%20%20%20%20%20%20%20%20%20state.stack%5Bstate.stack.length-1%5D%20%3D%20%22%40media%7B%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20state.stack.push(%22rule%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20if%20(type%20%3D%3D%20%22%7D%22)%20%7B%0A%20%20%20%20%20%20%20%20state.stack.pop()%3B%0A%20%20%20%20%20%20%20%20if%20(context%20%3D%3D%20%22propertyValue%22)%20state.stack.pop()%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20if%20(type%20%3D%3D%20%22%40media%22)%20state.stack.push(%22%40media%22)%3B%0A%20%20%20%20%20%20else%20if%20(context%20%3D%3D%20%22%40media%22%20%26%26%20%2F%5Cb(keyword%7Cattribute)%5Cb%2F.test(style))%0A%20%20%20%20%20%20%20%20state.stack.push(%22%40mediaType%22)%3B%0A%20%20%20%20%20%20else%20if%20(context%20%3D%3D%20%22%40mediaType%22%20%26%26%20stream.current()%20%3D%3D%20%22%2C%22)%20state.stack.pop()%3B%0A%20%20%20%20%20%20else%20if%20(context%20%3D%3D%20%22%40mediaType%22%20%26%26%20type%20%3D%3D%20%22(%22)%20state.stack.push(%22%40mediaType(%22)%3B%0A%20%20%20%20%20%20else%20if%20(context%20%3D%3D%20%22%40mediaType(%22%20%26%26%20type%20%3D%3D%20%22)%22)%20state.stack.pop()%3B%0A%20%20%20%20%20%20else%20if%20(context%20%3D%3D%20%22rule%22%20%26%26%20type%20%3D%3D%20%22%3A%22)%20state.stack.push(%22propertyValue%22)%3B%0A%20%20%20%20%20%20else%20if%20(context%20%3D%3D%20%22propertyValue%22%20%26%26%20type%20%3D%3D%20%22%3B%22)%20state.stack.pop()%3B%0A%20%20%20%20%20%20return%20style%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20indent%3A%20function(state%2C%20textAfter)%20%7B%0A%20%20%20%20%20%20var%20n%20%3D%20state.stack.length%3B%0A%20%20%20%20%20%20if%20(%2F%5E%5C%7D%2F.test(textAfter))%0A%20%20%20%20%20%20%20%20n%20-%3D%20state.stack%5Bstate.stack.length-1%5D%20%3D%3D%20%22propertyValue%22%20%3F%202%20%3A%201%3B%0A%20%20%20%20%20%20return%20state.baseIndent%20%2B%20n%20*%20indentUnit%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20electricChars%3A%20%22%7D%22%0A%20%20%7D%3B%0A%7D)%3B%0A%0ACodeMirror.defineMIME(%22text%2Fcss%22%2C%20%22css%22)%3B%0A%20%20%20%20%3C%2Fscript%3E%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%3C!--%20http%3A%2F%2Fcodemirror.net%2Fmode%2Fhtmlmixed%2Fhtmlmixed.js%20--%3E%3Cscript%3E%0ACodeMirror.defineMode(%22htmlmixed%22%2C%20function(config)%20%7B%0A%20%20var%20htmlMode%20%3D%20CodeMirror.getMode(config%2C%20%7Bname%3A%20%22xml%22%2C%20htmlMode%3A%20true%7D)%3B%0A%20%20var%20jsMode%20%3D%20CodeMirror.getMode(config%2C%20%22javascript%22)%3B%0A%20%20var%20cssMode%20%3D%20CodeMirror.getMode(config%2C%20%22css%22)%3B%0A%0A%20%20function%20html(stream%2C%20state)%20%7B%0A%20%20%20%20var%20style%20%3D%20htmlMode.token(stream%2C%20state.htmlState)%3B%0A%20%20%20%20if%20(style%20%3D%3D%20%22tag%22%20%26%26%20stream.current()%20%3D%3D%20%22%3E%22%20%26%26%20state.htmlState.context)%20%7B%0A%20%20%20%20%20%20if%20(%2F%5Escript%24%2Fi.test(state.htmlState.context.tagName))%20%7B%0A%20%20%20%20%20%20%20%20state.token%20%3D%20javascript%3B%0A%20%20%20%20%20%20%20%20state.localState%20%3D%20jsMode.startState(htmlMode.indent(state.htmlState%2C%20%22%22))%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20if%20(%2F%5Estyle%24%2Fi.test(state.htmlState.context.tagName))%20%7B%0A%20%20%20%20%20%20%20%20state.token%20%3D%20css%3B%0A%20%20%20%20%20%20%20%20state.localState%20%3D%20cssMode.startState(htmlMode.indent(state.htmlState%2C%20%22%22))%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20style%3B%0A%20%20%7D%0A%20%20function%20maybeBackup(stream%2C%20pat%2C%20style)%20%7B%0A%20%20%20%20var%20cur%20%3D%20stream.current()%3B%0A%20%20%20%20var%20close%20%3D%20cur.search(pat)%2C%20m%3B%0A%20%20%20%20if%20(close%20%3E%20-1)%20stream.backUp(cur.length%20-%20close)%3B%0A%20%20%20%20else%20if%20(m%20%3D%20cur.match(%2F%3C%5C%2F%3F%24%2F))%20%7B%0A%20%20%20%20%20%20stream.backUp(cur%5B0%5D.length)%3B%0A%20%20%20%20%20%20if%20(!stream.match(pat%2C%20false))%20stream.match(cur%5B0%5D)%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20style%3B%0A%20%20%7D%0A%20%20function%20javascript(stream%2C%20state)%20%7B%0A%20%20%20%20if%20(stream.match(%2F%5E%3C%5C%2F%5Cs*script%5Cs*%3E%2Fi%2C%20false))%20%7B%0A%20%20%20%20%20%20state.token%20%3D%20html%3B%0A%20%20%20%20%20%20state.localState%20%3D%20null%3B%0A%20%20%20%20%20%20return%20html(stream%2C%20state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20maybeBackup(stream%2C%20%2F%3C%5C%2F%5Cs*script%5Cs*%3E%2F%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jsMode.token(stream%2C%20state.localState))%3B%0A%20%20%7D%0A%20%20function%20css(stream%2C%20state)%20%7B%0A%20%20%20%20if%20(stream.match(%2F%5E%3C%5C%2F%5Cs*style%5Cs*%3E%2Fi%2C%20false))%20%7B%0A%20%20%20%20%20%20state.token%20%3D%20html%3B%0A%20%20%20%20%20%20state.localState%20%3D%20null%3B%0A%20%20%20%20%20%20return%20html(stream%2C%20state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20maybeBackup(stream%2C%20%2F%3C%5C%2F%5Cs*style%5Cs*%3E%2F%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20cssMode.token(stream%2C%20state.localState))%3B%0A%20%20%7D%0A%0A%20%20return%20%7B%0A%20%20%20%20startState%3A%20function()%20%7B%0A%20%20%20%20%20%20var%20state%20%3D%20htmlMode.startState()%3B%0A%20%20%20%20%20%20return%20%7Btoken%3A%20html%2C%20localState%3A%20null%2C%20mode%3A%20%22html%22%2C%20htmlState%3A%20state%7D%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20copyState%3A%20function(state)%20%7B%0A%20%20%20%20%20%20if%20(state.localState)%0A%20%20%20%20%20%20%20%20var%20local%20%3D%20CodeMirror.copyState(state.token%20%3D%3D%20css%20%3F%20cssMode%20%3A%20jsMode%2C%20state.localState)%3B%0A%20%20%20%20%20%20return%20%7Btoken%3A%20state.token%2C%20localState%3A%20local%2C%20mode%3A%20state.mode%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20htmlState%3A%20CodeMirror.copyState(htmlMode%2C%20state.htmlState)%7D%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20token%3A%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20return%20state.token(stream%2C%20state)%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20indent%3A%20function(state%2C%20textAfter)%20%7B%0A%20%20%20%20%20%20if%20(state.token%20%3D%3D%20html%20%7C%7C%20%2F%5E%5Cs*%3C%5C%2F%2F.test(textAfter))%0A%20%20%20%20%20%20%20%20return%20htmlMode.indent(state.htmlState%2C%20textAfter)%3B%0A%20%20%20%20%20%20else%20if%20(state.token%20%3D%3D%20javascript)%0A%20%20%20%20%20%20%20%20return%20jsMode.indent(state.localState%2C%20textAfter)%3B%0A%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20return%20cssMode.indent(state.localState%2C%20textAfter)%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20electricChars%3A%20%22%2F%7B%7D%3A%22%2C%0A%0A%20%20%20%20innerMode%3A%20function(state)%20%7B%0A%20%20%20%20%20%20var%20mode%20%3D%20state.token%20%3D%3D%20html%20%3F%20htmlMode%20%3A%20state.token%20%3D%3D%20javascript%20%3F%20jsMode%20%3A%20cssMode%3B%0A%20%20%20%20%20%20return%20%7Bstate%3A%20state.localState%20%7C%7C%20state.htmlState%2C%20mode%3A%20mode%7D%3B%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%7D%2C%20%22xml%22%2C%20%22javascript%22%2C%20%22css%22)%3B%0A%0ACodeMirror.defineMIME(%22text%2Fhtml%22%2C%20%22htmlmixed%22)%3B%0A%20%20%20%20%3C%2Fscript%3E%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%3C!--%20http%3A%2F%2Fcodemirror.net%2Fmode%2Fmarkdown%2Fmarkdown.js%20--%3E%3Cscript%3E%0ACodeMirror.defineMode(%22markdown%22%2C%20function(cmCfg%2C%20modeCfg)%20%7B%0A%0A%20%20var%20htmlFound%20%3D%20CodeMirror.mimeModes.hasOwnProperty(%22text%2Fhtml%22)%3B%0A%20%20var%20htmlMode%20%3D%20CodeMirror.getMode(cmCfg%2C%20htmlFound%20%3F%20%22text%2Fhtml%22%20%3A%20%22text%2Fplain%22)%3B%0A%20%20%0A%20%20var%20codeDepth%20%3D%200%3B%0A%20%20var%20prevLineHasContent%20%3D%20false%0A%20%20%2C%20%20%20thisLineHasContent%20%3D%20false%3B%0A%0A%20%20var%20header%20%20%20%3D%20'header'%0A%20%20%2C%20%20%20code%20%20%20%20%20%3D%20'comment'%0A%20%20%2C%20%20%20quote%20%20%20%20%3D%20'quote'%0A%20%20%2C%20%20%20list%20%20%20%20%20%3D%20'string'%0A%20%20%2C%20%20%20hr%20%20%20%20%20%20%20%3D%20'hr'%0A%20%20%2C%20%20%20linkinline%20%3D%20'link'%0A%20%20%2C%20%20%20linkemail%20%3D%20'link'%0A%20%20%2C%20%20%20linktext%20%3D%20'link'%0A%20%20%2C%20%20%20linkhref%20%3D%20'string'%0A%20%20%2C%20%20%20em%20%20%20%20%20%20%20%3D%20'em'%0A%20%20%2C%20%20%20strong%20%20%20%3D%20'strong'%0A%20%20%2C%20%20%20emstrong%20%3D%20'emstrong'%3B%0A%0A%20%20var%20hrRE%20%3D%20%2F%5E(%5B*%5C-%3D_%5D)(%3F%3A%5Cs*%5C1)%7B2%2C%7D%5Cs*%24%2F%0A%20%20%2C%20%20%20ulRE%20%3D%20%2F%5E%5B*%5C-%2B%5D%5Cs%2B%2F%0A%20%20%2C%20%20%20olRE%20%3D%20%2F%5E%5B0-9%5D%2B%5C.%5Cs%2B%2F%0A%20%20%2C%20%20%20headerRE%20%3D%20%2F%5E(%3F%3A%5C%3D%7B1%2C%7D%7C-%7B1%2C%7D)%24%2F%0A%20%20%2C%20%20%20textRE%20%3D%20%2F%5E%5B%5E%5C%5B*_%5C%5C%3C%3E%60%20%22'(%5D%2B%2F%3B%0A%0A%20%20function%20switchInline(stream%2C%20state%2C%20f)%20%7B%0A%20%20%20%20state.f%20%3D%20state.inline%20%3D%20f%3B%0A%20%20%20%20return%20f(stream%2C%20state)%3B%0A%20%20%7D%0A%0A%20%20function%20switchBlock(stream%2C%20state%2C%20f)%20%7B%0A%20%20%20%20state.f%20%3D%20state.block%20%3D%20f%3B%0A%20%20%20%20return%20f(stream%2C%20state)%3B%0A%20%20%7D%0A%0A%0A%20%20%2F%2F%20Blocks%0A%0A%20%20function%20blankLine(state)%20%7B%0A%20%20%20%20%2F%2F%20Reset%20linkTitle%20state%0A%20%20%20%20state.linkTitle%20%3D%20false%3B%0A%20%20%20%20%2F%2F%20Reset%20CODE%20state%0A%20%20%20%20state.code%20%3D%20false%3B%0A%20%20%20%20%2F%2F%20Reset%20EM%20state%0A%20%20%20%20state.em%20%3D%20false%3B%0A%20%20%20%20%2F%2F%20Reset%20STRONG%20state%0A%20%20%20%20state.strong%20%3D%20false%3B%0A%20%20%20%20%2F%2F%20Reset%20state.quote%0A%20%20%20%20state.quote%20%3D%20false%3B%0A%20%20%20%20if%20(!htmlFound%20%26%26%20state.f%20%3D%3D%20htmlBlock)%20%7B%0A%20%20%20%20%20%20state.f%20%3D%20inlineNormal%3B%0A%20%20%20%20%20%20state.block%20%3D%20blockNormal%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20null%3B%0A%20%20%7D%0A%0A%20%20function%20blockNormal(stream%2C%20state)%20%7B%0A%20%20%20%20var%20match%3B%0A%20%20%20%20%0A%20%20%20%20if%20(state.list%20!%3D%3D%20false%20%26%26%20state.indentationDiff%20%3E%3D%200)%20%7B%20%2F%2F%20Continued%20list%0A%20%20%20%20%20%20if%20(state.indentationDiff%20%3C%204)%20%7B%20%2F%2F%20Only%20adjust%20indentation%20if%20*not*%20a%20code%20block%0A%20%20%20%20%20%20%20%20state.indentation%20-%3D%20state.indentationDiff%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20state.list%20%3D%20null%3B%0A%20%20%20%20%7D%20else%20%7B%20%2F%2F%20No%20longer%20a%20list%0A%20%20%20%20%20%20state.list%20%3D%20false%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(state.indentationDiff%20%3E%3D%204)%20%7B%0A%20%20%20%20%20%20state.indentation%20-%3D%204%3B%0A%20%20%20%20%20%20stream.skipToEnd()%3B%0A%20%20%20%20%20%20return%20code%3B%0A%20%20%20%20%7D%20else%20if%20(stream.eatSpace())%20%7B%0A%20%20%20%20%20%20return%20null%3B%0A%20%20%20%20%7D%20else%20if%20(stream.peek()%20%3D%3D%3D%20'%23'%20%7C%7C%20(prevLineHasContent%20%26%26%20stream.match(headerRE))%20)%20%7B%0A%20%20%20%20%20%20state.header%20%3D%20true%3B%0A%20%20%20%20%7D%20else%20if%20(stream.eat('%3E'))%20%7B%0A%20%20%20%20%20%20state.indentation%2B%2B%3B%0A%20%20%20%20%20%20state.quote%20%3D%20true%3B%0A%20%20%20%20%7D%20else%20if%20(stream.peek()%20%3D%3D%3D%20'%5B')%20%7B%0A%20%20%20%20%20%20return%20switchInline(stream%2C%20state%2C%20footnoteLink)%3B%0A%20%20%20%20%7D%20else%20if%20(stream.match(hrRE%2C%20true))%20%7B%0A%20%20%20%20%20%20return%20hr%3B%0A%20%20%20%20%7D%20else%20if%20(match%20%3D%20stream.match(ulRE%2C%20true)%20%7C%7C%20stream.match(olRE%2C%20true))%20%7B%0A%20%20%20%20%20%20state.indentation%20%2B%3D%204%3B%0A%20%20%20%20%20%20state.list%20%3D%20true%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20return%20switchInline(stream%2C%20state%2C%20state.inline)%3B%0A%20%20%7D%0A%0A%20%20function%20htmlBlock(stream%2C%20state)%20%7B%0A%20%20%20%20var%20style%20%3D%20htmlMode.token(stream%2C%20state.htmlState)%3B%0A%20%20%20%20if%20(htmlFound%20%26%26%20style%20%3D%3D%3D%20'tag'%20%26%26%20state.htmlState.type%20!%3D%3D%20'openTag'%20%26%26%20!state.htmlState.context)%20%7B%0A%20%20%20%20%20%20state.f%20%3D%20inlineNormal%3B%0A%20%20%20%20%20%20state.block%20%3D%20blockNormal%3B%0A%20%20%20%20%7D%0A%20%20%20%20if%20(state.md_inside%20%26%26%20stream.current().indexOf(%22%3E%22)!%3D-1)%20%7B%0A%20%20%20%20%20%20state.f%20%3D%20inlineNormal%3B%0A%20%20%20%20%20%20state.block%20%3D%20blockNormal%3B%0A%20%20%20%20%20%20state.htmlState.context%20%3D%20undefined%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20style%3B%0A%20%20%7D%0A%0A%0A%20%20%2F%2F%20Inline%0A%20%20function%20getType(state)%20%7B%0A%20%20%20%20var%20styles%20%3D%20%5B%5D%3B%0A%20%20%20%20%0A%20%20%20%20if%20(state.strong)%20%7B%20styles.push(state.em%20%3F%20emstrong%20%3A%20strong)%3B%20%7D%0A%20%20%20%20else%20if%20(state.em)%20%7B%20styles.push(em)%3B%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(state.code)%20%7B%20styles.push(code)%3B%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(state.header)%20%7B%20styles.push(header)%3B%20%7D%0A%20%20%20%20if%20(state.quote)%20%7B%20styles.push(quote)%3B%20%7D%0A%20%20%20%20if%20(state.list%20!%3D%3D%20false)%20%7B%20styles.push(list)%3B%20%7D%0A%0A%20%20%20%20return%20styles.length%20%3F%20styles.join('%20')%20%3A%20null%3B%0A%20%20%7D%0A%0A%20%20function%20handleText(stream%2C%20state)%20%7B%0A%20%20%20%20if%20(stream.match(textRE%2C%20true))%20%7B%0A%20%20%20%20%20%20return%20getType(state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20undefined%3B%20%20%20%20%20%20%20%20%0A%20%20%7D%0A%0A%20%20function%20inlineNormal(stream%2C%20state)%20%7B%0A%20%20%20%20var%20style%20%3D%20state.text(stream%2C%20state)%3B%0A%20%20%20%20if%20(typeof%20style%20!%3D%3D%20'undefined')%0A%20%20%20%20%20%20return%20style%3B%0A%20%20%20%20%0A%20%20%20%20if%20(state.list)%20%7B%20%2F%2F%20List%20marker%20(*%2C%20%2B%2C%20-%2C%201.%2C%20etc)%0A%20%20%20%20%20%20state.list%20%3D%20null%3B%0A%20%20%20%20%20%20return%20list%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20var%20ch%20%3D%20stream.next()%3B%0A%20%20%20%20%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'%5C%5C')%20%7B%0A%20%20%20%20%20%20stream.next()%3B%0A%20%20%20%20%20%20return%20getType(state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20Matches%20link%20titles%20present%20on%20next%20line%0A%20%20%20%20if%20(state.linkTitle)%20%7B%0A%20%20%20%20%20%20state.linkTitle%20%3D%20false%3B%0A%20%20%20%20%20%20var%20matchCh%20%3D%20ch%3B%0A%20%20%20%20%20%20if%20(ch%20%3D%3D%3D%20'(')%20%7B%0A%20%20%20%20%20%20%20%20matchCh%20%3D%20')'%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20matchCh%20%3D%20(matchCh%2B'').replace(%2F(%5B.%3F*%2B%5E%24%5B%5C%5D%5C%5C()%7B%7D%7C-%5D)%2Fg%2C%20%22%5C%5C%241%22)%3B%0A%20%20%20%20%20%20var%20regex%20%3D%20'%5E%5C%5Cs*(%3F%3A%5B%5E'%20%2B%20matchCh%20%2B%20'%5C%5C%5C%5C%5D%2B%7C%5C%5C%5C%5C%5C%5C%5C%5C%7C%5C%5C%5C%5C.)'%20%2B%20matchCh%3B%0A%20%20%20%20%20%20if%20(stream.match(new%20RegExp(regex)%2C%20true))%20%7B%0A%20%20%20%20%20%20%20%20return%20linkhref%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'%60')%20%7B%0A%20%20%20%20%20%20var%20t%20%3D%20getType(state)%3B%0A%20%20%20%20%20%20var%20before%20%3D%20stream.pos%3B%0A%20%20%20%20%20%20stream.eatWhile('%60')%3B%0A%20%20%20%20%20%20var%20difference%20%3D%201%20%2B%20stream.pos%20-%20before%3B%0A%20%20%20%20%20%20if%20(!state.code)%20%7B%0A%20%20%20%20%20%20%20%20codeDepth%20%3D%20difference%3B%0A%20%20%20%20%20%20%20%20state.code%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20return%20getType(state)%3B%0A%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20if%20(difference%20%3D%3D%3D%20codeDepth)%20%7B%20%2F%2F%20Must%20be%20exact%0A%20%20%20%20%20%20%20%20%20%20state.code%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20return%20t%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20return%20getType(state)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%20else%20if%20(state.code)%20%7B%0A%20%20%20%20%20%20return%20getType(state)%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'%5B'%20%26%26%20stream.match(%2F.*%5C%5D%20%3F(%3F%3A%5C(%7C%5C%5B)%2F%2C%20false))%20%7B%0A%20%20%20%20%20%20return%20switchInline(stream%2C%20state%2C%20linkText)%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'%3C'%20%26%26%20stream.match(%2F%5E(https%3F%7Cftps%3F)%3A%5C%2F%5C%2F(%3F%3A%5B%5E%5C%5C%3E%5D%7C%5C%5C.)%2B%3E%2F%2C%20true))%20%7B%0A%20%20%20%20%20%20return%20switchInline(stream%2C%20state%2C%20inlineElement(linkinline%2C%20'%3E'))%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'%3C'%20%26%26%20stream.match(%2F%5E%5B%5E%3E%20%5C%5C%5D%2B%40(%3F%3A%5B%5E%5C%5C%3E%5D%7C%5C%5C.)%2B%3E%2F%2C%20true))%20%7B%0A%20%20%20%20%20%20return%20switchInline(stream%2C%20state%2C%20inlineElement(linkemail%2C%20'%3E'))%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'%3C'%20%26%26%20stream.match(%2F%5E%5Cw%2F%2C%20false))%20%7B%0A%20%20%20%20%20%20var%20md_inside%20%3D%20false%3B%0A%20%20%20%20%20%20if%20(stream.string.indexOf(%22%3E%22)!%3D-1)%20%7B%0A%20%20%20%20%20%20%20%20var%20atts%20%3D%20stream.string.substring(1%2Cstream.string.indexOf(%22%3E%22))%3B%0A%20%20%20%20%20%20%20%20if%20(%2Fmarkdown%5Cs*%3D%5Cs*('%7C%22)%7B0%2C1%7D1('%7C%22)%7B0%2C1%7D%2F.test(atts))%20%7B%0A%20%20%20%20%20%20%20%20%20%20state.md_inside%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20stream.backUp(1)%3B%0A%20%20%20%20%20%20return%20switchBlock(stream%2C%20state%2C%20htmlBlock)%3B%0A%20%20%20%20%7D%0A%20%20%20%20%20%20%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'%3C'%20%26%26%20stream.match(%2F%5E%5C%2F%5Cw*%3F%3E%2F))%20%7B%0A%20%20%20%20%20%20state.md_inside%20%3D%20false%3B%0A%20%20%20%20%20%20return%20%22tag%22%3B%0A%20%20%20%20%7D%0A%20%20%20%20%20%20%0A%20%20%20%20var%20t%20%3D%20getType(state)%3B%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'*'%20%7C%7C%20ch%20%3D%3D%3D%20'_')%20%7B%0A%20%20%20%20%20%20if%20(state.strong%20%3D%3D%3D%20ch%20%26%26%20stream.eat(ch))%20%7B%20%2F%2F%20Remove%20STRONG%0A%20%20%20%20%20%20%20%20state.strong%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20return%20t%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(!state.strong%20%26%26%20stream.eat(ch))%20%7B%20%2F%2F%20Add%20STRONG%0A%20%20%20%20%20%20%20%20state.strong%20%3D%20ch%3B%0A%20%20%20%20%20%20%20%20return%20getType(state)%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(state.em%20%3D%3D%3D%20ch)%20%7B%20%2F%2F%20Remove%20EM%0A%20%20%20%20%20%20%20%20state.em%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20return%20t%3B%0A%20%20%20%20%20%20%7D%20else%20if%20(!state.em)%20%7B%20%2F%2F%20Add%20EM%0A%20%20%20%20%20%20%20%20state.em%20%3D%20ch%3B%0A%20%20%20%20%20%20%20%20return%20getType(state)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%20else%20if%20(ch%20%3D%3D%3D%20'%20')%20%7B%0A%20%20%20%20%20%20if%20(stream.eat('*')%20%7C%7C%20stream.eat('_'))%20%7B%20%2F%2F%20Probably%20surrounded%20by%20spaces%0A%20%20%20%20%20%20%20%20if%20(stream.peek()%20%3D%3D%3D%20'%20')%20%7B%20%2F%2F%20Surrounded%20by%20spaces%2C%20ignore%0A%20%20%20%20%20%20%20%20%20%20return%20getType(state)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%20%2F%2F%20Not%20surrounded%20by%20spaces%2C%20back%20up%20pointer%0A%20%20%20%20%20%20%20%20%20%20stream.backUp(1)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20return%20getType(state)%3B%0A%20%20%7D%0A%0A%20%20function%20linkText(stream%2C%20state)%20%7B%0A%20%20%20%20while%20(!stream.eol())%20%7B%0A%20%20%20%20%20%20var%20ch%20%3D%20stream.next()%3B%0A%20%20%20%20%20%20if%20(ch%20%3D%3D%3D%20'%5C%5C')%20stream.next()%3B%0A%20%20%20%20%20%20if%20(ch%20%3D%3D%3D%20'%5D')%20%7B%0A%20%20%20%20%20%20%20%20state.inline%20%3D%20state.f%20%3D%20linkHref%3B%0A%20%20%20%20%20%20%20%20return%20linktext%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20return%20linktext%3B%0A%20%20%7D%0A%0A%20%20function%20linkHref(stream%2C%20state)%20%7B%0A%20%20%20%20%2F%2F%20Check%20if%20space%2C%20and%20return%20NULL%20if%20so%20(to%20avoid%20marking%20the%20space)%0A%20%20%20%20if(stream.eatSpace())%7B%0A%20%20%20%20%20%20return%20null%3B%0A%20%20%20%20%7D%0A%20%20%20%20var%20ch%20%3D%20stream.next()%3B%0A%20%20%20%20if%20(ch%20%3D%3D%3D%20'('%20%7C%7C%20ch%20%3D%3D%3D%20'%5B')%20%7B%0A%20%20%20%20%20%20return%20switchInline(stream%2C%20state%2C%20inlineElement(linkhref%2C%20ch%20%3D%3D%3D%20'('%20%3F%20')'%20%3A%20'%5D'))%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20'error'%3B%0A%20%20%7D%0A%0A%20%20function%20footnoteLink(stream%2C%20state)%20%7B%0A%20%20%20%20if%20(stream.match(%2F%5E%5B%5E%5C%5D%5D*%5C%5D%3A%2F%2C%20true))%20%7B%0A%20%20%20%20%20%20state.f%20%3D%20footnoteUrl%3B%0A%20%20%20%20%20%20return%20linktext%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20switchInline(stream%2C%20state%2C%20inlineNormal)%3B%0A%20%20%7D%0A%0A%20%20function%20footnoteUrl(stream%2C%20state)%20%7B%0A%20%20%20%20%2F%2F%20Check%20if%20space%2C%20and%20return%20NULL%20if%20so%20(to%20avoid%20marking%20the%20space)%0A%20%20%20%20if(stream.eatSpace())%7B%0A%20%20%20%20%20%20return%20null%3B%0A%20%20%20%20%7D%0A%20%20%20%20%2F%2F%20Match%20URL%0A%20%20%20%20stream.match(%2F%5E%5B%5E%5Cs%5D%2B%2F%2C%20true)%3B%0A%20%20%20%20%2F%2F%20Check%20for%20link%20title%0A%20%20%20%20if%20(stream.peek()%20%3D%3D%3D%20undefined)%20%7B%20%2F%2F%20End%20of%20line%2C%20set%20flag%20to%20check%20next%20line%0A%20%20%20%20%20%20state.linkTitle%20%3D%20true%3B%0A%20%20%20%20%7D%20else%20%7B%20%2F%2F%20More%20content%20on%20line%2C%20check%20if%20link%20title%0A%20%20%20%20%20%20stream.match(%2F%5E(%3F%3A%5Cs%2B(%3F%3A%22(%3F%3A%5B%5E%22%5C%5C%5D%7C%5C%5C%5C%5C%7C%5C%5C.)%2B%22%7C'(%3F%3A%5B%5E'%5C%5C%5D%7C%5C%5C%5C%5C%7C%5C%5C.)%2B'%7C%5C((%3F%3A%5B%5E)%5C%5C%5D%7C%5C%5C%5C%5C%7C%5C%5C.)%2B%5C)))%3F%2F%2C%20true)%3B%0A%20%20%20%20%7D%0A%20%20%20%20state.f%20%3D%20state.inline%20%3D%20inlineNormal%3B%0A%20%20%20%20return%20linkhref%3B%0A%20%20%7D%0A%0A%20%20function%20inlineRE(endChar)%20%7B%0A%20%20%20%20if%20(!inlineRE%5BendChar%5D)%20%7B%0A%20%20%20%20%20%20%2F%2F%20Escape%20endChar%20for%20RegExp%20(taken%20from%20http%3A%2F%2Fstackoverflow.com%2Fa%2F494122%2F526741)%0A%20%20%20%20%20%20endChar%20%3D%20(endChar%2B'').replace(%2F(%5B.%3F*%2B%5E%24%5B%5C%5D%5C%5C()%7B%7D%7C-%5D)%2Fg%2C%20%22%5C%5C%241%22)%3B%0A%20%20%20%20%20%20%2F%2F%20Match%20any%20non-endChar%2C%20escaped%20character%2C%20as%20well%20as%20the%20closing%20%0A%20%20%20%20%20%20%2F%2F%20endChar.%0A%20%20%20%20%20%20inlineRE%5BendChar%5D%20%3D%20new%20RegExp('%5E(%3F%3A%5B%5E%5C%5C%5C%5C%5D%2B%3F%7C%5C%5C%5C%5C.)*%3F('%20%2B%20endChar%20%2B%20')')%3B%0A%20%20%20%20%7D%0A%20%20%20%20return%20inlineRE%5BendChar%5D%3B%0A%20%20%7D%0A%0A%20%20function%20inlineElement(type%2C%20endChar%2C%20next)%20%7B%0A%20%20%20%20next%20%3D%20next%20%7C%7C%20inlineNormal%3B%0A%20%20%20%20return%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20stream.match(inlineRE(endChar))%3B%0A%20%20%20%20%20%20state.inline%20%3D%20state.f%20%3D%20next%3B%0A%20%20%20%20%20%20return%20type%3B%0A%20%20%20%20%7D%3B%0A%20%20%7D%0A%0A%20%20return%20%7B%0A%20%20%20%20startState%3A%20function()%20%7B%0A%20%20%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%20%20f%3A%20blockNormal%2C%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20block%3A%20blockNormal%2C%0A%20%20%20%20%20%20%20%20htmlState%3A%20CodeMirror.startState(htmlMode)%2C%0A%20%20%20%20%20%20%20%20indentation%3A%200%2C%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20inline%3A%20inlineNormal%2C%0A%20%20%20%20%20%20%20%20text%3A%20handleText%2C%0A%20%20%20%20%20%20%20%20linkTitle%3A%20false%2C%0A%20%20%20%20%20%20%20%20em%3A%20false%2C%0A%20%20%20%20%20%20%20%20strong%3A%20false%2C%0A%20%20%20%20%20%20%20%20header%3A%20false%2C%0A%20%20%20%20%20%20%20%20list%3A%20false%2C%0A%20%20%20%20%20%20%20%20quote%3A%20false%0A%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20copyState%3A%20function(s)%20%7B%0A%20%20%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%20%20f%3A%20s.f%2C%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20block%3A%20s.block%2C%0A%20%20%20%20%20%20%20%20htmlState%3A%20CodeMirror.copyState(htmlMode%2C%20s.htmlState)%2C%0A%20%20%20%20%20%20%20%20indentation%3A%20s.indentation%2C%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20inline%3A%20s.inline%2C%0A%20%20%20%20%20%20%20%20text%3A%20s.text%2C%0A%20%20%20%20%20%20%20%20linkTitle%3A%20s.linkTitle%2C%0A%20%20%20%20%20%20%20%20em%3A%20s.em%2C%0A%20%20%20%20%20%20%20%20strong%3A%20s.strong%2C%0A%20%20%20%20%20%20%20%20header%3A%20s.header%2C%0A%20%20%20%20%20%20%20%20list%3A%20s.list%2C%0A%20%20%20%20%20%20%20%20quote%3A%20s.quote%2C%0A%20%20%20%20%20%20%20%20md_inside%3A%20s.md_inside%0A%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20token%3A%20function(stream%2C%20state)%20%7B%0A%20%20%20%20%20%20if%20(stream.sol())%20%7B%0A%20%20%20%20%20%20%20%20if%20(stream.match(%2F%5E%5Cs*%24%2F%2C%20true))%20%7B%0A%20%20%20%20%20%20%20%20%20%20prevLineHasContent%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20return%20blankLine(state)%3B%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20if(thisLineHasContent)%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20prevLineHasContent%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20thisLineHasContent%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20thisLineHasContent%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20Reset%20state.header%0A%20%20%20%20%20%20%20%20state.header%20%3D%20false%3B%0A%0A%20%20%20%20%20%20%20%20state.f%20%3D%20state.block%3B%0A%20%20%20%20%20%20%20%20var%20indentation%20%3D%20stream.match(%2F%5E%5Cs*%2F%2C%20true)%5B0%5D.replace(%2F%5Ct%2Fg%2C%20'%20%20%20%20').length%3B%0A%20%20%20%20%20%20%20%20state.indentationDiff%20%3D%20indentation%20-%20state.indentation%3B%0A%20%20%20%20%20%20%20%20state.indentation%20%3D%20indentation%3B%0A%20%20%20%20%20%20%20%20if%20(indentation%20%3E%200)%20%7B%20return%20null%3B%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20state.f(stream%2C%20state)%3B%0A%20%20%20%20%7D%2C%0A%0A%20%20%20%20blankLine%3A%20blankLine%2C%0A%0A%20%20%20%20getType%3A%20getType%0A%20%20%7D%3B%0A%0A%7D%2C%20%22xml%22)%3B%0A%0ACodeMirror.defineMIME(%22text%2Fx-markdown%22%2C%20%22markdown%22)%3B%0A%20%20%20%20%3C%2Fscript%3E%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%3C%2Fhead%3E%0A%20%20%3Cbody%3E%0A%20%20%20%20%3Cdiv%20id%3D%22editor%22%3E%3C%2Fdiv%3E%0A%20%20%20%20%3Cp%3E%0A%20%20%20%20%20%20Local%3A%0A%20%20%20%20%20%20%3Cinput%20type%3D%22file%22%20onchange%3D%22localLoad(this.files)%3B%22%20%2F%3E%0A%20%20%20%20%20%20%3Cinput%20type%3D%22submit%22%20value%3D%22save%22%20onclick%3D%22window.open(localSave())%3B%22%3E%0A%20%20%20%20%20%20%7C%0A%20%20%20%20%20%20%3Cinput%20type%3D%22submit%22%20value%3D%22js%22%20onclick%3D%22myCodeMirror.setOption('mode'%2C%20'javascript')%3B%22%3E%0A%20%20%20%20%20%20%3Cinput%20type%3D%22submit%22%20value%3D%22html%22%20onclick%3D%22myCodeMirror.setOption('mode'%2C%20'htmlmixed')%3B%22%3E%0A%20%20%20%20%20%20%3Cinput%20type%3D%22submit%22%20value%3D%22markdown%22%20onclick%3D%22myCodeMirror.setOption('mode'%2C%20'markdown')%3B%22%3E%0A%20%20%20%20%3C%2Fp%3E%0A%20%0A%20%20%3C%2Fbody%3E%0A%20%20%3Cscript%3E%0A%20%20%20%20%0A%20%20%20%20%2F%2FCODE%20MIRROR%0A%20%20%20%20var%20myCodeMirror%20%3D%20CodeMirror(document.getElementById('editor')%2C%20%7B%0A%20%20%20%20%20%20lineNumbers%3A%20true%0A%20%20%20%20%7D)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%2F%2FLOCAL%0A%20%20%20%20function%20localSave()%20%7B%0A%20%20%20%20%20%20return%20'data%3Atext%2Fplain%3Bcharset%3Dutf-8%2C'%2BencodeURIComponent(myCodeMirror.getValue())%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20function%20localLoad(files)%20%7B%0A%20%20%20%20%20%20if(files.length%20%3D%3D%201)%20%7B%0A%20%20%20%20%20%20%20%20document.title%3Descape(files%5B0%5D.name)%3B%0A%20%20%20%20%20%20%20%20var%20reader%20%3D%20new%20FileReader()%3B%0A%20%20%20%20%20%20%20%20reader.onload%20%3D%20function(e)%20%7B%0A%20%20%20%20%20%20%20%20%20%20myCodeMirror.setValue(e.target.result)%3B%0A%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20%20%20reader.readAsText(files%5B0%5D)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%3C%2Fscript%3E%0A%3C%2Fhtml%3E"
target="_blank">unhosted editor</a>. So by bookmarking that, or saving it to your filesystem, you will always be able to edit files in your
browser, whether online or offline. I am using this editor right now to write this blogpost, and I will use it to write all other apps, scripts and
texts that
come up in the coming weeks. It is a good idea to save one working version which you don't touch, so that if you break your editor while editing it,
you have
a way to bootstrap back into your editor-editing world. :)</p>
<p>That's it for this week. We have created the first unhosted web app of this blog series, and we will be using it as the development environment
to create
all other apps, as well as all server-side scripts in the coming episodes. I hope you liked it. If you did, then please share it with your
friends and followers. Next week we'll discuss how to set up your own personal server.</p>
<p><a href="https://groups.google.com/d/topic/unhosted/ANz3ofSyfmc/discussion">Comments welcome!</a></p>