Version Description
- CodeMirror library updated to the latest version v5.38.0. The directory structure is changed (files are better organized). Added a test files for the CodeMirror modes.
- Updated the method of loading the modes and addons of the CodeMirror library.
Download this release
Release Info
Developer | Arthur Gareginyan |
Plugin | My Custom Functions |
Version | 4.19 |
Comparing to | |
See all releases |
Code changes from version 4.18 to 4.19
- inc/lib/codemirror/AUTHORS +748 -0
- inc/lib/codemirror/CHANGELOG.md +1412 -0
- inc/lib/codemirror/CONTRIBUTING.md +92 -0
- inc/lib/codemirror/LICENSE +3 -1
- inc/lib/codemirror/README.md +44 -7
- inc/lib/codemirror/{addons → addon/selection}/active-line.js +11 -13
- inc/lib/codemirror/codemirror-compressed.js +0 -23
- inc/lib/codemirror/{codemirror.css → lib/codemirror.css} +70 -49
- inc/lib/codemirror/lib/codemirror.js +9685 -0
- inc/lib/codemirror/mode/clike/clike.js +823 -0
- inc/lib/codemirror/mode/clike/index.html +360 -0
- inc/lib/codemirror/mode/clike/scala.html +767 -0
- inc/lib/codemirror/mode/clike/test.js +69 -0
- inc/lib/codemirror/mode/css/css.js +832 -0
- inc/lib/codemirror/mode/css/gss.html +103 -0
- inc/lib/codemirror/mode/css/gss_test.js +17 -0
- inc/lib/codemirror/mode/css/index.html +75 -0
- inc/lib/codemirror/mode/css/less.html +152 -0
- inc/lib/codemirror/mode/css/less_test.js +54 -0
- inc/lib/codemirror/mode/css/scss.html +157 -0
- inc/lib/codemirror/mode/css/scss_test.js +110 -0
- inc/lib/codemirror/mode/css/test.js +209 -0
- inc/lib/codemirror/mode/htmlmixed/htmlmixed.js +152 -0
- inc/lib/codemirror/mode/htmlmixed/index.html +100 -0
- inc/lib/codemirror/mode/index.html +165 -0
- inc/lib/codemirror/mode/javascript/index.html +114 -0
- inc/lib/codemirror/mode/javascript/javascript.js +896 -0
- inc/lib/codemirror/mode/javascript/json-ld.html +72 -0
- inc/lib/codemirror/mode/javascript/test.js +482 -0
- inc/lib/codemirror/mode/javascript/typescript.html +61 -0
- inc/lib/codemirror/mode/meta.js +217 -0
- inc/lib/codemirror/mode/php/index.html +64 -0
- inc/lib/codemirror/mode/php/php.js +234 -0
- inc/lib/codemirror/mode/php/test.js +154 -0
- inc/lib/codemirror/mode/xml/index.html +61 -0
- inc/lib/codemirror/mode/xml/test.js +51 -0
- inc/lib/codemirror/mode/xml/xml.js +401 -0
- inc/lib/codemirror/package.json +49 -0
- inc/php/enqueue.php +10 -3
- my-custom-functions.php +1 -1
- readme.txt +6 -2
inc/lib/codemirror/AUTHORS
ADDED
@@ -0,0 +1,748 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
List of CodeMirror contributors. Updated before every release.
|
2 |
+
|
3 |
+
4oo4
|
4 |
+
4r2r
|
5 |
+
Aaron Brooks
|
6 |
+
Abdelouahab
|
7 |
+
Abe Fettig
|
8 |
+
Adam Ahmed
|
9 |
+
Adam King
|
10 |
+
Adam Particka
|
11 |
+
adanlobato
|
12 |
+
Adán Lobato
|
13 |
+
Adrian Aichner
|
14 |
+
Adrian Heine
|
15 |
+
Adrien Bertrand
|
16 |
+
aeroson
|
17 |
+
Ahmad Amireh
|
18 |
+
Ahmad M. Zawawi
|
19 |
+
ahoward
|
20 |
+
Akeksandr Motsjonov
|
21 |
+
Alasdair Smith
|
22 |
+
Alberto González Palomo
|
23 |
+
Alberto Pose
|
24 |
+
Albert Xing
|
25 |
+
Alexander Pavlov
|
26 |
+
Alexander Schepanovski
|
27 |
+
Alexander Shvets
|
28 |
+
Alexander Solovyov
|
29 |
+
Alexandre Bique
|
30 |
+
alexey-k
|
31 |
+
Alex Piggott
|
32 |
+
Aliaksei Chapyzhenka
|
33 |
+
Allen Sarkisyan
|
34 |
+
Ami Fischman
|
35 |
+
Amin Shali
|
36 |
+
Amin Ullah Khan
|
37 |
+
amshali@google.com
|
38 |
+
Amsul
|
39 |
+
amuntean
|
40 |
+
Amy
|
41 |
+
Ananya Sen
|
42 |
+
anaran
|
43 |
+
AndersMad
|
44 |
+
Anders Nawroth
|
45 |
+
Anderson Mesquita
|
46 |
+
Anders Wåglund
|
47 |
+
Andrea G
|
48 |
+
Andreas Reischuck
|
49 |
+
Andres Taylor
|
50 |
+
Andre von Houck
|
51 |
+
Andrew Cheng
|
52 |
+
Andrew Dassonville
|
53 |
+
Andrey Fedorov
|
54 |
+
Andrey Klyuchnikov
|
55 |
+
Andrey Lushnikov
|
56 |
+
Andrey Shchekin
|
57 |
+
Andy Joslin
|
58 |
+
Andy Kimball
|
59 |
+
Andy Li
|
60 |
+
Angelo
|
61 |
+
angelozerr
|
62 |
+
angelo.zerr@gmail.com
|
63 |
+
Ankit
|
64 |
+
Ankit Ahuja
|
65 |
+
Ansel Santosa
|
66 |
+
Anthony Dugois
|
67 |
+
anthonygego
|
68 |
+
Anthony Gégo
|
69 |
+
Anthony Grimes
|
70 |
+
Anton Kovalyov
|
71 |
+
Apollo Zhu
|
72 |
+
AQNOUCH Mohammed
|
73 |
+
Aram Shatakhtsyan
|
74 |
+
areos
|
75 |
+
Arnab Bose
|
76 |
+
Arsène von Wyss
|
77 |
+
Arthur Müller
|
78 |
+
Arun Narasani
|
79 |
+
as3boyan
|
80 |
+
asolove
|
81 |
+
atelierbram
|
82 |
+
AtomicPages LLC
|
83 |
+
Atul Bhouraskar
|
84 |
+
Aurelian Oancea
|
85 |
+
Axel Lewenhaupt
|
86 |
+
Barret Rennie
|
87 |
+
Basarat Ali Syed
|
88 |
+
Bastian Müller
|
89 |
+
belhaj
|
90 |
+
Bem Jones-Bey
|
91 |
+
benbro
|
92 |
+
Beni Cherniavsky-Paskin
|
93 |
+
Benjamin DeCoste
|
94 |
+
Benjamin Young
|
95 |
+
Ben Keen
|
96 |
+
Ben Miller
|
97 |
+
Ben Mosher
|
98 |
+
Bernhard Sirlinger
|
99 |
+
Bert Chang
|
100 |
+
Bharad
|
101 |
+
BigBlueHat
|
102 |
+
Billy Moon
|
103 |
+
binny
|
104 |
+
B Krishna Chaitanya
|
105 |
+
Blaine G
|
106 |
+
blukat29
|
107 |
+
Bo
|
108 |
+
boomyjee
|
109 |
+
Bo Peng
|
110 |
+
borawjm
|
111 |
+
Brad Metcalf
|
112 |
+
Brandon Frohs
|
113 |
+
Brandon Wamboldt
|
114 |
+
Bret Little
|
115 |
+
Brett Zamir
|
116 |
+
Brian Grinstead
|
117 |
+
Brian Sletten
|
118 |
+
brrd
|
119 |
+
Bruce Mitchener
|
120 |
+
Bryan Massoth
|
121 |
+
Caitlin Potter
|
122 |
+
Calin Barbat
|
123 |
+
callodacity
|
124 |
+
Camilo Roca
|
125 |
+
Casey Klebba
|
126 |
+
César González Íñiguez
|
127 |
+
Chad Jolly
|
128 |
+
Chandra Sekhar Pydi
|
129 |
+
Charles Skelton
|
130 |
+
Cheah Chu Yeow
|
131 |
+
Chris Coyier
|
132 |
+
Chris Ford
|
133 |
+
Chris Granger
|
134 |
+
Chris Houseknecht
|
135 |
+
Chris Lohfink
|
136 |
+
Chris Morgan
|
137 |
+
Chris Reeves
|
138 |
+
Chris Smith
|
139 |
+
Christian Gruen
|
140 |
+
Christian Oyarzun
|
141 |
+
Christian Petrov
|
142 |
+
christopherblaser
|
143 |
+
Christopher Brown
|
144 |
+
Christopher Kramer
|
145 |
+
Christopher Mitchell
|
146 |
+
Christopher Pfohl
|
147 |
+
Chunliang Lyu
|
148 |
+
ciaranj
|
149 |
+
CodeAnimal
|
150 |
+
CodeBitt
|
151 |
+
coderaiser
|
152 |
+
Cole R Lawrence
|
153 |
+
ComFreek
|
154 |
+
Cristian Prieto
|
155 |
+
Curtis Gagliardi
|
156 |
+
dagsta
|
157 |
+
daines
|
158 |
+
Dale Jung
|
159 |
+
Dan Bentley
|
160 |
+
Dan Heberden
|
161 |
+
Daniel, Dao Quang Minh
|
162 |
+
Daniele Di Sarli
|
163 |
+
Daniel Faust
|
164 |
+
Daniel Huigens
|
165 |
+
Daniel Kesler
|
166 |
+
Daniel KJ
|
167 |
+
Daniel Neel
|
168 |
+
Daniel Parnell
|
169 |
+
Daniel Thwaites
|
170 |
+
Danila Malyutin
|
171 |
+
Danny Yoo
|
172 |
+
darealshinji
|
173 |
+
Darius Roberts
|
174 |
+
Dave Brondsema
|
175 |
+
Dave Myers
|
176 |
+
David Barnett
|
177 |
+
David H. Bronke
|
178 |
+
David Mignot
|
179 |
+
David Pathakjee
|
180 |
+
David Vázquez
|
181 |
+
David Whittington
|
182 |
+
deebugger
|
183 |
+
Deep Thought
|
184 |
+
Devin Abbott
|
185 |
+
Devon Carew
|
186 |
+
Dick Choi
|
187 |
+
dignifiedquire
|
188 |
+
Dimage Sapelkin
|
189 |
+
Dmitry Kiselyov
|
190 |
+
domagoj412
|
191 |
+
Dominator008
|
192 |
+
Domizio Demichelis
|
193 |
+
Doug Wikle
|
194 |
+
Drew Bratcher
|
195 |
+
Drew Hintz
|
196 |
+
Drew Khoury
|
197 |
+
Drini Cami
|
198 |
+
Dror BG
|
199 |
+
duralog
|
200 |
+
dwelle
|
201 |
+
eborden
|
202 |
+
edsharp
|
203 |
+
ekhaled
|
204 |
+
Elisée
|
205 |
+
Emmanuel Schanzer
|
206 |
+
Enam Mijbah Noor
|
207 |
+
Eric Allam
|
208 |
+
Eric Bogard
|
209 |
+
Erik Welander
|
210 |
+
eustas
|
211 |
+
Fabien Dubosson
|
212 |
+
Fabien O'Carroll
|
213 |
+
Fabio Zendhi Nagao
|
214 |
+
Faiza Alsaied
|
215 |
+
Fauntleroy
|
216 |
+
fbuchinger
|
217 |
+
feizhang365
|
218 |
+
Felipe Lalanne
|
219 |
+
Felix Raab
|
220 |
+
ficristo
|
221 |
+
Filip Noetzel
|
222 |
+
Filip Stollár
|
223 |
+
Filype Pereira
|
224 |
+
flack
|
225 |
+
Florian Felten
|
226 |
+
ForbesLindesay
|
227 |
+
Forbes Lindesay
|
228 |
+
Ford_Lawnmower
|
229 |
+
Forrest Oliphant
|
230 |
+
Franco Catena
|
231 |
+
Frank Wiegand
|
232 |
+
Fredrik Borg
|
233 |
+
Gabriel Gheorghian
|
234 |
+
Gabriel Horner
|
235 |
+
Gabriel Nahmias
|
236 |
+
galambalazs
|
237 |
+
Gary Sheng
|
238 |
+
Gautam Mehta
|
239 |
+
Gavin Douglas
|
240 |
+
gekkoe
|
241 |
+
Geordie Hall
|
242 |
+
George Stephanis
|
243 |
+
geowarin
|
244 |
+
Gerard Braad
|
245 |
+
Gergely Hegykozi
|
246 |
+
Giovanni Calò
|
247 |
+
Glebov Boris
|
248 |
+
Glenn Jorde
|
249 |
+
Glenn Ruehle
|
250 |
+
goldsmcb
|
251 |
+
Golevka
|
252 |
+
Google Inc.
|
253 |
+
Gordon Smith
|
254 |
+
Grant Skinner
|
255 |
+
greengiant
|
256 |
+
Gregory Koberger
|
257 |
+
Grzegorz Mazur
|
258 |
+
Guan Gui
|
259 |
+
Guillaume Massé
|
260 |
+
Guillaume Massé
|
261 |
+
guraga
|
262 |
+
Gustavo Rodrigues
|
263 |
+
Hakan Tunc
|
264 |
+
Hans Engel
|
265 |
+
Hardest
|
266 |
+
Harshvardhan Gupta
|
267 |
+
Hasan Karahan
|
268 |
+
Heanes
|
269 |
+
Hector Oswaldo Caballero
|
270 |
+
Hélio
|
271 |
+
Hendrik Wallbaum
|
272 |
+
Henrik Haugbølle
|
273 |
+
Herculano Campos
|
274 |
+
hidaiy
|
275 |
+
Hiroyuki Makino
|
276 |
+
hitsthings
|
277 |
+
Hocdoc
|
278 |
+
Hugues Malphettes
|
279 |
+
Ian Beck
|
280 |
+
Ian Davies
|
281 |
+
Ian Dickinson
|
282 |
+
Ian Rose
|
283 |
+
Ian Wehrman
|
284 |
+
Ian Wetherbee
|
285 |
+
Ice White
|
286 |
+
ICHIKAWA, Yuji
|
287 |
+
idleberg
|
288 |
+
ilvalle
|
289 |
+
Ingo Richter
|
290 |
+
Irakli Gozalishvili
|
291 |
+
Ivan Kurnosov
|
292 |
+
Ivoah
|
293 |
+
Jacob Lee
|
294 |
+
Jaimin
|
295 |
+
Jake Peyser
|
296 |
+
Jakob Miland
|
297 |
+
Jakub Vrana
|
298 |
+
Jakub Vrána
|
299 |
+
James Campos
|
300 |
+
James Howard
|
301 |
+
James Thorne
|
302 |
+
Jamie Hill
|
303 |
+
Jamie Morris
|
304 |
+
Jan Jongboom
|
305 |
+
jankeromnes
|
306 |
+
Jan Keromnes
|
307 |
+
Jan Odvarko
|
308 |
+
Jan Schär
|
309 |
+
Jan T. Sott
|
310 |
+
Jared Dean
|
311 |
+
Jared Forsyth
|
312 |
+
Jared Jacobs
|
313 |
+
Jason
|
314 |
+
Jason Barnabe
|
315 |
+
Jason Grout
|
316 |
+
Jason Johnston
|
317 |
+
Jason San Jose
|
318 |
+
Jason Siefken
|
319 |
+
Jayaprabhakar
|
320 |
+
Jaydeep Solanki
|
321 |
+
Jean Boussier
|
322 |
+
Jeff Blaisdell
|
323 |
+
Jeff Hanke
|
324 |
+
Jeff Jenkins
|
325 |
+
jeffkenton
|
326 |
+
Jeff Pickhardt
|
327 |
+
jem (graphite)
|
328 |
+
Jeremy Parmenter
|
329 |
+
Jim
|
330 |
+
Jim Avery
|
331 |
+
jkaplon
|
332 |
+
JobJob
|
333 |
+
jochenberger
|
334 |
+
Jochen Berger
|
335 |
+
Joel Einbinder
|
336 |
+
joelpinheiro
|
337 |
+
Johan Ask
|
338 |
+
John Connor
|
339 |
+
John-David Dalton
|
340 |
+
John Engler
|
341 |
+
John Lees-Miller
|
342 |
+
John Snelson
|
343 |
+
John Van Der Loo
|
344 |
+
Jon Ander Peñalba
|
345 |
+
Jonas Döbertin
|
346 |
+
Jonas Helfer
|
347 |
+
Jonathan Hart
|
348 |
+
Jonathan Malmaud
|
349 |
+
Jon Gacnik
|
350 |
+
jongalloway
|
351 |
+
Jon Malmaud
|
352 |
+
Jon Sangster
|
353 |
+
Joost-Wim Boekesteijn
|
354 |
+
Joseph Pecoraro
|
355 |
+
Josh Barnes
|
356 |
+
Josh Cohen
|
357 |
+
Josh Soref
|
358 |
+
Joshua Newman
|
359 |
+
Josh Watzman
|
360 |
+
jots
|
361 |
+
jsoojeon
|
362 |
+
ju1ius
|
363 |
+
Juan Benavides Romero
|
364 |
+
Jucovschi Constantin
|
365 |
+
Juho Vuori
|
366 |
+
Julien CROUZET
|
367 |
+
Julien Rebetez
|
368 |
+
Justin Andresen
|
369 |
+
Justin Hileman
|
370 |
+
jwallers@gmail.com
|
371 |
+
kaniga
|
372 |
+
karevn
|
373 |
+
Karol
|
374 |
+
Kayur Patel
|
375 |
+
Kazuhito Hokamura
|
376 |
+
Ken Newman
|
377 |
+
ken restivo
|
378 |
+
Ken Rockot
|
379 |
+
Kevin Earls
|
380 |
+
Kevin Kwok
|
381 |
+
Kevin Muret
|
382 |
+
Kevin Sawicki
|
383 |
+
Kevin Ushey
|
384 |
+
Klaus Silveira
|
385 |
+
Koh Zi Han, Cliff
|
386 |
+
komakino
|
387 |
+
Konstantin Lopuhin
|
388 |
+
koops
|
389 |
+
Kris Ciccarello
|
390 |
+
ks-ifware
|
391 |
+
kubelsmieci
|
392 |
+
KwanEsq
|
393 |
+
Kyle Kelley
|
394 |
+
KyleMcNutt
|
395 |
+
Lanfei
|
396 |
+
Lanny
|
397 |
+
Laszlo Vidacs
|
398 |
+
leaf corcoran
|
399 |
+
Lemmon
|
400 |
+
Leonid Khachaturov
|
401 |
+
Leon Sorokin
|
402 |
+
Leonya Khachaturov
|
403 |
+
Liam Newman
|
404 |
+
Libo Cannici
|
405 |
+
Lior Goldberg
|
406 |
+
Lior Shub
|
407 |
+
LloydMilligan
|
408 |
+
LM
|
409 |
+
lochel
|
410 |
+
Lorenzo Stoakes
|
411 |
+
Louis Mauchet
|
412 |
+
Luca Fabbri
|
413 |
+
Luciano Longo
|
414 |
+
Lu Fangjian
|
415 |
+
Luke Browning
|
416 |
+
Luke Granger-Brown
|
417 |
+
Luke Stagner
|
418 |
+
lynschinzer
|
419 |
+
M1cha
|
420 |
+
Madhura Jayaratne
|
421 |
+
Maksim Lin
|
422 |
+
Maksym Taran
|
423 |
+
Malay Majithia
|
424 |
+
Manideep
|
425 |
+
Manuel Rego Casasnovas
|
426 |
+
Marat Dreizin
|
427 |
+
Marcel Gerber
|
428 |
+
Marcelo Camargo
|
429 |
+
Marco Aurélio
|
430 |
+
Marco Munizaga
|
431 |
+
Marcus Bointon
|
432 |
+
Marek Rudnicki
|
433 |
+
Marijn Haverbeke
|
434 |
+
Mário Gonçalves
|
435 |
+
Mario Pietsch
|
436 |
+
Mark Anderson
|
437 |
+
Mark Lentczner
|
438 |
+
Marko Bonaci
|
439 |
+
Mark Peace
|
440 |
+
Markus Bordihn
|
441 |
+
Markus Olsson
|
442 |
+
Martin Balek
|
443 |
+
Martín Gaitán
|
444 |
+
Martin Hasoň
|
445 |
+
Martin Hunt
|
446 |
+
Martin Laine
|
447 |
+
Martin Zagora
|
448 |
+
Mason Malone
|
449 |
+
Mateusz Paprocki
|
450 |
+
Mathias Bynens
|
451 |
+
mats cronqvist
|
452 |
+
Matt Gaide
|
453 |
+
Matthew Bauer
|
454 |
+
Matthew Beale
|
455 |
+
matthewhayes
|
456 |
+
Matthew Rathbone
|
457 |
+
Matthias Bussonnier
|
458 |
+
Matthias BUSSONNIER
|
459 |
+
Matt MacPherson
|
460 |
+
Matt McDonald
|
461 |
+
Matt Pass
|
462 |
+
Matt Sacks
|
463 |
+
mauricio
|
464 |
+
Maximilian Hils
|
465 |
+
Maxim Kraev
|
466 |
+
Max Kirsch
|
467 |
+
Max Schaefer
|
468 |
+
Max Xiantu
|
469 |
+
mbarkhau
|
470 |
+
McBrainy
|
471 |
+
mce2
|
472 |
+
melpon
|
473 |
+
meshuamam
|
474 |
+
Metatheos
|
475 |
+
Micah Dubinko
|
476 |
+
Michael
|
477 |
+
Michael Goderbauer
|
478 |
+
Michael Grey
|
479 |
+
Michael Kaminsky
|
480 |
+
Michael Lehenbauer
|
481 |
+
Michael Walker
|
482 |
+
Michael Zhou
|
483 |
+
Michal Čihař
|
484 |
+
Michal Dorner
|
485 |
+
Michal Kapiczynski
|
486 |
+
Mighty Guava
|
487 |
+
Miguel Castillo
|
488 |
+
mihailik
|
489 |
+
Mike
|
490 |
+
Mike Brevoort
|
491 |
+
Mike Diaz
|
492 |
+
Mike Ivanov
|
493 |
+
Mike Kadin
|
494 |
+
Mike Kobit
|
495 |
+
Milan Szekely
|
496 |
+
MinRK
|
497 |
+
Miraculix87
|
498 |
+
misfo
|
499 |
+
mkaminsky11
|
500 |
+
mloginov
|
501 |
+
Moritz Schubotz (physikerwelt)
|
502 |
+
Moritz Schwörer
|
503 |
+
Moshe Wajnberg
|
504 |
+
mps
|
505 |
+
ms
|
506 |
+
mtaran-google
|
507 |
+
Mu-An Chiou
|
508 |
+
Mu-An ✌️ Chiou
|
509 |
+
mzabuawala
|
510 |
+
Narciso Jaramillo
|
511 |
+
Nathan Williams
|
512 |
+
ndr
|
513 |
+
Neil Anderson
|
514 |
+
neon-dev
|
515 |
+
nerbert
|
516 |
+
NetworkNode
|
517 |
+
nextrevision
|
518 |
+
ngn
|
519 |
+
nguillaumin
|
520 |
+
Ng Zhi An
|
521 |
+
Nicholas Bollweg
|
522 |
+
Nicholas Bollweg (Nick)
|
523 |
+
NickKolok
|
524 |
+
Nick Kreeger
|
525 |
+
Nick Small
|
526 |
+
Nicolas Kick
|
527 |
+
Nicolò Ribaudo
|
528 |
+
Niels van Groningen
|
529 |
+
nightwing
|
530 |
+
Nikita Beloglazov
|
531 |
+
Nikita Vasilyev
|
532 |
+
Nikolay Kostov
|
533 |
+
nilp0inter
|
534 |
+
Nisarg Jhaveri
|
535 |
+
nlwillia
|
536 |
+
noragrossman
|
537 |
+
Norman Rzepka
|
538 |
+
opl-
|
539 |
+
Oreoluwa Onatemowo
|
540 |
+
Oskar Segersvärd
|
541 |
+
overdodactyl
|
542 |
+
pablo
|
543 |
+
pabloferz
|
544 |
+
Pablo Zubieta
|
545 |
+
paddya
|
546 |
+
Page
|
547 |
+
paladox
|
548 |
+
Panupong Pasupat
|
549 |
+
paris
|
550 |
+
Paris
|
551 |
+
Paris Kasidiaris
|
552 |
+
Patil Arpith
|
553 |
+
Patrick Stoica
|
554 |
+
Patrick Strawderman
|
555 |
+
Paul Garvin
|
556 |
+
Paul Ivanov
|
557 |
+
Paul Masson
|
558 |
+
Pavel
|
559 |
+
Pavel Feldman
|
560 |
+
Pavel Petržela
|
561 |
+
Pavel Strashkin
|
562 |
+
Paweł Bartkiewicz
|
563 |
+
peteguhl
|
564 |
+
peter
|
565 |
+
Peter Flynn
|
566 |
+
peterkroon
|
567 |
+
Peter Kroon
|
568 |
+
Philipp A
|
569 |
+
Philip Stadermann
|
570 |
+
Pi Delport
|
571 |
+
Pierre Gerold
|
572 |
+
Pieter Ouwerkerk
|
573 |
+
Pontus Melke
|
574 |
+
prasanthj
|
575 |
+
Prasanth J
|
576 |
+
Prayag Verma
|
577 |
+
Prendota
|
578 |
+
Qiang Li
|
579 |
+
Radek Piórkowski
|
580 |
+
Rahul
|
581 |
+
Rahul Anand
|
582 |
+
ramwin1
|
583 |
+
Randall Mason
|
584 |
+
Randy Burden
|
585 |
+
Randy Edmunds
|
586 |
+
Randy Luecke
|
587 |
+
Raphael Amorim
|
588 |
+
Rasmus Erik Voel Jensen
|
589 |
+
Rasmus Schultz
|
590 |
+
Raymond Hill
|
591 |
+
ray ratchup
|
592 |
+
Ray Ratchup
|
593 |
+
Remi Nyborg
|
594 |
+
Renaud Durlin
|
595 |
+
Richard Denton
|
596 |
+
Richard van der Meer
|
597 |
+
Richard Z.H. Wang
|
598 |
+
Rishi Goomar
|
599 |
+
Robert Brignull
|
600 |
+
Robert Crossfield
|
601 |
+
Roberto Abdelkader Martínez Pérez
|
602 |
+
robertop23
|
603 |
+
Robert Plummer
|
604 |
+
Rrandom
|
605 |
+
Rrrandom
|
606 |
+
Ruslan Osmanov
|
607 |
+
Ryan Petrello
|
608 |
+
Ryan Prior
|
609 |
+
ryu-sato
|
610 |
+
sabaca
|
611 |
+
Sam Lee
|
612 |
+
Sam Rawlins
|
613 |
+
Samuel Ainsworth
|
614 |
+
Sam Wilson
|
615 |
+
sandeepshetty
|
616 |
+
Sander AKA Redsandro
|
617 |
+
Sander Verweij
|
618 |
+
santec
|
619 |
+
Sarah McAlear and Wenlin Zhang
|
620 |
+
Sascha Peilicke
|
621 |
+
satamas
|
622 |
+
satchmorun
|
623 |
+
sathyamoorthi
|
624 |
+
Saul Costa
|
625 |
+
S. Chris Colbert
|
626 |
+
SCLINIC\jdecker
|
627 |
+
Scott Aikin
|
628 |
+
Scott Goodhew
|
629 |
+
Sebastian Wilzbach
|
630 |
+
Sebastian Zaha
|
631 |
+
Sergey Goder
|
632 |
+
Sergey Tselovalnikov
|
633 |
+
Se-Won Kim
|
634 |
+
Shane Liesegang
|
635 |
+
shaund
|
636 |
+
shaun gilchrist
|
637 |
+
Shawn A
|
638 |
+
Shea Bunge
|
639 |
+
sheopory
|
640 |
+
Shil S
|
641 |
+
Shiv Deepak
|
642 |
+
Shmuel Englard
|
643 |
+
Shubham Jain
|
644 |
+
Siamak Mokhtari
|
645 |
+
silverwind
|
646 |
+
Simon Edwards
|
647 |
+
sinkuu
|
648 |
+
snasa
|
649 |
+
soliton4
|
650 |
+
sonson
|
651 |
+
Sorab Bisht
|
652 |
+
spastorelli
|
653 |
+
srajanpaliwal
|
654 |
+
Stanislav Oaserele
|
655 |
+
stan-z
|
656 |
+
Stas Kobzar
|
657 |
+
Stefan Borsje
|
658 |
+
Steffen Beyer
|
659 |
+
Steffen Bruchmann
|
660 |
+
Steffen Kowalski
|
661 |
+
Stephane Moore
|
662 |
+
Stephen Lavelle
|
663 |
+
Steve Champagne
|
664 |
+
Steve Hoover
|
665 |
+
Steve O'Hara
|
666 |
+
stoskov
|
667 |
+
Stu Kennedy
|
668 |
+
Sungho Kim
|
669 |
+
sverweij
|
670 |
+
Taha Jahangir
|
671 |
+
takamori
|
672 |
+
Tako Schotanus
|
673 |
+
Takuji Shimokawa
|
674 |
+
Takuya Matsuyama
|
675 |
+
Tarmil
|
676 |
+
TDaglis
|
677 |
+
tel
|
678 |
+
Tentone
|
679 |
+
tfjgeorge
|
680 |
+
Thaddee Tyl
|
681 |
+
thanasis
|
682 |
+
TheHowl
|
683 |
+
themrmax
|
684 |
+
think
|
685 |
+
Thomas Brouard
|
686 |
+
Thomas Dvornik
|
687 |
+
Thomas Kluyver
|
688 |
+
Thomas Schmid
|
689 |
+
Tim Alby
|
690 |
+
Tim Baumann
|
691 |
+
Timothy Farrell
|
692 |
+
Timothy Gu
|
693 |
+
Timothy Hatcher
|
694 |
+
Tobias Bertelsen
|
695 |
+
TobiasBg
|
696 |
+
Todd Berman
|
697 |
+
Todd Kennedy
|
698 |
+
Tomas-A
|
699 |
+
Tomas Varaneckas
|
700 |
+
Tom Erik Støwer
|
701 |
+
Tom Klancer
|
702 |
+
Tom MacWright
|
703 |
+
Tom McLaughlin
|
704 |
+
Tony Jian
|
705 |
+
tophf
|
706 |
+
totalamd
|
707 |
+
Travis Heppe
|
708 |
+
Triangle717
|
709 |
+
Tristan Tarrant
|
710 |
+
TSUYUSATO Kitsune
|
711 |
+
Tugrul Elmas
|
712 |
+
twifkak
|
713 |
+
Tyler Long
|
714 |
+
Vadzim Ramanenka
|
715 |
+
Vaibhav Sagar
|
716 |
+
VapidWorx
|
717 |
+
Vestimir Markov
|
718 |
+
vf
|
719 |
+
Victor Bocharsky
|
720 |
+
Vincent Woo
|
721 |
+
Volker Mische
|
722 |
+
vtripolitakis
|
723 |
+
Weiyan Shao
|
724 |
+
wenli
|
725 |
+
Wes Cossick
|
726 |
+
Wesley Wiser
|
727 |
+
Weston Ruter
|
728 |
+
Will Binns-Smith
|
729 |
+
Will Dean
|
730 |
+
William Jamieson
|
731 |
+
William Stein
|
732 |
+
Willy
|
733 |
+
Wojtek Ptak
|
734 |
+
wonderboyjon
|
735 |
+
Wu Cheng-Han
|
736 |
+
Xavier Mendez
|
737 |
+
Yassin N. Hassan
|
738 |
+
YNH Webdev
|
739 |
+
Yunchi Luo
|
740 |
+
Yuvi Panda
|
741 |
+
Yvonnick Esnault
|
742 |
+
Zac Anger
|
743 |
+
Zachary Dremann
|
744 |
+
Zeno Rocha
|
745 |
+
Zhang Hao
|
746 |
+
Ziv
|
747 |
+
zziuni
|
748 |
+
魏鹏刚
|
inc/lib/codemirror/CHANGELOG.md
ADDED
@@ -0,0 +1,1412 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## 5.38.0 (2018-05-21)
|
2 |
+
|
3 |
+
### Bug fixes
|
4 |
+
|
5 |
+
Improve reliability of noticing a missing mouseup event during dragging.
|
6 |
+
|
7 |
+
Make sure `getSelection` is always called on the correct document.
|
8 |
+
|
9 |
+
Fix interpretation of line breaks and non-breaking spaces inserted by renderer in contentEditable mode.
|
10 |
+
|
11 |
+
Work around some browsers inexplicably making the fake scrollbars focusable.
|
12 |
+
|
13 |
+
Make sure `coordsChar` doesn't return positions inside collapsed ranges.
|
14 |
+
|
15 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Support block scopes, bindingless catch, bignum suffix, `s` regexp flag.
|
16 |
+
|
17 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Adjust a wasteful regexp.
|
18 |
+
|
19 |
+
[show-hint addon](http://codemirror.net/doc/manual.html#addon_show-hint): Allow opening the control without any item selected.
|
20 |
+
|
21 |
+
### New features
|
22 |
+
|
23 |
+
New theme: [darcula](http://codemirror.net/demo/theme.html#darcula).
|
24 |
+
|
25 |
+
[dialog addon](http://codemirror.net/doc/manual.html#addon_dialog): Add a CSS class (`dialog-opened`) to the editor when a dialog is open.
|
26 |
+
|
27 |
+
## 5.37.0 (2018-04-20)
|
28 |
+
|
29 |
+
### Bug fixes
|
30 |
+
|
31 |
+
Suppress keypress events during composition, for platforms that don't properly do this themselves.
|
32 |
+
|
33 |
+
[xml-fold addon](http://codemirror.net/demo/folding.html): Improve handling of line-wrapped opening tags.
|
34 |
+
|
35 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Improve TypeScript support.
|
36 |
+
|
37 |
+
[python mode](http://codemirror.net/mode/python/): Highlight expressions inside format strings.
|
38 |
+
|
39 |
+
### New features
|
40 |
+
|
41 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Add support for '(' and ')' movement.
|
42 |
+
|
43 |
+
New themes: [idea](http://codemirror.net/demo/theme.html#idea), [ssms](http://codemirror.net/demo/theme.html#ssms), [gruvbox-dark](http://codemirror.net/demo/theme.html#gruvbox-dark).
|
44 |
+
|
45 |
+
## 5.36.0 (2018-03-20)
|
46 |
+
|
47 |
+
### Bug fixes
|
48 |
+
|
49 |
+
Make sure all document-level event handlers are registered on the document that the editor is part of.
|
50 |
+
|
51 |
+
Fix issue that prevented edits whose origin starts with `+` from being combined in history events for an editor-less document.
|
52 |
+
|
53 |
+
[multiplex addon](http://codemirror.net/demo/multiplex.html): Improve handling of indentation.
|
54 |
+
|
55 |
+
[merge addon](http://codemirror.net/doc/manual.html#addon_merge): Use CSS `:after` element to style the scroll-lock icon.
|
56 |
+
|
57 |
+
[javascript-hint addon](http://codemirror.net/doc/manual.html#addon_javascript-hint): Don't provide completions in JSON mode.
|
58 |
+
|
59 |
+
[continuelist addon](http://codemirror.net/doc/manual.html#addon_continuelist): Fix numbering error.
|
60 |
+
|
61 |
+
[show-hint addon](http://codemirror.net/doc/manual.html#addon_show-hint): Make `fromList` completion strategy act on the current token up to the cursor, rather than the entire token.
|
62 |
+
|
63 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Fix a regexp with potentially exponental complexity.
|
64 |
+
|
65 |
+
### New features
|
66 |
+
|
67 |
+
New theme: [lucario](http://codemirror.net/demo/theme.html#lucario).
|
68 |
+
|
69 |
+
## 5.35.0 (2018-02-20)
|
70 |
+
|
71 |
+
### Bug fixes
|
72 |
+
|
73 |
+
Fix problem where selection undo might change read-only documents.
|
74 |
+
|
75 |
+
Fix crash when calling `addLineWidget` on a document that has no attached editor.
|
76 |
+
|
77 |
+
[searchcursor addon](http://codemirror.net/doc/manual.html#addon_searchcursor): Fix behavior of `^` in multiline regexp mode.
|
78 |
+
|
79 |
+
[match-highlighter addon](http://codemirror.net/doc/manual.html#addon_match-highlighter): Fix problem with matching words that have regexp special syntax in them.
|
80 |
+
|
81 |
+
[sublime bindings](http://codemirror.net/demo/sublime.html): Fix `addCursorToSelection` for short lines.
|
82 |
+
|
83 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Support TypeScript intersection types, dynamic `import`.
|
84 |
+
|
85 |
+
[stex mode](http://codemirror.net/mode/stex/): Fix parsing of `\(` `\)` delimiters, recognize more atom arguments.
|
86 |
+
|
87 |
+
[haskell mode](http://codemirror.net/mode/haskell/): Highlight more builtins, support `<*` and `*>`.
|
88 |
+
|
89 |
+
[sql mode](http://codemirror.net/mode/sql/): Make it possible to disable backslash escapes in strings for dialects that don't have them, do this for MS SQL.
|
90 |
+
|
91 |
+
[dockerfile mode](http://codemirror.net/mode/dockerfile/): Highlight strings and ports, recognize more instructions.
|
92 |
+
|
93 |
+
### New features
|
94 |
+
|
95 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Support alternative delimiters in replace command.
|
96 |
+
|
97 |
+
## 5.34.0 (2018-01-29)
|
98 |
+
|
99 |
+
### Bug fixes
|
100 |
+
|
101 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Fix a problem where inline styles would persist across list items.
|
102 |
+
|
103 |
+
[sublime bindings](http://codemirror.net/demo/sublime.html): Fix the `toggleBookmark` command.
|
104 |
+
|
105 |
+
[closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets): Improve behavior when closing triple quotes.
|
106 |
+
|
107 |
+
[xml-fold addon](http://codemirror.net/demo/folding.html): Fix folding of line-broken XML tags.
|
108 |
+
|
109 |
+
[shell mode](http://codemirror.net/mode/shell/): Better handling of nested quoting.
|
110 |
+
|
111 |
+
[javascript-lint addon](http://codemirror.net/demo/lint.html): Clean up and simplify.
|
112 |
+
|
113 |
+
[matchbrackets addon](http://codemirror.net/doc/manual.html#addon_matchbrackets): Fix support for multiple editors at the same time.
|
114 |
+
|
115 |
+
### New features
|
116 |
+
|
117 |
+
New themes: [oceanic-next](http://codemirror.net/demo/theme.html#oceanic-next) and [shadowfox](http://codemirror.net/demo/theme.html#shadowfox).
|
118 |
+
|
119 |
+
## 5.33.0 (2017-12-21)
|
120 |
+
|
121 |
+
### Bug fixes
|
122 |
+
|
123 |
+
[lint addon](http://codemirror.net/doc/manual.html#addon_lint): Make updates more efficient.
|
124 |
+
|
125 |
+
[css mode](http://codemirror.net/mode/css/): The mode is now properly case-insensitive.
|
126 |
+
|
127 |
+
[continuelist addon](http://codemirror.net/doc/manual.html#addon_continuelist): Fix broken handling of unordered lists introduced in previous release.
|
128 |
+
|
129 |
+
[swift](http://codemirror.net/mode/swift) and [scala](http://codemirror.net/mode/clike/) modes: Support nested block comments.
|
130 |
+
|
131 |
+
[mllike mode](http://codemirror.net/mode/mllike/index.html): Improve OCaml support.
|
132 |
+
|
133 |
+
[sublime bindings](http://codemirror.net/demo/sublime.html): Use the proper key bindings for `addCursorToNextLine` and `addCursorToPrevLine`.
|
134 |
+
|
135 |
+
### New features
|
136 |
+
|
137 |
+
[jsx mode](http://codemirror.net/mode/jsx/index.html): Support JSX fragments.
|
138 |
+
|
139 |
+
[closetag addon](http://codemirror.net/demo/closetag.html): Add an option to disable auto-indenting.
|
140 |
+
|
141 |
+
## 5.32.0 (2017-11-22)
|
142 |
+
|
143 |
+
### Bug fixes
|
144 |
+
|
145 |
+
Increase contrast on default bracket-matching colors.
|
146 |
+
|
147 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Recognize TypeScript type parameters for calls, type guards, and type parameter defaults. Improve handling of `enum` and `module` keywords.
|
148 |
+
|
149 |
+
[comment addon](http://codemirror.net/doc/manual.html#addon_comment): Fix bug when uncommenting a comment that spans all but the last selected line.
|
150 |
+
|
151 |
+
[searchcursor addon](http://codemirror.net/doc/manual.html#addon_searchcursor): Fix bug in case folding.
|
152 |
+
|
153 |
+
[emacs bindings](http://codemirror.net/demo/emacs.html): Prevent single-character deletions from resetting the kill ring.
|
154 |
+
|
155 |
+
[closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets): Tweak quote matching behavior.
|
156 |
+
|
157 |
+
### New features
|
158 |
+
|
159 |
+
[continuelist addon](http://codemirror.net/doc/manual.html#addon_continuelist): Increment ordered list numbers when adding one.
|
160 |
+
|
161 |
+
## 5.31.0 (2017-10-20)
|
162 |
+
|
163 |
+
### Bug fixes
|
164 |
+
|
165 |
+
Further improve selection drawing and cursor motion in right-to-left documents.
|
166 |
+
|
167 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Fix ctrl-w behavior, support quote-dot and backtick-dot marks, make the wide cursor visible in contentEditable [input mode](http://codemirror.net/doc/manual.html#option_contentEditable).
|
168 |
+
|
169 |
+
[continuecomment addon](http://codemirror.net/doc/manual.html#addon_continuecomment): Fix bug when pressing enter after a single-line block comment.
|
170 |
+
|
171 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Fix issue with leaving indented fenced code blocks.
|
172 |
+
|
173 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Fix bad parsing of operators without spaces between them. Fix some corner cases around semicolon insertion and regexps.
|
174 |
+
|
175 |
+
### New features
|
176 |
+
|
177 |
+
Modes added with [`addOverlay`](http://codemirror.net/doc/manual.html#addOverlay) now have access to a [`baseToken`](http://codemirror.net/doc/manual.html#baseToken) method on their input stream, giving access to the tokens of the underlying mode.
|
178 |
+
|
179 |
+
## 5.30.0 (2017-09-20)
|
180 |
+
|
181 |
+
### Bug fixes
|
182 |
+
|
183 |
+
Fixed a number of issues with drawing right-to-left selections and mouse selection in bidirectional text.
|
184 |
+
|
185 |
+
[search addon](http://codemirror.net/demo/search/): Fix crash when restarting search after doing empty search.
|
186 |
+
|
187 |
+
[mark-selection addon](http://cm/doc/manual.html#addon_mark-selection): Fix off-by-one bug.
|
188 |
+
|
189 |
+
[tern addon](http://codemirror.net/demo/tern.html): Fix bad request made when editing at the bottom of a large document.
|
190 |
+
|
191 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Improve parsing in a number of corner cases.
|
192 |
+
|
193 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Fix crash when a sub-mode doesn't support indentation, allow uppercase X in task lists.
|
194 |
+
|
195 |
+
[gfm mode](http://codemirror.net/mode/gfm/): Don't highlight SHA1 'hashes' without numbers to avoid false positives.
|
196 |
+
|
197 |
+
[soy mode](http://codemirror.net/mode/soy/): Support injected data and `@param` in comments.
|
198 |
+
|
199 |
+
### New features
|
200 |
+
|
201 |
+
[simple mode addon](http://codemirror.net/demo/simplemode.html): Allow groups in regexps when `token` isn't an array.
|
202 |
+
|
203 |
+
## 5.29.0 (2017-08-24)
|
204 |
+
|
205 |
+
### Bug fixes
|
206 |
+
|
207 |
+
Fix crash in contentEditable input style when editing near a bookmark.
|
208 |
+
|
209 |
+
Make sure change origins are preserved when splitting changes on [read-only marks](http://codemirror.net/doc/manual.html#mark_readOnly).
|
210 |
+
|
211 |
+
[javascript mode](http://codemirror.net/mode/javascript/): More support for TypeScript syntax.
|
212 |
+
|
213 |
+
[d mode](http://codemirror.net/mode/d/): Support nested comments.
|
214 |
+
|
215 |
+
[python mode](http://codemirror.net/mode/python/): Improve tokenizing of operators.
|
216 |
+
|
217 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Further improve CommonMark conformance.
|
218 |
+
|
219 |
+
[css mode](http://codemirror.net/mode/css/): Don't run comment tokens through the mode's state machine.
|
220 |
+
|
221 |
+
[shell mode](http://codemirror.net/mode/shell/): Allow strings to span lines.
|
222 |
+
|
223 |
+
[search addon](http://codemirror.net/demo/search/): Fix crash in persistent search when `extraKeys` is null.
|
224 |
+
|
225 |
+
## 5.28.0 (2017-07-21)
|
226 |
+
|
227 |
+
### Bug fixes
|
228 |
+
|
229 |
+
Fix copying of, or replacing editor content with, a single dash character when copying a big selection in some corner cases.
|
230 |
+
|
231 |
+
Make [`"goLineLeft"`](http://codemirror.net/doc/manual.html#command_goLineLeft)/`"goLineRight"` behave better on wrapped lines.
|
232 |
+
|
233 |
+
[sql mode](http://codemirror.net/mode/sql/): Fix tokenizing of multi-dot operator and allow digits in subfield names.
|
234 |
+
|
235 |
+
[searchcursor addon](http://codemirror.net/doc/manual.html#addon_searchcursor): Fix infinite loop on some composed character inputs.
|
236 |
+
|
237 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Make list parsing more CommonMark-compliant.
|
238 |
+
|
239 |
+
[gfm mode](http://codemirror.net/mode/gfm/): Highlight colon syntax for emoji.
|
240 |
+
|
241 |
+
### New features
|
242 |
+
|
243 |
+
Expose [`startOperation`](http://codemirror.net/doc/manual.html#startOperation) and `endOperation` for explicit operation management.
|
244 |
+
|
245 |
+
[sublime bindings](http://codemirror.net/demo/sublime.html): Add extend-selection (Ctrl-Alt- or Cmd-Shift-Up/Down).
|
246 |
+
|
247 |
+
## 5.27.4 (2017-06-29)
|
248 |
+
|
249 |
+
### Bug fixes
|
250 |
+
|
251 |
+
Fix crash when using mode lookahead.
|
252 |
+
|
253 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Don't block inner mode's indentation support.
|
254 |
+
|
255 |
+
## 5.27.2 (2017-06-22)
|
256 |
+
|
257 |
+
### Bug fixes
|
258 |
+
|
259 |
+
Fix crash in the [simple mode](http://codemirror.net/demo/simplemode.html)< addon.
|
260 |
+
|
261 |
+
## 5.27.0 (2017-06-22)
|
262 |
+
|
263 |
+
### Bug fixes
|
264 |
+
|
265 |
+
Fix infinite loop in forced display update.
|
266 |
+
|
267 |
+
Properly disable the hidden textarea when `readOnly` is `"nocursor"`.
|
268 |
+
|
269 |
+
Calling the `Doc` constructor without `new` works again.
|
270 |
+
|
271 |
+
[sql mode](http://codemirror.net/mode/sql/): Handle nested comments.
|
272 |
+
|
273 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Improve support for TypeScript syntax.
|
274 |
+
|
275 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Fix bug where markup was ignored on indented paragraph lines.
|
276 |
+
|
277 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Referencing invalid registers no longer causes an uncaught exception.
|
278 |
+
|
279 |
+
[rust mode](http://codemirror.net/mode/rust/): Add the correct MIME type.
|
280 |
+
|
281 |
+
[matchbrackets addon](http://codemirror.net/doc/manual.html#addon_matchbrackets): Document options.
|
282 |
+
|
283 |
+
### New features
|
284 |
+
|
285 |
+
Mouse button clicks can now be bound in keymaps by using names like `"LeftClick"` or `"Ctrl-Alt-MiddleTripleClick"`. When bound to a function, that function will be passed the position of the click as second argument.
|
286 |
+
|
287 |
+
The behavior of mouse selection and dragging can now be customized with the [`configureMouse`](http://codemirror.net/doc/manual.html#option_configureMouse) option.
|
288 |
+
|
289 |
+
Modes can now look ahead across line boundaries with the [`StringStream`](http://codemirror.net/doc/manual.html#StringStream)`.lookahead` method.
|
290 |
+
|
291 |
+
Introduces a `"type"` token type, makes modes that recognize types output it, and add styling for it to the themes.
|
292 |
+
|
293 |
+
New [`pasteLinesPerSelection`](http://codemirror.net/doc/manual.html#option_pasteLinesPerSelection) option to control the behavior of pasting multiple lines into multiple selections.
|
294 |
+
|
295 |
+
[searchcursor addon](http://codemirror.net/doc/manual.html#addon_searchcursor): Support multi-line regular expression matches, and normalize strings when matching.
|
296 |
+
|
297 |
+
## 5.26.0 (2017-05-22)
|
298 |
+
|
299 |
+
### Bug fixes
|
300 |
+
|
301 |
+
In textarea-mode, don't reset the input field during composition.
|
302 |
+
|
303 |
+
More careful restoration of selections in widgets, during editor redraw.
|
304 |
+
|
305 |
+
[javascript mode](http://codemirror.net/mode/javascript/): More TypeScript parsing fixes.
|
306 |
+
|
307 |
+
[julia mode](http://codemirror.net/mode/julia/): Fix issue where the mode gets stuck.
|
308 |
+
|
309 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Understand cross-line links, parse all bracketed things as links.
|
310 |
+
|
311 |
+
[soy mode](http://codemirror.net/mode/soy/): Support single-quoted strings.
|
312 |
+
|
313 |
+
[go mode](http://codemirror.net/mode/go/): Don't try to indent inside strings or comments.
|
314 |
+
|
315 |
+
### New features
|
316 |
+
|
317 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Parse line offsets in line or range specs.
|
318 |
+
|
319 |
+
## 5.25.2 (2017-04-20)
|
320 |
+
|
321 |
+
### Bug fixes
|
322 |
+
|
323 |
+
Better handling of selections that cover the whole viewport in contentEditable-mode.
|
324 |
+
|
325 |
+
No longer accidentally scroll the editor into view when calling `setValue`.
|
326 |
+
|
327 |
+
Work around Chrome Android bug when converting screen coordinates to editor positions.
|
328 |
+
|
329 |
+
Make sure long-clicking a selection sets a cursor and doesn't show the editor losing focus.
|
330 |
+
|
331 |
+
Fix issue where pointer events were incorrectly disabled on Chrome's overlay scrollbars.
|
332 |
+
|
333 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Recognize annotations and TypeScript-style type parameters.
|
334 |
+
|
335 |
+
[shell mode](http://codemirror.net/mode/shell/): Handle nested braces.
|
336 |
+
|
337 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Make parsing of strong/em delimiters CommonMark-compliant.
|
338 |
+
|
339 |
+
## 5.25.0 (2017-03-20)
|
340 |
+
|
341 |
+
### Bug fixes
|
342 |
+
|
343 |
+
In contentEditable-mode, properly locate changes that repeat a character when inserted with IME.
|
344 |
+
|
345 |
+
Fix handling of selections bigger than the viewport in contentEditable mode.
|
346 |
+
|
347 |
+
Improve handling of changes that insert or delete lines in contentEditable mode.
|
348 |
+
|
349 |
+
Count Unicode control characters 0x80 to 0x9F as special (non-printing) chars.
|
350 |
+
|
351 |
+
Fix handling of shadow DOM roots when finding the active element.
|
352 |
+
|
353 |
+
Add `role=presentation` to more DOM elements to improve screen reader support.
|
354 |
+
|
355 |
+
[merge addon](http://codemirror.net/doc/manual.html#addon_merge): Make aligning of unchanged chunks more robust.
|
356 |
+
|
357 |
+
[comment addon](http://codemirror.net/doc/manual.html#addon_comment): Fix comment-toggling on a block of text that starts and ends in a (differnet) block comment.
|
358 |
+
|
359 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Improve support for TypeScript syntax.
|
360 |
+
|
361 |
+
[r mode](http://codemirror.net/mode/r/): Fix indentation after semicolon-less statements.
|
362 |
+
|
363 |
+
[shell mode](http://codemirror.net/mode/shell/): Properly handle escaped parentheses in parenthesized expressions.
|
364 |
+
|
365 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Fix a few bugs around leaving fenced code blocks.
|
366 |
+
|
367 |
+
[soy mode](http://codemirror.net/mode/soy/): Improve indentation.
|
368 |
+
|
369 |
+
### New features
|
370 |
+
|
371 |
+
[lint addon](http://codemirror.net/doc/manual.html#addon_lint): Support asynchronous linters that return promises.
|
372 |
+
|
373 |
+
[continuelist addon](http://codemirror.net/doc/manual.html#addon_continuelist): Support continuing task lists.
|
374 |
+
|
375 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Make Y behave like yy.
|
376 |
+
|
377 |
+
[sql mode](http://codemirror.net/mode/sql/): Support sqlite dialect.
|
378 |
+
|
379 |
+
## 5.24.2 (2017-02-22)
|
380 |
+
|
381 |
+
### Bug fixes
|
382 |
+
|
383 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Support computed class method names.
|
384 |
+
|
385 |
+
[merge addon](http://codemirror.net/doc/manual.html#addon_merge): Improve aligning of unchanged code in the presence of marks and line widgets.
|
386 |
+
|
387 |
+
## 5.24.0 (2017-02-20)
|
388 |
+
|
389 |
+
### Bug fixes
|
390 |
+
|
391 |
+
A cursor directly before a line-wrapping break is now drawn before or after the line break depending on which direction you arrived from.
|
392 |
+
|
393 |
+
Visual cursor motion in line-wrapped right-to-left text should be much more correct.
|
394 |
+
|
395 |
+
Fix bug in handling of read-only marked text.
|
396 |
+
|
397 |
+
[shell mode](http://codemirror.net/mode/shell/): Properly tokenize nested parentheses.
|
398 |
+
|
399 |
+
[python mode](http://codemirror.net/mode/python/): Support underscores in number literals.
|
400 |
+
|
401 |
+
[sass mode](http://codemirror.net/mode/sass/): Uses the full list of CSS properties and keywords from the CSS mode, rather than defining its own incomplete subset.
|
402 |
+
|
403 |
+
[css mode](http://codemirror.net/mode/css/): Expose `lineComment` property for LESS and SCSS dialects. Recognize vendor prefixes on pseudo-elements.
|
404 |
+
|
405 |
+
[julia mode](http://codemirror.net/mode/julia/): Properly indent `elseif` lines.
|
406 |
+
|
407 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Properly recognize the end of fenced code blocks when inside other markup.
|
408 |
+
|
409 |
+
[scala mode](http://codemirror.net/mode/clike/): Improve handling of operators containing <code>#</code>, <code>@</code>, and <code>:</code> chars.
|
410 |
+
|
411 |
+
[xml mode](http://codemirror.net/mode/xml/): Allow dashes in HTML tag names.
|
412 |
+
|
413 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Improve parsing of async methods, TypeScript-style comma-separated superclass lists.
|
414 |
+
|
415 |
+
[indent-fold addon](http://codemirror.net/demo/folding.html): Ignore comment lines.
|
416 |
+
|
417 |
+
### New features
|
418 |
+
|
419 |
+
Positions now support a `sticky` property which determines whether they should be associated with the character before (value `"before"`) or after (value `"after"`) them.
|
420 |
+
|
421 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Make it possible to remove built-in bindings through the API.
|
422 |
+
|
423 |
+
[comment addon](http://codemirror.net/doc/manual.html#addon_comment): Support a per-mode <code>useInnerComments</code> option to optionally suppress descending to the inner modes to get comment strings.
|
424 |
+
|
425 |
+
### Breaking changes
|
426 |
+
|
427 |
+
The [sass mode](http://codemirror.net/mode/sass/) now depends on the [css mode](http://codemirror.net/mode/css/).
|
428 |
+
|
429 |
+
## 5.23.0 (2017-01-19)
|
430 |
+
|
431 |
+
### Bug fixes
|
432 |
+
|
433 |
+
Presentation-related elements DOM elements are now marked as such to help screen readers.
|
434 |
+
|
435 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Be more picky about what HTML tags look like to avoid false positives.
|
436 |
+
|
437 |
+
### New features
|
438 |
+
|
439 |
+
`findModeByMIME` now understands `+json` and `+xml` MIME suffixes.
|
440 |
+
|
441 |
+
[closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets): Add support for an `override` option to ignore language-specific defaults.
|
442 |
+
|
443 |
+
[panel addon](http://codemirror.net/doc/manual.html#addon_panel): Add a `stable` option that auto-scrolls the content to keep it in the same place when inserting/removing a panel.
|
444 |
+
|
445 |
+
## 5.22.2 (2017-01-12)
|
446 |
+
|
447 |
+
### Bug fixes
|
448 |
+
|
449 |
+
Include rollup.config.js in NPM package, so that it can be used to build from source.
|
450 |
+
|
451 |
+
## 5.22.0 (2016-12-20)
|
452 |
+
|
453 |
+
### Bug fixes
|
454 |
+
|
455 |
+
[sublime bindings](http://codemirror.net/demo/sublime.html): Make `selectBetweenBrackets` work with multiple cursors.
|
456 |
+
|
457 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Fix issues with parsing complex TypeScript types, imports, and exports.
|
458 |
+
|
459 |
+
A contentEditable editor instance with autofocus enabled no longer crashes during initializing.
|
460 |
+
|
461 |
+
### New features
|
462 |
+
|
463 |
+
[emacs bindings](http://codemirror.net/demo/emacs.html): Export `CodeMirror.emacs` to allow other addons to hook into Emacs-style functionality.
|
464 |
+
|
465 |
+
[active-line addon](http://codemirror.net/doc/manual.html#addon_active-line): Add `nonEmpty` option.
|
466 |
+
|
467 |
+
New event: [`optionChange`](http://codemirror.net/doc/manual.html#event_optionChange).
|
468 |
+
|
469 |
+
## 5.21.0 (2016-11-21)
|
470 |
+
|
471 |
+
### Bug fixes
|
472 |
+
|
473 |
+
Tapping/clicking the editor in [contentEditable mode](http://codemirror.net/doc/manual.html#option_inputStyle) on Chrome now puts the cursor at the tapped position.
|
474 |
+
|
475 |
+
Fix various crashes and misbehaviors when reading composition events in [contentEditable mode](http://codemirror.net/doc/manual.html#option_inputStyle).
|
476 |
+
|
477 |
+
Catches and ignores an IE 'Unspecified Error' when creating an editor in an iframe before there is a `<body>`.
|
478 |
+
|
479 |
+
[merge addon](http://codemirror.net/doc/manual.html#addon_merge): Fix several issues in the chunk-aligning feature.
|
480 |
+
|
481 |
+
[verilog mode](http://codemirror.net/mode/verilog): Rewritten to address various issues.
|
482 |
+
|
483 |
+
[julia mode](http://codemirror.net/mode/julia): Recognize Julia 0.5 syntax.
|
484 |
+
|
485 |
+
[swift mode](http://codemirror.net/mode/swift): Various fixes and adjustments to current syntax.
|
486 |
+
|
487 |
+
[markdown mode](http://codemirror.net/mode/markdown): Allow lists without a blank line above them.
|
488 |
+
|
489 |
+
### New features
|
490 |
+
|
491 |
+
The [`setGutterMarker`](http://codemirror.net/doc/manual.html#setGutterMarker), [`clearGutter`](http://codemirror.net/doc/manual.html#clearGutter), and [`lineInfo`](http://codemirror.net/doc/manual.html#lineInfo) methods are now available on `Doc` objects.
|
492 |
+
|
493 |
+
The [`heightAtLine`](http://codemirror.net/doc/manual.html#heightAtLine) method now takes an extra argument to allow finding the height at the top of the line's line widgets.
|
494 |
+
|
495 |
+
[ruby mode](http://codemirror.net/mode/ruby): `else` and `elsif` are now immediately indented.
|
496 |
+
|
497 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Bind Ctrl-T and Ctrl-D to in- and dedent in insert mode.
|
498 |
+
|
499 |
+
## 5.20.2 (2016-10-21)
|
500 |
+
|
501 |
+
### Bug fixes
|
502 |
+
|
503 |
+
Fix `CodeMirror.version` returning the wrong version number.
|
504 |
+
|
505 |
+
## 5.20.0 (2016-10-20)
|
506 |
+
|
507 |
+
### Bug fixes
|
508 |
+
|
509 |
+
Make `newlineAndIndent` command work with multiple cursors on the same line.
|
510 |
+
|
511 |
+
Make sure keypress events for backspace are ignored.
|
512 |
+
|
513 |
+
Tokens styled with overlays no longer get a nonsense `cm-cm-overlay` class.
|
514 |
+
|
515 |
+
Line endings for pasted content are now normalized to the editor's [preferred ending](http://codemirror.net/doc/manual.html#option_lineSeparator).
|
516 |
+
|
517 |
+
[javascript mode](http://codemirror.net/mode/javascript): Improve support for class expressions. Support TypeScript optional class properties, the `abstract` keyword, and return type declarations for arrow functions.
|
518 |
+
|
519 |
+
[css mode](http://codemirror.net/mode/css): Fix highlighting of mixed-case keywords.
|
520 |
+
|
521 |
+
[closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets): Improve behavior when typing a quote before a string.
|
522 |
+
|
523 |
+
### New features
|
524 |
+
|
525 |
+
The core is now maintained as a number of small files, using ES6 syntax and modules, under the `src/` directory. A git checkout no longer contains a working `codemirror.js` until you `npm build` (but when installing from NPM, it is included).
|
526 |
+
|
527 |
+
The [`refresh`](http://codemirror.net/doc/manual.html#event_refresh) event is now documented and stable.
|
528 |
+
|
529 |
+
## 5.19.0 (2016-09-20)
|
530 |
+
|
531 |
+
### Bugfixes
|
532 |
+
|
533 |
+
[erlang mode](http://codemirror.net/mode/erlang): Fix mode crash when trying to read an empty context.
|
534 |
+
|
535 |
+
[comment addon](http://codemirror.net/doc/manual.html#addon_comment): Fix broken behavior when toggling comments inside a comment.
|
536 |
+
|
537 |
+
xml-fold addon: Fix a null-dereference bug.
|
538 |
+
|
539 |
+
Page up and page down now do something even in single-line documents.
|
540 |
+
|
541 |
+
Fix an issue where the cursor position could be off in really long (~8000 character) tokens.
|
542 |
+
|
543 |
+
### New features
|
544 |
+
|
545 |
+
[javascript mode](http://codemirror.net/mode/javascript): Better indentation when semicolons are missing. Better support for TypeScript classes, optional parameters, and the `type` keyword.
|
546 |
+
|
547 |
+
The [`blur`](http://codemirror.net/doc/manual.html#event_blur) and [`focus`](http://codemirror.net/doc/manual.html#event_focus) events now pass the DOM event to their handlers.
|
548 |
+
|
549 |
+
## 5.18.2 (2016-08-23)
|
550 |
+
|
551 |
+
### Bugfixes
|
552 |
+
|
553 |
+
[vue mode](http://codemirror.net/mode/vue): Fix outdated references to renamed Pug mode dependency.
|
554 |
+
|
555 |
+
## 5.18.0 (2016-08-22)
|
556 |
+
|
557 |
+
### Bugfixes
|
558 |
+
|
559 |
+
Make sure [gutter backgrounds](http://codemirror.net/doc/manual.html#addLineClass) stick to the rest of the gutter during horizontal scrolling.
|
560 |
+
|
561 |
+
The contenteditable [`inputStyle`](http://codemirror.net/doc/manual.html#option_inputStyle) now properly supports pasting on pre-Edge IE versions.
|
562 |
+
|
563 |
+
[javascript mode](http://codemirror.net/mode/javascript): Fix some small parsing bugs and improve TypeScript support.
|
564 |
+
|
565 |
+
[matchbrackets addon](http://codemirror.net/doc/manual.html#addon_matchbrackets): Fix bug where active highlighting was left in editor when the addon was disabled.
|
566 |
+
|
567 |
+
[match-highlighter addon](http://codemirror.net/doc/manual.html#addon_match-highlighter): Only start highlighting things when the editor gains focus.
|
568 |
+
|
569 |
+
[javascript-hint addon](http://codemirror.net/doc/manual.html#addon_javascript-hint): Also complete non-enumerable properties.
|
570 |
+
|
571 |
+
### New features
|
572 |
+
|
573 |
+
The [`addOverlay`](http://codemirror.net/doc/manual.html#addOverlay) method now supports a `priority` option to control the order in which overlays are applied.
|
574 |
+
|
575 |
+
MIME types that end in `+json` now default to the JSON mode when the MIME itself is not defined.
|
576 |
+
|
577 |
+
### Breaking changes
|
578 |
+
|
579 |
+
The mode formerly known as Jade was renamed to [Pug](http://codemirror.net/mode/pug).
|
580 |
+
|
581 |
+
The [Python mode](http://codemirror.net/mode/python) now defaults to Python 3 (rather than 2) syntax.
|
582 |
+
|
583 |
+
## 5.17.0 (2016-07-19)
|
584 |
+
|
585 |
+
### Bugfixes
|
586 |
+
|
587 |
+
Fix problem with wrapped trailing whitespace displaying incorrectly.
|
588 |
+
|
589 |
+
Prevent IME dialog from overlapping typed content in Chrome.
|
590 |
+
|
591 |
+
Improve measuring of characters near a line wrap.
|
592 |
+
|
593 |
+
[javascript mode](http://codemirror.net/mode/javascript): Improve support for `async`, allow trailing commas in `import` lists.
|
594 |
+
|
595 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Fix backspace in replace mode.
|
596 |
+
|
597 |
+
[sublime bindings](http://codemirror.net/demo/sublime.html): Fix some key bindings on OS X to match Sublime Text.
|
598 |
+
|
599 |
+
### New features
|
600 |
+
|
601 |
+
[markdown mode](http://codemirror.net/mode/markdown): Add more classes to image links in highlight-formatting mode.
|
602 |
+
|
603 |
+
## 5.16.0 (2016-06-20)
|
604 |
+
|
605 |
+
### Bugfixes
|
606 |
+
|
607 |
+
Fix glitches when dragging content caused by the drop indicator receiving mouse events.
|
608 |
+
|
609 |
+
Make Control-drag work on Firefox.
|
610 |
+
|
611 |
+
Make clicking or selection-dragging at the end of a wrapped line select the right position.
|
612 |
+
|
613 |
+
[show-hint addon](http://codemirror.net/doc/manual.html#addon_show-hint): Prevent widget scrollbar from hiding part of the hint text.
|
614 |
+
|
615 |
+
[rulers addon](http://codemirror.net/doc/manual.html#addon_rulers): Prevent rulers from forcing a horizontal editor scrollbar.
|
616 |
+
|
617 |
+
### New features
|
618 |
+
|
619 |
+
[search addon](http://codemirror.net/doc/manual.html#addon_search): Automatically bind search-related keys in persistent dialog.
|
620 |
+
|
621 |
+
[sublime keymap](http://codemirror.net/demo/sublime.html): Add a multi-cursor aware smart backspace binding.
|
622 |
+
|
623 |
+
## 5.15.2 (2016-05-20)
|
624 |
+
|
625 |
+
### Bugfixes
|
626 |
+
|
627 |
+
Fix a critical document corruption bug that occurs when a document is gradually grown.
|
628 |
+
|
629 |
+
## 5.15.0 (2016-05-20)
|
630 |
+
|
631 |
+
### Bugfixes
|
632 |
+
|
633 |
+
Fix bug that caused the selection to reset when focusing the editor in contentEditable input mode.
|
634 |
+
|
635 |
+
Fix issue where not all ASCII control characters were being replaced by placeholders.
|
636 |
+
|
637 |
+
Remove the assumption that all modes have a `startState` method from several wrapping modes.
|
638 |
+
|
639 |
+
Fix issue where the editor would complain about overlapping collapsed ranges when there weren't any.
|
640 |
+
|
641 |
+
Optimize document tree building when loading or pasting huge chunks of content.
|
642 |
+
|
643 |
+
[markdown mode](http://codemirror.net/mode/markdown/): Fix several issues in matching link targets.
|
644 |
+
|
645 |
+
[clike mode](http://codemirror.net/mode/clike/): Improve indentation of C++ template declarations.
|
646 |
+
|
647 |
+
### New features
|
648 |
+
|
649 |
+
Explicitly bind Ctrl-O on OS X to make that binding (“open line”) act as expected.
|
650 |
+
|
651 |
+
Pasting [linewise-copied](http://codemirror.net/doc/manual.html#option_lineWiseCopyCut) content when there is no selection now inserts the lines above the current line.
|
652 |
+
|
653 |
+
[javascript mode](http://codemirror.net/mode/javascript/): Support `async`/`await` and improve support for TypeScript type syntax.
|
654 |
+
|
655 |
+
## 5.14.2 (2016-04-20)
|
656 |
+
|
657 |
+
### Bugfixes
|
658 |
+
|
659 |
+
Push a new package to NPM due to an [NPM bug](https://github.com/npm/npm/issues/5082) omitting the LICENSE file in 5.14.0.
|
660 |
+
|
661 |
+
Set `dataTransfer.effectAllowed` in `dragstart` handler to help browsers use the right drag icon.
|
662 |
+
|
663 |
+
Add the [mbox mode](http://codemirror.net/mode/mbox/index.html) to `mode/meta.js`.
|
664 |
+
|
665 |
+
## 5.14.0 (2016-04-20)
|
666 |
+
|
667 |
+
### Bugfixes
|
668 |
+
|
669 |
+
[`posFromIndex`](http://codemirror.net/doc/manual.html#posFromIndex) and [`indexFromPos`](http://codemirror.net/doc/manual.html#indexFromPos) now take [`lineSeparator`](http://codemirror.net/doc/manual.html#option_lineSeparator) into account.
|
670 |
+
|
671 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Only call `.save()` when it is actually available.
|
672 |
+
|
673 |
+
[comment addon](http://codemirror.net/doc/manual.html#addon_comment): Be careful not to mangle multi-line strings.
|
674 |
+
|
675 |
+
[Python mode](http://codemirror.net/mode/python/index.html): Improve distinguishing of decorators from `@` operators.
|
676 |
+
|
677 |
+
[`findMarks`](http://codemirror.net/doc/manual.html#findMarks): No longer return marks that touch but don't overlap given range.
|
678 |
+
|
679 |
+
### New features
|
680 |
+
|
681 |
+
[vim bindings](http://codemirror.net/demo/vim.html): Add yank command.
|
682 |
+
|
683 |
+
[match-highlighter addon](http://codemirror.net/doc/manual.html#addon_match-highlighter): Add `trim` option to disable ignoring of whitespace.
|
684 |
+
|
685 |
+
[PowerShell mode](http://codemirror.net/mode/powershell/index.html): Added.
|
686 |
+
|
687 |
+
[Yacas mode](http://codemirror.net/mode/yacas/index.html): Added.
|
688 |
+
|
689 |
+
[Web IDL mode](http://codemirror.net/mode/webidl/index.html): Added.
|
690 |
+
|
691 |
+
[SAS mode](http://codemirror.net/mode/sas/index.html): Added.
|
692 |
+
|
693 |
+
[mbox mode](http://codemirror.net/mode/mbox/index.html): Added.
|
694 |
+
|
695 |
+
## 5.13.2 (2016-03-23)
|
696 |
+
|
697 |
+
### Bugfixes
|
698 |
+
|
699 |
+
Solves a problem where the gutter would sometimes not extend all the way to the end of the document.
|
700 |
+
|
701 |
+
## 5.13.0 (2016-03-21)
|
702 |
+
|
703 |
+
### New features
|
704 |
+
|
705 |
+
New DOM event forwarded: [`"dragleave"`](http://codemirror.net/doc/manual.html#event_dom).
|
706 |
+
|
707 |
+
[protobuf mode](http://codemirror.net/mode/protobuf/index.html): Newly added.
|
708 |
+
|
709 |
+
### Bugfixes
|
710 |
+
|
711 |
+
Fix problem where [`findMarks`](http://codemirror.net/doc/manual.html#findMarks) sometimes failed to find multi-line marks.
|
712 |
+
|
713 |
+
Fix crash that showed up when atomic ranges and bidi text were combined.
|
714 |
+
|
715 |
+
[show-hint addon](http://codemirror.net/demo/complete.html): Completion widgets no longer close when the line indented or dedented.
|
716 |
+
|
717 |
+
[merge addon](http://codemirror.net/demo/merge.html): Fix bug when merging chunks at the end of the file.
|
718 |
+
|
719 |
+
[placeholder addon](http://codemirror.net/doc/manual.html#addon_placeholder): No longer gets confused by [`swapDoc`](http://codemirror.net/doc/manual.html#swapDoc).
|
720 |
+
|
721 |
+
[simplescrollbars addon](http://codemirror.net/doc/manual.html#addon_simplescrollbars): Fix invalid state when deleting at end of document.
|
722 |
+
|
723 |
+
[clike mode](http://codemirror.net/mode/clike/index.html): No longer gets confused when a comment starts after an operator.
|
724 |
+
|
725 |
+
[markdown mode](http://codemirror.net/mode/markdown/index.html): Now supports CommonMark-style flexible list indentation.
|
726 |
+
|
727 |
+
[dylan mode](http://codemirror.net/mode/dylan/index.html): Several improvements and fixes.
|
728 |
+
|
729 |
+
## 5.12.0 (2016-02-19)
|
730 |
+
|
731 |
+
### New features
|
732 |
+
|
733 |
+
[Vim bindings](http://codemirror.net/demo/vim.html): Ctrl-Q is now an alias for Ctrl-V.
|
734 |
+
|
735 |
+
[Vim bindings](http://codemirror.net/demo/vim.html): The Vim API now exposes an `unmap` method to unmap bindings.
|
736 |
+
|
737 |
+
[active-line addon](http://codemirror.net/demo/activeline.html): This addon can now style the active line's gutter.
|
738 |
+
|
739 |
+
[FCL mode](http://codemirror.net/mode/fcl/): Newly added.
|
740 |
+
|
741 |
+
[SQL mode](http://codemirror.net/mode/sql/): Now has a Postgresql dialect.
|
742 |
+
|
743 |
+
### Bugfixes
|
744 |
+
|
745 |
+
Fix [issue](https://github.com/codemirror/CodeMirror/issues/3781) where trying to scroll to a horizontal position outside of the document's width could cause the gutter to be positioned incorrectly.
|
746 |
+
|
747 |
+
Use absolute, rather than fixed positioning in the context-menu intercept hack, to work around a [problem](https://github.com/codemirror/CodeMirror/issues/3238) when the editor is inside a transformed parent container.
|
748 |
+
|
749 |
+
Solve a [problem](https://github.com/codemirror/CodeMirror/issues/3821) where the horizontal scrollbar could hide text in Firefox.
|
750 |
+
|
751 |
+
Fix a [bug](https://github.com/codemirror/CodeMirror/issues/3834) that caused phantom scroll space under the text in some situations.
|
752 |
+
|
753 |
+
[Sublime Text bindings](http://codemirror.net/demo/sublime.html): Bind delete-line to Shift-Ctrl-K on OS X.
|
754 |
+
|
755 |
+
[Markdown mode](http://codemirror.net/mode/markdown/): Fix [issue](https://github.com/codemirror/CodeMirror/issues/3787) where the mode would keep state related to fenced code blocks in an unsafe way, leading to occasional corrupted parses.
|
756 |
+
|
757 |
+
[Markdown mode](http://codemirror.net/mode/markdown/): Ignore backslashes in code fragments.
|
758 |
+
|
759 |
+
[Markdown mode](http://codemirror.net/mode/markdown/): Use whichever mode is registered as `text/html` to parse HTML.
|
760 |
+
|
761 |
+
[Clike mode](http://codemirror.net/mode/clike/): Improve indentation of Scala `=>` functions.
|
762 |
+
|
763 |
+
[Python mode](http://codemirror.net/mode/python/): Improve indentation of bracketed code.
|
764 |
+
|
765 |
+
[HTMLMixed mode](http://codemirror.net/mode/htmlmixed/): Support multi-line opening tags for sub-languages (`<script>`, `<style>`, etc).
|
766 |
+
|
767 |
+
[Spreadsheet mode](http://codemirror.net/mode/spreadsheet/): Fix bug where the mode did not advance the stream when finding a backslash.
|
768 |
+
|
769 |
+
[XML mode](http://codemirror.net/mode/xml/): The mode now takes a `matchClosing` option to configure whether mismatched closing tags should be highlighted as errors.
|
770 |
+
|
771 |
+
## 5.11.0 (2016-01-20)
|
772 |
+
|
773 |
+
* New modes: [JSX](http://codemirror.net/mode/jsx/index.html), [literate Haskell](http://codemirror.net/mode/haskell-literate/index.html)
|
774 |
+
* The editor now forwards more [DOM events](http://codemirror.net/doc/manual.html#event_dom): `cut`, `copy`, `paste`, and `touchstart`. It will also forward `mousedown` for drag events
|
775 |
+
* Fixes a bug where bookmarks next to collapsed spans were not rendered
|
776 |
+
* The [Swift](http://codemirror.net/mode/swift/index.html) mode now supports auto-indentation
|
777 |
+
* Frontmatters in the [YAML frontmatter](http://codemirror.net/mode/yaml-frontmatter/index.html) mode are now optional as intended
|
778 |
+
|
779 |
+
## 5.10.0 (2015-12-21)
|
780 |
+
|
781 |
+
* Modify the way [atomic ranges](http://codemirror.net/doc/manual.html#mark_atomic) are skipped by selection to try and make it less surprising.
|
782 |
+
* The [Swift mode](http://codemirror.net/mode/swift/index.html) was rewritten.
|
783 |
+
* New addon: [jump-to-line](http://codemirror.net/doc/manual.html#addon_jump-to-line).
|
784 |
+
* New method: [`isReadOnly`](http://codemirror.net/doc/manual.html#isReadOnly).
|
785 |
+
* The [show-hint addon](http://codemirror.net/doc/manual.html#addon_show-hint) now defaults to picking completions on single click.
|
786 |
+
* The object passed to [`"beforeSelectionChange"`](http://codemirror.net/doc/manual.html#event_beforeSelectionChange) events now has an `origin` property.
|
787 |
+
* New mode: [Crystal](http://codemirror.net/mode/crystal/index.html).
|
788 |
+
|
789 |
+
## 5.9.0 (2015-11-23)
|
790 |
+
|
791 |
+
* Improve the way overlay (OS X-style) scrollbars are handled
|
792 |
+
* Make [annotatescrollbar](http://codemirror.net/doc/manual.html#addon_annotatescrollbar) and scrollpastend addons work properly together
|
793 |
+
* Make [show-hint](http://codemirror.net/doc/manual.html#addon_show-hint) addon select options on single click by default, move selection to hovered item
|
794 |
+
* Properly fold comments that include block-comment-start markers
|
795 |
+
* Many small language mode fixes
|
796 |
+
|
797 |
+
## 5.8.0 (2015-10-20)
|
798 |
+
|
799 |
+
* Fixes an infinite loop in the [hardwrap addon](http://codemirror.net/doc/manual.html#addon_hardwrap)
|
800 |
+
* New modes: [NSIS](http://codemirror.net/mode/nsis/index.html), [Ceylon](http://codemirror.net/mode/clike/index.html)
|
801 |
+
* The Kotlin mode is now a [clike](http://codemirror.net/mode/clike/index.html) dialect, rather than a stand-alone mode
|
802 |
+
* New option: [`allowDropFileTypes`](http://codemirror.net/doc/manual.html#option_allowDropFileTypes). Binary files can no longer be dropped into CodeMirror
|
803 |
+
* New themes: [bespin](http://codemirror.net/demo/theme.html#bespin), [hopscotch](http://codemirror.net/demo/theme.html#hopscotch), [isotope](http://codemirror.net/demo/theme.html#isotope), [railscasts](http://codemirror.net/demo/theme.html#railscasts)
|
804 |
+
|
805 |
+
## 5.7.0 (2015-09-21)
|
806 |
+
|
807 |
+
* New modes: [Vue](http://codemirror.net/mode/vue/index.html), [Oz](http://codemirror.net/mode/oz/index.html), [MscGen](http://codemirror.net/mode/mscgen/index.html) (and dialects), [Closure Stylesheets](http://codemirror.net/mode/css/gss.html)
|
808 |
+
* Implement [CommonMark](http://commonmark.org)-style flexible list indent and cross-line code spans in [Markdown](http://codemirror.net/mode/markdown/index.html) mode
|
809 |
+
* Add a replace-all button to the [search addon](http://codemirror.net/doc/manual.html#addon_search), and make the persistent search dialog transparent when it obscures the match
|
810 |
+
* Handle `acync`/`await` and ocal and binary numbers in [JavaScript mode](http://codemirror.net/mode/javascript/index.html)
|
811 |
+
* Fix various issues with the [Haxe mode](http://codemirror.net/mode/haxe/index.html)
|
812 |
+
* Make the [closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets) select only the wrapped text when wrapping selection in brackets
|
813 |
+
* Tokenize properties as properties in the [CoffeeScript mode](http://codemirror.net/mode/coffeescript/index.html)
|
814 |
+
* The [placeholder addon](http://codemirror.net/doc/manual.html#addon_placeholder) now accepts a DOM node as well as a string placeholder
|
815 |
+
|
816 |
+
## 5.6.0 (2015-08-20)
|
817 |
+
|
818 |
+
* Fix bug where you could paste into a `readOnly` editor
|
819 |
+
* Show a cursor at the drop location when dragging over the editor
|
820 |
+
* The [Rust mode](http://codemirror.net/mode/rust/index.html) was rewritten to handle modern Rust
|
821 |
+
* The editor and theme CSS was cleaned up. Some selectors are now less specific than before
|
822 |
+
* New theme: [abcdef](http://codemirror.net/demo/theme.html#abcdef)
|
823 |
+
* Lines longer than [`maxHighlightLength`](http://codemirror.net/doc/manual.html#option_maxHighlightLength) are now less likely to mess up indentation
|
824 |
+
* New addons: [`autorefresh`](http://codemirror.net/doc/manual.html#addon_autorefresh) for refreshing an editor the first time it becomes visible, and `html-lint` for using [HTMLHint](http://htmlhint.com/)
|
825 |
+
* The [`search`](http://codemirror.net/doc/manual.html#addon_search) addon now recognizes `\r` and `\n` in pattern and replacement input
|
826 |
+
|
827 |
+
## 5.5.0 (2015-07-20)
|
828 |
+
|
829 |
+
* New option: [`lineSeparator`](http://codemirror.net/doc/manual.html#option_lineSeparator) (with corresponding [method](http://codemirror.net/doc/manual.html#lineSeparator))
|
830 |
+
* New themes: [dracula](http://codemirror.net/demo/theme.html#dracula), [seti](http://codemirror.net/demo/theme.html#seti), [yeti](http://codemirror.net/demo/theme.html#yeti), [material](http://codemirror.net/demo/theme.html#material), and [icecoder](http://codemirror.net/demo/theme.html#icecoder)
|
831 |
+
* New modes: [Brainfuck](http://codemirror.net/mode/brainfuck/index.html), [VHDL](http://codemirror.net/mode/vhdl/index.html), Squirrel ([clike](http://codemirror.net/mode/clike/index.html) dialect)
|
832 |
+
* Define a `findPersistent` command in the [search](http://codemirror.net/demo/search.html) addon, for a dialog that stays open as you cycle through matches
|
833 |
+
* From this release on, the NPM module doesn't include documentation and demos
|
834 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.4.0...5.5.0)
|
835 |
+
|
836 |
+
## 5.4.0 (2015-06-25)
|
837 |
+
|
838 |
+
* New modes: [Twig](http://codemirror.net/mode/twig/index.html), [Elm](http://codemirror.net/mode/elm/index.html), [Factor](http://codemirror.net/mode/factor/index.html), [Swift](http://codemirror.net/mode/swift/index.html)
|
839 |
+
* Prefer clipboard API (if available) when pasting
|
840 |
+
* Refined definition highlighting in [clike](http://codemirror.net/mode/clike/index.html) mode
|
841 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.3.0...5.4.0)
|
842 |
+
|
843 |
+
## 5.3.0 (2015-05-20)
|
844 |
+
|
845 |
+
* Fix several regressions in the [`show-hint`](http://codemirror.net/doc/manual.html#addon_show-hint) addon (`completeSingle` option, `"shown"` and `"close"` events)
|
846 |
+
* The [vim mode](http://codemirror.net/demo/vim.html) API was [documented](http://codemirror.net/doc/manual.html#vimapi)
|
847 |
+
* New modes: [ASN.1](http://codemirror.net/mode/asn.1/index.html), [TTCN](http://codemirror.net/mode/ttcn/index.html), and [TTCN-CFG](http://codemirror.net/mode/ttcn-cfg/index.html)
|
848 |
+
* The [clike](http://codemirror.net/mode/clike/index.html) mode can now deep-indent `switch` statements, and roughly recognizes types and defined identifiers
|
849 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.2.0...5.3.0)
|
850 |
+
|
851 |
+
## 5.2.0 (2015-04-20)
|
852 |
+
|
853 |
+
* Fix several race conditions in [`show-hint`](http://codemirror.net/doc/manual.html#addon_show-hint)'s asynchronous mode
|
854 |
+
* Fix backspace binding in [Sublime bindings](http://codemirror.net/demo/sublime.html)
|
855 |
+
* Change the way IME is handled in the `"textarea"` [input style](http://codemirror.net/doc/manual.html#option_inputStyle)
|
856 |
+
* New modes: [MUMPS](http://codemirror.net/mode/mumps/index.html), [Handlebars](http://codemirror.net/mode/handlebars/index.html)
|
857 |
+
* Rewritten modes: [Django](http://codemirror.net/mode/django/index.html), [Z80](http://codemirror.net/mode/z80/index.html)
|
858 |
+
* New theme: [Liquibyte](http://codemirror.net/demo/theme.html#liquibyte)
|
859 |
+
* New option: [`lineWiseCopyCut`](http://codemirror.net/doc/manual.html#option_lineWiseCopyCut)
|
860 |
+
* The [Vim mode](http://codemirror.net/demo/vim.html) now supports buffer-local options and the `filetype` setting
|
861 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.1.0...5.2.0)
|
862 |
+
|
863 |
+
## 5.1.0 (2015-03-23)
|
864 |
+
|
865 |
+
* New modes: [ASCII armor](http://codemirror.net/mode/asciiarmor/index.html) (PGP data), [Troff](http://codemirror.net/mode/troff/index.html), and [CMake](http://codemirror.net/mode/cmake/index.html).
|
866 |
+
* Remove SmartyMixed mode, rewrite [Smarty](http://codemirror.net/mode/smarty/index.html) mode to supersede it.
|
867 |
+
* New commands in the [merge addon](http://codemirror.net/doc/manual.html#addon_merge): `goNextDiff` and `goPrevDiff`.
|
868 |
+
* The [closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets) can now be configured per mode.
|
869 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.0.0...5.1.0).
|
870 |
+
|
871 |
+
## 5.0.0 (2015-02-20)
|
872 |
+
|
873 |
+
* Experimental mobile support (tested on iOS, Android Chrome, stock Android browser)
|
874 |
+
* New option [`inputStyle`](http://codemirror.net/doc/manual.html#option_inputStyle) to switch between hidden textarea and contenteditable input.
|
875 |
+
* The [`getInputField`](http://codemirror.net/doc/manual.html#getInputField) method is no longer guaranteed to return a textarea.
|
876 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.13.0...5.0.0).
|
877 |
+
|
878 |
+
## 4.13.0 (2015-02-20)
|
879 |
+
|
880 |
+
* Fix the way the [`closetag`](http://codemirror.net/demo/closetag.html) demo handles the slash character.
|
881 |
+
* New modes: [Forth](http://codemirror.net/mode/forth/index.html), [Stylus](http://codemirror.net/mode/stylus/index.html).
|
882 |
+
* Make the [CSS mode](http://codemirror.net/mode/css/index.html) understand some modern CSS extensions.
|
883 |
+
* Have the [Scala mode](http://codemirror.net/mode/clike/index.html) handle symbols and triple-quoted strings.
|
884 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.12.0...4.13.0).
|
885 |
+
|
886 |
+
## 4.12.0 (2015-01-22)
|
887 |
+
|
888 |
+
* The [`closetag`](http://codemirror.net/doc/manual.html#addon_closetag) addon now defines a `"closeTag"` command.
|
889 |
+
* Adds a `findModeByFileName` to the [mode metadata](http://codemirror.net/doc/manual.html#addon_meta) addon.
|
890 |
+
* [Simple mode](http://codemirror.net/demo/simplemode.html) rules can now contain a `sol` property to only match at the start of a line.
|
891 |
+
* New addon: [`selection-pointer`](http://codemirror.net/doc/manual.html#addon_selection-pointer) to style the mouse cursor over the selection.
|
892 |
+
* Improvements to the [Sass mode](http://codemirror.net/mode/sass/index.html)'s indentation.
|
893 |
+
* The [Vim keymap](http://codemirror.net/demo/vim.html)'s search functionality now supports [scrollbar annotation](http://codemirror.net/doc/manual.html#addon_matchesonscrollbar).
|
894 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.11.0...4.12.0).
|
895 |
+
|
896 |
+
## 4.11.0 (2015-01-09)
|
897 |
+
|
898 |
+
Unfortunately, 4.10 did not take care of the Firefox scrolling issue entirely. This release adds two more patches to address that.
|
899 |
+
|
900 |
+
## 4.10.0 (2014-12-29)
|
901 |
+
|
902 |
+
Emergency single-patch update to 4.9\. Fixes Firefox-specific problem where the cursor could end up behind the horizontal scrollbar.
|
903 |
+
|
904 |
+
## 4.9.0 (2014-12-23)
|
905 |
+
|
906 |
+
* Overhauled scroll bar handling. Add pluggable [scrollbar implementations](http://codemirror.net/demo/simplescrollbars.html).
|
907 |
+
* Tweaked behavior for the [completion addons](http://codemirror.net/doc/manual.html#addon_show-hint) to not take text after cursor into account.
|
908 |
+
* Two new optional features in the [merge addon](http://codemirror.net/doc/manual.html#addon_merge): aligning editors, and folding unchanged text.
|
909 |
+
* New modes: [Dart](http://codemirror.net/mode/dart/index.html), [EBNF](http://codemirror.net/mode/ebnf/index.html), [spreadsheet](http://codemirror.net/mode/spreadsheet/index.html), and [Soy](http://codemirror.net/mode/soy/index.html).
|
910 |
+
* New [addon](http://codemirror.net/demo/panel.html) to show persistent panels below/above an editor.
|
911 |
+
* New themes: [zenburn](http://codemirror.net/demo/theme.html#zenburn) and [tomorrow night bright](http://codemirror.net/demo/theme.html#tomorrow-night-bright).
|
912 |
+
* Allow ctrl-click to clear existing cursors.
|
913 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.8.0...4.9.0).
|
914 |
+
|
915 |
+
## 4.8.0 (2014-11-22)
|
916 |
+
|
917 |
+
* Built-in support for [multi-stroke key bindings](http://codemirror.net/doc/manual.html#normalizeKeyMap).
|
918 |
+
* New method: [`getLineTokens`](http://codemirror.net/doc/manual.html#getLineTokens).
|
919 |
+
* New modes: [dockerfile](http://codemirror.net/mode/dockerfile/index.html), [IDL](http://codemirror.net/mode/idl/index.html), [Objective C](http://codemirror.net/mode/clike/index.html) (crude).
|
920 |
+
* Support styling of gutter backgrounds, allow `"gutter"` styles in [`addLineClass`](http://codemirror.net/doc/manual.html#addLineClass).
|
921 |
+
* Many improvements to the [Vim mode](http://codemirror.net/demo/vim.html), rewritten visual mode.
|
922 |
+
* Improvements to modes: [gfm](http://codemirror.net/mode/gfm/index.html) (strikethrough), [SPARQL](http://codemirror.net/mode/sparql/index.html) (version 1.1 support), and [sTeX](http://codemirror.net/mode/stex/index.html) (no more runaway math mode).
|
923 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.7.0...4.8.0).
|
924 |
+
|
925 |
+
## 4.7.0 (2014-10-20)
|
926 |
+
|
927 |
+
* **Incompatible**: The [lint addon](http://codemirror.net/demo/lint.html) now passes the editor's value as first argument to asynchronous lint functions, for consistency. The editor is still passed, as fourth argument.
|
928 |
+
* Improved handling of unicode identifiers in modes for languages that support them.
|
929 |
+
* More mode improvements: [CoffeeScript](http://codemirror.net/mode/coffeescript/index.html) (indentation), [Verilog](http://codemirror.net/mode/verilog/index.html) (indentation), [Scala](http://codemirror.net/mode/clike/index.html) (indentation, triple-quoted strings), and [PHP](http://codemirror.net/mode/php/index.html) (interpolated variables in heredoc strings).
|
930 |
+
* New modes: [Textile](http://codemirror.net/mode/textile/index.html) and [Tornado templates](http://codemirror.net/mode/tornado/index.html).
|
931 |
+
* Experimental new [way to define modes](http://codemirror.net/demo/simplemode.html).
|
932 |
+
* Improvements to the [Vim bindings](http://codemirror.net/demo/vim.html): Arbitrary insert mode key mappings are now possible, and text objects are supported in visual mode.
|
933 |
+
* The mode [meta-information file](http://codemirror.net/mode/meta.js) now includes information about file extensions, and [helper functions](http://codemirror.net/doc/manual.html#addon_meta) `findModeByMIME` and `findModeByExtension`.
|
934 |
+
* New logo!
|
935 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.6.0...4.7.0).
|
936 |
+
|
937 |
+
## 4.6.0 (2014-09-19)
|
938 |
+
|
939 |
+
* New mode: [Modelica](http://codemirror.net/mode/modelica/index.html)
|
940 |
+
* New method: [`findWordAt`](http://codemirror.net/doc/manual.html#findWordAt)
|
941 |
+
* Make it easier to [use text background styling](http://codemirror.net/demo/markselection.html)
|
942 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.5.0...4.6.0).
|
943 |
+
|
944 |
+
## 4.5.0 (2014-08-21)
|
945 |
+
|
946 |
+
* Fix several serious bugs with horizontal scrolling
|
947 |
+
* New mode: [Slim](http://codemirror.net/mode/slim/index.html)
|
948 |
+
* New command: [`goLineLeftSmart`](http://codemirror.net/doc/manual.html#command_goLineLeftSmart)
|
949 |
+
* More fixes and extensions for the [Vim](http://codemirror.net/demo/vim.html) visual block mode
|
950 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.4.0...4.5.0).
|
951 |
+
|
952 |
+
## 4.4.0 (2014-07-21)
|
953 |
+
|
954 |
+
* **Note:** Some events might now fire in slightly different order (`"change"` is still guaranteed to fire before `"cursorActivity"`)
|
955 |
+
* Nested operations in multiple editors are now synced (complete at same time, reducing DOM reflows)
|
956 |
+
* Visual block mode for [vim](http://codemirror.net/demo/vim.html) (<C-v>) is nearly complete
|
957 |
+
* New mode: [Kotlin](http://codemirror.net/mode/kotlin/index.html)
|
958 |
+
* Better multi-selection paste for text copied from multiple CodeMirror selections
|
959 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.3.0...4.4.0).
|
960 |
+
|
961 |
+
## 4.3.0 (2014-06-23)
|
962 |
+
|
963 |
+
* Several [vim bindings](http://codemirror.net/demo/vim.html) improvements: search and exCommand history, global flag for `:substitute`, `:global` command.
|
964 |
+
* Allow hiding the cursor by setting [`cursorBlinkRate`](http://codemirror.net/doc/manual.html#option_cursorBlinkRate) to a negative value.
|
965 |
+
* Make gutter markers themeable, use this in foldgutter.
|
966 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.2.0...4.3.0).
|
967 |
+
|
968 |
+
## 4.2.0 (2014-05-19)
|
969 |
+
|
970 |
+
* Fix problem where some modes were broken by the fact that empty tokens were forbidden.
|
971 |
+
* Several fixes to context menu handling.
|
972 |
+
* On undo, scroll _change_, not cursor, into view.
|
973 |
+
* Rewritten [Jade](http://codemirror.net/mode/jade/index.html) mode.
|
974 |
+
* Various improvements to [Shell](http://codemirror.net/mode/shell/index.html) (support for more syntax) and [Python](http://codemirror.net/mode/python/index.html) (better indentation) modes.
|
975 |
+
* New mode: [Cypher](http://codemirror.net/mode/cypher/index.html).
|
976 |
+
* New theme: [Neo](http://codemirror.net/demo/theme.html#neo).
|
977 |
+
* Support direct styling options (color, line style, width) in the [rulers](http://codemirror.net/doc/manual.html#addon_rulers) addon.
|
978 |
+
* Recognize per-editor configuration for the [show-hint](http://codemirror.net/doc/manual.html#addon_show-hint) and [foldcode](http://codemirror.net/doc/manual.html#addon_foldcode) addons.
|
979 |
+
* More intelligent scanning for existing close tags in [closetag](http://codemirror.net/doc/manual.html#addon_closetag) addon.
|
980 |
+
* In the [Vim bindings](http://codemirror.net/demo/vim.html): Fix bracket matching, support case conversion in visual mode, visual paste, append action.
|
981 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.1.0...4.2.0).
|
982 |
+
|
983 |
+
## 4.1.0 (2014-04-22)
|
984 |
+
|
985 |
+
* _Slightly incompatible_: The [`"cursorActivity"`](http://codemirror.net/doc/manual.html#event_cursorActivity) event now fires after all other events for the operation (and only for handlers that were actually registered at the time the activity happened).
|
986 |
+
* New command: [`insertSoftTab`](http://codemirror.net/doc/manual.html#command_insertSoftTab).
|
987 |
+
* New mode: [Django](http://codemirror.net/mode/django/index.html).
|
988 |
+
* Improved modes: [Verilog](http://codemirror.net/mode/verilog/index.html) (rewritten), [Jinja2](http://codemirror.net/mode/jinja2/index.html), [Haxe](http://codemirror.net/mode/haxe/index.html), [PHP](http://codemirror.net/mode/php/index.html) (string interpolation highlighted), [JavaScript](http://codemirror.net/mode/javascript/index.html) (indentation of trailing else, template strings), [LiveScript](http://codemirror.net/mode/livescript/index.html) (multi-line strings).
|
989 |
+
* Many small issues from the 3.x→4.x transition were found and fixed.
|
990 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.0.3...4.1.0).
|
991 |
+
|
992 |
+
## 3.24.0 (2014-04-22)
|
993 |
+
|
994 |
+
Merges the improvements from 4.1 that could easily be applied to the 3.x code. Also improves the way the editor size is updated when line widgets change.
|
995 |
+
|
996 |
+
## 3.23.0 (2014-03-20)
|
997 |
+
|
998 |
+
* In the [XML mode](http://codemirror.net/mode/xml/index.html), add `brackets` style to angle brackets, fix case-sensitivity of tags for HTML.
|
999 |
+
* New mode: [Dylan](http://codemirror.net/mode/dylan/index.html).
|
1000 |
+
* Many improvements to the [Vim bindings](http://codemirror.net/demo/vim.html).
|
1001 |
+
|
1002 |
+
## 3.22.0 (2014-02-21)
|
1003 |
+
|
1004 |
+
* Adds the [`findMarks`](http://codemirror.net/doc/manual.html#findMarks) method.
|
1005 |
+
* New addons: [rulers](http://codemirror.net/doc/manual.html#addon_rulers), markdown-fold, yaml-lint.
|
1006 |
+
* New theme: [mdn-like](http://codemirror.net/demo/theme.html#mdn-like).
|
1007 |
+
* New mode: [Solr](http://codemirror.net/mode/solr/index.html).
|
1008 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.21.0...3.22.0).
|
1009 |
+
|
1010 |
+
## 3.21.0 (2014-01-16)
|
1011 |
+
|
1012 |
+
* Auto-indenting a block will no longer add trailing whitespace to blank lines.
|
1013 |
+
* Marking text has a new option [`clearWhenEmpty`](http://codemirror.net/doc/manual.html#markText) to control auto-removal.
|
1014 |
+
* Several bugfixes in the handling of bidirectional text.
|
1015 |
+
* The [XML](http://codemirror.net/mode/xml/index.html) and [CSS](http://codemirror.net/mode/css/index.html) modes were largely rewritten. [LESS](http://codemirror.net/mode/css/less.html) support was added to the CSS mode.
|
1016 |
+
* The OCaml mode was moved to an [mllike](http://codemirror.net/mode/mllike/index.html) mode, F# support added.
|
1017 |
+
* Make it possible to fetch multiple applicable helper values with [`getHelpers`](http://codemirror.net/doc/manual.html#getHelpers), and to register helpers matched on predicates with [`registerGlobalHelper`](http://codemirror.net/doc/manual.html#registerGlobalHelper).
|
1018 |
+
* New theme [pastel-on-dark](http://codemirror.net/demo/theme.html#pastel-on-dark).
|
1019 |
+
* Better ECMAScript 6 support in [JavaScript](http://codemirror.net/mode/javascript/index.html) mode.
|
1020 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.20.0...3.21.0).
|
1021 |
+
|
1022 |
+
## 3.20.0 (2013-11-21)
|
1023 |
+
|
1024 |
+
* New modes: [Julia](http://codemirror.net/mode/julia/index.html) and [PEG.js](http://codemirror.net/mode/pegjs/index.html).
|
1025 |
+
* Support ECMAScript 6 in the [JavaScript mode](http://codemirror.net/mode/javascript/index.html).
|
1026 |
+
* Improved indentation for the [CoffeeScript mode](http://codemirror.net/mode/coffeescript/index.html).
|
1027 |
+
* Make non-printable-character representation [configurable](http://codemirror.net/doc/manual.html#option_specialChars).
|
1028 |
+
* Add ‘notification’ functionality to [dialog](http://codemirror.net/doc/manual.html#addon_dialog) addon.
|
1029 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.19.0...3.20.0).
|
1030 |
+
|
1031 |
+
## 3.19.0 (2013-10-21)
|
1032 |
+
|
1033 |
+
* New modes: [Eiffel](http://codemirror.net/mode/eiffel/index.html), [Gherkin](http://codemirror.net/mode/gherkin/index.html), [MSSQL dialect](http://codemirror.net/mode/sql/?mime=text/x-mssql).
|
1034 |
+
* New addons: [hardwrap](http://codemirror.net/doc/manual.html#addon_hardwrap), [sql-hint](http://codemirror.net/doc/manual.html#addon_sql-hint).
|
1035 |
+
* New theme: [MBO](http://codemirror.net/demo/theme.html#mbo).
|
1036 |
+
* Add [support](http://codemirror.net/doc/manual.html#token_style_line) for line-level styling from mode tokenizers.
|
1037 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.18.0...3.19.0).
|
1038 |
+
|
1039 |
+
## 3.18.0 (2013-09-23)
|
1040 |
+
|
1041 |
+
Emergency release to fix a problem in 3.17 where `.setOption("lineNumbers", false)` would raise an error.
|
1042 |
+
|
1043 |
+
## 3.17.0 (2013-09-23)
|
1044 |
+
|
1045 |
+
* New modes: [Fortran](http://codemirror.net/mode/fortran/index.html), [Octave](http://codemirror.net/mode/octave/index.html) (Matlab), [TOML](http://codemirror.net/mode/toml/index.html), and [DTD](http://codemirror.net/mode/dtd/index.html).
|
1046 |
+
* New addons: [`css-lint`](http://codemirror.net/addon/lint/css-lint.js), [`css-hint`](http://codemirror.net/doc/manual.html#addon_css-hint).
|
1047 |
+
* Improve resilience to CSS 'frameworks' that globally mess up `box-sizing`.
|
1048 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.16.0...3.17.0).
|
1049 |
+
|
1050 |
+
## 3.16.0 (2013-08-21)
|
1051 |
+
|
1052 |
+
* The whole codebase is now under a single [license](http://codemirror.net/LICENSE) file.
|
1053 |
+
* The project page was overhauled and redesigned.
|
1054 |
+
* New themes: [Paraiso](http://codemirror.net/demo/theme.html#paraiso-dark) ([light](http://codemirror.net/demo/theme.html#paraiso-light)), [The Matrix](http://codemirror.net/demo/theme.html#the-matrix).
|
1055 |
+
* Improved interaction between themes and [active-line](http://codemirror.net/doc/manual.html#addon_active-line)/[matchbrackets](http://codemirror.net/doc/manual.html#addon_matchbrackets) addons.
|
1056 |
+
* New [folding](http://codemirror.net/doc/manual.html#addon_foldcode) function `CodeMirror.fold.comment`.
|
1057 |
+
* Added [fullscreen](http://codemirror.net/doc/manual.html#addon_fullscreen) addon.
|
1058 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.15.0...3.16.0).
|
1059 |
+
|
1060 |
+
## 3.15.0 (2013-07-29)
|
1061 |
+
|
1062 |
+
* New modes: [Jade](http://codemirror.net/mode/jade/index.html), [Nginx](http://codemirror.net/mode/nginx/index.html).
|
1063 |
+
* New addons: [Tern](http://codemirror.net/demo/tern.html), [matchtags](http://codemirror.net/doc/manual.html#addon_matchtags), and [foldgutter](http://codemirror.net/doc/manual.html#addon_foldgutter).
|
1064 |
+
* Introduced [_helper_](http://codemirror.net/doc/manual.html#getHelper) concept ([context](https://groups.google.com/forum/#!msg/codemirror/cOc0xvUUEUU/nLrX1-qnidgJ)).
|
1065 |
+
* New method: [`getModeAt`](http://codemirror.net/doc/manual.html#getModeAt).
|
1066 |
+
* New themes: base16 [dark](http://codemirror.net/demo/theme.html#base16-dark)/[light](http://codemirror.net/demo/theme.html#base16-light), 3024 [dark](http://codemirror.net/demo/theme.html#3024-night)/[light](http://codemirror.net/demo/theme.html#3024-day), [tomorrow-night](http://codemirror.net/demo/theme.html#tomorrow-night-eighties).
|
1067 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.14.0...3.15.0).
|
1068 |
+
|
1069 |
+
## 3.14.0 (2013-06-20)
|
1070 |
+
|
1071 |
+
* New addons: [trailing space highlight](http://codemirror.net/doc/manual.html#addon_trailingspace), [XML completion](http://codemirror.net/doc/manual.html#addon_xml-hint) (rewritten), and [diff merging](http://codemirror.net/doc/manual.html#addon_merge).
|
1072 |
+
* [`markText`](http://codemirror.net/doc/manual.html#markText) and [`addLineWidget`](http://codemirror.net/doc/manual.html#addLineWidget) now take a `handleMouseEvents` option.
|
1073 |
+
* New methods: [`lineAtHeight`](http://codemirror.net/doc/manual.html#lineAtHeight), [`getTokenTypeAt`](http://codemirror.net/doc/manual.html#getTokenTypeAt).
|
1074 |
+
* More precise cleanness-tracking using [`changeGeneration`](http://codemirror.net/doc/manual.html#changeGeneration) and [`isClean`](http://codemirror.net/doc/manual.html#isClean).
|
1075 |
+
* Many extensions to [Emacs](http://codemirror.net/demo/emacs.html) mode (prefixes, more navigation units, and more).
|
1076 |
+
* New events [`"keyHandled"`](http://codemirror.net/doc/manual.html#event_keyHandled) and [`"inputRead"`](http://codemirror.net/doc/manual.html#event_inputRead).
|
1077 |
+
* Various improvements to [Ruby](http://codemirror.net/mode/ruby/index.html), [Smarty](http://codemirror.net/mode/smarty/index.html), [SQL](http://codemirror.net/mode/sql/index.html), and [Vim](http://codemirror.net/demo/vim.html) modes.
|
1078 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.13.0...3.14.0).
|
1079 |
+
|
1080 |
+
## 3.13.0 (2013-05-20)
|
1081 |
+
|
1082 |
+
* New modes: [COBOL](http://codemirror.net/mode/cobol/index.html) and [HAML](http://codemirror.net/mode/haml/index.html).
|
1083 |
+
* New options: [`cursorScrollMargin`](http://codemirror.net/doc/manual.html#option_cursorScrollMargin) and [`coverGutterNextToScrollbar`](http://codemirror.net/doc/manual.html#option_coverGutterNextToScrollbar).
|
1084 |
+
* New addon: [commenting](http://codemirror.net/doc/manual.html#addon_comment).
|
1085 |
+
* More features added to the [Vim keymap](http://codemirror.net/demo/vim.html).
|
1086 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.12...3.13.0).
|
1087 |
+
|
1088 |
+
## 3.12.0 (2013-04-19)
|
1089 |
+
|
1090 |
+
* New mode: [GNU assembler](http://codemirror.net/mode/gas/index.html).
|
1091 |
+
* New options: [`maxHighlightLength`](http://codemirror.net/doc/manual.html#option_maxHighlightLength) and [`historyEventDelay`](http://codemirror.net/doc/manual.html#option_historyEventDelay).
|
1092 |
+
* Added [`addToHistory`](http://codemirror.net/doc/manual.html#mark_addToHistory) option for `markText`.
|
1093 |
+
* Various fixes to JavaScript tokenization and indentation corner cases.
|
1094 |
+
* Further improvements to the vim mode.
|
1095 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.11...v3.12).
|
1096 |
+
|
1097 |
+
## 3.11.0 (2013-03-20)
|
1098 |
+
|
1099 |
+
* **Removed code:** `collapserange`, `formatting`, and `simple-hint` addons. `plsql` and `mysql` modes (use [`sql`](http://codemirror.net/mode/sql/index.html) mode).
|
1100 |
+
* **Moved code:** the range-finding functions for folding now have [their own files](http://codemirror.net/addon/fold/).
|
1101 |
+
* **Changed interface:** the [`continuecomment`](http://codemirror.net/doc/manual.html#addon_continuecomment) addon now exposes an option, rather than a command.
|
1102 |
+
* New modes: [SCSS](http://codemirror.net/mode/css/scss.html), [Tcl](http://codemirror.net/mode/tcl/index.html), [LiveScript](http://codemirror.net/mode/livescript/index.html), and [mIRC](http://codemirror.net/mode/mirc/index.html).
|
1103 |
+
* New addons: [`placeholder`](http://codemirror.net/demo/placeholder.html), [HTML completion](http://codemirror.net/demo/html5complete.html).
|
1104 |
+
* New methods: [`hasFocus`](http://codemirror.net/doc/manual.html#hasFocus), [`defaultCharWidth`](http://codemirror.net/doc/manual.html#defaultCharWidth).
|
1105 |
+
* New events: [`beforeCursorEnter`](http://codemirror.net/doc/manual.html#event_beforeCursorEnter), [`renderLine`](http://codemirror.net/doc/manual.html#event_renderLine).
|
1106 |
+
* Many improvements to the [`show-hint`](http://codemirror.net/doc/manual.html#addon_show-hint) completion dialog addon.
|
1107 |
+
* Tweak behavior of by-word cursor motion.
|
1108 |
+
* Further improvements to the [vim mode](http://codemirror.net/demo/vim.html).
|
1109 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.1...v3.11).
|
1110 |
+
|
1111 |
+
## 3.02.0 (2013-01-25)
|
1112 |
+
|
1113 |
+
Single-bugfix release. Fixes a problem that prevents CodeMirror instances from being garbage-collected after they become unused.
|
1114 |
+
|
1115 |
+
## 3.01.0 (2013-01-21)
|
1116 |
+
|
1117 |
+
* Move all add-ons into an organized directory structure under [`/addon`](http://codemirror.net/addon/). **You might have to adjust your paths.**
|
1118 |
+
* New modes: [D](http://codemirror.net/mode/d/index.html), [Sass](http://codemirror.net/mode/sass/index.html), [APL](http://codemirror.net/mode/apl/index.html), [SQL](http://codemirror.net/mode/sql/index.html) (configurable), and [Asterisk](http://codemirror.net/mode/asterisk/index.html).
|
1119 |
+
* Several bugfixes in right-to-left text support.
|
1120 |
+
* Add [`rtlMoveVisually`](http://codemirror.net/doc/manual.html#option_rtlMoveVisually) option.
|
1121 |
+
* Improvements to vim keymap.
|
1122 |
+
* Add built-in (lightweight) [overlay mode](http://codemirror.net/doc/manual.html#addOverlay) support.
|
1123 |
+
* Support `showIfHidden` option for [line widgets](http://codemirror.net/doc/manual.html#addLineWidget).
|
1124 |
+
* Add simple [Python hinter](http://codemirror.net/doc/manual.html#addon_python-hint).
|
1125 |
+
* Bring back the [`fixedGutter`](http://codemirror.net/doc/manual.html#option_fixedGutter) option.
|
1126 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.0...v3.01).
|
1127 |
+
|
1128 |
+
## 3.1.0 (2013-02-21)
|
1129 |
+
|
1130 |
+
* **Incompatible:** key handlers may now _return_, rather than _throw_ `CodeMirror.Pass` to signal they didn't handle the key.
|
1131 |
+
* Make documents a [first-class construct](http://codemirror.net/doc/manual.html#api_doc), support split views and subviews.
|
1132 |
+
* Add a [new module](http://codemirror.net/doc/manual.html#addon_show-hint) for showing completion hints. Deprecate `simple-hint.js`.
|
1133 |
+
* Extend [htmlmixed mode](http://codemirror.net/mode/htmlmixed/index.html) to allow custom handling of script types.
|
1134 |
+
* Support an `insertLeft` option to [`setBookmark`](http://codemirror.net/doc/manual.html#setBookmark).
|
1135 |
+
* Add an [`eachLine`](http://codemirror.net/doc/manual.html#eachLine) method to iterate over a document.
|
1136 |
+
* New addon modules: [selection marking](http://codemirror.net/demo/markselection.html), [linting](http://codemirror.net/demo/lint.html), and [automatic bracket closing](http://codemirror.net/demo/closebrackets.html).
|
1137 |
+
* Add [`"beforeChange"`](http://codemirror.net/doc/manual.html#event_beforeChange) and [`"beforeSelectionChange"`](http://codemirror.net/doc/manual.html#event_beforeSelectionChange) events.
|
1138 |
+
* Add [`"hide"`](http://codemirror.net/doc/manual.html#event_hide) and [`"unhide"`](http://codemirror.net/doc/manual.html#event_unhide) events to marked ranges.
|
1139 |
+
* Fix [`coordsChar`](http://codemirror.net/doc/manual.html#coordsChar)'s interpretation of its argument to match the documentation.
|
1140 |
+
* New modes: [Turtle](http://codemirror.net/mode/turtle/index.html) and [Q](http://codemirror.net/mode/q/index.html).
|
1141 |
+
* Further improvements to the [vim mode](http://codemirror.net/demo/vim.html).
|
1142 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.01...v3.1).
|
1143 |
+
|
1144 |
+
## 3.0.0 (2012-12-10)
|
1145 |
+
|
1146 |
+
**New major version**. Only partially backwards-compatible. See the [upgrading guide](http://codemirror.net/doc/upgrade_v3.html) for more information. Changes since release candidate 2:
|
1147 |
+
|
1148 |
+
* Rewritten VIM mode.
|
1149 |
+
* Fix a few minor scrolling and sizing issues.
|
1150 |
+
* Work around Safari segfault when dragging.
|
1151 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.0rc2...v3.0).
|
1152 |
+
|
1153 |
+
## 2.38.0 (2013-01-21)
|
1154 |
+
|
1155 |
+
Integrate some bugfixes, enhancements to the vim keymap, and new modes ([D](http://codemirror.net/mode/d/index.html), [Sass](http://codemirror.net/mode/sass/index.html), [APL](http://codemirror.net/mode/apl/index.html)) from the v3 branch.
|
1156 |
+
|
1157 |
+
## 2.37.0 (2012-12-20)
|
1158 |
+
|
1159 |
+
* New mode: [SQL](http://codemirror.net/mode/sql/index.html) (will replace [plsql](http://codemirror.net/mode/plsql/index.html) and [mysql](http://codemirror.net/mode/mysql/index.html) modes).
|
1160 |
+
* Further work on the new VIM mode.
|
1161 |
+
* Fix Cmd/Ctrl keys on recent Operas on OS X.
|
1162 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v2.36...v2.37).
|
1163 |
+
|
1164 |
+
## 2.36.0 (2012-11-20)
|
1165 |
+
|
1166 |
+
* New mode: [Z80 assembly](http://codemirror.net/mode/z80/index.html).
|
1167 |
+
* New theme: [Twilight](http://codemirror.net/demo/theme.html#twilight).
|
1168 |
+
* Add command-line compression helper.
|
1169 |
+
* Make [`scrollIntoView`](http://codemirror.net/doc/manual.html#scrollIntoView) public.
|
1170 |
+
* Add [`defaultTextHeight`](http://codemirror.net/doc/manual.html#defaultTextHeight) method.
|
1171 |
+
* Various extensions to the vim keymap.
|
1172 |
+
* Make [PHP mode](http://codemirror.net/mode/php/index.html) build on [mixed HTML mode](http://codemirror.net/mode/htmlmixed/index.html).
|
1173 |
+
* Add [comment-continuing](http://codemirror.net/doc/manual.html#addon_continuecomment) add-on.
|
1174 |
+
* Full [list of patches](http://codemirror.net/https://github.com/codemirror/CodeMirror/compare/v2.35...v2.36).
|
1175 |
+
|
1176 |
+
## 2.35.0 (2012-10-22)
|
1177 |
+
|
1178 |
+
* New (sub) mode: [TypeScript](http://codemirror.net/mode/javascript/typescript.html).
|
1179 |
+
* Don't overwrite (insert key) when pasting.
|
1180 |
+
* Fix several bugs in [`markText`](http://codemirror.net/doc/manual.html#markText)/undo interaction.
|
1181 |
+
* Better indentation of JavaScript code without semicolons.
|
1182 |
+
* Add [`defineInitHook`](http://codemirror.net/doc/manual.html#defineInitHook) function.
|
1183 |
+
* Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v2.34...v2.35).
|
1184 |
+
|
1185 |
+
## 2.34.0 (2012-09-19)
|
1186 |
+
|
1187 |
+
* New mode: [Common Lisp](http://codemirror.net/mode/commonlisp/index.html).
|
1188 |
+
* Fix right-click select-all on most browsers.
|
1189 |
+
* Change the way highlighting happens:
|
1190 |
+
Saves memory and CPU cycles.
|
1191 |
+
`compareStates` is no longer needed.
|
1192 |
+
`onHighlightComplete` no longer works.
|
1193 |
+
* Integrate mode (Markdown, XQuery, CSS, sTex) tests in central testsuite.
|
1194 |
+
* Add a [`CodeMirror.version`](http://codemirror.net/doc/manual.html#version) property.
|
1195 |
+
* More robust handling of nested modes in [formatting](http://codemirror.net/demo/formatting.html) and [closetag](http://codemirror.net/demo/closetag.html) plug-ins.
|
1196 |
+
* Un/redo now preserves [marked text](http://codemirror.net/doc/manual.html#markText) and bookmarks.
|
1197 |
+
* [Full list](https://github.com/codemirror/CodeMirror/compare/v2.33...v2.34) of patches.
|
1198 |
+
|
1199 |
+
## 2.33.0 (2012-08-23)
|
1200 |
+
|
1201 |
+
* New mode: [Sieve](http://codemirror.net/mode/sieve/index.html).
|
1202 |
+
* New [`getViewPort`](http://codemirror.net/doc/manual.html#getViewport) and [`onViewportChange`](http://codemirror.net/doc/manual.html#option_onViewportChange) API.
|
1203 |
+
* [Configurable](http://codemirror.net/doc/manual.html#option_cursorBlinkRate) cursor blink rate.
|
1204 |
+
* Make binding a key to `false` disabling handling (again).
|
1205 |
+
* Show non-printing characters as red dots.
|
1206 |
+
* More tweaks to the scrolling model.
|
1207 |
+
* Expanded testsuite. Basic linter added.
|
1208 |
+
* Remove most uses of `innerHTML`. Remove `CodeMirror.htmlEscape`.
|
1209 |
+
* [Full list](https://github.com/codemirror/CodeMirror/compare/v2.32...v2.33) of patches.
|
1210 |
+
|
1211 |
+
## 2.32.0 (2012-07-23)
|
1212 |
+
|
1213 |
+
Emergency fix for a bug where an editor with line wrapping on IE will break when there is _no_ scrollbar.
|
1214 |
+
|
1215 |
+
## 2.31.0 (2012-07-20)
|
1216 |
+
|
1217 |
+
* New modes: [OCaml](http://codemirror.net/mode/ocaml/index.html), [Haxe](http://codemirror.net/mode/haxe/index.html), and [VB.NET](http://codemirror.net/mode/vb/index.html).
|
1218 |
+
* Several fixes to the new scrolling model.
|
1219 |
+
* Add a [`setSize`](http://codemirror.net/doc/manual.html#setSize) method for programmatic resizing.
|
1220 |
+
* Add [`getHistory`](http://codemirror.net/doc/manual.html#getHistory) and [`setHistory`](http://codemirror.net/doc/manual.html#setHistory) methods.
|
1221 |
+
* Allow custom line separator string in [`getValue`](http://codemirror.net/doc/manual.html#getValue) and [`getRange`](http://codemirror.net/doc/manual.html#getRange).
|
1222 |
+
* Support double- and triple-click drag, double-clicking whitespace.
|
1223 |
+
* And more... [(all patches)](https://github.com/codemirror/CodeMirror/compare/v2.3...v2.31)
|
1224 |
+
|
1225 |
+
## 2.30.0 (2012-06-22)
|
1226 |
+
|
1227 |
+
* **New scrollbar implementation**. Should flicker less. Changes DOM structure of the editor.
|
1228 |
+
* New theme: [vibrant-ink](http://codemirror.net/demo/theme.html#vibrant-ink).
|
1229 |
+
* Many extensions to the VIM keymap (including text objects).
|
1230 |
+
* Add [mode-multiplexing](http://codemirror.net/demo/multiplex.html) utility script.
|
1231 |
+
* Fix bug where right-click paste works in read-only mode.
|
1232 |
+
* Add a [`getScrollInfo`](http://codemirror.net/doc/manual.html#getScrollInfo) method.
|
1233 |
+
* Lots of other [fixes](https://github.com/codemirror/CodeMirror/compare/v2.25...v2.3).
|
1234 |
+
|
1235 |
+
## 2.25.0 (2012-05-23)
|
1236 |
+
|
1237 |
+
* New mode: [Erlang](http://codemirror.net/mode/erlang/index.html).
|
1238 |
+
* **Remove xmlpure mode** (use [xml.js](http://codemirror.net/mode/xml/index.html)).
|
1239 |
+
* Fix line-wrapping in Opera.
|
1240 |
+
* Fix X Windows middle-click paste in Chrome.
|
1241 |
+
* Fix bug that broke pasting of huge documents.
|
1242 |
+
* Fix backspace and tab key repeat in Opera.
|
1243 |
+
|
1244 |
+
## 2.24.0 (2012-04-23)
|
1245 |
+
|
1246 |
+
* **Drop support for Internet Explorer 6**.
|
1247 |
+
* New modes: [Shell](http://codemirror.net/mode/shell/index.html), [Tiki wiki](http://codemirror.net/mode/tiki/index.html), [Pig Latin](http://codemirror.net/mode/pig/index.html).
|
1248 |
+
* New themes: [Ambiance](http://codemirror.net/demo/theme.html#ambiance), [Blackboard](http://codemirror.net/demo/theme.html#blackboard).
|
1249 |
+
* More control over drag/drop with [`dragDrop`](http://codemirror.net/doc/manual.html#option_dragDrop) and [`onDragEvent`](http://codemirror.net/doc/manual.html#option_onDragEvent) options.
|
1250 |
+
* Make HTML mode a bit less pedantic.
|
1251 |
+
* Add [`compoundChange`](http://codemirror.net/doc/manual.html#compoundChange) API method.
|
1252 |
+
* Several fixes in undo history and line hiding.
|
1253 |
+
* Remove (broken) support for `catchall` in key maps, add `nofallthrough` boolean field instead.
|
1254 |
+
|
1255 |
+
## 2.23.0 (2012-03-26)
|
1256 |
+
|
1257 |
+
* Change **default binding for tab**. Starting in 2.23, these bindings are default:
|
1258 |
+
* Tab: Insert tab character
|
1259 |
+
* Shift-tab: Reset line indentation to default
|
1260 |
+
* Ctrl/Cmd-[: Reduce line indentation (old tab behaviour)
|
1261 |
+
* Ctrl/Cmd-]: Increase line indentation (old shift-tab behaviour)
|
1262 |
+
* New modes: [XQuery](http://codemirror.net/mode/xquery/index.html) and [VBScript](http://codemirror.net/mode/vbscript/index.html).
|
1263 |
+
* Two new themes: [lesser-dark](http://codemirror.net/mode/less/index.html) and [xq-dark](http://codemirror.net/mode/xquery/index.html).
|
1264 |
+
* Differentiate between background and text styles in [`setLineClass`](http://codemirror.net/doc/manual.html#setLineClass).
|
1265 |
+
* Fix drag-and-drop in IE9+.
|
1266 |
+
* Extend [`charCoords`](http://codemirror.net/doc/manual.html#charCoords) and [`cursorCoords`](http://codemirror.net/doc/manual.html#cursorCoords) with a `mode` argument.
|
1267 |
+
* Add [`autofocus`](http://codemirror.net/doc/manual.html#option_autofocus) option.
|
1268 |
+
* Add [`findMarksAt`](http://codemirror.net/doc/manual.html#findMarksAt) method.
|
1269 |
+
|
1270 |
+
## 2.22.0 (2012-02-27)
|
1271 |
+
|
1272 |
+
* Allow [key handlers](http://codemirror.net/doc/manual.html#keymaps) to pass up events, allow binding characters.
|
1273 |
+
* Add [`autoClearEmptyLines`](http://codemirror.net/doc/manual.html#option_autoClearEmptyLines) option.
|
1274 |
+
* Properly use tab stops when rendering tabs.
|
1275 |
+
* Make PHP mode more robust.
|
1276 |
+
* Support indentation blocks in [code folder](http://codemirror.net/doc/manual.html#addon_foldcode).
|
1277 |
+
* Add a script for [highlighting instances of the selection](http://codemirror.net/doc/manual.html#addon_match-highlighter).
|
1278 |
+
* New [.properties](http://codemirror.net/mode/properties/index.html) mode.
|
1279 |
+
* Fix many bugs.
|
1280 |
+
|
1281 |
+
## 2.21.0 (2012-01-27)
|
1282 |
+
|
1283 |
+
* Added [LESS](http://codemirror.net/mode/less/index.html), [MySQL](http://codemirror.net/mode/mysql/index.html), [Go](http://codemirror.net/mode/go/index.html), and [Verilog](http://codemirror.net/mode/verilog/index.html) modes.
|
1284 |
+
* Add [`smartIndent`](http://codemirror.net/doc/manual.html#option_smartIndent) option.
|
1285 |
+
* Support a cursor in [`readOnly`](http://codemirror.net/doc/manual.html#option_readOnly)-mode.
|
1286 |
+
* Support assigning multiple styles to a token.
|
1287 |
+
* Use a new approach to drawing the selection.
|
1288 |
+
* Add [`scrollTo`](http://codemirror.net/doc/manual.html#scrollTo) method.
|
1289 |
+
* Allow undo/redo events to span non-adjacent lines.
|
1290 |
+
* Lots and lots of bugfixes.
|
1291 |
+
|
1292 |
+
## 2.20.0 (2011-12-20)
|
1293 |
+
|
1294 |
+
* Slightly incompatible API changes. Read [this](http://codemirror.net/doc/upgrade_v2.2.html).
|
1295 |
+
* New approach to [binding](http://codemirror.net/doc/manual.html#option_extraKeys) keys, support for [custom bindings](http://codemirror.net/doc/manual.html#option_keyMap).
|
1296 |
+
* Support for overwrite (insert).
|
1297 |
+
* [Custom-width](http://codemirror.net/doc/manual.html#option_tabSize) and [stylable](http://codemirror.net/demo/visibletabs.html) tabs.
|
1298 |
+
* Moved more code into [add-on scripts](http://codemirror.net/doc/manual.html#addons).
|
1299 |
+
* Support for sane vertical cursor movement in wrapped lines.
|
1300 |
+
* More reliable handling of editing [marked text](http://codemirror.net/doc/manual.html#markText).
|
1301 |
+
* Add minimal [emacs](http://codemirror.net/demo/emacs.html) and [vim](http://codemirror.net/demo/vim.html) bindings.
|
1302 |
+
* Rename `coordsFromIndex` to [`posFromIndex`](http://codemirror.net/doc/manual.html#posFromIndex), add [`indexFromPos`](http://codemirror.net/doc/manual.html#indexFromPos) method.
|
1303 |
+
|
1304 |
+
## 2.18.0 (2011-11-21)
|
1305 |
+
|
1306 |
+
Fixes `TextMarker.clear`, which is broken in 2.17.
|
1307 |
+
|
1308 |
+
## 2.17.0 (2011-11-21)
|
1309 |
+
|
1310 |
+
* Add support for [line wrapping](http://codemirror.net/doc/manual.html#option_lineWrapping) and [code folding](http://codemirror.net/doc/manual.html#hideLine).
|
1311 |
+
* Add [Github-style Markdown](http://codemirror.net/mode/gfm/index.html) mode.
|
1312 |
+
* Add [Monokai](http://codemirror.net/theme/monokai.css) and [Rubyblue](http://codemirror.net/theme/rubyblue.css) themes.
|
1313 |
+
* Add [`setBookmark`](http://codemirror.net/doc/manual.html#setBookmark) method.
|
1314 |
+
* Move some of the demo code into reusable components under [`lib/util`](http://codemirror.net/addon/).
|
1315 |
+
* Make screen-coord-finding code faster and more reliable.
|
1316 |
+
* Fix drag-and-drop in Firefox.
|
1317 |
+
* Improve support for IME.
|
1318 |
+
* Speed up content rendering.
|
1319 |
+
* Fix browser's built-in search in Webkit.
|
1320 |
+
* Make double- and triple-click work in IE.
|
1321 |
+
* Various fixes to modes.
|
1322 |
+
|
1323 |
+
## 2.16.0 (2011-10-27)
|
1324 |
+
|
1325 |
+
* Add [Perl](http://codemirror.net/mode/perl/index.html), [Rust](http://codemirror.net/mode/rust/index.html), [TiddlyWiki](http://codemirror.net/mode/tiddlywiki/index.html), and [Groovy](http://codemirror.net/mode/groovy/index.html) modes.
|
1326 |
+
* Dragging text inside the editor now moves, rather than copies.
|
1327 |
+
* Add a [`coordsFromIndex`](http://codemirror.net/doc/manual.html#coordsFromIndex) method.
|
1328 |
+
* **API change**: `setValue` now no longer clears history. Use [`clearHistory`](http://codemirror.net/doc/manual.html#clearHistory) for that.
|
1329 |
+
* **API change**: [`markText`](http://codemirror.net/doc/manual.html#markText) now returns an object with `clear` and `find` methods. Marked text is now more robust when edited.
|
1330 |
+
* Fix editing code with tabs in Internet Explorer.
|
1331 |
+
|
1332 |
+
## 2.15.0 (2011-09-26)
|
1333 |
+
|
1334 |
+
Fix bug that snuck into 2.14: Clicking the character that currently has the cursor didn't re-focus the editor.
|
1335 |
+
|
1336 |
+
## 2.14.0 (2011-09-26)
|
1337 |
+
|
1338 |
+
* Add [Clojure](http://codemirror.net/mode/clojure/index.html), [Pascal](http://codemirror.net/mode/pascal/index.html), [NTriples](http://codemirror.net/mode/ntriples/index.html), [Jinja2](http://codemirror.net/mode/jinja2/index.html), and [Markdown](http://codemirror.net/mode/markdown/index.html) modes.
|
1339 |
+
* Add [Cobalt](http://codemirror.net/theme/cobalt.css) and [Eclipse](http://codemirror.net/theme/eclipse.css) themes.
|
1340 |
+
* Add a [`fixedGutter`](http://codemirror.net/doc/manual.html#option_fixedGutter) option.
|
1341 |
+
* Fix bug with `setValue` breaking cursor movement.
|
1342 |
+
* Make gutter updates much more efficient.
|
1343 |
+
* Allow dragging of text out of the editor (on modern browsers).
|
1344 |
+
|
1345 |
+
## 2.13.0 (2011-08-23)
|
1346 |
+
|
1347 |
+
* Add [Ruby](http://codemirror.net/mode/ruby/index.html), [R](http://codemirror.net/mode/r/index.html), [CoffeeScript](http://codemirror.net/mode/coffeescript/index.html), and [Velocity](http://codemirror.net/mode/velocity/index.html) modes.
|
1348 |
+
* Add [`getGutterElement`](http://codemirror.net/doc/manual.html#getGutterElement) to API.
|
1349 |
+
* Several fixes to scrolling and positioning.
|
1350 |
+
* Add [`smartHome`](http://codemirror.net/doc/manual.html#option_smartHome) option.
|
1351 |
+
* Add an experimental [pure XML](http://codemirror.net/mode/xmlpure/index.html) mode.
|
1352 |
+
|
1353 |
+
## 2.12.0 (2011-07-25)
|
1354 |
+
|
1355 |
+
* Add a [SPARQL](http://codemirror.net/mode/sparql/index.html) mode.
|
1356 |
+
* Fix bug with cursor jumping around in an unfocused editor in IE.
|
1357 |
+
* Allow key and mouse events to bubble out of the editor. Ignore widget clicks.
|
1358 |
+
* Solve cursor flakiness after undo/redo.
|
1359 |
+
* Fix block-reindent ignoring the last few lines.
|
1360 |
+
* Fix parsing of multi-line attrs in XML mode.
|
1361 |
+
* Use `innerHTML` for HTML-escaping.
|
1362 |
+
* Some fixes to indentation in C-like mode.
|
1363 |
+
* Shrink horiz scrollbars when long lines removed.
|
1364 |
+
* Fix width feedback loop bug that caused the width of an inner DIV to shrink.
|
1365 |
+
|
1366 |
+
## 2.11.0 (2011-07-04)
|
1367 |
+
|
1368 |
+
* Add a [Scheme mode](http://codemirror.net/mode/scheme/index.html).
|
1369 |
+
* Add a `replace` method to search cursors, for cursor-preserving replacements.
|
1370 |
+
* Make the [C-like mode](http://codemirror.net/mode/clike/index.html) mode more customizable.
|
1371 |
+
* Update XML mode to spot mismatched tags.
|
1372 |
+
* Add `getStateAfter` API and `compareState` mode API methods for finer-grained mode magic.
|
1373 |
+
* Add a `getScrollerElement` API method to manipulate the scrolling DIV.
|
1374 |
+
* Fix drag-and-drop for Firefox.
|
1375 |
+
* Add a C# configuration for the [C-like mode](http://codemirror.net/mode/clike/index.html).
|
1376 |
+
* Add [full-screen editing](http://codemirror.net/demo/fullscreen.html) and [mode-changing](http://codemirror.net/demo/changemode.html) demos.
|
1377 |
+
|
1378 |
+
## 2.10.0 (2011-06-07)
|
1379 |
+
|
1380 |
+
Add a [theme](http://codemirror.net/doc/manual.html#option_theme) system ([demo](http://codemirror.net/demo/theme.html)). Note that this is not backwards-compatible—you'll have to update your styles and modes!
|
1381 |
+
|
1382 |
+
## 2.2.0 (2011-06-07)
|
1383 |
+
|
1384 |
+
* Add a [Lua mode](http://codemirror.net/mode/lua/index.html).
|
1385 |
+
* Fix reverse-searching for a regexp.
|
1386 |
+
* Empty lines can no longer break highlighting.
|
1387 |
+
* Rework scrolling model (the outer wrapper no longer does the scrolling).
|
1388 |
+
* Solve horizontal jittering on long lines.
|
1389 |
+
* Add [runmode.js](http://codemirror.net/demo/runmode.html).
|
1390 |
+
* Immediately re-highlight text when typing.
|
1391 |
+
* Fix problem with 'sticking' horizontal scrollbar.
|
1392 |
+
|
1393 |
+
## 2.1.0 (2011-05-26)
|
1394 |
+
|
1395 |
+
* Add a [Smalltalk mode](http://codemirror.net/mode/smalltalk/index.html).
|
1396 |
+
* Add a [reStructuredText mode](http://codemirror.net/mode/rst/index.html).
|
1397 |
+
* Add a [Python mode](http://codemirror.net/mode/python/index.html).
|
1398 |
+
* Add a [PL/SQL mode](http://codemirror.net/mode/plsql/index.html).
|
1399 |
+
* `coordsChar` now works
|
1400 |
+
* Fix a problem where `onCursorActivity` interfered with `onChange`.
|
1401 |
+
* Fix a number of scrolling and mouse-click-position glitches.
|
1402 |
+
* Pass information about the changed lines to `onChange`.
|
1403 |
+
* Support cmd-up/down on OS X.
|
1404 |
+
* Add triple-click line selection.
|
1405 |
+
* Don't handle shift when changing the selection through the API.
|
1406 |
+
* Support `"nocursor"` mode for `readOnly` option.
|
1407 |
+
* Add an `onHighlightComplete` option.
|
1408 |
+
* Fix the context menu for Firefox.
|
1409 |
+
|
1410 |
+
## 2.0.0 (2011-03-28)
|
1411 |
+
|
1412 |
+
CodeMirror 2 is a complete rewrite that's faster, smaller, simpler to use, and less dependent on browser quirks. See [this](http://codemirror.net/doc/internals.html) and [this](http://groups.google.com/group/codemirror/browse_thread/thread/5a8e894024a9f580) for more information.
|
inc/lib/codemirror/CONTRIBUTING.md
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# How to contribute
|
2 |
+
|
3 |
+
- [Getting help](#getting-help)
|
4 |
+
- [Submitting bug reports](#submitting-bug-reports)
|
5 |
+
- [Contributing code](#contributing-code)
|
6 |
+
|
7 |
+
## Getting help
|
8 |
+
|
9 |
+
Community discussion, questions, and informal bug reporting is done on the
|
10 |
+
[discuss.CodeMirror forum](http://discuss.codemirror.net).
|
11 |
+
|
12 |
+
## Submitting bug reports
|
13 |
+
|
14 |
+
The preferred way to report bugs is to use the
|
15 |
+
[GitHub issue tracker](http://github.com/codemirror/CodeMirror/issues). Before
|
16 |
+
reporting a bug, read these pointers.
|
17 |
+
|
18 |
+
**Note:** The issue tracker is for *bugs*, not requests for help. Questions
|
19 |
+
should be asked on the
|
20 |
+
[discuss.CodeMirror forum](http://discuss.codemirror.net) instead.
|
21 |
+
|
22 |
+
### Reporting bugs effectively
|
23 |
+
|
24 |
+
- CodeMirror is maintained by volunteers. They don't owe you anything, so be
|
25 |
+
polite. Reports with an indignant or belligerent tone tend to be moved to the
|
26 |
+
bottom of the pile.
|
27 |
+
|
28 |
+
- Include information about **the browser in which the problem occurred**. Even
|
29 |
+
if you tested several browsers, and the problem occurred in all of them,
|
30 |
+
mention this fact in the bug report. Also include browser version numbers and
|
31 |
+
the operating system that you're on.
|
32 |
+
|
33 |
+
- Mention which release of CodeMirror you're using. Preferably, try also with
|
34 |
+
the current development snapshot, to ensure the problem has not already been
|
35 |
+
fixed.
|
36 |
+
|
37 |
+
- Mention very precisely what went wrong. "X is broken" is not a good bug
|
38 |
+
report. What did you expect to happen? What happened instead? Describe the
|
39 |
+
exact steps a maintainer has to take to make the problem occur. We can not
|
40 |
+
fix something that we can not observe.
|
41 |
+
|
42 |
+
- If the problem can not be reproduced in any of the demos included in the
|
43 |
+
CodeMirror distribution, please provide an HTML document that demonstrates
|
44 |
+
the problem. The best way to do this is to go to
|
45 |
+
[jsbin.com](http://jsbin.com/ihunin/edit), enter it there, press save, and
|
46 |
+
include the resulting link in your bug report.
|
47 |
+
|
48 |
+
## Contributing code
|
49 |
+
|
50 |
+
Note that we are not accepting any new addons or modes into the main
|
51 |
+
distribution. If you've written such a module, please distribute it as
|
52 |
+
a separate NPM package.
|
53 |
+
|
54 |
+
- Make sure you have a [GitHub Account](https://github.com/signup/free)
|
55 |
+
- Fork [CodeMirror](https://github.com/codemirror/CodeMirror/)
|
56 |
+
([how to fork a repo](https://help.github.com/articles/fork-a-repo))
|
57 |
+
- Make your changes
|
58 |
+
- If your changes are easy to test or likely to regress, add tests.
|
59 |
+
Tests for the core go into `test/test.js`, some modes have their own
|
60 |
+
test suite under `mode/XXX/test.js`. Feel free to add new test
|
61 |
+
suites to modes that don't have one yet (be sure to link the new
|
62 |
+
tests into `test/index.html`).
|
63 |
+
- Follow the general code style of the rest of the project (see
|
64 |
+
below). Run `bin/lint` to verify that the linter is happy.
|
65 |
+
- Make sure all tests pass. Visit `test/index.html` in your browser to
|
66 |
+
run them.
|
67 |
+
- Submit a pull request
|
68 |
+
([how to create a pull request](https://help.github.com/articles/fork-a-repo)).
|
69 |
+
Don't put more than one feature/fix in a single pull request.
|
70 |
+
|
71 |
+
By contributing code to CodeMirror you
|
72 |
+
|
73 |
+
- agree to license the contributed code under CodeMirror's [MIT
|
74 |
+
license](http://codemirror.net/LICENSE).
|
75 |
+
|
76 |
+
- confirm that you have the right to contribute and license the code
|
77 |
+
in question. (Either you hold all rights on the code, or the rights
|
78 |
+
holder has explicitly granted the right to use it like this,
|
79 |
+
through a compatible open source license or through a direct
|
80 |
+
agreement with you.)
|
81 |
+
|
82 |
+
### Coding standards
|
83 |
+
|
84 |
+
- 2 spaces per indentation level, no tabs.
|
85 |
+
|
86 |
+
- Note that the linter (`bin/lint`) which is run after each commit
|
87 |
+
complains about unused variables and functions. Prefix their names
|
88 |
+
with an underscore to muffle it.
|
89 |
+
|
90 |
+
- CodeMirror does *not* follow JSHint or JSLint prescribed style.
|
91 |
+
Patches that try to 'fix' code to pass one of these linters will be
|
92 |
+
unceremoniously discarded.
|
inc/lib/codemirror/LICENSE
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
-
|
|
|
|
|
2 |
|
3 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
of this software and associated documentation files (the "Software"), to deal
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others
|
4 |
|
5 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
of this software and associated documentation files (the "Software"), to deal
|
inc/lib/codemirror/README.md
CHANGED
@@ -1,12 +1,49 @@
|
|
1 |
# CodeMirror
|
|
|
2 |
[![Build Status](https://travis-ci.org/codemirror/CodeMirror.svg)](https://travis-ci.org/codemirror/CodeMirror)
|
3 |
-
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
|
|
|
4 |
[Funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png?again)](https://marijnhaverbeke.nl/fund/)
|
5 |
|
6 |
-
CodeMirror is a
|
7 |
-
the browser.
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
1 |
# CodeMirror
|
2 |
+
|
3 |
[![Build Status](https://travis-ci.org/codemirror/CodeMirror.svg)](https://travis-ci.org/codemirror/CodeMirror)
|
4 |
+
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
|
5 |
+
[![Join the chat at https://gitter.im/codemirror/CodeMirror](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/codemirror/CodeMirror)
|
6 |
[Funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png?again)](https://marijnhaverbeke.nl/fund/)
|
7 |
|
8 |
+
CodeMirror is a versatile text editor implemented in JavaScript for
|
9 |
+
the browser. It is specialized for editing code, and comes with over
|
10 |
+
100 language modes and various addons that implement more advanced
|
11 |
+
editing functionality. Every language comes with fully-featured code
|
12 |
+
and syntax highlighting to help with reading and editing complex code.
|
13 |
+
|
14 |
+
A rich programming API and a CSS theming system are available for
|
15 |
+
customizing CodeMirror to fit your application, and extending it with
|
16 |
+
new functionality.
|
17 |
+
|
18 |
+
You can find more information (and the
|
19 |
+
[manual](http://codemirror.net/doc/manual.html)) on the [project
|
20 |
+
page](http://codemirror.net). For questions and discussion, use the
|
21 |
+
[discussion forum](https://discuss.codemirror.net/).
|
22 |
+
|
23 |
+
See
|
24 |
+
[CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
|
25 |
+
for contributing guidelines.
|
26 |
+
|
27 |
+
The CodeMirror community aims to be welcoming to everybody. We use the
|
28 |
+
[Contributor Covenant
|
29 |
+
(1.1)](http://contributor-covenant.org/version/1/1/0/) as our code of
|
30 |
+
conduct.
|
31 |
+
|
32 |
+
### Installation
|
33 |
+
|
34 |
+
Either get the [zip file](https://codemirror.net/codemirror.zip) with
|
35 |
+
the latest version, or make sure you have [Node](https://nodejs.org/)
|
36 |
+
installed and run:
|
37 |
+
|
38 |
+
npm install codemirror
|
39 |
+
|
40 |
+
**NOTE**: This is the source repository for the library, and not the
|
41 |
+
distribution channel. Cloning it is not the recommended way to install
|
42 |
+
the library, and will in fact not work unless you also run the build
|
43 |
+
step.
|
44 |
+
|
45 |
+
### Quickstart
|
46 |
|
47 |
+
To build the project, make sure you have Node.js installed (at least version 6)
|
48 |
+
and then `npm install`. To run, just open `index.html` in your
|
49 |
+
browser (you don't need to run a webserver). Run the tests with `npm test`.
|
inc/lib/codemirror/{addons → addon/selection}/active-line.js
RENAMED
@@ -1,12 +1,6 @@
|
|
1 |
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
|
4 |
-
// Because sometimes you need to style the cursor's line.
|
5 |
-
//
|
6 |
-
// Adds an option 'styleActiveLine' which, when enabled, gives the
|
7 |
-
// active line's wrapping <div> the CSS class "CodeMirror-activeline",
|
8 |
-
// and gives its background <div> the class "CodeMirror-activeline-background".
|
9 |
-
|
10 |
(function(mod) {
|
11 |
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12 |
mod(require("../../lib/codemirror"));
|
@@ -21,16 +15,18 @@
|
|
21 |
var GUTT_CLASS = "CodeMirror-activeline-gutter";
|
22 |
|
23 |
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
|
24 |
-
var prev = old
|
25 |
-
if (val
|
26 |
-
|
27 |
-
updateActiveLines(cm, cm.listSelections());
|
28 |
-
cm.on("beforeSelectionChange", selectionChange);
|
29 |
-
} else if (!val && prev) {
|
30 |
cm.off("beforeSelectionChange", selectionChange);
|
31 |
clearActiveLines(cm);
|
32 |
delete cm.state.activeLines;
|
33 |
}
|
|
|
|
|
|
|
|
|
|
|
34 |
});
|
35 |
|
36 |
function clearActiveLines(cm) {
|
@@ -52,7 +48,9 @@
|
|
52 |
var active = [];
|
53 |
for (var i = 0; i < ranges.length; i++) {
|
54 |
var range = ranges[i];
|
55 |
-
|
|
|
|
|
56 |
var line = cm.getLineHandleVisualStart(range.head.line);
|
57 |
if (active[active.length - 1] != line) active.push(line);
|
58 |
}
|
1 |
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
(function(mod) {
|
5 |
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
mod(require("../../lib/codemirror"));
|
15 |
var GUTT_CLASS = "CodeMirror-activeline-gutter";
|
16 |
|
17 |
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
|
18 |
+
var prev = old == CodeMirror.Init ? false : old;
|
19 |
+
if (val == prev) return
|
20 |
+
if (prev) {
|
|
|
|
|
|
|
21 |
cm.off("beforeSelectionChange", selectionChange);
|
22 |
clearActiveLines(cm);
|
23 |
delete cm.state.activeLines;
|
24 |
}
|
25 |
+
if (val) {
|
26 |
+
cm.state.activeLines = [];
|
27 |
+
updateActiveLines(cm, cm.listSelections());
|
28 |
+
cm.on("beforeSelectionChange", selectionChange);
|
29 |
+
}
|
30 |
});
|
31 |
|
32 |
function clearActiveLines(cm) {
|
48 |
var active = [];
|
49 |
for (var i = 0; i < ranges.length; i++) {
|
50 |
var range = ranges[i];
|
51 |
+
var option = cm.getOption("styleActiveLine");
|
52 |
+
if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty())
|
53 |
+
continue
|
54 |
var line = cm.getLineHandleVisualStart(range.head.line);
|
55 |
if (active[active.length - 1] != line) active.push(line);
|
56 |
}
|
inc/lib/codemirror/codemirror-compressed.js
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
/* CodeMirror - Minified & Bundled
|
2 |
-
Generated on 26 Sep 2015 with http://codemirror.net/doc/compress.html
|
3 |
-
Version: HEAD
|
4 |
-
|
5 |
-
CodeMirror Library:
|
6 |
-
- codemirror.js
|
7 |
-
Modes:
|
8 |
-
- clike.js
|
9 |
-
- css.js
|
10 |
-
- htmlmixed.js
|
11 |
-
- javascript.js
|
12 |
-
- php.js
|
13 |
-
- xml.js
|
14 |
-
*/
|
15 |
-
|
16 |
-
!function(a){if("object"==typeof exports&&"object"==typeof module)module.exports=a();else{if("function"==typeof define&&define.amd)return define([],a);this.CodeMirror=a()}}(function(){"use strict";function v(a,b){if(!(this instanceof v))return new v(a,b);this.options=b=b?jg(b):{},jg(Ad,b,!1),I(b);var c=b.value;"string"==typeof c&&(c=new af(c,b.mode,null,b.lineSeparator)),this.doc=c;var g=new v.inputStyles[b.inputStyle](this),h=this.display=new w(a,c,g);h.wrapper.CodeMirror=this,E(this),C(this),b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),b.autofocus&&!n&&h.input.focus(),M(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new $f,keySeq:null,specialChars:null};var i=this;d&&11>e&&setTimeout(function(){i.display.input.reset(!0)},20),pc(this),Dg(),Vb(this),this.curOp.forceUpdate=!0,ef(this,c),b.autofocus&&!n||i.hasFocus()?setTimeout(kg(Zc,this),20):$c(this);for(var j in Bd)Bd.hasOwnProperty(j)&&Bd[j](this,b[j],Dd);R(this),b.finishInit&&b.finishInit(this);for(var k=0;k<Hd.length;++k)Hd[k](this);Xb(this),f&&b.lineWrapping&&"optimizelegibility"==getComputedStyle(h.lineDiv).textRendering&&(h.lineDiv.style.textRendering="auto")}function w(b,c,g){var h=this;this.input=g,h.scrollbarFiller=rg("div",null,"CodeMirror-scrollbar-filler"),h.scrollbarFiller.setAttribute("cm-not-content","true"),h.gutterFiller=rg("div",null,"CodeMirror-gutter-filler"),h.gutterFiller.setAttribute("cm-not-content","true"),h.lineDiv=rg("div",null,"CodeMirror-code"),h.selectionDiv=rg("div",null,null,"position: relative; z-index: 1"),h.cursorDiv=rg("div",null,"CodeMirror-cursors"),h.measure=rg("div",null,"CodeMirror-measure"),h.lineMeasure=rg("div",null,"CodeMirror-measure"),h.lineSpace=rg("div",[h.measure,h.lineMeasure,h.selectionDiv,h.cursorDiv,h.lineDiv],null,"position: relative; outline: none"),h.mover=rg("div",[rg("div",[h.lineSpace],"CodeMirror-lines")],null,"position: relative"),h.sizer=rg("div",[h.mover],"CodeMirror-sizer"),h.sizerWidth=null,h.heightForcer=rg("div",null,null,"position: absolute; height: "+Vf+"px; width: 1px;"),h.gutters=rg("div",null,"CodeMirror-gutters"),h.lineGutter=null,h.scroller=rg("div",[h.sizer,h.heightForcer,h.gutters],"CodeMirror-scroll"),h.scroller.setAttribute("tabIndex","-1"),h.wrapper=rg("div",[h.scrollbarFiller,h.gutterFiller,h.scroller],"CodeMirror"),d&&8>e&&(h.gutters.style.zIndex=-1,h.scroller.style.paddingRight=0),f||a&&n||(h.scroller.draggable=!0),b&&(b.appendChild?b.appendChild(h.wrapper):b(h.wrapper)),h.viewFrom=h.viewTo=c.first,h.reportedViewFrom=h.reportedViewTo=c.first,h.view=[],h.renderedView=null,h.externalMeasured=null,h.viewOffset=0,h.lastWrapHeight=h.lastWrapWidth=0,h.updateLineNumbers=null,h.nativeBarWidth=h.barHeight=h.barWidth=0,h.scrollbarsClipped=!1,h.lineNumWidth=h.lineNumInnerWidth=h.lineNumChars=null,h.alignWidgets=!1,h.cachedCharWidth=h.cachedTextHeight=h.cachedPaddingH=null,h.maxLine=null,h.maxLineLength=0,h.maxLineChanged=!1,h.wheelDX=h.wheelDY=h.wheelStartX=h.wheelStartY=null,h.shift=!1,h.selForContextMenu=null,h.activeTouch=null,g.init(h)}function x(a){a.doc.mode=v.getMode(a.options,a.doc.modeOption),y(a)}function y(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null)}),a.doc.frontier=a.doc.first,ib(a,100),a.state.modeGen++,a.curOp&&ic(a)}function z(a){a.options.lineWrapping?(zg(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(yg(a.display.wrapper,"CodeMirror-wrap"),H(a)),B(a),ic(a),Fb(a),setTimeout(function(){N(a)},100)}function A(a){var b=Rb(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/Sb(a.display)-3);return function(e){if(we(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;g<e.widgets.length;g++)e.widgets[g].height&&(f+=e.widgets[g].height);return c?f+(Math.ceil(e.text.length/d)||1)*b:f+b}}function B(a){var b=a.doc,c=A(a);b.iter(function(a){var b=c(a);b!=a.height&&jf(a,b)})}function C(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Fb(a)}function D(a){E(a),ic(a),setTimeout(function(){Q(a)},20)}function E(a){var b=a.display.gutters,c=a.options.gutters;tg(b);for(var d=0;d<c.length;++d){var e=c[d],f=b.appendChild(rg("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==e&&(a.display.lineGutter=f,f.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none",F(a)}function F(a){var b=a.display.gutters.offsetWidth;a.display.sizer.style.marginLeft=b+"px"}function G(a){if(0==a.height)return 0;for(var c,b=a.text.length,d=a;c=pe(d);){var e=c.find(0,!0);d=e.from.line,b+=e.from.ch-e.to.ch}for(d=a;c=qe(d);){var e=c.find(0,!0);b-=d.text.length-e.from.ch,d=e.to.line,b+=d.text.length-e.to.ch}return b}function H(a){var b=a.display,c=a.doc;b.maxLine=ff(c,c.first),b.maxLineLength=G(b.maxLine),b.maxLineChanged=!0,c.iter(function(a){var c=G(a);c>b.maxLineLength&&(b.maxLineLength=c,b.maxLine=a)})}function I(a){var b=fg(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):b>-1&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function J(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+nb(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight,scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?c:0,docHeight:d,scrollHeight:d+pb(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function K(a,b,c){this.cm=c;var f=this.vert=rg("div",[rg("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),g=this.horiz=rg("div",[rg("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a(f),a(g),Jf(f,"scroll",function(){f.clientHeight&&b(f.scrollTop,"vertical")}),Jf(g,"scroll",function(){g.clientWidth&&b(g.scrollLeft,"horizontal")}),this.checkedOverlay=!1,d&&8>e&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function L(){}function M(a){a.display.scrollbars&&(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&yg(a.display.wrapper,a.display.scrollbars.addClass)),a.display.scrollbars=new v.scrollbarModel[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller),Jf(b,"mousedown",function(){a.state.focused&&setTimeout(function(){a.display.input.focus()},0)}),b.setAttribute("cm-not-content","true")},function(b,c){"horizontal"==c?Ic(a,b):Hc(a,b)},a),a.display.scrollbars.addClass&&zg(a.display.wrapper,a.display.scrollbars.addClass)}function N(a,b){b||(b=J(a));var c=a.display.barWidth,d=a.display.barHeight;O(a,b);for(var e=0;4>e&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&$(a),O(a,J(a)),c=a.display.barWidth,d=a.display.barHeight}function O(a,b){var c=a.display,d=c.scrollbars.update(b);c.sizer.style.paddingRight=(c.barWidth=d.right)+"px",c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px",d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=d.bottom+"px",c.scrollbarFiller.style.width=d.right+"px"):c.scrollbarFiller.style.display="",d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=""}function P(a,b,c){var d=c&&null!=c.top?Math.max(0,c.top):a.scroller.scrollTop;d=Math.floor(d-mb(a));var e=c&&null!=c.bottom?c.bottom:d+a.wrapper.clientHeight,f=lf(b,d),g=lf(b,e);if(c&&c.ensure){var h=c.ensure.from.line,i=c.ensure.to.line;f>h?(f=h,g=lf(b,mf(ff(b,h))+a.wrapper.clientHeight)):Math.min(i,b.lastLine())>=g&&(f=lf(b,mf(ff(b,i))-a.wrapper.clientHeight),g=i)}return{from:f,to:Math.max(g,f+1)}}function Q(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=T(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g<c.length;g++)if(!c[g].hidden){a.options.fixedGutter&&c[g].gutter&&(c[g].gutter.style.left=f);var h=c[g].alignable;if(h)for(var i=0;i<h.length;i++)h[i].style.left=f}a.options.fixedGutter&&(b.gutters.style.left=d+e+"px")}}function R(a){if(!a.options.lineNumbers)return!1;var b=a.doc,c=S(a.options,b.first+b.size-1),d=a.display;if(c.length!=d.lineNumChars){var e=d.measure.appendChild(rg("div",[rg("div",c)],"CodeMirror-linenumber CodeMirror-gutter-elt")),f=e.firstChild.offsetWidth,g=e.offsetWidth-f;return d.lineGutter.style.width="",d.lineNumInnerWidth=Math.max(f,d.lineGutter.offsetWidth-g)+1,d.lineNumWidth=d.lineNumInnerWidth+g,d.lineNumChars=d.lineNumInnerWidth?c.length:-1,d.lineGutter.style.width=d.lineNumWidth+"px",F(a),!0}return!1}function S(a,b){return String(a.lineNumberFormatter(b+a.firstLineNumber))}function T(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function U(a,b,c){var d=a.display;this.viewport=b,this.visible=P(d,a.doc,b),this.editorIsHidden=!d.wrapper.offsetWidth,this.wrapperHeight=d.wrapper.clientHeight,this.wrapperWidth=d.wrapper.clientWidth,this.oldDisplayWidth=qb(a),this.force=c,this.dims=aa(a),this.events=[]}function V(a){var b=a.display;!b.scrollbarsClipped&&b.scroller.offsetWidth&&(b.nativeBarWidth=b.scroller.offsetWidth-b.scroller.clientWidth,b.heightForcer.style.height=pb(a)+"px",b.sizer.style.marginBottom=-b.nativeBarWidth+"px",b.sizer.style.borderRightWidth=pb(a)+"px",b.scrollbarsClipped=!0)}function W(a,b){var c=a.display,d=a.doc;if(b.editorIsHidden)return kc(a),!1;if(!b.force&&b.visible.from>=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo)&&c.renderedView==c.view&&0==oc(a))return!1;R(a)&&(kc(a),b.dims=aa(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),g=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFrom<f&&f-c.viewFrom<20&&(f=Math.max(d.first,c.viewFrom)),c.viewTo>g&&c.viewTo-g<20&&(g=Math.min(e,c.viewTo)),u&&(f=ue(a.doc,f),g=ve(a.doc,g));var h=f!=c.viewFrom||g!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;nc(a,f,g),c.viewOffset=mf(ff(a.doc,c.viewFrom)),a.display.mover.style.top=c.viewOffset+"px";var i=oc(a);if(!h&&0==i&&!b.force&&c.renderedView==c.view&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;var j=wg();return i>4&&(c.lineDiv.style.display="none"),ba(a,c.updateLineNumbers,b.dims),i>4&&(c.lineDiv.style.display=""),c.renderedView=c.view,j&&wg()!=j&&j.offsetHeight&&j.focus(),tg(c.cursorDiv),tg(c.selectionDiv),c.gutters.style.height=c.sizer.style.minHeight=0,h&&(c.lastWrapHeight=b.wrapperHeight,c.lastWrapWidth=b.wrapperWidth,ib(a,400)),c.updateLineNumbers=null,!0}function X(a,b){for(var c=b.viewport,d=!0;(d&&a.options.lineWrapping&&b.oldDisplayWidth!=qb(a)||(c&&null!=c.top&&(c={top:Math.min(a.doc.height+nb(a.display)-rb(a),c.top)}),b.visible=P(a.display,a.doc,c),!(b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)))&&W(a,b);d=!1){$(a);var e=J(a);db(a),Z(a,e),N(a,e)}b.signal(a,"update",a),(a.display.viewFrom!=a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)&&(b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo)}function Y(a,b){var c=new U(a,b);if(W(a,c)){$(a),X(a,c);var d=J(a);db(a),Z(a,d),N(a,d),c.finish()}}function Z(a,b){a.display.sizer.style.minHeight=b.docHeight+"px";var c=b.docHeight+a.display.barHeight;a.display.heightForcer.style.top=c+"px",a.display.gutters.style.height=Math.max(c+pb(a),b.clientHeight)+"px"}function $(a){for(var b=a.display,c=b.lineDiv.offsetTop,f=0;f<b.view.length;f++){var h,g=b.view[f];if(!g.hidden){if(d&&8>e){var i=g.node.offsetTop+g.node.offsetHeight;h=i-c,c=i}else{var j=g.node.getBoundingClientRect();h=j.bottom-j.top}var k=g.line.height-h;if(2>h&&(h=Rb(b)),(k>.001||-.001>k)&&(jf(g.line,h),_(g.line),g.rest))for(var l=0;l<g.rest.length;l++)_(g.rest[l])}}}function _(a){if(a.widgets)for(var b=0;b<a.widgets.length;++b)a.widgets[b].height=a.widgets[b].node.offsetHeight}function aa(a){for(var b=a.display,c={},d={},e=b.gutters.clientLeft,f=b.gutters.firstChild,g=0;f;f=f.nextSibling,++g)c[a.options.gutters[g]]=f.offsetLeft+f.clientLeft+e,d[a.options.gutters[g]]=f.clientWidth;return{fixedPos:T(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function ba(a,b,c){function i(b){var c=b.nextSibling;return f&&o&&a.display.currentWheelTarget==b?b.style.display="none":b.parentNode.removeChild(b),c}for(var d=a.display,e=a.options.lineNumbers,g=d.lineDiv,h=g.firstChild,j=d.view,k=d.viewFrom,l=0;l<j.length;l++){var m=j[l];if(m.hidden);else if(m.node&&m.node.parentNode==g){for(;h!=m.node;)h=i(h);var p=e&&null!=b&&k>=b&&m.lineNumber;m.changes&&(fg(m.changes,"gutter")>-1&&(p=!1),ca(a,m,k,c)),p&&(tg(m.lineNumber),m.lineNumber.appendChild(document.createTextNode(S(a.options,k)))),h=m.node.nextSibling}else{var n=ka(a,m,k,c);g.insertBefore(n,h)}k+=m.size}for(;h;)h=i(h)}function ca(a,b,c,d){for(var e=0;e<b.changes.length;e++){var f=b.changes[e];"text"==f?ga(a,b):"gutter"==f?ia(a,b,c,d):"class"==f?ha(b):"widget"==f&&ja(a,b,d)}b.changes=null}function da(a){return a.node==a.text&&(a.node=rg("div",null,null,"position: relative"),a.text.parentNode&&a.text.parentNode.replaceChild(a.node,a.text),a.node.appendChild(a.text),d&&8>e&&(a.node.style.zIndex=2)),a.node}function ea(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;if(b&&(b+=" CodeMirror-linebackground"),a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),a.background=null);else if(b){var c=da(a);a.background=c.insertBefore(rg("div",null,b),c.firstChild)}}function fa(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):Qe(a,b)}function ga(a,b){var c=b.text.className,d=fa(a,b);b.text==b.node&&(b.node=d.pre),b.text.parentNode.replaceChild(d.pre,b.text),b.text=d.pre,d.bgClass!=b.bgClass||d.textClass!=b.textClass?(b.bgClass=d.bgClass,b.textClass=d.textClass,ha(b)):c&&(b.text.className=c)}function ha(a){ea(a),a.line.wrapClass?da(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");var b=a.textClass?a.textClass+" "+(a.line.textClass||""):a.line.textClass;a.text.className=b||""}function ia(a,b,c,d){if(b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null),b.gutterBackground&&(b.node.removeChild(b.gutterBackground),b.gutterBackground=null),b.line.gutterClass){var e=da(b);b.gutterBackground=rg("div",null,"CodeMirror-gutter-background "+b.line.gutterClass,"left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+d.gutterTotalWidth+"px"),e.insertBefore(b.gutterBackground,b.text)}var f=b.line.gutterMarkers;if(a.options.lineNumbers||f){var e=da(b),g=b.gutter=rg("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px");if(a.display.input.setUneditable(g),e.insertBefore(g,b.text),b.line.gutterClass&&(g.className+=" "+b.line.gutterClass),!a.options.lineNumbers||f&&f["CodeMirror-linenumbers"]||(b.lineNumber=g.appendChild(rg("div",S(a.options,c),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+"px"))),f)for(var h=0;h<a.options.gutters.length;++h){var i=a.options.gutters[h],j=f.hasOwnProperty(i)&&f[i];j&&g.appendChild(rg("div",[j],"CodeMirror-gutter-elt","left: "+d.gutterLeft[i]+"px; width: "+d.gutterWidth[i]+"px"))}}}function ja(a,b,c){b.alignable&&(b.alignable=null);for(var e,d=b.node.firstChild;d;d=e){var e=d.nextSibling;"CodeMirror-linewidget"==d.className&&b.node.removeChild(d)}la(a,b,c)}function ka(a,b,c,d){var e=fa(a,b);return b.text=b.node=e.pre,e.bgClass&&(b.bgClass=e.bgClass),e.textClass&&(b.textClass=e.textClass),ha(b),ia(a,b,c,d),la(a,b,d),b.node}function la(a,b,c){if(ma(a,b.line,b,c,!0),b.rest)for(var d=0;d<b.rest.length;d++)ma(a,b.rest[d],b,c,!1)}function ma(a,b,c,d,e){if(b.widgets)for(var f=da(c),g=0,h=b.widgets;g<h.length;++g){var i=h[g],j=rg("div",[i.node],"CodeMirror-linewidget");i.handleMouseEvents||j.setAttribute("cm-ignore-events","true"),na(i,j,c,d),a.display.input.setUneditable(j),e&&i.above?f.insertBefore(j,c.gutter||c.text):f.appendChild(j),Pf(i,"redraw")}}function na(a,b,c,d){if(a.noHScroll){(c.alignable||(c.alignable=[])).push(b);var e=d.wrapperWidth;b.style.left=d.fixedPos+"px",a.coverGutter||(e-=d.gutterTotalWidth,b.style.paddingLeft=d.gutterTotalWidth+"px"),b.style.width=e+"px"}a.coverGutter&&(b.style.zIndex=5,b.style.position="relative",a.noHScroll||(b.style.marginLeft=-d.gutterTotalWidth+"px"))}function qa(a){return oa(a.line,a.ch)}function ra(a,b){return pa(a,b)<0?b:a}function sa(a,b){return pa(a,b)<0?a:b}function ta(a){a.state.focused||(a.display.input.focus(),Zc(a))}function ua(a){return a.options.readOnly||a.doc.cantEdit}function wa(a,b,c,d,e){var f=a.doc;a.display.shift=!1,d||(d=f.sel);var g=a.state.pasteIncoming||"paste"==e,h=f.splitLines(b),i=null;if(g&&d.ranges.length>1)if(va&&va.join("\n")==b){if(d.ranges.length%va.length==0){i=[];for(var j=0;j<va.length;j++)i.push(f.splitLines(va[j]))}}else h.length==d.ranges.length&&(i=gg(h,function(a){return[a]}));for(var j=d.ranges.length-1;j>=0;j--){var k=d.ranges[j],l=k.from(),m=k.to();k.empty()&&(c&&c>0?l=oa(l.line,l.ch-c):a.state.overwrite&&!g&&(m=oa(m.line,Math.min(ff(f,m.line).text.length,m.ch+dg(h).length))));var n=a.curOp.updateInput,o={from:l,to:m,text:i?i[j%i.length]:h,origin:e||(g?"paste":a.state.cutIncoming?"cut":"+input")};hd(a.doc,o),Pf(a,"inputRead",a,o)}b&&!g&&ya(a,b),td(a),a.curOp.updateInput=n,a.curOp.typing=!0,a.state.pasteIncoming=a.state.cutIncoming=!1}function xa(a,b){var c=a.clipboardData&&a.clipboardData.getData("text/plain");return c?(a.preventDefault(),ua(b)||b.options.disableInput||cc(b,function(){wa(b,c,0,null,"paste")}),!0):void 0}function ya(a,b){if(a.options.electricChars&&a.options.smartIndent)for(var c=a.doc.sel,d=c.ranges.length-1;d>=0;d--){var e=c.ranges[d];if(!(e.head.ch>100||d&&c.ranges[d-1].head.line==e.head.line)){var f=a.getModeAt(e.head),g=!1;if(f.electricChars){for(var h=0;h<f.electricChars.length;h++)if(b.indexOf(f.electricChars.charAt(h))>-1){g=vd(a,e.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(ff(a.doc,e.head.line).text.slice(0,e.head.ch))&&(g=vd(a,e.head.line,"smart"));g&&Pf(a,"electricInput",a,e.head.line)}}}function za(a){for(var b=[],c=[],d=0;d<a.doc.sel.ranges.length;d++){var e=a.doc.sel.ranges[d].head.line,f={anchor:oa(e,0),head:oa(e+1,0)};c.push(f),b.push(a.getRange(f.anchor,f.head))}return{text:b,ranges:c}}function Aa(a){a.setAttribute("autocorrect","off"),a.setAttribute("autocapitalize","off"),a.setAttribute("spellcheck","false")}function Ba(a){this.cm=a,this.prevInput="",this.pollingFast=!1,this.polling=new $f,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function Ca(){var a=rg("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),b=rg("div",[a],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return f?a.style.width="1000px":a.setAttribute("wrap","off"),m&&(a.style.border="1px solid black"),Aa(a),b}function Da(a){this.cm=a,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new $f,this.gracePeriod=!1}function Ea(a,b){var c=wb(a,b.line);if(!c||c.hidden)return null;var d=ff(a.doc,b.line),e=tb(c,d,b.line),f=nf(d),g="left";if(f){var h=$g(f,b.ch);g=h%2?"right":"left"}var i=Ab(e.map,b.ch,g);return i.offset="right"==i.collapse?i.end:i.start,i}function Fa(a,b){return b&&(a.bad=!0),a}function Ga(a,b,c){var d;if(b==a.display.lineDiv){if(d=a.display.lineDiv.childNodes[c],!d)return Fa(a.clipPos(oa(a.display.viewTo-1)),!0);b=null,c=0}else for(d=b;;d=d.parentNode){if(!d||d==a.display.lineDiv)return null;if(d.parentNode&&d.parentNode==a.display.lineDiv)break}for(var e=0;e<a.display.view.length;e++){var f=a.display.view[e];if(f.node==d)return Ha(f,b,c)}}function Ha(a,b,c){function k(b,c,d){for(var e=-1;e<(j?j.length:0);e++)for(var f=0>e?i.map:j[e],g=0;g<f.length;g+=3){var h=f[g+2];if(h==b||h==c){var k=kf(0>e?a.line:a.rest[e]),l=f[g]+d;return(0>d||h!=b)&&(l=f[g+(d?1:0)]),oa(k,l)}}}var d=a.text.firstChild,e=!1;if(!b||!vg(d,b))return Fa(oa(kf(a.line),0),!0);if(b==d&&(e=!0,b=d.childNodes[c],c=0,!b)){var f=a.rest?dg(a.rest):a.line;return Fa(oa(kf(f),f.text.length),e)}var g=3==b.nodeType?b:null,h=b;for(g||1!=b.childNodes.length||3!=b.firstChild.nodeType||(g=b.firstChild,c&&(c=g.nodeValue.length));h.parentNode!=d;)h=h.parentNode;var i=a.measure,j=i.maps,l=k(g,h,c);if(l)return Fa(l,e);for(var m=h.nextSibling,n=g?g.nodeValue.length-c:0;m;m=m.nextSibling){if(l=k(m,m.firstChild,0))return Fa(oa(l.line,l.ch-n),e);n+=m.textContent.length}for(var o=h.previousSibling,n=c;o;o=o.previousSibling){if(l=k(o,o.firstChild,-1))return Fa(oa(l.line,l.ch+n),e);n+=m.textContent.length}}function Ia(a,b,c,d,e){function i(a){return function(b){return b.id==a}}function j(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(null!=c)return""==c&&(c=b.textContent.replace(/\u200b/g,"")),void(f+=c);var l,k=b.getAttribute("cm-marker");if(k){var m=a.findMarks(oa(d,0),oa(e+1,0),i(+k));return void(m.length&&(l=m[0].find())&&(f+=gf(a.doc,l.from,l.to).join(h)))}if("false"==b.getAttribute("contenteditable"))return;for(var n=0;n<b.childNodes.length;n++)j(b.childNodes[n]);/^(pre|div|p)$/i.test(b.nodeName)&&(g=!0)}else if(3==b.nodeType){var o=b.nodeValue;if(!o)return;g&&(f+=h,g=!1),f+=o}}for(var f="",g=!1,h=a.doc.lineSeparator();j(b),b!=c;)b=b.nextSibling;return f}function Ja(a,b){this.ranges=a,this.primIndex=b}function Ka(a,b){this.anchor=a,this.head=b}function La(a,b){var c=a[b];a.sort(function(a,b){return pa(a.from(),b.from())}),b=fg(a,c);for(var d=1;d<a.length;d++){var e=a[d],f=a[d-1];if(pa(f.to(),e.from())>=0){var g=sa(f.from(),e.from()),h=ra(f.to(),e.to()),i=f.empty()?e.from()==e.head:f.from()==f.head;b>=d&&--b,a.splice(--d,2,new Ka(i?h:g,i?g:h))}}return new Ja(a,b)}function Ma(a,b){return new Ja([new Ka(a,b||a)],0)}function Na(a,b){return Math.max(a.first,Math.min(b,a.first+a.size-1))}function Oa(a,b){if(b.line<a.first)return oa(a.first,0);var c=a.first+a.size-1;return b.line>c?oa(c,ff(a,c).text.length):Pa(b,ff(a,b.line).text.length)}function Pa(a,b){var c=a.ch;return null==c||c>b?oa(a.line,b):0>c?oa(a.line,0):a}function Qa(a,b){return b>=a.first&&b<a.first+a.size}function Ra(a,b){for(var c=[],d=0;d<b.length;d++)c[d]=Oa(a,b[d]);return c}function Sa(a,b,c,d){if(a.cm&&a.cm.display.shift||a.extend){var e=b.anchor;if(d){var f=pa(c,e)<0;f!=pa(d,e)<0?(e=c,c=d):f!=pa(c,d)<0&&(c=d)}return new Ka(e,c)}return new Ka(d||c,c)}function Ta(a,b,c,d){Za(a,new Ja([Sa(a,a.sel.primary(),b,c)],0),d)}function Ua(a,b,c){for(var d=[],e=0;e<a.sel.ranges.length;e++)d[e]=Sa(a,a.sel.ranges[e],b[e],null);var f=La(d,a.sel.primIndex);Za(a,f,c)}function Va(a,b,c,d){var e=a.sel.ranges.slice(0);e[b]=c,Za(a,La(e,a.sel.primIndex),d)}function Wa(a,b,c,d){Za(a,Ma(b,c),d)}function Xa(a,b){var c={ranges:b.ranges,update:function(b){this.ranges=[];for(var c=0;c<b.length;c++)this.ranges[c]=new Ka(Oa(a,b[c].anchor),Oa(a,b[c].head))}};return Nf(a,"beforeSelectionChange",a,c),a.cm&&Nf(a.cm,"beforeSelectionChange",a.cm,c),c.ranges!=b.ranges?La(c.ranges,c.ranges.length-1):b}function Ya(a,b,c){var d=a.history.done,e=dg(d);e&&e.ranges?(d[d.length-1]=b,$a(a,b,c)):Za(a,b,c)}function Za(a,b,c){$a(a,b,c),uf(a,a.sel,a.cm?a.cm.curOp.id:NaN,c)}function $a(a,b,c){(Tf(a,"beforeSelectionChange")||a.cm&&Tf(a.cm,"beforeSelectionChange"))&&(b=Xa(a,b));var d=c&&c.bias||(pa(b.primary().head,a.sel.primary().head)<0?-1:1);_a(a,bb(a,b,d,!0)),c&&c.scroll===!1||!a.cm||td(a.cm)}function _a(a,b){b.equals(a.sel)||(a.sel=b,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0,Sf(a.cm)),Pf(a,"cursorActivity",a))}function ab(a){_a(a,bb(a,a.sel,null,!1),Xf)}function bb(a,b,c,d){for(var e,f=0;f<b.ranges.length;f++){var g=b.ranges[f],h=cb(a,g.anchor,c,d),i=cb(a,g.head,c,d);(e||h!=g.anchor||i!=g.head)&&(e||(e=b.ranges.slice(0,f)),e[f]=new Ka(h,i))}return e?La(e,b.primIndex):b}function cb(a,b,c,d){var e=!1,f=b,g=c||1;a.cantEdit=!1;a:for(;;){var h=ff(a,f.line);if(h.markedSpans)for(var i=0;i<h.markedSpans.length;++i){var j=h.markedSpans[i],k=j.marker;if((null==j.from||(k.inclusiveLeft?j.from<=f.ch:j.from<f.ch))&&(null==j.to||(k.inclusiveRight?j.to>=f.ch:j.to>f.ch))){if(d&&(Nf(k,"beforeCursorEnter"),k.explicitlyCleared)){if(h.markedSpans){--i;continue}break}if(!k.atomic)continue;var l=k.find(0>g?-1:1);if(0==pa(l,f)&&(l.ch+=g,l.ch<0?l=l.line>a.first?Oa(a,oa(l.line-1)):null:l.ch>h.text.length&&(l=l.line<a.first+a.size-1?oa(l.line+1,0):null),!l)){if(e)return d?(a.cantEdit=!0,oa(a.first,0)):cb(a,b,c,!0);e=!0,l=b,g=-g}f=l;continue a}}return f}}function db(a){a.display.input.showSelection(a.display.input.prepareSelection())}function eb(a,b){for(var c=a.doc,d={},e=d.cursors=document.createDocumentFragment(),f=d.selection=document.createDocumentFragment(),g=0;g<c.sel.ranges.length;g++)if(b!==!1||g!=c.sel.primIndex){var h=c.sel.ranges[g],i=h.empty();(i||a.options.showCursorWhenSelecting)&&fb(a,h.head,e),i||gb(a,h,f)}return d}function fb(a,b,c){var d=Lb(a,b,"div",null,null,!a.options.singleCursorHeightPerLine),e=c.appendChild(rg("div","\xa0","CodeMirror-cursor"));if(e.style.left=d.left+"px",e.style.top=d.top+"px",e.style.height=Math.max(0,d.bottom-d.top)*a.options.cursorHeight+"px",d.other){var f=c.appendChild(rg("div","\xa0","CodeMirror-cursor CodeMirror-secondarycursor"));f.style.display="",f.style.left=d.other.left+"px",f.style.top=d.other.top+"px",f.style.height=.85*(d.other.bottom-d.other.top)+"px"}}function gb(a,b,c){function j(a,b,c,d){0>b&&(b=0),b=Math.round(b),d=Math.round(d),f.appendChild(rg("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?i-a:c)+"px; height: "+(d-b)+"px"))}function k(b,c,d){function m(c,d){return Kb(a,oa(b,c),"div",f,d)}var k,l,f=ff(e,b),g=f.text.length;return Qg(nf(f),c||0,null==d?g:d,function(a,b,e){var n,o,p,f=m(a,"left");if(a==b)n=f,o=p=f.left;else{if(n=m(b-1,"right"),"rtl"==e){var q=f;f=n,n=q}o=f.left,p=n.right}null==c&&0==a&&(o=h),n.top-f.top>3&&(j(o,f.top,null,f.bottom),o=h,f.bottom<n.top&&j(o,f.bottom,null,n.top)),null==d&&b==g&&(p=i),(!k||f.top<k.top||f.top==k.top&&f.left<k.left)&&(k=f),(!l||n.bottom>l.bottom||n.bottom==l.bottom&&n.right>l.right)&&(l=n),h+1>o&&(o=h),j(o,n.top,p-o,n.bottom)}),{start:k,end:l}}var d=a.display,e=a.doc,f=document.createDocumentFragment(),g=ob(a.display),h=g.left,i=Math.max(d.sizerWidth,qb(a)-d.sizer.offsetLeft)-g.right,l=b.from(),m=b.to();if(l.line==m.line)k(l.line,l.ch,m.ch);else{var n=ff(e,l.line),o=ff(e,m.line),p=se(n)==se(o),q=k(l.line,l.ch,p?n.text.length+1:null).end,r=k(m.line,p?0:null,m.ch).start;p&&(q.top<r.top-2?(j(q.right,q.top,null,q.bottom),j(h,r.top,r.left,r.bottom)):j(q.right,q.top,r.left-q.right,q.bottom)),q.bottom<r.top&&j(h,q.bottom,null,r.top)}c.appendChild(f)}function hb(a){if(a.state.focused){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursorDiv.style.visibility="",a.options.cursorBlinkRate>0?b.blinker=setInterval(function(){b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate):a.options.cursorBlinkRate<0&&(b.cursorDiv.style.visibility="hidden")}}function ib(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.viewTo&&a.state.highlight.set(b,kg(jb,a))}function jb(a){var b=a.doc;if(b.frontier<b.first&&(b.frontier=b.first),!(b.frontier>=a.display.viewTo)){var c=+new Date+a.options.workTime,d=Jd(b.mode,lb(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var g=f.styles,h=f.text.length>a.options.maxHighlightLength,i=Ke(a,f,h?Jd(b.mode,d):d,!0);f.styles=i.styles;var j=f.styleClasses,k=i.classes;k?f.styleClasses=k:j&&(f.styleClasses=null);for(var l=!g||g.length!=f.styles.length||j!=k&&(!j||!k||j.bgClass!=k.bgClass||j.textClass!=k.textClass),m=0;!l&&m<g.length;++m)l=g[m]!=f.styles[m];l&&e.push(b.frontier),f.stateAfter=h?d:Jd(b.mode,d)}else f.text.length<=a.options.maxHighlightLength&&Me(a,f.text,d),f.stateAfter=b.frontier%5==0?Jd(b.mode,d):null;return++b.frontier,+new Date>c?(ib(a,a.options.workDelay),!0):void 0}),e.length&&cc(a,function(){for(var b=0;b<e.length;b++)jc(a,e[b],"text")})}}function kb(a,b,c){for(var d,e,f=a.doc,g=c?-1:b-(a.doc.mode.innerMode?1e3:100),h=b;h>g;--h){if(h<=f.first)return f.first;var i=ff(f,h-1);if(i.stateAfter&&(!c||h<=f.frontier))return h;var j=_f(i.text,null,a.options.tabSize);(null==e||d>j)&&(e=h-1,d=j)}return e}function lb(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var f=kb(a,b,c),g=f>d.first&&ff(d,f-1).stateAfter;return g=g?Jd(d.mode,g):Kd(d.mode),d.iter(f,b,function(c){Me(a,c.text,g);var h=f==b-1||f%5==0||f>=e.viewFrom&&f<e.viewTo;c.stateAfter=h?Jd(d.mode,g):null,++f}),c&&(d.frontier=f),g}function mb(a){return a.lineSpace.offsetTop}function nb(a){return a.mover.offsetHeight-a.lineSpace.offsetHeight}function ob(a){if(a.cachedPaddingH)return a.cachedPaddingH;var b=ug(a.measure,rg("pre","x")),c=window.getComputedStyle?window.getComputedStyle(b):b.currentStyle,d={left:parseInt(c.paddingLeft),right:parseInt(c.paddingRight)};return isNaN(d.left)||isNaN(d.right)||(a.cachedPaddingH=d),d}function pb(a){return Vf-a.display.nativeBarWidth}function qb(a){return a.display.scroller.clientWidth-pb(a)-a.display.barWidth}function rb(a){return a.display.scroller.clientHeight-pb(a)-a.display.barHeight}function sb(a,b,c){var d=a.options.lineWrapping,e=d&&qb(a);if(!b.measure.heights||d&&b.measure.width!=e){var f=b.measure.heights=[];if(d){b.measure.width=e;for(var g=b.text.firstChild.getClientRects(),h=0;h<g.length-1;h++){var i=g[h],j=g[h+1];Math.abs(i.bottom-j.bottom)>2&&f.push((i.bottom+j.top)/2-c.top)}}f.push(c.bottom-c.top)}}function tb(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;d<a.rest.length;d++)if(a.rest[d]==b)return{map:a.measure.maps[d],cache:a.measure.caches[d]};for(var d=0;d<a.rest.length;d++)if(kf(a.rest[d])>c)return{map:a.measure.maps[d],cache:a.measure.caches[d],before:!0}}function ub(a,b){b=se(b);var c=kf(b),d=a.display.externalMeasured=new gc(a.doc,b,c);d.lineN=c;var e=d.built=Qe(a,d);return d.text=e.pre,ug(a.display.lineMeasure,e.pre),d}function vb(a,b,c,d){return yb(a,xb(a,b),c,d)}function wb(a,b){if(b>=a.display.viewFrom&&b<a.display.viewTo)return a.display.view[lc(a,b)];var c=a.display.externalMeasured;return c&&b>=c.lineN&&b<c.lineN+c.size?c:void 0}function xb(a,b){var c=kf(b),d=wb(a,c);d&&!d.text?d=null:d&&d.changes&&(ca(a,d,c,aa(a)),a.curOp.forceUpdate=!0),d||(d=ub(a,b));var e=tb(d,b,c);return{line:b,view:d,rect:null,map:e.map,cache:e.cache,before:e.before,hasHeights:!1}}function yb(a,b,c,d,e){b.before&&(c=-1);var g,f=c+(d||"");return b.cache.hasOwnProperty(f)?g=b.cache[f]:(b.rect||(b.rect=b.view.text.getBoundingClientRect()),b.hasHeights||(sb(a,b.view,b.rect),b.hasHeights=!0),g=Bb(a,b,c,d),g.bogus||(b.cache[f]=g)),{left:g.left,right:g.right,top:e?g.rtop:g.top,bottom:e?g.rbottom:g.bottom}}function Ab(a,b,c){for(var d,e,f,g,h=0;h<a.length;h+=3){var i=a[h],j=a[h+1];if(i>b?(e=0,f=1,g="left"):j>b?(e=b-i,f=e+1):(h==a.length-3||b==j&&a[h+3]>b)&&(f=j-i,e=f-1,b>=j&&(g="right")),null!=e){if(d=a[h+2],i==j&&c==(d.insertLeft?"left":"right")&&(g=c),"left"==c&&0==e)for(;h&&a[h-2]==a[h-3]&&a[h-1].insertLeft;)d=a[(h-=3)+2],g="left";if("right"==c&&e==j-i)for(;h<a.length-3&&a[h+3]==a[h+4]&&!a[h+5].insertLeft;)d=a[(h+=3)+2],g="right";break}}return{node:d,start:e,end:f,collapse:g,coverStart:i,coverEnd:j}}function Bb(a,b,c,f){var l,g=Ab(b.map,c,f),h=g.node,i=g.start,j=g.end,k=g.collapse;if(3==h.nodeType){for(var m=0;4>m;m++){for(;i&&qg(b.line.text.charAt(g.coverStart+i));)--i;for(;g.coverStart+j<g.coverEnd&&qg(b.line.text.charAt(g.coverStart+j));)++j;
|
17 |
-
if(d&&9>e&&0==i&&j==g.coverEnd-g.coverStart)l=h.parentNode.getBoundingClientRect();else if(d&&a.options.lineWrapping){var n=sg(h,i,j).getClientRects();l=n.length?n["right"==f?n.length-1:0]:zb}else l=sg(h,i,j).getBoundingClientRect()||zb;if(l.left||l.right||0==i)break;j=i,i-=1,k="right"}d&&11>e&&(l=Cb(a.display.measure,l))}else{i>0&&(k=f="right");var n;l=a.options.lineWrapping&&(n=h.getClientRects()).length>1?n["right"==f?n.length-1:0]:h.getBoundingClientRect()}if(d&&9>e&&!i&&(!l||!l.left&&!l.right)){var o=h.parentNode.getClientRects()[0];l=o?{left:o.left,right:o.left+Sb(a.display),top:o.top,bottom:o.bottom}:zb}for(var p=l.top-b.rect.top,q=l.bottom-b.rect.top,r=(p+q)/2,s=b.view.measure.heights,m=0;m<s.length-1&&!(r<s[m]);m++);var t=m?s[m-1]:0,u=s[m],v={left:("right"==k?l.right:l.left)-b.rect.left,right:("left"==k?l.left:l.right)-b.rect.left,top:t,bottom:u};return l.left||l.right||(v.bogus=!0),a.options.singleCursorHeightPerLine||(v.rtop=p,v.rbottom=q),v}function Cb(a,b){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Og(a))return b;var c=screen.logicalXDPI/screen.deviceXDPI,d=screen.logicalYDPI/screen.deviceYDPI;return{left:b.left*c,right:b.right*c,top:b.top*d,bottom:b.bottom*d}}function Db(a){if(a.measure&&(a.measure.cache={},a.measure.heights=null,a.rest))for(var b=0;b<a.rest.length;b++)a.measure.caches[b]={}}function Eb(a){a.display.externalMeasure=null,tg(a.display.lineMeasure);for(var b=0;b<a.display.view.length;b++)Db(a.display.view[b])}function Fb(a){Eb(a),a.display.cachedCharWidth=a.display.cachedTextHeight=a.display.cachedPaddingH=null,a.options.lineWrapping||(a.display.maxLineChanged=!0),a.display.lineNumChars=null}function Gb(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Hb(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function Ib(a,b,c,d){if(b.widgets)for(var e=0;e<b.widgets.length;++e)if(b.widgets[e].above){var f=Ae(b.widgets[e]);c.top+=f,c.bottom+=f}if("line"==d)return c;d||(d="local");var g=mf(b);if("local"==d?g+=mb(a.display):g-=a.display.viewOffset,"page"==d||"window"==d){var h=a.display.lineSpace.getBoundingClientRect();g+=h.top+("window"==d?0:Hb());var i=h.left+("window"==d?0:Gb());c.left+=i,c.right+=i}return c.top+=g,c.bottom+=g,c}function Jb(a,b,c){if("div"==c)return b;var d=b.left,e=b.top;if("page"==c)d-=Gb(),e-=Hb();else if("local"==c||!c){var f=a.display.sizer.getBoundingClientRect();d+=f.left,e+=f.top}var g=a.display.lineSpace.getBoundingClientRect();return{left:d-g.left,top:e-g.top}}function Kb(a,b,c,d,e){return d||(d=ff(a.doc,b.line)),Ib(a,d,vb(a,d,b.ch,e),c)}function Lb(a,b,c,d,e,f){function g(b,g){var h=yb(a,e,b,g?"right":"left",f);return g?h.left=h.right:h.right=h.left,Ib(a,d,h,c)}function h(a,b){var c=i[b],d=c.level%2;return a==Rg(c)&&b&&c.level<i[b-1].level?(c=i[--b],a=Sg(c)-(c.level%2?0:1),d=!0):a==Sg(c)&&b<i.length-1&&c.level<i[b+1].level&&(c=i[++b],a=Rg(c)-c.level%2,d=!1),d&&a==c.to&&a>c.from?g(a-1):g(a,d)}d=d||ff(a.doc,b.line),e||(e=xb(a,d));var i=nf(d),j=b.ch;if(!i)return g(j);var k=$g(i,j),l=h(j,k);return null!=Zg&&(l.other=h(j,Zg)),l}function Mb(a,b){var c=0,b=Oa(a.doc,b);a.options.lineWrapping||(c=Sb(a.display)*b.ch);var d=ff(a.doc,b.line),e=mf(d)+mb(a.display);return{left:c,right:c,top:e,bottom:e+d.height}}function Nb(a,b,c,d){var e=oa(a,b);return e.xRel=d,c&&(e.outside=!0),e}function Ob(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,0>c)return Nb(d.first,0,!0,-1);var e=lf(d,c),f=d.first+d.size-1;if(e>f)return Nb(d.first+d.size-1,ff(d,f).text.length,!0,1);0>b&&(b=0);for(var g=ff(d,e);;){var h=Pb(a,g,e,b,c),i=qe(g),j=i&&i.find(0,!0);if(!i||!(h.ch>j.from.ch||h.ch==j.from.ch&&h.xRel>0))return h;e=kf(g=j.to.line)}}function Pb(a,b,c,d,e){function j(d){var e=Lb(a,oa(c,d),"line",b,i);return g=!0,f>e.bottom?e.left-h:f<e.top?e.left+h:(g=!1,e.left)}var f=e-mf(b),g=!1,h=2*a.display.wrapper.clientWidth,i=xb(a,b),k=nf(b),l=b.text.length,m=Tg(b),n=Ug(b),o=j(m),p=g,q=j(n),r=g;if(d>q)return Nb(c,n,r,1);for(;;){if(k?n==m||n==ah(b,m,1):1>=n-m){for(var s=o>d||q-d>=d-o?m:n,t=d-(s==m?o:q);qg(b.text.charAt(s));)++s;var u=Nb(c,s,s==m?p:r,-1>t?-1:t>1?1:0);return u}var v=Math.ceil(l/2),w=m+v;if(k){w=m;for(var x=0;v>x;++x)w=ah(b,w,1)}var y=j(w);y>d?(n=w,q=y,(r=g)&&(q+=1e3),l=v):(m=w,o=y,p=g,l-=v)}}function Rb(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==Qb){Qb=rg("pre");for(var b=0;49>b;++b)Qb.appendChild(document.createTextNode("x")),Qb.appendChild(rg("br"));Qb.appendChild(document.createTextNode("x"))}ug(a.measure,Qb);var c=Qb.offsetHeight/50;return c>3&&(a.cachedTextHeight=c),tg(a.measure),c||1}function Sb(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=rg("span","xxxxxxxxxx"),c=rg("pre",[b]);ug(a.measure,c);var d=b.getBoundingClientRect(),e=(d.right-d.left)/10;return e>2&&(a.cachedCharWidth=e),e||10}function Vb(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Ub},Tb?Tb.ops.push(a.curOp):a.curOp.ownsGroup=Tb={ops:[a.curOp],delayedCallbacks:[]}}function Wb(a){var b=a.delayedCallbacks,c=0;do{for(;c<b.length;c++)b[c].call(null);for(var d=0;d<a.ops.length;d++){var e=a.ops[d];if(e.cursorActivityHandlers)for(;e.cursorActivityCalled<e.cursorActivityHandlers.length;)e.cursorActivityHandlers[e.cursorActivityCalled++].call(null,e.cm)}}while(c<b.length)}function Xb(a){var b=a.curOp,c=b.ownsGroup;if(c)try{Wb(c)}finally{Tb=null;for(var d=0;d<c.ops.length;d++)c.ops[d].cm.curOp=null;Yb(c)}}function Yb(a){for(var b=a.ops,c=0;c<b.length;c++)Zb(b[c]);for(var c=0;c<b.length;c++)$b(b[c]);for(var c=0;c<b.length;c++)_b(b[c]);for(var c=0;c<b.length;c++)ac(b[c]);for(var c=0;c<b.length;c++)bc(b[c])}function Zb(a){var b=a.cm,c=b.display;V(b),a.updateMaxLine&&H(b),a.mustUpdate=a.viewChanged||a.forceUpdate||null!=a.scrollTop||a.scrollToPos&&(a.scrollToPos.from.line<c.viewFrom||a.scrollToPos.to.line>=c.viewTo)||c.maxLineChanged&&b.options.lineWrapping,a.update=a.mustUpdate&&new U(b,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function $b(a){a.updatedDisplay=a.mustUpdate&&W(a.cm,a.update)}function _b(a){var b=a.cm,c=b.display;a.updatedDisplay&&$(b),a.barMeasure=J(b),c.maxLineChanged&&!b.options.lineWrapping&&(a.adjustWidthTo=vb(b,c.maxLine,c.maxLine.text.length).left+3,b.display.sizerWidth=a.adjustWidthTo,a.barMeasure.scrollWidth=Math.max(c.scroller.clientWidth,c.sizer.offsetLeft+a.adjustWidthTo+pb(b)+b.display.barWidth),a.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+a.adjustWidthTo-qb(b))),(a.updatedDisplay||a.selectionChanged)&&(a.preparedSelection=c.input.prepareSelection())}function ac(a){var b=a.cm;null!=a.adjustWidthTo&&(b.display.sizer.style.minWidth=a.adjustWidthTo+"px",a.maxScrollLeft<b.doc.scrollLeft&&Ic(b,Math.min(b.display.scroller.scrollLeft,a.maxScrollLeft),!0),b.display.maxLineChanged=!1),a.preparedSelection&&b.display.input.showSelection(a.preparedSelection),a.updatedDisplay&&Z(b,a.barMeasure),(a.updatedDisplay||a.startHeight!=b.doc.height)&&N(b,a.barMeasure),a.selectionChanged&&hb(b),b.state.focused&&a.updateInput&&b.display.input.reset(a.typing),a.focus&&a.focus==wg()&&ta(a.cm)}function bc(a){var b=a.cm,c=b.display,d=b.doc;if(a.updatedDisplay&&X(b,a.update),null==c.wheelStartX||null==a.scrollTop&&null==a.scrollLeft&&!a.scrollToPos||(c.wheelStartX=c.wheelStartY=null),null==a.scrollTop||c.scroller.scrollTop==a.scrollTop&&!a.forceScroll||(d.scrollTop=Math.max(0,Math.min(c.scroller.scrollHeight-c.scroller.clientHeight,a.scrollTop)),c.scrollbars.setScrollTop(d.scrollTop),c.scroller.scrollTop=d.scrollTop),null==a.scrollLeft||c.scroller.scrollLeft==a.scrollLeft&&!a.forceScroll||(d.scrollLeft=Math.max(0,Math.min(c.scroller.scrollWidth-qb(b),a.scrollLeft)),c.scrollbars.setScrollLeft(d.scrollLeft),c.scroller.scrollLeft=d.scrollLeft,Q(b)),a.scrollToPos){var e=pd(b,Oa(d,a.scrollToPos.from),Oa(d,a.scrollToPos.to),a.scrollToPos.margin);a.scrollToPos.isCursor&&b.state.focused&&od(b,e)}var f=a.maybeHiddenMarkers,g=a.maybeUnhiddenMarkers;if(f)for(var h=0;h<f.length;++h)f[h].lines.length||Nf(f[h],"hide");if(g)for(var h=0;h<g.length;++h)g[h].lines.length&&Nf(g[h],"unhide");c.wrapper.offsetHeight&&(d.scrollTop=b.display.scroller.scrollTop),a.changeObjs&&Nf(b,"changes",b,a.changeObjs),a.update&&a.update.finish()}function cc(a,b){if(a.curOp)return b();Vb(a);try{return b()}finally{Xb(a)}}function dc(a,b){return function(){if(a.curOp)return b.apply(a,arguments);Vb(a);try{return b.apply(a,arguments)}finally{Xb(a)}}}function ec(a){return function(){if(this.curOp)return a.apply(this,arguments);Vb(this);try{return a.apply(this,arguments)}finally{Xb(this)}}}function fc(a){return function(){var b=this.cm;if(!b||b.curOp)return a.apply(this,arguments);Vb(b);try{return a.apply(this,arguments)}finally{Xb(b)}}}function gc(a,b,c){this.line=b,this.rest=te(b),this.size=this.rest?kf(dg(this.rest))-c+1:1,this.node=this.text=null,this.hidden=we(a,b)}function hc(a,b,c){for(var e,d=[],f=b;c>f;f=e){var g=new gc(a.doc,ff(a.doc,f),f);e=f+g.size,d.push(g)}return d}function ic(a,b,c,d){null==b&&(b=a.doc.first),null==c&&(c=a.doc.first+a.doc.size),d||(d=0);var e=a.display;if(d&&c<e.viewTo&&(null==e.updateLineNumbers||e.updateLineNumbers>b)&&(e.updateLineNumbers=b),a.curOp.viewChanged=!0,b>=e.viewTo)u&&ue(a.doc,b)<e.viewTo&&kc(a);else if(c<=e.viewFrom)u&&ve(a.doc,c+d)>e.viewFrom?kc(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)kc(a);else if(b<=e.viewFrom){var f=mc(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):kc(a)}else if(c>=e.viewTo){var f=mc(a,b,b,-1);f?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):kc(a)}else{var g=mc(a,b,b,-1),h=mc(a,c,c+d,1);g&&h?(e.view=e.view.slice(0,g.index).concat(hc(a,g.lineN,h.lineN)).concat(e.view.slice(h.index)),e.viewTo+=d):kc(a)}var i=e.externalMeasured;i&&(c<i.lineN?i.lineN+=d:b<i.lineN+i.size&&(e.externalMeasured=null))}function jc(a,b,c){a.curOp.viewChanged=!0;var d=a.display,e=a.display.externalMeasured;if(e&&b>=e.lineN&&b<e.lineN+e.size&&(d.externalMeasured=null),!(b<d.viewFrom||b>=d.viewTo)){var f=d.view[lc(a,b)];if(null!=f.node){var g=f.changes||(f.changes=[]);-1==fg(g,c)&&g.push(c)}}}function kc(a){a.display.viewFrom=a.display.viewTo=a.doc.first,a.display.view=[],a.display.viewOffset=0}function lc(a,b){if(b>=a.display.viewTo)return null;if(b-=a.display.viewFrom,0>b)return null;for(var c=a.display.view,d=0;d<c.length;d++)if(b-=c[d].size,0>b)return d}function mc(a,b,c,d){var f,e=lc(a,b),g=a.display.view;if(!u||c==a.doc.first+a.doc.size)return{index:e,lineN:c};for(var h=0,i=a.display.viewFrom;e>h;h++)i+=g[h].size;if(i!=b){if(d>0){if(e==g.length-1)return null;f=i+g[e].size-b,e++}else f=i-b;b+=f,c+=f}for(;ue(a.doc,c)!=c;){if(e==(0>d?0:g.length-1))return null;c+=d*g[e-(0>d?1:0)].size,e+=d}return{index:e,lineN:c}}function nc(a,b,c){var d=a.display,e=d.view;0==e.length||b>=d.viewTo||c<=d.viewFrom?(d.view=hc(a,b,c),d.viewFrom=b):(d.viewFrom>b?d.view=hc(a,b,d.viewFrom).concat(d.view):d.viewFrom<b&&(d.view=d.view.slice(lc(a,b))),d.viewFrom=b,d.viewTo<c?d.view=d.view.concat(hc(a,d.viewTo,c)):d.viewTo>c&&(d.view=d.view.slice(0,lc(a,c)))),d.viewTo=c}function oc(a){for(var b=a.display.view,c=0,d=0;d<b.length;d++){var e=b[d];e.hidden||e.node&&!e.changes||++c}return c}function pc(a){function g(){b.activeTouch&&(c=setTimeout(function(){b.activeTouch=null},1e3),f=b.activeTouch,f.end=+new Date)}function h(a){if(1!=a.touches.length)return!1;var b=a.touches[0];return b.radiusX<=1&&b.radiusY<=1}function i(a,b){if(null==b.left)return!0;var c=b.left-a.left,d=b.top-a.top;return c*c+d*d>400}var b=a.display;Jf(b.scroller,"mousedown",dc(a,uc)),d&&11>e?Jf(b.scroller,"dblclick",dc(a,function(b){if(!Rf(a,b)){var c=tc(a,b);if(c&&!Bc(a,b)&&!sc(a.display,b)){Df(b);var d=a.findWordAt(c);Ta(a.doc,d.anchor,d.head)}}})):Jf(b.scroller,"dblclick",function(b){Rf(a,b)||Df(b)}),s||Jf(b.scroller,"contextmenu",function(b){_c(a,b)});var c,f={end:0};Jf(b.scroller,"touchstart",function(a){if(!h(a)){clearTimeout(c);var d=+new Date;b.activeTouch={start:d,moved:!1,prev:d-f.end<=300?f:null},1==a.touches.length&&(b.activeTouch.left=a.touches[0].pageX,b.activeTouch.top=a.touches[0].pageY)}}),Jf(b.scroller,"touchmove",function(){b.activeTouch&&(b.activeTouch.moved=!0)}),Jf(b.scroller,"touchend",function(c){var d=b.activeTouch;if(d&&!sc(b,c)&&null!=d.left&&!d.moved&&new Date-d.start<300){var f,e=a.coordsChar(b.activeTouch,"page");f=!d.prev||i(d,d.prev)?new Ka(e,e):!d.prev.prev||i(d,d.prev.prev)?a.findWordAt(e):new Ka(oa(e.line,0),Oa(a.doc,oa(e.line+1,0))),a.setSelection(f.anchor,f.head),a.focus(),Df(c)}g()}),Jf(b.scroller,"touchcancel",g),Jf(b.scroller,"scroll",function(){b.scroller.clientHeight&&(Hc(a,b.scroller.scrollTop),Ic(a,b.scroller.scrollLeft,!0),Nf(a,"scroll",a))}),Jf(b.scroller,"mousewheel",function(b){Mc(a,b)}),Jf(b.scroller,"DOMMouseScroll",function(b){Mc(a,b)}),Jf(b.wrapper,"scroll",function(){b.wrapper.scrollTop=b.wrapper.scrollLeft=0}),b.dragFunctions={enter:function(b){Rf(a,b)||Gf(b)},over:function(b){Rf(a,b)||(Fc(a,b),Gf(b))},start:function(b){Ec(a,b)},drop:dc(a,Dc),leave:function(){Gc(a)}};var j=b.input.getField();Jf(j,"keyup",function(b){Wc.call(a,b)}),Jf(j,"keydown",dc(a,Uc)),Jf(j,"keypress",dc(a,Xc)),Jf(j,"focus",kg(Zc,a)),Jf(j,"blur",kg($c,a))}function qc(a,b,c){var d=c&&c!=v.Init;if(!b!=!d){var e=a.display.dragFunctions,f=b?Jf:Mf;f(a.display.scroller,"dragstart",e.start),f(a.display.scroller,"dragenter",e.enter),f(a.display.scroller,"dragover",e.over),f(a.display.scroller,"dragleave",e.leave),f(a.display.scroller,"drop",e.drop)}}function rc(a){var b=a.display;(b.lastWrapHeight!=b.wrapper.clientHeight||b.lastWrapWidth!=b.wrapper.clientWidth)&&(b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,b.scrollbarsClipped=!1,a.setSize())}function sc(a,b){for(var c=Hf(b);c!=a.wrapper;c=c.parentNode)if(!c||1==c.nodeType&&"true"==c.getAttribute("cm-ignore-events")||c.parentNode==a.sizer&&c!=a.mover)return!0}function tc(a,b,c,d){var e=a.display;if(!c&&"true"==Hf(b).getAttribute("cm-not-content"))return null;var f,g,h=e.lineSpace.getBoundingClientRect();try{f=b.clientX-h.left,g=b.clientY-h.top}catch(b){return null}var j,i=Ob(a,f,g);if(d&&1==i.xRel&&(j=ff(a.doc,i.line).text).length==i.ch){var k=_f(j,j.length,a.options.tabSize)-j.length;i=oa(i.line,Math.max(0,Math.round((f-ob(a.display).left)/Sb(a.display))-k))}return i}function uc(a){var b=this,c=b.display;if(!(c.activeTouch&&c.input.supportsTouch()||Rf(b,a))){if(c.shift=a.shiftKey,sc(c,a))return void(f||(c.scroller.draggable=!1,setTimeout(function(){c.scroller.draggable=!0},100)));if(!Bc(b,a)){var d=tc(b,a);switch(window.focus(),If(a)){case 1:b.state.selectingText?b.state.selectingText(a):d?xc(b,a,d):Hf(a)==c.scroller&&Df(a);break;case 2:f&&(b.state.lastMiddleDown=+new Date),d&&Ta(b.doc,d),setTimeout(function(){c.input.focus()},20),Df(a);break;case 3:s?_c(b,a):Yc(b)}}}}function xc(a,b,c){d?setTimeout(kg(ta,a),0):a.curOp.focus=wg();var f,e=+new Date;wc&&wc.time>e-400&&0==pa(wc.pos,c)?f="triple":vc&&vc.time>e-400&&0==pa(vc.pos,c)?(f="double",wc={time:e,pos:c}):(f="single",vc={time:e,pos:c});var i,g=a.doc.sel,h=o?b.metaKey:b.ctrlKey;a.options.dragDrop&&Fg&&!ua(a)&&"single"==f&&(i=g.contains(c))>-1&&(pa((i=g.ranges[i]).from(),c)<0||c.xRel>0)&&(pa(i.to(),c)>0||c.xRel<0)?yc(a,b,c,h):zc(a,b,c,f,h)}function yc(a,b,c,g){var h=a.display,i=+new Date,j=dc(a,function(k){f&&(h.scroller.draggable=!1),a.state.draggingText=!1,Mf(document,"mouseup",j),Mf(h.scroller,"drop",j),Math.abs(b.clientX-k.clientX)+Math.abs(b.clientY-k.clientY)<10&&(Df(k),!g&&+new Date-200<i&&Ta(a.doc,c),f||d&&9==e?setTimeout(function(){document.body.focus(),h.input.focus()},20):h.input.focus())});f&&(h.scroller.draggable=!0),a.state.draggingText=j,h.scroller.dragDrop&&h.scroller.dragDrop(),Jf(document,"mouseup",j),Jf(h.scroller,"drop",j)}function zc(a,b,c,d,e){function o(b){if(0!=pa(n,b))if(n=b,"rect"==d){for(var e=[],f=a.options.tabSize,k=_f(ff(g,c.line).text,c.ch,f),l=_f(ff(g,b.line).text,b.ch,f),m=Math.min(k,l),o=Math.max(k,l),p=Math.min(c.line,b.line),q=Math.min(a.lastLine(),Math.max(c.line,b.line));q>=p;p++){var r=ff(g,p).text,s=ag(r,m,f);m==o?e.push(new Ka(oa(p,s),oa(p,s))):r.length>s&&e.push(new Ka(oa(p,s),oa(p,ag(r,o,f))))}e.length||e.push(new Ka(c,c)),Za(g,La(j.ranges.slice(0,i).concat(e),i),{origin:"*mouse",scroll:!1}),a.scrollIntoView(b)}else{var t=h,u=t.anchor,v=b;if("single"!=d){if("double"==d)var w=a.findWordAt(b);else var w=new Ka(oa(b.line,0),Oa(g,oa(b.line+1,0)));pa(w.anchor,u)>0?(v=w.head,u=sa(t.from(),w.anchor)):(v=w.anchor,u=ra(t.to(),w.head))}var e=j.ranges.slice(0);e[i]=new Ka(Oa(g,u),v),Za(g,La(e,i),Yf)}}function r(b){var c=++q,e=tc(a,b,!0,"rect"==d);if(e)if(0!=pa(e,n)){a.curOp.focus=wg(),o(e);var h=P(f,g);(e.line>=h.to||e.line<h.from)&&setTimeout(dc(a,function(){q==c&&r(b)}),150)}else{var i=b.clientY<p.top?-20:b.clientY>p.bottom?20:0;i&&setTimeout(dc(a,function(){q==c&&(f.scroller.scrollTop+=i,r(b))}),50)}}function s(b){a.state.selectingText=!1,q=1/0,Df(b),f.input.focus(),Mf(document,"mousemove",t),Mf(document,"mouseup",u),g.history.lastSelOrigin=null}var f=a.display,g=a.doc;Df(b);var h,i,j=g.sel,k=j.ranges;if(e&&!b.shiftKey?(i=g.sel.contains(c),h=i>-1?k[i]:new Ka(c,c)):(h=g.sel.primary(),i=g.sel.primIndex),b.altKey)d="rect",e||(h=new Ka(c,c)),c=tc(a,b,!0,!0),i=-1;else if("double"==d){var l=a.findWordAt(c);h=a.display.shift||g.extend?Sa(g,h,l.anchor,l.head):l}else if("triple"==d){var m=new Ka(oa(c.line,0),Oa(g,oa(c.line+1,0)));h=a.display.shift||g.extend?Sa(g,h,m.anchor,m.head):m}else h=Sa(g,h,c);e?-1==i?(i=k.length,Za(g,La(k.concat([h]),i),{scroll:!1,origin:"*mouse"})):k.length>1&&k[i].empty()&&"single"==d&&!b.shiftKey?(Za(g,La(k.slice(0,i).concat(k.slice(i+1)),0),{scroll:!1,origin:"*mouse"}),j=g.sel):Va(g,i,h,Yf):(i=0,Za(g,new Ja([h],0),Yf),j=g.sel);var n=c,p=f.wrapper.getBoundingClientRect(),q=0,t=dc(a,function(a){If(a)?r(a):s(a)}),u=dc(a,s);a.state.selectingText=u,Jf(document,"mousemove",t),Jf(document,"mouseup",u)}function Ac(a,b,c,d,e){try{var f=b.clientX,g=b.clientY}catch(b){return!1}if(f>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&Df(b);var h=a.display,i=h.lineDiv.getBoundingClientRect();if(g>i.bottom||!Tf(a,c))return Ff(b);g-=i.top-h.viewOffset;for(var j=0;j<a.options.gutters.length;++j){var k=h.gutters.childNodes[j];if(k&&k.getBoundingClientRect().right>=f){var l=lf(a.doc,g),m=a.options.gutters[j];return e(a,c,a,l,m,b),Ff(b)}}}function Bc(a,b){return Ac(a,b,"gutterClick",!0,Pf)}function Dc(a){var b=this;if(Gc(b),!Rf(b,a)&&!sc(b.display,a)){Df(a),d&&(Cc=+new Date);var c=tc(b,a,!0),e=a.dataTransfer.files;if(c&&!ua(b))if(e&&e.length&&window.FileReader&&window.File)for(var f=e.length,g=Array(f),h=0,i=function(a,d){var e=new FileReader;e.onload=dc(b,function(){if(g[d]=e.result,++h==f){c=Oa(b.doc,c);var a={from:c,to:c,text:b.doc.splitLines(g.join(b.doc.lineSeparator())),origin:"paste"};hd(b.doc,a),Ya(b.doc,Ma(c,bd(a)))}}),e.readAsText(a)},j=0;f>j;++j)i(e[j],j);else{if(b.state.draggingText&&b.doc.sel.contains(c)>-1)return b.state.draggingText(a),void setTimeout(function(){b.display.input.focus()},20);try{var g=a.dataTransfer.getData("Text");if(g){if(b.state.draggingText&&!(o?a.altKey:a.ctrlKey))var k=b.listSelections();if($a(b.doc,Ma(c,c)),k)for(var j=0;j<k.length;++j)nd(b.doc,"",k[j].anchor,k[j].head,"drag");b.replaceSelection(g,"around","paste"),b.display.input.focus()}}catch(a){}}}}function Ec(a,b){if(d&&(!a.state.draggingText||+new Date-Cc<100))return void Gf(b);if(!Rf(a,b)&&!sc(a.display,b)&&(b.dataTransfer.setData("Text",a.getSelection()),b.dataTransfer.setDragImage&&!j)){var c=rg("img",null,null,"position: fixed; left: 0; top: 0;");c.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",i&&(c.width=c.height=1,a.display.wrapper.appendChild(c),c._top=c.offsetTop),b.dataTransfer.setDragImage(c,0,0),i&&c.parentNode.removeChild(c)}}function Fc(a,b){var c=tc(a,b);if(c){var d=document.createDocumentFragment();fb(a,c,d),a.display.dragCursor||(a.display.dragCursor=rg("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),a.display.lineSpace.insertBefore(a.display.dragCursor,a.display.cursorDiv)),ug(a.display.dragCursor,d)}}function Gc(a){a.display.dragCursor&&(a.display.lineSpace.removeChild(a.display.dragCursor),a.display.dragCursor=null)}function Hc(b,c){Math.abs(b.doc.scrollTop-c)<2||(b.doc.scrollTop=c,a||Y(b,{top:c}),b.display.scroller.scrollTop!=c&&(b.display.scroller.scrollTop=c),b.display.scrollbars.setScrollTop(c),a&&Y(b),ib(b,100))}function Ic(a,b,c){(c?b==a.doc.scrollLeft:Math.abs(a.doc.scrollLeft-b)<2)||(b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,Q(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbars.setScrollLeft(b))}function Mc(b,c){var d=Lc(c),e=d.x,g=d.y,h=b.display,j=h.scroller;if(e&&j.scrollWidth>j.clientWidth||g&&j.scrollHeight>j.clientHeight){if(g&&o&&f)a:for(var k=c.target,l=h.view;k!=j;k=k.parentNode)for(var m=0;m<l.length;m++)if(l[m].node==k){b.display.currentWheelTarget=k;break a}if(e&&!a&&!i&&null!=Kc)return g&&Hc(b,Math.max(0,Math.min(j.scrollTop+g*Kc,j.scrollHeight-j.clientHeight))),Ic(b,Math.max(0,Math.min(j.scrollLeft+e*Kc,j.scrollWidth-j.clientWidth))),Df(c),void(h.wheelStartX=null);if(g&&null!=Kc){var n=g*Kc,p=b.doc.scrollTop,q=p+h.wrapper.clientHeight;0>n?p=Math.max(0,p+n-50):q=Math.min(b.doc.height,q+n+50),Y(b,{top:p,bottom:q})}20>Jc&&(null==h.wheelStartX?(h.wheelStartX=j.scrollLeft,h.wheelStartY=j.scrollTop,h.wheelDX=e,h.wheelDY=g,setTimeout(function(){if(null!=h.wheelStartX){var a=j.scrollLeft-h.wheelStartX,b=j.scrollTop-h.wheelStartY,c=b&&h.wheelDY&&b/h.wheelDY||a&&h.wheelDX&&a/h.wheelDX;h.wheelStartX=h.wheelStartY=null,c&&(Kc=(Kc*Jc+c)/(Jc+1),++Jc)}},200)):(h.wheelDX+=e,h.wheelDY+=g))}}function Nc(a,b,c){if("string"==typeof b&&(b=Ld[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift,e=!1;try{ua(a)&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=Wf}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function Oc(a,b,c){for(var d=0;d<a.state.keyMaps.length;d++){var e=Od(b,a.state.keyMaps[d],c,a);if(e)return e}return a.options.extraKeys&&Od(b,a.options.extraKeys,c,a)||Od(b,a.options.keyMap,c,a)}function Qc(a,b,c,d){var e=a.state.keySeq;if(e){if(Pd(b))return"handled";Pc.set(50,function(){a.state.keySeq==e&&(a.state.keySeq=null,a.display.input.reset())}),b=e+" "+b}var f=Oc(a,b,d);return"multi"==f&&(a.state.keySeq=b),"handled"==f&&Pf(a,"keyHandled",a,b,c),("handled"==f||"multi"==f)&&(Df(c),hb(a)),e&&!f&&/\'$/.test(b)?(Df(c),!0):!!f}function Rc(a,b){var c=Qd(b,!0);return c?b.shiftKey&&!a.state.keySeq?Qc(a,"Shift-"+c,b,function(b){return Nc(a,b,!0)})||Qc(a,c,b,function(b){return("string"==typeof b?/^go[A-Z]/.test(b):b.motion)?Nc(a,b):void 0}):Qc(a,c,b,function(b){return Nc(a,b)}):!1}function Sc(a,b,c){return Qc(a,"'"+c+"'",b,function(b){return Nc(a,b,!0)})}function Uc(a){var b=this;if(b.curOp.focus=wg(),!Rf(b,a)){d&&11>e&&27==a.keyCode&&(a.returnValue=!1);var c=a.keyCode;b.display.shift=16==c||a.shiftKey;var f=Rc(b,a);i&&(Tc=f?c:null,!f&&88==c&&!Mg&&(o?a.metaKey:a.ctrlKey)&&b.replaceSelection("",null,"cut")),18!=c||/\bCodeMirror-crosshair\b/.test(b.display.lineDiv.className)||Vc(b)}}function Vc(a){function c(a){18!=a.keyCode&&a.altKey||(yg(b,"CodeMirror-crosshair"),Mf(document,"keyup",c),Mf(document,"mouseover",c))}var b=a.display.lineDiv;zg(b,"CodeMirror-crosshair"),Jf(document,"keyup",c),Jf(document,"mouseover",c)}function Wc(a){16==a.keyCode&&(this.doc.sel.shift=!1),Rf(this,a)}function Xc(a){var b=this;if(!(sc(b.display,a)||Rf(b,a)||a.ctrlKey&&!a.altKey||o&&a.metaKey)){var c=a.keyCode,d=a.charCode;if(i&&c==Tc)return Tc=null,void Df(a);if(!i||a.which&&!(a.which<10)||!Rc(b,a)){var e=String.fromCharCode(null==d?c:d);Sc(b,a,e)||b.display.input.onKeyPress(a)}}}function Yc(a){a.state.delayingBlurEvent=!0,setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,$c(a))},100)}function Zc(a){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1),"nocursor"!=a.options.readOnly&&(a.state.focused||(Nf(a,"focus",a),a.state.focused=!0,zg(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),f&&setTimeout(function(){a.display.input.reset(!0)},20)),a.display.input.receivedFocus()),hb(a))}function $c(a){a.state.delayingBlurEvent||(a.state.focused&&(Nf(a,"blur",a),a.state.focused=!1,yg(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150))}function _c(a,b){sc(a.display,b)||ad(a,b)||a.display.input.onContextMenu(b)}function ad(a,b){return Tf(a,"gutterContextMenu")?Ac(a,b,"gutterContextMenu",!1,Nf):!1}function cd(a,b){if(pa(a,b.from)<0)return a;if(pa(a,b.to)<=0)return bd(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;return a.line==b.to.line&&(d+=bd(b).ch-b.to.ch),oa(c,d)}function dd(a,b){for(var c=[],d=0;d<a.sel.ranges.length;d++){var e=a.sel.ranges[d];c.push(new Ka(cd(e.anchor,b),cd(e.head,b)))}return La(c,a.sel.primIndex)}function ed(a,b,c){return a.line==b.line?oa(c.line,a.ch-b.ch+c.ch):oa(c.line+(a.line-b.line),a.ch)}function fd(a,b,c){for(var d=[],e=oa(a.first,0),f=e,g=0;g<b.length;g++){var h=b[g],i=ed(h.from,e,f),j=ed(bd(h),e,f);if(e=h.to,f=j,"around"==c){var k=a.sel.ranges[g],l=pa(k.head,k.anchor)<0;d[g]=new Ka(l?j:i,l?i:j)}else d[g]=new Ka(i,i)}return new Ja(d,a.sel.primIndex)}function gd(a,b,c){var d={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,cancel:function(){this.canceled=!0}};return c&&(d.update=function(b,c,d,e){b&&(this.from=Oa(a,b)),c&&(this.to=Oa(a,c)),d&&(this.text=d),void 0!==e&&(this.origin=e)}),Nf(a,"beforeChange",a,d),a.cm&&Nf(a.cm,"beforeChange",a.cm,d),d.canceled?null:{from:d.from,to:d.to,text:d.text,origin:d.origin}}function hd(a,b,c){if(a.cm){if(!a.cm.curOp)return dc(a.cm,hd)(a,b,c);if(a.cm.state.suppressEdits)return}if(!(Tf(a,"beforeChange")||a.cm&&Tf(a.cm,"beforeChange"))||(b=gd(a,b,!0))){var d=t&&!c&&ie(a,b.from,b.to);if(d)for(var e=d.length-1;e>=0;--e)id(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text});else id(a,b)}}function id(a,b){if(1!=b.text.length||""!=b.text[0]||0!=pa(b.from,b.to)){var c=dd(a,b);sf(a,b,c,a.cm?a.cm.curOp.id:NaN),ld(a,b,c,fe(a,b));var d=[];df(a,function(a,c){c||-1!=fg(d,a.history)||(Cf(a.history,b),d.push(a.history)),ld(a,b,null,fe(a,b))})}}function jd(a,b,c){if(!a.cm||!a.cm.state.suppressEdits){for(var e,d=a.history,f=a.sel,g="undo"==b?d.done:d.undone,h="undo"==b?d.undone:d.done,i=0;i<g.length&&(e=g[i],c?!e.ranges||e.equals(a.sel):e.ranges);i++);if(i!=g.length){for(d.lastOrigin=d.lastSelOrigin=null;e=g.pop(),e.ranges;){if(vf(e,h),c&&!e.equals(a.sel))return void Za(a,e,{clearRedo:!1});f=e}var j=[];vf(f,h),h.push({changes:j,generation:d.generation}),d.generation=e.generation||++d.maxGeneration;for(var k=Tf(a,"beforeChange")||a.cm&&Tf(a.cm,"beforeChange"),i=e.changes.length-1;i>=0;--i){var l=e.changes[i];if(l.origin=b,k&&!gd(a,l,!1))return void(g.length=0);j.push(pf(a,l));var m=i?dd(a,l):dg(g);ld(a,l,m,he(a,l)),!i&&a.cm&&a.cm.scrollIntoView({from:l.from,to:bd(l)});var n=[];df(a,function(a,b){b||-1!=fg(n,a.history)||(Cf(a.history,l),n.push(a.history)),ld(a,l,null,he(a,l))})}}}}function kd(a,b){if(0!=b&&(a.first+=b,a.sel=new Ja(gg(a.sel.ranges,function(a){return new Ka(oa(a.anchor.line+b,a.anchor.ch),oa(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){ic(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;d<c.viewTo;d++)jc(a.cm,d,"gutter")}}function ld(a,b,c,d){if(a.cm&&!a.cm.curOp)return dc(a.cm,ld)(a,b,c,d);if(b.to.line<a.first)return void kd(a,b.text.length-1-(b.to.line-b.from.line));if(!(b.from.line>a.lastLine())){if(b.from.line<a.first){var e=b.text.length-1-(a.first-b.from.line);kd(a,e),b={from:oa(a.first,0),to:oa(b.to.line+e,b.to.ch),text:[dg(b.text)],origin:b.origin}}var f=a.lastLine();b.to.line>f&&(b={from:b.from,to:oa(f,ff(a,f).text.length),text:[b.text[0]],origin:b.origin}),b.removed=gf(a,b.from,b.to),c||(c=dd(a,b)),a.cm?md(a.cm,b,d):Ye(a,b,d),$a(a,c,Xf)}}function md(a,b,c){var d=a.doc,e=a.display,f=b.from,g=b.to,h=!1,i=f.line;a.options.lineWrapping||(i=kf(se(ff(d,f.line))),d.iter(i,g.line+1,function(a){return a==e.maxLine?(h=!0,!0):void 0})),d.sel.contains(b.from,b.to)>-1&&Sf(a),Ye(d,b,c,A(a)),a.options.lineWrapping||(d.iter(i,f.line+b.text.length,function(a){var b=G(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,h=!1)}),h&&(a.curOp.updateMaxLine=!0)),d.frontier=Math.min(d.frontier,f.line),ib(a,400);var j=b.text.length-(g.line-f.line)-1;b.full?ic(a):f.line!=g.line||1!=b.text.length||Xe(a.doc,b)?ic(a,f.line,g.line+1,j):jc(a,f.line,"text");var k=Tf(a,"changes"),l=Tf(a,"change");if(l||k){var m={from:f,to:g,text:b.text,removed:b.removed,origin:b.origin};l&&Pf(a,"change",a,m),k&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(m)}a.display.selForContextMenu=null}function nd(a,b,c,d,e){if(d||(d=c),pa(d,c)<0){var f=d;d=c,c=f}"string"==typeof b&&(b=a.splitLines(b)),hd(a,{from:c,to:d,text:b,origin:e})}function od(a,b){if(!Rf(a,"scrollCursorIntoView")){var c=a.display,d=c.sizer.getBoundingClientRect(),e=null;if(b.top+d.top<0?e=!0:b.bottom+d.top>(window.innerHeight||document.documentElement.clientHeight)&&(e=!1),null!=e&&!l){var f=rg("div","\u200b",null,"position: absolute; top: "+(b.top-c.viewOffset-mb(a.display))+"px; height: "+(b.bottom-b.top+pb(a)+c.barHeight)+"px; left: "+b.left+"px; width: 2px;");a.display.lineSpace.appendChild(f),f.scrollIntoView(e),a.display.lineSpace.removeChild(f)}}}function pd(a,b,c,d){null==d&&(d=0);for(var e=0;5>e;e++){var f=!1,g=Lb(a,b),h=c&&c!=b?Lb(a,c):g,i=rd(a,Math.min(g.left,h.left),Math.min(g.top,h.top)-d,Math.max(g.left,h.left),Math.max(g.bottom,h.bottom)+d),j=a.doc.scrollTop,k=a.doc.scrollLeft;if(null!=i.scrollTop&&(Hc(a,i.scrollTop),Math.abs(a.doc.scrollTop-j)>1&&(f=!0)),null!=i.scrollLeft&&(Ic(a,i.scrollLeft),Math.abs(a.doc.scrollLeft-k)>1&&(f=!0)),!f)break}return g}function qd(a,b,c,d,e){var f=rd(a,b,c,d,e);null!=f.scrollTop&&Hc(a,f.scrollTop),null!=f.scrollLeft&&Ic(a,f.scrollLeft)}function rd(a,b,c,d,e){var f=a.display,g=Rb(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,i=rb(a),j={};e-c>i&&(e=c+i);var k=a.doc.height+nb(f),l=g>c,m=e>k-g;if(h>c)j.scrollTop=l?0:c;else if(e>h+i){var n=Math.min(c,(m?k:e)-i);n!=h&&(j.scrollTop=n)}var o=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft,p=qb(a)-(a.options.fixedGutter?f.gutters.offsetWidth:0),q=d-b>p;return q&&(d=b+p),10>b?j.scrollLeft=0:o>b?j.scrollLeft=Math.max(0,b-(q?0:10)):d>p+o-3&&(j.scrollLeft=d+(q?0:10)-p),j}function sd(a,b,c){(null!=b||null!=c)&&ud(a),null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b),null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function td(a){ud(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?oa(b.line,b.ch-1):b,d=oa(b.line,b.ch+1)),a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function ud(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=Mb(a,b.from),d=Mb(a,b.to),e=rd(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(e.scrollLeft,e.scrollTop)}}function vd(a,b,c,d){var f,e=a.doc;null==c&&(c="add"),"smart"==c&&(e.mode.indent?f=lb(a,b):c="prev");var g=a.options.tabSize,h=ff(e,b),i=_f(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var k,j=h.text.match(/^\s*/)[0];if(d||/\S/.test(h.text)){if("smart"==c&&(k=e.mode.indent(f,h.text.slice(j.length),h.text),k==Wf||k>150)){if(!d)return;c="prev"}}else k=0,c="not";"prev"==c?k=b>e.first?_f(ff(e,b-1).text,null,g):0:"add"==c?k=i+a.options.indentUnit:"subtract"==c?k=i-a.options.indentUnit:"number"==typeof c&&(k=i+c),k=Math.max(0,k);
|
18 |
-
var l="",m=0;if(a.options.indentWithTabs)for(var n=Math.floor(k/g);n;--n)m+=g,l+=" ";if(k>m&&(l+=cg(k-m)),l!=j)return nd(e,l,oa(b,0),oa(b,j.length),"+input"),h.stateAfter=null,!0;for(var n=0;n<e.sel.ranges.length;n++){var o=e.sel.ranges[n];if(o.head.line==b&&o.head.ch<j.length){var m=oa(b,j.length);Va(e,n,new Ka(m,m));break}}}function wd(a,b,c,d){var e=b,f=b;return"number"==typeof b?f=ff(a,Na(a,b)):e=kf(b),null==e?null:(d(f,e)&&a.cm&&jc(a.cm,e,c),f)}function xd(a,b){for(var c=a.doc.sel.ranges,d=[],e=0;e<c.length;e++){for(var f=b(c[e]);d.length&&pa(f.from,dg(d).to)<=0;){var g=d.pop();if(pa(g.from,f.from)<0){f.from=g.from;break}}d.push(f)}cc(a,function(){for(var b=d.length-1;b>=0;b--)nd(a.doc,"",d[b].from,d[b].to,"+delete");td(a)})}function yd(a,b,c,d,e){function k(){var b=f+c;return b<a.first||b>=a.first+a.size?j=!1:(f=b,i=ff(a,b))}function l(a){var b=(e?ah:bh)(i,g,c,!0);if(null==b){if(a||!k())return j=!1;g=e?(0>c?Ug:Tg)(i):0>c?i.text.length:0}else g=b;return!0}var f=b.line,g=b.ch,h=c,i=ff(a,f),j=!0;if("char"==d)l();else if("column"==d)l(!0);else if("word"==d||"group"==d)for(var m=null,n="group"==d,o=a.cm&&a.cm.getHelper(b,"wordChars"),p=!0;!(0>c)||l(!p);p=!1){var q=i.text.charAt(g)||"\n",r=ng(q,o)?"w":n&&"\n"==q?"n":!n||/\s/.test(q)?null:"p";if(!n||p||r||(r="s"),m&&m!=r){0>c&&(c=1,l());break}if(r&&(m=r),c>0&&!l(!p))break}var s=cb(a,oa(f,g),h,!0);return j||(s.hitSide=!0),s}function zd(a,b,c,d){var g,e=a.doc,f=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);g=b.top+c*(h-(0>c?1.5:.5)*Rb(a.display))}else"line"==d&&(g=c>0?b.bottom+3:b.top-3);for(;;){var i=Ob(a,f,g);if(!i.outside)break;if(0>c?0>=g:g>=e.height){i.hitSide=!0;break}g+=5*c}return i}function Cd(a,b,c,d){v.defaults[a]=b,c&&(Bd[a]=d?function(a,b,d){d!=Dd&&c(a,b,d)}:c)}function Nd(a){for(var c,d,e,f,b=a.split(/-(?!$)/),a=b[b.length-1],g=0;g<b.length-1;g++){var h=b[g];if(/^(cmd|meta|m)$/i.test(h))f=!0;else if(/^a(lt)?$/i.test(h))c=!0;else if(/^(c|ctrl|control)$/i.test(h))d=!0;else{if(!/^s(hift)$/i.test(h))throw new Error("Unrecognized modifier name: "+h);e=!0}}return c&&(a="Alt-"+a),d&&(a="Ctrl-"+a),f&&(a="Cmd-"+a),e&&(a="Shift-"+a),a}function Rd(a){return"string"==typeof a?Md[a]:a}function Vd(a,b,c,d,e){if(d&&d.shared)return Xd(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return dc(a.cm,Vd)(a,b,c,d,e);var f=new Ud(a,e),g=pa(b,c);if(d&&jg(d,f,!1),g>0||0==g&&f.clearWhenEmpty!==!1)return f;if(f.replacedWith&&(f.collapsed=!0,f.widgetNode=rg("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||f.widgetNode.setAttribute("cm-ignore-events","true"),d.insertLeft&&(f.widgetNode.insertLeft=!0)),f.collapsed){if(re(a,b.line,b,c,f)||b.line!=c.line&&re(a,c.line,b,c,f))throw new Error("Inserting collapsed marker partially overlapping an existing one");u=!0}f.addToHistory&&sf(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var j,h=b.line,i=a.cm;if(a.iter(h,c.line+1,function(a){i&&f.collapsed&&!i.options.lineWrapping&&se(a)==i.display.maxLine&&(j=!0),f.collapsed&&h!=b.line&&jf(a,0),ce(a,new _d(f,h==b.line?b.ch:null,h==c.line?c.ch:null)),++h}),f.collapsed&&a.iter(b.line,c.line+1,function(b){we(a,b)&&jf(b,0)}),f.clearOnEnter&&Jf(f,"beforeCursorEnter",function(){f.clear()}),f.readOnly&&(t=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory()),f.collapsed&&(f.id=++Td,f.atomic=!0),i){if(j&&(i.curOp.updateMaxLine=!0),f.collapsed)ic(i,b.line,c.line+1);else if(f.className||f.title||f.startStyle||f.endStyle||f.css)for(var k=b.line;k<=c.line;k++)jc(i,k,"text");f.atomic&&ab(i.doc),Pf(i,"markerAdded",i,f)}return f}function Xd(a,b,c,d,e){d=jg(d),d.shared=!1;var f=[Vd(a,b,c,d,e)],g=f[0],h=d.widgetNode;return df(a,function(a){h&&(d.widgetNode=h.cloneNode(!0)),f.push(Vd(a,Oa(a,b),Oa(a,c),d,e));for(var i=0;i<a.linked.length;++i)if(a.linked[i].isParent)return;g=dg(f)}),new Wd(f,g)}function Yd(a){return a.findMarks(oa(a.first,0),a.clipPos(oa(a.lastLine())),function(a){return a.parent})}function Zd(a,b){for(var c=0;c<b.length;c++){var d=b[c],e=d.find(),f=a.clipPos(e.from),g=a.clipPos(e.to);if(pa(f,g)){var h=Vd(a,f,g,d.primary,d.primary.type);d.markers.push(h),h.parent=d}}}function $d(a){for(var b=0;b<a.length;b++){var c=a[b],d=[c.primary.doc];df(c.primary.doc,function(a){d.push(a)});for(var e=0;e<c.markers.length;e++){var f=c.markers[e];-1==fg(d,f.doc)&&(f.parent=null,c.markers.splice(e--,1))}}}function _d(a,b,c){this.marker=a,this.from=b,this.to=c}function ae(a,b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function be(a,b){for(var c,d=0;d<a.length;++d)a[d]!=b&&(c||(c=[])).push(a[d]);return c}function ce(a,b){a.markedSpans=a.markedSpans?a.markedSpans.concat([b]):[b],b.marker.attachLine(a)}function de(a,b,c){if(a)for(var e,d=0;d<a.length;++d){var f=a[d],g=f.marker,h=null==f.from||(g.inclusiveLeft?f.from<=b:f.from<b);if(h||f.from==b&&"bookmark"==g.type&&(!c||!f.marker.insertLeft)){var i=null==f.to||(g.inclusiveRight?f.to>=b:f.to>b);(e||(e=[])).push(new _d(g,f.from,i?null:f.to))}}return e}function ee(a,b,c){if(a)for(var e,d=0;d<a.length;++d){var f=a[d],g=f.marker,h=null==f.to||(g.inclusiveRight?f.to>=b:f.to>b);if(h||f.from==b&&"bookmark"==g.type&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from<b);(e||(e=[])).push(new _d(g,i?null:f.from-b,null==f.to?null:f.to-b))}}return e}function fe(a,b){if(b.full)return null;var c=Qa(a,b.from.line)&&ff(a,b.from.line).markedSpans,d=Qa(a,b.to.line)&&ff(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,f=b.to.ch,g=0==pa(b.from,b.to),h=de(c,e,g),i=ee(d,f,g),j=1==b.text.length,k=dg(b.text).length+(j?e:0);if(h)for(var l=0;l<h.length;++l){var m=h[l];if(null==m.to){var n=ae(i,m.marker);n?j&&(m.to=null==n.to?null:n.to+k):m.to=e}}if(i)for(var l=0;l<i.length;++l){var m=i[l];if(null!=m.to&&(m.to+=k),null==m.from){var n=ae(h,m.marker);n||(m.from=k,j&&(h||(h=[])).push(m))}else m.from+=k,j&&(h||(h=[])).push(m)}h&&(h=ge(h)),i&&i!=h&&(i=ge(i));var o=[h];if(!j){var q,p=b.text.length-2;if(p>0&&h)for(var l=0;l<h.length;++l)null==h[l].to&&(q||(q=[])).push(new _d(h[l].marker,null,null));for(var l=0;p>l;++l)o.push(q);o.push(i)}return o}function ge(a){for(var b=0;b<a.length;++b){var c=a[b];null!=c.from&&c.from==c.to&&c.marker.clearWhenEmpty!==!1&&a.splice(b--,1)}return a.length?a:null}function he(a,b){var c=yf(a,b),d=fe(a,b);if(!c)return d;if(!d)return c;for(var e=0;e<c.length;++e){var f=c[e],g=d[e];if(f&&g)a:for(var h=0;h<g.length;++h){for(var i=g[h],j=0;j<f.length;++j)if(f[j].marker==i.marker)continue a;f.push(i)}else g&&(c[e]=g)}return c}function ie(a,b,c){var d=null;if(a.iter(b.line,c.line+1,function(a){if(a.markedSpans)for(var b=0;b<a.markedSpans.length;++b){var c=a.markedSpans[b].marker;!c.readOnly||d&&-1!=fg(d,c)||(d||(d=[])).push(c)}}),!d)return null;for(var e=[{from:b,to:c}],f=0;f<d.length;++f)for(var g=d[f],h=g.find(0),i=0;i<e.length;++i){var j=e[i];if(!(pa(j.to,h.from)<0||pa(j.from,h.to)>0)){var k=[i,1],l=pa(j.from,h.from),m=pa(j.to,h.to);(0>l||!g.inclusiveLeft&&!l)&&k.push({from:j.from,to:h.from}),(m>0||!g.inclusiveRight&&!m)&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-1}}return e}function je(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=null}}function ke(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=b}}function le(a){return a.inclusiveLeft?-1:0}function me(a){return a.inclusiveRight?1:0}function ne(a,b){var c=a.lines.length-b.lines.length;if(0!=c)return c;var d=a.find(),e=b.find(),f=pa(d.from,e.from)||le(a)-le(b);if(f)return-f;var g=pa(d.to,e.to)||me(a)-me(b);return g?g:b.id-a.id}function oe(a,b){var d,c=u&&a.markedSpans;if(c)for(var e,f=0;f<c.length;++f)e=c[f],e.marker.collapsed&&null==(b?e.from:e.to)&&(!d||ne(d,e.marker)<0)&&(d=e.marker);return d}function pe(a){return oe(a,!0)}function qe(a){return oe(a,!1)}function re(a,b,c,d,e){var f=ff(a,b),g=u&&f.markedSpans;if(g)for(var h=0;h<g.length;++h){var i=g[h];if(i.marker.collapsed){var j=i.marker.find(0),k=pa(j.from,c)||le(i.marker)-le(e),l=pa(j.to,d)||me(i.marker)-me(e);if(!(k>=0&&0>=l||0>=k&&l>=0)&&(0>=k&&(pa(j.to,c)>0||i.marker.inclusiveRight&&e.inclusiveLeft)||k>=0&&(pa(j.from,d)<0||i.marker.inclusiveLeft&&e.inclusiveRight)))return!0}}}function se(a){for(var b;b=pe(a);)a=b.find(-1,!0).line;return a}function te(a){for(var b,c;b=qe(a);)a=b.find(1,!0).line,(c||(c=[])).push(a);return c}function ue(a,b){var c=ff(a,b),d=se(c);return c==d?b:kf(d)}function ve(a,b){if(b>a.lastLine())return b;var d,c=ff(a,b);if(!we(a,c))return b;for(;d=qe(c);)c=d.find(1,!0).line;return kf(c)+1}function we(a,b){var c=u&&b.markedSpans;if(c)for(var d,e=0;e<c.length;++e)if(d=c[e],d.marker.collapsed){if(null==d.from)return!0;if(!d.marker.widgetNode&&0==d.from&&d.marker.inclusiveLeft&&xe(a,b,d))return!0}}function xe(a,b,c){if(null==c.to){var d=c.marker.find(1,!0);return xe(a,d.line,ae(d.line.markedSpans,c.marker))}if(c.marker.inclusiveRight&&c.to==b.text.length)return!0;for(var e,f=0;f<b.markedSpans.length;++f)if(e=b.markedSpans[f],e.marker.collapsed&&!e.marker.widgetNode&&e.from==c.to&&(null==e.to||e.to!=c.from)&&(e.marker.inclusiveLeft||c.marker.inclusiveRight)&&xe(a,b,e))return!0}function ze(a,b,c){mf(b)<(a.curOp&&a.curOp.scrollTop||a.doc.scrollTop)&&sd(a,null,c)}function Ae(a){if(null!=a.height)return a.height;var b=a.doc.cm;if(!b)return 0;if(!vg(document.body,a.node)){var c="position: relative;";a.coverGutter&&(c+="margin-left: -"+b.display.gutters.offsetWidth+"px;"),a.noHScroll&&(c+="width: "+b.display.wrapper.clientWidth+"px;"),ug(b.display.measure,rg("div",[a.node],null,c))}return a.height=a.node.offsetHeight}function Be(a,b,c,d){var e=new ye(a,c,d),f=a.cm;return f&&e.noHScroll&&(f.display.alignWidgets=!0),wd(a,b,"widget",function(b){var c=b.widgets||(b.widgets=[]);if(null==e.insertAt?c.push(e):c.splice(Math.min(c.length-1,Math.max(0,e.insertAt)),0,e),e.line=b,f&&!we(a,b)){var d=mf(b)<a.scrollTop;jf(b,b.height+Ae(e)),d&&sd(f,null,e.height),f.curOp.forceUpdate=!0}return!0}),e}function De(a,b,c,d){a.text=b,a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null),null!=a.order&&(a.order=null),je(a),ke(a,c);var e=d?d(a):1;e!=a.height&&jf(a,e)}function Ee(a){a.parent=null,je(a)}function Fe(a,b){if(a)for(;;){var c=a.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!c)break;a=a.slice(0,c.index)+a.slice(c.index+c[0].length);var d=c[1]?"bgClass":"textClass";null==b[d]?b[d]=c[2]:new RegExp("(?:^|s)"+c[2]+"(?:$|s)").test(b[d])||(b[d]+=" "+c[2])}return a}function Ge(a,b){if(a.blankLine)return a.blankLine(b);if(a.innerMode){var c=v.innerMode(a,b);return c.mode.blankLine?c.mode.blankLine(c.state):void 0}}function He(a,b,c,d){for(var e=0;10>e;e++){d&&(d[0]=v.innerMode(a,c).mode);var f=a.token(b,c);if(b.pos>b.start)return f}throw new Error("Mode "+a.name+" failed to advance stream.")}function Ie(a,b,c,d){function e(a){return{start:k.start,end:k.pos,string:k.current(),type:h||null,state:a?Jd(f.mode,j):j}}var h,f=a.doc,g=f.mode;b=Oa(f,b);var l,i=ff(f,b.line),j=lb(a,b.line,c),k=new Sd(i.text,a.options.tabSize);for(d&&(l=[]);(d||k.pos<b.ch)&&!k.eol();)k.start=k.pos,h=He(g,k,j),d&&l.push(e(!0));return d?l:e()}function Je(a,b,c,d,e,f,g){var h=c.flattenSpans;null==h&&(h=a.options.flattenSpans);var l,i=0,j=null,k=new Sd(b,a.options.tabSize),m=a.options.addModeClass&&[null];for(""==b&&Fe(Ge(c,d),f);!k.eol();){if(k.pos>a.options.maxHighlightLength?(h=!1,g&&Me(a,b,d,k.pos),k.pos=b.length,l=null):l=Fe(He(c,k,d,m),f),m){var n=m[0].name;n&&(l="m-"+(l?n+" "+l:n))}if(!h||j!=l){for(;i<k.start;)i=Math.min(k.start,i+5e4),e(i,j);j=l}k.start=k.pos}for(;i<k.pos;){var o=Math.min(k.pos,i+5e4);e(o,j),i=o}}function Ke(a,b,c,d){var e=[a.state.modeGen],f={};Je(a,b.text,a.doc.mode,c,function(a,b){e.push(a,b)},f,d);for(var g=0;g<a.state.overlays.length;++g){var h=a.state.overlays[g],i=1,j=0;Je(a,b.text,h.mode,!0,function(a,b){for(var c=i;a>j;){var d=e[i];d>a&&e.splice(i,1,a,e[i+1],d),i+=2,j=Math.min(a,d)}if(b)if(h.opaque)e.splice(c,i-c,a,"cm-overlay "+b),i=c+2;else for(;i>c;c+=2){var f=e[c+1];e[c+1]=(f?f+" ":"")+"cm-overlay "+b}},f)}return{styles:e,classes:f.bgClass||f.textClass?f:null}}function Le(a,b,c){if(!b.styles||b.styles[0]!=a.state.modeGen){var d=lb(a,kf(b)),e=Ke(a,b,b.text.length>a.options.maxHighlightLength?Jd(a.doc.mode,d):d);b.stateAfter=d,b.styles=e.styles,e.classes?b.styleClasses=e.classes:b.styleClasses&&(b.styleClasses=null),c===a.doc.frontier&&a.doc.frontier++}return b.styles}function Me(a,b,c,d){var e=a.doc.mode,f=new Sd(b,a.options.tabSize);for(f.start=f.pos=d||0,""==b&&Ge(e,c);!f.eol();)He(e,f,c),f.start=f.pos}function Pe(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?Oe:Ne;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function Qe(a,b){var c=rg("span",null,null,f?"padding-right: .1px":null),e={pre:rg("pre",[c],"CodeMirror-line"),content:c,col:0,pos:0,cm:a,splitSpaces:(d||f)&&a.getOption("lineWrapping")};b.measure={};for(var g=0;g<=(b.rest?b.rest.length:0);g++){var i,h=g?b.rest[g-1]:b.line;e.pos=0,e.addToken=Se,Jg(a.display.measure)&&(i=nf(h))&&(e.addToken=Ue(e.addToken,i)),e.map=[];var j=b!=a.display.externalMeasured&&kf(h);We(h,e,Le(a,h,j)),h.styleClasses&&(h.styleClasses.bgClass&&(e.bgClass=Ag(h.styleClasses.bgClass,e.bgClass||"")),h.styleClasses.textClass&&(e.textClass=Ag(h.styleClasses.textClass,e.textClass||""))),0==e.map.length&&e.map.push(0,0,e.content.appendChild(Hg(a.display.measure))),0==g?(b.measure.map=e.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(e.map),(b.measure.caches||(b.measure.caches=[])).push({}))}return f&&/\bcm-tab\b/.test(e.content.lastChild.className)&&(e.content.className="cm-tab-wrap-hack"),Nf(a,"renderLine",a,b.line,e.pre),e.pre.className&&(e.textClass=Ag(e.pre.className,e.textClass||"")),e}function Re(a){var b=rg("span","\u2022","cm-invalidchar");return b.title="\\u"+a.charCodeAt(0).toString(16),b.setAttribute("aria-label",b.title),b}function Se(a,b,c,f,g,h,i){if(b){var j=a.splitSpaces?b.replace(/ {3,}/g,Te):b,k=a.cm.state.specialChars,l=!1;if(k.test(b))for(var m=document.createDocumentFragment(),n=0;;){k.lastIndex=n;var o=k.exec(b),p=o?o.index-n:b.length-n;if(p){var q=document.createTextNode(j.slice(n,n+p));d&&9>e?m.appendChild(rg("span",[q])):m.appendChild(q),a.map.push(a.pos,a.pos+p,q),a.col+=p,a.pos+=p}if(!o)break;if(n+=p+1," "==o[0]){var r=a.cm.options.tabSize,s=r-a.col%r,q=m.appendChild(rg("span",cg(s),"cm-tab"));q.setAttribute("role","presentation"),q.setAttribute("cm-text"," "),a.col+=s}else if("\r"==o[0]||"\n"==o[0]){var q=m.appendChild(rg("span","\r"==o[0]?"\u240d":"\u2424","cm-invalidchar"));q.setAttribute("cm-text",o[0]),a.col+=1}else{var q=a.cm.options.specialCharPlaceholder(o[0]);q.setAttribute("cm-text",o[0]),d&&9>e?m.appendChild(rg("span",[q])):m.appendChild(q),a.col+=1}a.map.push(a.pos,a.pos+1,q),a.pos++}else{a.col+=b.length;var m=document.createTextNode(j);a.map.push(a.pos,a.pos+b.length,m),d&&9>e&&(l=!0),a.pos+=b.length}if(c||f||g||l||i){var t=c||"";f&&(t+=f),g&&(t+=g);var u=rg("span",[m],t,i);return h&&(u.title=h),a.content.appendChild(u)}a.content.appendChild(m)}}function Te(a){for(var b=" ",c=0;c<a.length-2;++c)b+=c%2?" ":"\xa0";return b+=" "}function Ue(a,b){return function(c,d,e,f,g,h,i){e=e?e+" cm-force-border":"cm-force-border";for(var j=c.pos,k=j+d.length;;){for(var l=0;l<b.length;l++){var m=b[l];if(m.to>j&&m.from<=j)break}if(m.to>=k)return a(c,d,e,f,g,h,i);a(c,d.slice(0,m.to-j),e,f,null,h,i),f=null,d=d.slice(m.to-j),j=m.to}}}function Ve(a,b,c,d){var e=!d&&c.widgetNode;e&&a.map.push(a.pos,a.pos+b,e),!d&&a.cm.display.input.needsContentAttribute&&(e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id)),e&&(a.cm.display.input.setUneditable(e),a.content.appendChild(e)),a.pos+=b}function We(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(d)for(var k,l,n,o,p,q,r,h=e.length,i=0,g=1,j="",m=0;;){if(m==i){n=o=p=q=l="",r=null,m=1/0;for(var s=[],t=0;t<d.length;++t){var u=d[t],v=u.marker;"bookmark"==v.type&&u.from==i&&v.widgetNode?s.push(v):u.from<=i&&(null==u.to||u.to>i||v.collapsed&&u.to==i&&u.from==i)?(null!=u.to&&u.to!=i&&m>u.to&&(m=u.to,o=""),v.className&&(n+=" "+v.className),v.css&&(l=v.css),v.startStyle&&u.from==i&&(p+=" "+v.startStyle),v.endStyle&&u.to==m&&(o+=" "+v.endStyle),v.title&&!q&&(q=v.title),v.collapsed&&(!r||ne(r.marker,v)<0)&&(r=u)):u.from>i&&m>u.from&&(m=u.from)}if(r&&(r.from||0)==i){if(Ve(b,(null==r.to?h+1:r.to)-i,r.marker,null==r.from),null==r.to)return;r.to==i&&(r=!1)}if(!r&&s.length)for(var t=0;t<s.length;++t)Ve(b,0,s[t])}if(i>=h)break;for(var w=Math.min(h,m);;){if(j){var x=i+j.length;if(!r){var y=x>w?j.slice(0,w-i):j;b.addToken(b,y,k?k+n:n,p,i+y.length==m?o:"",q,l)}if(x>=w){j=j.slice(w-i),i=w;break}i=x,p=""}j=e.slice(f,f=c[g++]),k=Pe(c[g++],b.cm.options)}}else for(var g=1;g<c.length;g+=2)b.addToken(b,e.slice(f,f=c[g]),Pe(c[g+1],b.cm.options))}function Xe(a,b){return 0==b.from.ch&&0==b.to.ch&&""==dg(b.text)&&(!a.cm||a.cm.options.wholeLineUpdateBefore)}function Ye(a,b,c,d){function e(a){return c?c[a]:null}function f(a,c,e){De(a,c,e,d),Pf(a,"change",a,b)}function g(a,b){for(var c=a,f=[];b>c;++c)f.push(new Ce(j[c],e(c),d));return f}var h=b.from,i=b.to,j=b.text,k=ff(a,h.line),l=ff(a,i.line),m=dg(j),n=e(j.length-1),o=i.line-h.line;if(b.full)a.insert(0,g(0,j.length)),a.remove(j.length,a.size-j.length);else if(Xe(a,b)){var p=g(0,j.length-1);f(l,l.text,n),o&&a.remove(h.line,o),p.length&&a.insert(h.line,p)}else if(k==l)if(1==j.length)f(k,k.text.slice(0,h.ch)+m+k.text.slice(i.ch),n);else{var p=g(1,j.length-1);p.push(new Ce(m+k.text.slice(i.ch),n,d)),f(k,k.text.slice(0,h.ch)+j[0],e(0)),a.insert(h.line+1,p)}else if(1==j.length)f(k,k.text.slice(0,h.ch)+j[0]+l.text.slice(i.ch),e(0)),a.remove(h.line+1,o);else{f(k,k.text.slice(0,h.ch)+j[0],e(0)),f(l,m+l.text.slice(i.ch),n);var p=g(1,j.length-1);o>1&&a.remove(h.line+1,o-1),a.insert(h.line+1,p)}Pf(a,"change",a,b)}function Ze(a){this.lines=a,this.parent=null;for(var b=0,c=0;b<a.length;++b)a[b].parent=this,c+=a[b].height;this.height=c}function $e(a){this.children=a;for(var b=0,c=0,d=0;d<a.length;++d){var e=a[d];b+=e.chunkSize(),c+=e.height,e.parent=this}this.size=b,this.height=c,this.parent=null}function df(a,b,c){function d(a,e,f){if(a.linked)for(var g=0;g<a.linked.length;++g){var h=a.linked[g];if(h.doc!=e){var i=f&&h.sharedHist;(!c||i)&&(b(h.doc,i),d(h.doc,a,i))}}}d(a,null,!0)}function ef(a,b){if(b.cm)throw new Error("This document is already in use.");a.doc=b,b.cm=a,B(a),x(a),a.options.lineWrapping||H(a),a.options.mode=b.modeOption,ic(a)}function ff(a,b){if(b-=a.first,0>b||b>=a.size)throw new Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(f>b){c=e;break}b-=f}return c.lines[b]}function gf(a,b,c){var d=[],e=b.line;return a.iter(b.line,c.line+1,function(a){var f=a.text;e==c.line&&(f=f.slice(0,c.ch)),e==b.line&&(f=f.slice(b.ch)),d.push(f),++e}),d}function hf(a,b,c){var d=[];return a.iter(b,c,function(a){d.push(a.text)}),d}function jf(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function kf(a){if(null==a.parent)return null;for(var b=a.parent,c=fg(b.lines,a),d=b.parent;d;b=d,d=d.parent)for(var e=0;d.children[e]!=b;++e)c+=d.children[e].chunkSize();return c+b.first}function lf(a,b){var c=a.first;a:do{for(var d=0;d<a.children.length;++d){var e=a.children[d],f=e.height;if(f>b){a=e;continue a}b-=f,c+=e.chunkSize()}return c}while(!a.lines);for(var d=0;d<a.lines.length;++d){var g=a.lines[d],h=g.height;if(h>b)break;b-=h}return c+d}function mf(a){a=se(a);for(var b=0,c=a.parent,d=0;d<c.lines.length;++d){var e=c.lines[d];if(e==a)break;b+=e.height}for(var f=c.parent;f;c=f,f=c.parent)for(var d=0;d<f.children.length;++d){var g=f.children[d];if(g==c)break;b+=g.height}return b}function nf(a){var b=a.order;return null==b&&(b=a.order=ch(a.text)),b}function of(a){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=a||1}function pf(a,b){var c={from:qa(b.from),to:bd(b),text:gf(a,b.from,b.to)};return wf(a,c,b.from.line,b.to.line+1),df(a,function(a){wf(a,c,b.from.line,b.to.line+1)},!0),c}function qf(a){for(;a.length;){var b=dg(a);if(!b.ranges)break;a.pop()}}function rf(a,b){return b?(qf(a.done),dg(a.done)):a.done.length&&!dg(a.done).ranges?dg(a.done):a.done.length>1&&!a.done[a.done.length-2].ranges?(a.done.pop(),dg(a.done)):void 0}function sf(a,b,c,d){var e=a.history;e.undone.length=0;var g,f=+new Date;if((e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>f-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))&&(g=rf(e,e.lastOp==d))){var h=dg(g.changes);0==pa(b.from,b.to)&&0==pa(b.from,h.to)?h.to=bd(b):g.changes.push(pf(a,b))}else{var i=dg(e.done);for(i&&i.ranges||vf(a.sel,e.done),g={changes:[pf(a,b)],generation:e.generation},e.done.push(g);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift()}e.done.push(c),e.generation=++e.maxGeneration,e.lastModTime=e.lastSelTime=f,e.lastOp=e.lastSelOp=d,e.lastOrigin=e.lastSelOrigin=b.origin,h||Nf(a,"historyAdded")}function tf(a,b,c,d){var e=b.charAt(0);return"*"==e||"+"==e&&c.ranges.length==d.ranges.length&&c.somethingSelected()==d.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function uf(a,b,c,d){var e=a.history,f=d&&d.origin;c==e.lastSelOp||f&&e.lastSelOrigin==f&&(e.lastModTime==e.lastSelTime&&e.lastOrigin==f||tf(a,f,dg(e.done),b))?e.done[e.done.length-1]=b:vf(b,e.done),e.lastSelTime=+new Date,e.lastSelOrigin=f,e.lastSelOp=c,d&&d.clearRedo!==!1&&qf(e.undone)}function vf(a,b){var c=dg(b);c&&c.ranges&&c.equals(a)||b.push(a)}function wf(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f})}function xf(a){if(!a)return null;for(var c,b=0;b<a.length;++b)a[b].marker.explicitlyCleared?c||(c=a.slice(0,b)):c&&c.push(a[b]);return c?c.length?c:null:a}function yf(a,b){var c=b["spans_"+a.id];if(!c)return null;for(var d=0,e=[];d<b.text.length;++d)e.push(xf(c[d]));return e}function zf(a,b,c){for(var d=0,e=[];d<a.length;++d){var f=a[d];if(f.ranges)e.push(c?Ja.prototype.deepCopy.call(f):f);else{var g=f.changes,h=[];e.push({changes:h});for(var i=0;i<g.length;++i){var k,j=g[i];if(h.push({from:j.from,to:j.to,text:j.text}),b)for(var l in j)(k=l.match(/^spans_(\d+)$/))&&fg(b,Number(k[1]))>-1&&(dg(h)[l]=j[l],delete j[l])}}}return e}function Af(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}function Bf(a,b,c,d){for(var e=0;e<a.length;++e){var f=a[e],g=!0;if(f.ranges){f.copied||(f=a[e]=f.deepCopy(),f.copied=!0);for(var h=0;h<f.ranges.length;h++)Af(f.ranges[h].anchor,b,c,d),Af(f.ranges[h].head,b,c,d)}else{for(var h=0;h<f.changes.length;++h){var i=f.changes[h];if(c<i.from.line)i.from=oa(i.from.line+d,i.from.ch),i.to=oa(i.to.line+d,i.to.ch);else if(b<=i.to.line){g=!1;break}}g||(a.splice(0,e+1),e=0)}}}function Cf(a,b){var c=b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;Bf(a.done,c,d,e),Bf(a.undone,c,d,e)}function Ff(a){return null!=a.defaultPrevented?a.defaultPrevented:0==a.returnValue}function Hf(a){return a.target||a.srcElement}function If(a){var b=a.which;return null==b&&(1&a.button?b=1:2&a.button?b=3:4&a.button&&(b=2)),o&&a.ctrlKey&&1==b&&(b=3),b}function Lf(a,b,c){var d=a._handlers&&a._handlers[b];return c?d&&d.length>0?d.slice():Kf:d||Kf}function Pf(a,b){function f(a){return function(){a.apply(null,d)}}var c=Lf(a,b,!1);if(c.length){var e,d=Array.prototype.slice.call(arguments,2);Tb?e=Tb.delayedCallbacks:Of?e=Of:(e=Of=[],setTimeout(Qf,0));for(var g=0;g<c.length;++g)e.push(f(c[g]))}}function Qf(){var a=Of;Of=null;for(var b=0;b<a.length;++b)a[b]()}function Rf(a,b,c){return"string"==typeof b&&(b={type:b,preventDefault:function(){this.defaultPrevented=!0}}),Nf(a,c||b.type,a,b),Ff(b)||b.codemirrorIgnore}function Sf(a){var b=a._handlers&&a._handlers.cursorActivity;if(b)for(var c=a.curOp.cursorActivityHandlers||(a.curOp.cursorActivityHandlers=[]),d=0;d<b.length;++d)-1==fg(c,b[d])&&c.push(b[d])}function Tf(a,b){return Lf(a,b).length>0}function Uf(a){a.prototype.on=function(a,b){Jf(this,a,b)},a.prototype.off=function(a,b){Mf(this,a,b)}}function $f(){this.id=null}function cg(a){for(;bg.length<=a;)bg.push(dg(bg)+" ");return bg[a]}function dg(a){return a[a.length-1]}function fg(a,b){for(var c=0;c<a.length;++c)if(a[c]==b)return c;return-1}function gg(a,b){for(var c=[],d=0;d<a.length;d++)c[d]=b(a[d],d);return c}function hg(){}function ig(a,b){var c;return Object.create?c=Object.create(a):(hg.prototype=a,c=new hg),b&&jg(b,c),c}function jg(a,b,c){b||(b={});for(var d in a)!a.hasOwnProperty(d)||c===!1&&b.hasOwnProperty(d)||(b[d]=a[d]);return b}function kg(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function ng(a,b){return b?b.source.indexOf("\\w")>-1&&mg(a)?!0:b.test(a):mg(a)}function og(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function qg(a){return a.charCodeAt(0)>=768&&pg.test(a)}function rg(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)e.appendChild(document.createTextNode(b));else if(b)for(var f=0;f<b.length;++f)e.appendChild(b[f]);return e}function tg(a){for(var b=a.childNodes.length;b>0;--b)a.removeChild(a.firstChild);return a}function ug(a,b){return tg(a).appendChild(b)}function wg(){for(var a=document.activeElement;a&&a.root&&a.root.activeElement;)a=a.root.activeElement;return a}function xg(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function Ag(a,b){for(var c=a.split(" "),d=0;d<c.length;d++)c[d]&&!xg(c[d]).test(b)&&(b+=" "+c[d]);return b}function Bg(a){if(document.body.getElementsByClassName)for(var b=document.body.getElementsByClassName("CodeMirror"),c=0;c<b.length;c++){var d=b[c].CodeMirror;d&&a(d)}}function Dg(){Cg||(Eg(),Cg=!0)}function Eg(){var a;Jf(window,"resize",function(){null==a&&(a=setTimeout(function(){a=null,Bg(rc)},100))}),Jf(window,"blur",function(){Bg($c)})}function Hg(a){if(null==Gg){var b=rg("span","\u200b");ug(a,rg("span",[b,document.createTextNode("x")])),0!=a.firstChild.offsetHeight&&(Gg=b.offsetWidth<=1&&b.offsetHeight>2&&!(d&&8>e))}var c=Gg?rg("span","\u200b"):rg("span","\xa0",null,"display: inline-block; width: 1px; margin-right: -1px");return c.setAttribute("cm-text",""),c}function Jg(a){if(null!=Ig)return Ig;var b=ug(a,document.createTextNode("A\u062eA")),c=sg(b,0,1).getBoundingClientRect();if(!c||c.left==c.right)return!1;var d=sg(b,1,2).getBoundingClientRect();return Ig=d.right-c.right<3}function Og(a){if(null!=Ng)return Ng;var b=ug(a,rg("span","x")),c=b.getBoundingClientRect(),d=sg(b,0,1).getBoundingClientRect();return Ng=Math.abs(c.left-d.left)>1}function Qg(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;f<a.length;++f){var g=a[f];(g.from<c&&g.to>b||b==c&&g.to==b)&&(d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0)}e||d(b,c,"ltr")}function Rg(a){return a.level%2?a.to:a.from}function Sg(a){return a.level%2?a.from:a.to}function Tg(a){var b=nf(a);return b?Rg(b[0]):0}function Ug(a){var b=nf(a);return b?Sg(dg(b)):a.text.length}function Vg(a,b){var c=ff(a.doc,b),d=se(c);d!=c&&(b=kf(d));var e=nf(d),f=e?e[0].level%2?Ug(d):Tg(d):0;return oa(b,f)}function Wg(a,b){for(var c,d=ff(a.doc,b);c=qe(d);)d=c.find(1,!0).line,b=null;var e=nf(d),f=e?e[0].level%2?Tg(d):Ug(d):d.text.length;return oa(null==b?kf(d):b,f)}function Xg(a,b){var c=Vg(a,b.line),d=ff(a.doc,c.line),e=nf(d);if(!e||0==e[0].level){var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;return oa(c.line,g?0:f)}return c}function Yg(a,b,c){var d=a[0].level;return b==d?!0:c==d?!1:c>b}function $g(a,b){Zg=null;for(var d,c=0;c<a.length;++c){var e=a[c];if(e.from<b&&e.to>b)return c;if(e.from==b||e.to==b){if(null!=d)return Yg(a,e.level,a[d].level)?(e.from!=e.to&&(Zg=d),c):(e.from!=e.to&&(Zg=c),d);d=c}}return d}function _g(a,b,c,d){if(!d)return b+c;do b+=c;while(b>0&&qg(a.text.charAt(b)));return b}function ah(a,b,c,d){var e=nf(a);if(!e)return bh(a,b,c,d);for(var f=$g(e,b),g=e[f],h=_g(a,b,g.level%2?-c:c,d);;){if(h>g.from&&h<g.to)return h;if(h==g.from||h==g.to)return $g(e,h)==f?h:(g=e[f+=c],c>0==g.level%2?g.to:g.from);if(g=e[f+=c],!g)return null;h=c>0==g.level%2?_g(a,g.to,-1,d):_g(a,g.from,1,d)}}function bh(a,b,c,d){var e=b+c;if(d)for(;e>0&&qg(a.text.charAt(e));)e+=c;return 0>e||e>a.text.length?null:e}var a=/gecko\/\d/i.test(navigator.userAgent),b=/MSIE \d/.test(navigator.userAgent),c=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),d=b||c,e=d&&(b?document.documentMode||6:c[1]),f=/WebKit\//.test(navigator.userAgent),g=f&&/Qt\/\d+\.\d+/.test(navigator.userAgent),h=/Chrome\//.test(navigator.userAgent),i=/Opera\//.test(navigator.userAgent),j=/Apple Computer/.test(navigator.vendor),k=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),l=/PhantomJS/.test(navigator.userAgent),m=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),n=m||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),o=m||/Mac/.test(navigator.platform),p=/win/i.test(navigator.platform),q=i&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);q&&(q=Number(q[1])),q&&q>=15&&(i=!1,f=!0);var r=o&&(g||i&&(null==q||12.11>q)),s=a||d&&e>=9,t=!1,u=!1;K.prototype=jg({update:function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>a.clientHeight+1,d=a.nativeBarWidth;if(c){this.vert.style.display="block",this.vert.style.bottom=b?d+"px":"0";var e=a.viewHeight-(b?d:0);this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+e)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(b){this.horiz.style.display="block",this.horiz.style.right=c?d+"px":"0",this.horiz.style.left=a.barLeft+"px";var f=a.viewWidth-a.barLeft-(c?d:0);this.horiz.firstChild.style.width=a.scrollWidth-a.clientWidth+f+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&a.clientHeight>0&&(0==d&&this.overlayHack(),this.checkedOverlay=!0),{right:c?d:0,bottom:b?d:0}},setScrollLeft:function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=a)},setScrollTop:function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a)},overlayHack:function(){var a=o&&!k?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=a;var b=this,c=function(a){Hf(a)!=b.vert&&Hf(a)!=b.horiz&&dc(b.cm,uc)(a)};Jf(this.vert,"mousedown",c),Jf(this.horiz,"mousedown",c)},clear:function(){var a=this.horiz.parentNode;a.removeChild(this.horiz),a.removeChild(this.vert)}},K.prototype),L.prototype=jg({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},L.prototype),v.scrollbarModel={"native":K,"null":L},U.prototype.signal=function(a,b){Tf(a,b)&&this.events.push(arguments)},U.prototype.finish=function(){for(var a=0;a<this.events.length;a++)Nf.apply(null,this.events[a])};var oa=v.Pos=function(a,b){return this instanceof oa?(this.line=a,void(this.ch=b)):new oa(a,b)},pa=v.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch},va=null;Ba.prototype=jg({init:function(a){function h(a){if(c.somethingSelected())va=c.getSelections(),b.inaccurateSelection&&(b.prevInput="",b.inaccurateSelection=!1,g.value=va.join("\n"),eg(g));else{if(!c.options.lineWiseCopyCut)return;var d=za(c);va=d.text,"cut"==a.type?c.setSelections(d.ranges,null,Xf):(b.prevInput="",g.value=d.text.join("\n"),eg(g))}"cut"==a.type&&(c.state.cutIncoming=!0)}var b=this,c=this.cm,f=this.wrapper=Ca(),g=this.textarea=f.firstChild;a.wrapper.insertBefore(f,a.wrapper.firstChild),m&&(g.style.width="0px"),Jf(g,"input",function(){d&&e>=9&&b.hasSelection&&(b.hasSelection=null),b.poll()}),Jf(g,"paste",function(a){return xa(a,c)?!0:(c.state.pasteIncoming=!0,void b.fastPoll())}),Jf(g,"cut",h),Jf(g,"copy",h),Jf(a.scroller,"paste",function(d){sc(a,d)||(c.state.pasteIncoming=!0,b.focus())}),Jf(a.lineSpace,"selectstart",function(b){sc(a,b)||Df(b)}),Jf(g,"compositionstart",function(){
|
19 |
-
var a=c.getCursor("from");b.composing&&b.composing.range.clear(),b.composing={start:a,range:c.markText(a,c.getCursor("to"),{className:"CodeMirror-composing"})}}),Jf(g,"compositionend",function(){b.composing&&(b.poll(),b.composing.range.clear(),b.composing=null)})},prepareSelection:function(){var a=this.cm,b=a.display,c=a.doc,d=eb(a);if(a.options.moveInputWithCursor){var e=Lb(a,c.sel.primary().head,"div"),f=b.wrapper.getBoundingClientRect(),g=b.lineDiv.getBoundingClientRect();d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,e.top+g.top-f.top)),d.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-10,e.left+g.left-f.left))}return d},showSelection:function(a){var b=this.cm,c=b.display;ug(c.cursorDiv,a.cursors),ug(c.selectionDiv,a.selection),null!=a.teTop&&(this.wrapper.style.top=a.teTop+"px",this.wrapper.style.left=a.teLeft+"px")},reset:function(a){if(!this.contextMenuPending){var b,c,f=this.cm,g=f.doc;if(f.somethingSelected()){this.prevInput="";var h=g.sel.primary();b=Mg&&(h.to().line-h.from().line>100||(c=f.getSelection()).length>1e3);var i=b?"-":c||f.getSelection();this.textarea.value=i,f.state.focused&&eg(this.textarea),d&&e>=9&&(this.hasSelection=i)}else a||(this.prevInput=this.textarea.value="",d&&e>=9&&(this.hasSelection=null));this.inaccurateSelection=b}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!n||wg()!=this.textarea))try{this.textarea.focus()}catch(a){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var a=this;a.pollingFast||a.polling.set(this.cm.options.pollInterval,function(){a.poll(),a.cm.state.focused&&a.slowPoll()})},fastPoll:function(){function c(){var d=b.poll();d||a?(b.pollingFast=!1,b.slowPoll()):(a=!0,b.polling.set(60,c))}var a=!1,b=this;b.pollingFast=!0,b.polling.set(20,c)},poll:function(){var a=this.cm,b=this.textarea,c=this.prevInput;if(this.contextMenuPending||!a.state.focused||Lg(b)&&!c&&!this.composing||ua(a)||a.options.disableInput||a.state.keySeq)return!1;var f=b.value;if(f==c&&!a.somethingSelected())return!1;if(d&&e>=9&&this.hasSelection===f||o&&/[\uf700-\uf7ff]/.test(f))return a.display.input.reset(),!1;if(a.doc.sel==a.display.selForContextMenu){var g=f.charCodeAt(0);if(8203!=g||c||(c="\u200b"),8666==g)return this.reset(),this.cm.execCommand("undo")}for(var h=0,i=Math.min(c.length,f.length);i>h&&c.charCodeAt(h)==f.charCodeAt(h);)++h;var j=this;return cc(a,function(){wa(a,f.slice(h),c.length-h,null,j.composing?"*compose":null),f.length>1e3||f.indexOf("\n")>-1?b.value=j.prevInput="":j.prevInput=f,j.composing&&(j.composing.range.clear(),j.composing.range=a.markText(j.composing.start,a.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){d&&e>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(a){function o(){if(null!=h.selectionStart){var a=c.somethingSelected(),d="\u200b"+(a?h.value:"");h.value="\u21da",h.value=d,b.prevInput=a?"":"\u200b",h.selectionStart=1,h.selectionEnd=d.length,g.selForContextMenu=c.doc.sel}}function p(){if(b.contextMenuPending=!1,b.wrapper.style.position="relative",h.style.cssText=m,d&&9>e&&g.scrollbars.setScrollTop(g.scroller.scrollTop=k),null!=h.selectionStart){(!d||d&&9>e)&&o();var a=0,f=function(){g.selForContextMenu==c.doc.sel&&0==h.selectionStart&&h.selectionEnd>0&&"\u200b"==b.prevInput?dc(c,Ld.selectAll)(c):a++<10?g.detectingSelectAll=setTimeout(f,500):g.input.reset()};g.detectingSelectAll=setTimeout(f,200)}}var b=this,c=b.cm,g=c.display,h=b.textarea,j=tc(c,a),k=g.scroller.scrollTop;if(j&&!i){var l=c.options.resetSelectionOnContextMenu;l&&-1==c.doc.sel.contains(j)&&dc(c,Za)(c.doc,Ma(j),Xf);var m=h.style.cssText;if(b.wrapper.style.position="absolute",h.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(a.clientY-5)+"px; left: "+(a.clientX-5)+"px; z-index: 1000; background: "+(d?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",f)var n=window.scrollY;if(g.input.focus(),f&&window.scrollTo(null,n),g.input.reset(),c.somethingSelected()||(h.value=b.prevInput=" "),b.contextMenuPending=!0,g.selForContextMenu=c.doc.sel,clearTimeout(g.detectingSelectAll),d&&e>=9&&o(),s){Gf(a);var q=function(){Mf(window,"mouseup",q),setTimeout(p,20)};Jf(window,"mouseup",q)}else setTimeout(p,50)}},readOnlyChanged:function(a){a||this.reset()},setUneditable:hg,needsContentAttribute:!1},Ba.prototype),Da.prototype=jg({init:function(a){function e(a){if(c.somethingSelected())va=c.getSelections(),"cut"==a.type&&c.replaceSelection("",null,"cut");else{if(!c.options.lineWiseCopyCut)return;var b=za(c);va=b.text,"cut"==a.type&&c.operation(function(){c.setSelections(b.ranges,0,Xf),c.replaceSelection("",null,"cut")})}if(a.clipboardData&&!m)a.preventDefault(),a.clipboardData.clearData(),a.clipboardData.setData("text/plain",va.join("\n"));else{var d=Ca(),e=d.firstChild;c.display.lineSpace.insertBefore(d,c.display.lineSpace.firstChild),e.value=va.join("\n");var f=document.activeElement;eg(e),setTimeout(function(){c.display.lineSpace.removeChild(d),f.focus()},50)}}var b=this,c=b.cm,d=b.div=a.lineDiv;Aa(d),Jf(d,"paste",function(a){xa(a,c)}),Jf(d,"compositionstart",function(a){var d=a.data;if(b.composing={sel:c.doc.sel,data:d,startData:d},d){var e=c.doc.sel.primary(),f=c.getLine(e.head.line),g=f.indexOf(d,Math.max(0,e.head.ch-d.length));g>-1&&g<=e.head.ch&&(b.composing.sel=Ma(oa(e.head.line,g),oa(e.head.line,g+d.length)))}}),Jf(d,"compositionupdate",function(a){b.composing.data=a.data}),Jf(d,"compositionend",function(a){var c=b.composing;c&&(a.data==c.startData||/\u200b/.test(a.data)||(c.data=a.data),setTimeout(function(){c.handled||b.applyComposition(c),b.composing==c&&(b.composing=null)},50))}),Jf(d,"touchstart",function(){b.forceCompositionEnd()}),Jf(d,"input",function(){b.composing||(ua(c)||!b.pollContent())&&cc(b.cm,function(){ic(c)})}),Jf(d,"copy",e),Jf(d,"cut",e)},prepareSelection:function(){var a=eb(this.cm,!1);return a.focus=this.cm.state.focused,a},showSelection:function(a){a&&this.cm.display.view.length&&(a.focus&&this.showPrimarySelection(),this.showMultipleSelections(a))},showPrimarySelection:function(){var b=window.getSelection(),c=this.cm.doc.sel.primary(),d=Ga(this.cm,b.anchorNode,b.anchorOffset),e=Ga(this.cm,b.focusNode,b.focusOffset);if(!d||d.bad||!e||e.bad||0!=pa(sa(d,e),c.from())||0!=pa(ra(d,e),c.to())){var f=Ea(this.cm,c.from()),g=Ea(this.cm,c.to());if(f||g){var h=this.cm.display.view,i=b.rangeCount&&b.getRangeAt(0);if(f){if(!g){var j=h[h.length-1].measure,k=j.maps?j.maps[j.maps.length-1]:j.map;g={node:k[k.length-1],offset:k[k.length-2]-k[k.length-3]}}}else f={node:h[0].measure.map[2],offset:0};try{var l=sg(f.node,f.offset,g.offset,g.node)}catch(m){}l&&(b.removeAllRanges(),b.addRange(l),i&&null==b.anchorNode?b.addRange(i):a&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var a=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){a.gracePeriod=!1,a.selectionChanged()&&a.cm.operation(function(){a.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(a){ug(this.cm.display.cursorDiv,a.cursors),ug(this.cm.display.selectionDiv,a.selection)},rememberSelection:function(){var a=window.getSelection();this.lastAnchorNode=a.anchorNode,this.lastAnchorOffset=a.anchorOffset,this.lastFocusNode=a.focusNode,this.lastFocusOffset=a.focusOffset},selectionInEditor:function(){var a=window.getSelection();if(!a.rangeCount)return!1;var b=a.getRangeAt(0).commonAncestorContainer;return vg(this.div,b)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function b(){a.cm.state.focused&&(a.pollSelection(),a.polling.set(a.cm.options.pollInterval,b))}var a=this;this.selectionInEditor()?this.pollSelection():cc(this.cm,function(){a.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,b)},selectionChanged:function(){var a=window.getSelection();return a.anchorNode!=this.lastAnchorNode||a.anchorOffset!=this.lastAnchorOffset||a.focusNode!=this.lastFocusNode||a.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var a=window.getSelection(),b=this.cm;this.rememberSelection();var c=Ga(b,a.anchorNode,a.anchorOffset),d=Ga(b,a.focusNode,a.focusOffset);c&&d&&cc(b,function(){Za(b.doc,Ma(c,d),Xf),(c.bad||d.bad)&&(b.curOp.selectionChanged=!0)})}},pollContent:function(){var a=this.cm,b=a.display,c=a.doc.sel.primary(),d=c.from(),e=c.to();if(d.line<b.viewFrom||e.line>b.viewTo-1)return!1;var f;if(d.line==b.viewFrom||0==(f=lc(a,d.line)))var g=kf(b.view[0].line),h=b.view[0].node;else var g=kf(b.view[f].line),h=b.view[f-1].node.nextSibling;var i=lc(a,e.line);if(i==b.view.length-1)var j=b.viewTo-1,k=b.lineDiv.lastChild;else var j=kf(b.view[i+1].line)-1,k=b.view[i+1].node.previousSibling;for(var l=a.doc.splitLines(Ia(a,h,k,g,j)),m=gf(a.doc,oa(g,0),oa(j,ff(a.doc,j).text.length));l.length>1&&m.length>1;)if(dg(l)==dg(m))l.pop(),m.pop(),j--;else{if(l[0]!=m[0])break;l.shift(),m.shift(),g++}for(var n=0,o=0,p=l[0],q=m[0],r=Math.min(p.length,q.length);r>n&&p.charCodeAt(n)==q.charCodeAt(n);)++n;for(var s=dg(l),t=dg(m),u=Math.min(s.length-(1==l.length?n:0),t.length-(1==m.length?n:0));u>o&&s.charCodeAt(s.length-o-1)==t.charCodeAt(t.length-o-1);)++o;l[l.length-1]=s.slice(0,s.length-o),l[0]=l[0].slice(n);var v=oa(g,n),w=oa(j,m.length?dg(m).length-o:0);return l.length>1||l[0]||pa(v,w)?(nd(a.doc,l,v,w,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(a){ua(this.cm)?dc(this.cm,ic)(this.cm):a.data&&a.data!=a.startData&&dc(this.cm,wa)(this.cm,a.data,0,a.sel)},setUneditable:function(a){a.contentEditable="false"},onKeyPress:function(a){a.preventDefault(),ua(this.cm)||dc(this.cm,wa)(this.cm,String.fromCharCode(null==a.charCode?a.keyCode:a.charCode),0)},readOnlyChanged:function(a){this.div.contentEditable=String("nocursor"!=a)},onContextMenu:hg,resetPosition:hg,needsContentAttribute:!0},Da.prototype),v.inputStyles={textarea:Ba,contenteditable:Da},Ja.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(a){if(a==this)return!0;if(a.primIndex!=this.primIndex||a.ranges.length!=this.ranges.length)return!1;for(var b=0;b<this.ranges.length;b++){var c=this.ranges[b],d=a.ranges[b];if(0!=pa(c.anchor,d.anchor)||0!=pa(c.head,d.head))return!1}return!0},deepCopy:function(){for(var a=[],b=0;b<this.ranges.length;b++)a[b]=new Ka(qa(this.ranges[b].anchor),qa(this.ranges[b].head));return new Ja(a,this.primIndex)},somethingSelected:function(){for(var a=0;a<this.ranges.length;a++)if(!this.ranges[a].empty())return!0;return!1},contains:function(a,b){b||(b=a);for(var c=0;c<this.ranges.length;c++){var d=this.ranges[c];if(pa(b,d.from())>=0&&pa(a,d.to())<=0)return c}return-1}},Ka.prototype={from:function(){return sa(this.anchor,this.head)},to:function(){return ra(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Qb,vc,wc,zb={left:0,right:0,top:0,bottom:0},Tb=null,Ub=0,Cc=0,Jc=0,Kc=null;d?Kc=-.53:a?Kc=15:h?Kc=-.7:j&&(Kc=-1/3);var Lc=function(a){var b=a.wheelDeltaX,c=a.wheelDeltaY;return null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail),null==c&&a.detail&&a.axis==a.VERTICAL_AXIS?c=a.detail:null==c&&(c=a.wheelDelta),{x:b,y:c}};v.wheelEventPixels=function(a){var b=Lc(a);return b.x*=Kc,b.y*=Kc,b};var Pc=new $f,Tc=null,bd=v.changeEnd=function(a){return a.text?oa(a.from.line+a.text.length-1,dg(a.text).length+(1==a.text.length?a.from.ch:0)):a.to};v.prototype={constructor:v,focus:function(){window.focus(),this.display.input.focus()},setOption:function(a,b){var c=this.options,d=c[a];(c[a]!=b||"mode"==a)&&(c[a]=b,Bd.hasOwnProperty(a)&&dc(this,Bd[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](Rd(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;c<b.length;++c)if(b[c]==a||b[c].name==a)return b.splice(c,1),!0},addOverlay:ec(function(a,b){var c=a.token?a:v.getMode(this.options,a);if(c.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:c,modeSpec:a,opaque:b&&b.opaque}),this.state.modeGen++,ic(this)}),removeOverlay:ec(function(a){for(var b=this.state.overlays,c=0;c<b.length;++c){var d=b[c].modeSpec;if(d==a||"string"==typeof a&&d.name==a)return b.splice(c,1),this.state.modeGen++,void ic(this)}}),indentLine:ec(function(a,b,c){"string"!=typeof b&&"number"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract"),Qa(this.doc,a)&&vd(this,a,b,c)}),indentSelection:ec(function(a){for(var b=this.doc.sel.ranges,c=-1,d=0;d<b.length;d++){var e=b[d];if(e.empty())e.head.line>c&&(vd(this,e.head.line,a,!0),c=e.head.line,d==this.doc.sel.primIndex&&td(this));else{var f=e.from(),g=e.to(),h=Math.max(c,f.line);c=Math.min(this.lastLine(),g.line-(g.ch?0:1))+1;for(var i=h;c>i;++i)vd(this,i,a);var j=this.doc.sel.ranges;0==f.ch&&b.length==j.length&&j[d].from().ch>0&&Va(this.doc,d,new Ka(f,j[d].to()),Xf)}}}),getTokenAt:function(a,b){return Ie(this,a,b)},getLineTokens:function(a,b){return Ie(this,oa(a),b,!0)},getTokenTypeAt:function(a){a=Oa(this.doc,a);var f,b=Le(this,ff(this.doc,a.line)),c=0,d=(b.length-1)/2,e=a.ch;if(0==e)f=b[2];else for(;;){var g=c+d>>1;if((g?b[2*g-1]:0)>=e)d=g;else{if(!(b[2*g+1]<e)){f=b[2*g+2];break}c=g+1}}var h=f?f.indexOf("cm-overlay "):-1;return 0>h?f:0==h?null:f.slice(0,h-1)},getModeAt:function(a){var b=this.doc.mode;return b.innerMode?v.innerMode(b,this.getTokenAt(a).state).mode:b},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var c=[];if(!Id.hasOwnProperty(b))return c;var d=Id[b],e=this.getModeAt(a);if("string"==typeof e[b])d[e[b]]&&c.push(d[e[b]]);else if(e[b])for(var f=0;f<e[b].length;f++){var g=d[e[b][f]];g&&c.push(g)}else e.helperType&&d[e.helperType]?c.push(d[e.helperType]):d[e.name]&&c.push(d[e.name]);for(var f=0;f<d._global.length;f++){var h=d._global[f];h.pred(e,this)&&-1==fg(c,h.val)&&c.push(h.val)}return c},getStateAfter:function(a,b){var c=this.doc;return a=Na(c,null==a?c.first+c.size-1:a),lb(this,a+1,b)},cursorCoords:function(a,b){var c,d=this.doc.sel.primary();return c=null==a?d.head:"object"==typeof a?Oa(this.doc,a):a?d.from():d.to(),Lb(this,c,b||"page")},charCoords:function(a,b){return Kb(this,Oa(this.doc,a),b||"page")},coordsChar:function(a,b){return a=Jb(this,a,b||"page"),Ob(this,a.left,a.top)},lineAtHeight:function(a,b){return a=Jb(this,{top:a,left:0},b||"page").top,lf(this.doc,a+this.display.viewOffset)},heightAtLine:function(a,b){var d,c=!1;if("number"==typeof a){var e=this.doc.first+this.doc.size-1;a<this.doc.first?a=this.doc.first:a>e&&(a=e,c=!0),d=ff(this.doc,a)}else d=a;return Ib(this,d,{top:0,left:0},b||"page").top+(c?this.doc.height-mf(d):0)},defaultTextHeight:function(){return Rb(this.display)},defaultCharWidth:function(){return Sb(this.display)},setGutterMarker:ec(function(a,b,c){return wd(this.doc,a,"gutter",function(a){var d=a.gutterMarkers||(a.gutterMarkers={});return d[b]=c,!c&&og(d)&&(a.gutterMarkers=null),!0})}),clearGutter:ec(function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,jc(b,d,"gutter"),og(c.gutterMarkers)&&(c.gutterMarkers=null)),++d})}),lineInfo:function(a){if("number"==typeof a){if(!Qa(this.doc,a))return null;var b=a;if(a=ff(this.doc,a),!a)return null}else{var b=kf(a);if(null==b)return null}return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=Lb(this,Oa(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",b.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(b),f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&qd(this,h,g,h+b.offsetWidth,g+b.offsetHeight)},triggerOnKeyDown:ec(Uc),triggerOnKeyPress:ec(Xc),triggerOnKeyUp:Wc,execCommand:function(a){return Ld.hasOwnProperty(a)?Ld[a].call(null,this):void 0},triggerElectric:ec(function(a){ya(this,a)}),findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,g=Oa(this.doc,a);b>f&&(g=yd(this.doc,g,e,c,d),!g.hitSide);++f);return g},moveH:ec(function(a,b){var c=this;c.extendSelectionsBy(function(d){return c.display.shift||c.doc.extend||d.empty()?yd(c.doc,d.head,a,b,c.options.rtlMoveVisually):0>a?d.from():d.to()},Zf)}),deleteH:ec(function(a,b){var c=this.doc.sel,d=this.doc;c.somethingSelected()?d.replaceSelection("",null,"+delete"):xd(this,function(c){var e=yd(d,c.head,a,b,!1);return 0>a?{from:e,to:c.head}:{from:c.head,to:e}})}),findPosV:function(a,b,c,d){var e=1,f=d;0>b&&(e=-1,b=-b);for(var g=0,h=Oa(this.doc,a);b>g;++g){var i=Lb(this,h,"div");if(null==f?f=i.left:i.left=f,h=zd(this,i,e,c),h.hitSide)break}return h},moveV:ec(function(a,b){var c=this,d=this.doc,e=[],f=!c.display.shift&&!d.extend&&d.sel.somethingSelected();if(d.extendSelectionsBy(function(g){if(f)return 0>a?g.from():g.to();var h=Lb(c,g.head,"div");null!=g.goalColumn&&(h.left=g.goalColumn),e.push(h.left);var i=zd(c,h,a,b);return"page"==b&&g==d.sel.primary()&&sd(c,null,Kb(c,i,"div").top-h.top),i},Zf),e.length)for(var g=0;g<d.sel.ranges.length;g++)d.sel.ranges[g].goalColumn=e[g]}),findWordAt:function(a){var b=this.doc,c=ff(b,a.line).text,d=a.ch,e=a.ch;if(c){var f=this.getHelper(a,"wordChars");(a.xRel<0||e==c.length)&&d?--d:++e;for(var g=c.charAt(d),h=ng(g,f)?function(a){return ng(a,f)}:/\s/.test(g)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!ng(a)};d>0&&h(c.charAt(d-1));)--d;for(;e<c.length&&h(c.charAt(e));)++e}return new Ka(oa(a.line,d),oa(a.line,e))},toggleOverwrite:function(a){(null==a||a!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?zg(this.display.cursorDiv,"CodeMirror-overwrite"):yg(this.display.cursorDiv,"CodeMirror-overwrite"),Nf(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==wg()},scrollTo:ec(function(a,b){(null!=a||null!=b)&&ud(this),null!=a&&(this.curOp.scrollLeft=a),null!=b&&(this.curOp.scrollTop=b)}),getScrollInfo:function(){var a=this.display.scroller;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-pb(this)-this.display.barHeight,width:a.scrollWidth-pb(this)-this.display.barWidth,clientHeight:rb(this),clientWidth:qb(this)}},scrollIntoView:ec(function(a,b){if(null==a?(a={from:this.doc.sel.primary().head,to:null},null==b&&(b=this.options.cursorScrollMargin)):"number"==typeof a?a={from:oa(a,0),to:null}:null==a.from&&(a={from:a,to:null}),a.to||(a.to=a.from),a.margin=b||0,null!=a.from.line)ud(this),this.curOp.scrollToPos=a;else{var c=rd(this,Math.min(a.from.left,a.to.left),Math.min(a.from.top,a.to.top)-a.margin,Math.max(a.from.right,a.to.right),Math.max(a.from.bottom,a.to.bottom)+a.margin);this.scrollTo(c.scrollLeft,c.scrollTop)}}),setSize:ec(function(a,b){function d(a){return"number"==typeof a||/^\d+$/.test(String(a))?a+"px":a}var c=this;null!=a&&(c.display.wrapper.style.width=d(a)),null!=b&&(c.display.wrapper.style.height=d(b)),c.options.lineWrapping&&Eb(this);var e=c.display.viewFrom;c.doc.iter(e,c.display.viewTo,function(a){if(a.widgets)for(var b=0;b<a.widgets.length;b++)if(a.widgets[b].noHScroll){jc(c,e,"widget");break}++e}),c.curOp.forceUpdate=!0,Nf(c,"refresh",this)}),operation:function(a){return cc(this,a)},refresh:ec(function(){var a=this.display.cachedTextHeight;ic(this),this.curOp.forceUpdate=!0,Fb(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),F(this),(null==a||Math.abs(a-Rb(this.display))>.5)&&B(this),Nf(this,"refresh",this)}),swapDoc:ec(function(a){var b=this.doc;return b.cm=null,ef(this,a),Fb(this),this.display.input.reset(),this.scrollTo(a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,Pf(this,"swapDoc",this,b),b}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Uf(v);var Ad=v.defaults={},Bd=v.optionHandlers={},Dd=v.Init={toString:function(){return"CodeMirror.Init"}};Cd("value","",function(a,b){a.setValue(b)},!0),Cd("mode",null,function(a,b){a.doc.modeOption=b,x(a)},!0),Cd("indentUnit",2,x,!0),Cd("indentWithTabs",!1),Cd("smartIndent",!0),Cd("tabSize",4,function(a){y(a),Fb(a),ic(a)},!0),Cd("lineSeparator",null,function(a,b){if(a.doc.lineSep=b,b){var c=[],d=a.doc.first;a.doc.iter(function(a){for(var e=0;;){var f=a.text.indexOf(b,e);if(-1==f)break;e=f+b.length,c.push(oa(d,f))}d++});for(var e=c.length-1;e>=0;e--)nd(a.doc,b,c[e],oa(c[e].line,c[e].ch+b.length))}}),Cd("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(a,b,c){a.state.specialChars=new RegExp(b.source+(b.test(" ")?"":"| "),"g"),c!=v.Init&&a.refresh()}),Cd("specialCharPlaceholder",Re,function(a){a.refresh()},!0),Cd("electricChars",!0),Cd("inputStyle",n?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Cd("rtlMoveVisually",!p),Cd("wholeLineUpdateBefore",!0),Cd("theme","default",function(a){C(a),D(a)},!0),Cd("keyMap","default",function(a,b,c){var d=Rd(b),e=c!=v.Init&&Rd(c);e&&e.detach&&e.detach(a,d),d.attach&&d.attach(a,e||null)}),Cd("extraKeys",null),Cd("lineWrapping",!1,z,!0),Cd("gutters",[],function(a){I(a.options),D(a)},!0),Cd("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?T(a.display)+"px":"0",a.refresh()},!0),Cd("coverGutterNextToScrollbar",!1,function(a){N(a)},!0),Cd("scrollbarStyle","native",function(a){M(a),N(a),a.display.scrollbars.setScrollTop(a.doc.scrollTop),a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0),Cd("lineNumbers",!1,function(a){I(a.options),D(a)},!0),Cd("firstLineNumber",1,D,!0),Cd("lineNumberFormatter",function(a){return a},D,!0),Cd("showCursorWhenSelecting",!1,db,!0),Cd("resetSelectionOnContextMenu",!0),Cd("lineWiseCopyCut",!0),Cd("readOnly",!1,function(a,b){"nocursor"==b?($c(a),a.display.input.blur(),a.display.disabled=!0):a.display.disabled=!1,a.display.input.readOnlyChanged(b)}),Cd("disableInput",!1,function(a,b){b||a.display.input.reset()},!0),Cd("dragDrop",!0,qc),Cd("cursorBlinkRate",530),Cd("cursorScrollMargin",0),Cd("cursorHeight",1,db,!0),Cd("singleCursorHeightPerLine",!0,db,!0),Cd("workTime",100),Cd("workDelay",100),Cd("flattenSpans",!0,y,!0),Cd("addModeClass",!1,y,!0),Cd("pollInterval",100),Cd("undoDepth",200,function(a,b){a.doc.history.undoDepth=b}),Cd("historyEventDelay",1250),Cd("viewportMargin",10,function(a){a.refresh()},!0),Cd("maxHighlightLength",1e4,y,!0),Cd("moveInputWithCursor",!0,function(a,b){b||a.display.input.resetPosition()}),Cd("tabindex",null,function(a,b){a.display.input.getField().tabIndex=b||""}),Cd("autofocus",null);var Ed=v.modes={},Fd=v.mimeModes={};v.defineMode=function(a,b){v.defaults.mode||"null"==a||(v.defaults.mode=a),arguments.length>2&&(b.dependencies=Array.prototype.slice.call(arguments,2)),Ed[a]=b},v.defineMIME=function(a,b){Fd[a]=b},v.resolveMode=function(a){if("string"==typeof a&&Fd.hasOwnProperty(a))a=Fd[a];else if(a&&"string"==typeof a.name&&Fd.hasOwnProperty(a.name)){var b=Fd[a.name];"string"==typeof b&&(b={name:b}),a=ig(b,a),a.name=b.name}else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return v.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}},v.getMode=function(a,b){var b=v.resolveMode(b),c=Ed[b.name];if(!c)return v.getMode(a,"text/plain");var d=c(a,b);if(Gd.hasOwnProperty(b.name)){var e=Gd[b.name];for(var f in e)e.hasOwnProperty(f)&&(d.hasOwnProperty(f)&&(d["_"+f]=d[f]),d[f]=e[f])}if(d.name=b.name,b.helperType&&(d.helperType=b.helperType),b.modeProps)for(var f in b.modeProps)d[f]=b.modeProps[f];return d},v.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),v.defineMIME("text/plain","null");var Gd=v.modeExtensions={};v.extendMode=function(a,b){var c=Gd.hasOwnProperty(a)?Gd[a]:Gd[a]={};jg(b,c)},v.defineExtension=function(a,b){v.prototype[a]=b},v.defineDocExtension=function(a,b){af.prototype[a]=b},v.defineOption=Cd;var Hd=[];v.defineInitHook=function(a){Hd.push(a)};var Id=v.helpers={};v.registerHelper=function(a,b,c){Id.hasOwnProperty(a)||(Id[a]=v[a]={_global:[]}),Id[a][b]=c},v.registerGlobalHelper=function(a,b,c,d){v.registerHelper(a,b,d),Id[a]._global.push({pred:c,val:d})};var Jd=v.copyState=function(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c},Kd=v.startState=function(a,b,c){return a.startState?a.startState(b,c):!0};v.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);if(!c||c.mode==a)break;b=c.state,a=c.mode}return c||{mode:a,state:b}};var Ld=v.commands={selectAll:function(a){a.setSelection(oa(a.firstLine(),0),oa(a.lastLine()),Xf)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),Xf)},killLine:function(a){xd(a,function(b){if(b.empty()){var c=ff(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line<a.lastLine()?{from:b.head,to:oa(b.head.line+1,0)}:{from:b.head,to:oa(b.head.line,c)}}return{from:b.from(),to:b.to()}})},deleteLine:function(a){xd(a,function(b){return{from:oa(b.from().line,0),to:Oa(a.doc,oa(b.to().line+1,0))}})},delLineLeft:function(a){xd(a,function(a){return{from:oa(a.from().line,0),to:a.from()}})},delWrappedLineLeft:function(a){xd(a,function(b){var c=a.charCoords(b.head,"div").top+5,d=a.coordsChar({left:0,top:c},"div");return{from:d,to:b.from()}})},delWrappedLineRight:function(a){xd(a,function(b){var c=a.charCoords(b.head,"div").top+5,d=a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:c},"div");return{from:b.from(),to:d}})},undo:function(a){a.undo()},redo:function(a){a.redo()},undoSelection:function(a){a.undoSelection()},redoSelection:function(a){a.redoSelection()},goDocStart:function(a){a.extendSelection(oa(a.firstLine(),0))},goDocEnd:function(a){a.extendSelection(oa(a.lastLine()))},goLineStart:function(a){a.extendSelectionsBy(function(b){return Vg(a,b.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(a){a.extendSelectionsBy(function(b){return Xg(a,b.head)},{origin:"+move",bias:1})},goLineEnd:function(a){a.extendSelectionsBy(function(b){return Wg(a,b.head.line)},{origin:"+move",bias:-1})},goLineRight:function(a){a.extendSelectionsBy(function(b){var c=a.charCoords(b.head,"div").top+5;return a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:c},"div")},Zf)},goLineLeft:function(a){a.extendSelectionsBy(function(b){var c=a.charCoords(b.head,"div").top+5;return a.coordsChar({left:0,top:c},"div")},Zf)},goLineLeftSmart:function(a){a.extendSelectionsBy(function(b){var c=a.charCoords(b.head,"div").top+5,d=a.coordsChar({left:0,top:c},"div");return d.ch<a.getLine(d.line).search(/\S/)?Xg(a,b.head):d},Zf)},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,"char")},goCharRight:function(a){a.moveH(1,"char")},goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goGroupRight:function(a){a.moveH(1,"group")},goGroupLeft:function(a){a.moveH(-1,"group")},goWordRight:function(a){a.moveH(1,"word")},delCharBefore:function(a){a.deleteH(-1,"char")},delCharAfter:function(a){a.deleteH(1,"char")},delWordBefore:function(a){a.deleteH(-1,"word")},delWordAfter:function(a){a.deleteH(1,"word")},delGroupBefore:function(a){a.deleteH(-1,"group")},delGroupAfter:function(a){a.deleteH(1,"group")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},insertTab:function(a){a.replaceSelection(" ")},insertSoftTab:function(a){for(var b=[],c=a.listSelections(),d=a.options.tabSize,e=0;e<c.length;e++){var f=c[e].from(),g=_f(a.getLine(f.line),f.ch,d);b.push(new Array(d-g%d+1).join(" "))}a.replaceSelections(b)},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.execCommand("insertTab")},transposeChars:function(a){cc(a,function(){for(var b=a.listSelections(),c=[],d=0;d<b.length;d++){var e=b[d].head,f=ff(a.doc,e.line).text;if(f)if(e.ch==f.length&&(e=new oa(e.line,e.ch-1)),e.ch>0)e=new oa(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),oa(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var g=ff(a.doc,e.line-1).text;g&&a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+g.charAt(g.length-1),oa(e.line-1,g.length-1),oa(e.line,1),"+transpose")}c.push(new Ka(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){cc(a,function(){for(var b=a.listSelections().length,c=0;b>c;c++){var d=a.listSelections()[c];a.replaceRange(a.doc.lineSeparator(),d.anchor,d.head,"+input"),a.indentLine(d.from().line+1,null,!0),td(a)}})},toggleOverwrite:function(a){a.toggleOverwrite()}},Md=v.keyMap={};Md.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Md.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Md.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},Md.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext",
|
20 |
-
"Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Md["default"]=o?Md.macDefault:Md.pcDefault,v.normalizeKeyMap=function(a){var b={};for(var c in a)if(a.hasOwnProperty(c)){var d=a[c];if(/^(name|fallthrough|(de|at)tach)$/.test(c))continue;if("..."==d){delete a[c];continue}for(var e=gg(c.split(" "),Nd),f=0;f<e.length;f++){var g,h;f==e.length-1?(h=e.join(" "),g=d):(h=e.slice(0,f+1).join(" "),g="...");var i=b[h];if(i){if(i!=g)throw new Error("Inconsistent bindings for "+h)}else b[h]=g}delete a[c]}for(var j in b)a[j]=b[j];return a};var Od=v.lookupKey=function(a,b,c,d){b=Rd(b);var e=b.call?b.call(a,d):b[a];if(e===!1)return"nothing";if("..."===e)return"multi";if(null!=e&&c(e))return"handled";if(b.fallthrough){if("[object Array]"!=Object.prototype.toString.call(b.fallthrough))return Od(a,b.fallthrough,c,d);for(var f=0;f<b.fallthrough.length;f++){var g=Od(a,b.fallthrough[f],c,d);if(g)return g}}},Pd=v.isModifierKey=function(a){var b="string"==typeof a?a:Pg[a.keyCode];return"Ctrl"==b||"Alt"==b||"Shift"==b||"Mod"==b},Qd=v.keyName=function(a,b){if(i&&34==a.keyCode&&a["char"])return!1;var c=Pg[a.keyCode],d=c;return null==d||a.altGraphKey?!1:(a.altKey&&"Alt"!=c&&(d="Alt-"+d),(r?a.metaKey:a.ctrlKey)&&"Ctrl"!=c&&(d="Ctrl-"+d),(r?a.ctrlKey:a.metaKey)&&"Cmd"!=c&&(d="Cmd-"+d),!b&&a.shiftKey&&"Shift"!=c&&(d="Shift-"+d),d)};v.fromTextArea=function(a,b){function d(){a.value=i.getValue()}if(b=b?jg(b):{},b.value=a.value,!b.tabindex&&a.tabIndex&&(b.tabindex=a.tabIndex),!b.placeholder&&a.placeholder&&(b.placeholder=a.placeholder),null==b.autofocus){var c=wg();b.autofocus=c==a||null!=a.getAttribute("autofocus")&&c==document.body}if(a.form&&(Jf(a.form,"submit",d),!b.leaveSubmitMethodAlone)){var e=a.form,f=e.submit;try{var g=e.submit=function(){d(),e.submit=f,e.submit(),e.submit=g}}catch(h){}}b.finishInit=function(b){b.save=d,b.getTextArea=function(){return a},b.toTextArea=function(){b.toTextArea=isNaN,d(),a.parentNode.removeChild(b.getWrapperElement()),a.style.display="",a.form&&(Mf(a.form,"submit",d),"function"==typeof a.form.submit&&(a.form.submit=f))}},a.style.display="none";var i=v(function(b){a.parentNode.insertBefore(b,a.nextSibling)},b);return i};var Sd=v.StringStream=function(a,b){this.pos=this.start=0,this.string=a,this.tabSize=b||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};Sd.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(a){var b=this.string.charAt(this.pos);if("string"==typeof a)var c=b==a;else var c=b&&(a.test?a.test(b):a(b));return c?(++this.pos,b):void 0},eatWhile:function(a){for(var b=this.pos;this.eat(a););return this.pos>b},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);return b>-1?(this.pos=b,!0):void 0},backUp:function(a){this.pos-=a},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=_f(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?_f(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return _f(this.string,null,this.tabSize)-(this.lineStart?_f(this.string,this.lineStart,this.tabSize):0)},match:function(a,b,c){if("string"!=typeof a){var f=this.string.slice(this.pos).match(a);return f&&f.index>0?null:(f&&b!==!1&&(this.pos+=f[0].length),f)}var d=function(a){return c?a.toLowerCase():a},e=this.string.substr(this.pos,a.length);return d(e)==d(a)?(b!==!1&&(this.pos+=a.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}}};var Td=0,Ud=v.TextMarker=function(a,b){this.lines=[],this.type=b,this.doc=a,this.id=++Td};Uf(Ud),Ud.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;if(b&&Vb(a),Tf(this,"clear")){var c=this.find();c&&Pf(this,"clear",c.from,c.to)}for(var d=null,e=null,f=0;f<this.lines.length;++f){var g=this.lines[f],h=ae(g.markedSpans,this);a&&!this.collapsed?jc(a,kf(g),"text"):a&&(null!=h.to&&(e=kf(g)),null!=h.from&&(d=kf(g))),g.markedSpans=be(g.markedSpans,h),null==h.from&&this.collapsed&&!we(this.doc,g)&&a&&jf(g,Rb(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(var f=0;f<this.lines.length;++f){var i=se(this.lines[f]),j=G(i);j>a.display.maxLineLength&&(a.display.maxLine=i,a.display.maxLineLength=j,a.display.maxLineChanged=!0)}null!=d&&a&&this.collapsed&&ic(a,d,e+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&ab(a.doc)),a&&Pf(a,"markerCleared",a,this),b&&Xb(a),this.parent&&this.parent.clear()}},Ud.prototype.find=function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;e<this.lines.length;++e){var f=this.lines[e],g=ae(f.markedSpans,this);if(null!=g.from&&(c=oa(b?f:kf(f),g.from),-1==a))return c;if(null!=g.to&&(d=oa(b?f:kf(f),g.to),1==a))return d}return c&&{from:c,to:d}},Ud.prototype.changed=function(){var a=this.find(-1,!0),b=this,c=this.doc.cm;a&&c&&cc(c,function(){var d=a.line,e=kf(a.line),f=wb(c,e);if(f&&(Db(f),c.curOp.selectionChanged=c.curOp.forceUpdate=!0),c.curOp.updateMaxLine=!0,!we(b.doc,d)&&null!=b.height){var g=b.height;b.height=null;var h=Ae(b)-g;h&&jf(d,d.height+h)}})},Ud.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;b.maybeHiddenMarkers&&-1!=fg(b.maybeHiddenMarkers,this)||(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)},Ud.prototype.detachLine=function(a){if(this.lines.splice(fg(this.lines,a),1),!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;(b.maybeHiddenMarkers||(b.maybeHiddenMarkers=[])).push(this)}};var Td=0,Wd=v.SharedTextMarker=function(a,b){this.markers=a,this.primary=b;for(var c=0;c<a.length;++c)a[c].parent=this};Uf(Wd),Wd.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();Pf(this,"clear")}},Wd.prototype.find=function(a,b){return this.primary.find(a,b)};var ye=v.LineWidget=function(a,b,c){if(c)for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.doc=a,this.node=b};Uf(ye),ye.prototype.clear=function(){var a=this.doc.cm,b=this.line.widgets,c=this.line,d=kf(c);if(null!=d&&b){for(var e=0;e<b.length;++e)b[e]==this&&b.splice(e--,1);b.length||(c.widgets=null);var f=Ae(this);jf(c,Math.max(0,c.height-f)),a&&cc(a,function(){ze(a,c,-f),jc(a,d,"widget")})}},ye.prototype.changed=function(){var a=this.height,b=this.doc.cm,c=this.line;this.height=null;var d=Ae(this)-a;d&&(jf(c,c.height+d),b&&cc(b,function(){b.curOp.forceUpdate=!0,ze(b,c,d)}))};var Ce=v.Line=function(a,b,c){this.text=a,ke(this,b),this.height=c?c(this):1};Uf(Ce),Ce.prototype.lineNo=function(){return kf(this)};var Ne={},Oe={};Ze.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=a,d=a+b;d>c;++c){var e=this.lines[c];this.height-=e.height,Ee(e),Pf(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0;d<b.length;++d)b[d].parent=this},iterN:function(a,b,c){for(var d=a+b;d>a;++a)if(c(this.lines[a]))return!0}},$e.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;c<this.children.length;++c){var d=this.children[c],e=d.chunkSize();if(e>a){var f=Math.min(b,e-a),g=d.height;if(d.removeInner(a,f),this.height-=g-d.height,e==f&&(this.children.splice(c--,1),d.parent=null),0==(b-=f))break;a=0}else a-=e}if(this.size-b<25&&(this.children.length>1||!(this.children[0]instanceof Ze))){var h=[];this.collapse(h),this.children=[new Ze(h)],this.children[0].parent=this}},collapse:function(a){for(var b=0;b<this.children.length;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size+=b.length,this.height+=c;for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(f>=a){if(e.insertInner(a,b,c),e.lines&&e.lines.length>50){for(;e.lines.length>50;){var g=e.lines.splice(e.lines.length-25,25),h=new Ze(g);e.height-=h.height,this.children.splice(d+1,0,h),h.parent=this}this.maybeSpill()}break}a-=f}},maybeSpill:function(){if(!(this.children.length<=10)){var a=this;do{var b=a.children.splice(a.children.length-5,5),c=new $e(b);if(a.parent){a.size-=c.size,a.height-=c.height;var e=fg(a.parent.children,a);a.parent.children.splice(e+1,0,c)}else{var d=new $e(a.children);d.parent=a,a.children=[d,c],a=d}c.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(f>a){var g=Math.min(b,f-a);if(e.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=f}}};var _e=0,af=v.Doc=function(a,b,c,d){if(!(this instanceof af))return new af(a,b,c,d);null==c&&(c=0),$e.call(this,[new Ze([new Ce("",null)])]),this.first=c,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=c;var e=oa(c,0);this.sel=Ma(e),this.history=new of(null),this.id=++_e,this.modeOption=b,this.lineSep=d,"string"==typeof a&&(a=this.splitLines(a)),Ye(this,{from:e,to:e,text:a}),Za(this,Ma(e),Xf)};af.prototype=ig($e.prototype,{constructor:af,iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0;d<b.length;++d)c+=b[d].height;this.insertInner(a-this.first,b,c)},remove:function(a,b){this.removeInner(a-this.first,b)},getValue:function(a){var b=hf(this,this.first,this.first+this.size);return a===!1?b:b.join(a||this.lineSeparator())},setValue:fc(function(a){var b=oa(this.first,0),c=this.first+this.size-1;hd(this,{from:b,to:oa(c,ff(this,c).text.length),text:this.splitLines(a),origin:"setValue",full:!0},!0),Za(this,Ma(b))}),replaceRange:function(a,b,c,d){b=Oa(this,b),c=c?Oa(this,c):b,nd(this,a,b,c,d)},getRange:function(a,b,c){var d=gf(this,Oa(this,a),Oa(this,b));return c===!1?d:d.join(c||this.lineSeparator())},getLine:function(a){var b=this.getLineHandle(a);return b&&b.text},getLineHandle:function(a){return Qa(this,a)?ff(this,a):void 0},getLineNumber:function(a){return kf(a)},getLineHandleVisualStart:function(a){return"number"==typeof a&&(a=ff(this,a)),se(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(a){return Oa(this,a)},getCursor:function(a){var c,b=this.sel.primary();return c=null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||"to"==a||a===!1?b.to():b.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:fc(function(a,b,c){Wa(this,Oa(this,"number"==typeof a?oa(a,b||0):a),null,c)}),setSelection:fc(function(a,b,c){Wa(this,Oa(this,a),Oa(this,b||a),c)}),extendSelection:fc(function(a,b,c){Ta(this,Oa(this,a),b&&Oa(this,b),c)}),extendSelections:fc(function(a,b){Ua(this,Ra(this,a,b))}),extendSelectionsBy:fc(function(a,b){Ua(this,gg(this.sel.ranges,a),b)}),setSelections:fc(function(a,b,c){if(a.length){for(var d=0,e=[];d<a.length;d++)e[d]=new Ka(Oa(this,a[d].anchor),Oa(this,a[d].head));null==b&&(b=Math.min(a.length-1,this.sel.primIndex)),Za(this,La(e,b),c)}}),addSelection:fc(function(a,b,c){var d=this.sel.ranges.slice(0);d.push(new Ka(Oa(this,a),Oa(this,b||a))),Za(this,La(d,d.length-1),c)}),getSelection:function(a){for(var c,b=this.sel.ranges,d=0;d<b.length;d++){var e=gf(this,b[d].from(),b[d].to());c=c?c.concat(e):e}return a===!1?c:c.join(a||this.lineSeparator())},getSelections:function(a){for(var b=[],c=this.sel.ranges,d=0;d<c.length;d++){var e=gf(this,c[d].from(),c[d].to());a!==!1&&(e=e.join(a||this.lineSeparator())),b[d]=e}return b},replaceSelection:function(a,b,c){for(var d=[],e=0;e<this.sel.ranges.length;e++)d[e]=a;this.replaceSelections(d,b,c||"+input")},replaceSelections:fc(function(a,b,c){for(var d=[],e=this.sel,f=0;f<e.ranges.length;f++){var g=e.ranges[f];d[f]={from:g.from(),to:g.to(),text:this.splitLines(a[f]),origin:c}}for(var h=b&&"end"!=b&&fd(this,d,b),f=d.length-1;f>=0;f--)hd(this,d[f]);h?Ya(this,h):this.cm&&td(this.cm)}),undo:fc(function(){jd(this,"undo")}),redo:fc(function(){jd(this,"redo")}),undoSelection:fc(function(){jd(this,"undo",!0)}),redoSelection:fc(function(){jd(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d<a.done.length;d++)a.done[d].ranges||++b;for(var d=0;d<a.undone.length;d++)a.undone[d].ranges||++c;return{undo:b,redo:c}},clearHistory:function(){this.history=new of(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(a){return a&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(a){return this.history.generation==(a||this.cleanGeneration)},getHistory:function(){return{done:zf(this.history.done),undone:zf(this.history.undone)}},setHistory:function(a){var b=this.history=new of(this.history.maxGeneration);b.done=zf(a.done.slice(0),null,!0),b.undone=zf(a.undone.slice(0),null,!0)},addLineClass:fc(function(a,b,c){return wd(this,a,"gutter"==b?"gutter":"class",function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass";if(a[d]){if(xg(c).test(a[d]))return!1;a[d]+=" "+c}else a[d]=c;return!0})}),removeLineClass:fc(function(a,b,c){return wd(this,a,"gutter"==b?"gutter":"class",function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass",e=a[d];if(!e)return!1;if(null==c)a[d]=null;else{var f=e.match(xg(c));if(!f)return!1;var g=f.index+f[0].length;a[d]=e.slice(0,f.index)+(f.index&&g!=e.length?" ":"")+e.slice(g)||null}return!0})}),addLineWidget:fc(function(a,b,c){return Be(this,a,b,c)}),removeLineWidget:function(a){a.clear()},markText:function(a,b,c){return Vd(this,Oa(this,a),Oa(this,b),c,"range")},setBookmark:function(a,b){var c={replacedWith:b&&(null==b.nodeType?b.widget:b),insertLeft:b&&b.insertLeft,clearWhenEmpty:!1,shared:b&&b.shared,handleMouseEvents:b&&b.handleMouseEvents};return a=Oa(this,a),Vd(this,a,a,c,"bookmark")},findMarksAt:function(a){a=Oa(this,a);var b=[],c=ff(this,a.line).markedSpans;if(c)for(var d=0;d<c.length;++d){var e=c[d];(null==e.from||e.from<=a.ch)&&(null==e.to||e.to>=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=Oa(this,a),b=Oa(this,b);var d=[],e=a.line;return this.iter(a.line,b.line+1,function(f){var g=f.markedSpans;if(g)for(var h=0;h<g.length;h++){var i=g[h];e==a.line&&a.ch>i.to||null==i.from&&e!=a.line||e==b.line&&i.from>b.ch||c&&!c(i.marker)||d.push(i.marker.parent||i.marker)}++e}),d},getAllMarks:function(){var a=[];return this.iter(function(b){var c=b.markedSpans;if(c)for(var d=0;d<c.length;++d)null!=c[d].from&&a.push(c[d].marker)}),a},posFromIndex:function(a){var b,c=this.first;return this.iter(function(d){var e=d.text.length+1;return e>a?(b=a,!0):(a-=e,void++c)}),Oa(this,oa(c,b))},indexFromPos:function(a){a=Oa(this,a);var b=a.ch;return a.line<this.first||a.ch<0?0:(this.iter(this.first,a.line,function(a){b+=a.text.length+1}),b)},copy:function(a){var b=new af(hf(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);return b.scrollTop=this.scrollTop,b.scrollLeft=this.scrollLeft,b.sel=this.sel,b.extend=!1,a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory())),b},linkedDoc:function(a){a||(a={});var b=this.first,c=this.first+this.size;null!=a.from&&a.from>b&&(b=a.from),null!=a.to&&a.to<c&&(c=a.to);var d=new af(hf(this,b,c),a.mode||this.modeOption,b,this.lineSep);return a.sharedHist&&(d.history=this.history),(this.linked||(this.linked=[])).push({doc:d,sharedHist:a.sharedHist}),d.linked=[{doc:this,isParent:!0,sharedHist:a.sharedHist}],Zd(d,Yd(this)),d},unlinkDoc:function(a){if(a instanceof v&&(a=a.doc),this.linked)for(var b=0;b<this.linked.length;++b){var c=this.linked[b];if(c.doc==a){this.linked.splice(b,1),a.unlinkDoc(this),$d(Yd(this));break}}if(a.history==this.history){var d=[a.id];df(a,function(a){d.push(a.id)},!0),a.history=new of(null),a.history.done=zf(this.history.done,d),a.history.undone=zf(this.history.undone,d)}},iterLinkedDocs:function(a){df(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(a){return this.lineSep?a.split(this.lineSep):Kg(a)},lineSeparator:function(){return this.lineSep||"\n"}}),af.prototype.eachLine=af.prototype.iter;var bf="iter insert remove copy getEditor constructor".split(" ");for(var cf in af.prototype)af.prototype.hasOwnProperty(cf)&&fg(bf,cf)<0&&(v.prototype[cf]=function(a){return function(){return a.apply(this.doc,arguments)}}(af.prototype[cf]));Uf(af);var Df=v.e_preventDefault=function(a){a.preventDefault?a.preventDefault():a.returnValue=!1},Ef=v.e_stopPropagation=function(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0},Gf=v.e_stop=function(a){Df(a),Ef(a)},Jf=v.on=function(a,b,c){if(a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent)a.attachEvent("on"+b,c);else{var d=a._handlers||(a._handlers={}),e=d[b]||(d[b]=[]);e.push(c)}},Kf=[],Mf=v.off=function(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else for(var d=Lf(a,b,!1),e=0;e<d.length;++e)if(d[e]==c){d.splice(e,1);break}},Nf=v.signal=function(a,b){var c=Lf(a,b,!0);if(c.length)for(var d=Array.prototype.slice.call(arguments,2),e=0;e<c.length;++e)c[e].apply(null,d)},Of=null,Vf=30,Wf=v.Pass={toString:function(){return"CodeMirror.Pass"}},Xf={scroll:!1},Yf={origin:"*mouse"},Zf={origin:"+move"};$f.prototype.set=function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)};var _f=v.countColumn=function(a,b,c,d,e){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));for(var f=d||0,g=e||0;;){var h=a.indexOf(" ",f);if(0>h||h>=b)return g+(b-f);g+=h-f,g+=c-g%c,f=h+1}},ag=v.findColumn=function(a,b,c){for(var d=0,e=0;;){var f=a.indexOf(" ",d);-1==f&&(f=a.length);var g=f-d;if(f==a.length||e+g>=b)return d+Math.min(g,b-e);if(e+=f-d,e+=c-e%c,d=f+1,e>=b)return d}},bg=[""],eg=function(a){a.select()};m?eg=function(a){a.selectionStart=0,a.selectionEnd=a.value.length}:d&&(eg=function(a){try{a.select()}catch(b){}});var sg,lg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,mg=v.isWordChar=function(a){return/\w/.test(a)||a>"\x80"&&(a.toUpperCase()!=a.toLowerCase()||lg.test(a))},pg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;sg=document.createRange?function(a,b,c,d){var e=document.createRange();return e.setEnd(d||a,c),e.setStart(a,b),e}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(e){return d}return d.collapse(!0),d.moveEnd("character",c),d.moveStart("character",b),d};var vg=v.contains=function(a,b){if(3==b.nodeType&&(b=b.parentNode),a.contains)return a.contains(b);do if(11==b.nodeType&&(b=b.host),b==a)return!0;while(b=b.parentNode)};d&&11>e&&(wg=function(){try{return document.activeElement}catch(a){return document.body}});var Gg,Ig,yg=v.rmClass=function(a,b){var c=a.className,d=xg(b).exec(c);if(d){var e=c.slice(d.index+d[0].length);a.className=c.slice(0,d.index)+(e?d[1]+e:"")}},zg=v.addClass=function(a,b){var c=a.className;xg(b).test(c)||(a.className+=(c?" ":"")+b)},Cg=!1,Fg=function(){if(d&&9>e)return!1;var a=rg("div");return"draggable"in a||"dragDrop"in a}(),Kg=v.splitLines=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)},Lg=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},Mg=function(){var a=rg("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),Ng=null,Pg=v.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var a=0;10>a;a++)Pg[a+48]=Pg[a+96]=String(a);for(var a=65;90>=a;a++)Pg[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)Pg[a+111]=Pg[a+63235]="F"+a}();var Zg,ch=function(){function c(c){return 247>=c?a.charAt(c):c>=1424&&1524>=c?"R":c>=1536&&1773>=c?b.charAt(c-1536):c>=1774&&2220>=c?"r":c>=8192&&8203>=c?"w":8204==c?"b":"L"}function j(a,b,c){this.level=a,this.from=b,this.to=c}var a="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",b="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/,i="L";return function(a){if(!d.test(a))return!1;for(var m,b=a.length,k=[],l=0;b>l;++l)k.push(m=c(a.charCodeAt(l)));for(var l=0,n=i;b>l;++l){var m=k[l];"m"==m?k[l]=n:n=m}for(var l=0,o=i;b>l;++l){var m=k[l];"1"==m&&"r"==o?k[l]="n":f.test(m)&&(o=m,"r"==m&&(k[l]="R"))}for(var l=1,n=k[0];b-1>l;++l){var m=k[l];"+"==m&&"1"==n&&"1"==k[l+1]?k[l]="1":","!=m||n!=k[l+1]||"1"!=n&&"n"!=n||(k[l]=n),n=m}for(var l=0;b>l;++l){var m=k[l];if(","==m)k[l]="N";else if("%"==m){for(var p=l+1;b>p&&"%"==k[p];++p);for(var q=l&&"!"==k[l-1]||b>p&&"1"==k[p]?"1":"N",r=l;p>r;++r)k[r]=q;l=p-1}}for(var l=0,o=i;b>l;++l){var m=k[l];"L"==o&&"1"==m?k[l]="L":f.test(m)&&(o=m)}for(var l=0;b>l;++l)if(e.test(k[l])){for(var p=l+1;b>p&&e.test(k[p]);++p);for(var s="L"==(l?k[l-1]:i),t="L"==(b>p?k[p]:i),q=s||t?"L":"R",r=l;p>r;++r)k[r]=q;l=p-1}for(var v,u=[],l=0;b>l;)if(g.test(k[l])){var w=l;for(++l;b>l&&g.test(k[l]);++l);u.push(new j(0,w,l))}else{var x=l,y=u.length;for(++l;b>l&&"L"!=k[l];++l);for(var r=x;l>r;)if(h.test(k[r])){r>x&&u.splice(y,0,new j(1,x,r));var z=r;for(++r;l>r&&h.test(k[r]);++r);u.splice(y,0,new j(2,z,r)),x=r}else++r;l>x&&u.splice(y,0,new j(1,x,l))}return 1==u[0].level&&(v=a.match(/^\s+/))&&(u[0].from=v[0].length,u.unshift(new j(0,0,v[0].length))),1==dg(u).level&&(v=a.match(/\s+$/))&&(dg(u).to-=v[0].length,u.push(new j(0,b-v[0].length,b))),2==u[0].level&&u.unshift(new j(1,u[0].to,u[0].to)),u[0].level!=dg(u).level&&u.push(new j(u[0].level,b,b)),u}}();return v.version="5.7.1",v}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){for(var b={},c=a.split(" "),d=0;d<c.length;++d)b[c[d]]=!0;return b}function e(a,b){if(!b.startOfLine)return!1;for(;;){if(!a.skipTo("\\")){a.skipToEnd(),b.tokenize=null;break}if(a.next(),a.eol()){b.tokenize=e;break}}return"meta"}function f(a,b){return"variable-3"==b.prevToken?"variable-3":!1}function g(a){return a.eatWhile(/[\w\.']/),"number"}function h(a,b){if(a.backUp(1),a.match(/(R|u8R|uR|UR|LR)/)){var c=a.match(/"([^\s\\()]{0,16})\(/);return c?(b.cpp11RawStringDelim=c[1],b.tokenize=k,k(a,b)):!1}return a.match(/(u8|u|U|L)/)?a.match(/["']/,!1)?"string":!1:(a.next(),!1)}function i(a){var b=/(\w+)::(\w+)$/.exec(a);return b&&b[1]==b[2]}function j(a,b){for(var c;null!=(c=a.next());)if('"'==c&&!a.eat('"')){b.tokenize=null;break}return"string"}function k(a,b){var c=b.cpp11RawStringDelim.replace(/[^\w\s]/g,"\\$&"),d=a.match(new RegExp(".*?\\)"+c+'"'));return d?b.tokenize=null:a.skipToEnd(),"string"}function l(b,c){function e(a){if(a)for(var b in a)a.hasOwnProperty(b)&&d.push(b)}"string"==typeof b&&(b=[b]);var d=[];e(c.keywords),e(c.types),e(c.builtin),e(c.atoms),d.length&&(c.helperType=b[0],a.registerHelper("hintWords",b[0],d));for(var f=0;f<b.length;++f)a.defineMIME(b[f],c)}function m(a,b){for(var c=!1;!a.eol();){if(!c&&a.match('"""')){b.tokenize=null;break}c="\\"==a.next()&&!c}return"string"}a.defineMode("clike",function(b,c){function u(a,b){var c=a.next();if(m[c]){var d=m[c](a,b);if(d!==!1)return d}if('"'==c||"'"==c)return b.tokenize=v(c),b.tokenize(a,b);if(/[\[\]{}\(\),;\:\.]/.test(c))return s=c,null;if(/\d/.test(c))return a.eatWhile(/[\w\.]/),"number";if("/"==c){if(a.eat("*"))return b.tokenize=w,w(a,b);if(a.eat("/"))return a.skipToEnd(),"comment"}if(r.test(c))return a.eatWhile(r),"operator";if(a.eatWhile(/[\w\$_\xa1-\uffff]/),q)for(;a.match(q);)a.eatWhile(/[\w\$_\xa1-\uffff]/);var e=a.current();return g.propertyIsEnumerable(e)?(j.propertyIsEnumerable(e)&&(s="newstatement"),k.propertyIsEnumerable(e)&&(t=!0),"keyword"):h.propertyIsEnumerable(e)?"variable-3":i.propertyIsEnumerable(e)?(j.propertyIsEnumerable(e)&&(s="newstatement"),"builtin"):l.propertyIsEnumerable(e)?"atom":"variable"}function v(a){return function(b,c){for(var e,d=!1,f=!1;null!=(e=b.next());){if(e==a&&!d){f=!0;break}d=!d&&"\\"==e}return(f||!d&&!n)&&(c.tokenize=null),"string"}}function w(a,b){for(var d,c=!1;d=a.next();){if("/"==d&&c){b.tokenize=null;break}c="*"==d}return"comment"}function x(a,b,c,d,e){this.indented=a,this.column=b,this.type=c,this.align=d,this.prev=e}function y(a){return"statement"==a||"switchstatement"==a||"namespace"==a}function z(a,b,c){var d=a.indented;return a.context&&y(a.context.type)&&!y(c)&&(d=a.context.indented),a.context=new x(d,b,c,null,a.context)}function A(a){var b=a.context.type;return(")"==b||"]"==b||"}"==b)&&(a.indented=a.context.indented),a.context=a.context.prev}function B(a,b){return"variable"==b.prevToken||"variable-3"==b.prevToken?!0:/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(a.string.slice(0,a.start))?!0:void 0}function C(a){for(;;){if(!a||"top"==a.type)return!0;if("}"==a.type&&"namespace"!=a.prev.type)return!1;a=a.prev}}var s,t,d=b.indentUnit,e=c.statementIndentUnit||d,f=c.dontAlignCalls,g=c.keywords||{},h=c.types||{},i=c.builtin||{},j=c.blockKeywords||{},k=c.defKeywords||{},l=c.atoms||{},m=c.hooks||{},n=c.multiLineStrings,o=c.indentStatements!==!1,p=c.indentSwitch!==!1,q=c.namespaceSeparator,r=/[+\-*&%=<>!?|\/]/;return{startState:function(a){return{tokenize:null,context:new x((a||0)-d,0,"top",!1),indented:0,startOfLine:!0,prevToken:null}},token:function(a,b){var d=b.context;if(a.sol()&&(null==d.align&&(d.align=!1),b.indented=a.indentation(),b.startOfLine=!0),a.eatSpace())return null;s=t=null;var e=(b.tokenize||u)(a,b);if("comment"==e||"meta"==e)return e;if(null==d.align&&(d.align=!0),";"==s||":"==s||","==s)for(;y(b.context.type);)A(b);else if("{"==s)z(b,a.column(),"}");else if("["==s)z(b,a.column(),"]");else if("("==s)z(b,a.column(),")");else if("}"==s){for(;y(d.type);)d=A(b);for("}"==d.type&&(d=A(b));y(d.type);)d=A(b)}else if(s==d.type)A(b);else if(o&&(("}"==d.type||"top"==d.type)&&";"!=s||y(d.type)&&"newstatement"==s)){var f="statement";"newstatement"==s&&p&&"switch"==a.current()?f="switchstatement":"keyword"==e&&"namespace"==a.current()&&(f="namespace"),z(b,a.column(),f)}if("variable"==e&&("def"==b.prevToken||c.typeFirstDefinitions&&B(a,b)&&C(b.context)&&a.match(/^\s*\(/,!1))&&(e="def"),m.token){var g=m.token(a,b,e);void 0!==g&&(e=g)}return"def"==e&&c.styleDefs===!1&&(e="variable"),b.startOfLine=!1,b.prevToken=t?"def":e||s,e},indent:function(b,c){if(b.tokenize!=u&&null!=b.tokenize)return a.Pass;var g=b.context,h=c&&c.charAt(0);y(g.type)&&"}"==h&&(g=g.prev);var i=h==g.type,j=g.prev&&"switchstatement"==g.prev.type;return y(g.type)?g.indented+("{"==h?0:e):!g.align||f&&")"==g.type?")"!=g.type||i?g.indented+(i?0:d)+(i||!j||/^(?:case|default)\b/.test(c)?0:d):g.indented+e:g.column+(i?0:1)},electricInput:p?/^\s*(?:case .*?:|default:|\{\}?|\})$/:/^\s*[{}]$/,blockCommentStart:"/*",blockCommentEnd:"*/",lineComment:"//",fold:"brace"}});var c="auto if break case register continue return default do sizeof static else struct switch extern typedef float union for goto while enum const volatile",d="int long char short double float unsigned signed void size_t ptrdiff_t";l(["text/x-csrc","text/x-c","text/x-chdr"],{name:"clike",keywords:b(c),types:b(d+" bool _Complex _Bool float_t double_t intptr_t intmax_t int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t uint32_t uint64_t"),blockKeywords:b("case do else for if switch while struct"),defKeywords:b("struct"),typeFirstDefinitions:!0,atoms:b("null true false"),hooks:{"#":e,"*":f},modeProps:{fold:["brace","include"]}}),l(["text/x-c++src","text/x-c++hdr"],{name:"clike",keywords:b(c+" asm dynamic_cast namespace reinterpret_cast try explicit new static_cast typeid catch operator template typename class friend private this using const_cast inline public throw virtual delete mutable protected alignas alignof constexpr decltype nullptr noexcept thread_local final static_assert override"),types:b(d+" bool wchar_t"),blockKeywords:b("catch class do else finally for if struct switch try while"),
|
21 |
-
defKeywords:b("class namespace struct enum union"),typeFirstDefinitions:!0,atoms:b("true false null"),hooks:{"#":e,"*":f,u:h,U:h,L:h,R:h,0:g,1:g,2:g,3:g,4:g,5:g,6:g,7:g,8:g,9:g,token:function(a,b,c){return"variable"!=c||"("!=a.peek()||";"!=b.prevToken&&null!=b.prevToken&&"}"!=b.prevToken||!i(a.current())?void 0:"def"}},namespaceSeparator:"::",modeProps:{fold:["brace","include"]}}),l("text/x-java",{name:"clike",keywords:b("abstract assert break case catch class const continue default do else enum extends final finally float for goto if implements import instanceof interface native new package private protected public return static strictfp super switch synchronized this throw throws transient try volatile while"),types:b("byte short int long float double boolean char void Boolean Byte Character Double Float Integer Long Number Object Short String StringBuffer StringBuilder Void"),blockKeywords:b("catch class do else finally for if switch try while"),defKeywords:b("class interface package enum"),typeFirstDefinitions:!0,atoms:b("true false null"),hooks:{"@":function(a){return a.eatWhile(/[\w\$_]/),"meta"}},modeProps:{fold:["brace","import"]}}),l("text/x-csharp",{name:"clike",keywords:b("abstract as async await base break case catch checked class const continue default delegate do else enum event explicit extern finally fixed for foreach goto if implicit in interface internal is lock namespace new operator out override params private protected public readonly ref return sealed sizeof stackalloc static struct switch this throw try typeof unchecked unsafe using virtual void volatile while add alias ascending descending dynamic from get global group into join let orderby partial remove select set value var yield"),types:b("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32 UInt64 bool byte char decimal double short int long object sbyte float string ushort uint ulong"),blockKeywords:b("catch class do else finally for foreach if struct switch try while"),defKeywords:b("class interface namespace struct var"),typeFirstDefinitions:!0,atoms:b("true false null"),hooks:{"@":function(a,b){return a.eat('"')?(b.tokenize=j,j(a,b)):(a.eatWhile(/[\w\$_]/),"meta")}}}),l("text/x-scala",{name:"clike",keywords:b("abstract case catch class def do else extends false final finally for forSome if implicit import lazy match new null object override package private protected return sealed super this throw trait try type val var while with yield _ : = => <- <: <% >: # @ assert assume require print println printf readLine readBoolean readByte readShort readChar readInt readLong readFloat readDouble :: #:: "),types:b("AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable Compiler Double Exception Float Integer Long Math Number Object Package Pair Process Runtime Runnable SecurityManager Short StackTraceElement StrictMath String StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"),multiLineStrings:!0,blockKeywords:b("catch class do else finally for forSome if match switch try while"),defKeywords:b("class def object package trait type val var"),atoms:b("true false null"),indentStatements:!1,indentSwitch:!1,hooks:{"@":function(a){return a.eatWhile(/[\w\$_]/),"meta"},'"':function(a,b){return a.match('""')?(b.tokenize=m,b.tokenize(a,b)):!1},"'":function(a){return a.eatWhile(/[\w\$_\xa1-\uffff]/),"atom"}},modeProps:{closeBrackets:{triples:'"'}}}),l("text/x-kotlin",{name:"clike",keywords:b("package as typealias class interface this super val var fun for is in This throw return break continue object if else while do try when !in !is as?file import where by get set abstract enum open inner override private public internal protected catch finally out final vararg reified dynamic companion constructor init sealed field property receiver param sparam lateinit data inline noinline tailrec external annotation crossinline"),types:b("Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable Compiler Double Exception Float Integer Long Math Number Object Package Pair Process Runtime Runnable SecurityManager Short StackTraceElement StrictMath String StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"),multiLineStrings:!0,blockKeywords:b("catch class do else finally for if where try while enum"),defKeywords:b("class val var object package interface fun"),atoms:b("true false null this"),modeProps:{closeBrackets:{triples:'"'}}}),l(["x-shader/x-vertex","x-shader/x-fragment"],{name:"clike",keywords:b("sampler1D sampler2D sampler3D samplerCube sampler1DShadow sampler2DShadow const attribute uniform varying break continue discard return for while do if else struct in out inout"),types:b("float int bool void vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 mat2 mat3 mat4"),blockKeywords:b("for while do if else struct"),builtin:b("radians degrees sin cos tan asin acos atan pow exp log exp2 sqrt inversesqrt abs sign floor ceil fract mod min max clamp mix step smoothstep length distance dot cross normalize ftransform faceforward reflect refract matrixCompMult lessThan lessThanEqual greaterThan greaterThanEqual equal notEqual any all not texture1D texture1DProj texture1DLod texture1DProjLod texture2D texture2DProj texture2DLod texture2DProjLod texture3D texture3DProj texture3DLod texture3DProjLod textureCube textureCubeLod shadow1D shadow2D shadow1DProj shadow2DProj shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod dFdx dFdy fwidth noise1 noise2 noise3 noise4"),atoms:b("true false gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 gl_FogCoord gl_PointCoord gl_Position gl_PointSize gl_ClipVertex gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor gl_TexCoord gl_FogFragCoord gl_FragCoord gl_FrontFacing gl_FragData gl_FragDepth gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose gl_ProjectionMatrixInverseTranspose gl_ModelViewProjectionMatrixInverseTranspose gl_TextureMatrixInverseTranspose gl_NormalScale gl_DepthRange gl_ClipPlane gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel gl_FrontLightModelProduct gl_BackLightModelProduct gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ gl_FogParameters gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits gl_MaxDrawBuffers"),indentSwitch:!1,hooks:{"#":e},modeProps:{fold:["brace","include"]}}),l("text/x-nesc",{name:"clike",keywords:b(c+"as atomic async call command component components configuration event generic implementation includes interface module new norace nx_struct nx_union post provides signal task uses abstract extends"),types:b(d),blockKeywords:b("case do else for if switch while struct"),atoms:b("null true false"),hooks:{"#":e},modeProps:{fold:["brace","include"]}}),l("text/x-objectivec",{name:"clike",keywords:b(c+"inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),types:b(d),atoms:b("YES NO NULL NILL ON OFF true false"),hooks:{"@":function(a){return a.eatWhile(/[\w\$]/),"keyword"},"#":e},modeProps:{fold:"brace"}}),l("text/x-squirrel",{name:"clike",keywords:b("base break clone continue const default delete enum extends function in class foreach local resume return this throw typeof yield constructor instanceof static"),types:b(d),blockKeywords:b("case catch class else for foreach if switch try while"),defKeywords:b("function local class"),typeFirstDefinitions:!0,atoms:b("true false null"),hooks:{"#":e},modeProps:{fold:["brace","include"]}})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){for(var b={},c=0;c<a.length;++c)b[a[c]]=!0;return b}function x(a,b){for(var d,c=!1;null!=(d=a.next());){if(c&&"/"==d){b.tokenize=null;break}c="*"==d}return["comment","comment"]}a.defineMode("css",function(b,c){function u(a,b){return s=b,a}function v(a,b){var c=a.next();if(f[c]){var d=f[c](a,b);if(d!==!1)return d}return"@"==c?(a.eatWhile(/[\w\\\-]/),u("def",a.current())):"="==c||("~"==c||"|"==c)&&a.eat("=")?u(null,"compare"):'"'==c||"'"==c?(b.tokenize=w(c),b.tokenize(a,b)):"#"==c?(a.eatWhile(/[\w\\\-]/),u("atom","hash")):"!"==c?(a.match(/^\s*\w*/),u("keyword","important")):/\d/.test(c)||"."==c&&a.eat(/\d/)?(a.eatWhile(/[\w.%]/),u("number","unit")):"-"!==c?/[,+>*\/]/.test(c)?u(null,"select-op"):"."==c&&a.match(/^-?[_a-z][_a-z0-9-]*/i)?u("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(c)?u(null,c):"u"==c&&a.match(/rl(-prefix)?\(/)||"d"==c&&a.match("omain(")||"r"==c&&a.match("egexp(")?(a.backUp(1),b.tokenize=x,u("property","word")):/[\w\\\-]/.test(c)?(a.eatWhile(/[\w\\\-]/),u("property","word")):u(null,null):/[\d.]/.test(a.peek())?(a.eatWhile(/[\w.%]/),u("number","unit")):a.match(/^-[\w\\\-]+/)?(a.eatWhile(/[\w\\\-]/),a.match(/^\s*:/,!1)?u("variable-2","variable-definition"):u("variable-2","variable")):a.match(/^\w+-/)?u("meta","meta"):void 0}function w(a){return function(b,c){for(var e,d=!1;null!=(e=b.next());){if(e==a&&!d){")"==a&&b.backUp(1);break}d=!d&&"\\"==e}return(e==a||!d&&")"!=a)&&(c.tokenize=null),u("string","string")}}function x(a,b){return a.next(),a.match(/\s*[\"\')]/,!1)?b.tokenize=null:b.tokenize=w(")"),u(null,"(")}function y(a,b,c){this.type=a,this.indent=b,this.prev=c}function z(a,b,c,d){return a.context=new y(c,b.indentation()+(d===!1?0:e),a.context),c}function A(a){return a.context.prev&&(a.context=a.context.prev),a.context.type}function B(a,b,c){return E[c.context.type](a,b,c)}function C(a,b,c,d){for(var e=d||1;e>0;e--)c.context=c.context.prev;return B(a,b,c)}function D(a){var b=a.current().toLowerCase();t=p.hasOwnProperty(b)?"atom":o.hasOwnProperty(b)?"keyword":"variable"}var d=c;c.propertyKeywords||(c=a.resolveMode("text/css")),c.inline=d.inline;var s,t,e=b.indentUnit,f=c.tokenHooks,g=c.documentTypes||{},h=c.mediaTypes||{},i=c.mediaFeatures||{},j=c.mediaValueKeywords||{},k=c.propertyKeywords||{},l=c.nonStandardPropertyKeywords||{},m=c.fontProperties||{},n=c.counterDescriptors||{},o=c.colorKeywords||{},p=c.valueKeywords||{},q=c.allowNested,r=c.supportsAtComponent===!0,E={};return E.top=function(a,b,c){if("{"==a)return z(c,b,"block");if("}"==a&&c.context.prev)return A(c);if(r&&/@component/.test(a))return z(c,b,"atComponentBlock");if(/^@(-moz-)?document$/.test(a))return z(c,b,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/.test(a))return z(c,b,"atBlock");if(/^@(font-face|counter-style)/.test(a))return c.stateArg=a,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(a))return"keyframes";if(a&&"@"==a.charAt(0))return z(c,b,"at");if("hash"==a)t="builtin";else if("word"==a)t="tag";else{if("variable-definition"==a)return"maybeprop";if("interpolation"==a)return z(c,b,"interpolation");if(":"==a)return"pseudo";if(q&&"("==a)return z(c,b,"parens")}return c.context.type},E.block=function(a,b,c){if("word"==a){var d=b.current().toLowerCase();return k.hasOwnProperty(d)?(t="property","maybeprop"):l.hasOwnProperty(d)?(t="string-2","maybeprop"):q?(t=b.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(t+=" error","maybeprop")}return"meta"==a?"block":q||"hash"!=a&&"qualifier"!=a?E.top(a,b,c):(t="error","block")},E.maybeprop=function(a,b,c){return":"==a?z(c,b,"prop"):B(a,b,c)},E.prop=function(a,b,c){if(";"==a)return A(c);if("{"==a&&q)return z(c,b,"propBlock");if("}"==a||"{"==a)return C(a,b,c);if("("==a)return z(c,b,"parens");if("hash"!=a||/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(b.current())){if("word"==a)D(b);else if("interpolation"==a)return z(c,b,"interpolation")}else t+=" error";return"prop"},E.propBlock=function(a,b,c){return"}"==a?A(c):"word"==a?(t="property","maybeprop"):c.context.type},E.parens=function(a,b,c){return"{"==a||"}"==a?C(a,b,c):")"==a?A(c):"("==a?z(c,b,"parens"):"interpolation"==a?z(c,b,"interpolation"):("word"==a&&D(b),"parens")},E.pseudo=function(a,b,c){return"word"==a?(t="variable-3",c.context.type):B(a,b,c)},E.documentTypes=function(a,b,c){return"word"==a&&g.hasOwnProperty(b.current())?(t="tag",c.context.type):E.atBlock(a,b,c)},E.atBlock=function(a,b,c){if("("==a)return z(c,b,"atBlock_parens");if("}"==a||";"==a)return C(a,b,c);if("{"==a)return A(c)&&z(c,b,q?"block":"top");if("word"==a){var d=b.current().toLowerCase();t="only"==d||"not"==d||"and"==d||"or"==d?"keyword":h.hasOwnProperty(d)?"attribute":i.hasOwnProperty(d)?"property":j.hasOwnProperty(d)?"keyword":k.hasOwnProperty(d)?"property":l.hasOwnProperty(d)?"string-2":p.hasOwnProperty(d)?"atom":o.hasOwnProperty(d)?"keyword":"error"}return c.context.type},E.atComponentBlock=function(a,b,c){return"}"==a?C(a,b,c):"{"==a?A(c)&&z(c,b,q?"block":"top",!1):("word"==a&&(t="error"),c.context.type)},E.atBlock_parens=function(a,b,c){return")"==a?A(c):"{"==a||"}"==a?C(a,b,c,2):E.atBlock(a,b,c)},E.restricted_atBlock_before=function(a,b,c){return"{"==a?z(c,b,"restricted_atBlock"):"word"==a&&"@counter-style"==c.stateArg?(t="variable","restricted_atBlock_before"):B(a,b,c)},E.restricted_atBlock=function(a,b,c){return"}"==a?(c.stateArg=null,A(c)):"word"==a?(t="@font-face"==c.stateArg&&!m.hasOwnProperty(b.current().toLowerCase())||"@counter-style"==c.stateArg&&!n.hasOwnProperty(b.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},E.keyframes=function(a,b,c){return"word"==a?(t="variable","keyframes"):"{"==a?z(c,b,"top"):B(a,b,c)},E.at=function(a,b,c){return";"==a?A(c):"{"==a||"}"==a?C(a,b,c):("word"==a?t="tag":"hash"==a&&(t="builtin"),"at")},E.interpolation=function(a,b,c){return"}"==a?A(c):"{"==a||";"==a?C(a,b,c):("word"==a?t="variable":"variable"!=a&&"("!=a&&")"!=a&&(t="error"),"interpolation")},{startState:function(a){return{tokenize:null,state:c.inline?"block":"top",stateArg:null,context:new y(c.inline?"block":"top",a||0,null)}},token:function(a,b){if(!b.tokenize&&a.eatSpace())return null;var c=(b.tokenize||v)(a,b);return c&&"object"==typeof c&&(s=c[1],c=c[0]),t=c,b.state=E[b.state](s,a,b),t},indent:function(a,b){var c=a.context,d=b&&b.charAt(0),f=c.indent;return"prop"!=c.type||"}"!=d&&")"!=d||(c=c.prev),c.prev&&("}"!=d||"block"!=c.type&&"top"!=c.type&&"interpolation"!=c.type&&"restricted_atBlock"!=c.type?(")"==d&&("parens"==c.type||"atBlock_parens"==c.type)||"{"==d&&("at"==c.type||"atBlock"==c.type))&&(f=Math.max(0,c.indent-e),c=c.prev):(c=c.prev,f=c.indent)),f},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var c=["domain","regexp","url","url-prefix"],d=b(c),e=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],f=b(e),g=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],h=b(g),i=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],j=b(i),k=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],l=b(k),m=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],n=b(m),o=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],p=b(o),q=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],r=b(q),s=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],t=b(s),u=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","column-reverse","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],v=b(u),w=c.concat(e).concat(g).concat(i).concat(k).concat(m).concat(s).concat(u);a.registerHelper("hintWords","css",w),a.defineMIME("text/css",{documentTypes:d,mediaTypes:f,mediaFeatures:h,mediaValueKeywords:j,propertyKeywords:l,nonStandardPropertyKeywords:n,fontProperties:p,counterDescriptors:r,colorKeywords:t,valueKeywords:v,tokenHooks:{"/":function(a,b){return a.eat("*")?(b.tokenize=x,x(a,b)):!1}},name:"css"}),a.defineMIME("text/x-scss",{mediaTypes:f,mediaFeatures:h,mediaValueKeywords:j,propertyKeywords:l,nonStandardPropertyKeywords:n,colorKeywords:t,valueKeywords:v,fontProperties:p,allowNested:!0,tokenHooks:{"/":function(a,b){return a.eat("/")?(a.skipToEnd(),["comment","comment"]):a.eat("*")?(b.tokenize=x,x(a,b)):["operator","operator"]},":":function(a){return a.match(/\s*\{/)?[null,"{"]:!1},$:function(a){return a.match(/^[\w-]+/),a.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(a){return a.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),a.defineMIME("text/x-less",{mediaTypes:f,mediaFeatures:h,mediaValueKeywords:j,propertyKeywords:l,nonStandardPropertyKeywords:n,colorKeywords:t,valueKeywords:v,fontProperties:p,allowNested:!0,tokenHooks:{"/":function(a,b){return a.eat("/")?(a.skipToEnd(),
|
22 |
-
["comment","comment"]):a.eat("*")?(b.tokenize=x,x(a,b)):["operator","operator"]},"@":function(a){return a.eat("{")?[null,"interpolation"]:a.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)?!1:(a.eatWhile(/[\w\\\-]/),a.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"}),a.defineMIME("text/x-gss",{documentTypes:d,mediaTypes:f,mediaFeatures:h,propertyKeywords:l,nonStandardPropertyKeywords:n,fontProperties:p,counterDescriptors:r,colorKeywords:t,valueKeywords:v,supportsAtComponent:!0,tokenHooks:{"/":function(a,b){return a.eat("*")?(b.tokenize=x,x(a,b)):!1}},name:"css",helperType:"gss"})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],a):a(CodeMirror)}(function(a){"use strict";function c(a,b,c){var d=a.current(),e=d.search(b);return e>-1?a.backUp(d.length-e):d.match(/<\/?$/)&&(a.backUp(d.length),a.match(b,!1)||a.match(d)),c}function e(a){var b=d[a];return b?b:d[a]=new RegExp("\\s+"+a+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")}function f(a,b){for(var d,c=a.pos;c>=0&&"<"!==a.string.charAt(c);)c--;return 0>c?c:(d=a.string.slice(c,a.pos).match(e(b)))?d[2]:""}function g(a,b){return new RegExp((b?"^":"")+"</s*"+a+"s*>","i")}function h(a,b){for(var c in a)for(var d=b[c]||(b[c]=[]),e=a[c],f=e.length-1;f>=0;f--)d.unshift(e[f])}function i(a,b){for(var c=0;c<a.length;c++){var d=a[c];if(!d[0]||d[1].test(f(b,d[0])))return d[2]}}var b={script:[["lang",/(javascript|babel)/i,"javascript"],["type",/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,"javascript"],["type",/./,"text/plain"],[null,null,"javascript"]],style:[["lang",/^css$/i,"css"],["type",/^(text\/)?(x-)?(stylesheet|css)$/i,"css"],["type",/./,"text/plain"],[null,null,"css"]]},d={};a.defineMode("htmlmixed",function(d,e){function n(b,e){var m,h=e.htmlState.tagName,k=h&&j[h.toLowerCase()],l=f.token(b,e.htmlState);if(k&&/\btag\b/.test(l)&&">"===b.current()&&(m=i(k,b))){var o=a.getMode(d,m),p=g(h,!0),q=g(h,!1);e.token=function(a,b){return a.match(p,!1)?(b.token=n,b.localState=b.localMode=null,null):c(a,q,b.localMode.token(a,b.localState))},e.localMode=o,e.localState=a.startState(o,f.indent(e.htmlState,""))}return l}var f=a.getMode(d,{name:"xml",htmlMode:!0,multilineTagIndentFactor:e.multilineTagIndentFactor,multilineTagIndentPastTag:e.multilineTagIndentPastTag}),j={},k=e&&e.tags,l=e&&e.scriptTypes;if(h(b,j),k&&h(k,j),l)for(var m=l.length-1;m>=0;m--)j.script.unshift(["type",l[m].matches,l[m].mode]);return{startState:function(){var a=f.startState();return{token:n,localMode:null,localState:null,htmlState:a}},copyState:function(b){var c;return b.localState&&(c=a.copyState(b.localMode,b.localState)),{token:b.token,localMode:b.localMode,localState:c,htmlState:a.copyState(f,b.htmlState)}},token:function(a,b){return b.token(a,b)},indent:function(b,c){return!b.localMode||/^\s*<\//.test(c)?f.indent(b.htmlState,c):b.localMode.indent?b.localMode.indent(b.localState,c):a.Pass},innerMode:function(a){return{state:a.localState||a.htmlState,mode:a.localMode||f}}}},"xml","javascript","css"),a.defineMIME("text/html","htmlmixed")}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("javascript",function(b,c){function m(a){for(var c,b=!1,d=!1;null!=(c=a.next());){if(!b){if("/"==c&&!d)return;"["==c?d=!0:d&&"]"==c&&(d=!1)}b=!b&&"\\"==c}}function p(a,b,c){return n=a,o=c,b}function q(a,b){var c=a.next();if('"'==c||"'"==c)return b.tokenize=r(c),b.tokenize(a,b);if("."==c&&a.match(/^\d+(?:[eE][+\-]?\d+)?/))return p("number","number");if("."==c&&a.match(".."))return p("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(c))return p(c);if("="==c&&a.eat(">"))return p("=>","operator");if("0"==c&&a.eat(/x/i))return a.eatWhile(/[\da-f]/i),p("number","number");if("0"==c&&a.eat(/o/i))return a.eatWhile(/[0-7]/i),p("number","number");if("0"==c&&a.eat(/b/i))return a.eatWhile(/[01]/i),p("number","number");if(/\d/.test(c))return a.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),p("number","number");if("/"==c)return a.eat("*")?(b.tokenize=s,s(a,b)):a.eat("/")?(a.skipToEnd(),p("comment","comment")):"operator"==b.lastType||"keyword c"==b.lastType||"sof"==b.lastType||/^[\[{}\(,;:]$/.test(b.lastType)?(m(a),a.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),p("regexp","string-2")):(a.eatWhile(k),p("operator","operator",a.current()));if("`"==c)return b.tokenize=t,t(a,b);if("#"==c)return a.skipToEnd(),p("error","error");if(k.test(c))return a.eatWhile(k),p("operator","operator",a.current());if(i.test(c)){a.eatWhile(i);var d=a.current(),e=j.propertyIsEnumerable(d)&&j[d];return e&&"."!=b.lastType?p(e.type,e.style,d):p("variable","variable",d)}}function r(a){return function(b,c){var e,d=!1;if(f&&"@"==b.peek()&&b.match(l))return c.tokenize=q,p("jsonld-keyword","meta");for(;null!=(e=b.next())&&(e!=a||d);)d=!d&&"\\"==e;return d||(c.tokenize=q),p("string","string")}}function s(a,b){for(var d,c=!1;d=a.next();){if("/"==d&&c){b.tokenize=q;break}c="*"==d}return p("comment","comment")}function t(a,b){for(var d,c=!1;null!=(d=a.next());){if(!c&&("`"==d||"$"==d&&a.eat("{"))){b.tokenize=q;break}c=!c&&"\\"==d}return p("quasi","string-2",a.current())}function v(a,b){b.fatArrowAt&&(b.fatArrowAt=null);var c=a.string.indexOf("=>",a.start);if(!(0>c)){for(var d=0,e=!1,f=c-1;f>=0;--f){var g=a.string.charAt(f),h=u.indexOf(g);if(h>=0&&3>h){if(!d){++f;break}if(0==--d)break}else if(h>=3&&6>h)++d;else if(i.test(g))e=!0;else{if(/["'\/]/.test(g))return;if(e&&!d){++f;break}}}e&&!d&&(b.fatArrowAt=f)}}function x(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,null!=d&&(this.align=d)}function y(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0;for(var d=a.context;d;d=d.prev)for(var c=d.vars;c;c=c.next)if(c.name==b)return!0}function z(a,b,c,d,e){var f=a.cc;for(A.state=a,A.stream=e,A.marked=null,A.cc=f,A.style=b,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);;){var h=f.length?f.pop():g?L:K;if(h(c,d)){for(;f.length&&f[f.length-1].lex;)f.pop()();return A.marked?A.marked:"variable"==c&&y(a,d)?"variable-2":b}}}function B(){for(var a=arguments.length-1;a>=0;a--)A.cc.push(arguments[a])}function C(){return B.apply(null,arguments),!0}function D(a){function b(b){for(var c=b;c;c=c.next)if(c.name==a)return!0;return!1}var d=A.state;if(d.context){if(A.marked="def",b(d.localVars))return;d.localVars={name:a,next:d.localVars}}else{if(b(d.globalVars))return;c.globalVars&&(d.globalVars={name:a,next:d.globalVars})}}function F(){A.state.context={prev:A.state.context,vars:A.state.localVars},A.state.localVars=E}function G(){A.state.localVars=A.state.context.vars,A.state.context=A.state.context.prev}function H(a,b){var c=function(){var c=A.state,d=c.indented;if("stat"==c.lexical.type)d=c.lexical.indented;else for(var e=c.lexical;e&&")"==e.type&&e.align;e=e.prev)d=e.indented;c.lexical=new x(d,A.stream.column(),a,null,c.lexical,b)};return c.lex=!0,c}function I(){var a=A.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function J(a){function b(c){return c==a?C():";"==a?B():C(b)}return b}function K(a,b){return"var"==a?C(H("vardef",b.length),fa,J(";"),I):"keyword a"==a?C(H("form"),L,K,I):"keyword b"==a?C(H("form"),K,I):"{"==a?C(H("}"),ba,I):";"==a?C():"if"==a?("else"==A.state.lexical.info&&A.state.cc[A.state.cc.length-1]==I&&A.state.cc.pop()(),C(H("form"),L,K,I,ka)):"function"==a?C(qa):"for"==a?C(H("form"),la,K,I):"variable"==a?C(H("stat"),W):"switch"==a?C(H("form"),L,H("}","switch"),J("{"),ba,I,I):"case"==a?C(L,J(":")):"default"==a?C(J(":")):"catch"==a?C(H("form"),F,J("("),ra,J(")"),K,I,G):"class"==a?C(H("form"),sa,I):"export"==a?C(H("stat"),wa,I):"import"==a?C(H("stat"),xa,I):B(H("stat"),L,J(";"),I)}function L(a){return N(a,!1)}function M(a){return N(a,!0)}function N(a,b){if(A.state.fatArrowAt==A.stream.start){var c=b?V:U;if("("==a)return C(F,H(")"),_(ga,")"),I,J("=>"),c,G);if("variable"==a)return B(F,ga,J("=>"),c,G)}var d=b?R:Q;return w.hasOwnProperty(a)?C(d):"async"==a?C(L):"function"==a?C(qa,d):"keyword c"==a?C(b?P:O):"("==a?C(H(")"),O,Da,J(")"),I,d):"operator"==a||"spread"==a?C(b?M:L):"["==a?C(H("]"),Ba,I,d):"{"==a?aa(Y,"}",null,d):"quasi"==a?B(S,d):C()}function O(a){return a.match(/[;\}\)\],]/)?B():B(L)}function P(a){return a.match(/[;\}\)\],]/)?B():B(M)}function Q(a,b){return","==a?C(L):R(a,b,!1)}function R(a,b,c){var d=0==c?Q:R,e=0==c?L:M;return"=>"==a?C(F,c?V:U,G):"operator"==a?/\+\+|--/.test(b)?C(d):"?"==b?C(L,J(":"),e):C(e):"quasi"==a?B(S,d):";"!=a?"("==a?aa(M,")","call",d):"."==a?C(X,d):"["==a?C(H("]"),O,J("]"),I,d):void 0:void 0}function S(a,b){return"quasi"!=a?B():"${"!=b.slice(b.length-2)?C(S):C(L,T)}function T(a){return"}"==a?(A.marked="string-2",A.state.tokenize=t,C(S)):void 0}function U(a){return v(A.stream,A.state),B("{"==a?K:L)}function V(a){return v(A.stream,A.state),B("{"==a?K:M)}function W(a){return":"==a?C(I,K):B(Q,J(";"),I)}function X(a){return"variable"==a?(A.marked="property",C()):void 0}function Y(a,b){return"async"==a?C(Y):"variable"==a||"keyword"==A.style?(A.marked="property",C("get"==b||"set"==b?Z:$)):"number"==a||"string"==a?(A.marked=f?"property":A.style+" property",C($)):"jsonld-keyword"==a?C($):"["==a?C(L,J("]"),$):void 0}function Z(a){return"variable"!=a?B($):(A.marked="property",C(qa))}function $(a){return":"==a?C(M):"("==a?B(qa):void 0}function _(a,b){function c(d){if(","==d){var e=A.state.lexical;return"call"==e.info&&(e.pos=(e.pos||0)+1),C(a,c)}return d==b?C():C(J(b))}return function(d){return d==b?C():B(a,c)}}function aa(a,b,c){for(var d=3;d<arguments.length;d++)A.cc.push(arguments[d]);return C(H(b,c),_(a,b),I)}function ba(a){return"}"==a?C():B(K,ba)}function ca(a){return h&&":"==a?C(ea):void 0}function da(a,b){return"="==b?C(M):void 0}function ea(a){return"variable"==a?(A.marked="variable-3",C()):void 0}function fa(){return B(ga,ca,ia,ja)}function ga(a,b){return"variable"==a?(D(b),C()):"spread"==a?C(ga):"["==a?aa(ga,"]"):"{"==a?aa(ha,"}"):void 0}function ha(a,b){return"variable"!=a||A.stream.match(/^\s*:/,!1)?("variable"==a&&(A.marked="property"),"spread"==a?C(ga):C(J(":"),ga,ia)):(D(b),C(ia))}function ia(a,b){return"="==b?C(M):void 0}function ja(a){return","==a?C(fa):void 0}function ka(a,b){return"keyword b"==a&&"else"==b?C(H("form","else"),K,I):void 0}function la(a){return"("==a?C(H(")"),ma,J(")"),I):void 0}function ma(a){return"var"==a?C(fa,J(";"),oa):";"==a?C(oa):"variable"==a?C(na):B(L,J(";"),oa)}function na(a,b){return"in"==b||"of"==b?(A.marked="keyword",C(L)):C(Q,oa)}function oa(a,b){return";"==a?C(pa):"in"==b||"of"==b?(A.marked="keyword",C(L)):B(L,J(";"),pa)}function pa(a){")"!=a&&C(L)}function qa(a,b){return"*"==b?(A.marked="keyword",C(qa)):"variable"==a?(D(b),C(qa)):"("==a?C(F,H(")"),_(ra,")"),I,K,G):void 0}function ra(a){return"spread"==a?C(ra):B(ga,ca,da)}function sa(a,b){return"variable"==a?(D(b),C(ta)):void 0}function ta(a,b){return"extends"==b?C(L,ta):"{"==a?C(H("}"),ua,I):void 0}function ua(a,b){return"variable"==a||"keyword"==A.style?"static"==b?(A.marked="keyword",C(ua)):(A.marked="property","get"==b||"set"==b?C(va,qa,ua):C(qa,ua)):"*"==b?(A.marked="keyword",C(ua)):";"==a?C(ua):"}"==a?C():void 0}function va(a){return"variable"!=a?B():(A.marked="property",C())}function wa(a,b){return"*"==b?(A.marked="keyword",C(Aa,J(";"))):"default"==b?(A.marked="keyword",C(L,J(";"))):B(K)}function xa(a){return"string"==a?C():B(ya,Aa)}function ya(a,b){return"{"==a?aa(ya,"}"):("variable"==a&&D(b),"*"==b&&(A.marked="keyword"),C(za))}function za(a,b){return"as"==b?(A.marked="keyword",C(ya)):void 0}function Aa(a,b){return"from"==b?(A.marked="keyword",C(L)):void 0}function Ba(a){return"]"==a?C():B(M,Ca)}function Ca(a){return"for"==a?B(Da,J("]")):","==a?C(_(P,"]")):B(_(M,"]"))}function Da(a){return"for"==a?C(la,Da):"if"==a?C(L,Da):void 0}function Ea(a,b){return"operator"==a.lastType||","==a.lastType||k.test(b.charAt(0))||/[,.]/.test(b.charAt(0))}var n,o,d=b.indentUnit,e=c.statementIndent,f=c.jsonld,g=c.json||f,h=c.typescript,i=c.wordCharacters||/[\w$\xa1-\uffff]/,j=function(){function a(a){return{type:a,style:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("operator"),f={type:"atom",style:"atom"},g={"if":a("if"),"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":d,"delete":d,"throw":d,"debugger":d,"var":a("var"),"const":a("var"),let:a("var"),async:a("async"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":e,"typeof":e,"instanceof":e,"true":f,"false":f,"null":f,undefined:f,NaN:f,Infinity:f,"this":a("this"),"class":a("class"),"super":a("atom"),await:d,"yield":d,"export":a("export"),"import":a("import"),"extends":d};if(h){var i={type:"variable",style:"variable-3"},j={"interface":a("interface"),"extends":a("extends"),constructor:a("constructor"),"public":a("public"),"private":a("private"),"protected":a("protected"),"static":a("static"),string:i,number:i,bool:i,any:i};for(var k in j)g[k]=j[k]}return g}(),k=/[+\-*&%=<>!?|~^]/,l=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,u="([{}])",w={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},A={state:null,column:null,marked:null,cc:null},E={name:"this",next:{name:"arguments"}};return I.lex=!0,{startState:function(a){var b={tokenize:q,lastType:"sof",cc:[],lexical:new x((a||0)-d,0,"block",!1),localVars:c.localVars,context:c.localVars&&{vars:c.localVars},indented:0};return c.globalVars&&"object"==typeof c.globalVars&&(b.globalVars=c.globalVars),b},token:function(a,b){if(a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation(),v(a,b)),b.tokenize!=s&&a.eatSpace())return null;var c=b.tokenize(a,b);return"comment"==n?c:(b.lastType="operator"!=n||"++"!=o&&"--"!=o?n:"incdec",z(b,c,n,o,a))},indent:function(b,f){if(b.tokenize==s)return a.Pass;if(b.tokenize!=q)return 0;var g=f&&f.charAt(0),h=b.lexical;if(!/^\s*else\b/.test(f))for(var i=b.cc.length-1;i>=0;--i){var j=b.cc[i];if(j==I)h=h.prev;else if(j!=ka)break}"stat"==h.type&&"}"==g&&(h=h.prev),e&&")"==h.type&&"stat"==h.prev.type&&(h=h.prev);var k=h.type,l=g==k;return"vardef"==k?h.indented+("operator"==b.lastType||","==b.lastType?h.info+1:0):"form"==k&&"{"==g?h.indented:"form"==k?h.indented+d:"stat"==k?h.indented+(Ea(b,f)?e||d:0):"switch"!=h.info||l||0==c.doubleIndentSwitch?h.align?h.column+(l?0:1):h.indented+(l?0:d):h.indented+(/^(?:case|default)\b/.test(f)?d:2*d)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:g?null:"/*",blockCommentEnd:g?null:"*/",lineComment:g?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:g?"json":"javascript",jsonldMode:f,jsonMode:g}}),a.registerHelper("wordChars","javascript",/[\w$]/),a.defineMIME("text/javascript","javascript"),a.defineMIME("text/ecmascript","javascript"),a.defineMIME("application/javascript","javascript"),a.defineMIME("application/x-javascript","javascript"),a.defineMIME("application/ecmascript","javascript"),a.defineMIME("application/json",{name:"javascript",json:!0}),a.defineMIME("application/x-json",{name:"javascript",json:!0}),a.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),a.defineMIME("text/typescript",{name:"javascript",typescript:!0}),a.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../htmlmixed/htmlmixed"),require("../clike/clike")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../htmlmixed/htmlmixed","../clike/clike"],a):a(CodeMirror)}(function(a){"use strict";function b(a){for(var b={},c=a.split(" "),d=0;d<c.length;++d)b[c[d]]=!0;return b}function c(a,b,e){return 0==a.length?d(b):function(f,g){for(var h=a[0],i=0;i<h.length;i++)if(f.match(h[i][0]))return g.tokenize=c(a.slice(1),b),h[i][1];return g.tokenize=d(b,e),"string"}}function d(a,b){return function(c,d){return e(c,d,a,b)}}function e(a,b,d,e){if(e!==!1&&a.match("${",!1)||a.match("{$",!1))return b.tokenize=null,"string";if(e!==!1&&a.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/))return a.match("[",!1)&&(b.tokenize=c([[["[",null]],[[/\d[\w\.]*/,"number"],[/\$[a-zA-Z_][a-zA-Z0-9_]*/,"variable-2"],[/[\w\$]+/,"variable"]],[["]",null]]],d,e)),a.match(/\-\>\w/,!1)&&(b.tokenize=c([[["->",null]],[[/[\w]+/,"variable"]]],d,e)),"variable-2";for(var f=!1;!a.eol()&&(f||e===!1||!a.match("{$",!1)&&!a.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/,!1));){if(!f&&a.match(d)){b.tokenize=null,b.tokStack.pop(),b.tokStack.pop();break}f="\\"==a.next()&&!f}return"string"}var f="abstract and array as break case catch class clone const continue declare default do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final for foreach function global goto if implements interface instanceof namespace new or private protected public static switch throw trait try use var while xor die echo empty exit eval include include_once isset list require require_once return print unset __halt_compiler self static parent yield insteadof finally",g="true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__",h="func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents file_put_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once json_decode json_encode json_last_error json_last_error_msg curl_close curl_copy_handle curl_errno curl_error curl_escape curl_exec curl_file_create curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_setopt curl_share_close curl_share_init curl_share_setopt curl_strerror curl_unescape curl_version mysqli_affected_rows mysqli_autocommit mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect_errno mysqli_connect_error mysqli_connect mysqli_data_seek mysqli_debug mysqli_dump_debug_info mysqli_errno mysqli_error_list mysqli_error mysqli_fetch_all mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_charset mysqli_get_client_info mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_num_fields mysqli_num_rows mysqli_options mysqli_ping mysqli_prepare mysqli_query mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reap_async_query mysqli_refresh mysqli_rollback mysqli_select_db mysqli_set_charset mysqli_set_local_infile_default mysqli_set_local_infile_handler mysqli_sqlstate mysqli_ssl_set mysqli_stat mysqli_stmt_init mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count";a.registerHelper("hintWords","php",[f,g,h].join(" ").split(" ")),a.registerHelper("wordChars","php",/[\w$]/);var i={name:"clike",helperType:"php",keywords:b(f),blockKeywords:b("catch do else elseif for foreach if switch try while finally"),defKeywords:b("class function interface namespace trait"),atoms:b(g),builtin:b(h),multiLineStrings:!0,hooks:{$:function(a){return a.eatWhile(/[\w\$_]/),"variable-2"},"<":function(a,b){var c;if(c=a.match(/<<\s*/)){var e=a.eat(/['"]/);a.eatWhile(/[\w\.]/);var f=a.current().slice(c[0].length+(e?2:1));if(e&&a.eat(e),f)return(b.tokStack||(b.tokStack=[])).push(f,0),b.tokenize=d(f,"'"!=e),"string"}return!1},"#":function(a){for(;!a.eol()&&!a.match("?>",!1);)a.next();return"comment"},"/":function(a){if(a.eat("/")){for(;!a.eol()&&!a.match("?>",!1);)a.next();return"comment"}return!1},'"':function(a,b){return(b.tokStack||(b.tokStack=[])).push('"',0),b.tokenize=d('"'),"string"},"{":function(a,b){return b.tokStack&&b.tokStack.length&&b.tokStack[b.tokStack.length-1]++,!1},"}":function(a,b){return b.tokStack&&b.tokStack.length>0&&!--b.tokStack[b.tokStack.length-1]&&(b.tokenize=d(b.tokStack[b.tokStack.length-2])),!1}}};a.defineMode("php",function(b,c){function f(b,c){var f=c.curMode==e;if(b.sol()&&c.pending&&'"'!=c.pending&&"'"!=c.pending&&(c.pending=null),f)return f&&null==c.php.tokenize&&b.match("?>")?(c.curMode=d,c.curState=c.html,c.php.context.prev||(c.php=null),"meta"):e.token(b,c.curState);if(b.match(/^<\?\w*/))return c.curMode=e,c.php||(c.php=a.startState(e,d.indent(c.html,""))),c.curState=c.php,"meta";if('"'==c.pending||"'"==c.pending){for(;!b.eol()&&b.next()!=c.pending;);var g="string"}else if(c.pending&&b.pos<c.pending.end){b.pos=c.pending.end;var g=c.pending.style}else var g=d.token(b,c.curState);c.pending&&(c.pending=null);var j,h=b.current(),i=h.search(/<\?/);return-1!=i&&("string"==g&&(j=h.match(/[\'\"]$/))&&!/\?>/.test(h)?c.pending=j[0]:c.pending={end:b.pos,style:g},b.backUp(h.length-i)),g}var d=a.getMode(b,"text/html"),e=a.getMode(b,i);return{startState:function(){var b=a.startState(d),f=c.startOpen?a.startState(e):null;return{html:b,php:f,curMode:c.startOpen?e:d,curState:c.startOpen?f:b,pending:null}},copyState:function(b){var i,c=b.html,f=a.copyState(d,c),g=b.php,h=g&&a.copyState(e,g);return i=b.curMode==d?f:h,{html:f,php:h,curMode:b.curMode,curState:i,pending:b.pending}},token:f,indent:function(a,b){return a.curMode!=e&&/^\s*<\//.test(b)||a.curMode==e&&/^\?>/.test(b)?d.indent(a.html,b):a.curMode.indent(a.curState,b)},blockCommentStart:"/*",blockCommentEnd:"*/",lineComment:"//",innerMode:function(a){return{state:a.curState,mode:a.curMode}}}},"htmlmixed","clike"),a.defineMIME("application/x-httpd-php","php"),a.defineMIME("application/x-httpd-php-open",{name:"php",startOpen:!0}),a.defineMIME("text/x-php",i)}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("xml",function(b,c){function k(a,b){function c(c){return b.tokenize=c,c(a,b)}var d=a.next();if("<"==d)return a.eat("!")?a.eat("[")?a.match("CDATA[")?c(n("atom","]]>")):null:a.match("--")?c(n("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),c(o(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=n("meta","?>"),"meta"):(i=a.eat("/")?"closeTag":"openTag",b.tokenize=l,"tag bracket");if("&"==d){var e;return e=a.eat("#")?a.eat("x")?a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):a.eatWhile(/[\d]/)&&a.eat(";"):a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),e?"atom":"error"}return a.eatWhile(/[^&<]/),null}function l(a,b){var c=a.next();if(">"==c||"/"==c&&a.eat(">"))return b.tokenize=k,i=">"==c?"endTag":"selfcloseTag","tag bracket";if("="==c)return i="equals",null;if("<"==c){b.tokenize=k,b.state=s,b.tagName=b.tagStart=null;var d=b.tokenize(a,b);return d?d+" tag error":"tag error"}return/[\'\"]/.test(c)?(b.tokenize=m(c),b.stringStartCol=a.column(),b.tokenize(a,b)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function m(a){var b=function(b,c){for(;!b.eol();)if(b.next()==a){c.tokenize=l;break}return"string"};return b.isInAttribute=!0,b}function n(a,b){return function(c,d){for(;!c.eol();){if(c.match(b)){d.tokenize=k;break}c.next()}return a}}function o(a){return function(b,c){for(var d;null!=(d=b.next());){if("<"==d)return c.tokenize=o(a+1),c.tokenize(b,c);if(">"==d){if(1==a){c.tokenize=k;break}return c.tokenize=o(a-1),c.tokenize(b,c)}}return"meta"}}function p(a,b,c){this.prev=a.context,this.tagName=b,this.indent=a.indented,this.startOfLine=c,(g.doNotIndent.hasOwnProperty(b)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function q(a){a.context&&(a.context=a.context.prev)}function r(a,b){for(var c;;){if(!a.context)return;if(c=a.context.tagName,!g.contextGrabbers.hasOwnProperty(c)||!g.contextGrabbers[c].hasOwnProperty(b))return;q(a)}}function s(a,b,c){return"openTag"==a?(c.tagStart=b.column(),t):"closeTag"==a?u:s}function t(a,b,c){return"word"==a?(c.tagName=b.current(),j="tag",x):(j="error",t)}function u(a,b,c){if("word"==a){var d=b.current();return c.context&&c.context.tagName!=d&&g.implicitlyClosed.hasOwnProperty(c.context.tagName)&&q(c),
|
23 |
-
c.context&&c.context.tagName==d?(j="tag",v):(j="tag error",w)}return j="error",w}function v(a,b,c){return"endTag"!=a?(j="error",v):(q(c),s)}function w(a,b,c){return j="error",v(a,b,c)}function x(a,b,c){if("word"==a)return j="attribute",y;if("endTag"==a||"selfcloseTag"==a){var d=c.tagName,e=c.tagStart;return c.tagName=c.tagStart=null,"selfcloseTag"==a||g.autoSelfClosers.hasOwnProperty(d)?r(c,d):(r(c,d),c.context=new p(c,d,e==c.indented)),s}return j="error",x}function y(a,b,c){return"equals"==a?z:(g.allowMissing||(j="error"),x(a,b,c))}function z(a,b,c){return"string"==a?A:"word"==a&&g.allowUnquoted?(j="string",x):(j="error",x(a,b,c))}function A(a,b,c){return"string"==a?A:x(a,b,c)}var d=b.indentUnit,e=c.multilineTagIndentFactor||1,f=c.multilineTagIndentPastTag;null==f&&(f=!0);var i,j,g=c.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},h=c.alignCDATA;return k.isInText=!0,{startState:function(){return{tokenize:k,state:s,indented:0,tagName:null,tagStart:null,context:null}},token:function(a,b){if(!b.tagName&&a.sol()&&(b.indented=a.indentation()),a.eatSpace())return null;i=null;var c=b.tokenize(a,b);return(c||i)&&"comment"!=c&&(j=null,b.state=b.state(i||c,a,b),j&&(c="error"==j?c+" error":j)),c},indent:function(b,c,i){var j=b.context;if(b.tokenize.isInAttribute)return b.tagStart==b.indented?b.stringStartCol+1:b.indented+d;if(j&&j.noIndent)return a.Pass;if(b.tokenize!=l&&b.tokenize!=k)return i?i.match(/^(\s*)/)[0].length:0;if(b.tagName)return f?b.tagStart+b.tagName.length+2:b.tagStart+d*e;if(h&&/<!\[CDATA\[/.test(c))return 0;var m=c&&/^<(\/)?([\w_:\.-]*)/.exec(c);if(m&&m[1])for(;j;){if(j.tagName==m[2]){j=j.prev;break}if(!g.implicitlyClosed.hasOwnProperty(j.tagName))break;j=j.prev}else if(m)for(;j;){var n=g.contextGrabbers[j.tagName];if(!n||!n.hasOwnProperty(m[2]))break;j=j.prev}for(;j&&!j.startOfLine;)j=j.prev;return j?j.indent+d:0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:c.htmlMode?"html":"xml",helperType:c.htmlMode?"html":"xml"}}),a.defineMIME("text/xml","xml"),a.defineMIME("application/xml","xml"),a.mimeModes.hasOwnProperty("text/html")||a.defineMIME("text/html",{name:"xml",htmlMode:!0})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/lib/codemirror/{codemirror.css → lib/codemirror.css}
RENAMED
@@ -5,6 +5,7 @@
|
|
5 |
font-family: monospace;
|
6 |
height: 300px;
|
7 |
color: black;
|
|
|
8 |
}
|
9 |
|
10 |
/* PADDING */
|
@@ -41,57 +42,80 @@
|
|
41 |
|
42 |
/* CURSOR */
|
43 |
|
44 |
-
.CodeMirror
|
45 |
border-left: 1px solid black;
|
|
|
|
|
46 |
}
|
47 |
/* Shown when moving in bi-directional text */
|
48 |
.CodeMirror div.CodeMirror-secondarycursor {
|
49 |
border-left: 1px solid silver;
|
50 |
}
|
51 |
-
.
|
52 |
width: auto;
|
53 |
-
border: 0;
|
54 |
background: #7e7;
|
55 |
}
|
56 |
-
.
|
57 |
z-index: 1;
|
58 |
}
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
60 |
.cm-animate-fat-cursor {
|
61 |
width: auto;
|
62 |
border: 0;
|
63 |
-webkit-animation: blink 1.06s steps(1) infinite;
|
64 |
-moz-animation: blink 1.06s steps(1) infinite;
|
65 |
animation: blink 1.06s steps(1) infinite;
|
|
|
66 |
}
|
67 |
@-moz-keyframes blink {
|
68 |
-
0% {
|
69 |
-
50% { background:
|
70 |
-
100% {
|
71 |
}
|
72 |
@-webkit-keyframes blink {
|
73 |
-
0% {
|
74 |
-
50% { background:
|
75 |
-
100% {
|
76 |
}
|
77 |
@keyframes blink {
|
78 |
-
0% {
|
79 |
-
50% { background:
|
80 |
-
100% {
|
81 |
}
|
82 |
|
83 |
/* Can style cursor different in overwrite (non-insert) mode */
|
84 |
-
|
85 |
|
86 |
.cm-tab { display: inline-block; text-decoration: inherit; }
|
87 |
|
|
|
|
|
|
|
|
|
|
|
88 |
.CodeMirror-ruler {
|
89 |
border-left: 1px solid #ccc;
|
|
|
90 |
position: absolute;
|
91 |
}
|
92 |
|
93 |
/* DEFAULT THEME */
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
.cm-s-default .cm-keyword {color: #708;}
|
96 |
.cm-s-default .cm-atom {color: #219;}
|
97 |
.cm-s-default .cm-number {color: #164;}
|
@@ -101,7 +125,7 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
|
101 |
.cm-s-default .cm-property,
|
102 |
.cm-s-default .cm-operator {}
|
103 |
.cm-s-default .cm-variable-2 {color: #05a;}
|
104 |
-
.cm-s-default .cm-variable-3 {color: #085;}
|
105 |
.cm-s-default .cm-comment {color: #a50;}
|
106 |
.cm-s-default .cm-string {color: #a11;}
|
107 |
.cm-s-default .cm-string-2 {color: #f50;}
|
@@ -111,18 +135,9 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
|
111 |
.cm-s-default .cm-bracket {color: #997;}
|
112 |
.cm-s-default .cm-tag {color: #170;}
|
113 |
.cm-s-default .cm-attribute {color: #00c;}
|
114 |
-
.cm-s-default .cm-header {color: blue;}
|
115 |
-
.cm-s-default .cm-quote {color: #090;}
|
116 |
.cm-s-default .cm-hr {color: #999;}
|
117 |
.cm-s-default .cm-link {color: #00c;}
|
118 |
|
119 |
-
.cm-negative {color: #d44;}
|
120 |
-
.cm-positive {color: #292;}
|
121 |
-
.cm-header, .cm-strong {font-weight: bold;}
|
122 |
-
.cm-em {font-style: italic;}
|
123 |
-
.cm-link {text-decoration: underline;}
|
124 |
-
.cm-strikethrough {text-decoration: line-through;}
|
125 |
-
|
126 |
.cm-s-default .cm-error {color: #f00;}
|
127 |
.cm-invalidchar {color: #f00;}
|
128 |
|
@@ -130,8 +145,8 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
|
130 |
|
131 |
/* Default styles for common addons */
|
132 |
|
133 |
-
div.CodeMirror span.CodeMirror-matchingbracket {color: #
|
134 |
-
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #
|
135 |
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
136 |
.CodeMirror-activeline-background {background: #e8f2ff;}
|
137 |
|
@@ -162,7 +177,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
162 |
}
|
163 |
|
164 |
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
165 |
-
before
|
166 |
flickering artifacts. */
|
167 |
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
168 |
position: absolute;
|
@@ -188,32 +203,34 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
188 |
|
189 |
.CodeMirror-gutters {
|
190 |
position: absolute; left: 0; top: 0;
|
|
|
191 |
z-index: 3;
|
192 |
}
|
193 |
.CodeMirror-gutter {
|
194 |
white-space: normal;
|
195 |
height: 100%;
|
196 |
display: inline-block;
|
|
|
197 |
margin-bottom: -30px;
|
198 |
-
/* Hack to make IE7 behave */
|
199 |
-
*zoom:1;
|
200 |
-
*display:inline;
|
201 |
}
|
202 |
.CodeMirror-gutter-wrapper {
|
203 |
position: absolute;
|
204 |
z-index: 4;
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
.CodeMirror-gutter-elt {
|
208 |
position: absolute;
|
209 |
cursor: default;
|
210 |
z-index: 4;
|
211 |
}
|
212 |
-
.CodeMirror-gutter-wrapper {
|
213 |
-
|
214 |
-
-moz-user-select: none;
|
215 |
-
user-select: none;
|
216 |
-
}
|
217 |
|
218 |
.CodeMirror-lines {
|
219 |
cursor: text;
|
@@ -235,6 +252,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
235 |
position: relative;
|
236 |
overflow: visible;
|
237 |
-webkit-tap-highlight-color: transparent;
|
|
|
|
|
238 |
}
|
239 |
.CodeMirror-wrap pre {
|
240 |
word-wrap: break-word;
|
@@ -251,11 +270,13 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
251 |
.CodeMirror-linewidget {
|
252 |
position: relative;
|
253 |
z-index: 2;
|
254 |
-
|
255 |
}
|
256 |
|
257 |
.CodeMirror-widget {}
|
258 |
|
|
|
|
|
259 |
.CodeMirror-code {
|
260 |
outline: none;
|
261 |
}
|
@@ -277,19 +298,22 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
277 |
overflow: hidden;
|
278 |
visibility: hidden;
|
279 |
}
|
280 |
-
.CodeMirror-measure pre { position: static; }
|
281 |
|
282 |
-
.CodeMirror
|
283 |
position: absolute;
|
284 |
-
|
285 |
-
width: 0;
|
286 |
}
|
|
|
287 |
|
288 |
div.CodeMirror-cursors {
|
289 |
visibility: hidden;
|
290 |
position: relative;
|
291 |
z-index: 3;
|
292 |
}
|
|
|
|
|
|
|
|
|
293 |
.CodeMirror-focused div.CodeMirror-cursors {
|
294 |
visibility: visible;
|
295 |
}
|
@@ -297,17 +321,14 @@ div.CodeMirror-cursors {
|
|
297 |
.CodeMirror-selected { background: #d9d9d9; }
|
298 |
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
299 |
.CodeMirror-crosshair { cursor: crosshair; }
|
300 |
-
.CodeMirror ::selection { background: #d7d4f0; }
|
301 |
-
.CodeMirror ::-moz-selection { background: #d7d4f0; }
|
302 |
|
303 |
.cm-searching {
|
304 |
-
background: #ffa;
|
305 |
-
background: rgba(255, 255, 0, .4);
|
306 |
}
|
307 |
|
308 |
-
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
309 |
-
.CodeMirror span { *vertical-align: text-bottom; }
|
310 |
-
|
311 |
/* Used to force a border model for a node */
|
312 |
.cm-force-border { padding-right: .1px; }
|
313 |
|
5 |
font-family: monospace;
|
6 |
height: 300px;
|
7 |
color: black;
|
8 |
+
direction: ltr;
|
9 |
}
|
10 |
|
11 |
/* PADDING */
|
42 |
|
43 |
/* CURSOR */
|
44 |
|
45 |
+
.CodeMirror-cursor {
|
46 |
border-left: 1px solid black;
|
47 |
+
border-right: none;
|
48 |
+
width: 0;
|
49 |
}
|
50 |
/* Shown when moving in bi-directional text */
|
51 |
.CodeMirror div.CodeMirror-secondarycursor {
|
52 |
border-left: 1px solid silver;
|
53 |
}
|
54 |
+
.cm-fat-cursor .CodeMirror-cursor {
|
55 |
width: auto;
|
56 |
+
border: 0 !important;
|
57 |
background: #7e7;
|
58 |
}
|
59 |
+
.cm-fat-cursor div.CodeMirror-cursors {
|
60 |
z-index: 1;
|
61 |
}
|
62 |
+
.cm-fat-cursor-mark {
|
63 |
+
background-color: rgba(20, 255, 20, 0.5);
|
64 |
+
-webkit-animation: blink 1.06s steps(1) infinite;
|
65 |
+
-moz-animation: blink 1.06s steps(1) infinite;
|
66 |
+
animation: blink 1.06s steps(1) infinite;
|
67 |
+
}
|
68 |
.cm-animate-fat-cursor {
|
69 |
width: auto;
|
70 |
border: 0;
|
71 |
-webkit-animation: blink 1.06s steps(1) infinite;
|
72 |
-moz-animation: blink 1.06s steps(1) infinite;
|
73 |
animation: blink 1.06s steps(1) infinite;
|
74 |
+
background-color: #7e7;
|
75 |
}
|
76 |
@-moz-keyframes blink {
|
77 |
+
0% {}
|
78 |
+
50% { background-color: transparent; }
|
79 |
+
100% {}
|
80 |
}
|
81 |
@-webkit-keyframes blink {
|
82 |
+
0% {}
|
83 |
+
50% { background-color: transparent; }
|
84 |
+
100% {}
|
85 |
}
|
86 |
@keyframes blink {
|
87 |
+
0% {}
|
88 |
+
50% { background-color: transparent; }
|
89 |
+
100% {}
|
90 |
}
|
91 |
|
92 |
/* Can style cursor different in overwrite (non-insert) mode */
|
93 |
+
.CodeMirror-overwrite .CodeMirror-cursor {}
|
94 |
|
95 |
.cm-tab { display: inline-block; text-decoration: inherit; }
|
96 |
|
97 |
+
.CodeMirror-rulers {
|
98 |
+
position: absolute;
|
99 |
+
left: 0; right: 0; top: -50px; bottom: -20px;
|
100 |
+
overflow: hidden;
|
101 |
+
}
|
102 |
.CodeMirror-ruler {
|
103 |
border-left: 1px solid #ccc;
|
104 |
+
top: 0; bottom: 0;
|
105 |
position: absolute;
|
106 |
}
|
107 |
|
108 |
/* DEFAULT THEME */
|
109 |
|
110 |
+
.cm-s-default .cm-header {color: blue;}
|
111 |
+
.cm-s-default .cm-quote {color: #090;}
|
112 |
+
.cm-negative {color: #d44;}
|
113 |
+
.cm-positive {color: #292;}
|
114 |
+
.cm-header, .cm-strong {font-weight: bold;}
|
115 |
+
.cm-em {font-style: italic;}
|
116 |
+
.cm-link {text-decoration: underline;}
|
117 |
+
.cm-strikethrough {text-decoration: line-through;}
|
118 |
+
|
119 |
.cm-s-default .cm-keyword {color: #708;}
|
120 |
.cm-s-default .cm-atom {color: #219;}
|
121 |
.cm-s-default .cm-number {color: #164;}
|
125 |
.cm-s-default .cm-property,
|
126 |
.cm-s-default .cm-operator {}
|
127 |
.cm-s-default .cm-variable-2 {color: #05a;}
|
128 |
+
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
|
129 |
.cm-s-default .cm-comment {color: #a50;}
|
130 |
.cm-s-default .cm-string {color: #a11;}
|
131 |
.cm-s-default .cm-string-2 {color: #f50;}
|
135 |
.cm-s-default .cm-bracket {color: #997;}
|
136 |
.cm-s-default .cm-tag {color: #170;}
|
137 |
.cm-s-default .cm-attribute {color: #00c;}
|
|
|
|
|
138 |
.cm-s-default .cm-hr {color: #999;}
|
139 |
.cm-s-default .cm-link {color: #00c;}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
.cm-s-default .cm-error {color: #f00;}
|
142 |
.cm-invalidchar {color: #f00;}
|
143 |
|
145 |
|
146 |
/* Default styles for common addons */
|
147 |
|
148 |
+
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
|
149 |
+
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
150 |
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
151 |
.CodeMirror-activeline-background {background: #e8f2ff;}
|
152 |
|
177 |
}
|
178 |
|
179 |
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
180 |
+
before actual scrolling happens, thus preventing shaking and
|
181 |
flickering artifacts. */
|
182 |
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
183 |
position: absolute;
|
203 |
|
204 |
.CodeMirror-gutters {
|
205 |
position: absolute; left: 0; top: 0;
|
206 |
+
min-height: 100%;
|
207 |
z-index: 3;
|
208 |
}
|
209 |
.CodeMirror-gutter {
|
210 |
white-space: normal;
|
211 |
height: 100%;
|
212 |
display: inline-block;
|
213 |
+
vertical-align: top;
|
214 |
margin-bottom: -30px;
|
|
|
|
|
|
|
215 |
}
|
216 |
.CodeMirror-gutter-wrapper {
|
217 |
position: absolute;
|
218 |
z-index: 4;
|
219 |
+
background: none !important;
|
220 |
+
border: none !important;
|
221 |
+
}
|
222 |
+
.CodeMirror-gutter-background {
|
223 |
+
position: absolute;
|
224 |
+
top: 0; bottom: 0;
|
225 |
+
z-index: 4;
|
226 |
}
|
227 |
.CodeMirror-gutter-elt {
|
228 |
position: absolute;
|
229 |
cursor: default;
|
230 |
z-index: 4;
|
231 |
}
|
232 |
+
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
|
233 |
+
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
|
|
|
|
|
|
|
234 |
|
235 |
.CodeMirror-lines {
|
236 |
cursor: text;
|
252 |
position: relative;
|
253 |
overflow: visible;
|
254 |
-webkit-tap-highlight-color: transparent;
|
255 |
+
-webkit-font-variant-ligatures: contextual;
|
256 |
+
font-variant-ligatures: contextual;
|
257 |
}
|
258 |
.CodeMirror-wrap pre {
|
259 |
word-wrap: break-word;
|
270 |
.CodeMirror-linewidget {
|
271 |
position: relative;
|
272 |
z-index: 2;
|
273 |
+
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
274 |
}
|
275 |
|
276 |
.CodeMirror-widget {}
|
277 |
|
278 |
+
.CodeMirror-rtl pre { direction: rtl; }
|
279 |
+
|
280 |
.CodeMirror-code {
|
281 |
outline: none;
|
282 |
}
|
298 |
overflow: hidden;
|
299 |
visibility: hidden;
|
300 |
}
|
|
|
301 |
|
302 |
+
.CodeMirror-cursor {
|
303 |
position: absolute;
|
304 |
+
pointer-events: none;
|
|
|
305 |
}
|
306 |
+
.CodeMirror-measure pre { position: static; }
|
307 |
|
308 |
div.CodeMirror-cursors {
|
309 |
visibility: hidden;
|
310 |
position: relative;
|
311 |
z-index: 3;
|
312 |
}
|
313 |
+
div.CodeMirror-dragcursors {
|
314 |
+
visibility: visible;
|
315 |
+
}
|
316 |
+
|
317 |
.CodeMirror-focused div.CodeMirror-cursors {
|
318 |
visibility: visible;
|
319 |
}
|
321 |
.CodeMirror-selected { background: #d9d9d9; }
|
322 |
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
323 |
.CodeMirror-crosshair { cursor: crosshair; }
|
324 |
+
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
325 |
+
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
326 |
|
327 |
.cm-searching {
|
328 |
+
background-color: #ffa;
|
329 |
+
background-color: rgba(255, 255, 0, .4);
|
330 |
}
|
331 |
|
|
|
|
|
|
|
332 |
/* Used to force a border model for a node */
|
333 |
.cm-force-border { padding-right: .1px; }
|
334 |
|
inc/lib/codemirror/lib/codemirror.js
ADDED
@@ -0,0 +1,9685 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// This is CodeMirror (http://codemirror.net), a code editor
|
5 |
+
// implemented in JavaScript on top of the browser's DOM.
|
6 |
+
//
|
7 |
+
// You can find some technical background for some of the code below
|
8 |
+
// at http://marijnhaverbeke.nl/blog/#cm-internals .
|
9 |
+
|
10 |
+
(function (global, factory) {
|
11 |
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
12 |
+
typeof define === 'function' && define.amd ? define(factory) :
|
13 |
+
(global.CodeMirror = factory());
|
14 |
+
}(this, (function () { 'use strict';
|
15 |
+
|
16 |
+
// Kludges for bugs and behavior differences that can't be feature
|
17 |
+
// detected are enabled based on userAgent etc sniffing.
|
18 |
+
var userAgent = navigator.userAgent
|
19 |
+
var platform = navigator.platform
|
20 |
+
|
21 |
+
var gecko = /gecko\/\d/i.test(userAgent)
|
22 |
+
var ie_upto10 = /MSIE \d/.test(userAgent)
|
23 |
+
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent)
|
24 |
+
var edge = /Edge\/(\d+)/.exec(userAgent)
|
25 |
+
var ie = ie_upto10 || ie_11up || edge
|
26 |
+
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1])
|
27 |
+
var webkit = !edge && /WebKit\//.test(userAgent)
|
28 |
+
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent)
|
29 |
+
var chrome = !edge && /Chrome\//.test(userAgent)
|
30 |
+
var presto = /Opera\//.test(userAgent)
|
31 |
+
var safari = /Apple Computer/.test(navigator.vendor)
|
32 |
+
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent)
|
33 |
+
var phantom = /PhantomJS/.test(userAgent)
|
34 |
+
|
35 |
+
var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent)
|
36 |
+
var android = /Android/.test(userAgent)
|
37 |
+
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
38 |
+
var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent)
|
39 |
+
var mac = ios || /Mac/.test(platform)
|
40 |
+
var chromeOS = /\bCrOS\b/.test(userAgent)
|
41 |
+
var windows = /win/i.test(platform)
|
42 |
+
|
43 |
+
var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/)
|
44 |
+
if (presto_version) { presto_version = Number(presto_version[1]) }
|
45 |
+
if (presto_version && presto_version >= 15) { presto = false; webkit = true }
|
46 |
+
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
|
47 |
+
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11))
|
48 |
+
var captureRightClick = gecko || (ie && ie_version >= 9)
|
49 |
+
|
50 |
+
function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
|
51 |
+
|
52 |
+
var rmClass = function(node, cls) {
|
53 |
+
var current = node.className
|
54 |
+
var match = classTest(cls).exec(current)
|
55 |
+
if (match) {
|
56 |
+
var after = current.slice(match.index + match[0].length)
|
57 |
+
node.className = current.slice(0, match.index) + (after ? match[1] + after : "")
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
function removeChildren(e) {
|
62 |
+
for (var count = e.childNodes.length; count > 0; --count)
|
63 |
+
{ e.removeChild(e.firstChild) }
|
64 |
+
return e
|
65 |
+
}
|
66 |
+
|
67 |
+
function removeChildrenAndAdd(parent, e) {
|
68 |
+
return removeChildren(parent).appendChild(e)
|
69 |
+
}
|
70 |
+
|
71 |
+
function elt(tag, content, className, style) {
|
72 |
+
var e = document.createElement(tag)
|
73 |
+
if (className) { e.className = className }
|
74 |
+
if (style) { e.style.cssText = style }
|
75 |
+
if (typeof content == "string") { e.appendChild(document.createTextNode(content)) }
|
76 |
+
else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]) } }
|
77 |
+
return e
|
78 |
+
}
|
79 |
+
// wrapper for elt, which removes the elt from the accessibility tree
|
80 |
+
function eltP(tag, content, className, style) {
|
81 |
+
var e = elt(tag, content, className, style)
|
82 |
+
e.setAttribute("role", "presentation")
|
83 |
+
return e
|
84 |
+
}
|
85 |
+
|
86 |
+
var range
|
87 |
+
if (document.createRange) { range = function(node, start, end, endNode) {
|
88 |
+
var r = document.createRange()
|
89 |
+
r.setEnd(endNode || node, end)
|
90 |
+
r.setStart(node, start)
|
91 |
+
return r
|
92 |
+
} }
|
93 |
+
else { range = function(node, start, end) {
|
94 |
+
var r = document.body.createTextRange()
|
95 |
+
try { r.moveToElementText(node.parentNode) }
|
96 |
+
catch(e) { return r }
|
97 |
+
r.collapse(true)
|
98 |
+
r.moveEnd("character", end)
|
99 |
+
r.moveStart("character", start)
|
100 |
+
return r
|
101 |
+
} }
|
102 |
+
|
103 |
+
function contains(parent, child) {
|
104 |
+
if (child.nodeType == 3) // Android browser always returns false when child is a textnode
|
105 |
+
{ child = child.parentNode }
|
106 |
+
if (parent.contains)
|
107 |
+
{ return parent.contains(child) }
|
108 |
+
do {
|
109 |
+
if (child.nodeType == 11) { child = child.host }
|
110 |
+
if (child == parent) { return true }
|
111 |
+
} while (child = child.parentNode)
|
112 |
+
}
|
113 |
+
|
114 |
+
function activeElt() {
|
115 |
+
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
|
116 |
+
// IE < 10 will throw when accessed while the page is loading or in an iframe.
|
117 |
+
// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
|
118 |
+
var activeElement
|
119 |
+
try {
|
120 |
+
activeElement = document.activeElement
|
121 |
+
} catch(e) {
|
122 |
+
activeElement = document.body || null
|
123 |
+
}
|
124 |
+
while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
|
125 |
+
{ activeElement = activeElement.shadowRoot.activeElement }
|
126 |
+
return activeElement
|
127 |
+
}
|
128 |
+
|
129 |
+
function addClass(node, cls) {
|
130 |
+
var current = node.className
|
131 |
+
if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls }
|
132 |
+
}
|
133 |
+
function joinClasses(a, b) {
|
134 |
+
var as = a.split(" ")
|
135 |
+
for (var i = 0; i < as.length; i++)
|
136 |
+
{ if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i] } }
|
137 |
+
return b
|
138 |
+
}
|
139 |
+
|
140 |
+
var selectInput = function(node) { node.select() }
|
141 |
+
if (ios) // Mobile Safari apparently has a bug where select() is broken.
|
142 |
+
{ selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length } }
|
143 |
+
else if (ie) // Suppress mysterious IE10 errors
|
144 |
+
{ selectInput = function(node) { try { node.select() } catch(_e) {} } }
|
145 |
+
|
146 |
+
function bind(f) {
|
147 |
+
var args = Array.prototype.slice.call(arguments, 1)
|
148 |
+
return function(){return f.apply(null, args)}
|
149 |
+
}
|
150 |
+
|
151 |
+
function copyObj(obj, target, overwrite) {
|
152 |
+
if (!target) { target = {} }
|
153 |
+
for (var prop in obj)
|
154 |
+
{ if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
|
155 |
+
{ target[prop] = obj[prop] } }
|
156 |
+
return target
|
157 |
+
}
|
158 |
+
|
159 |
+
// Counts the column offset in a string, taking tabs into account.
|
160 |
+
// Used mostly to find indentation.
|
161 |
+
function countColumn(string, end, tabSize, startIndex, startValue) {
|
162 |
+
if (end == null) {
|
163 |
+
end = string.search(/[^\s\u00a0]/)
|
164 |
+
if (end == -1) { end = string.length }
|
165 |
+
}
|
166 |
+
for (var i = startIndex || 0, n = startValue || 0;;) {
|
167 |
+
var nextTab = string.indexOf("\t", i)
|
168 |
+
if (nextTab < 0 || nextTab >= end)
|
169 |
+
{ return n + (end - i) }
|
170 |
+
n += nextTab - i
|
171 |
+
n += tabSize - (n % tabSize)
|
172 |
+
i = nextTab + 1
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
var Delayed = function() {this.id = null};
|
177 |
+
Delayed.prototype.set = function (ms, f) {
|
178 |
+
clearTimeout(this.id)
|
179 |
+
this.id = setTimeout(f, ms)
|
180 |
+
};
|
181 |
+
|
182 |
+
function indexOf(array, elt) {
|
183 |
+
for (var i = 0; i < array.length; ++i)
|
184 |
+
{ if (array[i] == elt) { return i } }
|
185 |
+
return -1
|
186 |
+
}
|
187 |
+
|
188 |
+
// Number of pixels added to scroller and sizer to hide scrollbar
|
189 |
+
var scrollerGap = 30
|
190 |
+
|
191 |
+
// Returned or thrown by various protocols to signal 'I'm not
|
192 |
+
// handling this'.
|
193 |
+
var Pass = {toString: function(){return "CodeMirror.Pass"}}
|
194 |
+
|
195 |
+
// Reused option objects for setSelection & friends
|
196 |
+
var sel_dontScroll = {scroll: false};
|
197 |
+
var sel_mouse = {origin: "*mouse"};
|
198 |
+
var sel_move = {origin: "+move"};
|
199 |
+
// The inverse of countColumn -- find the offset that corresponds to
|
200 |
+
// a particular column.
|
201 |
+
function findColumn(string, goal, tabSize) {
|
202 |
+
for (var pos = 0, col = 0;;) {
|
203 |
+
var nextTab = string.indexOf("\t", pos)
|
204 |
+
if (nextTab == -1) { nextTab = string.length }
|
205 |
+
var skipped = nextTab - pos
|
206 |
+
if (nextTab == string.length || col + skipped >= goal)
|
207 |
+
{ return pos + Math.min(skipped, goal - col) }
|
208 |
+
col += nextTab - pos
|
209 |
+
col += tabSize - (col % tabSize)
|
210 |
+
pos = nextTab + 1
|
211 |
+
if (col >= goal) { return pos }
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
var spaceStrs = [""]
|
216 |
+
function spaceStr(n) {
|
217 |
+
while (spaceStrs.length <= n)
|
218 |
+
{ spaceStrs.push(lst(spaceStrs) + " ") }
|
219 |
+
return spaceStrs[n]
|
220 |
+
}
|
221 |
+
|
222 |
+
function lst(arr) { return arr[arr.length-1] }
|
223 |
+
|
224 |
+
function map(array, f) {
|
225 |
+
var out = []
|
226 |
+
for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i) }
|
227 |
+
return out
|
228 |
+
}
|
229 |
+
|
230 |
+
function insertSorted(array, value, score) {
|
231 |
+
var pos = 0, priority = score(value)
|
232 |
+
while (pos < array.length && score(array[pos]) <= priority) { pos++ }
|
233 |
+
array.splice(pos, 0, value)
|
234 |
+
}
|
235 |
+
|
236 |
+
function nothing() {}
|
237 |
+
|
238 |
+
function createObj(base, props) {
|
239 |
+
var inst
|
240 |
+
if (Object.create) {
|
241 |
+
inst = Object.create(base)
|
242 |
+
} else {
|
243 |
+
nothing.prototype = base
|
244 |
+
inst = new nothing()
|
245 |
+
}
|
246 |
+
if (props) { copyObj(props, inst) }
|
247 |
+
return inst
|
248 |
+
}
|
249 |
+
|
250 |
+
var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/
|
251 |
+
function isWordCharBasic(ch) {
|
252 |
+
return /\w/.test(ch) || ch > "\x80" &&
|
253 |
+
(ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
|
254 |
+
}
|
255 |
+
function isWordChar(ch, helper) {
|
256 |
+
if (!helper) { return isWordCharBasic(ch) }
|
257 |
+
if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true }
|
258 |
+
return helper.test(ch)
|
259 |
+
}
|
260 |
+
|
261 |
+
function isEmpty(obj) {
|
262 |
+
for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }
|
263 |
+
return true
|
264 |
+
}
|
265 |
+
|
266 |
+
// Extending unicode characters. A series of a non-extending char +
|
267 |
+
// any number of extending chars is treated as a single unit as far
|
268 |
+
// as editing and measuring is concerned. This is not fully correct,
|
269 |
+
// since some scripts/fonts/browsers also treat other configurations
|
270 |
+
// of code points as a group.
|
271 |
+
var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/
|
272 |
+
function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
|
273 |
+
|
274 |
+
// Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
|
275 |
+
function skipExtendingChars(str, pos, dir) {
|
276 |
+
while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir }
|
277 |
+
return pos
|
278 |
+
}
|
279 |
+
|
280 |
+
// Returns the value from the range [`from`; `to`] that satisfies
|
281 |
+
// `pred` and is closest to `from`. Assumes that at least `to`
|
282 |
+
// satisfies `pred`. Supports `from` being greater than `to`.
|
283 |
+
function findFirst(pred, from, to) {
|
284 |
+
// At any point we are certain `to` satisfies `pred`, don't know
|
285 |
+
// whether `from` does.
|
286 |
+
var dir = from > to ? -1 : 1
|
287 |
+
for (;;) {
|
288 |
+
if (from == to) { return from }
|
289 |
+
var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF)
|
290 |
+
if (mid == from) { return pred(mid) ? from : to }
|
291 |
+
if (pred(mid)) { to = mid }
|
292 |
+
else { from = mid + dir }
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
// The display handles the DOM integration, both for input reading
|
297 |
+
// and content drawing. It holds references to DOM nodes and
|
298 |
+
// display-related state.
|
299 |
+
|
300 |
+
function Display(place, doc, input) {
|
301 |
+
var d = this
|
302 |
+
this.input = input
|
303 |
+
|
304 |
+
// Covers bottom-right square when both scrollbars are present.
|
305 |
+
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler")
|
306 |
+
d.scrollbarFiller.setAttribute("cm-not-content", "true")
|
307 |
+
// Covers bottom of gutter when coverGutterNextToScrollbar is on
|
308 |
+
// and h scrollbar is present.
|
309 |
+
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler")
|
310 |
+
d.gutterFiller.setAttribute("cm-not-content", "true")
|
311 |
+
// Will contain the actual code, positioned to cover the viewport.
|
312 |
+
d.lineDiv = eltP("div", null, "CodeMirror-code")
|
313 |
+
// Elements are added to these to represent selection and cursors.
|
314 |
+
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1")
|
315 |
+
d.cursorDiv = elt("div", null, "CodeMirror-cursors")
|
316 |
+
// A visibility: hidden element used to find the size of things.
|
317 |
+
d.measure = elt("div", null, "CodeMirror-measure")
|
318 |
+
// When lines outside of the viewport are measured, they are drawn in this.
|
319 |
+
d.lineMeasure = elt("div", null, "CodeMirror-measure")
|
320 |
+
// Wraps everything that needs to exist inside the vertically-padded coordinate system
|
321 |
+
d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
|
322 |
+
null, "position: relative; outline: none")
|
323 |
+
var lines = eltP("div", [d.lineSpace], "CodeMirror-lines")
|
324 |
+
// Moved around its parent to cover visible view.
|
325 |
+
d.mover = elt("div", [lines], null, "position: relative")
|
326 |
+
// Set to the height of the document, allowing scrolling.
|
327 |
+
d.sizer = elt("div", [d.mover], "CodeMirror-sizer")
|
328 |
+
d.sizerWidth = null
|
329 |
+
// Behavior of elts with overflow: auto and padding is
|
330 |
+
// inconsistent across browsers. This is used to ensure the
|
331 |
+
// scrollable area is big enough.
|
332 |
+
d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;")
|
333 |
+
// Will contain the gutters, if any.
|
334 |
+
d.gutters = elt("div", null, "CodeMirror-gutters")
|
335 |
+
d.lineGutter = null
|
336 |
+
// Actual scrollable element.
|
337 |
+
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll")
|
338 |
+
d.scroller.setAttribute("tabIndex", "-1")
|
339 |
+
// The element in which the editor lives.
|
340 |
+
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror")
|
341 |
+
|
342 |
+
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
|
343 |
+
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0 }
|
344 |
+
if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true }
|
345 |
+
|
346 |
+
if (place) {
|
347 |
+
if (place.appendChild) { place.appendChild(d.wrapper) }
|
348 |
+
else { place(d.wrapper) }
|
349 |
+
}
|
350 |
+
|
351 |
+
// Current rendered range (may be bigger than the view window).
|
352 |
+
d.viewFrom = d.viewTo = doc.first
|
353 |
+
d.reportedViewFrom = d.reportedViewTo = doc.first
|
354 |
+
// Information about the rendered lines.
|
355 |
+
d.view = []
|
356 |
+
d.renderedView = null
|
357 |
+
// Holds info about a single rendered line when it was rendered
|
358 |
+
// for measurement, while not in view.
|
359 |
+
d.externalMeasured = null
|
360 |
+
// Empty space (in pixels) above the view
|
361 |
+
d.viewOffset = 0
|
362 |
+
d.lastWrapHeight = d.lastWrapWidth = 0
|
363 |
+
d.updateLineNumbers = null
|
364 |
+
|
365 |
+
d.nativeBarWidth = d.barHeight = d.barWidth = 0
|
366 |
+
d.scrollbarsClipped = false
|
367 |
+
|
368 |
+
// Used to only resize the line number gutter when necessary (when
|
369 |
+
// the amount of lines crosses a boundary that makes its width change)
|
370 |
+
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null
|
371 |
+
// Set to true when a non-horizontal-scrolling line widget is
|
372 |
+
// added. As an optimization, line widget aligning is skipped when
|
373 |
+
// this is false.
|
374 |
+
d.alignWidgets = false
|
375 |
+
|
376 |
+
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null
|
377 |
+
|
378 |
+
// Tracks the maximum line length so that the horizontal scrollbar
|
379 |
+
// can be kept static when scrolling.
|
380 |
+
d.maxLine = null
|
381 |
+
d.maxLineLength = 0
|
382 |
+
d.maxLineChanged = false
|
383 |
+
|
384 |
+
// Used for measuring wheel scrolling granularity
|
385 |
+
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null
|
386 |
+
|
387 |
+
// True when shift is held down.
|
388 |
+
d.shift = false
|
389 |
+
|
390 |
+
// Used to track whether anything happened since the context menu
|
391 |
+
// was opened.
|
392 |
+
d.selForContextMenu = null
|
393 |
+
|
394 |
+
d.activeTouch = null
|
395 |
+
|
396 |
+
input.init(d)
|
397 |
+
}
|
398 |
+
|
399 |
+
// Find the line object corresponding to the given line number.
|
400 |
+
function getLine(doc, n) {
|
401 |
+
n -= doc.first
|
402 |
+
if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") }
|
403 |
+
var chunk = doc
|
404 |
+
while (!chunk.lines) {
|
405 |
+
for (var i = 0;; ++i) {
|
406 |
+
var child = chunk.children[i], sz = child.chunkSize()
|
407 |
+
if (n < sz) { chunk = child; break }
|
408 |
+
n -= sz
|
409 |
+
}
|
410 |
+
}
|
411 |
+
return chunk.lines[n]
|
412 |
+
}
|
413 |
+
|
414 |
+
// Get the part of a document between two positions, as an array of
|
415 |
+
// strings.
|
416 |
+
function getBetween(doc, start, end) {
|
417 |
+
var out = [], n = start.line
|
418 |
+
doc.iter(start.line, end.line + 1, function (line) {
|
419 |
+
var text = line.text
|
420 |
+
if (n == end.line) { text = text.slice(0, end.ch) }
|
421 |
+
if (n == start.line) { text = text.slice(start.ch) }
|
422 |
+
out.push(text)
|
423 |
+
++n
|
424 |
+
})
|
425 |
+
return out
|
426 |
+
}
|
427 |
+
// Get the lines between from and to, as array of strings.
|
428 |
+
function getLines(doc, from, to) {
|
429 |
+
var out = []
|
430 |
+
doc.iter(from, to, function (line) { out.push(line.text) }) // iter aborts when callback returns truthy value
|
431 |
+
return out
|
432 |
+
}
|
433 |
+
|
434 |
+
// Update the height of a line, propagating the height change
|
435 |
+
// upwards to parent nodes.
|
436 |
+
function updateLineHeight(line, height) {
|
437 |
+
var diff = height - line.height
|
438 |
+
if (diff) { for (var n = line; n; n = n.parent) { n.height += diff } }
|
439 |
+
}
|
440 |
+
|
441 |
+
// Given a line object, find its line number by walking up through
|
442 |
+
// its parent links.
|
443 |
+
function lineNo(line) {
|
444 |
+
if (line.parent == null) { return null }
|
445 |
+
var cur = line.parent, no = indexOf(cur.lines, line)
|
446 |
+
for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
|
447 |
+
for (var i = 0;; ++i) {
|
448 |
+
if (chunk.children[i] == cur) { break }
|
449 |
+
no += chunk.children[i].chunkSize()
|
450 |
+
}
|
451 |
+
}
|
452 |
+
return no + cur.first
|
453 |
+
}
|
454 |
+
|
455 |
+
// Find the line at the given vertical position, using the height
|
456 |
+
// information in the document tree.
|
457 |
+
function lineAtHeight(chunk, h) {
|
458 |
+
var n = chunk.first
|
459 |
+
outer: do {
|
460 |
+
for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
|
461 |
+
var child = chunk.children[i$1], ch = child.height
|
462 |
+
if (h < ch) { chunk = child; continue outer }
|
463 |
+
h -= ch
|
464 |
+
n += child.chunkSize()
|
465 |
+
}
|
466 |
+
return n
|
467 |
+
} while (!chunk.lines)
|
468 |
+
var i = 0
|
469 |
+
for (; i < chunk.lines.length; ++i) {
|
470 |
+
var line = chunk.lines[i], lh = line.height
|
471 |
+
if (h < lh) { break }
|
472 |
+
h -= lh
|
473 |
+
}
|
474 |
+
return n + i
|
475 |
+
}
|
476 |
+
|
477 |
+
function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}
|
478 |
+
|
479 |
+
function lineNumberFor(options, i) {
|
480 |
+
return String(options.lineNumberFormatter(i + options.firstLineNumber))
|
481 |
+
}
|
482 |
+
|
483 |
+
// A Pos instance represents a position within the text.
|
484 |
+
function Pos(line, ch, sticky) {
|
485 |
+
if ( sticky === void 0 ) sticky = null;
|
486 |
+
|
487 |
+
if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
|
488 |
+
this.line = line
|
489 |
+
this.ch = ch
|
490 |
+
this.sticky = sticky
|
491 |
+
}
|
492 |
+
|
493 |
+
// Compare two positions, return 0 if they are the same, a negative
|
494 |
+
// number when a is less, and a positive number otherwise.
|
495 |
+
function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
|
496 |
+
|
497 |
+
function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
|
498 |
+
|
499 |
+
function copyPos(x) {return Pos(x.line, x.ch)}
|
500 |
+
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
|
501 |
+
function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
|
502 |
+
|
503 |
+
// Most of the external API clips given positions to make sure they
|
504 |
+
// actually exist within the document.
|
505 |
+
function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
|
506 |
+
function clipPos(doc, pos) {
|
507 |
+
if (pos.line < doc.first) { return Pos(doc.first, 0) }
|
508 |
+
var last = doc.first + doc.size - 1
|
509 |
+
if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }
|
510 |
+
return clipToLen(pos, getLine(doc, pos.line).text.length)
|
511 |
+
}
|
512 |
+
function clipToLen(pos, linelen) {
|
513 |
+
var ch = pos.ch
|
514 |
+
if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }
|
515 |
+
else if (ch < 0) { return Pos(pos.line, 0) }
|
516 |
+
else { return pos }
|
517 |
+
}
|
518 |
+
function clipPosArray(doc, array) {
|
519 |
+
var out = []
|
520 |
+
for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]) }
|
521 |
+
return out
|
522 |
+
}
|
523 |
+
|
524 |
+
// Optimize some code when these features are not used.
|
525 |
+
var sawReadOnlySpans = false;
|
526 |
+
var sawCollapsedSpans = false;
|
527 |
+
function seeReadOnlySpans() {
|
528 |
+
sawReadOnlySpans = true
|
529 |
+
}
|
530 |
+
|
531 |
+
function seeCollapsedSpans() {
|
532 |
+
sawCollapsedSpans = true
|
533 |
+
}
|
534 |
+
|
535 |
+
// TEXTMARKER SPANS
|
536 |
+
|
537 |
+
function MarkedSpan(marker, from, to) {
|
538 |
+
this.marker = marker
|
539 |
+
this.from = from; this.to = to
|
540 |
+
}
|
541 |
+
|
542 |
+
// Search an array of spans for a span matching the given marker.
|
543 |
+
function getMarkedSpanFor(spans, marker) {
|
544 |
+
if (spans) { for (var i = 0; i < spans.length; ++i) {
|
545 |
+
var span = spans[i]
|
546 |
+
if (span.marker == marker) { return span }
|
547 |
+
} }
|
548 |
+
}
|
549 |
+
// Remove a span from an array, returning undefined if no spans are
|
550 |
+
// left (we don't store arrays for lines without spans).
|
551 |
+
function removeMarkedSpan(spans, span) {
|
552 |
+
var r
|
553 |
+
for (var i = 0; i < spans.length; ++i)
|
554 |
+
{ if (spans[i] != span) { (r || (r = [])).push(spans[i]) } }
|
555 |
+
return r
|
556 |
+
}
|
557 |
+
// Add a span to a line.
|
558 |
+
function addMarkedSpan(line, span) {
|
559 |
+
line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]
|
560 |
+
span.marker.attachLine(line)
|
561 |
+
}
|
562 |
+
|
563 |
+
// Used for the algorithm that adjusts markers for a change in the
|
564 |
+
// document. These functions cut an array of spans at a given
|
565 |
+
// character position, returning an array of remaining chunks (or
|
566 |
+
// undefined if nothing remains).
|
567 |
+
function markedSpansBefore(old, startCh, isInsert) {
|
568 |
+
var nw
|
569 |
+
if (old) { for (var i = 0; i < old.length; ++i) {
|
570 |
+
var span = old[i], marker = span.marker
|
571 |
+
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh)
|
572 |
+
if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
|
573 |
+
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)
|
574 |
+
;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to))
|
575 |
+
}
|
576 |
+
} }
|
577 |
+
return nw
|
578 |
+
}
|
579 |
+
function markedSpansAfter(old, endCh, isInsert) {
|
580 |
+
var nw
|
581 |
+
if (old) { for (var i = 0; i < old.length; ++i) {
|
582 |
+
var span = old[i], marker = span.marker
|
583 |
+
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh)
|
584 |
+
if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
|
585 |
+
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)
|
586 |
+
;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
|
587 |
+
span.to == null ? null : span.to - endCh))
|
588 |
+
}
|
589 |
+
} }
|
590 |
+
return nw
|
591 |
+
}
|
592 |
+
|
593 |
+
// Given a change object, compute the new set of marker spans that
|
594 |
+
// cover the line in which the change took place. Removes spans
|
595 |
+
// entirely within the change, reconnects spans belonging to the
|
596 |
+
// same marker that appear on both sides of the change, and cuts off
|
597 |
+
// spans partially within the change. Returns an array of span
|
598 |
+
// arrays with one element for each line in (after) the change.
|
599 |
+
function stretchSpansOverChange(doc, change) {
|
600 |
+
if (change.full) { return null }
|
601 |
+
var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans
|
602 |
+
var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans
|
603 |
+
if (!oldFirst && !oldLast) { return null }
|
604 |
+
|
605 |
+
var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0
|
606 |
+
// Get the spans that 'stick out' on both sides
|
607 |
+
var first = markedSpansBefore(oldFirst, startCh, isInsert)
|
608 |
+
var last = markedSpansAfter(oldLast, endCh, isInsert)
|
609 |
+
|
610 |
+
// Next, merge those two ends
|
611 |
+
var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0)
|
612 |
+
if (first) {
|
613 |
+
// Fix up .to properties of first
|
614 |
+
for (var i = 0; i < first.length; ++i) {
|
615 |
+
var span = first[i]
|
616 |
+
if (span.to == null) {
|
617 |
+
var found = getMarkedSpanFor(last, span.marker)
|
618 |
+
if (!found) { span.to = startCh }
|
619 |
+
else if (sameLine) { span.to = found.to == null ? null : found.to + offset }
|
620 |
+
}
|
621 |
+
}
|
622 |
+
}
|
623 |
+
if (last) {
|
624 |
+
// Fix up .from in last (or move them into first in case of sameLine)
|
625 |
+
for (var i$1 = 0; i$1 < last.length; ++i$1) {
|
626 |
+
var span$1 = last[i$1]
|
627 |
+
if (span$1.to != null) { span$1.to += offset }
|
628 |
+
if (span$1.from == null) {
|
629 |
+
var found$1 = getMarkedSpanFor(first, span$1.marker)
|
630 |
+
if (!found$1) {
|
631 |
+
span$1.from = offset
|
632 |
+
if (sameLine) { (first || (first = [])).push(span$1) }
|
633 |
+
}
|
634 |
+
} else {
|
635 |
+
span$1.from += offset
|
636 |
+
if (sameLine) { (first || (first = [])).push(span$1) }
|
637 |
+
}
|
638 |
+
}
|
639 |
+
}
|
640 |
+
// Make sure we didn't create any zero-length spans
|
641 |
+
if (first) { first = clearEmptySpans(first) }
|
642 |
+
if (last && last != first) { last = clearEmptySpans(last) }
|
643 |
+
|
644 |
+
var newMarkers = [first]
|
645 |
+
if (!sameLine) {
|
646 |
+
// Fill gap with whole-line-spans
|
647 |
+
var gap = change.text.length - 2, gapMarkers
|
648 |
+
if (gap > 0 && first)
|
649 |
+
{ for (var i$2 = 0; i$2 < first.length; ++i$2)
|
650 |
+
{ if (first[i$2].to == null)
|
651 |
+
{ (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)) } } }
|
652 |
+
for (var i$3 = 0; i$3 < gap; ++i$3)
|
653 |
+
{ newMarkers.push(gapMarkers) }
|
654 |
+
newMarkers.push(last)
|
655 |
+
}
|
656 |
+
return newMarkers
|
657 |
+
}
|
658 |
+
|
659 |
+
// Remove spans that are empty and don't have a clearWhenEmpty
|
660 |
+
// option of false.
|
661 |
+
function clearEmptySpans(spans) {
|
662 |
+
for (var i = 0; i < spans.length; ++i) {
|
663 |
+
var span = spans[i]
|
664 |
+
if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
|
665 |
+
{ spans.splice(i--, 1) }
|
666 |
+
}
|
667 |
+
if (!spans.length) { return null }
|
668 |
+
return spans
|
669 |
+
}
|
670 |
+
|
671 |
+
// Used to 'clip' out readOnly ranges when making a change.
|
672 |
+
function removeReadOnlyRanges(doc, from, to) {
|
673 |
+
var markers = null
|
674 |
+
doc.iter(from.line, to.line + 1, function (line) {
|
675 |
+
if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
|
676 |
+
var mark = line.markedSpans[i].marker
|
677 |
+
if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
|
678 |
+
{ (markers || (markers = [])).push(mark) }
|
679 |
+
} }
|
680 |
+
})
|
681 |
+
if (!markers) { return null }
|
682 |
+
var parts = [{from: from, to: to}]
|
683 |
+
for (var i = 0; i < markers.length; ++i) {
|
684 |
+
var mk = markers[i], m = mk.find(0)
|
685 |
+
for (var j = 0; j < parts.length; ++j) {
|
686 |
+
var p = parts[j]
|
687 |
+
if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }
|
688 |
+
var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to)
|
689 |
+
if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
|
690 |
+
{ newParts.push({from: p.from, to: m.from}) }
|
691 |
+
if (dto > 0 || !mk.inclusiveRight && !dto)
|
692 |
+
{ newParts.push({from: m.to, to: p.to}) }
|
693 |
+
parts.splice.apply(parts, newParts)
|
694 |
+
j += newParts.length - 3
|
695 |
+
}
|
696 |
+
}
|
697 |
+
return parts
|
698 |
+
}
|
699 |
+
|
700 |
+
// Connect or disconnect spans from a line.
|
701 |
+
function detachMarkedSpans(line) {
|
702 |
+
var spans = line.markedSpans
|
703 |
+
if (!spans) { return }
|
704 |
+
for (var i = 0; i < spans.length; ++i)
|
705 |
+
{ spans[i].marker.detachLine(line) }
|
706 |
+
line.markedSpans = null
|
707 |
+
}
|
708 |
+
function attachMarkedSpans(line, spans) {
|
709 |
+
if (!spans) { return }
|
710 |
+
for (var i = 0; i < spans.length; ++i)
|
711 |
+
{ spans[i].marker.attachLine(line) }
|
712 |
+
line.markedSpans = spans
|
713 |
+
}
|
714 |
+
|
715 |
+
// Helpers used when computing which overlapping collapsed span
|
716 |
+
// counts as the larger one.
|
717 |
+
function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
|
718 |
+
function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
|
719 |
+
|
720 |
+
// Returns a number indicating which of two overlapping collapsed
|
721 |
+
// spans is larger (and thus includes the other). Falls back to
|
722 |
+
// comparing ids when the spans cover exactly the same range.
|
723 |
+
function compareCollapsedMarkers(a, b) {
|
724 |
+
var lenDiff = a.lines.length - b.lines.length
|
725 |
+
if (lenDiff != 0) { return lenDiff }
|
726 |
+
var aPos = a.find(), bPos = b.find()
|
727 |
+
var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b)
|
728 |
+
if (fromCmp) { return -fromCmp }
|
729 |
+
var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b)
|
730 |
+
if (toCmp) { return toCmp }
|
731 |
+
return b.id - a.id
|
732 |
+
}
|
733 |
+
|
734 |
+
// Find out whether a line ends or starts in a collapsed span. If
|
735 |
+
// so, return the marker for that span.
|
736 |
+
function collapsedSpanAtSide(line, start) {
|
737 |
+
var sps = sawCollapsedSpans && line.markedSpans, found
|
738 |
+
if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
|
739 |
+
sp = sps[i]
|
740 |
+
if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
|
741 |
+
(!found || compareCollapsedMarkers(found, sp.marker) < 0))
|
742 |
+
{ found = sp.marker }
|
743 |
+
} }
|
744 |
+
return found
|
745 |
+
}
|
746 |
+
function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
|
747 |
+
function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
|
748 |
+
|
749 |
+
function collapsedSpanAround(line, ch) {
|
750 |
+
var sps = sawCollapsedSpans && line.markedSpans, found
|
751 |
+
if (sps) { for (var i = 0; i < sps.length; ++i) {
|
752 |
+
var sp = sps[i]
|
753 |
+
if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) &&
|
754 |
+
(!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker }
|
755 |
+
} }
|
756 |
+
return found
|
757 |
+
}
|
758 |
+
|
759 |
+
// Test whether there exists a collapsed span that partially
|
760 |
+
// overlaps (covers the start or end, but not both) of a new span.
|
761 |
+
// Such overlap is not allowed.
|
762 |
+
function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
|
763 |
+
var line = getLine(doc, lineNo)
|
764 |
+
var sps = sawCollapsedSpans && line.markedSpans
|
765 |
+
if (sps) { for (var i = 0; i < sps.length; ++i) {
|
766 |
+
var sp = sps[i]
|
767 |
+
if (!sp.marker.collapsed) { continue }
|
768 |
+
var found = sp.marker.find(0)
|
769 |
+
var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker)
|
770 |
+
var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker)
|
771 |
+
if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }
|
772 |
+
if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
|
773 |
+
fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
|
774 |
+
{ return true }
|
775 |
+
} }
|
776 |
+
}
|
777 |
+
|
778 |
+
// A visual line is a line as drawn on the screen. Folding, for
|
779 |
+
// example, can cause multiple logical lines to appear on the same
|
780 |
+
// visual line. This finds the start of the visual line that the
|
781 |
+
// given line is part of (usually that is the line itself).
|
782 |
+
function visualLine(line) {
|
783 |
+
var merged
|
784 |
+
while (merged = collapsedSpanAtStart(line))
|
785 |
+
{ line = merged.find(-1, true).line }
|
786 |
+
return line
|
787 |
+
}
|
788 |
+
|
789 |
+
function visualLineEnd(line) {
|
790 |
+
var merged
|
791 |
+
while (merged = collapsedSpanAtEnd(line))
|
792 |
+
{ line = merged.find(1, true).line }
|
793 |
+
return line
|
794 |
+
}
|
795 |
+
|
796 |
+
// Returns an array of logical lines that continue the visual line
|
797 |
+
// started by the argument, or undefined if there are no such lines.
|
798 |
+
function visualLineContinued(line) {
|
799 |
+
var merged, lines
|
800 |
+
while (merged = collapsedSpanAtEnd(line)) {
|
801 |
+
line = merged.find(1, true).line
|
802 |
+
;(lines || (lines = [])).push(line)
|
803 |
+
}
|
804 |
+
return lines
|
805 |
+
}
|
806 |
+
|
807 |
+
// Get the line number of the start of the visual line that the
|
808 |
+
// given line number is part of.
|
809 |
+
function visualLineNo(doc, lineN) {
|
810 |
+
var line = getLine(doc, lineN), vis = visualLine(line)
|
811 |
+
if (line == vis) { return lineN }
|
812 |
+
return lineNo(vis)
|
813 |
+
}
|
814 |
+
|
815 |
+
// Get the line number of the start of the next visual line after
|
816 |
+
// the given line.
|
817 |
+
function visualLineEndNo(doc, lineN) {
|
818 |
+
if (lineN > doc.lastLine()) { return lineN }
|
819 |
+
var line = getLine(doc, lineN), merged
|
820 |
+
if (!lineIsHidden(doc, line)) { return lineN }
|
821 |
+
while (merged = collapsedSpanAtEnd(line))
|
822 |
+
{ line = merged.find(1, true).line }
|
823 |
+
return lineNo(line) + 1
|
824 |
+
}
|
825 |
+
|
826 |
+
// Compute whether a line is hidden. Lines count as hidden when they
|
827 |
+
// are part of a visual line that starts with another line, or when
|
828 |
+
// they are entirely covered by collapsed, non-widget span.
|
829 |
+
function lineIsHidden(doc, line) {
|
830 |
+
var sps = sawCollapsedSpans && line.markedSpans
|
831 |
+
if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
|
832 |
+
sp = sps[i]
|
833 |
+
if (!sp.marker.collapsed) { continue }
|
834 |
+
if (sp.from == null) { return true }
|
835 |
+
if (sp.marker.widgetNode) { continue }
|
836 |
+
if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
|
837 |
+
{ return true }
|
838 |
+
} }
|
839 |
+
}
|
840 |
+
function lineIsHiddenInner(doc, line, span) {
|
841 |
+
if (span.to == null) {
|
842 |
+
var end = span.marker.find(1, true)
|
843 |
+
return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
|
844 |
+
}
|
845 |
+
if (span.marker.inclusiveRight && span.to == line.text.length)
|
846 |
+
{ return true }
|
847 |
+
for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
|
848 |
+
sp = line.markedSpans[i]
|
849 |
+
if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
|
850 |
+
(sp.to == null || sp.to != span.from) &&
|
851 |
+
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
|
852 |
+
lineIsHiddenInner(doc, line, sp)) { return true }
|
853 |
+
}
|
854 |
+
}
|
855 |
+
|
856 |
+
// Find the height above the given line.
|
857 |
+
function heightAtLine(lineObj) {
|
858 |
+
lineObj = visualLine(lineObj)
|
859 |
+
|
860 |
+
var h = 0, chunk = lineObj.parent
|
861 |
+
for (var i = 0; i < chunk.lines.length; ++i) {
|
862 |
+
var line = chunk.lines[i]
|
863 |
+
if (line == lineObj) { break }
|
864 |
+
else { h += line.height }
|
865 |
+
}
|
866 |
+
for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
|
867 |
+
for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
|
868 |
+
var cur = p.children[i$1]
|
869 |
+
if (cur == chunk) { break }
|
870 |
+
else { h += cur.height }
|
871 |
+
}
|
872 |
+
}
|
873 |
+
return h
|
874 |
+
}
|
875 |
+
|
876 |
+
// Compute the character length of a line, taking into account
|
877 |
+
// collapsed ranges (see markText) that might hide parts, and join
|
878 |
+
// other lines onto it.
|
879 |
+
function lineLength(line) {
|
880 |
+
if (line.height == 0) { return 0 }
|
881 |
+
var len = line.text.length, merged, cur = line
|
882 |
+
while (merged = collapsedSpanAtStart(cur)) {
|
883 |
+
var found = merged.find(0, true)
|
884 |
+
cur = found.from.line
|
885 |
+
len += found.from.ch - found.to.ch
|
886 |
+
}
|
887 |
+
cur = line
|
888 |
+
while (merged = collapsedSpanAtEnd(cur)) {
|
889 |
+
var found$1 = merged.find(0, true)
|
890 |
+
len -= cur.text.length - found$1.from.ch
|
891 |
+
cur = found$1.to.line
|
892 |
+
len += cur.text.length - found$1.to.ch
|
893 |
+
}
|
894 |
+
return len
|
895 |
+
}
|
896 |
+
|
897 |
+
// Find the longest line in the document.
|
898 |
+
function findMaxLine(cm) {
|
899 |
+
var d = cm.display, doc = cm.doc
|
900 |
+
d.maxLine = getLine(doc, doc.first)
|
901 |
+
d.maxLineLength = lineLength(d.maxLine)
|
902 |
+
d.maxLineChanged = true
|
903 |
+
doc.iter(function (line) {
|
904 |
+
var len = lineLength(line)
|
905 |
+
if (len > d.maxLineLength) {
|
906 |
+
d.maxLineLength = len
|
907 |
+
d.maxLine = line
|
908 |
+
}
|
909 |
+
})
|
910 |
+
}
|
911 |
+
|
912 |
+
// BIDI HELPERS
|
913 |
+
|
914 |
+
function iterateBidiSections(order, from, to, f) {
|
915 |
+
if (!order) { return f(from, to, "ltr", 0) }
|
916 |
+
var found = false
|
917 |
+
for (var i = 0; i < order.length; ++i) {
|
918 |
+
var part = order[i]
|
919 |
+
if (part.from < to && part.to > from || from == to && part.to == from) {
|
920 |
+
f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i)
|
921 |
+
found = true
|
922 |
+
}
|
923 |
+
}
|
924 |
+
if (!found) { f(from, to, "ltr") }
|
925 |
+
}
|
926 |
+
|
927 |
+
var bidiOther = null
|
928 |
+
function getBidiPartAt(order, ch, sticky) {
|
929 |
+
var found
|
930 |
+
bidiOther = null
|
931 |
+
for (var i = 0; i < order.length; ++i) {
|
932 |
+
var cur = order[i]
|
933 |
+
if (cur.from < ch && cur.to > ch) { return i }
|
934 |
+
if (cur.to == ch) {
|
935 |
+
if (cur.from != cur.to && sticky == "before") { found = i }
|
936 |
+
else { bidiOther = i }
|
937 |
+
}
|
938 |
+
if (cur.from == ch) {
|
939 |
+
if (cur.from != cur.to && sticky != "before") { found = i }
|
940 |
+
else { bidiOther = i }
|
941 |
+
}
|
942 |
+
}
|
943 |
+
return found != null ? found : bidiOther
|
944 |
+
}
|
945 |
+
|
946 |
+
// Bidirectional ordering algorithm
|
947 |
+
// See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
|
948 |
+
// that this (partially) implements.
|
949 |
+
|
950 |
+
// One-char codes used for character types:
|
951 |
+
// L (L): Left-to-Right
|
952 |
+
// R (R): Right-to-Left
|
953 |
+
// r (AL): Right-to-Left Arabic
|
954 |
+
// 1 (EN): European Number
|
955 |
+
// + (ES): European Number Separator
|
956 |
+
// % (ET): European Number Terminator
|
957 |
+
// n (AN): Arabic Number
|
958 |
+
// , (CS): Common Number Separator
|
959 |
+
// m (NSM): Non-Spacing Mark
|
960 |
+
// b (BN): Boundary Neutral
|
961 |
+
// s (B): Paragraph Separator
|
962 |
+
// t (S): Segment Separator
|
963 |
+
// w (WS): Whitespace
|
964 |
+
// N (ON): Other Neutrals
|
965 |
+
|
966 |
+
// Returns null if characters are ordered as they appear
|
967 |
+
// (left-to-right), or an array of sections ({from, to, level}
|
968 |
+
// objects) in the order in which they occur visually.
|
969 |
+
var bidiOrdering = (function() {
|
970 |
+
// Character types for codepoints 0 to 0xff
|
971 |
+
var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"
|
972 |
+
// Character types for codepoints 0x600 to 0x6f9
|
973 |
+
var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111"
|
974 |
+
function charType(code) {
|
975 |
+
if (code <= 0xf7) { return lowTypes.charAt(code) }
|
976 |
+
else if (0x590 <= code && code <= 0x5f4) { return "R" }
|
977 |
+
else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
|
978 |
+
else if (0x6ee <= code && code <= 0x8ac) { return "r" }
|
979 |
+
else if (0x2000 <= code && code <= 0x200b) { return "w" }
|
980 |
+
else if (code == 0x200c) { return "b" }
|
981 |
+
else { return "L" }
|
982 |
+
}
|
983 |
+
|
984 |
+
var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/
|
985 |
+
var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/
|
986 |
+
|
987 |
+
function BidiSpan(level, from, to) {
|
988 |
+
this.level = level
|
989 |
+
this.from = from; this.to = to
|
990 |
+
}
|
991 |
+
|
992 |
+
return function(str, direction) {
|
993 |
+
var outerType = direction == "ltr" ? "L" : "R"
|
994 |
+
|
995 |
+
if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false }
|
996 |
+
var len = str.length, types = []
|
997 |
+
for (var i = 0; i < len; ++i)
|
998 |
+
{ types.push(charType(str.charCodeAt(i))) }
|
999 |
+
|
1000 |
+
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
1001 |
+
// change the type of the NSM to the type of the previous
|
1002 |
+
// character. If the NSM is at the start of the level run, it will
|
1003 |
+
// get the type of sor.
|
1004 |
+
for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
|
1005 |
+
var type = types[i$1]
|
1006 |
+
if (type == "m") { types[i$1] = prev }
|
1007 |
+
else { prev = type }
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
// W2. Search backwards from each instance of a European number
|
1011 |
+
// until the first strong type (R, L, AL, or sor) is found. If an
|
1012 |
+
// AL is found, change the type of the European number to Arabic
|
1013 |
+
// number.
|
1014 |
+
// W3. Change all ALs to R.
|
1015 |
+
for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
|
1016 |
+
var type$1 = types[i$2]
|
1017 |
+
if (type$1 == "1" && cur == "r") { types[i$2] = "n" }
|
1018 |
+
else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R" } }
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
// W4. A single European separator between two European numbers
|
1022 |
+
// changes to a European number. A single common separator between
|
1023 |
+
// two numbers of the same type changes to that type.
|
1024 |
+
for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
|
1025 |
+
var type$2 = types[i$3]
|
1026 |
+
if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1" }
|
1027 |
+
else if (type$2 == "," && prev$1 == types[i$3+1] &&
|
1028 |
+
(prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1 }
|
1029 |
+
prev$1 = type$2
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
// W5. A sequence of European terminators adjacent to European
|
1033 |
+
// numbers changes to all European numbers.
|
1034 |
+
// W6. Otherwise, separators and terminators change to Other
|
1035 |
+
// Neutral.
|
1036 |
+
for (var i$4 = 0; i$4 < len; ++i$4) {
|
1037 |
+
var type$3 = types[i$4]
|
1038 |
+
if (type$3 == ",") { types[i$4] = "N" }
|
1039 |
+
else if (type$3 == "%") {
|
1040 |
+
var end = (void 0)
|
1041 |
+
for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
|
1042 |
+
var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"
|
1043 |
+
for (var j = i$4; j < end; ++j) { types[j] = replace }
|
1044 |
+
i$4 = end - 1
|
1045 |
+
}
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
// W7. Search backwards from each instance of a European number
|
1049 |
+
// until the first strong type (R, L, or sor) is found. If an L is
|
1050 |
+
// found, then change the type of the European number to L.
|
1051 |
+
for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
|
1052 |
+
var type$4 = types[i$5]
|
1053 |
+
if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L" }
|
1054 |
+
else if (isStrong.test(type$4)) { cur$1 = type$4 }
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
// N1. A sequence of neutrals takes the direction of the
|
1058 |
+
// surrounding strong text if the text on both sides has the same
|
1059 |
+
// direction. European and Arabic numbers act as if they were R in
|
1060 |
+
// terms of their influence on neutrals. Start-of-level-run (sor)
|
1061 |
+
// and end-of-level-run (eor) are used at level run boundaries.
|
1062 |
+
// N2. Any remaining neutrals take the embedding direction.
|
1063 |
+
for (var i$6 = 0; i$6 < len; ++i$6) {
|
1064 |
+
if (isNeutral.test(types[i$6])) {
|
1065 |
+
var end$1 = (void 0)
|
1066 |
+
for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
|
1067 |
+
var before = (i$6 ? types[i$6-1] : outerType) == "L"
|
1068 |
+
var after = (end$1 < len ? types[end$1] : outerType) == "L"
|
1069 |
+
var replace$1 = before == after ? (before ? "L" : "R") : outerType
|
1070 |
+
for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1 }
|
1071 |
+
i$6 = end$1 - 1
|
1072 |
+
}
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
// Here we depart from the documented algorithm, in order to avoid
|
1076 |
+
// building up an actual levels array. Since there are only three
|
1077 |
+
// levels (0, 1, 2) in an implementation that doesn't take
|
1078 |
+
// explicit embedding into account, we can build up the order on
|
1079 |
+
// the fly, without following the level-based algorithm.
|
1080 |
+
var order = [], m
|
1081 |
+
for (var i$7 = 0; i$7 < len;) {
|
1082 |
+
if (countsAsLeft.test(types[i$7])) {
|
1083 |
+
var start = i$7
|
1084 |
+
for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
|
1085 |
+
order.push(new BidiSpan(0, start, i$7))
|
1086 |
+
} else {
|
1087 |
+
var pos = i$7, at = order.length
|
1088 |
+
for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
|
1089 |
+
for (var j$2 = pos; j$2 < i$7;) {
|
1090 |
+
if (countsAsNum.test(types[j$2])) {
|
1091 |
+
if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)) }
|
1092 |
+
var nstart = j$2
|
1093 |
+
for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
|
1094 |
+
order.splice(at, 0, new BidiSpan(2, nstart, j$2))
|
1095 |
+
pos = j$2
|
1096 |
+
} else { ++j$2 }
|
1097 |
+
}
|
1098 |
+
if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)) }
|
1099 |
+
}
|
1100 |
+
}
|
1101 |
+
if (direction == "ltr") {
|
1102 |
+
if (order[0].level == 1 && (m = str.match(/^\s+/))) {
|
1103 |
+
order[0].from = m[0].length
|
1104 |
+
order.unshift(new BidiSpan(0, 0, m[0].length))
|
1105 |
+
}
|
1106 |
+
if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
|
1107 |
+
lst(order).to -= m[0].length
|
1108 |
+
order.push(new BidiSpan(0, len - m[0].length, len))
|
1109 |
+
}
|
1110 |
+
}
|
1111 |
+
|
1112 |
+
return direction == "rtl" ? order.reverse() : order
|
1113 |
+
}
|
1114 |
+
})()
|
1115 |
+
|
1116 |
+
// Get the bidi ordering for the given line (and cache it). Returns
|
1117 |
+
// false for lines that are fully left-to-right, and an array of
|
1118 |
+
// BidiSpan objects otherwise.
|
1119 |
+
function getOrder(line, direction) {
|
1120 |
+
var order = line.order
|
1121 |
+
if (order == null) { order = line.order = bidiOrdering(line.text, direction) }
|
1122 |
+
return order
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
// EVENT HANDLING
|
1126 |
+
|
1127 |
+
// Lightweight event framework. on/off also work on DOM nodes,
|
1128 |
+
// registering native DOM handlers.
|
1129 |
+
|
1130 |
+
var noHandlers = []
|
1131 |
+
|
1132 |
+
var on = function(emitter, type, f) {
|
1133 |
+
if (emitter.addEventListener) {
|
1134 |
+
emitter.addEventListener(type, f, false)
|
1135 |
+
} else if (emitter.attachEvent) {
|
1136 |
+
emitter.attachEvent("on" + type, f)
|
1137 |
+
} else {
|
1138 |
+
var map = emitter._handlers || (emitter._handlers = {})
|
1139 |
+
map[type] = (map[type] || noHandlers).concat(f)
|
1140 |
+
}
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
function getHandlers(emitter, type) {
|
1144 |
+
return emitter._handlers && emitter._handlers[type] || noHandlers
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
function off(emitter, type, f) {
|
1148 |
+
if (emitter.removeEventListener) {
|
1149 |
+
emitter.removeEventListener(type, f, false)
|
1150 |
+
} else if (emitter.detachEvent) {
|
1151 |
+
emitter.detachEvent("on" + type, f)
|
1152 |
+
} else {
|
1153 |
+
var map = emitter._handlers, arr = map && map[type]
|
1154 |
+
if (arr) {
|
1155 |
+
var index = indexOf(arr, f)
|
1156 |
+
if (index > -1)
|
1157 |
+
{ map[type] = arr.slice(0, index).concat(arr.slice(index + 1)) }
|
1158 |
+
}
|
1159 |
+
}
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
function signal(emitter, type /*, values...*/) {
|
1163 |
+
var handlers = getHandlers(emitter, type)
|
1164 |
+
if (!handlers.length) { return }
|
1165 |
+
var args = Array.prototype.slice.call(arguments, 2)
|
1166 |
+
for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args) }
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
// The DOM events that CodeMirror handles can be overridden by
|
1170 |
+
// registering a (non-DOM) handler on the editor for the event name,
|
1171 |
+
// and preventDefault-ing the event in that handler.
|
1172 |
+
function signalDOMEvent(cm, e, override) {
|
1173 |
+
if (typeof e == "string")
|
1174 |
+
{ e = {type: e, preventDefault: function() { this.defaultPrevented = true }} }
|
1175 |
+
signal(cm, override || e.type, cm, e)
|
1176 |
+
return e_defaultPrevented(e) || e.codemirrorIgnore
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
function signalCursorActivity(cm) {
|
1180 |
+
var arr = cm._handlers && cm._handlers.cursorActivity
|
1181 |
+
if (!arr) { return }
|
1182 |
+
var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = [])
|
1183 |
+
for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)
|
1184 |
+
{ set.push(arr[i]) } }
|
1185 |
+
}
|
1186 |
+
|
1187 |
+
function hasHandler(emitter, type) {
|
1188 |
+
return getHandlers(emitter, type).length > 0
|
1189 |
+
}
|
1190 |
+
|
1191 |
+
// Add on and off methods to a constructor's prototype, to make
|
1192 |
+
// registering events on such objects more convenient.
|
1193 |
+
function eventMixin(ctor) {
|
1194 |
+
ctor.prototype.on = function(type, f) {on(this, type, f)}
|
1195 |
+
ctor.prototype.off = function(type, f) {off(this, type, f)}
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
// Due to the fact that we still support jurassic IE versions, some
|
1199 |
+
// compatibility wrappers are needed.
|
1200 |
+
|
1201 |
+
function e_preventDefault(e) {
|
1202 |
+
if (e.preventDefault) { e.preventDefault() }
|
1203 |
+
else { e.returnValue = false }
|
1204 |
+
}
|
1205 |
+
function e_stopPropagation(e) {
|
1206 |
+
if (e.stopPropagation) { e.stopPropagation() }
|
1207 |
+
else { e.cancelBubble = true }
|
1208 |
+
}
|
1209 |
+
function e_defaultPrevented(e) {
|
1210 |
+
return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
|
1211 |
+
}
|
1212 |
+
function e_stop(e) {e_preventDefault(e); e_stopPropagation(e)}
|
1213 |
+
|
1214 |
+
function e_target(e) {return e.target || e.srcElement}
|
1215 |
+
function e_button(e) {
|
1216 |
+
var b = e.which
|
1217 |
+
if (b == null) {
|
1218 |
+
if (e.button & 1) { b = 1 }
|
1219 |
+
else if (e.button & 2) { b = 3 }
|
1220 |
+
else if (e.button & 4) { b = 2 }
|
1221 |
+
}
|
1222 |
+
if (mac && e.ctrlKey && b == 1) { b = 3 }
|
1223 |
+
return b
|
1224 |
+
}
|
1225 |
+
|
1226 |
+
// Detect drag-and-drop
|
1227 |
+
var dragAndDrop = function() {
|
1228 |
+
// There is *some* kind of drag-and-drop support in IE6-8, but I
|
1229 |
+
// couldn't get it to work yet.
|
1230 |
+
if (ie && ie_version < 9) { return false }
|
1231 |
+
var div = elt('div')
|
1232 |
+
return "draggable" in div || "dragDrop" in div
|
1233 |
+
}()
|
1234 |
+
|
1235 |
+
var zwspSupported
|
1236 |
+
function zeroWidthElement(measure) {
|
1237 |
+
if (zwspSupported == null) {
|
1238 |
+
var test = elt("span", "\u200b")
|
1239 |
+
removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]))
|
1240 |
+
if (measure.firstChild.offsetHeight != 0)
|
1241 |
+
{ zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8) }
|
1242 |
+
}
|
1243 |
+
var node = zwspSupported ? elt("span", "\u200b") :
|
1244 |
+
elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px")
|
1245 |
+
node.setAttribute("cm-text", "")
|
1246 |
+
return node
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
// Feature-detect IE's crummy client rect reporting for bidi text
|
1250 |
+
var badBidiRects
|
1251 |
+
function hasBadBidiRects(measure) {
|
1252 |
+
if (badBidiRects != null) { return badBidiRects }
|
1253 |
+
var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"))
|
1254 |
+
var r0 = range(txt, 0, 1).getBoundingClientRect()
|
1255 |
+
var r1 = range(txt, 1, 2).getBoundingClientRect()
|
1256 |
+
removeChildren(measure)
|
1257 |
+
if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)
|
1258 |
+
return badBidiRects = (r1.right - r0.right < 3)
|
1259 |
+
}
|
1260 |
+
|
1261 |
+
// See if "".split is the broken IE version, if so, provide an
|
1262 |
+
// alternative way to split lines.
|
1263 |
+
var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
|
1264 |
+
var pos = 0, result = [], l = string.length
|
1265 |
+
while (pos <= l) {
|
1266 |
+
var nl = string.indexOf("\n", pos)
|
1267 |
+
if (nl == -1) { nl = string.length }
|
1268 |
+
var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl)
|
1269 |
+
var rt = line.indexOf("\r")
|
1270 |
+
if (rt != -1) {
|
1271 |
+
result.push(line.slice(0, rt))
|
1272 |
+
pos += rt + 1
|
1273 |
+
} else {
|
1274 |
+
result.push(line)
|
1275 |
+
pos = nl + 1
|
1276 |
+
}
|
1277 |
+
}
|
1278 |
+
return result
|
1279 |
+
} : function (string) { return string.split(/\r\n?|\n/); }
|
1280 |
+
|
1281 |
+
var hasSelection = window.getSelection ? function (te) {
|
1282 |
+
try { return te.selectionStart != te.selectionEnd }
|
1283 |
+
catch(e) { return false }
|
1284 |
+
} : function (te) {
|
1285 |
+
var range
|
1286 |
+
try {range = te.ownerDocument.selection.createRange()}
|
1287 |
+
catch(e) {}
|
1288 |
+
if (!range || range.parentElement() != te) { return false }
|
1289 |
+
return range.compareEndPoints("StartToEnd", range) != 0
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
var hasCopyEvent = (function () {
|
1293 |
+
var e = elt("div")
|
1294 |
+
if ("oncopy" in e) { return true }
|
1295 |
+
e.setAttribute("oncopy", "return;")
|
1296 |
+
return typeof e.oncopy == "function"
|
1297 |
+
})()
|
1298 |
+
|
1299 |
+
var badZoomedRects = null
|
1300 |
+
function hasBadZoomedRects(measure) {
|
1301 |
+
if (badZoomedRects != null) { return badZoomedRects }
|
1302 |
+
var node = removeChildrenAndAdd(measure, elt("span", "x"))
|
1303 |
+
var normal = node.getBoundingClientRect()
|
1304 |
+
var fromRange = range(node, 0, 1).getBoundingClientRect()
|
1305 |
+
return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
|
1306 |
+
}
|
1307 |
+
|
1308 |
+
var modes = {};
|
1309 |
+
var mimeModes = {};
|
1310 |
+
// Extra arguments are stored as the mode's dependencies, which is
|
1311 |
+
// used by (legacy) mechanisms like loadmode.js to automatically
|
1312 |
+
// load a mode. (Preferred mechanism is the require/define calls.)
|
1313 |
+
function defineMode(name, mode) {
|
1314 |
+
if (arguments.length > 2)
|
1315 |
+
{ mode.dependencies = Array.prototype.slice.call(arguments, 2) }
|
1316 |
+
modes[name] = mode
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
function defineMIME(mime, spec) {
|
1320 |
+
mimeModes[mime] = spec
|
1321 |
+
}
|
1322 |
+
|
1323 |
+
// Given a MIME type, a {name, ...options} config object, or a name
|
1324 |
+
// string, return a mode config object.
|
1325 |
+
function resolveMode(spec) {
|
1326 |
+
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
|
1327 |
+
spec = mimeModes[spec]
|
1328 |
+
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
|
1329 |
+
var found = mimeModes[spec.name]
|
1330 |
+
if (typeof found == "string") { found = {name: found} }
|
1331 |
+
spec = createObj(found, spec)
|
1332 |
+
spec.name = found.name
|
1333 |
+
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
|
1334 |
+
return resolveMode("application/xml")
|
1335 |
+
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
|
1336 |
+
return resolveMode("application/json")
|
1337 |
+
}
|
1338 |
+
if (typeof spec == "string") { return {name: spec} }
|
1339 |
+
else { return spec || {name: "null"} }
|
1340 |
+
}
|
1341 |
+
|
1342 |
+
// Given a mode spec (anything that resolveMode accepts), find and
|
1343 |
+
// initialize an actual mode object.
|
1344 |
+
function getMode(options, spec) {
|
1345 |
+
spec = resolveMode(spec)
|
1346 |
+
var mfactory = modes[spec.name]
|
1347 |
+
if (!mfactory) { return getMode(options, "text/plain") }
|
1348 |
+
var modeObj = mfactory(options, spec)
|
1349 |
+
if (modeExtensions.hasOwnProperty(spec.name)) {
|
1350 |
+
var exts = modeExtensions[spec.name]
|
1351 |
+
for (var prop in exts) {
|
1352 |
+
if (!exts.hasOwnProperty(prop)) { continue }
|
1353 |
+
if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop] }
|
1354 |
+
modeObj[prop] = exts[prop]
|
1355 |
+
}
|
1356 |
+
}
|
1357 |
+
modeObj.name = spec.name
|
1358 |
+
if (spec.helperType) { modeObj.helperType = spec.helperType }
|
1359 |
+
if (spec.modeProps) { for (var prop$1 in spec.modeProps)
|
1360 |
+
{ modeObj[prop$1] = spec.modeProps[prop$1] } }
|
1361 |
+
|
1362 |
+
return modeObj
|
1363 |
+
}
|
1364 |
+
|
1365 |
+
// This can be used to attach properties to mode objects from
|
1366 |
+
// outside the actual mode definition.
|
1367 |
+
var modeExtensions = {}
|
1368 |
+
function extendMode(mode, properties) {
|
1369 |
+
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {})
|
1370 |
+
copyObj(properties, exts)
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
function copyState(mode, state) {
|
1374 |
+
if (state === true) { return state }
|
1375 |
+
if (mode.copyState) { return mode.copyState(state) }
|
1376 |
+
var nstate = {}
|
1377 |
+
for (var n in state) {
|
1378 |
+
var val = state[n]
|
1379 |
+
if (val instanceof Array) { val = val.concat([]) }
|
1380 |
+
nstate[n] = val
|
1381 |
+
}
|
1382 |
+
return nstate
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
// Given a mode and a state (for that mode), find the inner mode and
|
1386 |
+
// state at the position that the state refers to.
|
1387 |
+
function innerMode(mode, state) {
|
1388 |
+
var info
|
1389 |
+
while (mode.innerMode) {
|
1390 |
+
info = mode.innerMode(state)
|
1391 |
+
if (!info || info.mode == mode) { break }
|
1392 |
+
state = info.state
|
1393 |
+
mode = info.mode
|
1394 |
+
}
|
1395 |
+
return info || {mode: mode, state: state}
|
1396 |
+
}
|
1397 |
+
|
1398 |
+
function startState(mode, a1, a2) {
|
1399 |
+
return mode.startState ? mode.startState(a1, a2) : true
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
// STRING STREAM
|
1403 |
+
|
1404 |
+
// Fed to the mode parsers, provides helper functions to make
|
1405 |
+
// parsers more succinct.
|
1406 |
+
|
1407 |
+
var StringStream = function(string, tabSize, lineOracle) {
|
1408 |
+
this.pos = this.start = 0
|
1409 |
+
this.string = string
|
1410 |
+
this.tabSize = tabSize || 8
|
1411 |
+
this.lastColumnPos = this.lastColumnValue = 0
|
1412 |
+
this.lineStart = 0
|
1413 |
+
this.lineOracle = lineOracle
|
1414 |
+
};
|
1415 |
+
|
1416 |
+
StringStream.prototype.eol = function () {return this.pos >= this.string.length};
|
1417 |
+
StringStream.prototype.sol = function () {return this.pos == this.lineStart};
|
1418 |
+
StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
|
1419 |
+
StringStream.prototype.next = function () {
|
1420 |
+
if (this.pos < this.string.length)
|
1421 |
+
{ return this.string.charAt(this.pos++) }
|
1422 |
+
};
|
1423 |
+
StringStream.prototype.eat = function (match) {
|
1424 |
+
var ch = this.string.charAt(this.pos)
|
1425 |
+
var ok
|
1426 |
+
if (typeof match == "string") { ok = ch == match }
|
1427 |
+
else { ok = ch && (match.test ? match.test(ch) : match(ch)) }
|
1428 |
+
if (ok) {++this.pos; return ch}
|
1429 |
+
};
|
1430 |
+
StringStream.prototype.eatWhile = function (match) {
|
1431 |
+
var start = this.pos
|
1432 |
+
while (this.eat(match)){}
|
1433 |
+
return this.pos > start
|
1434 |
+
};
|
1435 |
+
StringStream.prototype.eatSpace = function () {
|
1436 |
+
var this$1 = this;
|
1437 |
+
|
1438 |
+
var start = this.pos
|
1439 |
+
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos }
|
1440 |
+
return this.pos > start
|
1441 |
+
};
|
1442 |
+
StringStream.prototype.skipToEnd = function () {this.pos = this.string.length};
|
1443 |
+
StringStream.prototype.skipTo = function (ch) {
|
1444 |
+
var found = this.string.indexOf(ch, this.pos)
|
1445 |
+
if (found > -1) {this.pos = found; return true}
|
1446 |
+
};
|
1447 |
+
StringStream.prototype.backUp = function (n) {this.pos -= n};
|
1448 |
+
StringStream.prototype.column = function () {
|
1449 |
+
if (this.lastColumnPos < this.start) {
|
1450 |
+
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue)
|
1451 |
+
this.lastColumnPos = this.start
|
1452 |
+
}
|
1453 |
+
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
|
1454 |
+
};
|
1455 |
+
StringStream.prototype.indentation = function () {
|
1456 |
+
return countColumn(this.string, null, this.tabSize) -
|
1457 |
+
(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
|
1458 |
+
};
|
1459 |
+
StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
|
1460 |
+
if (typeof pattern == "string") {
|
1461 |
+
var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }
|
1462 |
+
var substr = this.string.substr(this.pos, pattern.length)
|
1463 |
+
if (cased(substr) == cased(pattern)) {
|
1464 |
+
if (consume !== false) { this.pos += pattern.length }
|
1465 |
+
return true
|
1466 |
+
}
|
1467 |
+
} else {
|
1468 |
+
var match = this.string.slice(this.pos).match(pattern)
|
1469 |
+
if (match && match.index > 0) { return null }
|
1470 |
+
if (match && consume !== false) { this.pos += match[0].length }
|
1471 |
+
return match
|
1472 |
+
}
|
1473 |
+
};
|
1474 |
+
StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
|
1475 |
+
StringStream.prototype.hideFirstChars = function (n, inner) {
|
1476 |
+
this.lineStart += n
|
1477 |
+
try { return inner() }
|
1478 |
+
finally { this.lineStart -= n }
|
1479 |
+
};
|
1480 |
+
StringStream.prototype.lookAhead = function (n) {
|
1481 |
+
var oracle = this.lineOracle
|
1482 |
+
return oracle && oracle.lookAhead(n)
|
1483 |
+
};
|
1484 |
+
StringStream.prototype.baseToken = function () {
|
1485 |
+
var oracle = this.lineOracle
|
1486 |
+
return oracle && oracle.baseToken(this.pos)
|
1487 |
+
};
|
1488 |
+
|
1489 |
+
var SavedContext = function(state, lookAhead) {
|
1490 |
+
this.state = state
|
1491 |
+
this.lookAhead = lookAhead
|
1492 |
+
};
|
1493 |
+
|
1494 |
+
var Context = function(doc, state, line, lookAhead) {
|
1495 |
+
this.state = state
|
1496 |
+
this.doc = doc
|
1497 |
+
this.line = line
|
1498 |
+
this.maxLookAhead = lookAhead || 0
|
1499 |
+
this.baseTokens = null
|
1500 |
+
this.baseTokenPos = 1
|
1501 |
+
};
|
1502 |
+
|
1503 |
+
Context.prototype.lookAhead = function (n) {
|
1504 |
+
var line = this.doc.getLine(this.line + n)
|
1505 |
+
if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n }
|
1506 |
+
return line
|
1507 |
+
};
|
1508 |
+
|
1509 |
+
Context.prototype.baseToken = function (n) {
|
1510 |
+
var this$1 = this;
|
1511 |
+
|
1512 |
+
if (!this.baseTokens) { return null }
|
1513 |
+
while (this.baseTokens[this.baseTokenPos] <= n)
|
1514 |
+
{ this$1.baseTokenPos += 2 }
|
1515 |
+
var type = this.baseTokens[this.baseTokenPos + 1]
|
1516 |
+
return {type: type && type.replace(/( |^)overlay .*/, ""),
|
1517 |
+
size: this.baseTokens[this.baseTokenPos] - n}
|
1518 |
+
};
|
1519 |
+
|
1520 |
+
Context.prototype.nextLine = function () {
|
1521 |
+
this.line++
|
1522 |
+
if (this.maxLookAhead > 0) { this.maxLookAhead-- }
|
1523 |
+
};
|
1524 |
+
|
1525 |
+
Context.fromSaved = function (doc, saved, line) {
|
1526 |
+
if (saved instanceof SavedContext)
|
1527 |
+
{ return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) }
|
1528 |
+
else
|
1529 |
+
{ return new Context(doc, copyState(doc.mode, saved), line) }
|
1530 |
+
};
|
1531 |
+
|
1532 |
+
Context.prototype.save = function (copy) {
|
1533 |
+
var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state
|
1534 |
+
return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state
|
1535 |
+
};
|
1536 |
+
|
1537 |
+
|
1538 |
+
// Compute a style array (an array starting with a mode generation
|
1539 |
+
// -- for invalidation -- followed by pairs of end positions and
|
1540 |
+
// style strings), which is used to highlight the tokens on the
|
1541 |
+
// line.
|
1542 |
+
function highlightLine(cm, line, context, forceToEnd) {
|
1543 |
+
// A styles array always starts with a number identifying the
|
1544 |
+
// mode/overlays that it is based on (for easy invalidation).
|
1545 |
+
var st = [cm.state.modeGen], lineClasses = {}
|
1546 |
+
// Compute the base array of styles
|
1547 |
+
runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); },
|
1548 |
+
lineClasses, forceToEnd)
|
1549 |
+
var state = context.state
|
1550 |
+
|
1551 |
+
// Run overlays, adjust style array.
|
1552 |
+
var loop = function ( o ) {
|
1553 |
+
context.baseTokens = st
|
1554 |
+
var overlay = cm.state.overlays[o], i = 1, at = 0
|
1555 |
+
context.state = true
|
1556 |
+
runMode(cm, line.text, overlay.mode, context, function (end, style) {
|
1557 |
+
var start = i
|
1558 |
+
// Ensure there's a token end at the current position, and that i points at it
|
1559 |
+
while (at < end) {
|
1560 |
+
var i_end = st[i]
|
1561 |
+
if (i_end > end)
|
1562 |
+
{ st.splice(i, 1, end, st[i+1], i_end) }
|
1563 |
+
i += 2
|
1564 |
+
at = Math.min(end, i_end)
|
1565 |
+
}
|
1566 |
+
if (!style) { return }
|
1567 |
+
if (overlay.opaque) {
|
1568 |
+
st.splice(start, i - start, end, "overlay " + style)
|
1569 |
+
i = start + 2
|
1570 |
+
} else {
|
1571 |
+
for (; start < i; start += 2) {
|
1572 |
+
var cur = st[start+1]
|
1573 |
+
st[start+1] = (cur ? cur + " " : "") + "overlay " + style
|
1574 |
+
}
|
1575 |
+
}
|
1576 |
+
}, lineClasses)
|
1577 |
+
context.state = state
|
1578 |
+
context.baseTokens = null
|
1579 |
+
context.baseTokenPos = 1
|
1580 |
+
};
|
1581 |
+
|
1582 |
+
for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
|
1583 |
+
|
1584 |
+
return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
function getLineStyles(cm, line, updateFrontier) {
|
1588 |
+
if (!line.styles || line.styles[0] != cm.state.modeGen) {
|
1589 |
+
var context = getContextBefore(cm, lineNo(line))
|
1590 |
+
var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state)
|
1591 |
+
var result = highlightLine(cm, line, context)
|
1592 |
+
if (resetState) { context.state = resetState }
|
1593 |
+
line.stateAfter = context.save(!resetState)
|
1594 |
+
line.styles = result.styles
|
1595 |
+
if (result.classes) { line.styleClasses = result.classes }
|
1596 |
+
else if (line.styleClasses) { line.styleClasses = null }
|
1597 |
+
if (updateFrontier === cm.doc.highlightFrontier)
|
1598 |
+
{ cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier) }
|
1599 |
+
}
|
1600 |
+
return line.styles
|
1601 |
+
}
|
1602 |
+
|
1603 |
+
function getContextBefore(cm, n, precise) {
|
1604 |
+
var doc = cm.doc, display = cm.display
|
1605 |
+
if (!doc.mode.startState) { return new Context(doc, true, n) }
|
1606 |
+
var start = findStartLine(cm, n, precise)
|
1607 |
+
var saved = start > doc.first && getLine(doc, start - 1).stateAfter
|
1608 |
+
var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start)
|
1609 |
+
|
1610 |
+
doc.iter(start, n, function (line) {
|
1611 |
+
processLine(cm, line.text, context)
|
1612 |
+
var pos = context.line
|
1613 |
+
line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null
|
1614 |
+
context.nextLine()
|
1615 |
+
})
|
1616 |
+
if (precise) { doc.modeFrontier = context.line }
|
1617 |
+
return context
|
1618 |
+
}
|
1619 |
+
|
1620 |
+
// Lightweight form of highlight -- proceed over this line and
|
1621 |
+
// update state, but don't save a style array. Used for lines that
|
1622 |
+
// aren't currently visible.
|
1623 |
+
function processLine(cm, text, context, startAt) {
|
1624 |
+
var mode = cm.doc.mode
|
1625 |
+
var stream = new StringStream(text, cm.options.tabSize, context)
|
1626 |
+
stream.start = stream.pos = startAt || 0
|
1627 |
+
if (text == "") { callBlankLine(mode, context.state) }
|
1628 |
+
while (!stream.eol()) {
|
1629 |
+
readToken(mode, stream, context.state)
|
1630 |
+
stream.start = stream.pos
|
1631 |
+
}
|
1632 |
+
}
|
1633 |
+
|
1634 |
+
function callBlankLine(mode, state) {
|
1635 |
+
if (mode.blankLine) { return mode.blankLine(state) }
|
1636 |
+
if (!mode.innerMode) { return }
|
1637 |
+
var inner = innerMode(mode, state)
|
1638 |
+
if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }
|
1639 |
+
}
|
1640 |
+
|
1641 |
+
function readToken(mode, stream, state, inner) {
|
1642 |
+
for (var i = 0; i < 10; i++) {
|
1643 |
+
if (inner) { inner[0] = innerMode(mode, state).mode }
|
1644 |
+
var style = mode.token(stream, state)
|
1645 |
+
if (stream.pos > stream.start) { return style }
|
1646 |
+
}
|
1647 |
+
throw new Error("Mode " + mode.name + " failed to advance stream.")
|
1648 |
+
}
|
1649 |
+
|
1650 |
+
var Token = function(stream, type, state) {
|
1651 |
+
this.start = stream.start; this.end = stream.pos
|
1652 |
+
this.string = stream.current()
|
1653 |
+
this.type = type || null
|
1654 |
+
this.state = state
|
1655 |
+
};
|
1656 |
+
|
1657 |
+
// Utility for getTokenAt and getLineTokens
|
1658 |
+
function takeToken(cm, pos, precise, asArray) {
|
1659 |
+
var doc = cm.doc, mode = doc.mode, style
|
1660 |
+
pos = clipPos(doc, pos)
|
1661 |
+
var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise)
|
1662 |
+
var stream = new StringStream(line.text, cm.options.tabSize, context), tokens
|
1663 |
+
if (asArray) { tokens = [] }
|
1664 |
+
while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
|
1665 |
+
stream.start = stream.pos
|
1666 |
+
style = readToken(mode, stream, context.state)
|
1667 |
+
if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))) }
|
1668 |
+
}
|
1669 |
+
return asArray ? tokens : new Token(stream, style, context.state)
|
1670 |
+
}
|
1671 |
+
|
1672 |
+
function extractLineClasses(type, output) {
|
1673 |
+
if (type) { for (;;) {
|
1674 |
+
var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/)
|
1675 |
+
if (!lineClass) { break }
|
1676 |
+
type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length)
|
1677 |
+
var prop = lineClass[1] ? "bgClass" : "textClass"
|
1678 |
+
if (output[prop] == null)
|
1679 |
+
{ output[prop] = lineClass[2] }
|
1680 |
+
else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
|
1681 |
+
{ output[prop] += " " + lineClass[2] }
|
1682 |
+
} }
|
1683 |
+
return type
|
1684 |
+
}
|
1685 |
+
|
1686 |
+
// Run the given mode's parser over a line, calling f for each token.
|
1687 |
+
function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
|
1688 |
+
var flattenSpans = mode.flattenSpans
|
1689 |
+
if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans }
|
1690 |
+
var curStart = 0, curStyle = null
|
1691 |
+
var stream = new StringStream(text, cm.options.tabSize, context), style
|
1692 |
+
var inner = cm.options.addModeClass && [null]
|
1693 |
+
if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses) }
|
1694 |
+
while (!stream.eol()) {
|
1695 |
+
if (stream.pos > cm.options.maxHighlightLength) {
|
1696 |
+
flattenSpans = false
|
1697 |
+
if (forceToEnd) { processLine(cm, text, context, stream.pos) }
|
1698 |
+
stream.pos = text.length
|
1699 |
+
style = null
|
1700 |
+
} else {
|
1701 |
+
style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses)
|
1702 |
+
}
|
1703 |
+
if (inner) {
|
1704 |
+
var mName = inner[0].name
|
1705 |
+
if (mName) { style = "m-" + (style ? mName + " " + style : mName) }
|
1706 |
+
}
|
1707 |
+
if (!flattenSpans || curStyle != style) {
|
1708 |
+
while (curStart < stream.start) {
|
1709 |
+
curStart = Math.min(stream.start, curStart + 5000)
|
1710 |
+
f(curStart, curStyle)
|
1711 |
+
}
|
1712 |
+
curStyle = style
|
1713 |
+
}
|
1714 |
+
stream.start = stream.pos
|
1715 |
+
}
|
1716 |
+
while (curStart < stream.pos) {
|
1717 |
+
// Webkit seems to refuse to render text nodes longer than 57444
|
1718 |
+
// characters, and returns inaccurate measurements in nodes
|
1719 |
+
// starting around 5000 chars.
|
1720 |
+
var pos = Math.min(stream.pos, curStart + 5000)
|
1721 |
+
f(pos, curStyle)
|
1722 |
+
curStart = pos
|
1723 |
+
}
|
1724 |
+
}
|
1725 |
+
|
1726 |
+
// Finds the line to start with when starting a parse. Tries to
|
1727 |
+
// find a line with a stateAfter, so that it can start with a
|
1728 |
+
// valid state. If that fails, it returns the line with the
|
1729 |
+
// smallest indentation, which tends to need the least context to
|
1730 |
+
// parse correctly.
|
1731 |
+
function findStartLine(cm, n, precise) {
|
1732 |
+
var minindent, minline, doc = cm.doc
|
1733 |
+
var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100)
|
1734 |
+
for (var search = n; search > lim; --search) {
|
1735 |
+
if (search <= doc.first) { return doc.first }
|
1736 |
+
var line = getLine(doc, search - 1), after = line.stateAfter
|
1737 |
+
if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier))
|
1738 |
+
{ return search }
|
1739 |
+
var indented = countColumn(line.text, null, cm.options.tabSize)
|
1740 |
+
if (minline == null || minindent > indented) {
|
1741 |
+
minline = search - 1
|
1742 |
+
minindent = indented
|
1743 |
+
}
|
1744 |
+
}
|
1745 |
+
return minline
|
1746 |
+
}
|
1747 |
+
|
1748 |
+
function retreatFrontier(doc, n) {
|
1749 |
+
doc.modeFrontier = Math.min(doc.modeFrontier, n)
|
1750 |
+
if (doc.highlightFrontier < n - 10) { return }
|
1751 |
+
var start = doc.first
|
1752 |
+
for (var line = n - 1; line > start; line--) {
|
1753 |
+
var saved = getLine(doc, line).stateAfter
|
1754 |
+
// change is on 3
|
1755 |
+
// state on line 1 looked ahead 2 -- so saw 3
|
1756 |
+
// test 1 + 2 < 3 should cover this
|
1757 |
+
if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {
|
1758 |
+
start = line + 1
|
1759 |
+
break
|
1760 |
+
}
|
1761 |
+
}
|
1762 |
+
doc.highlightFrontier = Math.min(doc.highlightFrontier, start)
|
1763 |
+
}
|
1764 |
+
|
1765 |
+
// LINE DATA STRUCTURE
|
1766 |
+
|
1767 |
+
// Line objects. These hold state related to a line, including
|
1768 |
+
// highlighting info (the styles array).
|
1769 |
+
var Line = function(text, markedSpans, estimateHeight) {
|
1770 |
+
this.text = text
|
1771 |
+
attachMarkedSpans(this, markedSpans)
|
1772 |
+
this.height = estimateHeight ? estimateHeight(this) : 1
|
1773 |
+
};
|
1774 |
+
|
1775 |
+
Line.prototype.lineNo = function () { return lineNo(this) };
|
1776 |
+
eventMixin(Line)
|
1777 |
+
|
1778 |
+
// Change the content (text, markers) of a line. Automatically
|
1779 |
+
// invalidates cached information and tries to re-estimate the
|
1780 |
+
// line's height.
|
1781 |
+
function updateLine(line, text, markedSpans, estimateHeight) {
|
1782 |
+
line.text = text
|
1783 |
+
if (line.stateAfter) { line.stateAfter = null }
|
1784 |
+
if (line.styles) { line.styles = null }
|
1785 |
+
if (line.order != null) { line.order = null }
|
1786 |
+
detachMarkedSpans(line)
|
1787 |
+
attachMarkedSpans(line, markedSpans)
|
1788 |
+
var estHeight = estimateHeight ? estimateHeight(line) : 1
|
1789 |
+
if (estHeight != line.height) { updateLineHeight(line, estHeight) }
|
1790 |
+
}
|
1791 |
+
|
1792 |
+
// Detach a line from the document tree and its markers.
|
1793 |
+
function cleanUpLine(line) {
|
1794 |
+
line.parent = null
|
1795 |
+
detachMarkedSpans(line)
|
1796 |
+
}
|
1797 |
+
|
1798 |
+
// Convert a style as returned by a mode (either null, or a string
|
1799 |
+
// containing one or more styles) to a CSS style. This is cached,
|
1800 |
+
// and also looks for line-wide styles.
|
1801 |
+
var styleToClassCache = {};
|
1802 |
+
var styleToClassCacheWithMode = {};
|
1803 |
+
function interpretTokenStyle(style, options) {
|
1804 |
+
if (!style || /^\s*$/.test(style)) { return null }
|
1805 |
+
var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache
|
1806 |
+
return cache[style] ||
|
1807 |
+
(cache[style] = style.replace(/\S+/g, "cm-$&"))
|
1808 |
+
}
|
1809 |
+
|
1810 |
+
// Render the DOM representation of the text of a line. Also builds
|
1811 |
+
// up a 'line map', which points at the DOM nodes that represent
|
1812 |
+
// specific stretches of text, and is used by the measuring code.
|
1813 |
+
// The returned object contains the DOM node, this map, and
|
1814 |
+
// information about line-wide styles that were set by the mode.
|
1815 |
+
function buildLineContent(cm, lineView) {
|
1816 |
+
// The padding-right forces the element to have a 'border', which
|
1817 |
+
// is needed on Webkit to be able to get line-level bounding
|
1818 |
+
// rectangles for it (in measureChar).
|
1819 |
+
var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null)
|
1820 |
+
var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content,
|
1821 |
+
col: 0, pos: 0, cm: cm,
|
1822 |
+
trailingSpace: false,
|
1823 |
+
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}
|
1824 |
+
lineView.measure = {}
|
1825 |
+
|
1826 |
+
// Iterate over the logical lines that make up this visual line.
|
1827 |
+
for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
|
1828 |
+
var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0)
|
1829 |
+
builder.pos = 0
|
1830 |
+
builder.addToken = buildToken
|
1831 |
+
// Optionally wire in some hacks into the token-rendering
|
1832 |
+
// algorithm, to deal with browser quirks.
|
1833 |
+
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))
|
1834 |
+
{ builder.addToken = buildTokenBadBidi(builder.addToken, order) }
|
1835 |
+
builder.map = []
|
1836 |
+
var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line)
|
1837 |
+
insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate))
|
1838 |
+
if (line.styleClasses) {
|
1839 |
+
if (line.styleClasses.bgClass)
|
1840 |
+
{ builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "") }
|
1841 |
+
if (line.styleClasses.textClass)
|
1842 |
+
{ builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "") }
|
1843 |
+
}
|
1844 |
+
|
1845 |
+
// Ensure at least a single node is present, for measuring.
|
1846 |
+
if (builder.map.length == 0)
|
1847 |
+
{ builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))) }
|
1848 |
+
|
1849 |
+
// Store the map and a cache object for the current logical line
|
1850 |
+
if (i == 0) {
|
1851 |
+
lineView.measure.map = builder.map
|
1852 |
+
lineView.measure.cache = {}
|
1853 |
+
} else {
|
1854 |
+
;(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
|
1855 |
+
;(lineView.measure.caches || (lineView.measure.caches = [])).push({})
|
1856 |
+
}
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
// See issue #2901
|
1860 |
+
if (webkit) {
|
1861 |
+
var last = builder.content.lastChild
|
1862 |
+
if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
|
1863 |
+
{ builder.content.className = "cm-tab-wrap-hack" }
|
1864 |
+
}
|
1865 |
+
|
1866 |
+
signal(cm, "renderLine", cm, lineView.line, builder.pre)
|
1867 |
+
if (builder.pre.className)
|
1868 |
+
{ builder.textClass = joinClasses(builder.pre.className, builder.textClass || "") }
|
1869 |
+
|
1870 |
+
return builder
|
1871 |
+
}
|
1872 |
+
|
1873 |
+
function defaultSpecialCharPlaceholder(ch) {
|
1874 |
+
var token = elt("span", "\u2022", "cm-invalidchar")
|
1875 |
+
token.title = "\\u" + ch.charCodeAt(0).toString(16)
|
1876 |
+
token.setAttribute("aria-label", token.title)
|
1877 |
+
return token
|
1878 |
+
}
|
1879 |
+
|
1880 |
+
// Build up the DOM representation for a single token, and add it to
|
1881 |
+
// the line map. Takes care to render special characters separately.
|
1882 |
+
function buildToken(builder, text, style, startStyle, endStyle, title, css) {
|
1883 |
+
if (!text) { return }
|
1884 |
+
var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text
|
1885 |
+
var special = builder.cm.state.specialChars, mustWrap = false
|
1886 |
+
var content
|
1887 |
+
if (!special.test(text)) {
|
1888 |
+
builder.col += text.length
|
1889 |
+
content = document.createTextNode(displayText)
|
1890 |
+
builder.map.push(builder.pos, builder.pos + text.length, content)
|
1891 |
+
if (ie && ie_version < 9) { mustWrap = true }
|
1892 |
+
builder.pos += text.length
|
1893 |
+
} else {
|
1894 |
+
content = document.createDocumentFragment()
|
1895 |
+
var pos = 0
|
1896 |
+
while (true) {
|
1897 |
+
special.lastIndex = pos
|
1898 |
+
var m = special.exec(text)
|
1899 |
+
var skipped = m ? m.index - pos : text.length - pos
|
1900 |
+
if (skipped) {
|
1901 |
+
var txt = document.createTextNode(displayText.slice(pos, pos + skipped))
|
1902 |
+
if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])) }
|
1903 |
+
else { content.appendChild(txt) }
|
1904 |
+
builder.map.push(builder.pos, builder.pos + skipped, txt)
|
1905 |
+
builder.col += skipped
|
1906 |
+
builder.pos += skipped
|
1907 |
+
}
|
1908 |
+
if (!m) { break }
|
1909 |
+
pos += skipped + 1
|
1910 |
+
var txt$1 = (void 0)
|
1911 |
+
if (m[0] == "\t") {
|
1912 |
+
var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize
|
1913 |
+
txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"))
|
1914 |
+
txt$1.setAttribute("role", "presentation")
|
1915 |
+
txt$1.setAttribute("cm-text", "\t")
|
1916 |
+
builder.col += tabWidth
|
1917 |
+
} else if (m[0] == "\r" || m[0] == "\n") {
|
1918 |
+
txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"))
|
1919 |
+
txt$1.setAttribute("cm-text", m[0])
|
1920 |
+
builder.col += 1
|
1921 |
+
} else {
|
1922 |
+
txt$1 = builder.cm.options.specialCharPlaceholder(m[0])
|
1923 |
+
txt$1.setAttribute("cm-text", m[0])
|
1924 |
+
if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])) }
|
1925 |
+
else { content.appendChild(txt$1) }
|
1926 |
+
builder.col += 1
|
1927 |
+
}
|
1928 |
+
builder.map.push(builder.pos, builder.pos + 1, txt$1)
|
1929 |
+
builder.pos++
|
1930 |
+
}
|
1931 |
+
}
|
1932 |
+
builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32
|
1933 |
+
if (style || startStyle || endStyle || mustWrap || css) {
|
1934 |
+
var fullStyle = style || ""
|
1935 |
+
if (startStyle) { fullStyle += startStyle }
|
1936 |
+
if (endStyle) { fullStyle += endStyle }
|
1937 |
+
var token = elt("span", [content], fullStyle, css)
|
1938 |
+
if (title) { token.title = title }
|
1939 |
+
return builder.content.appendChild(token)
|
1940 |
+
}
|
1941 |
+
builder.content.appendChild(content)
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
function splitSpaces(text, trailingBefore) {
|
1945 |
+
if (text.length > 1 && !/ /.test(text)) { return text }
|
1946 |
+
var spaceBefore = trailingBefore, result = ""
|
1947 |
+
for (var i = 0; i < text.length; i++) {
|
1948 |
+
var ch = text.charAt(i)
|
1949 |
+
if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
|
1950 |
+
{ ch = "\u00a0" }
|
1951 |
+
result += ch
|
1952 |
+
spaceBefore = ch == " "
|
1953 |
+
}
|
1954 |
+
return result
|
1955 |
+
}
|
1956 |
+
|
1957 |
+
// Work around nonsense dimensions being reported for stretches of
|
1958 |
+
// right-to-left text.
|
1959 |
+
function buildTokenBadBidi(inner, order) {
|
1960 |
+
return function (builder, text, style, startStyle, endStyle, title, css) {
|
1961 |
+
style = style ? style + " cm-force-border" : "cm-force-border"
|
1962 |
+
var start = builder.pos, end = start + text.length
|
1963 |
+
for (;;) {
|
1964 |
+
// Find the part that overlaps with the start of this text
|
1965 |
+
var part = (void 0)
|
1966 |
+
for (var i = 0; i < order.length; i++) {
|
1967 |
+
part = order[i]
|
1968 |
+
if (part.to > start && part.from <= start) { break }
|
1969 |
+
}
|
1970 |
+
if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, title, css) }
|
1971 |
+
inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css)
|
1972 |
+
startStyle = null
|
1973 |
+
text = text.slice(part.to - start)
|
1974 |
+
start = part.to
|
1975 |
+
}
|
1976 |
+
}
|
1977 |
+
}
|
1978 |
+
|
1979 |
+
function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
|
1980 |
+
var widget = !ignoreWidget && marker.widgetNode
|
1981 |
+
if (widget) { builder.map.push(builder.pos, builder.pos + size, widget) }
|
1982 |
+
if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
|
1983 |
+
if (!widget)
|
1984 |
+
{ widget = builder.content.appendChild(document.createElement("span")) }
|
1985 |
+
widget.setAttribute("cm-marker", marker.id)
|
1986 |
+
}
|
1987 |
+
if (widget) {
|
1988 |
+
builder.cm.display.input.setUneditable(widget)
|
1989 |
+
builder.content.appendChild(widget)
|
1990 |
+
}
|
1991 |
+
builder.pos += size
|
1992 |
+
builder.trailingSpace = false
|
1993 |
+
}
|
1994 |
+
|
1995 |
+
// Outputs a number of spans to make up a line, taking highlighting
|
1996 |
+
// and marked text into account.
|
1997 |
+
function insertLineContent(line, builder, styles) {
|
1998 |
+
var spans = line.markedSpans, allText = line.text, at = 0
|
1999 |
+
if (!spans) {
|
2000 |
+
for (var i$1 = 1; i$1 < styles.length; i$1+=2)
|
2001 |
+
{ builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)) }
|
2002 |
+
return
|
2003 |
+
}
|
2004 |
+
|
2005 |
+
var len = allText.length, pos = 0, i = 1, text = "", style, css
|
2006 |
+
var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed
|
2007 |
+
for (;;) {
|
2008 |
+
if (nextChange == pos) { // Update current marker set
|
2009 |
+
spanStyle = spanEndStyle = spanStartStyle = title = css = ""
|
2010 |
+
collapsed = null; nextChange = Infinity
|
2011 |
+
var foundBookmarks = [], endStyles = (void 0)
|
2012 |
+
for (var j = 0; j < spans.length; ++j) {
|
2013 |
+
var sp = spans[j], m = sp.marker
|
2014 |
+
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
|
2015 |
+
foundBookmarks.push(m)
|
2016 |
+
} else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
|
2017 |
+
if (sp.to != null && sp.to != pos && nextChange > sp.to) {
|
2018 |
+
nextChange = sp.to
|
2019 |
+
spanEndStyle = ""
|
2020 |
+
}
|
2021 |
+
if (m.className) { spanStyle += " " + m.className }
|
2022 |
+
if (m.css) { css = (css ? css + ";" : "") + m.css }
|
2023 |
+
if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle }
|
2024 |
+
if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to) }
|
2025 |
+
if (m.title && !title) { title = m.title }
|
2026 |
+
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
2027 |
+
{ collapsed = sp }
|
2028 |
+
} else if (sp.from > pos && nextChange > sp.from) {
|
2029 |
+
nextChange = sp.from
|
2030 |
+
}
|
2031 |
+
}
|
2032 |
+
if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)
|
2033 |
+
{ if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1] } } }
|
2034 |
+
|
2035 |
+
if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)
|
2036 |
+
{ buildCollapsedSpan(builder, 0, foundBookmarks[j$2]) } }
|
2037 |
+
if (collapsed && (collapsed.from || 0) == pos) {
|
2038 |
+
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
2039 |
+
collapsed.marker, collapsed.from == null)
|
2040 |
+
if (collapsed.to == null) { return }
|
2041 |
+
if (collapsed.to == pos) { collapsed = false }
|
2042 |
+
}
|
2043 |
+
}
|
2044 |
+
if (pos >= len) { break }
|
2045 |
+
|
2046 |
+
var upto = Math.min(len, nextChange)
|
2047 |
+
while (true) {
|
2048 |
+
if (text) {
|
2049 |
+
var end = pos + text.length
|
2050 |
+
if (!collapsed) {
|
2051 |
+
var tokenText = end > upto ? text.slice(0, upto - pos) : text
|
2052 |
+
builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
|
2053 |
+
spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css)
|
2054 |
+
}
|
2055 |
+
if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
|
2056 |
+
pos = end
|
2057 |
+
spanStartStyle = ""
|
2058 |
+
}
|
2059 |
+
text = allText.slice(at, at = styles[i++])
|
2060 |
+
style = interpretTokenStyle(styles[i++], builder.cm.options)
|
2061 |
+
}
|
2062 |
+
}
|
2063 |
+
}
|
2064 |
+
|
2065 |
+
|
2066 |
+
// These objects are used to represent the visible (currently drawn)
|
2067 |
+
// part of the document. A LineView may correspond to multiple
|
2068 |
+
// logical lines, if those are connected by collapsed ranges.
|
2069 |
+
function LineView(doc, line, lineN) {
|
2070 |
+
// The starting line
|
2071 |
+
this.line = line
|
2072 |
+
// Continuing lines, if any
|
2073 |
+
this.rest = visualLineContinued(line)
|
2074 |
+
// Number of logical lines in this visual line
|
2075 |
+
this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1
|
2076 |
+
this.node = this.text = null
|
2077 |
+
this.hidden = lineIsHidden(doc, line)
|
2078 |
+
}
|
2079 |
+
|
2080 |
+
// Create a range of LineView objects for the given lines.
|
2081 |
+
function buildViewArray(cm, from, to) {
|
2082 |
+
var array = [], nextPos
|
2083 |
+
for (var pos = from; pos < to; pos = nextPos) {
|
2084 |
+
var view = new LineView(cm.doc, getLine(cm.doc, pos), pos)
|
2085 |
+
nextPos = pos + view.size
|
2086 |
+
array.push(view)
|
2087 |
+
}
|
2088 |
+
return array
|
2089 |
+
}
|
2090 |
+
|
2091 |
+
var operationGroup = null
|
2092 |
+
|
2093 |
+
function pushOperation(op) {
|
2094 |
+
if (operationGroup) {
|
2095 |
+
operationGroup.ops.push(op)
|
2096 |
+
} else {
|
2097 |
+
op.ownsGroup = operationGroup = {
|
2098 |
+
ops: [op],
|
2099 |
+
delayedCallbacks: []
|
2100 |
+
}
|
2101 |
+
}
|
2102 |
+
}
|
2103 |
+
|
2104 |
+
function fireCallbacksForOps(group) {
|
2105 |
+
// Calls delayed callbacks and cursorActivity handlers until no
|
2106 |
+
// new ones appear
|
2107 |
+
var callbacks = group.delayedCallbacks, i = 0
|
2108 |
+
do {
|
2109 |
+
for (; i < callbacks.length; i++)
|
2110 |
+
{ callbacks[i].call(null) }
|
2111 |
+
for (var j = 0; j < group.ops.length; j++) {
|
2112 |
+
var op = group.ops[j]
|
2113 |
+
if (op.cursorActivityHandlers)
|
2114 |
+
{ while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
|
2115 |
+
{ op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm) } }
|
2116 |
+
}
|
2117 |
+
} while (i < callbacks.length)
|
2118 |
+
}
|
2119 |
+
|
2120 |
+
function finishOperation(op, endCb) {
|
2121 |
+
var group = op.ownsGroup
|
2122 |
+
if (!group) { return }
|
2123 |
+
|
2124 |
+
try { fireCallbacksForOps(group) }
|
2125 |
+
finally {
|
2126 |
+
operationGroup = null
|
2127 |
+
endCb(group)
|
2128 |
+
}
|
2129 |
+
}
|
2130 |
+
|
2131 |
+
var orphanDelayedCallbacks = null
|
2132 |
+
|
2133 |
+
// Often, we want to signal events at a point where we are in the
|
2134 |
+
// middle of some work, but don't want the handler to start calling
|
2135 |
+
// other methods on the editor, which might be in an inconsistent
|
2136 |
+
// state or simply not expect any other events to happen.
|
2137 |
+
// signalLater looks whether there are any handlers, and schedules
|
2138 |
+
// them to be executed when the last operation ends, or, if no
|
2139 |
+
// operation is active, when a timeout fires.
|
2140 |
+
function signalLater(emitter, type /*, values...*/) {
|
2141 |
+
var arr = getHandlers(emitter, type)
|
2142 |
+
if (!arr.length) { return }
|
2143 |
+
var args = Array.prototype.slice.call(arguments, 2), list
|
2144 |
+
if (operationGroup) {
|
2145 |
+
list = operationGroup.delayedCallbacks
|
2146 |
+
} else if (orphanDelayedCallbacks) {
|
2147 |
+
list = orphanDelayedCallbacks
|
2148 |
+
} else {
|
2149 |
+
list = orphanDelayedCallbacks = []
|
2150 |
+
setTimeout(fireOrphanDelayed, 0)
|
2151 |
+
}
|
2152 |
+
var loop = function ( i ) {
|
2153 |
+
list.push(function () { return arr[i].apply(null, args); })
|
2154 |
+
};
|
2155 |
+
|
2156 |
+
for (var i = 0; i < arr.length; ++i)
|
2157 |
+
loop( i );
|
2158 |
+
}
|
2159 |
+
|
2160 |
+
function fireOrphanDelayed() {
|
2161 |
+
var delayed = orphanDelayedCallbacks
|
2162 |
+
orphanDelayedCallbacks = null
|
2163 |
+
for (var i = 0; i < delayed.length; ++i) { delayed[i]() }
|
2164 |
+
}
|
2165 |
+
|
2166 |
+
// When an aspect of a line changes, a string is added to
|
2167 |
+
// lineView.changes. This updates the relevant part of the line's
|
2168 |
+
// DOM structure.
|
2169 |
+
function updateLineForChanges(cm, lineView, lineN, dims) {
|
2170 |
+
for (var j = 0; j < lineView.changes.length; j++) {
|
2171 |
+
var type = lineView.changes[j]
|
2172 |
+
if (type == "text") { updateLineText(cm, lineView) }
|
2173 |
+
else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims) }
|
2174 |
+
else if (type == "class") { updateLineClasses(cm, lineView) }
|
2175 |
+
else if (type == "widget") { updateLineWidgets(cm, lineView, dims) }
|
2176 |
+
}
|
2177 |
+
lineView.changes = null
|
2178 |
+
}
|
2179 |
+
|
2180 |
+
// Lines with gutter elements, widgets or a background class need to
|
2181 |
+
// be wrapped, and have the extra elements added to the wrapper div
|
2182 |
+
function ensureLineWrapped(lineView) {
|
2183 |
+
if (lineView.node == lineView.text) {
|
2184 |
+
lineView.node = elt("div", null, null, "position: relative")
|
2185 |
+
if (lineView.text.parentNode)
|
2186 |
+
{ lineView.text.parentNode.replaceChild(lineView.node, lineView.text) }
|
2187 |
+
lineView.node.appendChild(lineView.text)
|
2188 |
+
if (ie && ie_version < 8) { lineView.node.style.zIndex = 2 }
|
2189 |
+
}
|
2190 |
+
return lineView.node
|
2191 |
+
}
|
2192 |
+
|
2193 |
+
function updateLineBackground(cm, lineView) {
|
2194 |
+
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass
|
2195 |
+
if (cls) { cls += " CodeMirror-linebackground" }
|
2196 |
+
if (lineView.background) {
|
2197 |
+
if (cls) { lineView.background.className = cls }
|
2198 |
+
else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null }
|
2199 |
+
} else if (cls) {
|
2200 |
+
var wrap = ensureLineWrapped(lineView)
|
2201 |
+
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild)
|
2202 |
+
cm.display.input.setUneditable(lineView.background)
|
2203 |
+
}
|
2204 |
+
}
|
2205 |
+
|
2206 |
+
// Wrapper around buildLineContent which will reuse the structure
|
2207 |
+
// in display.externalMeasured when possible.
|
2208 |
+
function getLineContent(cm, lineView) {
|
2209 |
+
var ext = cm.display.externalMeasured
|
2210 |
+
if (ext && ext.line == lineView.line) {
|
2211 |
+
cm.display.externalMeasured = null
|
2212 |
+
lineView.measure = ext.measure
|
2213 |
+
return ext.built
|
2214 |
+
}
|
2215 |
+
return buildLineContent(cm, lineView)
|
2216 |
+
}
|
2217 |
+
|
2218 |
+
// Redraw the line's text. Interacts with the background and text
|
2219 |
+
// classes because the mode may output tokens that influence these
|
2220 |
+
// classes.
|
2221 |
+
function updateLineText(cm, lineView) {
|
2222 |
+
var cls = lineView.text.className
|
2223 |
+
var built = getLineContent(cm, lineView)
|
2224 |
+
if (lineView.text == lineView.node) { lineView.node = built.pre }
|
2225 |
+
lineView.text.parentNode.replaceChild(built.pre, lineView.text)
|
2226 |
+
lineView.text = built.pre
|
2227 |
+
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
|
2228 |
+
lineView.bgClass = built.bgClass
|
2229 |
+
lineView.textClass = built.textClass
|
2230 |
+
updateLineClasses(cm, lineView)
|
2231 |
+
} else if (cls) {
|
2232 |
+
lineView.text.className = cls
|
2233 |
+
}
|
2234 |
+
}
|
2235 |
+
|
2236 |
+
function updateLineClasses(cm, lineView) {
|
2237 |
+
updateLineBackground(cm, lineView)
|
2238 |
+
if (lineView.line.wrapClass)
|
2239 |
+
{ ensureLineWrapped(lineView).className = lineView.line.wrapClass }
|
2240 |
+
else if (lineView.node != lineView.text)
|
2241 |
+
{ lineView.node.className = "" }
|
2242 |
+
var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass
|
2243 |
+
lineView.text.className = textClass || ""
|
2244 |
+
}
|
2245 |
+
|
2246 |
+
function updateLineGutter(cm, lineView, lineN, dims) {
|
2247 |
+
if (lineView.gutter) {
|
2248 |
+
lineView.node.removeChild(lineView.gutter)
|
2249 |
+
lineView.gutter = null
|
2250 |
+
}
|
2251 |
+
if (lineView.gutterBackground) {
|
2252 |
+
lineView.node.removeChild(lineView.gutterBackground)
|
2253 |
+
lineView.gutterBackground = null
|
2254 |
+
}
|
2255 |
+
if (lineView.line.gutterClass) {
|
2256 |
+
var wrap = ensureLineWrapped(lineView)
|
2257 |
+
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
|
2258 |
+
("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"))
|
2259 |
+
cm.display.input.setUneditable(lineView.gutterBackground)
|
2260 |
+
wrap.insertBefore(lineView.gutterBackground, lineView.text)
|
2261 |
+
}
|
2262 |
+
var markers = lineView.line.gutterMarkers
|
2263 |
+
if (cm.options.lineNumbers || markers) {
|
2264 |
+
var wrap$1 = ensureLineWrapped(lineView)
|
2265 |
+
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"))
|
2266 |
+
cm.display.input.setUneditable(gutterWrap)
|
2267 |
+
wrap$1.insertBefore(gutterWrap, lineView.text)
|
2268 |
+
if (lineView.line.gutterClass)
|
2269 |
+
{ gutterWrap.className += " " + lineView.line.gutterClass }
|
2270 |
+
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
|
2271 |
+
{ lineView.lineNumber = gutterWrap.appendChild(
|
2272 |
+
elt("div", lineNumberFor(cm.options, lineN),
|
2273 |
+
"CodeMirror-linenumber CodeMirror-gutter-elt",
|
2274 |
+
("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))) }
|
2275 |
+
if (markers) { for (var k = 0; k < cm.options.gutters.length; ++k) {
|
2276 |
+
var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]
|
2277 |
+
if (found)
|
2278 |
+
{ gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
|
2279 |
+
("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))) }
|
2280 |
+
} }
|
2281 |
+
}
|
2282 |
+
}
|
2283 |
+
|
2284 |
+
function updateLineWidgets(cm, lineView, dims) {
|
2285 |
+
if (lineView.alignable) { lineView.alignable = null }
|
2286 |
+
for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
|
2287 |
+
next = node.nextSibling
|
2288 |
+
if (node.className == "CodeMirror-linewidget")
|
2289 |
+
{ lineView.node.removeChild(node) }
|
2290 |
+
}
|
2291 |
+
insertLineWidgets(cm, lineView, dims)
|
2292 |
+
}
|
2293 |
+
|
2294 |
+
// Build a line's DOM representation from scratch
|
2295 |
+
function buildLineElement(cm, lineView, lineN, dims) {
|
2296 |
+
var built = getLineContent(cm, lineView)
|
2297 |
+
lineView.text = lineView.node = built.pre
|
2298 |
+
if (built.bgClass) { lineView.bgClass = built.bgClass }
|
2299 |
+
if (built.textClass) { lineView.textClass = built.textClass }
|
2300 |
+
|
2301 |
+
updateLineClasses(cm, lineView)
|
2302 |
+
updateLineGutter(cm, lineView, lineN, dims)
|
2303 |
+
insertLineWidgets(cm, lineView, dims)
|
2304 |
+
return lineView.node
|
2305 |
+
}
|
2306 |
+
|
2307 |
+
// A lineView may contain multiple logical lines (when merged by
|
2308 |
+
// collapsed spans). The widgets for all of them need to be drawn.
|
2309 |
+
function insertLineWidgets(cm, lineView, dims) {
|
2310 |
+
insertLineWidgetsFor(cm, lineView.line, lineView, dims, true)
|
2311 |
+
if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
|
2312 |
+
{ insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false) } }
|
2313 |
+
}
|
2314 |
+
|
2315 |
+
function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
|
2316 |
+
if (!line.widgets) { return }
|
2317 |
+
var wrap = ensureLineWrapped(lineView)
|
2318 |
+
for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
|
2319 |
+
var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget")
|
2320 |
+
if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true") }
|
2321 |
+
positionLineWidget(widget, node, lineView, dims)
|
2322 |
+
cm.display.input.setUneditable(node)
|
2323 |
+
if (allowAbove && widget.above)
|
2324 |
+
{ wrap.insertBefore(node, lineView.gutter || lineView.text) }
|
2325 |
+
else
|
2326 |
+
{ wrap.appendChild(node) }
|
2327 |
+
signalLater(widget, "redraw")
|
2328 |
+
}
|
2329 |
+
}
|
2330 |
+
|
2331 |
+
function positionLineWidget(widget, node, lineView, dims) {
|
2332 |
+
if (widget.noHScroll) {
|
2333 |
+
;(lineView.alignable || (lineView.alignable = [])).push(node)
|
2334 |
+
var width = dims.wrapperWidth
|
2335 |
+
node.style.left = dims.fixedPos + "px"
|
2336 |
+
if (!widget.coverGutter) {
|
2337 |
+
width -= dims.gutterTotalWidth
|
2338 |
+
node.style.paddingLeft = dims.gutterTotalWidth + "px"
|
2339 |
+
}
|
2340 |
+
node.style.width = width + "px"
|
2341 |
+
}
|
2342 |
+
if (widget.coverGutter) {
|
2343 |
+
node.style.zIndex = 5
|
2344 |
+
node.style.position = "relative"
|
2345 |
+
if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px" }
|
2346 |
+
}
|
2347 |
+
}
|
2348 |
+
|
2349 |
+
function widgetHeight(widget) {
|
2350 |
+
if (widget.height != null) { return widget.height }
|
2351 |
+
var cm = widget.doc.cm
|
2352 |
+
if (!cm) { return 0 }
|
2353 |
+
if (!contains(document.body, widget.node)) {
|
2354 |
+
var parentStyle = "position: relative;"
|
2355 |
+
if (widget.coverGutter)
|
2356 |
+
{ parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;" }
|
2357 |
+
if (widget.noHScroll)
|
2358 |
+
{ parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;" }
|
2359 |
+
removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle))
|
2360 |
+
}
|
2361 |
+
return widget.height = widget.node.parentNode.offsetHeight
|
2362 |
+
}
|
2363 |
+
|
2364 |
+
// Return true when the given mouse event happened in a widget
|
2365 |
+
function eventInWidget(display, e) {
|
2366 |
+
for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
|
2367 |
+
if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
|
2368 |
+
(n.parentNode == display.sizer && n != display.mover))
|
2369 |
+
{ return true }
|
2370 |
+
}
|
2371 |
+
}
|
2372 |
+
|
2373 |
+
// POSITION MEASUREMENT
|
2374 |
+
|
2375 |
+
function paddingTop(display) {return display.lineSpace.offsetTop}
|
2376 |
+
function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
|
2377 |
+
function paddingH(display) {
|
2378 |
+
if (display.cachedPaddingH) { return display.cachedPaddingH }
|
2379 |
+
var e = removeChildrenAndAdd(display.measure, elt("pre", "x"))
|
2380 |
+
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle
|
2381 |
+
var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}
|
2382 |
+
if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data }
|
2383 |
+
return data
|
2384 |
+
}
|
2385 |
+
|
2386 |
+
function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }
|
2387 |
+
function displayWidth(cm) {
|
2388 |
+
return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth
|
2389 |
+
}
|
2390 |
+
function displayHeight(cm) {
|
2391 |
+
return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight
|
2392 |
+
}
|
2393 |
+
|
2394 |
+
// Ensure the lineView.wrapping.heights array is populated. This is
|
2395 |
+
// an array of bottom offsets for the lines that make up a drawn
|
2396 |
+
// line. When lineWrapping is on, there might be more than one
|
2397 |
+
// height.
|
2398 |
+
function ensureLineHeights(cm, lineView, rect) {
|
2399 |
+
var wrapping = cm.options.lineWrapping
|
2400 |
+
var curWidth = wrapping && displayWidth(cm)
|
2401 |
+
if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
|
2402 |
+
var heights = lineView.measure.heights = []
|
2403 |
+
if (wrapping) {
|
2404 |
+
lineView.measure.width = curWidth
|
2405 |
+
var rects = lineView.text.firstChild.getClientRects()
|
2406 |
+
for (var i = 0; i < rects.length - 1; i++) {
|
2407 |
+
var cur = rects[i], next = rects[i + 1]
|
2408 |
+
if (Math.abs(cur.bottom - next.bottom) > 2)
|
2409 |
+
{ heights.push((cur.bottom + next.top) / 2 - rect.top) }
|
2410 |
+
}
|
2411 |
+
}
|
2412 |
+
heights.push(rect.bottom - rect.top)
|
2413 |
+
}
|
2414 |
+
}
|
2415 |
+
|
2416 |
+
// Find a line map (mapping character offsets to text nodes) and a
|
2417 |
+
// measurement cache for the given line number. (A line view might
|
2418 |
+
// contain multiple lines when collapsed ranges are present.)
|
2419 |
+
function mapFromLineView(lineView, line, lineN) {
|
2420 |
+
if (lineView.line == line)
|
2421 |
+
{ return {map: lineView.measure.map, cache: lineView.measure.cache} }
|
2422 |
+
for (var i = 0; i < lineView.rest.length; i++)
|
2423 |
+
{ if (lineView.rest[i] == line)
|
2424 |
+
{ return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
|
2425 |
+
for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
|
2426 |
+
{ if (lineNo(lineView.rest[i$1]) > lineN)
|
2427 |
+
{ return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
|
2428 |
+
}
|
2429 |
+
|
2430 |
+
// Render a line into the hidden node display.externalMeasured. Used
|
2431 |
+
// when measurement is needed for a line that's not in the viewport.
|
2432 |
+
function updateExternalMeasurement(cm, line) {
|
2433 |
+
line = visualLine(line)
|
2434 |
+
var lineN = lineNo(line)
|
2435 |
+
var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN)
|
2436 |
+
view.lineN = lineN
|
2437 |
+
var built = view.built = buildLineContent(cm, view)
|
2438 |
+
view.text = built.pre
|
2439 |
+
removeChildrenAndAdd(cm.display.lineMeasure, built.pre)
|
2440 |
+
return view
|
2441 |
+
}
|
2442 |
+
|
2443 |
+
// Get a {top, bottom, left, right} box (in line-local coordinates)
|
2444 |
+
// for a given character.
|
2445 |
+
function measureChar(cm, line, ch, bias) {
|
2446 |
+
return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)
|
2447 |
+
}
|
2448 |
+
|
2449 |
+
// Find a line view that corresponds to the given line number.
|
2450 |
+
function findViewForLine(cm, lineN) {
|
2451 |
+
if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
|
2452 |
+
{ return cm.display.view[findViewIndex(cm, lineN)] }
|
2453 |
+
var ext = cm.display.externalMeasured
|
2454 |
+
if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
|
2455 |
+
{ return ext }
|
2456 |
+
}
|
2457 |
+
|
2458 |
+
// Measurement can be split in two steps, the set-up work that
|
2459 |
+
// applies to the whole line, and the measurement of the actual
|
2460 |
+
// character. Functions like coordsChar, that need to do a lot of
|
2461 |
+
// measurements in a row, can thus ensure that the set-up work is
|
2462 |
+
// only done once.
|
2463 |
+
function prepareMeasureForLine(cm, line) {
|
2464 |
+
var lineN = lineNo(line)
|
2465 |
+
var view = findViewForLine(cm, lineN)
|
2466 |
+
if (view && !view.text) {
|
2467 |
+
view = null
|
2468 |
+
} else if (view && view.changes) {
|
2469 |
+
updateLineForChanges(cm, view, lineN, getDimensions(cm))
|
2470 |
+
cm.curOp.forceUpdate = true
|
2471 |
+
}
|
2472 |
+
if (!view)
|
2473 |
+
{ view = updateExternalMeasurement(cm, line) }
|
2474 |
+
|
2475 |
+
var info = mapFromLineView(view, line, lineN)
|
2476 |
+
return {
|
2477 |
+
line: line, view: view, rect: null,
|
2478 |
+
map: info.map, cache: info.cache, before: info.before,
|
2479 |
+
hasHeights: false
|
2480 |
+
}
|
2481 |
+
}
|
2482 |
+
|
2483 |
+
// Given a prepared measurement object, measures the position of an
|
2484 |
+
// actual character (or fetches it from the cache).
|
2485 |
+
function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
|
2486 |
+
if (prepared.before) { ch = -1 }
|
2487 |
+
var key = ch + (bias || ""), found
|
2488 |
+
if (prepared.cache.hasOwnProperty(key)) {
|
2489 |
+
found = prepared.cache[key]
|
2490 |
+
} else {
|
2491 |
+
if (!prepared.rect)
|
2492 |
+
{ prepared.rect = prepared.view.text.getBoundingClientRect() }
|
2493 |
+
if (!prepared.hasHeights) {
|
2494 |
+
ensureLineHeights(cm, prepared.view, prepared.rect)
|
2495 |
+
prepared.hasHeights = true
|
2496 |
+
}
|
2497 |
+
found = measureCharInner(cm, prepared, ch, bias)
|
2498 |
+
if (!found.bogus) { prepared.cache[key] = found }
|
2499 |
+
}
|
2500 |
+
return {left: found.left, right: found.right,
|
2501 |
+
top: varHeight ? found.rtop : found.top,
|
2502 |
+
bottom: varHeight ? found.rbottom : found.bottom}
|
2503 |
+
}
|
2504 |
+
|
2505 |
+
var nullRect = {left: 0, right: 0, top: 0, bottom: 0}
|
2506 |
+
|
2507 |
+
function nodeAndOffsetInLineMap(map, ch, bias) {
|
2508 |
+
var node, start, end, collapse, mStart, mEnd
|
2509 |
+
// First, search the line map for the text node corresponding to,
|
2510 |
+
// or closest to, the target character.
|
2511 |
+
for (var i = 0; i < map.length; i += 3) {
|
2512 |
+
mStart = map[i]
|
2513 |
+
mEnd = map[i + 1]
|
2514 |
+
if (ch < mStart) {
|
2515 |
+
start = 0; end = 1
|
2516 |
+
collapse = "left"
|
2517 |
+
} else if (ch < mEnd) {
|
2518 |
+
start = ch - mStart
|
2519 |
+
end = start + 1
|
2520 |
+
} else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
|
2521 |
+
end = mEnd - mStart
|
2522 |
+
start = end - 1
|
2523 |
+
if (ch >= mEnd) { collapse = "right" }
|
2524 |
+
}
|
2525 |
+
if (start != null) {
|
2526 |
+
node = map[i + 2]
|
2527 |
+
if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
|
2528 |
+
{ collapse = bias }
|
2529 |
+
if (bias == "left" && start == 0)
|
2530 |
+
{ while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
|
2531 |
+
node = map[(i -= 3) + 2]
|
2532 |
+
collapse = "left"
|
2533 |
+
} }
|
2534 |
+
if (bias == "right" && start == mEnd - mStart)
|
2535 |
+
{ while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
|
2536 |
+
node = map[(i += 3) + 2]
|
2537 |
+
collapse = "right"
|
2538 |
+
} }
|
2539 |
+
break
|
2540 |
+
}
|
2541 |
+
}
|
2542 |
+
return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}
|
2543 |
+
}
|
2544 |
+
|
2545 |
+
function getUsefulRect(rects, bias) {
|
2546 |
+
var rect = nullRect
|
2547 |
+
if (bias == "left") { for (var i = 0; i < rects.length; i++) {
|
2548 |
+
if ((rect = rects[i]).left != rect.right) { break }
|
2549 |
+
} } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
|
2550 |
+
if ((rect = rects[i$1]).left != rect.right) { break }
|
2551 |
+
} }
|
2552 |
+
return rect
|
2553 |
+
}
|
2554 |
+
|
2555 |
+
function measureCharInner(cm, prepared, ch, bias) {
|
2556 |
+
var place = nodeAndOffsetInLineMap(prepared.map, ch, bias)
|
2557 |
+
var node = place.node, start = place.start, end = place.end, collapse = place.collapse
|
2558 |
+
|
2559 |
+
var rect
|
2560 |
+
if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
|
2561 |
+
for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned
|
2562 |
+
while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start }
|
2563 |
+
while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end }
|
2564 |
+
if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
|
2565 |
+
{ rect = node.parentNode.getBoundingClientRect() }
|
2566 |
+
else
|
2567 |
+
{ rect = getUsefulRect(range(node, start, end).getClientRects(), bias) }
|
2568 |
+
if (rect.left || rect.right || start == 0) { break }
|
2569 |
+
end = start
|
2570 |
+
start = start - 1
|
2571 |
+
collapse = "right"
|
2572 |
+
}
|
2573 |
+
if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect) }
|
2574 |
+
} else { // If it is a widget, simply get the box for the whole widget.
|
2575 |
+
if (start > 0) { collapse = bias = "right" }
|
2576 |
+
var rects
|
2577 |
+
if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
|
2578 |
+
{ rect = rects[bias == "right" ? rects.length - 1 : 0] }
|
2579 |
+
else
|
2580 |
+
{ rect = node.getBoundingClientRect() }
|
2581 |
+
}
|
2582 |
+
if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
|
2583 |
+
var rSpan = node.parentNode.getClientRects()[0]
|
2584 |
+
if (rSpan)
|
2585 |
+
{ rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom} }
|
2586 |
+
else
|
2587 |
+
{ rect = nullRect }
|
2588 |
+
}
|
2589 |
+
|
2590 |
+
var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top
|
2591 |
+
var mid = (rtop + rbot) / 2
|
2592 |
+
var heights = prepared.view.measure.heights
|
2593 |
+
var i = 0
|
2594 |
+
for (; i < heights.length - 1; i++)
|
2595 |
+
{ if (mid < heights[i]) { break } }
|
2596 |
+
var top = i ? heights[i - 1] : 0, bot = heights[i]
|
2597 |
+
var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
|
2598 |
+
right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
|
2599 |
+
top: top, bottom: bot}
|
2600 |
+
if (!rect.left && !rect.right) { result.bogus = true }
|
2601 |
+
if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot }
|
2602 |
+
|
2603 |
+
return result
|
2604 |
+
}
|
2605 |
+
|
2606 |
+
// Work around problem with bounding client rects on ranges being
|
2607 |
+
// returned incorrectly when zoomed on IE10 and below.
|
2608 |
+
function maybeUpdateRectForZooming(measure, rect) {
|
2609 |
+
if (!window.screen || screen.logicalXDPI == null ||
|
2610 |
+
screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
|
2611 |
+
{ return rect }
|
2612 |
+
var scaleX = screen.logicalXDPI / screen.deviceXDPI
|
2613 |
+
var scaleY = screen.logicalYDPI / screen.deviceYDPI
|
2614 |
+
return {left: rect.left * scaleX, right: rect.right * scaleX,
|
2615 |
+
top: rect.top * scaleY, bottom: rect.bottom * scaleY}
|
2616 |
+
}
|
2617 |
+
|
2618 |
+
function clearLineMeasurementCacheFor(lineView) {
|
2619 |
+
if (lineView.measure) {
|
2620 |
+
lineView.measure.cache = {}
|
2621 |
+
lineView.measure.heights = null
|
2622 |
+
if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
|
2623 |
+
{ lineView.measure.caches[i] = {} } }
|
2624 |
+
}
|
2625 |
+
}
|
2626 |
+
|
2627 |
+
function clearLineMeasurementCache(cm) {
|
2628 |
+
cm.display.externalMeasure = null
|
2629 |
+
removeChildren(cm.display.lineMeasure)
|
2630 |
+
for (var i = 0; i < cm.display.view.length; i++)
|
2631 |
+
{ clearLineMeasurementCacheFor(cm.display.view[i]) }
|
2632 |
+
}
|
2633 |
+
|
2634 |
+
function clearCaches(cm) {
|
2635 |
+
clearLineMeasurementCache(cm)
|
2636 |
+
cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null
|
2637 |
+
if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true }
|
2638 |
+
cm.display.lineNumChars = null
|
2639 |
+
}
|
2640 |
+
|
2641 |
+
function pageScrollX() {
|
2642 |
+
// Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
|
2643 |
+
// which causes page_Offset and bounding client rects to use
|
2644 |
+
// different reference viewports and invalidate our calculations.
|
2645 |
+
if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
|
2646 |
+
return window.pageXOffset || (document.documentElement || document.body).scrollLeft
|
2647 |
+
}
|
2648 |
+
function pageScrollY() {
|
2649 |
+
if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
|
2650 |
+
return window.pageYOffset || (document.documentElement || document.body).scrollTop
|
2651 |
+
}
|
2652 |
+
|
2653 |
+
function widgetTopHeight(lineObj) {
|
2654 |
+
var height = 0
|
2655 |
+
if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above)
|
2656 |
+
{ height += widgetHeight(lineObj.widgets[i]) } } }
|
2657 |
+
return height
|
2658 |
+
}
|
2659 |
+
|
2660 |
+
// Converts a {top, bottom, left, right} box from line-local
|
2661 |
+
// coordinates into another coordinate system. Context may be one of
|
2662 |
+
// "line", "div" (display.lineDiv), "local"./null (editor), "window",
|
2663 |
+
// or "page".
|
2664 |
+
function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
|
2665 |
+
if (!includeWidgets) {
|
2666 |
+
var height = widgetTopHeight(lineObj)
|
2667 |
+
rect.top += height; rect.bottom += height
|
2668 |
+
}
|
2669 |
+
if (context == "line") { return rect }
|
2670 |
+
if (!context) { context = "local" }
|
2671 |
+
var yOff = heightAtLine(lineObj)
|
2672 |
+
if (context == "local") { yOff += paddingTop(cm.display) }
|
2673 |
+
else { yOff -= cm.display.viewOffset }
|
2674 |
+
if (context == "page" || context == "window") {
|
2675 |
+
var lOff = cm.display.lineSpace.getBoundingClientRect()
|
2676 |
+
yOff += lOff.top + (context == "window" ? 0 : pageScrollY())
|
2677 |
+
var xOff = lOff.left + (context == "window" ? 0 : pageScrollX())
|
2678 |
+
rect.left += xOff; rect.right += xOff
|
2679 |
+
}
|
2680 |
+
rect.top += yOff; rect.bottom += yOff
|
2681 |
+
return rect
|
2682 |
+
}
|
2683 |
+
|
2684 |
+
// Coverts a box from "div" coords to another coordinate system.
|
2685 |
+
// Context may be "window", "page", "div", or "local"./null.
|
2686 |
+
function fromCoordSystem(cm, coords, context) {
|
2687 |
+
if (context == "div") { return coords }
|
2688 |
+
var left = coords.left, top = coords.top
|
2689 |
+
// First move into "page" coordinate system
|
2690 |
+
if (context == "page") {
|
2691 |
+
left -= pageScrollX()
|
2692 |
+
top -= pageScrollY()
|
2693 |
+
} else if (context == "local" || !context) {
|
2694 |
+
var localBox = cm.display.sizer.getBoundingClientRect()
|
2695 |
+
left += localBox.left
|
2696 |
+
top += localBox.top
|
2697 |
+
}
|
2698 |
+
|
2699 |
+
var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect()
|
2700 |
+
return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}
|
2701 |
+
}
|
2702 |
+
|
2703 |
+
function charCoords(cm, pos, context, lineObj, bias) {
|
2704 |
+
if (!lineObj) { lineObj = getLine(cm.doc, pos.line) }
|
2705 |
+
return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)
|
2706 |
+
}
|
2707 |
+
|
2708 |
+
// Returns a box for a given cursor position, which may have an
|
2709 |
+
// 'other' property containing the position of the secondary cursor
|
2710 |
+
// on a bidi boundary.
|
2711 |
+
// A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
|
2712 |
+
// and after `char - 1` in writing order of `char - 1`
|
2713 |
+
// A cursor Pos(line, char, "after") is on the same visual line as `char`
|
2714 |
+
// and before `char` in writing order of `char`
|
2715 |
+
// Examples (upper-case letters are RTL, lower-case are LTR):
|
2716 |
+
// Pos(0, 1, ...)
|
2717 |
+
// before after
|
2718 |
+
// ab a|b a|b
|
2719 |
+
// aB a|B aB|
|
2720 |
+
// Ab |Ab A|b
|
2721 |
+
// AB B|A B|A
|
2722 |
+
// Every position after the last character on a line is considered to stick
|
2723 |
+
// to the last character on the line.
|
2724 |
+
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
|
2725 |
+
lineObj = lineObj || getLine(cm.doc, pos.line)
|
2726 |
+
if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }
|
2727 |
+
function get(ch, right) {
|
2728 |
+
var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight)
|
2729 |
+
if (right) { m.left = m.right; } else { m.right = m.left }
|
2730 |
+
return intoCoordSystem(cm, lineObj, m, context)
|
2731 |
+
}
|
2732 |
+
var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky
|
2733 |
+
if (ch >= lineObj.text.length) {
|
2734 |
+
ch = lineObj.text.length
|
2735 |
+
sticky = "before"
|
2736 |
+
} else if (ch <= 0) {
|
2737 |
+
ch = 0
|
2738 |
+
sticky = "after"
|
2739 |
+
}
|
2740 |
+
if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
|
2741 |
+
|
2742 |
+
function getBidi(ch, partPos, invert) {
|
2743 |
+
var part = order[partPos], right = part.level == 1
|
2744 |
+
return get(invert ? ch - 1 : ch, right != invert)
|
2745 |
+
}
|
2746 |
+
var partPos = getBidiPartAt(order, ch, sticky)
|
2747 |
+
var other = bidiOther
|
2748 |
+
var val = getBidi(ch, partPos, sticky == "before")
|
2749 |
+
if (other != null) { val.other = getBidi(ch, other, sticky != "before") }
|
2750 |
+
return val
|
2751 |
+
}
|
2752 |
+
|
2753 |
+
// Used to cheaply estimate the coordinates for a position. Used for
|
2754 |
+
// intermediate scroll updates.
|
2755 |
+
function estimateCoords(cm, pos) {
|
2756 |
+
var left = 0
|
2757 |
+
pos = clipPos(cm.doc, pos)
|
2758 |
+
if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch }
|
2759 |
+
var lineObj = getLine(cm.doc, pos.line)
|
2760 |
+
var top = heightAtLine(lineObj) + paddingTop(cm.display)
|
2761 |
+
return {left: left, right: left, top: top, bottom: top + lineObj.height}
|
2762 |
+
}
|
2763 |
+
|
2764 |
+
// Positions returned by coordsChar contain some extra information.
|
2765 |
+
// xRel is the relative x position of the input coordinates compared
|
2766 |
+
// to the found position (so xRel > 0 means the coordinates are to
|
2767 |
+
// the right of the character position, for example). When outside
|
2768 |
+
// is true, that means the coordinates lie outside the line's
|
2769 |
+
// vertical range.
|
2770 |
+
function PosWithInfo(line, ch, sticky, outside, xRel) {
|
2771 |
+
var pos = Pos(line, ch, sticky)
|
2772 |
+
pos.xRel = xRel
|
2773 |
+
if (outside) { pos.outside = true }
|
2774 |
+
return pos
|
2775 |
+
}
|
2776 |
+
|
2777 |
+
// Compute the character position closest to the given coordinates.
|
2778 |
+
// Input must be lineSpace-local ("div" coordinate system).
|
2779 |
+
function coordsChar(cm, x, y) {
|
2780 |
+
var doc = cm.doc
|
2781 |
+
y += cm.display.viewOffset
|
2782 |
+
if (y < 0) { return PosWithInfo(doc.first, 0, null, true, -1) }
|
2783 |
+
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1
|
2784 |
+
if (lineN > last)
|
2785 |
+
{ return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, true, 1) }
|
2786 |
+
if (x < 0) { x = 0 }
|
2787 |
+
|
2788 |
+
var lineObj = getLine(doc, lineN)
|
2789 |
+
for (;;) {
|
2790 |
+
var found = coordsCharInner(cm, lineObj, lineN, x, y)
|
2791 |
+
var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 ? 1 : 0))
|
2792 |
+
if (!collapsed) { return found }
|
2793 |
+
var rangeEnd = collapsed.find(1)
|
2794 |
+
if (rangeEnd.line == lineN) { return rangeEnd }
|
2795 |
+
lineObj = getLine(doc, lineN = rangeEnd.line)
|
2796 |
+
}
|
2797 |
+
}
|
2798 |
+
|
2799 |
+
function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
|
2800 |
+
y -= widgetTopHeight(lineObj)
|
2801 |
+
var end = lineObj.text.length
|
2802 |
+
var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0)
|
2803 |
+
end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end)
|
2804 |
+
return {begin: begin, end: end}
|
2805 |
+
}
|
2806 |
+
|
2807 |
+
function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
|
2808 |
+
if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }
|
2809 |
+
var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top
|
2810 |
+
return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
|
2811 |
+
}
|
2812 |
+
|
2813 |
+
// Returns true if the given side of a box is after the given
|
2814 |
+
// coordinates, in top-to-bottom, left-to-right order.
|
2815 |
+
function boxIsAfter(box, x, y, left) {
|
2816 |
+
return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
|
2817 |
+
}
|
2818 |
+
|
2819 |
+
function coordsCharInner(cm, lineObj, lineNo, x, y) {
|
2820 |
+
// Move y into line-local coordinate space
|
2821 |
+
y -= heightAtLine(lineObj)
|
2822 |
+
var preparedMeasure = prepareMeasureForLine(cm, lineObj)
|
2823 |
+
// When directly calling `measureCharPrepared`, we have to adjust
|
2824 |
+
// for the widgets at this line.
|
2825 |
+
var widgetHeight = widgetTopHeight(lineObj)
|
2826 |
+
var begin = 0, end = lineObj.text.length, ltr = true
|
2827 |
+
|
2828 |
+
var order = getOrder(lineObj, cm.doc.direction)
|
2829 |
+
// If the line isn't plain left-to-right text, first figure out
|
2830 |
+
// which bidi section the coordinates fall into.
|
2831 |
+
if (order) {
|
2832 |
+
var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)
|
2833 |
+
(cm, lineObj, lineNo, preparedMeasure, order, x, y)
|
2834 |
+
ltr = part.level != 1
|
2835 |
+
// The awkward -1 offsets are needed because findFirst (called
|
2836 |
+
// on these below) will treat its first bound as inclusive,
|
2837 |
+
// second as exclusive, but we want to actually address the
|
2838 |
+
// characters in the part's range
|
2839 |
+
begin = ltr ? part.from : part.to - 1
|
2840 |
+
end = ltr ? part.to : part.from - 1
|
2841 |
+
}
|
2842 |
+
|
2843 |
+
// A binary search to find the first character whose bounding box
|
2844 |
+
// starts after the coordinates. If we run across any whose box wrap
|
2845 |
+
// the coordinates, store that.
|
2846 |
+
var chAround = null, boxAround = null
|
2847 |
+
var ch = findFirst(function (ch) {
|
2848 |
+
var box = measureCharPrepared(cm, preparedMeasure, ch)
|
2849 |
+
box.top += widgetHeight; box.bottom += widgetHeight
|
2850 |
+
if (!boxIsAfter(box, x, y, false)) { return false }
|
2851 |
+
if (box.top <= y && box.left <= x) {
|
2852 |
+
chAround = ch
|
2853 |
+
boxAround = box
|
2854 |
+
}
|
2855 |
+
return true
|
2856 |
+
}, begin, end)
|
2857 |
+
|
2858 |
+
var baseX, sticky, outside = false
|
2859 |
+
// If a box around the coordinates was found, use that
|
2860 |
+
if (boxAround) {
|
2861 |
+
// Distinguish coordinates nearer to the left or right side of the box
|
2862 |
+
var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr
|
2863 |
+
ch = chAround + (atStart ? 0 : 1)
|
2864 |
+
sticky = atStart ? "after" : "before"
|
2865 |
+
baseX = atLeft ? boxAround.left : boxAround.right
|
2866 |
+
} else {
|
2867 |
+
// (Adjust for extended bound, if necessary.)
|
2868 |
+
if (!ltr && (ch == end || ch == begin)) { ch++ }
|
2869 |
+
// To determine which side to associate with, get the box to the
|
2870 |
+
// left of the character and compare it's vertical position to the
|
2871 |
+
// coordinates
|
2872 |
+
sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" :
|
2873 |
+
(measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight <= y) == ltr ?
|
2874 |
+
"after" : "before"
|
2875 |
+
// Now get accurate coordinates for this place, in order to get a
|
2876 |
+
// base X position
|
2877 |
+
var coords = cursorCoords(cm, Pos(lineNo, ch, sticky), "line", lineObj, preparedMeasure)
|
2878 |
+
baseX = coords.left
|
2879 |
+
outside = y < coords.top || y >= coords.bottom
|
2880 |
+
}
|
2881 |
+
|
2882 |
+
ch = skipExtendingChars(lineObj.text, ch, 1)
|
2883 |
+
return PosWithInfo(lineNo, ch, sticky, outside, x - baseX)
|
2884 |
+
}
|
2885 |
+
|
2886 |
+
function coordsBidiPart(cm, lineObj, lineNo, preparedMeasure, order, x, y) {
|
2887 |
+
// Bidi parts are sorted left-to-right, and in a non-line-wrapping
|
2888 |
+
// situation, we can take this ordering to correspond to the visual
|
2889 |
+
// ordering. This finds the first part whose end is after the given
|
2890 |
+
// coordinates.
|
2891 |
+
var index = findFirst(function (i) {
|
2892 |
+
var part = order[i], ltr = part.level != 1
|
2893 |
+
return boxIsAfter(cursorCoords(cm, Pos(lineNo, ltr ? part.to : part.from, ltr ? "before" : "after"),
|
2894 |
+
"line", lineObj, preparedMeasure), x, y, true)
|
2895 |
+
}, 0, order.length - 1)
|
2896 |
+
var part = order[index]
|
2897 |
+
// If this isn't the first part, the part's start is also after
|
2898 |
+
// the coordinates, and the coordinates aren't on the same line as
|
2899 |
+
// that start, move one part back.
|
2900 |
+
if (index > 0) {
|
2901 |
+
var ltr = part.level != 1
|
2902 |
+
var start = cursorCoords(cm, Pos(lineNo, ltr ? part.from : part.to, ltr ? "after" : "before"),
|
2903 |
+
"line", lineObj, preparedMeasure)
|
2904 |
+
if (boxIsAfter(start, x, y, true) && start.top > y)
|
2905 |
+
{ part = order[index - 1] }
|
2906 |
+
}
|
2907 |
+
return part
|
2908 |
+
}
|
2909 |
+
|
2910 |
+
function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
|
2911 |
+
// In a wrapped line, rtl text on wrapping boundaries can do things
|
2912 |
+
// that don't correspond to the ordering in our `order` array at
|
2913 |
+
// all, so a binary search doesn't work, and we want to return a
|
2914 |
+
// part that only spans one line so that the binary search in
|
2915 |
+
// coordsCharInner is safe. As such, we first find the extent of the
|
2916 |
+
// wrapped line, and then do a flat search in which we discard any
|
2917 |
+
// spans that aren't on the line.
|
2918 |
+
var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y);
|
2919 |
+
var begin = ref.begin;
|
2920 |
+
var end = ref.end;
|
2921 |
+
if (/\s/.test(lineObj.text.charAt(end - 1))) { end-- }
|
2922 |
+
var part = null, closestDist = null
|
2923 |
+
for (var i = 0; i < order.length; i++) {
|
2924 |
+
var p = order[i]
|
2925 |
+
if (p.from >= end || p.to <= begin) { continue }
|
2926 |
+
var ltr = p.level != 1
|
2927 |
+
var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right
|
2928 |
+
// Weigh against spans ending before this, so that they are only
|
2929 |
+
// picked if nothing ends after
|
2930 |
+
var dist = endX < x ? x - endX + 1e9 : endX - x
|
2931 |
+
if (!part || closestDist > dist) {
|
2932 |
+
part = p
|
2933 |
+
closestDist = dist
|
2934 |
+
}
|
2935 |
+
}
|
2936 |
+
if (!part) { part = order[order.length - 1] }
|
2937 |
+
// Clip the part to the wrapped line.
|
2938 |
+
if (part.from < begin) { part = {from: begin, to: part.to, level: part.level} }
|
2939 |
+
if (part.to > end) { part = {from: part.from, to: end, level: part.level} }
|
2940 |
+
return part
|
2941 |
+
}
|
2942 |
+
|
2943 |
+
var measureText
|
2944 |
+
// Compute the default text height.
|
2945 |
+
function textHeight(display) {
|
2946 |
+
if (display.cachedTextHeight != null) { return display.cachedTextHeight }
|
2947 |
+
if (measureText == null) {
|
2948 |
+
measureText = elt("pre")
|
2949 |
+
// Measure a bunch of lines, for browsers that compute
|
2950 |
+
// fractional heights.
|
2951 |
+
for (var i = 0; i < 49; ++i) {
|
2952 |
+
measureText.appendChild(document.createTextNode("x"))
|
2953 |
+
measureText.appendChild(elt("br"))
|
2954 |
+
}
|
2955 |
+
measureText.appendChild(document.createTextNode("x"))
|
2956 |
+
}
|
2957 |
+
removeChildrenAndAdd(display.measure, measureText)
|
2958 |
+
var height = measureText.offsetHeight / 50
|
2959 |
+
if (height > 3) { display.cachedTextHeight = height }
|
2960 |
+
removeChildren(display.measure)
|
2961 |
+
return height || 1
|
2962 |
+
}
|
2963 |
+
|
2964 |
+
// Compute the default character width.
|
2965 |
+
function charWidth(display) {
|
2966 |
+
if (display.cachedCharWidth != null) { return display.cachedCharWidth }
|
2967 |
+
var anchor = elt("span", "xxxxxxxxxx")
|
2968 |
+
var pre = elt("pre", [anchor])
|
2969 |
+
removeChildrenAndAdd(display.measure, pre)
|
2970 |
+
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10
|
2971 |
+
if (width > 2) { display.cachedCharWidth = width }
|
2972 |
+
return width || 10
|
2973 |
+
}
|
2974 |
+
|
2975 |
+
// Do a bulk-read of the DOM positions and sizes needed to draw the
|
2976 |
+
// view, so that we don't interleave reading and writing to the DOM.
|
2977 |
+
function getDimensions(cm) {
|
2978 |
+
var d = cm.display, left = {}, width = {}
|
2979 |
+
var gutterLeft = d.gutters.clientLeft
|
2980 |
+
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
|
2981 |
+
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft
|
2982 |
+
width[cm.options.gutters[i]] = n.clientWidth
|
2983 |
+
}
|
2984 |
+
return {fixedPos: compensateForHScroll(d),
|
2985 |
+
gutterTotalWidth: d.gutters.offsetWidth,
|
2986 |
+
gutterLeft: left,
|
2987 |
+
gutterWidth: width,
|
2988 |
+
wrapperWidth: d.wrapper.clientWidth}
|
2989 |
+
}
|
2990 |
+
|
2991 |
+
// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
|
2992 |
+
// but using getBoundingClientRect to get a sub-pixel-accurate
|
2993 |
+
// result.
|
2994 |
+
function compensateForHScroll(display) {
|
2995 |
+
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left
|
2996 |
+
}
|
2997 |
+
|
2998 |
+
// Returns a function that estimates the height of a line, to use as
|
2999 |
+
// first approximation until the line becomes visible (and is thus
|
3000 |
+
// properly measurable).
|
3001 |
+
function estimateHeight(cm) {
|
3002 |
+
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping
|
3003 |
+
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3)
|
3004 |
+
return function (line) {
|
3005 |
+
if (lineIsHidden(cm.doc, line)) { return 0 }
|
3006 |
+
|
3007 |
+
var widgetsHeight = 0
|
3008 |
+
if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
|
3009 |
+
if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height }
|
3010 |
+
} }
|
3011 |
+
|
3012 |
+
if (wrapping)
|
3013 |
+
{ return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
|
3014 |
+
else
|
3015 |
+
{ return widgetsHeight + th }
|
3016 |
+
}
|
3017 |
+
}
|
3018 |
+
|
3019 |
+
function estimateLineHeights(cm) {
|
3020 |
+
var doc = cm.doc, est = estimateHeight(cm)
|
3021 |
+
doc.iter(function (line) {
|
3022 |
+
var estHeight = est(line)
|
3023 |
+
if (estHeight != line.height) { updateLineHeight(line, estHeight) }
|
3024 |
+
})
|
3025 |
+
}
|
3026 |
+
|
3027 |
+
// Given a mouse event, find the corresponding position. If liberal
|
3028 |
+
// is false, it checks whether a gutter or scrollbar was clicked,
|
3029 |
+
// and returns null if it was. forRect is used by rectangular
|
3030 |
+
// selections, and tries to estimate a character position even for
|
3031 |
+
// coordinates beyond the right of the text.
|
3032 |
+
function posFromMouse(cm, e, liberal, forRect) {
|
3033 |
+
var display = cm.display
|
3034 |
+
if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null }
|
3035 |
+
|
3036 |
+
var x, y, space = display.lineSpace.getBoundingClientRect()
|
3037 |
+
// Fails unpredictably on IE[67] when mouse is dragged around quickly.
|
3038 |
+
try { x = e.clientX - space.left; y = e.clientY - space.top }
|
3039 |
+
catch (e) { return null }
|
3040 |
+
var coords = coordsChar(cm, x, y), line
|
3041 |
+
if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
|
3042 |
+
var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length
|
3043 |
+
coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff))
|
3044 |
+
}
|
3045 |
+
return coords
|
3046 |
+
}
|
3047 |
+
|
3048 |
+
// Find the view element corresponding to a given line. Return null
|
3049 |
+
// when the line isn't visible.
|
3050 |
+
function findViewIndex(cm, n) {
|
3051 |
+
if (n >= cm.display.viewTo) { return null }
|
3052 |
+
n -= cm.display.viewFrom
|
3053 |
+
if (n < 0) { return null }
|
3054 |
+
var view = cm.display.view
|
3055 |
+
for (var i = 0; i < view.length; i++) {
|
3056 |
+
n -= view[i].size
|
3057 |
+
if (n < 0) { return i }
|
3058 |
+
}
|
3059 |
+
}
|
3060 |
+
|
3061 |
+
function updateSelection(cm) {
|
3062 |
+
cm.display.input.showSelection(cm.display.input.prepareSelection())
|
3063 |
+
}
|
3064 |
+
|
3065 |
+
function prepareSelection(cm, primary) {
|
3066 |
+
if ( primary === void 0 ) primary = true;
|
3067 |
+
|
3068 |
+
var doc = cm.doc, result = {}
|
3069 |
+
var curFragment = result.cursors = document.createDocumentFragment()
|
3070 |
+
var selFragment = result.selection = document.createDocumentFragment()
|
3071 |
+
|
3072 |
+
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
3073 |
+
if (!primary && i == doc.sel.primIndex) { continue }
|
3074 |
+
var range = doc.sel.ranges[i]
|
3075 |
+
if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue }
|
3076 |
+
var collapsed = range.empty()
|
3077 |
+
if (collapsed || cm.options.showCursorWhenSelecting)
|
3078 |
+
{ drawSelectionCursor(cm, range.head, curFragment) }
|
3079 |
+
if (!collapsed)
|
3080 |
+
{ drawSelectionRange(cm, range, selFragment) }
|
3081 |
+
}
|
3082 |
+
return result
|
3083 |
+
}
|
3084 |
+
|
3085 |
+
// Draws a cursor for the given range
|
3086 |
+
function drawSelectionCursor(cm, head, output) {
|
3087 |
+
var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine)
|
3088 |
+
|
3089 |
+
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"))
|
3090 |
+
cursor.style.left = pos.left + "px"
|
3091 |
+
cursor.style.top = pos.top + "px"
|
3092 |
+
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"
|
3093 |
+
|
3094 |
+
if (pos.other) {
|
3095 |
+
// Secondary cursor, shown when on a 'jump' in bi-directional text
|
3096 |
+
var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"))
|
3097 |
+
otherCursor.style.display = ""
|
3098 |
+
otherCursor.style.left = pos.other.left + "px"
|
3099 |
+
otherCursor.style.top = pos.other.top + "px"
|
3100 |
+
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"
|
3101 |
+
}
|
3102 |
+
}
|
3103 |
+
|
3104 |
+
function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }
|
3105 |
+
|
3106 |
+
// Draws the given range as a highlighted selection
|
3107 |
+
function drawSelectionRange(cm, range, output) {
|
3108 |
+
var display = cm.display, doc = cm.doc
|
3109 |
+
var fragment = document.createDocumentFragment()
|
3110 |
+
var padding = paddingH(cm.display), leftSide = padding.left
|
3111 |
+
var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right
|
3112 |
+
var docLTR = doc.direction == "ltr"
|
3113 |
+
|
3114 |
+
function add(left, top, width, bottom) {
|
3115 |
+
if (top < 0) { top = 0 }
|
3116 |
+
top = Math.round(top)
|
3117 |
+
bottom = Math.round(bottom)
|
3118 |
+
fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px")))
|
3119 |
+
}
|
3120 |
+
|
3121 |
+
function drawForLine(line, fromArg, toArg) {
|
3122 |
+
var lineObj = getLine(doc, line)
|
3123 |
+
var lineLen = lineObj.text.length
|
3124 |
+
var start, end
|
3125 |
+
function coords(ch, bias) {
|
3126 |
+
return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
|
3127 |
+
}
|
3128 |
+
|
3129 |
+
function wrapX(pos, dir, side) {
|
3130 |
+
var extent = wrappedLineExtentChar(cm, lineObj, null, pos)
|
3131 |
+
var prop = (dir == "ltr") == (side == "after") ? "left" : "right"
|
3132 |
+
var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1)
|
3133 |
+
return coords(ch, prop)[prop]
|
3134 |
+
}
|
3135 |
+
|
3136 |
+
var order = getOrder(lineObj, doc.direction)
|
3137 |
+
iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) {
|
3138 |
+
var ltr = dir == "ltr"
|
3139 |
+
var fromPos = coords(from, ltr ? "left" : "right")
|
3140 |
+
var toPos = coords(to - 1, ltr ? "right" : "left")
|
3141 |
+
|
3142 |
+
var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen
|
3143 |
+
var first = i == 0, last = !order || i == order.length - 1
|
3144 |
+
if (toPos.top - fromPos.top <= 3) { // Single line
|
3145 |
+
var openLeft = (docLTR ? openStart : openEnd) && first
|
3146 |
+
var openRight = (docLTR ? openEnd : openStart) && last
|
3147 |
+
var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left
|
3148 |
+
var right = openRight ? rightSide : (ltr ? toPos : fromPos).right
|
3149 |
+
add(left, fromPos.top, right - left, fromPos.bottom)
|
3150 |
+
} else { // Multiple lines
|
3151 |
+
var topLeft, topRight, botLeft, botRight
|
3152 |
+
if (ltr) {
|
3153 |
+
topLeft = docLTR && openStart && first ? leftSide : fromPos.left
|
3154 |
+
topRight = docLTR ? rightSide : wrapX(from, dir, "before")
|
3155 |
+
botLeft = docLTR ? leftSide : wrapX(to, dir, "after")
|
3156 |
+
botRight = docLTR && openEnd && last ? rightSide : toPos.right
|
3157 |
+
} else {
|
3158 |
+
topLeft = !docLTR ? leftSide : wrapX(from, dir, "before")
|
3159 |
+
topRight = !docLTR && openStart && first ? rightSide : fromPos.right
|
3160 |
+
botLeft = !docLTR && openEnd && last ? leftSide : toPos.left
|
3161 |
+
botRight = !docLTR ? rightSide : wrapX(to, dir, "after")
|
3162 |
+
}
|
3163 |
+
add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom)
|
3164 |
+
if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top) }
|
3165 |
+
add(botLeft, toPos.top, botRight - botLeft, toPos.bottom)
|
3166 |
+
}
|
3167 |
+
|
3168 |
+
if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos }
|
3169 |
+
if (cmpCoords(toPos, start) < 0) { start = toPos }
|
3170 |
+
if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos }
|
3171 |
+
if (cmpCoords(toPos, end) < 0) { end = toPos }
|
3172 |
+
})
|
3173 |
+
return {start: start, end: end}
|
3174 |
+
}
|
3175 |
+
|
3176 |
+
var sFrom = range.from(), sTo = range.to()
|
3177 |
+
if (sFrom.line == sTo.line) {
|
3178 |
+
drawForLine(sFrom.line, sFrom.ch, sTo.ch)
|
3179 |
+
} else {
|
3180 |
+
var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line)
|
3181 |
+
var singleVLine = visualLine(fromLine) == visualLine(toLine)
|
3182 |
+
var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end
|
3183 |
+
var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start
|
3184 |
+
if (singleVLine) {
|
3185 |
+
if (leftEnd.top < rightStart.top - 2) {
|
3186 |
+
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom)
|
3187 |
+
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom)
|
3188 |
+
} else {
|
3189 |
+
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom)
|
3190 |
+
}
|
3191 |
+
}
|
3192 |
+
if (leftEnd.bottom < rightStart.top)
|
3193 |
+
{ add(leftSide, leftEnd.bottom, null, rightStart.top) }
|
3194 |
+
}
|
3195 |
+
|
3196 |
+
output.appendChild(fragment)
|
3197 |
+
}
|
3198 |
+
|
3199 |
+
// Cursor-blinking
|
3200 |
+
function restartBlink(cm) {
|
3201 |
+
if (!cm.state.focused) { return }
|
3202 |
+
var display = cm.display
|
3203 |
+
clearInterval(display.blinker)
|
3204 |
+
var on = true
|
3205 |
+
display.cursorDiv.style.visibility = ""
|
3206 |
+
if (cm.options.cursorBlinkRate > 0)
|
3207 |
+
{ display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
|
3208 |
+
cm.options.cursorBlinkRate) }
|
3209 |
+
else if (cm.options.cursorBlinkRate < 0)
|
3210 |
+
{ display.cursorDiv.style.visibility = "hidden" }
|
3211 |
+
}
|
3212 |
+
|
3213 |
+
function ensureFocus(cm) {
|
3214 |
+
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm) }
|
3215 |
+
}
|
3216 |
+
|
3217 |
+
function delayBlurEvent(cm) {
|
3218 |
+
cm.state.delayingBlurEvent = true
|
3219 |
+
setTimeout(function () { if (cm.state.delayingBlurEvent) {
|
3220 |
+
cm.state.delayingBlurEvent = false
|
3221 |
+
onBlur(cm)
|
3222 |
+
} }, 100)
|
3223 |
+
}
|
3224 |
+
|
3225 |
+
function onFocus(cm, e) {
|
3226 |
+
if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false }
|
3227 |
+
|
3228 |
+
if (cm.options.readOnly == "nocursor") { return }
|
3229 |
+
if (!cm.state.focused) {
|
3230 |
+
signal(cm, "focus", cm, e)
|
3231 |
+
cm.state.focused = true
|
3232 |
+
addClass(cm.display.wrapper, "CodeMirror-focused")
|
3233 |
+
// This test prevents this from firing when a context
|
3234 |
+
// menu is closed (since the input reset would kill the
|
3235 |
+
// select-all detection hack)
|
3236 |
+
if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
|
3237 |
+
cm.display.input.reset()
|
3238 |
+
if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20) } // Issue #1730
|
3239 |
+
}
|
3240 |
+
cm.display.input.receivedFocus()
|
3241 |
+
}
|
3242 |
+
restartBlink(cm)
|
3243 |
+
}
|
3244 |
+
function onBlur(cm, e) {
|
3245 |
+
if (cm.state.delayingBlurEvent) { return }
|
3246 |
+
|
3247 |
+
if (cm.state.focused) {
|
3248 |
+
signal(cm, "blur", cm, e)
|
3249 |
+
cm.state.focused = false
|
3250 |
+
rmClass(cm.display.wrapper, "CodeMirror-focused")
|
3251 |
+
}
|
3252 |
+
clearInterval(cm.display.blinker)
|
3253 |
+
setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false } }, 150)
|
3254 |
+
}
|
3255 |
+
|
3256 |
+
// Read the actual heights of the rendered lines, and update their
|
3257 |
+
// stored heights to match.
|
3258 |
+
function updateHeightsInViewport(cm) {
|
3259 |
+
var display = cm.display
|
3260 |
+
var prevBottom = display.lineDiv.offsetTop
|
3261 |
+
for (var i = 0; i < display.view.length; i++) {
|
3262 |
+
var cur = display.view[i], height = (void 0)
|
3263 |
+
if (cur.hidden) { continue }
|
3264 |
+
if (ie && ie_version < 8) {
|
3265 |
+
var bot = cur.node.offsetTop + cur.node.offsetHeight
|
3266 |
+
height = bot - prevBottom
|
3267 |
+
prevBottom = bot
|
3268 |
+
} else {
|
3269 |
+
var box = cur.node.getBoundingClientRect()
|
3270 |
+
height = box.bottom - box.top
|
3271 |
+
}
|
3272 |
+
var diff = cur.line.height - height
|
3273 |
+
if (height < 2) { height = textHeight(display) }
|
3274 |
+
if (diff > .005 || diff < -.005) {
|
3275 |
+
updateLineHeight(cur.line, height)
|
3276 |
+
updateWidgetHeight(cur.line)
|
3277 |
+
if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
|
3278 |
+
{ updateWidgetHeight(cur.rest[j]) } }
|
3279 |
+
}
|
3280 |
+
}
|
3281 |
+
}
|
3282 |
+
|
3283 |
+
// Read and store the height of line widgets associated with the
|
3284 |
+
// given line.
|
3285 |
+
function updateWidgetHeight(line) {
|
3286 |
+
if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) {
|
3287 |
+
var w = line.widgets[i], parent = w.node.parentNode
|
3288 |
+
if (parent) { w.height = parent.offsetHeight }
|
3289 |
+
} }
|
3290 |
+
}
|
3291 |
+
|
3292 |
+
// Compute the lines that are visible in a given viewport (defaults
|
3293 |
+
// the the current scroll position). viewport may contain top,
|
3294 |
+
// height, and ensure (see op.scrollToPos) properties.
|
3295 |
+
function visibleLines(display, doc, viewport) {
|
3296 |
+
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop
|
3297 |
+
top = Math.floor(top - paddingTop(display))
|
3298 |
+
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight
|
3299 |
+
|
3300 |
+
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom)
|
3301 |
+
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
|
3302 |
+
// forces those lines into the viewport (if possible).
|
3303 |
+
if (viewport && viewport.ensure) {
|
3304 |
+
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line
|
3305 |
+
if (ensureFrom < from) {
|
3306 |
+
from = ensureFrom
|
3307 |
+
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)
|
3308 |
+
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
|
3309 |
+
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight)
|
3310 |
+
to = ensureTo
|
3311 |
+
}
|
3312 |
+
}
|
3313 |
+
return {from: from, to: Math.max(to, from + 1)}
|
3314 |
+
}
|
3315 |
+
|
3316 |
+
// Re-align line numbers and gutter marks to compensate for
|
3317 |
+
// horizontal scrolling.
|
3318 |
+
function alignHorizontally(cm) {
|
3319 |
+
var display = cm.display, view = display.view
|
3320 |
+
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }
|
3321 |
+
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft
|
3322 |
+
var gutterW = display.gutters.offsetWidth, left = comp + "px"
|
3323 |
+
for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {
|
3324 |
+
if (cm.options.fixedGutter) {
|
3325 |
+
if (view[i].gutter)
|
3326 |
+
{ view[i].gutter.style.left = left }
|
3327 |
+
if (view[i].gutterBackground)
|
3328 |
+
{ view[i].gutterBackground.style.left = left }
|
3329 |
+
}
|
3330 |
+
var align = view[i].alignable
|
3331 |
+
if (align) { for (var j = 0; j < align.length; j++)
|
3332 |
+
{ align[j].style.left = left } }
|
3333 |
+
} }
|
3334 |
+
if (cm.options.fixedGutter)
|
3335 |
+
{ display.gutters.style.left = (comp + gutterW) + "px" }
|
3336 |
+
}
|
3337 |
+
|
3338 |
+
// Used to ensure that the line number gutter is still the right
|
3339 |
+
// size for the current document size. Returns true when an update
|
3340 |
+
// is needed.
|
3341 |
+
function maybeUpdateLineNumberWidth(cm) {
|
3342 |
+
if (!cm.options.lineNumbers) { return false }
|
3343 |
+
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display
|
3344 |
+
if (last.length != display.lineNumChars) {
|
3345 |
+
var test = display.measure.appendChild(elt("div", [elt("div", last)],
|
3346 |
+
"CodeMirror-linenumber CodeMirror-gutter-elt"))
|
3347 |
+
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW
|
3348 |
+
display.lineGutter.style.width = ""
|
3349 |
+
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1
|
3350 |
+
display.lineNumWidth = display.lineNumInnerWidth + padding
|
3351 |
+
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1
|
3352 |
+
display.lineGutter.style.width = display.lineNumWidth + "px"
|
3353 |
+
updateGutterSpace(cm)
|
3354 |
+
return true
|
3355 |
+
}
|
3356 |
+
return false
|
3357 |
+
}
|
3358 |
+
|
3359 |
+
// SCROLLING THINGS INTO VIEW
|
3360 |
+
|
3361 |
+
// If an editor sits on the top or bottom of the window, partially
|
3362 |
+
// scrolled out of view, this ensures that the cursor is visible.
|
3363 |
+
function maybeScrollWindow(cm, rect) {
|
3364 |
+
if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
|
3365 |
+
|
3366 |
+
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null
|
3367 |
+
if (rect.top + box.top < 0) { doScroll = true }
|
3368 |
+
else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false }
|
3369 |
+
if (doScroll != null && !phantom) {
|
3370 |
+
var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"))
|
3371 |
+
cm.display.lineSpace.appendChild(scrollNode)
|
3372 |
+
scrollNode.scrollIntoView(doScroll)
|
3373 |
+
cm.display.lineSpace.removeChild(scrollNode)
|
3374 |
+
}
|
3375 |
+
}
|
3376 |
+
|
3377 |
+
// Scroll a given position into view (immediately), verifying that
|
3378 |
+
// it actually became visible (as line heights are accurately
|
3379 |
+
// measured, the position of something may 'drift' during drawing).
|
3380 |
+
function scrollPosIntoView(cm, pos, end, margin) {
|
3381 |
+
if (margin == null) { margin = 0 }
|
3382 |
+
var rect
|
3383 |
+
if (!cm.options.lineWrapping && pos == end) {
|
3384 |
+
// Set pos and end to the cursor positions around the character pos sticks to
|
3385 |
+
// If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
|
3386 |
+
// If pos == Pos(_, 0, "before"), pos and end are unchanged
|
3387 |
+
pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos
|
3388 |
+
end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos
|
3389 |
+
}
|
3390 |
+
for (var limit = 0; limit < 5; limit++) {
|
3391 |
+
var changed = false
|
3392 |
+
var coords = cursorCoords(cm, pos)
|
3393 |
+
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end)
|
3394 |
+
rect = {left: Math.min(coords.left, endCoords.left),
|
3395 |
+
top: Math.min(coords.top, endCoords.top) - margin,
|
3396 |
+
right: Math.max(coords.left, endCoords.left),
|
3397 |
+
bottom: Math.max(coords.bottom, endCoords.bottom) + margin}
|
3398 |
+
var scrollPos = calculateScrollPos(cm, rect)
|
3399 |
+
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft
|
3400 |
+
if (scrollPos.scrollTop != null) {
|
3401 |
+
updateScrollTop(cm, scrollPos.scrollTop)
|
3402 |
+
if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true }
|
3403 |
+
}
|
3404 |
+
if (scrollPos.scrollLeft != null) {
|
3405 |
+
setScrollLeft(cm, scrollPos.scrollLeft)
|
3406 |
+
if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true }
|
3407 |
+
}
|
3408 |
+
if (!changed) { break }
|
3409 |
+
}
|
3410 |
+
return rect
|
3411 |
+
}
|
3412 |
+
|
3413 |
+
// Scroll a given set of coordinates into view (immediately).
|
3414 |
+
function scrollIntoView(cm, rect) {
|
3415 |
+
var scrollPos = calculateScrollPos(cm, rect)
|
3416 |
+
if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop) }
|
3417 |
+
if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft) }
|
3418 |
+
}
|
3419 |
+
|
3420 |
+
// Calculate a new scroll position needed to scroll the given
|
3421 |
+
// rectangle into view. Returns an object with scrollTop and
|
3422 |
+
// scrollLeft properties. When these are undefined, the
|
3423 |
+
// vertical/horizontal position does not need to be adjusted.
|
3424 |
+
function calculateScrollPos(cm, rect) {
|
3425 |
+
var display = cm.display, snapMargin = textHeight(cm.display)
|
3426 |
+
if (rect.top < 0) { rect.top = 0 }
|
3427 |
+
var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop
|
3428 |
+
var screen = displayHeight(cm), result = {}
|
3429 |
+
if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen }
|
3430 |
+
var docBottom = cm.doc.height + paddingVert(display)
|
3431 |
+
var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin
|
3432 |
+
if (rect.top < screentop) {
|
3433 |
+
result.scrollTop = atTop ? 0 : rect.top
|
3434 |
+
} else if (rect.bottom > screentop + screen) {
|
3435 |
+
var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen)
|
3436 |
+
if (newTop != screentop) { result.scrollTop = newTop }
|
3437 |
+
}
|
3438 |
+
|
3439 |
+
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft
|
3440 |
+
var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0)
|
3441 |
+
var tooWide = rect.right - rect.left > screenw
|
3442 |
+
if (tooWide) { rect.right = rect.left + screenw }
|
3443 |
+
if (rect.left < 10)
|
3444 |
+
{ result.scrollLeft = 0 }
|
3445 |
+
else if (rect.left < screenleft)
|
3446 |
+
{ result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)) }
|
3447 |
+
else if (rect.right > screenw + screenleft - 3)
|
3448 |
+
{ result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw }
|
3449 |
+
return result
|
3450 |
+
}
|
3451 |
+
|
3452 |
+
// Store a relative adjustment to the scroll position in the current
|
3453 |
+
// operation (to be applied when the operation finishes).
|
3454 |
+
function addToScrollTop(cm, top) {
|
3455 |
+
if (top == null) { return }
|
3456 |
+
resolveScrollToPos(cm)
|
3457 |
+
cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top
|
3458 |
+
}
|
3459 |
+
|
3460 |
+
// Make sure that at the end of the operation the current cursor is
|
3461 |
+
// shown.
|
3462 |
+
function ensureCursorVisible(cm) {
|
3463 |
+
resolveScrollToPos(cm)
|
3464 |
+
var cur = cm.getCursor()
|
3465 |
+
cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin}
|
3466 |
+
}
|
3467 |
+
|
3468 |
+
function scrollToCoords(cm, x, y) {
|
3469 |
+
if (x != null || y != null) { resolveScrollToPos(cm) }
|
3470 |
+
if (x != null) { cm.curOp.scrollLeft = x }
|
3471 |
+
if (y != null) { cm.curOp.scrollTop = y }
|
3472 |
+
}
|
3473 |
+
|
3474 |
+
function scrollToRange(cm, range) {
|
3475 |
+
resolveScrollToPos(cm)
|
3476 |
+
cm.curOp.scrollToPos = range
|
3477 |
+
}
|
3478 |
+
|
3479 |
+
// When an operation has its scrollToPos property set, and another
|
3480 |
+
// scroll action is applied before the end of the operation, this
|
3481 |
+
// 'simulates' scrolling that position into view in a cheap way, so
|
3482 |
+
// that the effect of intermediate scroll commands is not ignored.
|
3483 |
+
function resolveScrollToPos(cm) {
|
3484 |
+
var range = cm.curOp.scrollToPos
|
3485 |
+
if (range) {
|
3486 |
+
cm.curOp.scrollToPos = null
|
3487 |
+
var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to)
|
3488 |
+
scrollToCoordsRange(cm, from, to, range.margin)
|
3489 |
+
}
|
3490 |
+
}
|
3491 |
+
|
3492 |
+
function scrollToCoordsRange(cm, from, to, margin) {
|
3493 |
+
var sPos = calculateScrollPos(cm, {
|
3494 |
+
left: Math.min(from.left, to.left),
|
3495 |
+
top: Math.min(from.top, to.top) - margin,
|
3496 |
+
right: Math.max(from.right, to.right),
|
3497 |
+
bottom: Math.max(from.bottom, to.bottom) + margin
|
3498 |
+
})
|
3499 |
+
scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop)
|
3500 |
+
}
|
3501 |
+
|
3502 |
+
// Sync the scrollable area and scrollbars, ensure the viewport
|
3503 |
+
// covers the visible area.
|
3504 |
+
function updateScrollTop(cm, val) {
|
3505 |
+
if (Math.abs(cm.doc.scrollTop - val) < 2) { return }
|
3506 |
+
if (!gecko) { updateDisplaySimple(cm, {top: val}) }
|
3507 |
+
setScrollTop(cm, val, true)
|
3508 |
+
if (gecko) { updateDisplaySimple(cm) }
|
3509 |
+
startWorker(cm, 100)
|
3510 |
+
}
|
3511 |
+
|
3512 |
+
function setScrollTop(cm, val, forceScroll) {
|
3513 |
+
val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val)
|
3514 |
+
if (cm.display.scroller.scrollTop == val && !forceScroll) { return }
|
3515 |
+
cm.doc.scrollTop = val
|
3516 |
+
cm.display.scrollbars.setScrollTop(val)
|
3517 |
+
if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val }
|
3518 |
+
}
|
3519 |
+
|
3520 |
+
// Sync scroller and scrollbar, ensure the gutter elements are
|
3521 |
+
// aligned.
|
3522 |
+
function setScrollLeft(cm, val, isScroller, forceScroll) {
|
3523 |
+
val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)
|
3524 |
+
if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }
|
3525 |
+
cm.doc.scrollLeft = val
|
3526 |
+
alignHorizontally(cm)
|
3527 |
+
if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val }
|
3528 |
+
cm.display.scrollbars.setScrollLeft(val)
|
3529 |
+
}
|
3530 |
+
|
3531 |
+
// SCROLLBARS
|
3532 |
+
|
3533 |
+
// Prepare DOM reads needed to update the scrollbars. Done in one
|
3534 |
+
// shot to minimize update/measure roundtrips.
|
3535 |
+
function measureForScrollbars(cm) {
|
3536 |
+
var d = cm.display, gutterW = d.gutters.offsetWidth
|
3537 |
+
var docH = Math.round(cm.doc.height + paddingVert(cm.display))
|
3538 |
+
return {
|
3539 |
+
clientHeight: d.scroller.clientHeight,
|
3540 |
+
viewHeight: d.wrapper.clientHeight,
|
3541 |
+
scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
|
3542 |
+
viewWidth: d.wrapper.clientWidth,
|
3543 |
+
barLeft: cm.options.fixedGutter ? gutterW : 0,
|
3544 |
+
docHeight: docH,
|
3545 |
+
scrollHeight: docH + scrollGap(cm) + d.barHeight,
|
3546 |
+
nativeBarWidth: d.nativeBarWidth,
|
3547 |
+
gutterWidth: gutterW
|
3548 |
+
}
|
3549 |
+
}
|
3550 |
+
|
3551 |
+
var NativeScrollbars = function(place, scroll, cm) {
|
3552 |
+
this.cm = cm
|
3553 |
+
var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar")
|
3554 |
+
var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar")
|
3555 |
+
vert.tabIndex = horiz.tabIndex = -1
|
3556 |
+
place(vert); place(horiz)
|
3557 |
+
|
3558 |
+
on(vert, "scroll", function () {
|
3559 |
+
if (vert.clientHeight) { scroll(vert.scrollTop, "vertical") }
|
3560 |
+
})
|
3561 |
+
on(horiz, "scroll", function () {
|
3562 |
+
if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal") }
|
3563 |
+
})
|
3564 |
+
|
3565 |
+
this.checkedZeroWidth = false
|
3566 |
+
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
|
3567 |
+
if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px" }
|
3568 |
+
};
|
3569 |
+
|
3570 |
+
NativeScrollbars.prototype.update = function (measure) {
|
3571 |
+
var needsH = measure.scrollWidth > measure.clientWidth + 1
|
3572 |
+
var needsV = measure.scrollHeight > measure.clientHeight + 1
|
3573 |
+
var sWidth = measure.nativeBarWidth
|
3574 |
+
|
3575 |
+
if (needsV) {
|
3576 |
+
this.vert.style.display = "block"
|
3577 |
+
this.vert.style.bottom = needsH ? sWidth + "px" : "0"
|
3578 |
+
var totalHeight = measure.viewHeight - (needsH ? sWidth : 0)
|
3579 |
+
// A bug in IE8 can cause this value to be negative, so guard it.
|
3580 |
+
this.vert.firstChild.style.height =
|
3581 |
+
Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"
|
3582 |
+
} else {
|
3583 |
+
this.vert.style.display = ""
|
3584 |
+
this.vert.firstChild.style.height = "0"
|
3585 |
+
}
|
3586 |
+
|
3587 |
+
if (needsH) {
|
3588 |
+
this.horiz.style.display = "block"
|
3589 |
+
this.horiz.style.right = needsV ? sWidth + "px" : "0"
|
3590 |
+
this.horiz.style.left = measure.barLeft + "px"
|
3591 |
+
var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0)
|
3592 |
+
this.horiz.firstChild.style.width =
|
3593 |
+
Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px"
|
3594 |
+
} else {
|
3595 |
+
this.horiz.style.display = ""
|
3596 |
+
this.horiz.firstChild.style.width = "0"
|
3597 |
+
}
|
3598 |
+
|
3599 |
+
if (!this.checkedZeroWidth && measure.clientHeight > 0) {
|
3600 |
+
if (sWidth == 0) { this.zeroWidthHack() }
|
3601 |
+
this.checkedZeroWidth = true
|
3602 |
+
}
|
3603 |
+
|
3604 |
+
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
|
3605 |
+
};
|
3606 |
+
|
3607 |
+
NativeScrollbars.prototype.setScrollLeft = function (pos) {
|
3608 |
+
if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos }
|
3609 |
+
if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz") }
|
3610 |
+
};
|
3611 |
+
|
3612 |
+
NativeScrollbars.prototype.setScrollTop = function (pos) {
|
3613 |
+
if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos }
|
3614 |
+
if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert") }
|
3615 |
+
};
|
3616 |
+
|
3617 |
+
NativeScrollbars.prototype.zeroWidthHack = function () {
|
3618 |
+
var w = mac && !mac_geMountainLion ? "12px" : "18px"
|
3619 |
+
this.horiz.style.height = this.vert.style.width = w
|
3620 |
+
this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"
|
3621 |
+
this.disableHoriz = new Delayed
|
3622 |
+
this.disableVert = new Delayed
|
3623 |
+
};
|
3624 |
+
|
3625 |
+
NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
|
3626 |
+
bar.style.pointerEvents = "auto"
|
3627 |
+
function maybeDisable() {
|
3628 |
+
// To find out whether the scrollbar is still visible, we
|
3629 |
+
// check whether the element under the pixel in the bottom
|
3630 |
+
// right corner of the scrollbar box is the scrollbar box
|
3631 |
+
// itself (when the bar is still visible) or its filler child
|
3632 |
+
// (when the bar is hidden). If it is still visible, we keep
|
3633 |
+
// it enabled, if it's hidden, we disable pointer events.
|
3634 |
+
var box = bar.getBoundingClientRect()
|
3635 |
+
var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
|
3636 |
+
: document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1)
|
3637 |
+
if (elt != bar) { bar.style.pointerEvents = "none" }
|
3638 |
+
else { delay.set(1000, maybeDisable) }
|
3639 |
+
}
|
3640 |
+
delay.set(1000, maybeDisable)
|
3641 |
+
};
|
3642 |
+
|
3643 |
+
NativeScrollbars.prototype.clear = function () {
|
3644 |
+
var parent = this.horiz.parentNode
|
3645 |
+
parent.removeChild(this.horiz)
|
3646 |
+
parent.removeChild(this.vert)
|
3647 |
+
};
|
3648 |
+
|
3649 |
+
var NullScrollbars = function () {};
|
3650 |
+
|
3651 |
+
NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
|
3652 |
+
NullScrollbars.prototype.setScrollLeft = function () {};
|
3653 |
+
NullScrollbars.prototype.setScrollTop = function () {};
|
3654 |
+
NullScrollbars.prototype.clear = function () {};
|
3655 |
+
|
3656 |
+
function updateScrollbars(cm, measure) {
|
3657 |
+
if (!measure) { measure = measureForScrollbars(cm) }
|
3658 |
+
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight
|
3659 |
+
updateScrollbarsInner(cm, measure)
|
3660 |
+
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
|
3661 |
+
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
|
3662 |
+
{ updateHeightsInViewport(cm) }
|
3663 |
+
updateScrollbarsInner(cm, measureForScrollbars(cm))
|
3664 |
+
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight
|
3665 |
+
}
|
3666 |
+
}
|
3667 |
+
|
3668 |
+
// Re-synchronize the fake scrollbars with the actual size of the
|
3669 |
+
// content.
|
3670 |
+
function updateScrollbarsInner(cm, measure) {
|
3671 |
+
var d = cm.display
|
3672 |
+
var sizes = d.scrollbars.update(measure)
|
3673 |
+
|
3674 |
+
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"
|
3675 |
+
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"
|
3676 |
+
d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
|
3677 |
+
|
3678 |
+
if (sizes.right && sizes.bottom) {
|
3679 |
+
d.scrollbarFiller.style.display = "block"
|
3680 |
+
d.scrollbarFiller.style.height = sizes.bottom + "px"
|
3681 |
+
d.scrollbarFiller.style.width = sizes.right + "px"
|
3682 |
+
} else { d.scrollbarFiller.style.display = "" }
|
3683 |
+
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
|
3684 |
+
d.gutterFiller.style.display = "block"
|
3685 |
+
d.gutterFiller.style.height = sizes.bottom + "px"
|
3686 |
+
d.gutterFiller.style.width = measure.gutterWidth + "px"
|
3687 |
+
} else { d.gutterFiller.style.display = "" }
|
3688 |
+
}
|
3689 |
+
|
3690 |
+
var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}
|
3691 |
+
|
3692 |
+
function initScrollbars(cm) {
|
3693 |
+
if (cm.display.scrollbars) {
|
3694 |
+
cm.display.scrollbars.clear()
|
3695 |
+
if (cm.display.scrollbars.addClass)
|
3696 |
+
{ rmClass(cm.display.wrapper, cm.display.scrollbars.addClass) }
|
3697 |
+
}
|
3698 |
+
|
3699 |
+
cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
|
3700 |
+
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller)
|
3701 |
+
// Prevent clicks in the scrollbars from killing focus
|
3702 |
+
on(node, "mousedown", function () {
|
3703 |
+
if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0) }
|
3704 |
+
})
|
3705 |
+
node.setAttribute("cm-not-content", "true")
|
3706 |
+
}, function (pos, axis) {
|
3707 |
+
if (axis == "horizontal") { setScrollLeft(cm, pos) }
|
3708 |
+
else { updateScrollTop(cm, pos) }
|
3709 |
+
}, cm)
|
3710 |
+
if (cm.display.scrollbars.addClass)
|
3711 |
+
{ addClass(cm.display.wrapper, cm.display.scrollbars.addClass) }
|
3712 |
+
}
|
3713 |
+
|
3714 |
+
// Operations are used to wrap a series of changes to the editor
|
3715 |
+
// state in such a way that each change won't have to update the
|
3716 |
+
// cursor and display (which would be awkward, slow, and
|
3717 |
+
// error-prone). Instead, display updates are batched and then all
|
3718 |
+
// combined and executed at once.
|
3719 |
+
|
3720 |
+
var nextOpId = 0
|
3721 |
+
// Start a new operation.
|
3722 |
+
function startOperation(cm) {
|
3723 |
+
cm.curOp = {
|
3724 |
+
cm: cm,
|
3725 |
+
viewChanged: false, // Flag that indicates that lines might need to be redrawn
|
3726 |
+
startHeight: cm.doc.height, // Used to detect need to update scrollbar
|
3727 |
+
forceUpdate: false, // Used to force a redraw
|
3728 |
+
updateInput: null, // Whether to reset the input textarea
|
3729 |
+
typing: false, // Whether this reset should be careful to leave existing text (for compositing)
|
3730 |
+
changeObjs: null, // Accumulated changes, for firing change events
|
3731 |
+
cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
|
3732 |
+
cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
|
3733 |
+
selectionChanged: false, // Whether the selection needs to be redrawn
|
3734 |
+
updateMaxLine: false, // Set when the widest line needs to be determined anew
|
3735 |
+
scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
|
3736 |
+
scrollToPos: null, // Used to scroll to a specific position
|
3737 |
+
focus: false,
|
3738 |
+
id: ++nextOpId // Unique ID
|
3739 |
+
}
|
3740 |
+
pushOperation(cm.curOp)
|
3741 |
+
}
|
3742 |
+
|
3743 |
+
// Finish an operation, updating the display and signalling delayed events
|
3744 |
+
function endOperation(cm) {
|
3745 |
+
var op = cm.curOp
|
3746 |
+
finishOperation(op, function (group) {
|
3747 |
+
for (var i = 0; i < group.ops.length; i++)
|
3748 |
+
{ group.ops[i].cm.curOp = null }
|
3749 |
+
endOperations(group)
|
3750 |
+
})
|
3751 |
+
}
|
3752 |
+
|
3753 |
+
// The DOM updates done when an operation finishes are batched so
|
3754 |
+
// that the minimum number of relayouts are required.
|
3755 |
+
function endOperations(group) {
|
3756 |
+
var ops = group.ops
|
3757 |
+
for (var i = 0; i < ops.length; i++) // Read DOM
|
3758 |
+
{ endOperation_R1(ops[i]) }
|
3759 |
+
for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
|
3760 |
+
{ endOperation_W1(ops[i$1]) }
|
3761 |
+
for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
|
3762 |
+
{ endOperation_R2(ops[i$2]) }
|
3763 |
+
for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
|
3764 |
+
{ endOperation_W2(ops[i$3]) }
|
3765 |
+
for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
|
3766 |
+
{ endOperation_finish(ops[i$4]) }
|
3767 |
+
}
|
3768 |
+
|
3769 |
+
function endOperation_R1(op) {
|
3770 |
+
var cm = op.cm, display = cm.display
|
3771 |
+
maybeClipScrollbars(cm)
|
3772 |
+
if (op.updateMaxLine) { findMaxLine(cm) }
|
3773 |
+
|
3774 |
+
op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
|
3775 |
+
op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
|
3776 |
+
op.scrollToPos.to.line >= display.viewTo) ||
|
3777 |
+
display.maxLineChanged && cm.options.lineWrapping
|
3778 |
+
op.update = op.mustUpdate &&
|
3779 |
+
new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate)
|
3780 |
+
}
|
3781 |
+
|
3782 |
+
function endOperation_W1(op) {
|
3783 |
+
op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update)
|
3784 |
+
}
|
3785 |
+
|
3786 |
+
function endOperation_R2(op) {
|
3787 |
+
var cm = op.cm, display = cm.display
|
3788 |
+
if (op.updatedDisplay) { updateHeightsInViewport(cm) }
|
3789 |
+
|
3790 |
+
op.barMeasure = measureForScrollbars(cm)
|
3791 |
+
|
3792 |
+
// If the max line changed since it was last measured, measure it,
|
3793 |
+
// and ensure the document's width matches it.
|
3794 |
+
// updateDisplay_W2 will use these properties to do the actual resizing
|
3795 |
+
if (display.maxLineChanged && !cm.options.lineWrapping) {
|
3796 |
+
op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3
|
3797 |
+
cm.display.sizerWidth = op.adjustWidthTo
|
3798 |
+
op.barMeasure.scrollWidth =
|
3799 |
+
Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth)
|
3800 |
+
op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm))
|
3801 |
+
}
|
3802 |
+
|
3803 |
+
if (op.updatedDisplay || op.selectionChanged)
|
3804 |
+
{ op.preparedSelection = display.input.prepareSelection() }
|
3805 |
+
}
|
3806 |
+
|
3807 |
+
function endOperation_W2(op) {
|
3808 |
+
var cm = op.cm
|
3809 |
+
|
3810 |
+
if (op.adjustWidthTo != null) {
|
3811 |
+
cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"
|
3812 |
+
if (op.maxScrollLeft < cm.doc.scrollLeft)
|
3813 |
+
{ setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true) }
|
3814 |
+
cm.display.maxLineChanged = false
|
3815 |
+
}
|
3816 |
+
|
3817 |
+
var takeFocus = op.focus && op.focus == activeElt()
|
3818 |
+
if (op.preparedSelection)
|
3819 |
+
{ cm.display.input.showSelection(op.preparedSelection, takeFocus) }
|
3820 |
+
if (op.updatedDisplay || op.startHeight != cm.doc.height)
|
3821 |
+
{ updateScrollbars(cm, op.barMeasure) }
|
3822 |
+
if (op.updatedDisplay)
|
3823 |
+
{ setDocumentHeight(cm, op.barMeasure) }
|
3824 |
+
|
3825 |
+
if (op.selectionChanged) { restartBlink(cm) }
|
3826 |
+
|
3827 |
+
if (cm.state.focused && op.updateInput)
|
3828 |
+
{ cm.display.input.reset(op.typing) }
|
3829 |
+
if (takeFocus) { ensureFocus(op.cm) }
|
3830 |
+
}
|
3831 |
+
|
3832 |
+
function endOperation_finish(op) {
|
3833 |
+
var cm = op.cm, display = cm.display, doc = cm.doc
|
3834 |
+
|
3835 |
+
if (op.updatedDisplay) { postUpdateDisplay(cm, op.update) }
|
3836 |
+
|
3837 |
+
// Abort mouse wheel delta measurement, when scrolling explicitly
|
3838 |
+
if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
|
3839 |
+
{ display.wheelStartX = display.wheelStartY = null }
|
3840 |
+
|
3841 |
+
// Propagate the scroll position to the actual DOM scroller
|
3842 |
+
if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll) }
|
3843 |
+
|
3844 |
+
if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true) }
|
3845 |
+
// If we need to scroll a specific position into view, do so.
|
3846 |
+
if (op.scrollToPos) {
|
3847 |
+
var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
|
3848 |
+
clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin)
|
3849 |
+
maybeScrollWindow(cm, rect)
|
3850 |
+
}
|
3851 |
+
|
3852 |
+
// Fire events for markers that are hidden/unidden by editing or
|
3853 |
+
// undoing
|
3854 |
+
var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers
|
3855 |
+
if (hidden) { for (var i = 0; i < hidden.length; ++i)
|
3856 |
+
{ if (!hidden[i].lines.length) { signal(hidden[i], "hide") } } }
|
3857 |
+
if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)
|
3858 |
+
{ if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide") } } }
|
3859 |
+
|
3860 |
+
if (display.wrapper.offsetHeight)
|
3861 |
+
{ doc.scrollTop = cm.display.scroller.scrollTop }
|
3862 |
+
|
3863 |
+
// Fire change events, and delayed event handlers
|
3864 |
+
if (op.changeObjs)
|
3865 |
+
{ signal(cm, "changes", cm, op.changeObjs) }
|
3866 |
+
if (op.update)
|
3867 |
+
{ op.update.finish() }
|
3868 |
+
}
|
3869 |
+
|
3870 |
+
// Run the given function in an operation
|
3871 |
+
function runInOp(cm, f) {
|
3872 |
+
if (cm.curOp) { return f() }
|
3873 |
+
startOperation(cm)
|
3874 |
+
try { return f() }
|
3875 |
+
finally { endOperation(cm) }
|
3876 |
+
}
|
3877 |
+
// Wraps a function in an operation. Returns the wrapped function.
|
3878 |
+
function operation(cm, f) {
|
3879 |
+
return function() {
|
3880 |
+
if (cm.curOp) { return f.apply(cm, arguments) }
|
3881 |
+
startOperation(cm)
|
3882 |
+
try { return f.apply(cm, arguments) }
|
3883 |
+
finally { endOperation(cm) }
|
3884 |
+
}
|
3885 |
+
}
|
3886 |
+
// Used to add methods to editor and doc instances, wrapping them in
|
3887 |
+
// operations.
|
3888 |
+
function methodOp(f) {
|
3889 |
+
return function() {
|
3890 |
+
if (this.curOp) { return f.apply(this, arguments) }
|
3891 |
+
startOperation(this)
|
3892 |
+
try { return f.apply(this, arguments) }
|
3893 |
+
finally { endOperation(this) }
|
3894 |
+
}
|
3895 |
+
}
|
3896 |
+
function docMethodOp(f) {
|
3897 |
+
return function() {
|
3898 |
+
var cm = this.cm
|
3899 |
+
if (!cm || cm.curOp) { return f.apply(this, arguments) }
|
3900 |
+
startOperation(cm)
|
3901 |
+
try { return f.apply(this, arguments) }
|
3902 |
+
finally { endOperation(cm) }
|
3903 |
+
}
|
3904 |
+
}
|
3905 |
+
|
3906 |
+
// Updates the display.view data structure for a given change to the
|
3907 |
+
// document. From and to are in pre-change coordinates. Lendiff is
|
3908 |
+
// the amount of lines added or subtracted by the change. This is
|
3909 |
+
// used for changes that span multiple lines, or change the way
|
3910 |
+
// lines are divided into visual lines. regLineChange (below)
|
3911 |
+
// registers single-line changes.
|
3912 |
+
function regChange(cm, from, to, lendiff) {
|
3913 |
+
if (from == null) { from = cm.doc.first }
|
3914 |
+
if (to == null) { to = cm.doc.first + cm.doc.size }
|
3915 |
+
if (!lendiff) { lendiff = 0 }
|
3916 |
+
|
3917 |
+
var display = cm.display
|
3918 |
+
if (lendiff && to < display.viewTo &&
|
3919 |
+
(display.updateLineNumbers == null || display.updateLineNumbers > from))
|
3920 |
+
{ display.updateLineNumbers = from }
|
3921 |
+
|
3922 |
+
cm.curOp.viewChanged = true
|
3923 |
+
|
3924 |
+
if (from >= display.viewTo) { // Change after
|
3925 |
+
if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
|
3926 |
+
{ resetView(cm) }
|
3927 |
+
} else if (to <= display.viewFrom) { // Change before
|
3928 |
+
if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
|
3929 |
+
resetView(cm)
|
3930 |
+
} else {
|
3931 |
+
display.viewFrom += lendiff
|
3932 |
+
display.viewTo += lendiff
|
3933 |
+
}
|
3934 |
+
} else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
|
3935 |
+
resetView(cm)
|
3936 |
+
} else if (from <= display.viewFrom) { // Top overlap
|
3937 |
+
var cut = viewCuttingPoint(cm, to, to + lendiff, 1)
|
3938 |
+
if (cut) {
|
3939 |
+
display.view = display.view.slice(cut.index)
|
3940 |
+
display.viewFrom = cut.lineN
|
3941 |
+
display.viewTo += lendiff
|
3942 |
+
} else {
|
3943 |
+
resetView(cm)
|
3944 |
+
}
|
3945 |
+
} else if (to >= display.viewTo) { // Bottom overlap
|
3946 |
+
var cut$1 = viewCuttingPoint(cm, from, from, -1)
|
3947 |
+
if (cut$1) {
|
3948 |
+
display.view = display.view.slice(0, cut$1.index)
|
3949 |
+
display.viewTo = cut$1.lineN
|
3950 |
+
} else {
|
3951 |
+
resetView(cm)
|
3952 |
+
}
|
3953 |
+
} else { // Gap in the middle
|
3954 |
+
var cutTop = viewCuttingPoint(cm, from, from, -1)
|
3955 |
+
var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1)
|
3956 |
+
if (cutTop && cutBot) {
|
3957 |
+
display.view = display.view.slice(0, cutTop.index)
|
3958 |
+
.concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
|
3959 |
+
.concat(display.view.slice(cutBot.index))
|
3960 |
+
display.viewTo += lendiff
|
3961 |
+
} else {
|
3962 |
+
resetView(cm)
|
3963 |
+
}
|
3964 |
+
}
|
3965 |
+
|
3966 |
+
var ext = display.externalMeasured
|
3967 |
+
if (ext) {
|
3968 |
+
if (to < ext.lineN)
|
3969 |
+
{ ext.lineN += lendiff }
|
3970 |
+
else if (from < ext.lineN + ext.size)
|
3971 |
+
{ display.externalMeasured = null }
|
3972 |
+
}
|
3973 |
+
}
|
3974 |
+
|
3975 |
+
// Register a change to a single line. Type must be one of "text",
|
3976 |
+
// "gutter", "class", "widget"
|
3977 |
+
function regLineChange(cm, line, type) {
|
3978 |
+
cm.curOp.viewChanged = true
|
3979 |
+
var display = cm.display, ext = cm.display.externalMeasured
|
3980 |
+
if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
|
3981 |
+
{ display.externalMeasured = null }
|
3982 |
+
|
3983 |
+
if (line < display.viewFrom || line >= display.viewTo) { return }
|
3984 |
+
var lineView = display.view[findViewIndex(cm, line)]
|
3985 |
+
if (lineView.node == null) { return }
|
3986 |
+
var arr = lineView.changes || (lineView.changes = [])
|
3987 |
+
if (indexOf(arr, type) == -1) { arr.push(type) }
|
3988 |
+
}
|
3989 |
+
|
3990 |
+
// Clear the view.
|
3991 |
+
function resetView(cm) {
|
3992 |
+
cm.display.viewFrom = cm.display.viewTo = cm.doc.first
|
3993 |
+
cm.display.view = []
|
3994 |
+
cm.display.viewOffset = 0
|
3995 |
+
}
|
3996 |
+
|
3997 |
+
function viewCuttingPoint(cm, oldN, newN, dir) {
|
3998 |
+
var index = findViewIndex(cm, oldN), diff, view = cm.display.view
|
3999 |
+
if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
|
4000 |
+
{ return {index: index, lineN: newN} }
|
4001 |
+
var n = cm.display.viewFrom
|
4002 |
+
for (var i = 0; i < index; i++)
|
4003 |
+
{ n += view[i].size }
|
4004 |
+
if (n != oldN) {
|
4005 |
+
if (dir > 0) {
|
4006 |
+
if (index == view.length - 1) { return null }
|
4007 |
+
diff = (n + view[index].size) - oldN
|
4008 |
+
index++
|
4009 |
+
} else {
|
4010 |
+
diff = n - oldN
|
4011 |
+
}
|
4012 |
+
oldN += diff; newN += diff
|
4013 |
+
}
|
4014 |
+
while (visualLineNo(cm.doc, newN) != newN) {
|
4015 |
+
if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
|
4016 |
+
newN += dir * view[index - (dir < 0 ? 1 : 0)].size
|
4017 |
+
index += dir
|
4018 |
+
}
|
4019 |
+
return {index: index, lineN: newN}
|
4020 |
+
}
|
4021 |
+
|
4022 |
+
// Force the view to cover a given range, adding empty view element
|
4023 |
+
// or clipping off existing ones as needed.
|
4024 |
+
function adjustView(cm, from, to) {
|
4025 |
+
var display = cm.display, view = display.view
|
4026 |
+
if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
|
4027 |
+
display.view = buildViewArray(cm, from, to)
|
4028 |
+
display.viewFrom = from
|
4029 |
+
} else {
|
4030 |
+
if (display.viewFrom > from)
|
4031 |
+
{ display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view) }
|
4032 |
+
else if (display.viewFrom < from)
|
4033 |
+
{ display.view = display.view.slice(findViewIndex(cm, from)) }
|
4034 |
+
display.viewFrom = from
|
4035 |
+
if (display.viewTo < to)
|
4036 |
+
{ display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)) }
|
4037 |
+
else if (display.viewTo > to)
|
4038 |
+
{ display.view = display.view.slice(0, findViewIndex(cm, to)) }
|
4039 |
+
}
|
4040 |
+
display.viewTo = to
|
4041 |
+
}
|
4042 |
+
|
4043 |
+
// Count the number of lines in the view whose DOM representation is
|
4044 |
+
// out of date (or nonexistent).
|
4045 |
+
function countDirtyView(cm) {
|
4046 |
+
var view = cm.display.view, dirty = 0
|
4047 |
+
for (var i = 0; i < view.length; i++) {
|
4048 |
+
var lineView = view[i]
|
4049 |
+
if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty }
|
4050 |
+
}
|
4051 |
+
return dirty
|
4052 |
+
}
|
4053 |
+
|
4054 |
+
// HIGHLIGHT WORKER
|
4055 |
+
|
4056 |
+
function startWorker(cm, time) {
|
4057 |
+
if (cm.doc.highlightFrontier < cm.display.viewTo)
|
4058 |
+
{ cm.state.highlight.set(time, bind(highlightWorker, cm)) }
|
4059 |
+
}
|
4060 |
+
|
4061 |
+
function highlightWorker(cm) {
|
4062 |
+
var doc = cm.doc
|
4063 |
+
if (doc.highlightFrontier >= cm.display.viewTo) { return }
|
4064 |
+
var end = +new Date + cm.options.workTime
|
4065 |
+
var context = getContextBefore(cm, doc.highlightFrontier)
|
4066 |
+
var changedLines = []
|
4067 |
+
|
4068 |
+
doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
|
4069 |
+
if (context.line >= cm.display.viewFrom) { // Visible
|
4070 |
+
var oldStyles = line.styles
|
4071 |
+
var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null
|
4072 |
+
var highlighted = highlightLine(cm, line, context, true)
|
4073 |
+
if (resetState) { context.state = resetState }
|
4074 |
+
line.styles = highlighted.styles
|
4075 |
+
var oldCls = line.styleClasses, newCls = highlighted.classes
|
4076 |
+
if (newCls) { line.styleClasses = newCls }
|
4077 |
+
else if (oldCls) { line.styleClasses = null }
|
4078 |
+
var ischange = !oldStyles || oldStyles.length != line.styles.length ||
|
4079 |
+
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass)
|
4080 |
+
for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i] }
|
4081 |
+
if (ischange) { changedLines.push(context.line) }
|
4082 |
+
line.stateAfter = context.save()
|
4083 |
+
context.nextLine()
|
4084 |
+
} else {
|
4085 |
+
if (line.text.length <= cm.options.maxHighlightLength)
|
4086 |
+
{ processLine(cm, line.text, context) }
|
4087 |
+
line.stateAfter = context.line % 5 == 0 ? context.save() : null
|
4088 |
+
context.nextLine()
|
4089 |
+
}
|
4090 |
+
if (+new Date > end) {
|
4091 |
+
startWorker(cm, cm.options.workDelay)
|
4092 |
+
return true
|
4093 |
+
}
|
4094 |
+
})
|
4095 |
+
doc.highlightFrontier = context.line
|
4096 |
+
doc.modeFrontier = Math.max(doc.modeFrontier, context.line)
|
4097 |
+
if (changedLines.length) { runInOp(cm, function () {
|
4098 |
+
for (var i = 0; i < changedLines.length; i++)
|
4099 |
+
{ regLineChange(cm, changedLines[i], "text") }
|
4100 |
+
}) }
|
4101 |
+
}
|
4102 |
+
|
4103 |
+
// DISPLAY DRAWING
|
4104 |
+
|
4105 |
+
var DisplayUpdate = function(cm, viewport, force) {
|
4106 |
+
var display = cm.display
|
4107 |
+
|
4108 |
+
this.viewport = viewport
|
4109 |
+
// Store some values that we'll need later (but don't want to force a relayout for)
|
4110 |
+
this.visible = visibleLines(display, cm.doc, viewport)
|
4111 |
+
this.editorIsHidden = !display.wrapper.offsetWidth
|
4112 |
+
this.wrapperHeight = display.wrapper.clientHeight
|
4113 |
+
this.wrapperWidth = display.wrapper.clientWidth
|
4114 |
+
this.oldDisplayWidth = displayWidth(cm)
|
4115 |
+
this.force = force
|
4116 |
+
this.dims = getDimensions(cm)
|
4117 |
+
this.events = []
|
4118 |
+
};
|
4119 |
+
|
4120 |
+
DisplayUpdate.prototype.signal = function (emitter, type) {
|
4121 |
+
if (hasHandler(emitter, type))
|
4122 |
+
{ this.events.push(arguments) }
|
4123 |
+
};
|
4124 |
+
DisplayUpdate.prototype.finish = function () {
|
4125 |
+
var this$1 = this;
|
4126 |
+
|
4127 |
+
for (var i = 0; i < this.events.length; i++)
|
4128 |
+
{ signal.apply(null, this$1.events[i]) }
|
4129 |
+
};
|
4130 |
+
|
4131 |
+
function maybeClipScrollbars(cm) {
|
4132 |
+
var display = cm.display
|
4133 |
+
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
|
4134 |
+
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth
|
4135 |
+
display.heightForcer.style.height = scrollGap(cm) + "px"
|
4136 |
+
display.sizer.style.marginBottom = -display.nativeBarWidth + "px"
|
4137 |
+
display.sizer.style.borderRightWidth = scrollGap(cm) + "px"
|
4138 |
+
display.scrollbarsClipped = true
|
4139 |
+
}
|
4140 |
+
}
|
4141 |
+
|
4142 |
+
function selectionSnapshot(cm) {
|
4143 |
+
if (cm.hasFocus()) { return null }
|
4144 |
+
var active = activeElt()
|
4145 |
+
if (!active || !contains(cm.display.lineDiv, active)) { return null }
|
4146 |
+
var result = {activeElt: active}
|
4147 |
+
if (window.getSelection) {
|
4148 |
+
var sel = window.getSelection()
|
4149 |
+
if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
|
4150 |
+
result.anchorNode = sel.anchorNode
|
4151 |
+
result.anchorOffset = sel.anchorOffset
|
4152 |
+
result.focusNode = sel.focusNode
|
4153 |
+
result.focusOffset = sel.focusOffset
|
4154 |
+
}
|
4155 |
+
}
|
4156 |
+
return result
|
4157 |
+
}
|
4158 |
+
|
4159 |
+
function restoreSelection(snapshot) {
|
4160 |
+
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
|
4161 |
+
snapshot.activeElt.focus()
|
4162 |
+
if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
|
4163 |
+
var sel = window.getSelection(), range = document.createRange()
|
4164 |
+
range.setEnd(snapshot.anchorNode, snapshot.anchorOffset)
|
4165 |
+
range.collapse(false)
|
4166 |
+
sel.removeAllRanges()
|
4167 |
+
sel.addRange(range)
|
4168 |
+
sel.extend(snapshot.focusNode, snapshot.focusOffset)
|
4169 |
+
}
|
4170 |
+
}
|
4171 |
+
|
4172 |
+
// Does the actual updating of the line display. Bails out
|
4173 |
+
// (returning false) when there is nothing to be done and forced is
|
4174 |
+
// false.
|
4175 |
+
function updateDisplayIfNeeded(cm, update) {
|
4176 |
+
var display = cm.display, doc = cm.doc
|
4177 |
+
|
4178 |
+
if (update.editorIsHidden) {
|
4179 |
+
resetView(cm)
|
4180 |
+
return false
|
4181 |
+
}
|
4182 |
+
|
4183 |
+
// Bail out if the visible area is already rendered and nothing changed.
|
4184 |
+
if (!update.force &&
|
4185 |
+
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
|
4186 |
+
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
|
4187 |
+
display.renderedView == display.view && countDirtyView(cm) == 0)
|
4188 |
+
{ return false }
|
4189 |
+
|
4190 |
+
if (maybeUpdateLineNumberWidth(cm)) {
|
4191 |
+
resetView(cm)
|
4192 |
+
update.dims = getDimensions(cm)
|
4193 |
+
}
|
4194 |
+
|
4195 |
+
// Compute a suitable new viewport (from & to)
|
4196 |
+
var end = doc.first + doc.size
|
4197 |
+
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first)
|
4198 |
+
var to = Math.min(end, update.visible.to + cm.options.viewportMargin)
|
4199 |
+
if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom) }
|
4200 |
+
if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo) }
|
4201 |
+
if (sawCollapsedSpans) {
|
4202 |
+
from = visualLineNo(cm.doc, from)
|
4203 |
+
to = visualLineEndNo(cm.doc, to)
|
4204 |
+
}
|
4205 |
+
|
4206 |
+
var different = from != display.viewFrom || to != display.viewTo ||
|
4207 |
+
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth
|
4208 |
+
adjustView(cm, from, to)
|
4209 |
+
|
4210 |
+
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom))
|
4211 |
+
// Position the mover div to align with the current scroll position
|
4212 |
+
cm.display.mover.style.top = display.viewOffset + "px"
|
4213 |
+
|
4214 |
+
var toUpdate = countDirtyView(cm)
|
4215 |
+
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
|
4216 |
+
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
|
4217 |
+
{ return false }
|
4218 |
+
|
4219 |
+
// For big changes, we hide the enclosing element during the
|
4220 |
+
// update, since that speeds up the operations on most browsers.
|
4221 |
+
var selSnapshot = selectionSnapshot(cm)
|
4222 |
+
if (toUpdate > 4) { display.lineDiv.style.display = "none" }
|
4223 |
+
patchDisplay(cm, display.updateLineNumbers, update.dims)
|
4224 |
+
if (toUpdate > 4) { display.lineDiv.style.display = "" }
|
4225 |
+
display.renderedView = display.view
|
4226 |
+
// There might have been a widget with a focused element that got
|
4227 |
+
// hidden or updated, if so re-focus it.
|
4228 |
+
restoreSelection(selSnapshot)
|
4229 |
+
|
4230 |
+
// Prevent selection and cursors from interfering with the scroll
|
4231 |
+
// width and height.
|
4232 |
+
removeChildren(display.cursorDiv)
|
4233 |
+
removeChildren(display.selectionDiv)
|
4234 |
+
display.gutters.style.height = display.sizer.style.minHeight = 0
|
4235 |
+
|
4236 |
+
if (different) {
|
4237 |
+
display.lastWrapHeight = update.wrapperHeight
|
4238 |
+
display.lastWrapWidth = update.wrapperWidth
|
4239 |
+
startWorker(cm, 400)
|
4240 |
+
}
|
4241 |
+
|
4242 |
+
display.updateLineNumbers = null
|
4243 |
+
|
4244 |
+
return true
|
4245 |
+
}
|
4246 |
+
|
4247 |
+
function postUpdateDisplay(cm, update) {
|
4248 |
+
var viewport = update.viewport
|
4249 |
+
|
4250 |
+
for (var first = true;; first = false) {
|
4251 |
+
if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
|
4252 |
+
// Clip forced viewport to actual scrollable area.
|
4253 |
+
if (viewport && viewport.top != null)
|
4254 |
+
{ viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)} }
|
4255 |
+
// Updated line heights might result in the drawn area not
|
4256 |
+
// actually covering the viewport. Keep looping until it does.
|
4257 |
+
update.visible = visibleLines(cm.display, cm.doc, viewport)
|
4258 |
+
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
|
4259 |
+
{ break }
|
4260 |
+
}
|
4261 |
+
if (!updateDisplayIfNeeded(cm, update)) { break }
|
4262 |
+
updateHeightsInViewport(cm)
|
4263 |
+
var barMeasure = measureForScrollbars(cm)
|
4264 |
+
updateSelection(cm)
|
4265 |
+
updateScrollbars(cm, barMeasure)
|
4266 |
+
setDocumentHeight(cm, barMeasure)
|
4267 |
+
update.force = false
|
4268 |
+
}
|
4269 |
+
|
4270 |
+
update.signal(cm, "update", cm)
|
4271 |
+
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
|
4272 |
+
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo)
|
4273 |
+
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo
|
4274 |
+
}
|
4275 |
+
}
|
4276 |
+
|
4277 |
+
function updateDisplaySimple(cm, viewport) {
|
4278 |
+
var update = new DisplayUpdate(cm, viewport)
|
4279 |
+
if (updateDisplayIfNeeded(cm, update)) {
|
4280 |
+
updateHeightsInViewport(cm)
|
4281 |
+
postUpdateDisplay(cm, update)
|
4282 |
+
var barMeasure = measureForScrollbars(cm)
|
4283 |
+
updateSelection(cm)
|
4284 |
+
updateScrollbars(cm, barMeasure)
|
4285 |
+
setDocumentHeight(cm, barMeasure)
|
4286 |
+
update.finish()
|
4287 |
+
}
|
4288 |
+
}
|
4289 |
+
|
4290 |
+
// Sync the actual display DOM structure with display.view, removing
|
4291 |
+
// nodes for lines that are no longer in view, and creating the ones
|
4292 |
+
// that are not there yet, and updating the ones that are out of
|
4293 |
+
// date.
|
4294 |
+
function patchDisplay(cm, updateNumbersFrom, dims) {
|
4295 |
+
var display = cm.display, lineNumbers = cm.options.lineNumbers
|
4296 |
+
var container = display.lineDiv, cur = container.firstChild
|
4297 |
+
|
4298 |
+
function rm(node) {
|
4299 |
+
var next = node.nextSibling
|
4300 |
+
// Works around a throw-scroll bug in OS X Webkit
|
4301 |
+
if (webkit && mac && cm.display.currentWheelTarget == node)
|
4302 |
+
{ node.style.display = "none" }
|
4303 |
+
else
|
4304 |
+
{ node.parentNode.removeChild(node) }
|
4305 |
+
return next
|
4306 |
+
}
|
4307 |
+
|
4308 |
+
var view = display.view, lineN = display.viewFrom
|
4309 |
+
// Loop over the elements in the view, syncing cur (the DOM nodes
|
4310 |
+
// in display.lineDiv) with the view as we go.
|
4311 |
+
for (var i = 0; i < view.length; i++) {
|
4312 |
+
var lineView = view[i]
|
4313 |
+
if (lineView.hidden) {
|
4314 |
+
} else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
|
4315 |
+
var node = buildLineElement(cm, lineView, lineN, dims)
|
4316 |
+
container.insertBefore(node, cur)
|
4317 |
+
} else { // Already drawn
|
4318 |
+
while (cur != lineView.node) { cur = rm(cur) }
|
4319 |
+
var updateNumber = lineNumbers && updateNumbersFrom != null &&
|
4320 |
+
updateNumbersFrom <= lineN && lineView.lineNumber
|
4321 |
+
if (lineView.changes) {
|
4322 |
+
if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false }
|
4323 |
+
updateLineForChanges(cm, lineView, lineN, dims)
|
4324 |
+
}
|
4325 |
+
if (updateNumber) {
|
4326 |
+
removeChildren(lineView.lineNumber)
|
4327 |
+
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)))
|
4328 |
+
}
|
4329 |
+
cur = lineView.node.nextSibling
|
4330 |
+
}
|
4331 |
+
lineN += lineView.size
|
4332 |
+
}
|
4333 |
+
while (cur) { cur = rm(cur) }
|
4334 |
+
}
|
4335 |
+
|
4336 |
+
function updateGutterSpace(cm) {
|
4337 |
+
var width = cm.display.gutters.offsetWidth
|
4338 |
+
cm.display.sizer.style.marginLeft = width + "px"
|
4339 |
+
}
|
4340 |
+
|
4341 |
+
function setDocumentHeight(cm, measure) {
|
4342 |
+
cm.display.sizer.style.minHeight = measure.docHeight + "px"
|
4343 |
+
cm.display.heightForcer.style.top = measure.docHeight + "px"
|
4344 |
+
cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px"
|
4345 |
+
}
|
4346 |
+
|
4347 |
+
// Rebuild the gutter elements, ensure the margin to the left of the
|
4348 |
+
// code matches their width.
|
4349 |
+
function updateGutters(cm) {
|
4350 |
+
var gutters = cm.display.gutters, specs = cm.options.gutters
|
4351 |
+
removeChildren(gutters)
|
4352 |
+
var i = 0
|
4353 |
+
for (; i < specs.length; ++i) {
|
4354 |
+
var gutterClass = specs[i]
|
4355 |
+
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass))
|
4356 |
+
if (gutterClass == "CodeMirror-linenumbers") {
|
4357 |
+
cm.display.lineGutter = gElt
|
4358 |
+
gElt.style.width = (cm.display.lineNumWidth || 1) + "px"
|
4359 |
+
}
|
4360 |
+
}
|
4361 |
+
gutters.style.display = i ? "" : "none"
|
4362 |
+
updateGutterSpace(cm)
|
4363 |
+
}
|
4364 |
+
|
4365 |
+
// Make sure the gutters options contains the element
|
4366 |
+
// "CodeMirror-linenumbers" when the lineNumbers option is true.
|
4367 |
+
function setGuttersForLineNumbers(options) {
|
4368 |
+
var found = indexOf(options.gutters, "CodeMirror-linenumbers")
|
4369 |
+
if (found == -1 && options.lineNumbers) {
|
4370 |
+
options.gutters = options.gutters.concat(["CodeMirror-linenumbers"])
|
4371 |
+
} else if (found > -1 && !options.lineNumbers) {
|
4372 |
+
options.gutters = options.gutters.slice(0)
|
4373 |
+
options.gutters.splice(found, 1)
|
4374 |
+
}
|
4375 |
+
}
|
4376 |
+
|
4377 |
+
var wheelSamples = 0;
|
4378 |
+
var wheelPixelsPerUnit = null;
|
4379 |
+
// Fill in a browser-detected starting value on browsers where we
|
4380 |
+
// know one. These don't have to be accurate -- the result of them
|
4381 |
+
// being wrong would just be a slight flicker on the first wheel
|
4382 |
+
// scroll (if it is large enough).
|
4383 |
+
if (ie) { wheelPixelsPerUnit = -.53 }
|
4384 |
+
else if (gecko) { wheelPixelsPerUnit = 15 }
|
4385 |
+
else if (chrome) { wheelPixelsPerUnit = -.7 }
|
4386 |
+
else if (safari) { wheelPixelsPerUnit = -1/3 }
|
4387 |
+
|
4388 |
+
function wheelEventDelta(e) {
|
4389 |
+
var dx = e.wheelDeltaX, dy = e.wheelDeltaY
|
4390 |
+
if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail }
|
4391 |
+
if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail }
|
4392 |
+
else if (dy == null) { dy = e.wheelDelta }
|
4393 |
+
return {x: dx, y: dy}
|
4394 |
+
}
|
4395 |
+
function wheelEventPixels(e) {
|
4396 |
+
var delta = wheelEventDelta(e)
|
4397 |
+
delta.x *= wheelPixelsPerUnit
|
4398 |
+
delta.y *= wheelPixelsPerUnit
|
4399 |
+
return delta
|
4400 |
+
}
|
4401 |
+
|
4402 |
+
function onScrollWheel(cm, e) {
|
4403 |
+
var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y
|
4404 |
+
|
4405 |
+
var display = cm.display, scroll = display.scroller
|
4406 |
+
// Quit if there's nothing to scroll here
|
4407 |
+
var canScrollX = scroll.scrollWidth > scroll.clientWidth
|
4408 |
+
var canScrollY = scroll.scrollHeight > scroll.clientHeight
|
4409 |
+
if (!(dx && canScrollX || dy && canScrollY)) { return }
|
4410 |
+
|
4411 |
+
// Webkit browsers on OS X abort momentum scrolls when the target
|
4412 |
+
// of the scroll event is removed from the scrollable element.
|
4413 |
+
// This hack (see related code in patchDisplay) makes sure the
|
4414 |
+
// element is kept around.
|
4415 |
+
if (dy && mac && webkit) {
|
4416 |
+
outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
|
4417 |
+
for (var i = 0; i < view.length; i++) {
|
4418 |
+
if (view[i].node == cur) {
|
4419 |
+
cm.display.currentWheelTarget = cur
|
4420 |
+
break outer
|
4421 |
+
}
|
4422 |
+
}
|
4423 |
+
}
|
4424 |
+
}
|
4425 |
+
|
4426 |
+
// On some browsers, horizontal scrolling will cause redraws to
|
4427 |
+
// happen before the gutter has been realigned, causing it to
|
4428 |
+
// wriggle around in a most unseemly way. When we have an
|
4429 |
+
// estimated pixels/delta value, we just handle horizontal
|
4430 |
+
// scrolling entirely here. It'll be slightly off from native, but
|
4431 |
+
// better than glitching out.
|
4432 |
+
if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
|
4433 |
+
if (dy && canScrollY)
|
4434 |
+
{ updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)) }
|
4435 |
+
setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit))
|
4436 |
+
// Only prevent default scrolling if vertical scrolling is
|
4437 |
+
// actually possible. Otherwise, it causes vertical scroll
|
4438 |
+
// jitter on OSX trackpads when deltaX is small and deltaY
|
4439 |
+
// is large (issue #3579)
|
4440 |
+
if (!dy || (dy && canScrollY))
|
4441 |
+
{ e_preventDefault(e) }
|
4442 |
+
display.wheelStartX = null // Abort measurement, if in progress
|
4443 |
+
return
|
4444 |
+
}
|
4445 |
+
|
4446 |
+
// 'Project' the visible viewport to cover the area that is being
|
4447 |
+
// scrolled into view (if we know enough to estimate it).
|
4448 |
+
if (dy && wheelPixelsPerUnit != null) {
|
4449 |
+
var pixels = dy * wheelPixelsPerUnit
|
4450 |
+
var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight
|
4451 |
+
if (pixels < 0) { top = Math.max(0, top + pixels - 50) }
|
4452 |
+
else { bot = Math.min(cm.doc.height, bot + pixels + 50) }
|
4453 |
+
updateDisplaySimple(cm, {top: top, bottom: bot})
|
4454 |
+
}
|
4455 |
+
|
4456 |
+
if (wheelSamples < 20) {
|
4457 |
+
if (display.wheelStartX == null) {
|
4458 |
+
display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop
|
4459 |
+
display.wheelDX = dx; display.wheelDY = dy
|
4460 |
+
setTimeout(function () {
|
4461 |
+
if (display.wheelStartX == null) { return }
|
4462 |
+
var movedX = scroll.scrollLeft - display.wheelStartX
|
4463 |
+
var movedY = scroll.scrollTop - display.wheelStartY
|
4464 |
+
var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
|
4465 |
+
(movedX && display.wheelDX && movedX / display.wheelDX)
|
4466 |
+
display.wheelStartX = display.wheelStartY = null
|
4467 |
+
if (!sample) { return }
|
4468 |
+
wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1)
|
4469 |
+
++wheelSamples
|
4470 |
+
}, 200)
|
4471 |
+
} else {
|
4472 |
+
display.wheelDX += dx; display.wheelDY += dy
|
4473 |
+
}
|
4474 |
+
}
|
4475 |
+
}
|
4476 |
+
|
4477 |
+
// Selection objects are immutable. A new one is created every time
|
4478 |
+
// the selection changes. A selection is one or more non-overlapping
|
4479 |
+
// (and non-touching) ranges, sorted, and an integer that indicates
|
4480 |
+
// which one is the primary selection (the one that's scrolled into
|
4481 |
+
// view, that getCursor returns, etc).
|
4482 |
+
var Selection = function(ranges, primIndex) {
|
4483 |
+
this.ranges = ranges
|
4484 |
+
this.primIndex = primIndex
|
4485 |
+
};
|
4486 |
+
|
4487 |
+
Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
|
4488 |
+
|
4489 |
+
Selection.prototype.equals = function (other) {
|
4490 |
+
var this$1 = this;
|
4491 |
+
|
4492 |
+
if (other == this) { return true }
|
4493 |
+
if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
|
4494 |
+
for (var i = 0; i < this.ranges.length; i++) {
|
4495 |
+
var here = this$1.ranges[i], there = other.ranges[i]
|
4496 |
+
if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
|
4497 |
+
}
|
4498 |
+
return true
|
4499 |
+
};
|
4500 |
+
|
4501 |
+
Selection.prototype.deepCopy = function () {
|
4502 |
+
var this$1 = this;
|
4503 |
+
|
4504 |
+
var out = []
|
4505 |
+
for (var i = 0; i < this.ranges.length; i++)
|
4506 |
+
{ out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)) }
|
4507 |
+
return new Selection(out, this.primIndex)
|
4508 |
+
};
|
4509 |
+
|
4510 |
+
Selection.prototype.somethingSelected = function () {
|
4511 |
+
var this$1 = this;
|
4512 |
+
|
4513 |
+
for (var i = 0; i < this.ranges.length; i++)
|
4514 |
+
{ if (!this$1.ranges[i].empty()) { return true } }
|
4515 |
+
return false
|
4516 |
+
};
|
4517 |
+
|
4518 |
+
Selection.prototype.contains = function (pos, end) {
|
4519 |
+
var this$1 = this;
|
4520 |
+
|
4521 |
+
if (!end) { end = pos }
|
4522 |
+
for (var i = 0; i < this.ranges.length; i++) {
|
4523 |
+
var range = this$1.ranges[i]
|
4524 |
+
if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
|
4525 |
+
{ return i }
|
4526 |
+
}
|
4527 |
+
return -1
|
4528 |
+
};
|
4529 |
+
|
4530 |
+
var Range = function(anchor, head) {
|
4531 |
+
this.anchor = anchor; this.head = head
|
4532 |
+
};
|
4533 |
+
|
4534 |
+
Range.prototype.from = function () { return minPos(this.anchor, this.head) };
|
4535 |
+
Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
|
4536 |
+
Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
|
4537 |
+
|
4538 |
+
// Take an unsorted, potentially overlapping set of ranges, and
|
4539 |
+
// build a selection out of it. 'Consumes' ranges array (modifying
|
4540 |
+
// it).
|
4541 |
+
function normalizeSelection(ranges, primIndex) {
|
4542 |
+
var prim = ranges[primIndex]
|
4543 |
+
ranges.sort(function (a, b) { return cmp(a.from(), b.from()); })
|
4544 |
+
primIndex = indexOf(ranges, prim)
|
4545 |
+
for (var i = 1; i < ranges.length; i++) {
|
4546 |
+
var cur = ranges[i], prev = ranges[i - 1]
|
4547 |
+
if (cmp(prev.to(), cur.from()) >= 0) {
|
4548 |
+
var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to())
|
4549 |
+
var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head
|
4550 |
+
if (i <= primIndex) { --primIndex }
|
4551 |
+
ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to))
|
4552 |
+
}
|
4553 |
+
}
|
4554 |
+
return new Selection(ranges, primIndex)
|
4555 |
+
}
|
4556 |
+
|
4557 |
+
function simpleSelection(anchor, head) {
|
4558 |
+
return new Selection([new Range(anchor, head || anchor)], 0)
|
4559 |
+
}
|
4560 |
+
|
4561 |
+
// Compute the position of the end of a change (its 'to' property
|
4562 |
+
// refers to the pre-change end).
|
4563 |
+
function changeEnd(change) {
|
4564 |
+
if (!change.text) { return change.to }
|
4565 |
+
return Pos(change.from.line + change.text.length - 1,
|
4566 |
+
lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
|
4567 |
+
}
|
4568 |
+
|
4569 |
+
// Adjust a position to refer to the post-change position of the
|
4570 |
+
// same text, or the end of the change if the change covers it.
|
4571 |
+
function adjustForChange(pos, change) {
|
4572 |
+
if (cmp(pos, change.from) < 0) { return pos }
|
4573 |
+
if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
|
4574 |
+
|
4575 |
+
var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch
|
4576 |
+
if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch }
|
4577 |
+
return Pos(line, ch)
|
4578 |
+
}
|
4579 |
+
|
4580 |
+
function computeSelAfterChange(doc, change) {
|
4581 |
+
var out = []
|
4582 |
+
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
4583 |
+
var range = doc.sel.ranges[i]
|
4584 |
+
out.push(new Range(adjustForChange(range.anchor, change),
|
4585 |
+
adjustForChange(range.head, change)))
|
4586 |
+
}
|
4587 |
+
return normalizeSelection(out, doc.sel.primIndex)
|
4588 |
+
}
|
4589 |
+
|
4590 |
+
function offsetPos(pos, old, nw) {
|
4591 |
+
if (pos.line == old.line)
|
4592 |
+
{ return Pos(nw.line, pos.ch - old.ch + nw.ch) }
|
4593 |
+
else
|
4594 |
+
{ return Pos(nw.line + (pos.line - old.line), pos.ch) }
|
4595 |
+
}
|
4596 |
+
|
4597 |
+
// Used by replaceSelections to allow moving the selection to the
|
4598 |
+
// start or around the replaced test. Hint may be "start" or "around".
|
4599 |
+
function computeReplacedSel(doc, changes, hint) {
|
4600 |
+
var out = []
|
4601 |
+
var oldPrev = Pos(doc.first, 0), newPrev = oldPrev
|
4602 |
+
for (var i = 0; i < changes.length; i++) {
|
4603 |
+
var change = changes[i]
|
4604 |
+
var from = offsetPos(change.from, oldPrev, newPrev)
|
4605 |
+
var to = offsetPos(changeEnd(change), oldPrev, newPrev)
|
4606 |
+
oldPrev = change.to
|
4607 |
+
newPrev = to
|
4608 |
+
if (hint == "around") {
|
4609 |
+
var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0
|
4610 |
+
out[i] = new Range(inv ? to : from, inv ? from : to)
|
4611 |
+
} else {
|
4612 |
+
out[i] = new Range(from, from)
|
4613 |
+
}
|
4614 |
+
}
|
4615 |
+
return new Selection(out, doc.sel.primIndex)
|
4616 |
+
}
|
4617 |
+
|
4618 |
+
// Used to get the editor into a consistent state again when options change.
|
4619 |
+
|
4620 |
+
function loadMode(cm) {
|
4621 |
+
cm.doc.mode = getMode(cm.options, cm.doc.modeOption)
|
4622 |
+
resetModeState(cm)
|
4623 |
+
}
|
4624 |
+
|
4625 |
+
function resetModeState(cm) {
|
4626 |
+
cm.doc.iter(function (line) {
|
4627 |
+
if (line.stateAfter) { line.stateAfter = null }
|
4628 |
+
if (line.styles) { line.styles = null }
|
4629 |
+
})
|
4630 |
+
cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first
|
4631 |
+
startWorker(cm, 100)
|
4632 |
+
cm.state.modeGen++
|
4633 |
+
if (cm.curOp) { regChange(cm) }
|
4634 |
+
}
|
4635 |
+
|
4636 |
+
// DOCUMENT DATA STRUCTURE
|
4637 |
+
|
4638 |
+
// By default, updates that start and end at the beginning of a line
|
4639 |
+
// are treated specially, in order to make the association of line
|
4640 |
+
// widgets and marker elements with the text behave more intuitive.
|
4641 |
+
function isWholeLineUpdate(doc, change) {
|
4642 |
+
return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
|
4643 |
+
(!doc.cm || doc.cm.options.wholeLineUpdateBefore)
|
4644 |
+
}
|
4645 |
+
|
4646 |
+
// Perform a change on the document data structure.
|
4647 |
+
function updateDoc(doc, change, markedSpans, estimateHeight) {
|
4648 |
+
function spansFor(n) {return markedSpans ? markedSpans[n] : null}
|
4649 |
+
function update(line, text, spans) {
|
4650 |
+
updateLine(line, text, spans, estimateHeight)
|
4651 |
+
signalLater(line, "change", line, change)
|
4652 |
+
}
|
4653 |
+
function linesFor(start, end) {
|
4654 |
+
var result = []
|
4655 |
+
for (var i = start; i < end; ++i)
|
4656 |
+
{ result.push(new Line(text[i], spansFor(i), estimateHeight)) }
|
4657 |
+
return result
|
4658 |
+
}
|
4659 |
+
|
4660 |
+
var from = change.from, to = change.to, text = change.text
|
4661 |
+
var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line)
|
4662 |
+
var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line
|
4663 |
+
|
4664 |
+
// Adjust the line structure
|
4665 |
+
if (change.full) {
|
4666 |
+
doc.insert(0, linesFor(0, text.length))
|
4667 |
+
doc.remove(text.length, doc.size - text.length)
|
4668 |
+
} else if (isWholeLineUpdate(doc, change)) {
|
4669 |
+
// This is a whole-line replace. Treated specially to make
|
4670 |
+
// sure line objects move the way they are supposed to.
|
4671 |
+
var added = linesFor(0, text.length - 1)
|
4672 |
+
update(lastLine, lastLine.text, lastSpans)
|
4673 |
+
if (nlines) { doc.remove(from.line, nlines) }
|
4674 |
+
if (added.length) { doc.insert(from.line, added) }
|
4675 |
+
} else if (firstLine == lastLine) {
|
4676 |
+
if (text.length == 1) {
|
4677 |
+
update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans)
|
4678 |
+
} else {
|
4679 |
+
var added$1 = linesFor(1, text.length - 1)
|
4680 |
+
added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight))
|
4681 |
+
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0))
|
4682 |
+
doc.insert(from.line + 1, added$1)
|
4683 |
+
}
|
4684 |
+
} else if (text.length == 1) {
|
4685 |
+
update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0))
|
4686 |
+
doc.remove(from.line + 1, nlines)
|
4687 |
+
} else {
|
4688 |
+
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0))
|
4689 |
+
update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans)
|
4690 |
+
var added$2 = linesFor(1, text.length - 1)
|
4691 |
+
if (nlines > 1) { doc.remove(from.line + 1, nlines - 1) }
|
4692 |
+
doc.insert(from.line + 1, added$2)
|
4693 |
+
}
|
4694 |
+
|
4695 |
+
signalLater(doc, "change", doc, change)
|
4696 |
+
}
|
4697 |
+
|
4698 |
+
// Call f for all linked documents.
|
4699 |
+
function linkedDocs(doc, f, sharedHistOnly) {
|
4700 |
+
function propagate(doc, skip, sharedHist) {
|
4701 |
+
if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {
|
4702 |
+
var rel = doc.linked[i]
|
4703 |
+
if (rel.doc == skip) { continue }
|
4704 |
+
var shared = sharedHist && rel.sharedHist
|
4705 |
+
if (sharedHistOnly && !shared) { continue }
|
4706 |
+
f(rel.doc, shared)
|
4707 |
+
propagate(rel.doc, doc, shared)
|
4708 |
+
} }
|
4709 |
+
}
|
4710 |
+
propagate(doc, null, true)
|
4711 |
+
}
|
4712 |
+
|
4713 |
+
// Attach a document to an editor.
|
4714 |
+
function attachDoc(cm, doc) {
|
4715 |
+
if (doc.cm) { throw new Error("This document is already in use.") }
|
4716 |
+
cm.doc = doc
|
4717 |
+
doc.cm = cm
|
4718 |
+
estimateLineHeights(cm)
|
4719 |
+
loadMode(cm)
|
4720 |
+
setDirectionClass(cm)
|
4721 |
+
if (!cm.options.lineWrapping) { findMaxLine(cm) }
|
4722 |
+
cm.options.mode = doc.modeOption
|
4723 |
+
regChange(cm)
|
4724 |
+
}
|
4725 |
+
|
4726 |
+
function setDirectionClass(cm) {
|
4727 |
+
;(cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl")
|
4728 |
+
}
|
4729 |
+
|
4730 |
+
function directionChanged(cm) {
|
4731 |
+
runInOp(cm, function () {
|
4732 |
+
setDirectionClass(cm)
|
4733 |
+
regChange(cm)
|
4734 |
+
})
|
4735 |
+
}
|
4736 |
+
|
4737 |
+
function History(startGen) {
|
4738 |
+
// Arrays of change events and selections. Doing something adds an
|
4739 |
+
// event to done and clears undo. Undoing moves events from done
|
4740 |
+
// to undone, redoing moves them in the other direction.
|
4741 |
+
this.done = []; this.undone = []
|
4742 |
+
this.undoDepth = Infinity
|
4743 |
+
// Used to track when changes can be merged into a single undo
|
4744 |
+
// event
|
4745 |
+
this.lastModTime = this.lastSelTime = 0
|
4746 |
+
this.lastOp = this.lastSelOp = null
|
4747 |
+
this.lastOrigin = this.lastSelOrigin = null
|
4748 |
+
// Used by the isClean() method
|
4749 |
+
this.generation = this.maxGeneration = startGen || 1
|
4750 |
+
}
|
4751 |
+
|
4752 |
+
// Create a history change event from an updateDoc-style change
|
4753 |
+
// object.
|
4754 |
+
function historyChangeFromChange(doc, change) {
|
4755 |
+
var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}
|
4756 |
+
attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1)
|
4757 |
+
linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true)
|
4758 |
+
return histChange
|
4759 |
+
}
|
4760 |
+
|
4761 |
+
// Pop all selection events off the end of a history array. Stop at
|
4762 |
+
// a change event.
|
4763 |
+
function clearSelectionEvents(array) {
|
4764 |
+
while (array.length) {
|
4765 |
+
var last = lst(array)
|
4766 |
+
if (last.ranges) { array.pop() }
|
4767 |
+
else { break }
|
4768 |
+
}
|
4769 |
+
}
|
4770 |
+
|
4771 |
+
// Find the top change event in the history. Pop off selection
|
4772 |
+
// events that are in the way.
|
4773 |
+
function lastChangeEvent(hist, force) {
|
4774 |
+
if (force) {
|
4775 |
+
clearSelectionEvents(hist.done)
|
4776 |
+
return lst(hist.done)
|
4777 |
+
} else if (hist.done.length && !lst(hist.done).ranges) {
|
4778 |
+
return lst(hist.done)
|
4779 |
+
} else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
|
4780 |
+
hist.done.pop()
|
4781 |
+
return lst(hist.done)
|
4782 |
+
}
|
4783 |
+
}
|
4784 |
+
|
4785 |
+
// Register a change in the history. Merges changes that are within
|
4786 |
+
// a single operation, or are close together with an origin that
|
4787 |
+
// allows merging (starting with "+") into a single event.
|
4788 |
+
function addChangeToHistory(doc, change, selAfter, opId) {
|
4789 |
+
var hist = doc.history
|
4790 |
+
hist.undone.length = 0
|
4791 |
+
var time = +new Date, cur
|
4792 |
+
var last
|
4793 |
+
|
4794 |
+
if ((hist.lastOp == opId ||
|
4795 |
+
hist.lastOrigin == change.origin && change.origin &&
|
4796 |
+
((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) ||
|
4797 |
+
change.origin.charAt(0) == "*")) &&
|
4798 |
+
(cur = lastChangeEvent(hist, hist.lastOp == opId))) {
|
4799 |
+
// Merge this change into the last event
|
4800 |
+
last = lst(cur.changes)
|
4801 |
+
if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
|
4802 |
+
// Optimized case for simple insertion -- don't want to add
|
4803 |
+
// new changesets for every character typed
|
4804 |
+
last.to = changeEnd(change)
|
4805 |
+
} else {
|
4806 |
+
// Add new sub-event
|
4807 |
+
cur.changes.push(historyChangeFromChange(doc, change))
|
4808 |
+
}
|
4809 |
+
} else {
|
4810 |
+
// Can not be merged, start a new event.
|
4811 |
+
var before = lst(hist.done)
|
4812 |
+
if (!before || !before.ranges)
|
4813 |
+
{ pushSelectionToHistory(doc.sel, hist.done) }
|
4814 |
+
cur = {changes: [historyChangeFromChange(doc, change)],
|
4815 |
+
generation: hist.generation}
|
4816 |
+
hist.done.push(cur)
|
4817 |
+
while (hist.done.length > hist.undoDepth) {
|
4818 |
+
hist.done.shift()
|
4819 |
+
if (!hist.done[0].ranges) { hist.done.shift() }
|
4820 |
+
}
|
4821 |
+
}
|
4822 |
+
hist.done.push(selAfter)
|
4823 |
+
hist.generation = ++hist.maxGeneration
|
4824 |
+
hist.lastModTime = hist.lastSelTime = time
|
4825 |
+
hist.lastOp = hist.lastSelOp = opId
|
4826 |
+
hist.lastOrigin = hist.lastSelOrigin = change.origin
|
4827 |
+
|
4828 |
+
if (!last) { signal(doc, "historyAdded") }
|
4829 |
+
}
|
4830 |
+
|
4831 |
+
function selectionEventCanBeMerged(doc, origin, prev, sel) {
|
4832 |
+
var ch = origin.charAt(0)
|
4833 |
+
return ch == "*" ||
|
4834 |
+
ch == "+" &&
|
4835 |
+
prev.ranges.length == sel.ranges.length &&
|
4836 |
+
prev.somethingSelected() == sel.somethingSelected() &&
|
4837 |
+
new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)
|
4838 |
+
}
|
4839 |
+
|
4840 |
+
// Called whenever the selection changes, sets the new selection as
|
4841 |
+
// the pending selection in the history, and pushes the old pending
|
4842 |
+
// selection into the 'done' array when it was significantly
|
4843 |
+
// different (in number of selected ranges, emptiness, or time).
|
4844 |
+
function addSelectionToHistory(doc, sel, opId, options) {
|
4845 |
+
var hist = doc.history, origin = options && options.origin
|
4846 |
+
|
4847 |
+
// A new event is started when the previous origin does not match
|
4848 |
+
// the current, or the origins don't allow matching. Origins
|
4849 |
+
// starting with * are always merged, those starting with + are
|
4850 |
+
// merged when similar and close together in time.
|
4851 |
+
if (opId == hist.lastSelOp ||
|
4852 |
+
(origin && hist.lastSelOrigin == origin &&
|
4853 |
+
(hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
|
4854 |
+
selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
|
4855 |
+
{ hist.done[hist.done.length - 1] = sel }
|
4856 |
+
else
|
4857 |
+
{ pushSelectionToHistory(sel, hist.done) }
|
4858 |
+
|
4859 |
+
hist.lastSelTime = +new Date
|
4860 |
+
hist.lastSelOrigin = origin
|
4861 |
+
hist.lastSelOp = opId
|
4862 |
+
if (options && options.clearRedo !== false)
|
4863 |
+
{ clearSelectionEvents(hist.undone) }
|
4864 |
+
}
|
4865 |
+
|
4866 |
+
function pushSelectionToHistory(sel, dest) {
|
4867 |
+
var top = lst(dest)
|
4868 |
+
if (!(top && top.ranges && top.equals(sel)))
|
4869 |
+
{ dest.push(sel) }
|
4870 |
+
}
|
4871 |
+
|
4872 |
+
// Used to store marked span information in the history.
|
4873 |
+
function attachLocalSpans(doc, change, from, to) {
|
4874 |
+
var existing = change["spans_" + doc.id], n = 0
|
4875 |
+
doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
|
4876 |
+
if (line.markedSpans)
|
4877 |
+
{ (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans }
|
4878 |
+
++n
|
4879 |
+
})
|
4880 |
+
}
|
4881 |
+
|
4882 |
+
// When un/re-doing restores text containing marked spans, those
|
4883 |
+
// that have been explicitly cleared should not be restored.
|
4884 |
+
function removeClearedSpans(spans) {
|
4885 |
+
if (!spans) { return null }
|
4886 |
+
var out
|
4887 |
+
for (var i = 0; i < spans.length; ++i) {
|
4888 |
+
if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i) } }
|
4889 |
+
else if (out) { out.push(spans[i]) }
|
4890 |
+
}
|
4891 |
+
return !out ? spans : out.length ? out : null
|
4892 |
+
}
|
4893 |
+
|
4894 |
+
// Retrieve and filter the old marked spans stored in a change event.
|
4895 |
+
function getOldSpans(doc, change) {
|
4896 |
+
var found = change["spans_" + doc.id]
|
4897 |
+
if (!found) { return null }
|
4898 |
+
var nw = []
|
4899 |
+
for (var i = 0; i < change.text.length; ++i)
|
4900 |
+
{ nw.push(removeClearedSpans(found[i])) }
|
4901 |
+
return nw
|
4902 |
+
}
|
4903 |
+
|
4904 |
+
// Used for un/re-doing changes from the history. Combines the
|
4905 |
+
// result of computing the existing spans with the set of spans that
|
4906 |
+
// existed in the history (so that deleting around a span and then
|
4907 |
+
// undoing brings back the span).
|
4908 |
+
function mergeOldSpans(doc, change) {
|
4909 |
+
var old = getOldSpans(doc, change)
|
4910 |
+
var stretched = stretchSpansOverChange(doc, change)
|
4911 |
+
if (!old) { return stretched }
|
4912 |
+
if (!stretched) { return old }
|
4913 |
+
|
4914 |
+
for (var i = 0; i < old.length; ++i) {
|
4915 |
+
var oldCur = old[i], stretchCur = stretched[i]
|
4916 |
+
if (oldCur && stretchCur) {
|
4917 |
+
spans: for (var j = 0; j < stretchCur.length; ++j) {
|
4918 |
+
var span = stretchCur[j]
|
4919 |
+
for (var k = 0; k < oldCur.length; ++k)
|
4920 |
+
{ if (oldCur[k].marker == span.marker) { continue spans } }
|
4921 |
+
oldCur.push(span)
|
4922 |
+
}
|
4923 |
+
} else if (stretchCur) {
|
4924 |
+
old[i] = stretchCur
|
4925 |
+
}
|
4926 |
+
}
|
4927 |
+
return old
|
4928 |
+
}
|
4929 |
+
|
4930 |
+
// Used both to provide a JSON-safe object in .getHistory, and, when
|
4931 |
+
// detaching a document, to split the history in two
|
4932 |
+
function copyHistoryArray(events, newGroup, instantiateSel) {
|
4933 |
+
var copy = []
|
4934 |
+
for (var i = 0; i < events.length; ++i) {
|
4935 |
+
var event = events[i]
|
4936 |
+
if (event.ranges) {
|
4937 |
+
copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event)
|
4938 |
+
continue
|
4939 |
+
}
|
4940 |
+
var changes = event.changes, newChanges = []
|
4941 |
+
copy.push({changes: newChanges})
|
4942 |
+
for (var j = 0; j < changes.length; ++j) {
|
4943 |
+
var change = changes[j], m = (void 0)
|
4944 |
+
newChanges.push({from: change.from, to: change.to, text: change.text})
|
4945 |
+
if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
|
4946 |
+
if (indexOf(newGroup, Number(m[1])) > -1) {
|
4947 |
+
lst(newChanges)[prop] = change[prop]
|
4948 |
+
delete change[prop]
|
4949 |
+
}
|
4950 |
+
} } }
|
4951 |
+
}
|
4952 |
+
}
|
4953 |
+
return copy
|
4954 |
+
}
|
4955 |
+
|
4956 |
+
// The 'scroll' parameter given to many of these indicated whether
|
4957 |
+
// the new cursor position should be scrolled into view after
|
4958 |
+
// modifying the selection.
|
4959 |
+
|
4960 |
+
// If shift is held or the extend flag is set, extends a range to
|
4961 |
+
// include a given position (and optionally a second position).
|
4962 |
+
// Otherwise, simply returns the range between the given positions.
|
4963 |
+
// Used for cursor motion and such.
|
4964 |
+
function extendRange(range, head, other, extend) {
|
4965 |
+
if (extend) {
|
4966 |
+
var anchor = range.anchor
|
4967 |
+
if (other) {
|
4968 |
+
var posBefore = cmp(head, anchor) < 0
|
4969 |
+
if (posBefore != (cmp(other, anchor) < 0)) {
|
4970 |
+
anchor = head
|
4971 |
+
head = other
|
4972 |
+
} else if (posBefore != (cmp(head, other) < 0)) {
|
4973 |
+
head = other
|
4974 |
+
}
|
4975 |
+
}
|
4976 |
+
return new Range(anchor, head)
|
4977 |
+
} else {
|
4978 |
+
return new Range(other || head, head)
|
4979 |
+
}
|
4980 |
+
}
|
4981 |
+
|
4982 |
+
// Extend the primary selection range, discard the rest.
|
4983 |
+
function extendSelection(doc, head, other, options, extend) {
|
4984 |
+
if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend) }
|
4985 |
+
setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options)
|
4986 |
+
}
|
4987 |
+
|
4988 |
+
// Extend all selections (pos is an array of selections with length
|
4989 |
+
// equal the number of selections)
|
4990 |
+
function extendSelections(doc, heads, options) {
|
4991 |
+
var out = []
|
4992 |
+
var extend = doc.cm && (doc.cm.display.shift || doc.extend)
|
4993 |
+
for (var i = 0; i < doc.sel.ranges.length; i++)
|
4994 |
+
{ out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend) }
|
4995 |
+
var newSel = normalizeSelection(out, doc.sel.primIndex)
|
4996 |
+
setSelection(doc, newSel, options)
|
4997 |
+
}
|
4998 |
+
|
4999 |
+
// Updates a single range in the selection.
|
5000 |
+
function replaceOneSelection(doc, i, range, options) {
|
5001 |
+
var ranges = doc.sel.ranges.slice(0)
|
5002 |
+
ranges[i] = range
|
5003 |
+
setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options)
|
5004 |
+
}
|
5005 |
+
|
5006 |
+
// Reset the selection to a single range.
|
5007 |
+
function setSimpleSelection(doc, anchor, head, options) {
|
5008 |
+
setSelection(doc, simpleSelection(anchor, head), options)
|
5009 |
+
}
|
5010 |
+
|
5011 |
+
// Give beforeSelectionChange handlers a change to influence a
|
5012 |
+
// selection update.
|
5013 |
+
function filterSelectionChange(doc, sel, options) {
|
5014 |
+
var obj = {
|
5015 |
+
ranges: sel.ranges,
|
5016 |
+
update: function(ranges) {
|
5017 |
+
var this$1 = this;
|
5018 |
+
|
5019 |
+
this.ranges = []
|
5020 |
+
for (var i = 0; i < ranges.length; i++)
|
5021 |
+
{ this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
5022 |
+
clipPos(doc, ranges[i].head)) }
|
5023 |
+
},
|
5024 |
+
origin: options && options.origin
|
5025 |
+
}
|
5026 |
+
signal(doc, "beforeSelectionChange", doc, obj)
|
5027 |
+
if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj) }
|
5028 |
+
if (obj.ranges != sel.ranges) { return normalizeSelection(obj.ranges, obj.ranges.length - 1) }
|
5029 |
+
else { return sel }
|
5030 |
+
}
|
5031 |
+
|
5032 |
+
function setSelectionReplaceHistory(doc, sel, options) {
|
5033 |
+
var done = doc.history.done, last = lst(done)
|
5034 |
+
if (last && last.ranges) {
|
5035 |
+
done[done.length - 1] = sel
|
5036 |
+
setSelectionNoUndo(doc, sel, options)
|
5037 |
+
} else {
|
5038 |
+
setSelection(doc, sel, options)
|
5039 |
+
}
|
5040 |
+
}
|
5041 |
+
|
5042 |
+
// Set a new selection.
|
5043 |
+
function setSelection(doc, sel, options) {
|
5044 |
+
setSelectionNoUndo(doc, sel, options)
|
5045 |
+
addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options)
|
5046 |
+
}
|
5047 |
+
|
5048 |
+
function setSelectionNoUndo(doc, sel, options) {
|
5049 |
+
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
5050 |
+
{ sel = filterSelectionChange(doc, sel, options) }
|
5051 |
+
|
5052 |
+
var bias = options && options.bias ||
|
5053 |
+
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1)
|
5054 |
+
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true))
|
5055 |
+
|
5056 |
+
if (!(options && options.scroll === false) && doc.cm)
|
5057 |
+
{ ensureCursorVisible(doc.cm) }
|
5058 |
+
}
|
5059 |
+
|
5060 |
+
function setSelectionInner(doc, sel) {
|
5061 |
+
if (sel.equals(doc.sel)) { return }
|
5062 |
+
|
5063 |
+
doc.sel = sel
|
5064 |
+
|
5065 |
+
if (doc.cm) {
|
5066 |
+
doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true
|
5067 |
+
signalCursorActivity(doc.cm)
|
5068 |
+
}
|
5069 |
+
signalLater(doc, "cursorActivity", doc)
|
5070 |
+
}
|
5071 |
+
|
5072 |
+
// Verify that the selection does not partially select any atomic
|
5073 |
+
// marked ranges.
|
5074 |
+
function reCheckSelection(doc) {
|
5075 |
+
setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false))
|
5076 |
+
}
|
5077 |
+
|
5078 |
+
// Return a selection that does not partially select any atomic
|
5079 |
+
// ranges.
|
5080 |
+
function skipAtomicInSelection(doc, sel, bias, mayClear) {
|
5081 |
+
var out
|
5082 |
+
for (var i = 0; i < sel.ranges.length; i++) {
|
5083 |
+
var range = sel.ranges[i]
|
5084 |
+
var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]
|
5085 |
+
var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear)
|
5086 |
+
var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear)
|
5087 |
+
if (out || newAnchor != range.anchor || newHead != range.head) {
|
5088 |
+
if (!out) { out = sel.ranges.slice(0, i) }
|
5089 |
+
out[i] = new Range(newAnchor, newHead)
|
5090 |
+
}
|
5091 |
+
}
|
5092 |
+
return out ? normalizeSelection(out, sel.primIndex) : sel
|
5093 |
+
}
|
5094 |
+
|
5095 |
+
function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
|
5096 |
+
var line = getLine(doc, pos.line)
|
5097 |
+
if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
|
5098 |
+
var sp = line.markedSpans[i], m = sp.marker
|
5099 |
+
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
|
5100 |
+
(sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
|
5101 |
+
if (mayClear) {
|
5102 |
+
signal(m, "beforeCursorEnter")
|
5103 |
+
if (m.explicitlyCleared) {
|
5104 |
+
if (!line.markedSpans) { break }
|
5105 |
+
else {--i; continue}
|
5106 |
+
}
|
5107 |
+
}
|
5108 |
+
if (!m.atomic) { continue }
|
5109 |
+
|
5110 |
+
if (oldPos) {
|
5111 |
+
var near = m.find(dir < 0 ? 1 : -1), diff = (void 0)
|
5112 |
+
if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
|
5113 |
+
{ near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null) }
|
5114 |
+
if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
|
5115 |
+
{ return skipAtomicInner(doc, near, pos, dir, mayClear) }
|
5116 |
+
}
|
5117 |
+
|
5118 |
+
var far = m.find(dir < 0 ? -1 : 1)
|
5119 |
+
if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
|
5120 |
+
{ far = movePos(doc, far, dir, far.line == pos.line ? line : null) }
|
5121 |
+
return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
|
5122 |
+
}
|
5123 |
+
} }
|
5124 |
+
return pos
|
5125 |
+
}
|
5126 |
+
|
5127 |
+
// Ensure a given position is not inside an atomic range.
|
5128 |
+
function skipAtomic(doc, pos, oldPos, bias, mayClear) {
|
5129 |
+
var dir = bias || 1
|
5130 |
+
var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
|
5131 |
+
(!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
|
5132 |
+
skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
|
5133 |
+
(!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true))
|
5134 |
+
if (!found) {
|
5135 |
+
doc.cantEdit = true
|
5136 |
+
return Pos(doc.first, 0)
|
5137 |
+
}
|
5138 |
+
return found
|
5139 |
+
}
|
5140 |
+
|
5141 |
+
function movePos(doc, pos, dir, line) {
|
5142 |
+
if (dir < 0 && pos.ch == 0) {
|
5143 |
+
if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }
|
5144 |
+
else { return null }
|
5145 |
+
} else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
|
5146 |
+
if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }
|
5147 |
+
else { return null }
|
5148 |
+
} else {
|
5149 |
+
return new Pos(pos.line, pos.ch + dir)
|
5150 |
+
}
|
5151 |
+
}
|
5152 |
+
|
5153 |
+
function selectAll(cm) {
|
5154 |
+
cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll)
|
5155 |
+
}
|
5156 |
+
|
5157 |
+
// UPDATING
|
5158 |
+
|
5159 |
+
// Allow "beforeChange" event handlers to influence a change
|
5160 |
+
function filterChange(doc, change, update) {
|
5161 |
+
var obj = {
|
5162 |
+
canceled: false,
|
5163 |
+
from: change.from,
|
5164 |
+
to: change.to,
|
5165 |
+
text: change.text,
|
5166 |
+
origin: change.origin,
|
5167 |
+
cancel: function () { return obj.canceled = true; }
|
5168 |
+
}
|
5169 |
+
if (update) { obj.update = function (from, to, text, origin) {
|
5170 |
+
if (from) { obj.from = clipPos(doc, from) }
|
5171 |
+
if (to) { obj.to = clipPos(doc, to) }
|
5172 |
+
if (text) { obj.text = text }
|
5173 |
+
if (origin !== undefined) { obj.origin = origin }
|
5174 |
+
} }
|
5175 |
+
signal(doc, "beforeChange", doc, obj)
|
5176 |
+
if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj) }
|
5177 |
+
|
5178 |
+
if (obj.canceled) { return null }
|
5179 |
+
return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
|
5180 |
+
}
|
5181 |
+
|
5182 |
+
// Apply a change to a document, and add it to the document's
|
5183 |
+
// history, and propagating it to all linked documents.
|
5184 |
+
function makeChange(doc, change, ignoreReadOnly) {
|
5185 |
+
if (doc.cm) {
|
5186 |
+
if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }
|
5187 |
+
if (doc.cm.state.suppressEdits) { return }
|
5188 |
+
}
|
5189 |
+
|
5190 |
+
if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
|
5191 |
+
change = filterChange(doc, change, true)
|
5192 |
+
if (!change) { return }
|
5193 |
+
}
|
5194 |
+
|
5195 |
+
// Possibly split or suppress the update based on the presence
|
5196 |
+
// of read-only spans in its range.
|
5197 |
+
var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)
|
5198 |
+
if (split) {
|
5199 |
+
for (var i = split.length - 1; i >= 0; --i)
|
5200 |
+
{ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}) }
|
5201 |
+
} else {
|
5202 |
+
makeChangeInner(doc, change)
|
5203 |
+
}
|
5204 |
+
}
|
5205 |
+
|
5206 |
+
function makeChangeInner(doc, change) {
|
5207 |
+
if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return }
|
5208 |
+
var selAfter = computeSelAfterChange(doc, change)
|
5209 |
+
addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN)
|
5210 |
+
|
5211 |
+
makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change))
|
5212 |
+
var rebased = []
|
5213 |
+
|
5214 |
+
linkedDocs(doc, function (doc, sharedHist) {
|
5215 |
+
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
|
5216 |
+
rebaseHist(doc.history, change)
|
5217 |
+
rebased.push(doc.history)
|
5218 |
+
}
|
5219 |
+
makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change))
|
5220 |
+
})
|
5221 |
+
}
|
5222 |
+
|
5223 |
+
// Revert a change stored in a document's history.
|
5224 |
+
function makeChangeFromHistory(doc, type, allowSelectionOnly) {
|
5225 |
+
var suppress = doc.cm && doc.cm.state.suppressEdits
|
5226 |
+
if (suppress && !allowSelectionOnly) { return }
|
5227 |
+
|
5228 |
+
var hist = doc.history, event, selAfter = doc.sel
|
5229 |
+
var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done
|
5230 |
+
|
5231 |
+
// Verify that there is a useable event (so that ctrl-z won't
|
5232 |
+
// needlessly clear selection events)
|
5233 |
+
var i = 0
|
5234 |
+
for (; i < source.length; i++) {
|
5235 |
+
event = source[i]
|
5236 |
+
if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
|
5237 |
+
{ break }
|
5238 |
+
}
|
5239 |
+
if (i == source.length) { return }
|
5240 |
+
hist.lastOrigin = hist.lastSelOrigin = null
|
5241 |
+
|
5242 |
+
for (;;) {
|
5243 |
+
event = source.pop()
|
5244 |
+
if (event.ranges) {
|
5245 |
+
pushSelectionToHistory(event, dest)
|
5246 |
+
if (allowSelectionOnly && !event.equals(doc.sel)) {
|
5247 |
+
setSelection(doc, event, {clearRedo: false})
|
5248 |
+
return
|
5249 |
+
}
|
5250 |
+
selAfter = event
|
5251 |
+
} else if (suppress) {
|
5252 |
+
source.push(event)
|
5253 |
+
return
|
5254 |
+
} else { break }
|
5255 |
+
}
|
5256 |
+
|
5257 |
+
// Build up a reverse change object to add to the opposite history
|
5258 |
+
// stack (redo when undoing, and vice versa).
|
5259 |
+
var antiChanges = []
|
5260 |
+
pushSelectionToHistory(selAfter, dest)
|
5261 |
+
dest.push({changes: antiChanges, generation: hist.generation})
|
5262 |
+
hist.generation = event.generation || ++hist.maxGeneration
|
5263 |
+
|
5264 |
+
var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")
|
5265 |
+
|
5266 |
+
var loop = function ( i ) {
|
5267 |
+
var change = event.changes[i]
|
5268 |
+
change.origin = type
|
5269 |
+
if (filter && !filterChange(doc, change, false)) {
|
5270 |
+
source.length = 0
|
5271 |
+
return {}
|
5272 |
+
}
|
5273 |
+
|
5274 |
+
antiChanges.push(historyChangeFromChange(doc, change))
|
5275 |
+
|
5276 |
+
var after = i ? computeSelAfterChange(doc, change) : lst(source)
|
5277 |
+
makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change))
|
5278 |
+
if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}) }
|
5279 |
+
var rebased = []
|
5280 |
+
|
5281 |
+
// Propagate to the linked documents
|
5282 |
+
linkedDocs(doc, function (doc, sharedHist) {
|
5283 |
+
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
|
5284 |
+
rebaseHist(doc.history, change)
|
5285 |
+
rebased.push(doc.history)
|
5286 |
+
}
|
5287 |
+
makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change))
|
5288 |
+
})
|
5289 |
+
};
|
5290 |
+
|
5291 |
+
for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
|
5292 |
+
var returned = loop( i$1 );
|
5293 |
+
|
5294 |
+
if ( returned ) return returned.v;
|
5295 |
+
}
|
5296 |
+
}
|
5297 |
+
|
5298 |
+
// Sub-views need their line numbers shifted when text is added
|
5299 |
+
// above or below them in the parent document.
|
5300 |
+
function shiftDoc(doc, distance) {
|
5301 |
+
if (distance == 0) { return }
|
5302 |
+
doc.first += distance
|
5303 |
+
doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(
|
5304 |
+
Pos(range.anchor.line + distance, range.anchor.ch),
|
5305 |
+
Pos(range.head.line + distance, range.head.ch)
|
5306 |
+
); }), doc.sel.primIndex)
|
5307 |
+
if (doc.cm) {
|
5308 |
+
regChange(doc.cm, doc.first, doc.first - distance, distance)
|
5309 |
+
for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
|
5310 |
+
{ regLineChange(doc.cm, l, "gutter") }
|
5311 |
+
}
|
5312 |
+
}
|
5313 |
+
|
5314 |
+
// More lower-level change function, handling only a single document
|
5315 |
+
// (not linked ones).
|
5316 |
+
function makeChangeSingleDoc(doc, change, selAfter, spans) {
|
5317 |
+
if (doc.cm && !doc.cm.curOp)
|
5318 |
+
{ return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
|
5319 |
+
|
5320 |
+
if (change.to.line < doc.first) {
|
5321 |
+
shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line))
|
5322 |
+
return
|
5323 |
+
}
|
5324 |
+
if (change.from.line > doc.lastLine()) { return }
|
5325 |
+
|
5326 |
+
// Clip the change to the size of this doc
|
5327 |
+
if (change.from.line < doc.first) {
|
5328 |
+
var shift = change.text.length - 1 - (doc.first - change.from.line)
|
5329 |
+
shiftDoc(doc, shift)
|
5330 |
+
change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
|
5331 |
+
text: [lst(change.text)], origin: change.origin}
|
5332 |
+
}
|
5333 |
+
var last = doc.lastLine()
|
5334 |
+
if (change.to.line > last) {
|
5335 |
+
change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
|
5336 |
+
text: [change.text[0]], origin: change.origin}
|
5337 |
+
}
|
5338 |
+
|
5339 |
+
change.removed = getBetween(doc, change.from, change.to)
|
5340 |
+
|
5341 |
+
if (!selAfter) { selAfter = computeSelAfterChange(doc, change) }
|
5342 |
+
if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans) }
|
5343 |
+
else { updateDoc(doc, change, spans) }
|
5344 |
+
setSelectionNoUndo(doc, selAfter, sel_dontScroll)
|
5345 |
+
}
|
5346 |
+
|
5347 |
+
// Handle the interaction of a change to a document with the editor
|
5348 |
+
// that this document is part of.
|
5349 |
+
function makeChangeSingleDocInEditor(cm, change, spans) {
|
5350 |
+
var doc = cm.doc, display = cm.display, from = change.from, to = change.to
|
5351 |
+
|
5352 |
+
var recomputeMaxLength = false, checkWidthStart = from.line
|
5353 |
+
if (!cm.options.lineWrapping) {
|
5354 |
+
checkWidthStart = lineNo(visualLine(getLine(doc, from.line)))
|
5355 |
+
doc.iter(checkWidthStart, to.line + 1, function (line) {
|
5356 |
+
if (line == display.maxLine) {
|
5357 |
+
recomputeMaxLength = true
|
5358 |
+
return true
|
5359 |
+
}
|
5360 |
+
})
|
5361 |
+
}
|
5362 |
+
|
5363 |
+
if (doc.sel.contains(change.from, change.to) > -1)
|
5364 |
+
{ signalCursorActivity(cm) }
|
5365 |
+
|
5366 |
+
updateDoc(doc, change, spans, estimateHeight(cm))
|
5367 |
+
|
5368 |
+
if (!cm.options.lineWrapping) {
|
5369 |
+
doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
|
5370 |
+
var len = lineLength(line)
|
5371 |
+
if (len > display.maxLineLength) {
|
5372 |
+
display.maxLine = line
|
5373 |
+
display.maxLineLength = len
|
5374 |
+
display.maxLineChanged = true
|
5375 |
+
recomputeMaxLength = false
|
5376 |
+
}
|
5377 |
+
})
|
5378 |
+
if (recomputeMaxLength) { cm.curOp.updateMaxLine = true }
|
5379 |
+
}
|
5380 |
+
|
5381 |
+
retreatFrontier(doc, from.line)
|
5382 |
+
startWorker(cm, 400)
|
5383 |
+
|
5384 |
+
var lendiff = change.text.length - (to.line - from.line) - 1
|
5385 |
+
// Remember that these lines changed, for updating the display
|
5386 |
+
if (change.full)
|
5387 |
+
{ regChange(cm) }
|
5388 |
+
else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
|
5389 |
+
{ regLineChange(cm, from.line, "text") }
|
5390 |
+
else
|
5391 |
+
{ regChange(cm, from.line, to.line + 1, lendiff) }
|
5392 |
+
|
5393 |
+
var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change")
|
5394 |
+
if (changeHandler || changesHandler) {
|
5395 |
+
var obj = {
|
5396 |
+
from: from, to: to,
|
5397 |
+
text: change.text,
|
5398 |
+
removed: change.removed,
|
5399 |
+
origin: change.origin
|
5400 |
+
}
|
5401 |
+
if (changeHandler) { signalLater(cm, "change", cm, obj) }
|
5402 |
+
if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj) }
|
5403 |
+
}
|
5404 |
+
cm.display.selForContextMenu = null
|
5405 |
+
}
|
5406 |
+
|
5407 |
+
function replaceRange(doc, code, from, to, origin) {
|
5408 |
+
if (!to) { to = from }
|
5409 |
+
if (cmp(to, from) < 0) { var assign;
|
5410 |
+
(assign = [to, from], from = assign[0], to = assign[1], assign) }
|
5411 |
+
if (typeof code == "string") { code = doc.splitLines(code) }
|
5412 |
+
makeChange(doc, {from: from, to: to, text: code, origin: origin})
|
5413 |
+
}
|
5414 |
+
|
5415 |
+
// Rebasing/resetting history to deal with externally-sourced changes
|
5416 |
+
|
5417 |
+
function rebaseHistSelSingle(pos, from, to, diff) {
|
5418 |
+
if (to < pos.line) {
|
5419 |
+
pos.line += diff
|
5420 |
+
} else if (from < pos.line) {
|
5421 |
+
pos.line = from
|
5422 |
+
pos.ch = 0
|
5423 |
+
}
|
5424 |
+
}
|
5425 |
+
|
5426 |
+
// Tries to rebase an array of history events given a change in the
|
5427 |
+
// document. If the change touches the same lines as the event, the
|
5428 |
+
// event, and everything 'behind' it, is discarded. If the change is
|
5429 |
+
// before the event, the event's positions are updated. Uses a
|
5430 |
+
// copy-on-write scheme for the positions, to avoid having to
|
5431 |
+
// reallocate them all on every rebase, but also avoid problems with
|
5432 |
+
// shared position objects being unsafely updated.
|
5433 |
+
function rebaseHistArray(array, from, to, diff) {
|
5434 |
+
for (var i = 0; i < array.length; ++i) {
|
5435 |
+
var sub = array[i], ok = true
|
5436 |
+
if (sub.ranges) {
|
5437 |
+
if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true }
|
5438 |
+
for (var j = 0; j < sub.ranges.length; j++) {
|
5439 |
+
rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff)
|
5440 |
+
rebaseHistSelSingle(sub.ranges[j].head, from, to, diff)
|
5441 |
+
}
|
5442 |
+
continue
|
5443 |
+
}
|
5444 |
+
for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
|
5445 |
+
var cur = sub.changes[j$1]
|
5446 |
+
if (to < cur.from.line) {
|
5447 |
+
cur.from = Pos(cur.from.line + diff, cur.from.ch)
|
5448 |
+
cur.to = Pos(cur.to.line + diff, cur.to.ch)
|
5449 |
+
} else if (from <= cur.to.line) {
|
5450 |
+
ok = false
|
5451 |
+
break
|
5452 |
+
}
|
5453 |
+
}
|
5454 |
+
if (!ok) {
|
5455 |
+
array.splice(0, i + 1)
|
5456 |
+
i = 0
|
5457 |
+
}
|
5458 |
+
}
|
5459 |
+
}
|
5460 |
+
|
5461 |
+
function rebaseHist(hist, change) {
|
5462 |
+
var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1
|
5463 |
+
rebaseHistArray(hist.done, from, to, diff)
|
5464 |
+
rebaseHistArray(hist.undone, from, to, diff)
|
5465 |
+
}
|
5466 |
+
|
5467 |
+
// Utility for applying a change to a line by handle or number,
|
5468 |
+
// returning the number and optionally registering the line as
|
5469 |
+
// changed.
|
5470 |
+
function changeLine(doc, handle, changeType, op) {
|
5471 |
+
var no = handle, line = handle
|
5472 |
+
if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)) }
|
5473 |
+
else { no = lineNo(handle) }
|
5474 |
+
if (no == null) { return null }
|
5475 |
+
if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType) }
|
5476 |
+
return line
|
5477 |
+
}
|
5478 |
+
|
5479 |
+
// The document is represented as a BTree consisting of leaves, with
|
5480 |
+
// chunk of lines in them, and branches, with up to ten leaves or
|
5481 |
+
// other branch nodes below them. The top node is always a branch
|
5482 |
+
// node, and is the document object itself (meaning it has
|
5483 |
+
// additional methods and properties).
|
5484 |
+
//
|
5485 |
+
// All nodes have parent links. The tree is used both to go from
|
5486 |
+
// line numbers to line objects, and to go from objects to numbers.
|
5487 |
+
// It also indexes by height, and is used to convert between height
|
5488 |
+
// and line object, and to find the total height of the document.
|
5489 |
+
//
|
5490 |
+
// See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
|
5491 |
+
|
5492 |
+
function LeafChunk(lines) {
|
5493 |
+
var this$1 = this;
|
5494 |
+
|
5495 |
+
this.lines = lines
|
5496 |
+
this.parent = null
|
5497 |
+
var height = 0
|
5498 |
+
for (var i = 0; i < lines.length; ++i) {
|
5499 |
+
lines[i].parent = this$1
|
5500 |
+
height += lines[i].height
|
5501 |
+
}
|
5502 |
+
this.height = height
|
5503 |
+
}
|
5504 |
+
|
5505 |
+
LeafChunk.prototype = {
|
5506 |
+
chunkSize: function chunkSize() { return this.lines.length },
|
5507 |
+
|
5508 |
+
// Remove the n lines at offset 'at'.
|
5509 |
+
removeInner: function removeInner(at, n) {
|
5510 |
+
var this$1 = this;
|
5511 |
+
|
5512 |
+
for (var i = at, e = at + n; i < e; ++i) {
|
5513 |
+
var line = this$1.lines[i]
|
5514 |
+
this$1.height -= line.height
|
5515 |
+
cleanUpLine(line)
|
5516 |
+
signalLater(line, "delete")
|
5517 |
+
}
|
5518 |
+
this.lines.splice(at, n)
|
5519 |
+
},
|
5520 |
+
|
5521 |
+
// Helper used to collapse a small branch into a single leaf.
|
5522 |
+
collapse: function collapse(lines) {
|
5523 |
+
lines.push.apply(lines, this.lines)
|
5524 |
+
},
|
5525 |
+
|
5526 |
+
// Insert the given array of lines at offset 'at', count them as
|
5527 |
+
// having the given height.
|
5528 |
+
insertInner: function insertInner(at, lines, height) {
|
5529 |
+
var this$1 = this;
|
5530 |
+
|
5531 |
+
this.height += height
|
5532 |
+
this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at))
|
5533 |
+
for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1 }
|
5534 |
+
},
|
5535 |
+
|
5536 |
+
// Used to iterate over a part of the tree.
|
5537 |
+
iterN: function iterN(at, n, op) {
|
5538 |
+
var this$1 = this;
|
5539 |
+
|
5540 |
+
for (var e = at + n; at < e; ++at)
|
5541 |
+
{ if (op(this$1.lines[at])) { return true } }
|
5542 |
+
}
|
5543 |
+
}
|
5544 |
+
|
5545 |
+
function BranchChunk(children) {
|
5546 |
+
var this$1 = this;
|
5547 |
+
|
5548 |
+
this.children = children
|
5549 |
+
var size = 0, height = 0
|
5550 |
+
for (var i = 0; i < children.length; ++i) {
|
5551 |
+
var ch = children[i]
|
5552 |
+
size += ch.chunkSize(); height += ch.height
|
5553 |
+
ch.parent = this$1
|
5554 |
+
}
|
5555 |
+
this.size = size
|
5556 |
+
this.height = height
|
5557 |
+
this.parent = null
|
5558 |
+
}
|
5559 |
+
|
5560 |
+
BranchChunk.prototype = {
|
5561 |
+
chunkSize: function chunkSize() { return this.size },
|
5562 |
+
|
5563 |
+
removeInner: function removeInner(at, n) {
|
5564 |
+
var this$1 = this;
|
5565 |
+
|
5566 |
+
this.size -= n
|
5567 |
+
for (var i = 0; i < this.children.length; ++i) {
|
5568 |
+
var child = this$1.children[i], sz = child.chunkSize()
|
5569 |
+
if (at < sz) {
|
5570 |
+
var rm = Math.min(n, sz - at), oldHeight = child.height
|
5571 |
+
child.removeInner(at, rm)
|
5572 |
+
this$1.height -= oldHeight - child.height
|
5573 |
+
if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null }
|
5574 |
+
if ((n -= rm) == 0) { break }
|
5575 |
+
at = 0
|
5576 |
+
} else { at -= sz }
|
5577 |
+
}
|
5578 |
+
// If the result is smaller than 25 lines, ensure that it is a
|
5579 |
+
// single leaf node.
|
5580 |
+
if (this.size - n < 25 &&
|
5581 |
+
(this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
|
5582 |
+
var lines = []
|
5583 |
+
this.collapse(lines)
|
5584 |
+
this.children = [new LeafChunk(lines)]
|
5585 |
+
this.children[0].parent = this
|
5586 |
+
}
|
5587 |
+
},
|
5588 |
+
|
5589 |
+
collapse: function collapse(lines) {
|
5590 |
+
var this$1 = this;
|
5591 |
+
|
5592 |
+
for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines) }
|
5593 |
+
},
|
5594 |
+
|
5595 |
+
insertInner: function insertInner(at, lines, height) {
|
5596 |
+
var this$1 = this;
|
5597 |
+
|
5598 |
+
this.size += lines.length
|
5599 |
+
this.height += height
|
5600 |
+
for (var i = 0; i < this.children.length; ++i) {
|
5601 |
+
var child = this$1.children[i], sz = child.chunkSize()
|
5602 |
+
if (at <= sz) {
|
5603 |
+
child.insertInner(at, lines, height)
|
5604 |
+
if (child.lines && child.lines.length > 50) {
|
5605 |
+
// To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
|
5606 |
+
// Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
|
5607 |
+
var remaining = child.lines.length % 25 + 25
|
5608 |
+
for (var pos = remaining; pos < child.lines.length;) {
|
5609 |
+
var leaf = new LeafChunk(child.lines.slice(pos, pos += 25))
|
5610 |
+
child.height -= leaf.height
|
5611 |
+
this$1.children.splice(++i, 0, leaf)
|
5612 |
+
leaf.parent = this$1
|
5613 |
+
}
|
5614 |
+
child.lines = child.lines.slice(0, remaining)
|
5615 |
+
this$1.maybeSpill()
|
5616 |
+
}
|
5617 |
+
break
|
5618 |
+
}
|
5619 |
+
at -= sz
|
5620 |
+
}
|
5621 |
+
},
|
5622 |
+
|
5623 |
+
// When a node has grown, check whether it should be split.
|
5624 |
+
maybeSpill: function maybeSpill() {
|
5625 |
+
if (this.children.length <= 10) { return }
|
5626 |
+
var me = this
|
5627 |
+
do {
|
5628 |
+
var spilled = me.children.splice(me.children.length - 5, 5)
|
5629 |
+
var sibling = new BranchChunk(spilled)
|
5630 |
+
if (!me.parent) { // Become the parent node
|
5631 |
+
var copy = new BranchChunk(me.children)
|
5632 |
+
copy.parent = me
|
5633 |
+
me.children = [copy, sibling]
|
5634 |
+
me = copy
|
5635 |
+
} else {
|
5636 |
+
me.size -= sibling.size
|
5637 |
+
me.height -= sibling.height
|
5638 |
+
var myIndex = indexOf(me.parent.children, me)
|
5639 |
+
me.parent.children.splice(myIndex + 1, 0, sibling)
|
5640 |
+
}
|
5641 |
+
sibling.parent = me.parent
|
5642 |
+
} while (me.children.length > 10)
|
5643 |
+
me.parent.maybeSpill()
|
5644 |
+
},
|
5645 |
+
|
5646 |
+
iterN: function iterN(at, n, op) {
|
5647 |
+
var this$1 = this;
|
5648 |
+
|
5649 |
+
for (var i = 0; i < this.children.length; ++i) {
|
5650 |
+
var child = this$1.children[i], sz = child.chunkSize()
|
5651 |
+
if (at < sz) {
|
5652 |
+
var used = Math.min(n, sz - at)
|
5653 |
+
if (child.iterN(at, used, op)) { return true }
|
5654 |
+
if ((n -= used) == 0) { break }
|
5655 |
+
at = 0
|
5656 |
+
} else { at -= sz }
|
5657 |
+
}
|
5658 |
+
}
|
5659 |
+
}
|
5660 |
+
|
5661 |
+
// Line widgets are block elements displayed above or below a line.
|
5662 |
+
|
5663 |
+
var LineWidget = function(doc, node, options) {
|
5664 |
+
var this$1 = this;
|
5665 |
+
|
5666 |
+
if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
|
5667 |
+
{ this$1[opt] = options[opt] } } }
|
5668 |
+
this.doc = doc
|
5669 |
+
this.node = node
|
5670 |
+
};
|
5671 |
+
|
5672 |
+
LineWidget.prototype.clear = function () {
|
5673 |
+
var this$1 = this;
|
5674 |
+
|
5675 |
+
var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line)
|
5676 |
+
if (no == null || !ws) { return }
|
5677 |
+
for (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1) } }
|
5678 |
+
if (!ws.length) { line.widgets = null }
|
5679 |
+
var height = widgetHeight(this)
|
5680 |
+
updateLineHeight(line, Math.max(0, line.height - height))
|
5681 |
+
if (cm) {
|
5682 |
+
runInOp(cm, function () {
|
5683 |
+
adjustScrollWhenAboveVisible(cm, line, -height)
|
5684 |
+
regLineChange(cm, no, "widget")
|
5685 |
+
})
|
5686 |
+
signalLater(cm, "lineWidgetCleared", cm, this, no)
|
5687 |
+
}
|
5688 |
+
};
|
5689 |
+
|
5690 |
+
LineWidget.prototype.changed = function () {
|
5691 |
+
var this$1 = this;
|
5692 |
+
|
5693 |
+
var oldH = this.height, cm = this.doc.cm, line = this.line
|
5694 |
+
this.height = null
|
5695 |
+
var diff = widgetHeight(this) - oldH
|
5696 |
+
if (!diff) { return }
|
5697 |
+
updateLineHeight(line, line.height + diff)
|
5698 |
+
if (cm) {
|
5699 |
+
runInOp(cm, function () {
|
5700 |
+
cm.curOp.forceUpdate = true
|
5701 |
+
adjustScrollWhenAboveVisible(cm, line, diff)
|
5702 |
+
signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line))
|
5703 |
+
})
|
5704 |
+
}
|
5705 |
+
};
|
5706 |
+
eventMixin(LineWidget)
|
5707 |
+
|
5708 |
+
function adjustScrollWhenAboveVisible(cm, line, diff) {
|
5709 |
+
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
|
5710 |
+
{ addToScrollTop(cm, diff) }
|
5711 |
+
}
|
5712 |
+
|
5713 |
+
function addLineWidget(doc, handle, node, options) {
|
5714 |
+
var widget = new LineWidget(doc, node, options)
|
5715 |
+
var cm = doc.cm
|
5716 |
+
if (cm && widget.noHScroll) { cm.display.alignWidgets = true }
|
5717 |
+
changeLine(doc, handle, "widget", function (line) {
|
5718 |
+
var widgets = line.widgets || (line.widgets = [])
|
5719 |
+
if (widget.insertAt == null) { widgets.push(widget) }
|
5720 |
+
else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget) }
|
5721 |
+
widget.line = line
|
5722 |
+
if (cm && !lineIsHidden(doc, line)) {
|
5723 |
+
var aboveVisible = heightAtLine(line) < doc.scrollTop
|
5724 |
+
updateLineHeight(line, line.height + widgetHeight(widget))
|
5725 |
+
if (aboveVisible) { addToScrollTop(cm, widget.height) }
|
5726 |
+
cm.curOp.forceUpdate = true
|
5727 |
+
}
|
5728 |
+
return true
|
5729 |
+
})
|
5730 |
+
if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)) }
|
5731 |
+
return widget
|
5732 |
+
}
|
5733 |
+
|
5734 |
+
// TEXTMARKERS
|
5735 |
+
|
5736 |
+
// Created with markText and setBookmark methods. A TextMarker is a
|
5737 |
+
// handle that can be used to clear or find a marked position in the
|
5738 |
+
// document. Line objects hold arrays (markedSpans) containing
|
5739 |
+
// {from, to, marker} object pointing to such marker objects, and
|
5740 |
+
// indicating that such a marker is present on that line. Multiple
|
5741 |
+
// lines may point to the same marker when it spans across lines.
|
5742 |
+
// The spans will have null for their from/to properties when the
|
5743 |
+
// marker continues beyond the start/end of the line. Markers have
|
5744 |
+
// links back to the lines they currently touch.
|
5745 |
+
|
5746 |
+
// Collapsed markers have unique ids, in order to be able to order
|
5747 |
+
// them, which is needed for uniquely determining an outer marker
|
5748 |
+
// when they overlap (they may nest, but not partially overlap).
|
5749 |
+
var nextMarkerId = 0
|
5750 |
+
|
5751 |
+
var TextMarker = function(doc, type) {
|
5752 |
+
this.lines = []
|
5753 |
+
this.type = type
|
5754 |
+
this.doc = doc
|
5755 |
+
this.id = ++nextMarkerId
|
5756 |
+
};
|
5757 |
+
|
5758 |
+
// Clear the marker.
|
5759 |
+
TextMarker.prototype.clear = function () {
|
5760 |
+
var this$1 = this;
|
5761 |
+
|
5762 |
+
if (this.explicitlyCleared) { return }
|
5763 |
+
var cm = this.doc.cm, withOp = cm && !cm.curOp
|
5764 |
+
if (withOp) { startOperation(cm) }
|
5765 |
+
if (hasHandler(this, "clear")) {
|
5766 |
+
var found = this.find()
|
5767 |
+
if (found) { signalLater(this, "clear", found.from, found.to) }
|
5768 |
+
}
|
5769 |
+
var min = null, max = null
|
5770 |
+
for (var i = 0; i < this.lines.length; ++i) {
|
5771 |
+
var line = this$1.lines[i]
|
5772 |
+
var span = getMarkedSpanFor(line.markedSpans, this$1)
|
5773 |
+
if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), "text") }
|
5774 |
+
else if (cm) {
|
5775 |
+
if (span.to != null) { max = lineNo(line) }
|
5776 |
+
if (span.from != null) { min = lineNo(line) }
|
5777 |
+
}
|
5778 |
+
line.markedSpans = removeMarkedSpan(line.markedSpans, span)
|
5779 |
+
if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)
|
5780 |
+
{ updateLineHeight(line, textHeight(cm.display)) }
|
5781 |
+
}
|
5782 |
+
if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
|
5783 |
+
var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual)
|
5784 |
+
if (len > cm.display.maxLineLength) {
|
5785 |
+
cm.display.maxLine = visual
|
5786 |
+
cm.display.maxLineLength = len
|
5787 |
+
cm.display.maxLineChanged = true
|
5788 |
+
}
|
5789 |
+
} }
|
5790 |
+
|
5791 |
+
if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1) }
|
5792 |
+
this.lines.length = 0
|
5793 |
+
this.explicitlyCleared = true
|
5794 |
+
if (this.atomic && this.doc.cantEdit) {
|
5795 |
+
this.doc.cantEdit = false
|
5796 |
+
if (cm) { reCheckSelection(cm.doc) }
|
5797 |
+
}
|
5798 |
+
if (cm) { signalLater(cm, "markerCleared", cm, this, min, max) }
|
5799 |
+
if (withOp) { endOperation(cm) }
|
5800 |
+
if (this.parent) { this.parent.clear() }
|
5801 |
+
};
|
5802 |
+
|
5803 |
+
// Find the position of the marker in the document. Returns a {from,
|
5804 |
+
// to} object by default. Side can be passed to get a specific side
|
5805 |
+
// -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
|
5806 |
+
// Pos objects returned contain a line object, rather than a line
|
5807 |
+
// number (used to prevent looking up the same line twice).
|
5808 |
+
TextMarker.prototype.find = function (side, lineObj) {
|
5809 |
+
var this$1 = this;
|
5810 |
+
|
5811 |
+
if (side == null && this.type == "bookmark") { side = 1 }
|
5812 |
+
var from, to
|
5813 |
+
for (var i = 0; i < this.lines.length; ++i) {
|
5814 |
+
var line = this$1.lines[i]
|
5815 |
+
var span = getMarkedSpanFor(line.markedSpans, this$1)
|
5816 |
+
if (span.from != null) {
|
5817 |
+
from = Pos(lineObj ? line : lineNo(line), span.from)
|
5818 |
+
if (side == -1) { return from }
|
5819 |
+
}
|
5820 |
+
if (span.to != null) {
|
5821 |
+
to = Pos(lineObj ? line : lineNo(line), span.to)
|
5822 |
+
if (side == 1) { return to }
|
5823 |
+
}
|
5824 |
+
}
|
5825 |
+
return from && {from: from, to: to}
|
5826 |
+
};
|
5827 |
+
|
5828 |
+
// Signals that the marker's widget changed, and surrounding layout
|
5829 |
+
// should be recomputed.
|
5830 |
+
TextMarker.prototype.changed = function () {
|
5831 |
+
var this$1 = this;
|
5832 |
+
|
5833 |
+
var pos = this.find(-1, true), widget = this, cm = this.doc.cm
|
5834 |
+
if (!pos || !cm) { return }
|
5835 |
+
runInOp(cm, function () {
|
5836 |
+
var line = pos.line, lineN = lineNo(pos.line)
|
5837 |
+
var view = findViewForLine(cm, lineN)
|
5838 |
+
if (view) {
|
5839 |
+
clearLineMeasurementCacheFor(view)
|
5840 |
+
cm.curOp.selectionChanged = cm.curOp.forceUpdate = true
|
5841 |
+
}
|
5842 |
+
cm.curOp.updateMaxLine = true
|
5843 |
+
if (!lineIsHidden(widget.doc, line) && widget.height != null) {
|
5844 |
+
var oldHeight = widget.height
|
5845 |
+
widget.height = null
|
5846 |
+
var dHeight = widgetHeight(widget) - oldHeight
|
5847 |
+
if (dHeight)
|
5848 |
+
{ updateLineHeight(line, line.height + dHeight) }
|
5849 |
+
}
|
5850 |
+
signalLater(cm, "markerChanged", cm, this$1)
|
5851 |
+
})
|
5852 |
+
};
|
5853 |
+
|
5854 |
+
TextMarker.prototype.attachLine = function (line) {
|
5855 |
+
if (!this.lines.length && this.doc.cm) {
|
5856 |
+
var op = this.doc.cm.curOp
|
5857 |
+
if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
|
5858 |
+
{ (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this) }
|
5859 |
+
}
|
5860 |
+
this.lines.push(line)
|
5861 |
+
};
|
5862 |
+
|
5863 |
+
TextMarker.prototype.detachLine = function (line) {
|
5864 |
+
this.lines.splice(indexOf(this.lines, line), 1)
|
5865 |
+
if (!this.lines.length && this.doc.cm) {
|
5866 |
+
var op = this.doc.cm.curOp
|
5867 |
+
;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this)
|
5868 |
+
}
|
5869 |
+
};
|
5870 |
+
eventMixin(TextMarker)
|
5871 |
+
|
5872 |
+
// Create a marker, wire it up to the right lines, and
|
5873 |
+
function markText(doc, from, to, options, type) {
|
5874 |
+
// Shared markers (across linked documents) are handled separately
|
5875 |
+
// (markTextShared will call out to this again, once per
|
5876 |
+
// document).
|
5877 |
+
if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
|
5878 |
+
// Ensure we are in an operation.
|
5879 |
+
if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }
|
5880 |
+
|
5881 |
+
var marker = new TextMarker(doc, type), diff = cmp(from, to)
|
5882 |
+
if (options) { copyObj(options, marker, false) }
|
5883 |
+
// Don't connect empty markers unless clearWhenEmpty is false
|
5884 |
+
if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
|
5885 |
+
{ return marker }
|
5886 |
+
if (marker.replacedWith) {
|
5887 |
+
// Showing up as a widget implies collapsed (widget replaces text)
|
5888 |
+
marker.collapsed = true
|
5889 |
+
marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget")
|
5890 |
+
if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true") }
|
5891 |
+
if (options.insertLeft) { marker.widgetNode.insertLeft = true }
|
5892 |
+
}
|
5893 |
+
if (marker.collapsed) {
|
5894 |
+
if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
|
5895 |
+
from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
|
5896 |
+
{ throw new Error("Inserting collapsed marker partially overlapping an existing one") }
|
5897 |
+
seeCollapsedSpans()
|
5898 |
+
}
|
5899 |
+
|
5900 |
+
if (marker.addToHistory)
|
5901 |
+
{ addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN) }
|
5902 |
+
|
5903 |
+
var curLine = from.line, cm = doc.cm, updateMaxLine
|
5904 |
+
doc.iter(curLine, to.line + 1, function (line) {
|
5905 |
+
if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
|
5906 |
+
{ updateMaxLine = true }
|
5907 |
+
if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0) }
|
5908 |
+
addMarkedSpan(line, new MarkedSpan(marker,
|
5909 |
+
curLine == from.line ? from.ch : null,
|
5910 |
+
curLine == to.line ? to.ch : null))
|
5911 |
+
++curLine
|
5912 |
+
})
|
5913 |
+
// lineIsHidden depends on the presence of the spans, so needs a second pass
|
5914 |
+
if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {
|
5915 |
+
if (lineIsHidden(doc, line)) { updateLineHeight(line, 0) }
|
5916 |
+
}) }
|
5917 |
+
|
5918 |
+
if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }) }
|
5919 |
+
|
5920 |
+
if (marker.readOnly) {
|
5921 |
+
seeReadOnlySpans()
|
5922 |
+
if (doc.history.done.length || doc.history.undone.length)
|
5923 |
+
{ doc.clearHistory() }
|
5924 |
+
}
|
5925 |
+
if (marker.collapsed) {
|
5926 |
+
marker.id = ++nextMarkerId
|
5927 |
+
marker.atomic = true
|
5928 |
+
}
|
5929 |
+
if (cm) {
|
5930 |
+
// Sync editor state
|
5931 |
+
if (updateMaxLine) { cm.curOp.updateMaxLine = true }
|
5932 |
+
if (marker.collapsed)
|
5933 |
+
{ regChange(cm, from.line, to.line + 1) }
|
5934 |
+
else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
|
5935 |
+
{ for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text") } }
|
5936 |
+
if (marker.atomic) { reCheckSelection(cm.doc) }
|
5937 |
+
signalLater(cm, "markerAdded", cm, marker)
|
5938 |
+
}
|
5939 |
+
return marker
|
5940 |
+
}
|
5941 |
+
|
5942 |
+
// SHARED TEXTMARKERS
|
5943 |
+
|
5944 |
+
// A shared marker spans multiple linked documents. It is
|
5945 |
+
// implemented as a meta-marker-object controlling multiple normal
|
5946 |
+
// markers.
|
5947 |
+
var SharedTextMarker = function(markers, primary) {
|
5948 |
+
var this$1 = this;
|
5949 |
+
|
5950 |
+
this.markers = markers
|
5951 |
+
this.primary = primary
|
5952 |
+
for (var i = 0; i < markers.length; ++i)
|
5953 |
+
{ markers[i].parent = this$1 }
|
5954 |
+
};
|
5955 |
+
|
5956 |
+
SharedTextMarker.prototype.clear = function () {
|
5957 |
+
var this$1 = this;
|
5958 |
+
|
5959 |
+
if (this.explicitlyCleared) { return }
|
5960 |
+
this.explicitlyCleared = true
|
5961 |
+
for (var i = 0; i < this.markers.length; ++i)
|
5962 |
+
{ this$1.markers[i].clear() }
|
5963 |
+
signalLater(this, "clear")
|
5964 |
+
};
|
5965 |
+
|
5966 |
+
SharedTextMarker.prototype.find = function (side, lineObj) {
|
5967 |
+
return this.primary.find(side, lineObj)
|
5968 |
+
};
|
5969 |
+
eventMixin(SharedTextMarker)
|
5970 |
+
|
5971 |
+
function markTextShared(doc, from, to, options, type) {
|
5972 |
+
options = copyObj(options)
|
5973 |
+
options.shared = false
|
5974 |
+
var markers = [markText(doc, from, to, options, type)], primary = markers[0]
|
5975 |
+
var widget = options.widgetNode
|
5976 |
+
linkedDocs(doc, function (doc) {
|
5977 |
+
if (widget) { options.widgetNode = widget.cloneNode(true) }
|
5978 |
+
markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type))
|
5979 |
+
for (var i = 0; i < doc.linked.length; ++i)
|
5980 |
+
{ if (doc.linked[i].isParent) { return } }
|
5981 |
+
primary = lst(markers)
|
5982 |
+
})
|
5983 |
+
return new SharedTextMarker(markers, primary)
|
5984 |
+
}
|
5985 |
+
|
5986 |
+
function findSharedMarkers(doc) {
|
5987 |
+
return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })
|
5988 |
+
}
|
5989 |
+
|
5990 |
+
function copySharedMarkers(doc, markers) {
|
5991 |
+
for (var i = 0; i < markers.length; i++) {
|
5992 |
+
var marker = markers[i], pos = marker.find()
|
5993 |
+
var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to)
|
5994 |
+
if (cmp(mFrom, mTo)) {
|
5995 |
+
var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type)
|
5996 |
+
marker.markers.push(subMark)
|
5997 |
+
subMark.parent = marker
|
5998 |
+
}
|
5999 |
+
}
|
6000 |
+
}
|
6001 |
+
|
6002 |
+
function detachSharedMarkers(markers) {
|
6003 |
+
var loop = function ( i ) {
|
6004 |
+
var marker = markers[i], linked = [marker.primary.doc]
|
6005 |
+
linkedDocs(marker.primary.doc, function (d) { return linked.push(d); })
|
6006 |
+
for (var j = 0; j < marker.markers.length; j++) {
|
6007 |
+
var subMarker = marker.markers[j]
|
6008 |
+
if (indexOf(linked, subMarker.doc) == -1) {
|
6009 |
+
subMarker.parent = null
|
6010 |
+
marker.markers.splice(j--, 1)
|
6011 |
+
}
|
6012 |
+
}
|
6013 |
+
};
|
6014 |
+
|
6015 |
+
for (var i = 0; i < markers.length; i++) loop( i );
|
6016 |
+
}
|
6017 |
+
|
6018 |
+
var nextDocId = 0
|
6019 |
+
var Doc = function(text, mode, firstLine, lineSep, direction) {
|
6020 |
+
if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }
|
6021 |
+
if (firstLine == null) { firstLine = 0 }
|
6022 |
+
|
6023 |
+
BranchChunk.call(this, [new LeafChunk([new Line("", null)])])
|
6024 |
+
this.first = firstLine
|
6025 |
+
this.scrollTop = this.scrollLeft = 0
|
6026 |
+
this.cantEdit = false
|
6027 |
+
this.cleanGeneration = 1
|
6028 |
+
this.modeFrontier = this.highlightFrontier = firstLine
|
6029 |
+
var start = Pos(firstLine, 0)
|
6030 |
+
this.sel = simpleSelection(start)
|
6031 |
+
this.history = new History(null)
|
6032 |
+
this.id = ++nextDocId
|
6033 |
+
this.modeOption = mode
|
6034 |
+
this.lineSep = lineSep
|
6035 |
+
this.direction = (direction == "rtl") ? "rtl" : "ltr"
|
6036 |
+
this.extend = false
|
6037 |
+
|
6038 |
+
if (typeof text == "string") { text = this.splitLines(text) }
|
6039 |
+
updateDoc(this, {from: start, to: start, text: text})
|
6040 |
+
setSelection(this, simpleSelection(start), sel_dontScroll)
|
6041 |
+
}
|
6042 |
+
|
6043 |
+
Doc.prototype = createObj(BranchChunk.prototype, {
|
6044 |
+
constructor: Doc,
|
6045 |
+
// Iterate over the document. Supports two forms -- with only one
|
6046 |
+
// argument, it calls that for each line in the document. With
|
6047 |
+
// three, it iterates over the range given by the first two (with
|
6048 |
+
// the second being non-inclusive).
|
6049 |
+
iter: function(from, to, op) {
|
6050 |
+
if (op) { this.iterN(from - this.first, to - from, op) }
|
6051 |
+
else { this.iterN(this.first, this.first + this.size, from) }
|
6052 |
+
},
|
6053 |
+
|
6054 |
+
// Non-public interface for adding and removing lines.
|
6055 |
+
insert: function(at, lines) {
|
6056 |
+
var height = 0
|
6057 |
+
for (var i = 0; i < lines.length; ++i) { height += lines[i].height }
|
6058 |
+
this.insertInner(at - this.first, lines, height)
|
6059 |
+
},
|
6060 |
+
remove: function(at, n) { this.removeInner(at - this.first, n) },
|
6061 |
+
|
6062 |
+
// From here, the methods are part of the public interface. Most
|
6063 |
+
// are also available from CodeMirror (editor) instances.
|
6064 |
+
|
6065 |
+
getValue: function(lineSep) {
|
6066 |
+
var lines = getLines(this, this.first, this.first + this.size)
|
6067 |
+
if (lineSep === false) { return lines }
|
6068 |
+
return lines.join(lineSep || this.lineSeparator())
|
6069 |
+
},
|
6070 |
+
setValue: docMethodOp(function(code) {
|
6071 |
+
var top = Pos(this.first, 0), last = this.first + this.size - 1
|
6072 |
+
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
|
6073 |
+
text: this.splitLines(code), origin: "setValue", full: true}, true)
|
6074 |
+
if (this.cm) { scrollToCoords(this.cm, 0, 0) }
|
6075 |
+
setSelection(this, simpleSelection(top), sel_dontScroll)
|
6076 |
+
}),
|
6077 |
+
replaceRange: function(code, from, to, origin) {
|
6078 |
+
from = clipPos(this, from)
|
6079 |
+
to = to ? clipPos(this, to) : from
|
6080 |
+
replaceRange(this, code, from, to, origin)
|
6081 |
+
},
|
6082 |
+
getRange: function(from, to, lineSep) {
|
6083 |
+
var lines = getBetween(this, clipPos(this, from), clipPos(this, to))
|
6084 |
+
if (lineSep === false) { return lines }
|
6085 |
+
return lines.join(lineSep || this.lineSeparator())
|
6086 |
+
},
|
6087 |
+
|
6088 |
+
getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},
|
6089 |
+
|
6090 |
+
getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},
|
6091 |
+
getLineNumber: function(line) {return lineNo(line)},
|
6092 |
+
|
6093 |
+
getLineHandleVisualStart: function(line) {
|
6094 |
+
if (typeof line == "number") { line = getLine(this, line) }
|
6095 |
+
return visualLine(line)
|
6096 |
+
},
|
6097 |
+
|
6098 |
+
lineCount: function() {return this.size},
|
6099 |
+
firstLine: function() {return this.first},
|
6100 |
+
lastLine: function() {return this.first + this.size - 1},
|
6101 |
+
|
6102 |
+
clipPos: function(pos) {return clipPos(this, pos)},
|
6103 |
+
|
6104 |
+
getCursor: function(start) {
|
6105 |
+
var range = this.sel.primary(), pos
|
6106 |
+
if (start == null || start == "head") { pos = range.head }
|
6107 |
+
else if (start == "anchor") { pos = range.anchor }
|
6108 |
+
else if (start == "end" || start == "to" || start === false) { pos = range.to() }
|
6109 |
+
else { pos = range.from() }
|
6110 |
+
return pos
|
6111 |
+
},
|
6112 |
+
listSelections: function() { return this.sel.ranges },
|
6113 |
+
somethingSelected: function() {return this.sel.somethingSelected()},
|
6114 |
+
|
6115 |
+
setCursor: docMethodOp(function(line, ch, options) {
|
6116 |
+
setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options)
|
6117 |
+
}),
|
6118 |
+
setSelection: docMethodOp(function(anchor, head, options) {
|
6119 |
+
setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options)
|
6120 |
+
}),
|
6121 |
+
extendSelection: docMethodOp(function(head, other, options) {
|
6122 |
+
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options)
|
6123 |
+
}),
|
6124 |
+
extendSelections: docMethodOp(function(heads, options) {
|
6125 |
+
extendSelections(this, clipPosArray(this, heads), options)
|
6126 |
+
}),
|
6127 |
+
extendSelectionsBy: docMethodOp(function(f, options) {
|
6128 |
+
var heads = map(this.sel.ranges, f)
|
6129 |
+
extendSelections(this, clipPosArray(this, heads), options)
|
6130 |
+
}),
|
6131 |
+
setSelections: docMethodOp(function(ranges, primary, options) {
|
6132 |
+
var this$1 = this;
|
6133 |
+
|
6134 |
+
if (!ranges.length) { return }
|
6135 |
+
var out = []
|
6136 |
+
for (var i = 0; i < ranges.length; i++)
|
6137 |
+
{ out[i] = new Range(clipPos(this$1, ranges[i].anchor),
|
6138 |
+
clipPos(this$1, ranges[i].head)) }
|
6139 |
+
if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex) }
|
6140 |
+
setSelection(this, normalizeSelection(out, primary), options)
|
6141 |
+
}),
|
6142 |
+
addSelection: docMethodOp(function(anchor, head, options) {
|
6143 |
+
var ranges = this.sel.ranges.slice(0)
|
6144 |
+
ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)))
|
6145 |
+
setSelection(this, normalizeSelection(ranges, ranges.length - 1), options)
|
6146 |
+
}),
|
6147 |
+
|
6148 |
+
getSelection: function(lineSep) {
|
6149 |
+
var this$1 = this;
|
6150 |
+
|
6151 |
+
var ranges = this.sel.ranges, lines
|
6152 |
+
for (var i = 0; i < ranges.length; i++) {
|
6153 |
+
var sel = getBetween(this$1, ranges[i].from(), ranges[i].to())
|
6154 |
+
lines = lines ? lines.concat(sel) : sel
|
6155 |
+
}
|
6156 |
+
if (lineSep === false) { return lines }
|
6157 |
+
else { return lines.join(lineSep || this.lineSeparator()) }
|
6158 |
+
},
|
6159 |
+
getSelections: function(lineSep) {
|
6160 |
+
var this$1 = this;
|
6161 |
+
|
6162 |
+
var parts = [], ranges = this.sel.ranges
|
6163 |
+
for (var i = 0; i < ranges.length; i++) {
|
6164 |
+
var sel = getBetween(this$1, ranges[i].from(), ranges[i].to())
|
6165 |
+
if (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()) }
|
6166 |
+
parts[i] = sel
|
6167 |
+
}
|
6168 |
+
return parts
|
6169 |
+
},
|
6170 |
+
replaceSelection: function(code, collapse, origin) {
|
6171 |
+
var dup = []
|
6172 |
+
for (var i = 0; i < this.sel.ranges.length; i++)
|
6173 |
+
{ dup[i] = code }
|
6174 |
+
this.replaceSelections(dup, collapse, origin || "+input")
|
6175 |
+
},
|
6176 |
+
replaceSelections: docMethodOp(function(code, collapse, origin) {
|
6177 |
+
var this$1 = this;
|
6178 |
+
|
6179 |
+
var changes = [], sel = this.sel
|
6180 |
+
for (var i = 0; i < sel.ranges.length; i++) {
|
6181 |
+
var range = sel.ranges[i]
|
6182 |
+
changes[i] = {from: range.from(), to: range.to(), text: this$1.splitLines(code[i]), origin: origin}
|
6183 |
+
}
|
6184 |
+
var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse)
|
6185 |
+
for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)
|
6186 |
+
{ makeChange(this$1, changes[i$1]) }
|
6187 |
+
if (newSel) { setSelectionReplaceHistory(this, newSel) }
|
6188 |
+
else if (this.cm) { ensureCursorVisible(this.cm) }
|
6189 |
+
}),
|
6190 |
+
undo: docMethodOp(function() {makeChangeFromHistory(this, "undo")}),
|
6191 |
+
redo: docMethodOp(function() {makeChangeFromHistory(this, "redo")}),
|
6192 |
+
undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true)}),
|
6193 |
+
redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true)}),
|
6194 |
+
|
6195 |
+
setExtending: function(val) {this.extend = val},
|
6196 |
+
getExtending: function() {return this.extend},
|
6197 |
+
|
6198 |
+
historySize: function() {
|
6199 |
+
var hist = this.history, done = 0, undone = 0
|
6200 |
+
for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done } }
|
6201 |
+
for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone } }
|
6202 |
+
return {undo: done, redo: undone}
|
6203 |
+
},
|
6204 |
+
clearHistory: function() {this.history = new History(this.history.maxGeneration)},
|
6205 |
+
|
6206 |
+
markClean: function() {
|
6207 |
+
this.cleanGeneration = this.changeGeneration(true)
|
6208 |
+
},
|
6209 |
+
changeGeneration: function(forceSplit) {
|
6210 |
+
if (forceSplit)
|
6211 |
+
{ this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null }
|
6212 |
+
return this.history.generation
|
6213 |
+
},
|
6214 |
+
isClean: function (gen) {
|
6215 |
+
return this.history.generation == (gen || this.cleanGeneration)
|
6216 |
+
},
|
6217 |
+
|
6218 |
+
getHistory: function() {
|
6219 |
+
return {done: copyHistoryArray(this.history.done),
|
6220 |
+
undone: copyHistoryArray(this.history.undone)}
|
6221 |
+
},
|
6222 |
+
setHistory: function(histData) {
|
6223 |
+
var hist = this.history = new History(this.history.maxGeneration)
|
6224 |
+
hist.done = copyHistoryArray(histData.done.slice(0), null, true)
|
6225 |
+
hist.undone = copyHistoryArray(histData.undone.slice(0), null, true)
|
6226 |
+
},
|
6227 |
+
|
6228 |
+
setGutterMarker: docMethodOp(function(line, gutterID, value) {
|
6229 |
+
return changeLine(this, line, "gutter", function (line) {
|
6230 |
+
var markers = line.gutterMarkers || (line.gutterMarkers = {})
|
6231 |
+
markers[gutterID] = value
|
6232 |
+
if (!value && isEmpty(markers)) { line.gutterMarkers = null }
|
6233 |
+
return true
|
6234 |
+
})
|
6235 |
+
}),
|
6236 |
+
|
6237 |
+
clearGutter: docMethodOp(function(gutterID) {
|
6238 |
+
var this$1 = this;
|
6239 |
+
|
6240 |
+
this.iter(function (line) {
|
6241 |
+
if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
|
6242 |
+
changeLine(this$1, line, "gutter", function () {
|
6243 |
+
line.gutterMarkers[gutterID] = null
|
6244 |
+
if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null }
|
6245 |
+
return true
|
6246 |
+
})
|
6247 |
+
}
|
6248 |
+
})
|
6249 |
+
}),
|
6250 |
+
|
6251 |
+
lineInfo: function(line) {
|
6252 |
+
var n
|
6253 |
+
if (typeof line == "number") {
|
6254 |
+
if (!isLine(this, line)) { return null }
|
6255 |
+
n = line
|
6256 |
+
line = getLine(this, line)
|
6257 |
+
if (!line) { return null }
|
6258 |
+
} else {
|
6259 |
+
n = lineNo(line)
|
6260 |
+
if (n == null) { return null }
|
6261 |
+
}
|
6262 |
+
return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
|
6263 |
+
textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
|
6264 |
+
widgets: line.widgets}
|
6265 |
+
},
|
6266 |
+
|
6267 |
+
addLineClass: docMethodOp(function(handle, where, cls) {
|
6268 |
+
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
|
6269 |
+
var prop = where == "text" ? "textClass"
|
6270 |
+
: where == "background" ? "bgClass"
|
6271 |
+
: where == "gutter" ? "gutterClass" : "wrapClass"
|
6272 |
+
if (!line[prop]) { line[prop] = cls }
|
6273 |
+
else if (classTest(cls).test(line[prop])) { return false }
|
6274 |
+
else { line[prop] += " " + cls }
|
6275 |
+
return true
|
6276 |
+
})
|
6277 |
+
}),
|
6278 |
+
removeLineClass: docMethodOp(function(handle, where, cls) {
|
6279 |
+
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
|
6280 |
+
var prop = where == "text" ? "textClass"
|
6281 |
+
: where == "background" ? "bgClass"
|
6282 |
+
: where == "gutter" ? "gutterClass" : "wrapClass"
|
6283 |
+
var cur = line[prop]
|
6284 |
+
if (!cur) { return false }
|
6285 |
+
else if (cls == null) { line[prop] = null }
|
6286 |
+
else {
|
6287 |
+
var found = cur.match(classTest(cls))
|
6288 |
+
if (!found) { return false }
|
6289 |
+
var end = found.index + found[0].length
|
6290 |
+
line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null
|
6291 |
+
}
|
6292 |
+
return true
|
6293 |
+
})
|
6294 |
+
}),
|
6295 |
+
|
6296 |
+
addLineWidget: docMethodOp(function(handle, node, options) {
|
6297 |
+
return addLineWidget(this, handle, node, options)
|
6298 |
+
}),
|
6299 |
+
removeLineWidget: function(widget) { widget.clear() },
|
6300 |
+
|
6301 |
+
markText: function(from, to, options) {
|
6302 |
+
return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range")
|
6303 |
+
},
|
6304 |
+
setBookmark: function(pos, options) {
|
6305 |
+
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
|
6306 |
+
insertLeft: options && options.insertLeft,
|
6307 |
+
clearWhenEmpty: false, shared: options && options.shared,
|
6308 |
+
handleMouseEvents: options && options.handleMouseEvents}
|
6309 |
+
pos = clipPos(this, pos)
|
6310 |
+
return markText(this, pos, pos, realOpts, "bookmark")
|
6311 |
+
},
|
6312 |
+
findMarksAt: function(pos) {
|
6313 |
+
pos = clipPos(this, pos)
|
6314 |
+
var markers = [], spans = getLine(this, pos.line).markedSpans
|
6315 |
+
if (spans) { for (var i = 0; i < spans.length; ++i) {
|
6316 |
+
var span = spans[i]
|
6317 |
+
if ((span.from == null || span.from <= pos.ch) &&
|
6318 |
+
(span.to == null || span.to >= pos.ch))
|
6319 |
+
{ markers.push(span.marker.parent || span.marker) }
|
6320 |
+
} }
|
6321 |
+
return markers
|
6322 |
+
},
|
6323 |
+
findMarks: function(from, to, filter) {
|
6324 |
+
from = clipPos(this, from); to = clipPos(this, to)
|
6325 |
+
var found = [], lineNo = from.line
|
6326 |
+
this.iter(from.line, to.line + 1, function (line) {
|
6327 |
+
var spans = line.markedSpans
|
6328 |
+
if (spans) { for (var i = 0; i < spans.length; i++) {
|
6329 |
+
var span = spans[i]
|
6330 |
+
if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
|
6331 |
+
span.from == null && lineNo != from.line ||
|
6332 |
+
span.from != null && lineNo == to.line && span.from >= to.ch) &&
|
6333 |
+
(!filter || filter(span.marker)))
|
6334 |
+
{ found.push(span.marker.parent || span.marker) }
|
6335 |
+
} }
|
6336 |
+
++lineNo
|
6337 |
+
})
|
6338 |
+
return found
|
6339 |
+
},
|
6340 |
+
getAllMarks: function() {
|
6341 |
+
var markers = []
|
6342 |
+
this.iter(function (line) {
|
6343 |
+
var sps = line.markedSpans
|
6344 |
+
if (sps) { for (var i = 0; i < sps.length; ++i)
|
6345 |
+
{ if (sps[i].from != null) { markers.push(sps[i].marker) } } }
|
6346 |
+
})
|
6347 |
+
return markers
|
6348 |
+
},
|
6349 |
+
|
6350 |
+
posFromIndex: function(off) {
|
6351 |
+
var ch, lineNo = this.first, sepSize = this.lineSeparator().length
|
6352 |
+
this.iter(function (line) {
|
6353 |
+
var sz = line.text.length + sepSize
|
6354 |
+
if (sz > off) { ch = off; return true }
|
6355 |
+
off -= sz
|
6356 |
+
++lineNo
|
6357 |
+
})
|
6358 |
+
return clipPos(this, Pos(lineNo, ch))
|
6359 |
+
},
|
6360 |
+
indexFromPos: function (coords) {
|
6361 |
+
coords = clipPos(this, coords)
|
6362 |
+
var index = coords.ch
|
6363 |
+
if (coords.line < this.first || coords.ch < 0) { return 0 }
|
6364 |
+
var sepSize = this.lineSeparator().length
|
6365 |
+
this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value
|
6366 |
+
index += line.text.length + sepSize
|
6367 |
+
})
|
6368 |
+
return index
|
6369 |
+
},
|
6370 |
+
|
6371 |
+
copy: function(copyHistory) {
|
6372 |
+
var doc = new Doc(getLines(this, this.first, this.first + this.size),
|
6373 |
+
this.modeOption, this.first, this.lineSep, this.direction)
|
6374 |
+
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft
|
6375 |
+
doc.sel = this.sel
|
6376 |
+
doc.extend = false
|
6377 |
+
if (copyHistory) {
|
6378 |
+
doc.history.undoDepth = this.history.undoDepth
|
6379 |
+
doc.setHistory(this.getHistory())
|
6380 |
+
}
|
6381 |
+
return doc
|
6382 |
+
},
|
6383 |
+
|
6384 |
+
linkedDoc: function(options) {
|
6385 |
+
if (!options) { options = {} }
|
6386 |
+
var from = this.first, to = this.first + this.size
|
6387 |
+
if (options.from != null && options.from > from) { from = options.from }
|
6388 |
+
if (options.to != null && options.to < to) { to = options.to }
|
6389 |
+
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction)
|
6390 |
+
if (options.sharedHist) { copy.history = this.history
|
6391 |
+
; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist})
|
6392 |
+
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]
|
6393 |
+
copySharedMarkers(copy, findSharedMarkers(this))
|
6394 |
+
return copy
|
6395 |
+
},
|
6396 |
+
unlinkDoc: function(other) {
|
6397 |
+
var this$1 = this;
|
6398 |
+
|
6399 |
+
if (other instanceof CodeMirror) { other = other.doc }
|
6400 |
+
if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
|
6401 |
+
var link = this$1.linked[i]
|
6402 |
+
if (link.doc != other) { continue }
|
6403 |
+
this$1.linked.splice(i, 1)
|
6404 |
+
other.unlinkDoc(this$1)
|
6405 |
+
detachSharedMarkers(findSharedMarkers(this$1))
|
6406 |
+
break
|
6407 |
+
} }
|
6408 |
+
// If the histories were shared, split them again
|
6409 |
+
if (other.history == this.history) {
|
6410 |
+
var splitIds = [other.id]
|
6411 |
+
linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true)
|
6412 |
+
other.history = new History(null)
|
6413 |
+
other.history.done = copyHistoryArray(this.history.done, splitIds)
|
6414 |
+
other.history.undone = copyHistoryArray(this.history.undone, splitIds)
|
6415 |
+
}
|
6416 |
+
},
|
6417 |
+
iterLinkedDocs: function(f) {linkedDocs(this, f)},
|
6418 |
+
|
6419 |
+
getMode: function() {return this.mode},
|
6420 |
+
getEditor: function() {return this.cm},
|
6421 |
+
|
6422 |
+
splitLines: function(str) {
|
6423 |
+
if (this.lineSep) { return str.split(this.lineSep) }
|
6424 |
+
return splitLinesAuto(str)
|
6425 |
+
},
|
6426 |
+
lineSeparator: function() { return this.lineSep || "\n" },
|
6427 |
+
|
6428 |
+
setDirection: docMethodOp(function (dir) {
|
6429 |
+
if (dir != "rtl") { dir = "ltr" }
|
6430 |
+
if (dir == this.direction) { return }
|
6431 |
+
this.direction = dir
|
6432 |
+
this.iter(function (line) { return line.order = null; })
|
6433 |
+
if (this.cm) { directionChanged(this.cm) }
|
6434 |
+
})
|
6435 |
+
})
|
6436 |
+
|
6437 |
+
// Public alias.
|
6438 |
+
Doc.prototype.eachLine = Doc.prototype.iter
|
6439 |
+
|
6440 |
+
// Kludge to work around strange IE behavior where it'll sometimes
|
6441 |
+
// re-fire a series of drag-related events right after the drop (#1551)
|
6442 |
+
var lastDrop = 0
|
6443 |
+
|
6444 |
+
function onDrop(e) {
|
6445 |
+
var cm = this
|
6446 |
+
clearDragCursor(cm)
|
6447 |
+
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
|
6448 |
+
{ return }
|
6449 |
+
e_preventDefault(e)
|
6450 |
+
if (ie) { lastDrop = +new Date }
|
6451 |
+
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files
|
6452 |
+
if (!pos || cm.isReadOnly()) { return }
|
6453 |
+
// Might be a file drop, in which case we simply extract the text
|
6454 |
+
// and insert it.
|
6455 |
+
if (files && files.length && window.FileReader && window.File) {
|
6456 |
+
var n = files.length, text = Array(n), read = 0
|
6457 |
+
var loadFile = function (file, i) {
|
6458 |
+
if (cm.options.allowDropFileTypes &&
|
6459 |
+
indexOf(cm.options.allowDropFileTypes, file.type) == -1)
|
6460 |
+
{ return }
|
6461 |
+
|
6462 |
+
var reader = new FileReader
|
6463 |
+
reader.onload = operation(cm, function () {
|
6464 |
+
var content = reader.result
|
6465 |
+
if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = "" }
|
6466 |
+
text[i] = content
|
6467 |
+
if (++read == n) {
|
6468 |
+
pos = clipPos(cm.doc, pos)
|
6469 |
+
var change = {from: pos, to: pos,
|
6470 |
+
text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
|
6471 |
+
origin: "paste"}
|
6472 |
+
makeChange(cm.doc, change)
|
6473 |
+
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)))
|
6474 |
+
}
|
6475 |
+
})
|
6476 |
+
reader.readAsText(file)
|
6477 |
+
}
|
6478 |
+
for (var i = 0; i < n; ++i) { loadFile(files[i], i) }
|
6479 |
+
} else { // Normal drop
|
6480 |
+
// Don't do a replace if the drop happened inside of the selected text.
|
6481 |
+
if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
|
6482 |
+
cm.state.draggingText(e)
|
6483 |
+
// Ensure the editor is re-focused
|
6484 |
+
setTimeout(function () { return cm.display.input.focus(); }, 20)
|
6485 |
+
return
|
6486 |
+
}
|
6487 |
+
try {
|
6488 |
+
var text$1 = e.dataTransfer.getData("Text")
|
6489 |
+
if (text$1) {
|
6490 |
+
var selected
|
6491 |
+
if (cm.state.draggingText && !cm.state.draggingText.copy)
|
6492 |
+
{ selected = cm.listSelections() }
|
6493 |
+
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos))
|
6494 |
+
if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)
|
6495 |
+
{ replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag") } }
|
6496 |
+
cm.replaceSelection(text$1, "around", "paste")
|
6497 |
+
cm.display.input.focus()
|
6498 |
+
}
|
6499 |
+
}
|
6500 |
+
catch(e){}
|
6501 |
+
}
|
6502 |
+
}
|
6503 |
+
|
6504 |
+
function onDragStart(cm, e) {
|
6505 |
+
if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
|
6506 |
+
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }
|
6507 |
+
|
6508 |
+
e.dataTransfer.setData("Text", cm.getSelection())
|
6509 |
+
e.dataTransfer.effectAllowed = "copyMove"
|
6510 |
+
|
6511 |
+
// Use dummy image instead of default browsers image.
|
6512 |
+
// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
|
6513 |
+
if (e.dataTransfer.setDragImage && !safari) {
|
6514 |
+
var img = elt("img", null, null, "position: fixed; left: 0; top: 0;")
|
6515 |
+
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
|
6516 |
+
if (presto) {
|
6517 |
+
img.width = img.height = 1
|
6518 |
+
cm.display.wrapper.appendChild(img)
|
6519 |
+
// Force a relayout, or Opera won't use our image for some obscure reason
|
6520 |
+
img._top = img.offsetTop
|
6521 |
+
}
|
6522 |
+
e.dataTransfer.setDragImage(img, 0, 0)
|
6523 |
+
if (presto) { img.parentNode.removeChild(img) }
|
6524 |
+
}
|
6525 |
+
}
|
6526 |
+
|
6527 |
+
function onDragOver(cm, e) {
|
6528 |
+
var pos = posFromMouse(cm, e)
|
6529 |
+
if (!pos) { return }
|
6530 |
+
var frag = document.createDocumentFragment()
|
6531 |
+
drawSelectionCursor(cm, pos, frag)
|
6532 |
+
if (!cm.display.dragCursor) {
|
6533 |
+
cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors")
|
6534 |
+
cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv)
|
6535 |
+
}
|
6536 |
+
removeChildrenAndAdd(cm.display.dragCursor, frag)
|
6537 |
+
}
|
6538 |
+
|
6539 |
+
function clearDragCursor(cm) {
|
6540 |
+
if (cm.display.dragCursor) {
|
6541 |
+
cm.display.lineSpace.removeChild(cm.display.dragCursor)
|
6542 |
+
cm.display.dragCursor = null
|
6543 |
+
}
|
6544 |
+
}
|
6545 |
+
|
6546 |
+
// These must be handled carefully, because naively registering a
|
6547 |
+
// handler for each editor will cause the editors to never be
|
6548 |
+
// garbage collected.
|
6549 |
+
|
6550 |
+
function forEachCodeMirror(f) {
|
6551 |
+
if (!document.getElementsByClassName) { return }
|
6552 |
+
var byClass = document.getElementsByClassName("CodeMirror")
|
6553 |
+
for (var i = 0; i < byClass.length; i++) {
|
6554 |
+
var cm = byClass[i].CodeMirror
|
6555 |
+
if (cm) { f(cm) }
|
6556 |
+
}
|
6557 |
+
}
|
6558 |
+
|
6559 |
+
var globalsRegistered = false
|
6560 |
+
function ensureGlobalHandlers() {
|
6561 |
+
if (globalsRegistered) { return }
|
6562 |
+
registerGlobalHandlers()
|
6563 |
+
globalsRegistered = true
|
6564 |
+
}
|
6565 |
+
function registerGlobalHandlers() {
|
6566 |
+
// When the window resizes, we need to refresh active editors.
|
6567 |
+
var resizeTimer
|
6568 |
+
on(window, "resize", function () {
|
6569 |
+
if (resizeTimer == null) { resizeTimer = setTimeout(function () {
|
6570 |
+
resizeTimer = null
|
6571 |
+
forEachCodeMirror(onResize)
|
6572 |
+
}, 100) }
|
6573 |
+
})
|
6574 |
+
// When the window loses focus, we want to show the editor as blurred
|
6575 |
+
on(window, "blur", function () { return forEachCodeMirror(onBlur); })
|
6576 |
+
}
|
6577 |
+
// Called when the window resizes
|
6578 |
+
function onResize(cm) {
|
6579 |
+
var d = cm.display
|
6580 |
+
if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
|
6581 |
+
{ return }
|
6582 |
+
// Might be a text scaling operation, clear size caches.
|
6583 |
+
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null
|
6584 |
+
d.scrollbarsClipped = false
|
6585 |
+
cm.setSize()
|
6586 |
+
}
|
6587 |
+
|
6588 |
+
var keyNames = {
|
6589 |
+
3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
|
6590 |
+
19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
|
6591 |
+
36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
|
6592 |
+
46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
|
6593 |
+
106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete", 145: "ScrollLock",
|
6594 |
+
173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
|
6595 |
+
221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
|
6596 |
+
63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
|
6597 |
+
}
|
6598 |
+
|
6599 |
+
// Number keys
|
6600 |
+
for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i) }
|
6601 |
+
// Alphabetic keys
|
6602 |
+
for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1) }
|
6603 |
+
// Function keys
|
6604 |
+
for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2 }
|
6605 |
+
|
6606 |
+
var keyMap = {}
|
6607 |
+
|
6608 |
+
keyMap.basic = {
|
6609 |
+
"Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
|
6610 |
+
"End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
|
6611 |
+
"Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
|
6612 |
+
"Tab": "defaultTab", "Shift-Tab": "indentAuto",
|
6613 |
+
"Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
|
6614 |
+
"Esc": "singleSelection"
|
6615 |
+
}
|
6616 |
+
// Note that the save and find-related commands aren't defined by
|
6617 |
+
// default. User code or addons can define them. Unknown commands
|
6618 |
+
// are simply ignored.
|
6619 |
+
keyMap.pcDefault = {
|
6620 |
+
"Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
|
6621 |
+
"Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
|
6622 |
+
"Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
|
6623 |
+
"Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
|
6624 |
+
"Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
|
6625 |
+
"Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
|
6626 |
+
"Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
|
6627 |
+
fallthrough: "basic"
|
6628 |
+
}
|
6629 |
+
// Very basic readline/emacs-style bindings, which are standard on Mac.
|
6630 |
+
keyMap.emacsy = {
|
6631 |
+
"Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
|
6632 |
+
"Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
|
6633 |
+
"Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
|
6634 |
+
"Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
|
6635 |
+
"Ctrl-O": "openLine"
|
6636 |
+
}
|
6637 |
+
keyMap.macDefault = {
|
6638 |
+
"Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
|
6639 |
+
"Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
|
6640 |
+
"Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
|
6641 |
+
"Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
|
6642 |
+
"Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
|
6643 |
+
"Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
|
6644 |
+
"Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
|
6645 |
+
fallthrough: ["basic", "emacsy"]
|
6646 |
+
}
|
6647 |
+
keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault
|
6648 |
+
|
6649 |
+
// KEYMAP DISPATCH
|
6650 |
+
|
6651 |
+
function normalizeKeyName(name) {
|
6652 |
+
var parts = name.split(/-(?!$)/)
|
6653 |
+
name = parts[parts.length - 1]
|
6654 |
+
var alt, ctrl, shift, cmd
|
6655 |
+
for (var i = 0; i < parts.length - 1; i++) {
|
6656 |
+
var mod = parts[i]
|
6657 |
+
if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true }
|
6658 |
+
else if (/^a(lt)?$/i.test(mod)) { alt = true }
|
6659 |
+
else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true }
|
6660 |
+
else if (/^s(hift)?$/i.test(mod)) { shift = true }
|
6661 |
+
else { throw new Error("Unrecognized modifier name: " + mod) }
|
6662 |
+
}
|
6663 |
+
if (alt) { name = "Alt-" + name }
|
6664 |
+
if (ctrl) { name = "Ctrl-" + name }
|
6665 |
+
if (cmd) { name = "Cmd-" + name }
|
6666 |
+
if (shift) { name = "Shift-" + name }
|
6667 |
+
return name
|
6668 |
+
}
|
6669 |
+
|
6670 |
+
// This is a kludge to keep keymaps mostly working as raw objects
|
6671 |
+
// (backwards compatibility) while at the same time support features
|
6672 |
+
// like normalization and multi-stroke key bindings. It compiles a
|
6673 |
+
// new normalized keymap, and then updates the old object to reflect
|
6674 |
+
// this.
|
6675 |
+
function normalizeKeyMap(keymap) {
|
6676 |
+
var copy = {}
|
6677 |
+
for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
|
6678 |
+
var value = keymap[keyname]
|
6679 |
+
if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }
|
6680 |
+
if (value == "...") { delete keymap[keyname]; continue }
|
6681 |
+
|
6682 |
+
var keys = map(keyname.split(" "), normalizeKeyName)
|
6683 |
+
for (var i = 0; i < keys.length; i++) {
|
6684 |
+
var val = (void 0), name = (void 0)
|
6685 |
+
if (i == keys.length - 1) {
|
6686 |
+
name = keys.join(" ")
|
6687 |
+
val = value
|
6688 |
+
} else {
|
6689 |
+
name = keys.slice(0, i + 1).join(" ")
|
6690 |
+
val = "..."
|
6691 |
+
}
|
6692 |
+
var prev = copy[name]
|
6693 |
+
if (!prev) { copy[name] = val }
|
6694 |
+
else if (prev != val) { throw new Error("Inconsistent bindings for " + name) }
|
6695 |
+
}
|
6696 |
+
delete keymap[keyname]
|
6697 |
+
} }
|
6698 |
+
for (var prop in copy) { keymap[prop] = copy[prop] }
|
6699 |
+
return keymap
|
6700 |
+
}
|
6701 |
+
|
6702 |
+
function lookupKey(key, map, handle, context) {
|
6703 |
+
map = getKeyMap(map)
|
6704 |
+
var found = map.call ? map.call(key, context) : map[key]
|
6705 |
+
if (found === false) { return "nothing" }
|
6706 |
+
if (found === "...") { return "multi" }
|
6707 |
+
if (found != null && handle(found)) { return "handled" }
|
6708 |
+
|
6709 |
+
if (map.fallthrough) {
|
6710 |
+
if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
|
6711 |
+
{ return lookupKey(key, map.fallthrough, handle, context) }
|
6712 |
+
for (var i = 0; i < map.fallthrough.length; i++) {
|
6713 |
+
var result = lookupKey(key, map.fallthrough[i], handle, context)
|
6714 |
+
if (result) { return result }
|
6715 |
+
}
|
6716 |
+
}
|
6717 |
+
}
|
6718 |
+
|
6719 |
+
// Modifier key presses don't count as 'real' key presses for the
|
6720 |
+
// purpose of keymap fallthrough.
|
6721 |
+
function isModifierKey(value) {
|
6722 |
+
var name = typeof value == "string" ? value : keyNames[value.keyCode]
|
6723 |
+
return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"
|
6724 |
+
}
|
6725 |
+
|
6726 |
+
function addModifierNames(name, event, noShift) {
|
6727 |
+
var base = name
|
6728 |
+
if (event.altKey && base != "Alt") { name = "Alt-" + name }
|
6729 |
+
if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name }
|
6730 |
+
if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name }
|
6731 |
+
if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name }
|
6732 |
+
return name
|
6733 |
+
}
|
6734 |
+
|
6735 |
+
// Look up the name of a key as indicated by an event object.
|
6736 |
+
function keyName(event, noShift) {
|
6737 |
+
if (presto && event.keyCode == 34 && event["char"]) { return false }
|
6738 |
+
var name = keyNames[event.keyCode]
|
6739 |
+
if (name == null || event.altGraphKey) { return false }
|
6740 |
+
// Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,
|
6741 |
+
// so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)
|
6742 |
+
if (event.keyCode == 3 && event.code) { name = event.code }
|
6743 |
+
return addModifierNames(name, event, noShift)
|
6744 |
+
}
|
6745 |
+
|
6746 |
+
function getKeyMap(val) {
|
6747 |
+
return typeof val == "string" ? keyMap[val] : val
|
6748 |
+
}
|
6749 |
+
|
6750 |
+
// Helper for deleting text near the selection(s), used to implement
|
6751 |
+
// backspace, delete, and similar functionality.
|
6752 |
+
function deleteNearSelection(cm, compute) {
|
6753 |
+
var ranges = cm.doc.sel.ranges, kill = []
|
6754 |
+
// Build up a set of ranges to kill first, merging overlapping
|
6755 |
+
// ranges.
|
6756 |
+
for (var i = 0; i < ranges.length; i++) {
|
6757 |
+
var toKill = compute(ranges[i])
|
6758 |
+
while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
|
6759 |
+
var replaced = kill.pop()
|
6760 |
+
if (cmp(replaced.from, toKill.from) < 0) {
|
6761 |
+
toKill.from = replaced.from
|
6762 |
+
break
|
6763 |
+
}
|
6764 |
+
}
|
6765 |
+
kill.push(toKill)
|
6766 |
+
}
|
6767 |
+
// Next, remove those actual ranges.
|
6768 |
+
runInOp(cm, function () {
|
6769 |
+
for (var i = kill.length - 1; i >= 0; i--)
|
6770 |
+
{ replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete") }
|
6771 |
+
ensureCursorVisible(cm)
|
6772 |
+
})
|
6773 |
+
}
|
6774 |
+
|
6775 |
+
function moveCharLogically(line, ch, dir) {
|
6776 |
+
var target = skipExtendingChars(line.text, ch + dir, dir)
|
6777 |
+
return target < 0 || target > line.text.length ? null : target
|
6778 |
+
}
|
6779 |
+
|
6780 |
+
function moveLogically(line, start, dir) {
|
6781 |
+
var ch = moveCharLogically(line, start.ch, dir)
|
6782 |
+
return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
|
6783 |
+
}
|
6784 |
+
|
6785 |
+
function endOfLine(visually, cm, lineObj, lineNo, dir) {
|
6786 |
+
if (visually) {
|
6787 |
+
var order = getOrder(lineObj, cm.doc.direction)
|
6788 |
+
if (order) {
|
6789 |
+
var part = dir < 0 ? lst(order) : order[0]
|
6790 |
+
var moveInStorageOrder = (dir < 0) == (part.level == 1)
|
6791 |
+
var sticky = moveInStorageOrder ? "after" : "before"
|
6792 |
+
var ch
|
6793 |
+
// With a wrapped rtl chunk (possibly spanning multiple bidi parts),
|
6794 |
+
// it could be that the last bidi part is not on the last visual line,
|
6795 |
+
// since visual lines contain content order-consecutive chunks.
|
6796 |
+
// Thus, in rtl, we are looking for the first (content-order) character
|
6797 |
+
// in the rtl chunk that is on the last line (that is, the same line
|
6798 |
+
// as the last (content-order) character).
|
6799 |
+
if (part.level > 0 || cm.doc.direction == "rtl") {
|
6800 |
+
var prep = prepareMeasureForLine(cm, lineObj)
|
6801 |
+
ch = dir < 0 ? lineObj.text.length - 1 : 0
|
6802 |
+
var targetTop = measureCharPrepared(cm, prep, ch).top
|
6803 |
+
ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch)
|
6804 |
+
if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1) }
|
6805 |
+
} else { ch = dir < 0 ? part.to : part.from }
|
6806 |
+
return new Pos(lineNo, ch, sticky)
|
6807 |
+
}
|
6808 |
+
}
|
6809 |
+
return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
|
6810 |
+
}
|
6811 |
+
|
6812 |
+
function moveVisually(cm, line, start, dir) {
|
6813 |
+
var bidi = getOrder(line, cm.doc.direction)
|
6814 |
+
if (!bidi) { return moveLogically(line, start, dir) }
|
6815 |
+
if (start.ch >= line.text.length) {
|
6816 |
+
start.ch = line.text.length
|
6817 |
+
start.sticky = "before"
|
6818 |
+
} else if (start.ch <= 0) {
|
6819 |
+
start.ch = 0
|
6820 |
+
start.sticky = "after"
|
6821 |
+
}
|
6822 |
+
var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]
|
6823 |
+
if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
|
6824 |
+
// Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,
|
6825 |
+
// nothing interesting happens.
|
6826 |
+
return moveLogically(line, start, dir)
|
6827 |
+
}
|
6828 |
+
|
6829 |
+
var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); }
|
6830 |
+
var prep
|
6831 |
+
var getWrappedLineExtent = function (ch) {
|
6832 |
+
if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
|
6833 |
+
prep = prep || prepareMeasureForLine(cm, line)
|
6834 |
+
return wrappedLineExtentChar(cm, line, prep, ch)
|
6835 |
+
}
|
6836 |
+
var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch)
|
6837 |
+
|
6838 |
+
if (cm.doc.direction == "rtl" || part.level == 1) {
|
6839 |
+
var moveInStorageOrder = (part.level == 1) == (dir < 0)
|
6840 |
+
var ch = mv(start, moveInStorageOrder ? 1 : -1)
|
6841 |
+
if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
|
6842 |
+
// Case 2: We move within an rtl part or in an rtl editor on the same visual line
|
6843 |
+
var sticky = moveInStorageOrder ? "before" : "after"
|
6844 |
+
return new Pos(start.line, ch, sticky)
|
6845 |
+
}
|
6846 |
+
}
|
6847 |
+
|
6848 |
+
// Case 3: Could not move within this bidi part in this visual line, so leave
|
6849 |
+
// the current bidi part
|
6850 |
+
|
6851 |
+
var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
|
6852 |
+
var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
|
6853 |
+
? new Pos(start.line, mv(ch, 1), "before")
|
6854 |
+
: new Pos(start.line, ch, "after"); }
|
6855 |
+
|
6856 |
+
for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
|
6857 |
+
var part = bidi[partPos]
|
6858 |
+
var moveInStorageOrder = (dir > 0) == (part.level != 1)
|
6859 |
+
var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1)
|
6860 |
+
if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
|
6861 |
+
ch = moveInStorageOrder ? part.from : mv(part.to, -1)
|
6862 |
+
if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
|
6863 |
+
}
|
6864 |
+
}
|
6865 |
+
|
6866 |
+
// Case 3a: Look for other bidi parts on the same visual line
|
6867 |
+
var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent)
|
6868 |
+
if (res) { return res }
|
6869 |
+
|
6870 |
+
// Case 3b: Look for other bidi parts on the next visual line
|
6871 |
+
var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1)
|
6872 |
+
if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
|
6873 |
+
res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh))
|
6874 |
+
if (res) { return res }
|
6875 |
+
}
|
6876 |
+
|
6877 |
+
// Case 4: Nowhere to move
|
6878 |
+
return null
|
6879 |
+
}
|
6880 |
+
|
6881 |
+
// Commands are parameter-less actions that can be performed on an
|
6882 |
+
// editor, mostly used for keybindings.
|
6883 |
+
var commands = {
|
6884 |
+
selectAll: selectAll,
|
6885 |
+
singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); },
|
6886 |
+
killLine: function (cm) { return deleteNearSelection(cm, function (range) {
|
6887 |
+
if (range.empty()) {
|
6888 |
+
var len = getLine(cm.doc, range.head.line).text.length
|
6889 |
+
if (range.head.ch == len && range.head.line < cm.lastLine())
|
6890 |
+
{ return {from: range.head, to: Pos(range.head.line + 1, 0)} }
|
6891 |
+
else
|
6892 |
+
{ return {from: range.head, to: Pos(range.head.line, len)} }
|
6893 |
+
} else {
|
6894 |
+
return {from: range.from(), to: range.to()}
|
6895 |
+
}
|
6896 |
+
}); },
|
6897 |
+
deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({
|
6898 |
+
from: Pos(range.from().line, 0),
|
6899 |
+
to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
|
6900 |
+
}); }); },
|
6901 |
+
delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({
|
6902 |
+
from: Pos(range.from().line, 0), to: range.from()
|
6903 |
+
}); }); },
|
6904 |
+
delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {
|
6905 |
+
var top = cm.charCoords(range.head, "div").top + 5
|
6906 |
+
var leftPos = cm.coordsChar({left: 0, top: top}, "div")
|
6907 |
+
return {from: leftPos, to: range.from()}
|
6908 |
+
}); },
|
6909 |
+
delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {
|
6910 |
+
var top = cm.charCoords(range.head, "div").top + 5
|
6911 |
+
var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
|
6912 |
+
return {from: range.from(), to: rightPos }
|
6913 |
+
}); },
|
6914 |
+
undo: function (cm) { return cm.undo(); },
|
6915 |
+
redo: function (cm) { return cm.redo(); },
|
6916 |
+
undoSelection: function (cm) { return cm.undoSelection(); },
|
6917 |
+
redoSelection: function (cm) { return cm.redoSelection(); },
|
6918 |
+
goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },
|
6919 |
+
goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },
|
6920 |
+
goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },
|
6921 |
+
{origin: "+move", bias: 1}
|
6922 |
+
); },
|
6923 |
+
goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },
|
6924 |
+
{origin: "+move", bias: 1}
|
6925 |
+
); },
|
6926 |
+
goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },
|
6927 |
+
{origin: "+move", bias: -1}
|
6928 |
+
); },
|
6929 |
+
goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {
|
6930 |
+
var top = cm.cursorCoords(range.head, "div").top + 5
|
6931 |
+
return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
|
6932 |
+
}, sel_move); },
|
6933 |
+
goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {
|
6934 |
+
var top = cm.cursorCoords(range.head, "div").top + 5
|
6935 |
+
return cm.coordsChar({left: 0, top: top}, "div")
|
6936 |
+
}, sel_move); },
|
6937 |
+
goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {
|
6938 |
+
var top = cm.cursorCoords(range.head, "div").top + 5
|
6939 |
+
var pos = cm.coordsChar({left: 0, top: top}, "div")
|
6940 |
+
if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) }
|
6941 |
+
return pos
|
6942 |
+
}, sel_move); },
|
6943 |
+
goLineUp: function (cm) { return cm.moveV(-1, "line"); },
|
6944 |
+
goLineDown: function (cm) { return cm.moveV(1, "line"); },
|
6945 |
+
goPageUp: function (cm) { return cm.moveV(-1, "page"); },
|
6946 |
+
goPageDown: function (cm) { return cm.moveV(1, "page"); },
|
6947 |
+
goCharLeft: function (cm) { return cm.moveH(-1, "char"); },
|
6948 |
+
goCharRight: function (cm) { return cm.moveH(1, "char"); },
|
6949 |
+
goColumnLeft: function (cm) { return cm.moveH(-1, "column"); },
|
6950 |
+
goColumnRight: function (cm) { return cm.moveH(1, "column"); },
|
6951 |
+
goWordLeft: function (cm) { return cm.moveH(-1, "word"); },
|
6952 |
+
goGroupRight: function (cm) { return cm.moveH(1, "group"); },
|
6953 |
+
goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
|
6954 |
+
goWordRight: function (cm) { return cm.moveH(1, "word"); },
|
6955 |
+
delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
|
6956 |
+
delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
|
6957 |
+
delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
|
6958 |
+
delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
|
6959 |
+
delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); },
|
6960 |
+
delGroupAfter: function (cm) { return cm.deleteH(1, "group"); },
|
6961 |
+
indentAuto: function (cm) { return cm.indentSelection("smart"); },
|
6962 |
+
indentMore: function (cm) { return cm.indentSelection("add"); },
|
6963 |
+
indentLess: function (cm) { return cm.indentSelection("subtract"); },
|
6964 |
+
insertTab: function (cm) { return cm.replaceSelection("\t"); },
|
6965 |
+
insertSoftTab: function (cm) {
|
6966 |
+
var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize
|
6967 |
+
for (var i = 0; i < ranges.length; i++) {
|
6968 |
+
var pos = ranges[i].from()
|
6969 |
+
var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize)
|
6970 |
+
spaces.push(spaceStr(tabSize - col % tabSize))
|
6971 |
+
}
|
6972 |
+
cm.replaceSelections(spaces)
|
6973 |
+
},
|
6974 |
+
defaultTab: function (cm) {
|
6975 |
+
if (cm.somethingSelected()) { cm.indentSelection("add") }
|
6976 |
+
else { cm.execCommand("insertTab") }
|
6977 |
+
},
|
6978 |
+
// Swap the two chars left and right of each selection's head.
|
6979 |
+
// Move cursor behind the two swapped characters afterwards.
|
6980 |
+
//
|
6981 |
+
// Doesn't consider line feeds a character.
|
6982 |
+
// Doesn't scan more than one line above to find a character.
|
6983 |
+
// Doesn't do anything on an empty line.
|
6984 |
+
// Doesn't do anything with non-empty selections.
|
6985 |
+
transposeChars: function (cm) { return runInOp(cm, function () {
|
6986 |
+
var ranges = cm.listSelections(), newSel = []
|
6987 |
+
for (var i = 0; i < ranges.length; i++) {
|
6988 |
+
if (!ranges[i].empty()) { continue }
|
6989 |
+
var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text
|
6990 |
+
if (line) {
|
6991 |
+
if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1) }
|
6992 |
+
if (cur.ch > 0) {
|
6993 |
+
cur = new Pos(cur.line, cur.ch + 1)
|
6994 |
+
cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
|
6995 |
+
Pos(cur.line, cur.ch - 2), cur, "+transpose")
|
6996 |
+
} else if (cur.line > cm.doc.first) {
|
6997 |
+
var prev = getLine(cm.doc, cur.line - 1).text
|
6998 |
+
if (prev) {
|
6999 |
+
cur = new Pos(cur.line, 1)
|
7000 |
+
cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
|
7001 |
+
prev.charAt(prev.length - 1),
|
7002 |
+
Pos(cur.line - 1, prev.length - 1), cur, "+transpose")
|
7003 |
+
}
|
7004 |
+
}
|
7005 |
+
}
|
7006 |
+
newSel.push(new Range(cur, cur))
|
7007 |
+
}
|
7008 |
+
cm.setSelections(newSel)
|
7009 |
+
}); },
|
7010 |
+
newlineAndIndent: function (cm) { return runInOp(cm, function () {
|
7011 |
+
var sels = cm.listSelections()
|
7012 |
+
for (var i = sels.length - 1; i >= 0; i--)
|
7013 |
+
{ cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input") }
|
7014 |
+
sels = cm.listSelections()
|
7015 |
+
for (var i$1 = 0; i$1 < sels.length; i$1++)
|
7016 |
+
{ cm.indentLine(sels[i$1].from().line, null, true) }
|
7017 |
+
ensureCursorVisible(cm)
|
7018 |
+
}); },
|
7019 |
+
openLine: function (cm) { return cm.replaceSelection("\n", "start"); },
|
7020 |
+
toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }
|
7021 |
+
}
|
7022 |
+
|
7023 |
+
|
7024 |
+
function lineStart(cm, lineN) {
|
7025 |
+
var line = getLine(cm.doc, lineN)
|
7026 |
+
var visual = visualLine(line)
|
7027 |
+
if (visual != line) { lineN = lineNo(visual) }
|
7028 |
+
return endOfLine(true, cm, visual, lineN, 1)
|
7029 |
+
}
|
7030 |
+
function lineEnd(cm, lineN) {
|
7031 |
+
var line = getLine(cm.doc, lineN)
|
7032 |
+
var visual = visualLineEnd(line)
|
7033 |
+
if (visual != line) { lineN = lineNo(visual) }
|
7034 |
+
return endOfLine(true, cm, line, lineN, -1)
|
7035 |
+
}
|
7036 |
+
function lineStartSmart(cm, pos) {
|
7037 |
+
var start = lineStart(cm, pos.line)
|
7038 |
+
var line = getLine(cm.doc, start.line)
|
7039 |
+
var order = getOrder(line, cm.doc.direction)
|
7040 |
+
if (!order || order[0].level == 0) {
|
7041 |
+
var firstNonWS = Math.max(0, line.text.search(/\S/))
|
7042 |
+
var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
|
7043 |
+
return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
|
7044 |
+
}
|
7045 |
+
return start
|
7046 |
+
}
|
7047 |
+
|
7048 |
+
// Run a handler that was bound to a key.
|
7049 |
+
function doHandleBinding(cm, bound, dropShift) {
|
7050 |
+
if (typeof bound == "string") {
|
7051 |
+
bound = commands[bound]
|
7052 |
+
if (!bound) { return false }
|
7053 |
+
}
|
7054 |
+
// Ensure previous input has been read, so that the handler sees a
|
7055 |
+
// consistent view of the document
|
7056 |
+
cm.display.input.ensurePolled()
|
7057 |
+
var prevShift = cm.display.shift, done = false
|
7058 |
+
try {
|
7059 |
+
if (cm.isReadOnly()) { cm.state.suppressEdits = true }
|
7060 |
+
if (dropShift) { cm.display.shift = false }
|
7061 |
+
done = bound(cm) != Pass
|
7062 |
+
} finally {
|
7063 |
+
cm.display.shift = prevShift
|
7064 |
+
cm.state.suppressEdits = false
|
7065 |
+
}
|
7066 |
+
return done
|
7067 |
+
}
|
7068 |
+
|
7069 |
+
function lookupKeyForEditor(cm, name, handle) {
|
7070 |
+
for (var i = 0; i < cm.state.keyMaps.length; i++) {
|
7071 |
+
var result = lookupKey(name, cm.state.keyMaps[i], handle, cm)
|
7072 |
+
if (result) { return result }
|
7073 |
+
}
|
7074 |
+
return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
|
7075 |
+
|| lookupKey(name, cm.options.keyMap, handle, cm)
|
7076 |
+
}
|
7077 |
+
|
7078 |
+
// Note that, despite the name, this function is also used to check
|
7079 |
+
// for bound mouse clicks.
|
7080 |
+
|
7081 |
+
var stopSeq = new Delayed
|
7082 |
+
|
7083 |
+
function dispatchKey(cm, name, e, handle) {
|
7084 |
+
var seq = cm.state.keySeq
|
7085 |
+
if (seq) {
|
7086 |
+
if (isModifierKey(name)) { return "handled" }
|
7087 |
+
if (/\'$/.test(name))
|
7088 |
+
{ cm.state.keySeq = null }
|
7089 |
+
else
|
7090 |
+
{ stopSeq.set(50, function () {
|
7091 |
+
if (cm.state.keySeq == seq) {
|
7092 |
+
cm.state.keySeq = null
|
7093 |
+
cm.display.input.reset()
|
7094 |
+
}
|
7095 |
+
}) }
|
7096 |
+
if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true }
|
7097 |
+
}
|
7098 |
+
return dispatchKeyInner(cm, name, e, handle)
|
7099 |
+
}
|
7100 |
+
|
7101 |
+
function dispatchKeyInner(cm, name, e, handle) {
|
7102 |
+
var result = lookupKeyForEditor(cm, name, handle)
|
7103 |
+
|
7104 |
+
if (result == "multi")
|
7105 |
+
{ cm.state.keySeq = name }
|
7106 |
+
if (result == "handled")
|
7107 |
+
{ signalLater(cm, "keyHandled", cm, name, e) }
|
7108 |
+
|
7109 |
+
if (result == "handled" || result == "multi") {
|
7110 |
+
e_preventDefault(e)
|
7111 |
+
restartBlink(cm)
|
7112 |
+
}
|
7113 |
+
|
7114 |
+
return !!result
|
7115 |
+
}
|
7116 |
+
|
7117 |
+
// Handle a key from the keydown event.
|
7118 |
+
function handleKeyBinding(cm, e) {
|
7119 |
+
var name = keyName(e, true)
|
7120 |
+
if (!name) { return false }
|
7121 |
+
|
7122 |
+
if (e.shiftKey && !cm.state.keySeq) {
|
7123 |
+
// First try to resolve full name (including 'Shift-'). Failing
|
7124 |
+
// that, see if there is a cursor-motion command (starting with
|
7125 |
+
// 'go') bound to the keyname without 'Shift-'.
|
7126 |
+
return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); })
|
7127 |
+
|| dispatchKey(cm, name, e, function (b) {
|
7128 |
+
if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
|
7129 |
+
{ return doHandleBinding(cm, b) }
|
7130 |
+
})
|
7131 |
+
} else {
|
7132 |
+
return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })
|
7133 |
+
}
|
7134 |
+
}
|
7135 |
+
|
7136 |
+
// Handle a key from the keypress event
|
7137 |
+
function handleCharBinding(cm, e, ch) {
|
7138 |
+
return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); })
|
7139 |
+
}
|
7140 |
+
|
7141 |
+
var lastStoppedKey = null
|
7142 |
+
function onKeyDown(e) {
|
7143 |
+
var cm = this
|
7144 |
+
cm.curOp.focus = activeElt()
|
7145 |
+
if (signalDOMEvent(cm, e)) { return }
|
7146 |
+
// IE does strange things with escape.
|
7147 |
+
if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false }
|
7148 |
+
var code = e.keyCode
|
7149 |
+
cm.display.shift = code == 16 || e.shiftKey
|
7150 |
+
var handled = handleKeyBinding(cm, e)
|
7151 |
+
if (presto) {
|
7152 |
+
lastStoppedKey = handled ? code : null
|
7153 |
+
// Opera has no cut event... we try to at least catch the key combo
|
7154 |
+
if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
|
7155 |
+
{ cm.replaceSelection("", null, "cut") }
|
7156 |
+
}
|
7157 |
+
|
7158 |
+
// Turn mouse into crosshair when Alt is held on Mac.
|
7159 |
+
if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
|
7160 |
+
{ showCrossHair(cm) }
|
7161 |
+
}
|
7162 |
+
|
7163 |
+
function showCrossHair(cm) {
|
7164 |
+
var lineDiv = cm.display.lineDiv
|
7165 |
+
addClass(lineDiv, "CodeMirror-crosshair")
|
7166 |
+
|
7167 |
+
function up(e) {
|
7168 |
+
if (e.keyCode == 18 || !e.altKey) {
|
7169 |
+
rmClass(lineDiv, "CodeMirror-crosshair")
|
7170 |
+
off(document, "keyup", up)
|
7171 |
+
off(document, "mouseover", up)
|
7172 |
+
}
|
7173 |
+
}
|
7174 |
+
on(document, "keyup", up)
|
7175 |
+
on(document, "mouseover", up)
|
7176 |
+
}
|
7177 |
+
|
7178 |
+
function onKeyUp(e) {
|
7179 |
+
if (e.keyCode == 16) { this.doc.sel.shift = false }
|
7180 |
+
signalDOMEvent(this, e)
|
7181 |
+
}
|
7182 |
+
|
7183 |
+
function onKeyPress(e) {
|
7184 |
+
var cm = this
|
7185 |
+
if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
|
7186 |
+
var keyCode = e.keyCode, charCode = e.charCode
|
7187 |
+
if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
|
7188 |
+
if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }
|
7189 |
+
var ch = String.fromCharCode(charCode == null ? keyCode : charCode)
|
7190 |
+
// Some browsers fire keypress events for backspace
|
7191 |
+
if (ch == "\x08") { return }
|
7192 |
+
if (handleCharBinding(cm, e, ch)) { return }
|
7193 |
+
cm.display.input.onKeyPress(e)
|
7194 |
+
}
|
7195 |
+
|
7196 |
+
var DOUBLECLICK_DELAY = 400
|
7197 |
+
|
7198 |
+
var PastClick = function(time, pos, button) {
|
7199 |
+
this.time = time
|
7200 |
+
this.pos = pos
|
7201 |
+
this.button = button
|
7202 |
+
};
|
7203 |
+
|
7204 |
+
PastClick.prototype.compare = function (time, pos, button) {
|
7205 |
+
return this.time + DOUBLECLICK_DELAY > time &&
|
7206 |
+
cmp(pos, this.pos) == 0 && button == this.button
|
7207 |
+
};
|
7208 |
+
|
7209 |
+
var lastClick;
|
7210 |
+
var lastDoubleClick;
|
7211 |
+
function clickRepeat(pos, button) {
|
7212 |
+
var now = +new Date
|
7213 |
+
if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
|
7214 |
+
lastClick = lastDoubleClick = null
|
7215 |
+
return "triple"
|
7216 |
+
} else if (lastClick && lastClick.compare(now, pos, button)) {
|
7217 |
+
lastDoubleClick = new PastClick(now, pos, button)
|
7218 |
+
lastClick = null
|
7219 |
+
return "double"
|
7220 |
+
} else {
|
7221 |
+
lastClick = new PastClick(now, pos, button)
|
7222 |
+
lastDoubleClick = null
|
7223 |
+
return "single"
|
7224 |
+
}
|
7225 |
+
}
|
7226 |
+
|
7227 |
+
// A mouse down can be a single click, double click, triple click,
|
7228 |
+
// start of selection drag, start of text drag, new cursor
|
7229 |
+
// (ctrl-click), rectangle drag (alt-drag), or xwin
|
7230 |
+
// middle-click-paste. Or it might be a click on something we should
|
7231 |
+
// not interfere with, such as a scrollbar or widget.
|
7232 |
+
function onMouseDown(e) {
|
7233 |
+
var cm = this, display = cm.display
|
7234 |
+
if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
|
7235 |
+
display.input.ensurePolled()
|
7236 |
+
display.shift = e.shiftKey
|
7237 |
+
|
7238 |
+
if (eventInWidget(display, e)) {
|
7239 |
+
if (!webkit) {
|
7240 |
+
// Briefly turn off draggability, to allow widgets to do
|
7241 |
+
// normal dragging things.
|
7242 |
+
display.scroller.draggable = false
|
7243 |
+
setTimeout(function () { return display.scroller.draggable = true; }, 100)
|
7244 |
+
}
|
7245 |
+
return
|
7246 |
+
}
|
7247 |
+
if (clickInGutter(cm, e)) { return }
|
7248 |
+
var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single"
|
7249 |
+
window.focus()
|
7250 |
+
|
7251 |
+
// #3261: make sure, that we're not starting a second selection
|
7252 |
+
if (button == 1 && cm.state.selectingText)
|
7253 |
+
{ cm.state.selectingText(e) }
|
7254 |
+
|
7255 |
+
if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return }
|
7256 |
+
|
7257 |
+
if (button == 1) {
|
7258 |
+
if (pos) { leftButtonDown(cm, pos, repeat, e) }
|
7259 |
+
else if (e_target(e) == display.scroller) { e_preventDefault(e) }
|
7260 |
+
} else if (button == 2) {
|
7261 |
+
if (pos) { extendSelection(cm.doc, pos) }
|
7262 |
+
setTimeout(function () { return display.input.focus(); }, 20)
|
7263 |
+
} else if (button == 3) {
|
7264 |
+
if (captureRightClick) { onContextMenu(cm, e) }
|
7265 |
+
else { delayBlurEvent(cm) }
|
7266 |
+
}
|
7267 |
+
}
|
7268 |
+
|
7269 |
+
function handleMappedButton(cm, button, pos, repeat, event) {
|
7270 |
+
var name = "Click"
|
7271 |
+
if (repeat == "double") { name = "Double" + name }
|
7272 |
+
else if (repeat == "triple") { name = "Triple" + name }
|
7273 |
+
name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name
|
7274 |
+
|
7275 |
+
return dispatchKey(cm, addModifierNames(name, event), event, function (bound) {
|
7276 |
+
if (typeof bound == "string") { bound = commands[bound] }
|
7277 |
+
if (!bound) { return false }
|
7278 |
+
var done = false
|
7279 |
+
try {
|
7280 |
+
if (cm.isReadOnly()) { cm.state.suppressEdits = true }
|
7281 |
+
done = bound(cm, pos) != Pass
|
7282 |
+
} finally {
|
7283 |
+
cm.state.suppressEdits = false
|
7284 |
+
}
|
7285 |
+
return done
|
7286 |
+
})
|
7287 |
+
}
|
7288 |
+
|
7289 |
+
function configureMouse(cm, repeat, event) {
|
7290 |
+
var option = cm.getOption("configureMouse")
|
7291 |
+
var value = option ? option(cm, repeat, event) : {}
|
7292 |
+
if (value.unit == null) {
|
7293 |
+
var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey
|
7294 |
+
value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line"
|
7295 |
+
}
|
7296 |
+
if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey }
|
7297 |
+
if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey }
|
7298 |
+
if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey) }
|
7299 |
+
return value
|
7300 |
+
}
|
7301 |
+
|
7302 |
+
function leftButtonDown(cm, pos, repeat, event) {
|
7303 |
+
if (ie) { setTimeout(bind(ensureFocus, cm), 0) }
|
7304 |
+
else { cm.curOp.focus = activeElt() }
|
7305 |
+
|
7306 |
+
var behavior = configureMouse(cm, repeat, event)
|
7307 |
+
|
7308 |
+
var sel = cm.doc.sel, contained
|
7309 |
+
if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
|
7310 |
+
repeat == "single" && (contained = sel.contains(pos)) > -1 &&
|
7311 |
+
(cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) &&
|
7312 |
+
(cmp(contained.to(), pos) > 0 || pos.xRel < 0))
|
7313 |
+
{ leftButtonStartDrag(cm, event, pos, behavior) }
|
7314 |
+
else
|
7315 |
+
{ leftButtonSelect(cm, event, pos, behavior) }
|
7316 |
+
}
|
7317 |
+
|
7318 |
+
// Start a text drag. When it ends, see if any dragging actually
|
7319 |
+
// happen, and treat as a click if it didn't.
|
7320 |
+
function leftButtonStartDrag(cm, event, pos, behavior) {
|
7321 |
+
var display = cm.display, moved = false
|
7322 |
+
var dragEnd = operation(cm, function (e) {
|
7323 |
+
if (webkit) { display.scroller.draggable = false }
|
7324 |
+
cm.state.draggingText = false
|
7325 |
+
off(display.wrapper.ownerDocument, "mouseup", dragEnd)
|
7326 |
+
off(display.wrapper.ownerDocument, "mousemove", mouseMove)
|
7327 |
+
off(display.scroller, "dragstart", dragStart)
|
7328 |
+
off(display.scroller, "drop", dragEnd)
|
7329 |
+
if (!moved) {
|
7330 |
+
e_preventDefault(e)
|
7331 |
+
if (!behavior.addNew)
|
7332 |
+
{ extendSelection(cm.doc, pos, null, null, behavior.extend) }
|
7333 |
+
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
|
7334 |
+
if (webkit || ie && ie_version == 9)
|
7335 |
+
{ setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus()}, 20) }
|
7336 |
+
else
|
7337 |
+
{ display.input.focus() }
|
7338 |
+
}
|
7339 |
+
})
|
7340 |
+
var mouseMove = function(e2) {
|
7341 |
+
moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10
|
7342 |
+
}
|
7343 |
+
var dragStart = function () { return moved = true; }
|
7344 |
+
// Let the drag handler handle this.
|
7345 |
+
if (webkit) { display.scroller.draggable = true }
|
7346 |
+
cm.state.draggingText = dragEnd
|
7347 |
+
dragEnd.copy = !behavior.moveOnDrag
|
7348 |
+
// IE's approach to draggable
|
7349 |
+
if (display.scroller.dragDrop) { display.scroller.dragDrop() }
|
7350 |
+
on(display.wrapper.ownerDocument, "mouseup", dragEnd)
|
7351 |
+
on(display.wrapper.ownerDocument, "mousemove", mouseMove)
|
7352 |
+
on(display.scroller, "dragstart", dragStart)
|
7353 |
+
on(display.scroller, "drop", dragEnd)
|
7354 |
+
|
7355 |
+
delayBlurEvent(cm)
|
7356 |
+
setTimeout(function () { return display.input.focus(); }, 20)
|
7357 |
+
}
|
7358 |
+
|
7359 |
+
function rangeForUnit(cm, pos, unit) {
|
7360 |
+
if (unit == "char") { return new Range(pos, pos) }
|
7361 |
+
if (unit == "word") { return cm.findWordAt(pos) }
|
7362 |
+
if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
|
7363 |
+
var result = unit(cm, pos)
|
7364 |
+
return new Range(result.from, result.to)
|
7365 |
+
}
|
7366 |
+
|
7367 |
+
// Normal selection, as opposed to text dragging.
|
7368 |
+
function leftButtonSelect(cm, event, start, behavior) {
|
7369 |
+
var display = cm.display, doc = cm.doc
|
7370 |
+
e_preventDefault(event)
|
7371 |
+
|
7372 |
+
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges
|
7373 |
+
if (behavior.addNew && !behavior.extend) {
|
7374 |
+
ourIndex = doc.sel.contains(start)
|
7375 |
+
if (ourIndex > -1)
|
7376 |
+
{ ourRange = ranges[ourIndex] }
|
7377 |
+
else
|
7378 |
+
{ ourRange = new Range(start, start) }
|
7379 |
+
} else {
|
7380 |
+
ourRange = doc.sel.primary()
|
7381 |
+
ourIndex = doc.sel.primIndex
|
7382 |
+
}
|
7383 |
+
|
7384 |
+
if (behavior.unit == "rectangle") {
|
7385 |
+
if (!behavior.addNew) { ourRange = new Range(start, start) }
|
7386 |
+
start = posFromMouse(cm, event, true, true)
|
7387 |
+
ourIndex = -1
|
7388 |
+
} else {
|
7389 |
+
var range = rangeForUnit(cm, start, behavior.unit)
|
7390 |
+
if (behavior.extend)
|
7391 |
+
{ ourRange = extendRange(ourRange, range.anchor, range.head, behavior.extend) }
|
7392 |
+
else
|
7393 |
+
{ ourRange = range }
|
7394 |
+
}
|
7395 |
+
|
7396 |
+
if (!behavior.addNew) {
|
7397 |
+
ourIndex = 0
|
7398 |
+
setSelection(doc, new Selection([ourRange], 0), sel_mouse)
|
7399 |
+
startSel = doc.sel
|
7400 |
+
} else if (ourIndex == -1) {
|
7401 |
+
ourIndex = ranges.length
|
7402 |
+
setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
|
7403 |
+
{scroll: false, origin: "*mouse"})
|
7404 |
+
} else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
|
7405 |
+
setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
7406 |
+
{scroll: false, origin: "*mouse"})
|
7407 |
+
startSel = doc.sel
|
7408 |
+
} else {
|
7409 |
+
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse)
|
7410 |
+
}
|
7411 |
+
|
7412 |
+
var lastPos = start
|
7413 |
+
function extendTo(pos) {
|
7414 |
+
if (cmp(lastPos, pos) == 0) { return }
|
7415 |
+
lastPos = pos
|
7416 |
+
|
7417 |
+
if (behavior.unit == "rectangle") {
|
7418 |
+
var ranges = [], tabSize = cm.options.tabSize
|
7419 |
+
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize)
|
7420 |
+
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize)
|
7421 |
+
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol)
|
7422 |
+
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
7423 |
+
line <= end; line++) {
|
7424 |
+
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize)
|
7425 |
+
if (left == right)
|
7426 |
+
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))) }
|
7427 |
+
else if (text.length > leftPos)
|
7428 |
+
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))) }
|
7429 |
+
}
|
7430 |
+
if (!ranges.length) { ranges.push(new Range(start, start)) }
|
7431 |
+
setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
7432 |
+
{origin: "*mouse", scroll: false})
|
7433 |
+
cm.scrollIntoView(pos)
|
7434 |
+
} else {
|
7435 |
+
var oldRange = ourRange
|
7436 |
+
var range = rangeForUnit(cm, pos, behavior.unit)
|
7437 |
+
var anchor = oldRange.anchor, head
|
7438 |
+
if (cmp(range.anchor, anchor) > 0) {
|
7439 |
+
head = range.head
|
7440 |
+
anchor = minPos(oldRange.from(), range.anchor)
|
7441 |
+
} else {
|
7442 |
+
head = range.anchor
|
7443 |
+
anchor = maxPos(oldRange.to(), range.head)
|
7444 |
+
}
|
7445 |
+
var ranges$1 = startSel.ranges.slice(0)
|
7446 |
+
ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head))
|
7447 |
+
setSelection(doc, normalizeSelection(ranges$1, ourIndex), sel_mouse)
|
7448 |
+
}
|
7449 |
+
}
|
7450 |
+
|
7451 |
+
var editorSize = display.wrapper.getBoundingClientRect()
|
7452 |
+
// Used to ensure timeout re-tries don't fire when another extend
|
7453 |
+
// happened in the meantime (clearTimeout isn't reliable -- at
|
7454 |
+
// least on Chrome, the timeouts still happen even when cleared,
|
7455 |
+
// if the clear happens after their scheduled firing time).
|
7456 |
+
var counter = 0
|
7457 |
+
|
7458 |
+
function extend(e) {
|
7459 |
+
var curCount = ++counter
|
7460 |
+
var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle")
|
7461 |
+
if (!cur) { return }
|
7462 |
+
if (cmp(cur, lastPos) != 0) {
|
7463 |
+
cm.curOp.focus = activeElt()
|
7464 |
+
extendTo(cur)
|
7465 |
+
var visible = visibleLines(display, doc)
|
7466 |
+
if (cur.line >= visible.to || cur.line < visible.from)
|
7467 |
+
{ setTimeout(operation(cm, function () {if (counter == curCount) { extend(e) }}), 150) }
|
7468 |
+
} else {
|
7469 |
+
var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0
|
7470 |
+
if (outside) { setTimeout(operation(cm, function () {
|
7471 |
+
if (counter != curCount) { return }
|
7472 |
+
display.scroller.scrollTop += outside
|
7473 |
+
extend(e)
|
7474 |
+
}), 50) }
|
7475 |
+
}
|
7476 |
+
}
|
7477 |
+
|
7478 |
+
function done(e) {
|
7479 |
+
cm.state.selectingText = false
|
7480 |
+
counter = Infinity
|
7481 |
+
e_preventDefault(e)
|
7482 |
+
display.input.focus()
|
7483 |
+
off(display.wrapper.ownerDocument, "mousemove", move)
|
7484 |
+
off(display.wrapper.ownerDocument, "mouseup", up)
|
7485 |
+
doc.history.lastSelOrigin = null
|
7486 |
+
}
|
7487 |
+
|
7488 |
+
var move = operation(cm, function (e) {
|
7489 |
+
if (e.buttons === 0 || !e_button(e)) { done(e) }
|
7490 |
+
else { extend(e) }
|
7491 |
+
})
|
7492 |
+
var up = operation(cm, done)
|
7493 |
+
cm.state.selectingText = up
|
7494 |
+
on(display.wrapper.ownerDocument, "mousemove", move)
|
7495 |
+
on(display.wrapper.ownerDocument, "mouseup", up)
|
7496 |
+
}
|
7497 |
+
|
7498 |
+
// Used when mouse-selecting to adjust the anchor to the proper side
|
7499 |
+
// of a bidi jump depending on the visual position of the head.
|
7500 |
+
function bidiSimplify(cm, range) {
|
7501 |
+
var anchor = range.anchor;
|
7502 |
+
var head = range.head;
|
7503 |
+
var anchorLine = getLine(cm.doc, anchor.line)
|
7504 |
+
if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range }
|
7505 |
+
var order = getOrder(anchorLine)
|
7506 |
+
if (!order) { return range }
|
7507 |
+
var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index]
|
7508 |
+
if (part.from != anchor.ch && part.to != anchor.ch) { return range }
|
7509 |
+
var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1)
|
7510 |
+
if (boundary == 0 || boundary == order.length) { return range }
|
7511 |
+
|
7512 |
+
// Compute the relative visual position of the head compared to the
|
7513 |
+
// anchor (<0 is to the left, >0 to the right)
|
7514 |
+
var leftSide
|
7515 |
+
if (head.line != anchor.line) {
|
7516 |
+
leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0
|
7517 |
+
} else {
|
7518 |
+
var headIndex = getBidiPartAt(order, head.ch, head.sticky)
|
7519 |
+
var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1)
|
7520 |
+
if (headIndex == boundary - 1 || headIndex == boundary)
|
7521 |
+
{ leftSide = dir < 0 }
|
7522 |
+
else
|
7523 |
+
{ leftSide = dir > 0 }
|
7524 |
+
}
|
7525 |
+
|
7526 |
+
var usePart = order[boundary + (leftSide ? -1 : 0)]
|
7527 |
+
var from = leftSide == (usePart.level == 1)
|
7528 |
+
var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before"
|
7529 |
+
return anchor.ch == ch && anchor.sticky == sticky ? range : new Range(new Pos(anchor.line, ch, sticky), head)
|
7530 |
+
}
|
7531 |
+
|
7532 |
+
|
7533 |
+
// Determines whether an event happened in the gutter, and fires the
|
7534 |
+
// handlers for the corresponding event.
|
7535 |
+
function gutterEvent(cm, e, type, prevent) {
|
7536 |
+
var mX, mY
|
7537 |
+
if (e.touches) {
|
7538 |
+
mX = e.touches[0].clientX
|
7539 |
+
mY = e.touches[0].clientY
|
7540 |
+
} else {
|
7541 |
+
try { mX = e.clientX; mY = e.clientY }
|
7542 |
+
catch(e) { return false }
|
7543 |
+
}
|
7544 |
+
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
|
7545 |
+
if (prevent) { e_preventDefault(e) }
|
7546 |
+
|
7547 |
+
var display = cm.display
|
7548 |
+
var lineBox = display.lineDiv.getBoundingClientRect()
|
7549 |
+
|
7550 |
+
if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
|
7551 |
+
mY -= lineBox.top - display.viewOffset
|
7552 |
+
|
7553 |
+
for (var i = 0; i < cm.options.gutters.length; ++i) {
|
7554 |
+
var g = display.gutters.childNodes[i]
|
7555 |
+
if (g && g.getBoundingClientRect().right >= mX) {
|
7556 |
+
var line = lineAtHeight(cm.doc, mY)
|
7557 |
+
var gutter = cm.options.gutters[i]
|
7558 |
+
signal(cm, type, cm, line, gutter, e)
|
7559 |
+
return e_defaultPrevented(e)
|
7560 |
+
}
|
7561 |
+
}
|
7562 |
+
}
|
7563 |
+
|
7564 |
+
function clickInGutter(cm, e) {
|
7565 |
+
return gutterEvent(cm, e, "gutterClick", true)
|
7566 |
+
}
|
7567 |
+
|
7568 |
+
// CONTEXT MENU HANDLING
|
7569 |
+
|
7570 |
+
// To make the context menu work, we need to briefly unhide the
|
7571 |
+
// textarea (making it as unobtrusive as possible) to let the
|
7572 |
+
// right-click take effect on it.
|
7573 |
+
function onContextMenu(cm, e) {
|
7574 |
+
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }
|
7575 |
+
if (signalDOMEvent(cm, e, "contextmenu")) { return }
|
7576 |
+
cm.display.input.onContextMenu(e)
|
7577 |
+
}
|
7578 |
+
|
7579 |
+
function contextMenuInGutter(cm, e) {
|
7580 |
+
if (!hasHandler(cm, "gutterContextMenu")) { return false }
|
7581 |
+
return gutterEvent(cm, e, "gutterContextMenu", false)
|
7582 |
+
}
|
7583 |
+
|
7584 |
+
function themeChanged(cm) {
|
7585 |
+
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
|
7586 |
+
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-")
|
7587 |
+
clearCaches(cm)
|
7588 |
+
}
|
7589 |
+
|
7590 |
+
var Init = {toString: function(){return "CodeMirror.Init"}}
|
7591 |
+
|
7592 |
+
var defaults = {}
|
7593 |
+
var optionHandlers = {}
|
7594 |
+
|
7595 |
+
function defineOptions(CodeMirror) {
|
7596 |
+
var optionHandlers = CodeMirror.optionHandlers
|
7597 |
+
|
7598 |
+
function option(name, deflt, handle, notOnInit) {
|
7599 |
+
CodeMirror.defaults[name] = deflt
|
7600 |
+
if (handle) { optionHandlers[name] =
|
7601 |
+
notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old) }} : handle }
|
7602 |
+
}
|
7603 |
+
|
7604 |
+
CodeMirror.defineOption = option
|
7605 |
+
|
7606 |
+
// Passed to option handlers when there is no old value.
|
7607 |
+
CodeMirror.Init = Init
|
7608 |
+
|
7609 |
+
// These two are, on init, called from the constructor because they
|
7610 |
+
// have to be initialized before the editor can start at all.
|
7611 |
+
option("value", "", function (cm, val) { return cm.setValue(val); }, true)
|
7612 |
+
option("mode", null, function (cm, val) {
|
7613 |
+
cm.doc.modeOption = val
|
7614 |
+
loadMode(cm)
|
7615 |
+
}, true)
|
7616 |
+
|
7617 |
+
option("indentUnit", 2, loadMode, true)
|
7618 |
+
option("indentWithTabs", false)
|
7619 |
+
option("smartIndent", true)
|
7620 |
+
option("tabSize", 4, function (cm) {
|
7621 |
+
resetModeState(cm)
|
7622 |
+
clearCaches(cm)
|
7623 |
+
regChange(cm)
|
7624 |
+
}, true)
|
7625 |
+
|
7626 |
+
option("lineSeparator", null, function (cm, val) {
|
7627 |
+
cm.doc.lineSep = val
|
7628 |
+
if (!val) { return }
|
7629 |
+
var newBreaks = [], lineNo = cm.doc.first
|
7630 |
+
cm.doc.iter(function (line) {
|
7631 |
+
for (var pos = 0;;) {
|
7632 |
+
var found = line.text.indexOf(val, pos)
|
7633 |
+
if (found == -1) { break }
|
7634 |
+
pos = found + val.length
|
7635 |
+
newBreaks.push(Pos(lineNo, found))
|
7636 |
+
}
|
7637 |
+
lineNo++
|
7638 |
+
})
|
7639 |
+
for (var i = newBreaks.length - 1; i >= 0; i--)
|
7640 |
+
{ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }
|
7641 |
+
})
|
7642 |
+
option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
|
7643 |
+
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g")
|
7644 |
+
if (old != Init) { cm.refresh() }
|
7645 |
+
})
|
7646 |
+
option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true)
|
7647 |
+
option("electricChars", true)
|
7648 |
+
option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
|
7649 |
+
throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
|
7650 |
+
}, true)
|
7651 |
+
option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true)
|
7652 |
+
option("rtlMoveVisually", !windows)
|
7653 |
+
option("wholeLineUpdateBefore", true)
|
7654 |
+
|
7655 |
+
option("theme", "default", function (cm) {
|
7656 |
+
themeChanged(cm)
|
7657 |
+
guttersChanged(cm)
|
7658 |
+
}, true)
|
7659 |
+
option("keyMap", "default", function (cm, val, old) {
|
7660 |
+
var next = getKeyMap(val)
|
7661 |
+
var prev = old != Init && getKeyMap(old)
|
7662 |
+
if (prev && prev.detach) { prev.detach(cm, next) }
|
7663 |
+
if (next.attach) { next.attach(cm, prev || null) }
|
7664 |
+
})
|
7665 |
+
option("extraKeys", null)
|
7666 |
+
option("configureMouse", null)
|
7667 |
+
|
7668 |
+
option("lineWrapping", false, wrappingChanged, true)
|
7669 |
+
option("gutters", [], function (cm) {
|
7670 |
+
setGuttersForLineNumbers(cm.options)
|
7671 |
+
guttersChanged(cm)
|
7672 |
+
}, true)
|
7673 |
+
option("fixedGutter", true, function (cm, val) {
|
7674 |
+
cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"
|
7675 |
+
cm.refresh()
|
7676 |
+
}, true)
|
7677 |
+
option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true)
|
7678 |
+
option("scrollbarStyle", "native", function (cm) {
|
7679 |
+
initScrollbars(cm)
|
7680 |
+
updateScrollbars(cm)
|
7681 |
+
cm.display.scrollbars.setScrollTop(cm.doc.scrollTop)
|
7682 |
+
cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft)
|
7683 |
+
}, true)
|
7684 |
+
option("lineNumbers", false, function (cm) {
|
7685 |
+
setGuttersForLineNumbers(cm.options)
|
7686 |
+
guttersChanged(cm)
|
7687 |
+
}, true)
|
7688 |
+
option("firstLineNumber", 1, guttersChanged, true)
|
7689 |
+
option("lineNumberFormatter", function (integer) { return integer; }, guttersChanged, true)
|
7690 |
+
option("showCursorWhenSelecting", false, updateSelection, true)
|
7691 |
+
|
7692 |
+
option("resetSelectionOnContextMenu", true)
|
7693 |
+
option("lineWiseCopyCut", true)
|
7694 |
+
option("pasteLinesPerSelection", true)
|
7695 |
+
|
7696 |
+
option("readOnly", false, function (cm, val) {
|
7697 |
+
if (val == "nocursor") {
|
7698 |
+
onBlur(cm)
|
7699 |
+
cm.display.input.blur()
|
7700 |
+
}
|
7701 |
+
cm.display.input.readOnlyChanged(val)
|
7702 |
+
})
|
7703 |
+
option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset() }}, true)
|
7704 |
+
option("dragDrop", true, dragDropChanged)
|
7705 |
+
option("allowDropFileTypes", null)
|
7706 |
+
|
7707 |
+
option("cursorBlinkRate", 530)
|
7708 |
+
option("cursorScrollMargin", 0)
|
7709 |
+
option("cursorHeight", 1, updateSelection, true)
|
7710 |
+
option("singleCursorHeightPerLine", true, updateSelection, true)
|
7711 |
+
option("workTime", 100)
|
7712 |
+
option("workDelay", 100)
|
7713 |
+
option("flattenSpans", true, resetModeState, true)
|
7714 |
+
option("addModeClass", false, resetModeState, true)
|
7715 |
+
option("pollInterval", 100)
|
7716 |
+
option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; })
|
7717 |
+
option("historyEventDelay", 1250)
|
7718 |
+
option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true)
|
7719 |
+
option("maxHighlightLength", 10000, resetModeState, true)
|
7720 |
+
option("moveInputWithCursor", true, function (cm, val) {
|
7721 |
+
if (!val) { cm.display.input.resetPosition() }
|
7722 |
+
})
|
7723 |
+
|
7724 |
+
option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; })
|
7725 |
+
option("autofocus", null)
|
7726 |
+
option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true)
|
7727 |
+
}
|
7728 |
+
|
7729 |
+
function guttersChanged(cm) {
|
7730 |
+
updateGutters(cm)
|
7731 |
+
regChange(cm)
|
7732 |
+
alignHorizontally(cm)
|
7733 |
+
}
|
7734 |
+
|
7735 |
+
function dragDropChanged(cm, value, old) {
|
7736 |
+
var wasOn = old && old != Init
|
7737 |
+
if (!value != !wasOn) {
|
7738 |
+
var funcs = cm.display.dragFunctions
|
7739 |
+
var toggle = value ? on : off
|
7740 |
+
toggle(cm.display.scroller, "dragstart", funcs.start)
|
7741 |
+
toggle(cm.display.scroller, "dragenter", funcs.enter)
|
7742 |
+
toggle(cm.display.scroller, "dragover", funcs.over)
|
7743 |
+
toggle(cm.display.scroller, "dragleave", funcs.leave)
|
7744 |
+
toggle(cm.display.scroller, "drop", funcs.drop)
|
7745 |
+
}
|
7746 |
+
}
|
7747 |
+
|
7748 |
+
function wrappingChanged(cm) {
|
7749 |
+
if (cm.options.lineWrapping) {
|
7750 |
+
addClass(cm.display.wrapper, "CodeMirror-wrap")
|
7751 |
+
cm.display.sizer.style.minWidth = ""
|
7752 |
+
cm.display.sizerWidth = null
|
7753 |
+
} else {
|
7754 |
+
rmClass(cm.display.wrapper, "CodeMirror-wrap")
|
7755 |
+
findMaxLine(cm)
|
7756 |
+
}
|
7757 |
+
estimateLineHeights(cm)
|
7758 |
+
regChange(cm)
|
7759 |
+
clearCaches(cm)
|
7760 |
+
setTimeout(function () { return updateScrollbars(cm); }, 100)
|
7761 |
+
}
|
7762 |
+
|
7763 |
+
// A CodeMirror instance represents an editor. This is the object
|
7764 |
+
// that user code is usually dealing with.
|
7765 |
+
|
7766 |
+
function CodeMirror(place, options) {
|
7767 |
+
var this$1 = this;
|
7768 |
+
|
7769 |
+
if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
|
7770 |
+
|
7771 |
+
this.options = options = options ? copyObj(options) : {}
|
7772 |
+
// Determine effective options based on given values and defaults.
|
7773 |
+
copyObj(defaults, options, false)
|
7774 |
+
setGuttersForLineNumbers(options)
|
7775 |
+
|
7776 |
+
var doc = options.value
|
7777 |
+
if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction) }
|
7778 |
+
this.doc = doc
|
7779 |
+
|
7780 |
+
var input = new CodeMirror.inputStyles[options.inputStyle](this)
|
7781 |
+
var display = this.display = new Display(place, doc, input)
|
7782 |
+
display.wrapper.CodeMirror = this
|
7783 |
+
updateGutters(this)
|
7784 |
+
themeChanged(this)
|
7785 |
+
if (options.lineWrapping)
|
7786 |
+
{ this.display.wrapper.className += " CodeMirror-wrap" }
|
7787 |
+
initScrollbars(this)
|
7788 |
+
|
7789 |
+
this.state = {
|
7790 |
+
keyMaps: [], // stores maps added by addKeyMap
|
7791 |
+
overlays: [], // highlighting overlays, as added by addOverlay
|
7792 |
+
modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
|
7793 |
+
overwrite: false,
|
7794 |
+
delayingBlurEvent: false,
|
7795 |
+
focused: false,
|
7796 |
+
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
|
7797 |
+
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
|
7798 |
+
selectingText: false,
|
7799 |
+
draggingText: false,
|
7800 |
+
highlight: new Delayed(), // stores highlight worker timeout
|
7801 |
+
keySeq: null, // Unfinished key sequence
|
7802 |
+
specialChars: null
|
7803 |
+
}
|
7804 |
+
|
7805 |
+
if (options.autofocus && !mobile) { display.input.focus() }
|
7806 |
+
|
7807 |
+
// Override magic textarea content restore that IE sometimes does
|
7808 |
+
// on our hidden textarea on reload
|
7809 |
+
if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20) }
|
7810 |
+
|
7811 |
+
registerEventHandlers(this)
|
7812 |
+
ensureGlobalHandlers()
|
7813 |
+
|
7814 |
+
startOperation(this)
|
7815 |
+
this.curOp.forceUpdate = true
|
7816 |
+
attachDoc(this, doc)
|
7817 |
+
|
7818 |
+
if ((options.autofocus && !mobile) || this.hasFocus())
|
7819 |
+
{ setTimeout(bind(onFocus, this), 20) }
|
7820 |
+
else
|
7821 |
+
{ onBlur(this) }
|
7822 |
+
|
7823 |
+
for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))
|
7824 |
+
{ optionHandlers[opt](this$1, options[opt], Init) } }
|
7825 |
+
maybeUpdateLineNumberWidth(this)
|
7826 |
+
if (options.finishInit) { options.finishInit(this) }
|
7827 |
+
for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1) }
|
7828 |
+
endOperation(this)
|
7829 |
+
// Suppress optimizelegibility in Webkit, since it breaks text
|
7830 |
+
// measuring on line wrapping boundaries.
|
7831 |
+
if (webkit && options.lineWrapping &&
|
7832 |
+
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
|
7833 |
+
{ display.lineDiv.style.textRendering = "auto" }
|
7834 |
+
}
|
7835 |
+
|
7836 |
+
// The default configuration options.
|
7837 |
+
CodeMirror.defaults = defaults
|
7838 |
+
// Functions to run when options are changed.
|
7839 |
+
CodeMirror.optionHandlers = optionHandlers
|
7840 |
+
|
7841 |
+
// Attach the necessary event handlers when initializing the editor
|
7842 |
+
function registerEventHandlers(cm) {
|
7843 |
+
var d = cm.display
|
7844 |
+
on(d.scroller, "mousedown", operation(cm, onMouseDown))
|
7845 |
+
// Older IE's will not fire a second mousedown for a double click
|
7846 |
+
if (ie && ie_version < 11)
|
7847 |
+
{ on(d.scroller, "dblclick", operation(cm, function (e) {
|
7848 |
+
if (signalDOMEvent(cm, e)) { return }
|
7849 |
+
var pos = posFromMouse(cm, e)
|
7850 |
+
if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }
|
7851 |
+
e_preventDefault(e)
|
7852 |
+
var word = cm.findWordAt(pos)
|
7853 |
+
extendSelection(cm.doc, word.anchor, word.head)
|
7854 |
+
})) }
|
7855 |
+
else
|
7856 |
+
{ on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }) }
|
7857 |
+
// Some browsers fire contextmenu *after* opening the menu, at
|
7858 |
+
// which point we can't mess with it anymore. Context menu is
|
7859 |
+
// handled in onMouseDown for these browsers.
|
7860 |
+
if (!captureRightClick) { on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }) }
|
7861 |
+
|
7862 |
+
// Used to suppress mouse event handling when a touch happens
|
7863 |
+
var touchFinished, prevTouch = {end: 0}
|
7864 |
+
function finishTouch() {
|
7865 |
+
if (d.activeTouch) {
|
7866 |
+
touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000)
|
7867 |
+
prevTouch = d.activeTouch
|
7868 |
+
prevTouch.end = +new Date
|
7869 |
+
}
|
7870 |
+
}
|
7871 |
+
function isMouseLikeTouchEvent(e) {
|
7872 |
+
if (e.touches.length != 1) { return false }
|
7873 |
+
var touch = e.touches[0]
|
7874 |
+
return touch.radiusX <= 1 && touch.radiusY <= 1
|
7875 |
+
}
|
7876 |
+
function farAway(touch, other) {
|
7877 |
+
if (other.left == null) { return true }
|
7878 |
+
var dx = other.left - touch.left, dy = other.top - touch.top
|
7879 |
+
return dx * dx + dy * dy > 20 * 20
|
7880 |
+
}
|
7881 |
+
on(d.scroller, "touchstart", function (e) {
|
7882 |
+
if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
|
7883 |
+
d.input.ensurePolled()
|
7884 |
+
clearTimeout(touchFinished)
|
7885 |
+
var now = +new Date
|
7886 |
+
d.activeTouch = {start: now, moved: false,
|
7887 |
+
prev: now - prevTouch.end <= 300 ? prevTouch : null}
|
7888 |
+
if (e.touches.length == 1) {
|
7889 |
+
d.activeTouch.left = e.touches[0].pageX
|
7890 |
+
d.activeTouch.top = e.touches[0].pageY
|
7891 |
+
}
|
7892 |
+
}
|
7893 |
+
})
|
7894 |
+
on(d.scroller, "touchmove", function () {
|
7895 |
+
if (d.activeTouch) { d.activeTouch.moved = true }
|
7896 |
+
})
|
7897 |
+
on(d.scroller, "touchend", function (e) {
|
7898 |
+
var touch = d.activeTouch
|
7899 |
+
if (touch && !eventInWidget(d, e) && touch.left != null &&
|
7900 |
+
!touch.moved && new Date - touch.start < 300) {
|
7901 |
+
var pos = cm.coordsChar(d.activeTouch, "page"), range
|
7902 |
+
if (!touch.prev || farAway(touch, touch.prev)) // Single tap
|
7903 |
+
{ range = new Range(pos, pos) }
|
7904 |
+
else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
|
7905 |
+
{ range = cm.findWordAt(pos) }
|
7906 |
+
else // Triple tap
|
7907 |
+
{ range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
|
7908 |
+
cm.setSelection(range.anchor, range.head)
|
7909 |
+
cm.focus()
|
7910 |
+
e_preventDefault(e)
|
7911 |
+
}
|
7912 |
+
finishTouch()
|
7913 |
+
})
|
7914 |
+
on(d.scroller, "touchcancel", finishTouch)
|
7915 |
+
|
7916 |
+
// Sync scrolling between fake scrollbars and real scrollable
|
7917 |
+
// area, ensure viewport is updated when scrolling.
|
7918 |
+
on(d.scroller, "scroll", function () {
|
7919 |
+
if (d.scroller.clientHeight) {
|
7920 |
+
updateScrollTop(cm, d.scroller.scrollTop)
|
7921 |
+
setScrollLeft(cm, d.scroller.scrollLeft, true)
|
7922 |
+
signal(cm, "scroll", cm)
|
7923 |
+
}
|
7924 |
+
})
|
7925 |
+
|
7926 |
+
// Listen to wheel events in order to try and update the viewport on time.
|
7927 |
+
on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); })
|
7928 |
+
on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); })
|
7929 |
+
|
7930 |
+
// Prevent wrapper from ever scrolling
|
7931 |
+
on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; })
|
7932 |
+
|
7933 |
+
d.dragFunctions = {
|
7934 |
+
enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e) }},
|
7935 |
+
over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e) }},
|
7936 |
+
start: function (e) { return onDragStart(cm, e); },
|
7937 |
+
drop: operation(cm, onDrop),
|
7938 |
+
leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm) }}
|
7939 |
+
}
|
7940 |
+
|
7941 |
+
var inp = d.input.getField()
|
7942 |
+
on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); })
|
7943 |
+
on(inp, "keydown", operation(cm, onKeyDown))
|
7944 |
+
on(inp, "keypress", operation(cm, onKeyPress))
|
7945 |
+
on(inp, "focus", function (e) { return onFocus(cm, e); })
|
7946 |
+
on(inp, "blur", function (e) { return onBlur(cm, e); })
|
7947 |
+
}
|
7948 |
+
|
7949 |
+
var initHooks = []
|
7950 |
+
CodeMirror.defineInitHook = function (f) { return initHooks.push(f); }
|
7951 |
+
|
7952 |
+
// Indent the given line. The how parameter can be "smart",
|
7953 |
+
// "add"/null, "subtract", or "prev". When aggressive is false
|
7954 |
+
// (typically set to true for forced single-line indents), empty
|
7955 |
+
// lines are not indented, and places where the mode returns Pass
|
7956 |
+
// are left alone.
|
7957 |
+
function indentLine(cm, n, how, aggressive) {
|
7958 |
+
var doc = cm.doc, state
|
7959 |
+
if (how == null) { how = "add" }
|
7960 |
+
if (how == "smart") {
|
7961 |
+
// Fall back to "prev" when the mode doesn't have an indentation
|
7962 |
+
// method.
|
7963 |
+
if (!doc.mode.indent) { how = "prev" }
|
7964 |
+
else { state = getContextBefore(cm, n).state }
|
7965 |
+
}
|
7966 |
+
|
7967 |
+
var tabSize = cm.options.tabSize
|
7968 |
+
var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize)
|
7969 |
+
if (line.stateAfter) { line.stateAfter = null }
|
7970 |
+
var curSpaceString = line.text.match(/^\s*/)[0], indentation
|
7971 |
+
if (!aggressive && !/\S/.test(line.text)) {
|
7972 |
+
indentation = 0
|
7973 |
+
how = "not"
|
7974 |
+
} else if (how == "smart") {
|
7975 |
+
indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text)
|
7976 |
+
if (indentation == Pass || indentation > 150) {
|
7977 |
+
if (!aggressive) { return }
|
7978 |
+
how = "prev"
|
7979 |
+
}
|
7980 |
+
}
|
7981 |
+
if (how == "prev") {
|
7982 |
+
if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize) }
|
7983 |
+
else { indentation = 0 }
|
7984 |
+
} else if (how == "add") {
|
7985 |
+
indentation = curSpace + cm.options.indentUnit
|
7986 |
+
} else if (how == "subtract") {
|
7987 |
+
indentation = curSpace - cm.options.indentUnit
|
7988 |
+
} else if (typeof how == "number") {
|
7989 |
+
indentation = curSpace + how
|
7990 |
+
}
|
7991 |
+
indentation = Math.max(0, indentation)
|
7992 |
+
|
7993 |
+
var indentString = "", pos = 0
|
7994 |
+
if (cm.options.indentWithTabs)
|
7995 |
+
{ for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t"} }
|
7996 |
+
if (pos < indentation) { indentString += spaceStr(indentation - pos) }
|
7997 |
+
|
7998 |
+
if (indentString != curSpaceString) {
|
7999 |
+
replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input")
|
8000 |
+
line.stateAfter = null
|
8001 |
+
return true
|
8002 |
+
} else {
|
8003 |
+
// Ensure that, if the cursor was in the whitespace at the start
|
8004 |
+
// of the line, it is moved to the end of that space.
|
8005 |
+
for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
|
8006 |
+
var range = doc.sel.ranges[i$1]
|
8007 |
+
if (range.head.line == n && range.head.ch < curSpaceString.length) {
|
8008 |
+
var pos$1 = Pos(n, curSpaceString.length)
|
8009 |
+
replaceOneSelection(doc, i$1, new Range(pos$1, pos$1))
|
8010 |
+
break
|
8011 |
+
}
|
8012 |
+
}
|
8013 |
+
}
|
8014 |
+
}
|
8015 |
+
|
8016 |
+
// This will be set to a {lineWise: bool, text: [string]} object, so
|
8017 |
+
// that, when pasting, we know what kind of selections the copied
|
8018 |
+
// text was made out of.
|
8019 |
+
var lastCopied = null
|
8020 |
+
|
8021 |
+
function setLastCopied(newLastCopied) {
|
8022 |
+
lastCopied = newLastCopied
|
8023 |
+
}
|
8024 |
+
|
8025 |
+
function applyTextInput(cm, inserted, deleted, sel, origin) {
|
8026 |
+
var doc = cm.doc
|
8027 |
+
cm.display.shift = false
|
8028 |
+
if (!sel) { sel = doc.sel }
|
8029 |
+
|
8030 |
+
var paste = cm.state.pasteIncoming || origin == "paste"
|
8031 |
+
var textLines = splitLinesAuto(inserted), multiPaste = null
|
8032 |
+
// When pasting N lines into N selections, insert one line per selection
|
8033 |
+
if (paste && sel.ranges.length > 1) {
|
8034 |
+
if (lastCopied && lastCopied.text.join("\n") == inserted) {
|
8035 |
+
if (sel.ranges.length % lastCopied.text.length == 0) {
|
8036 |
+
multiPaste = []
|
8037 |
+
for (var i = 0; i < lastCopied.text.length; i++)
|
8038 |
+
{ multiPaste.push(doc.splitLines(lastCopied.text[i])) }
|
8039 |
+
}
|
8040 |
+
} else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {
|
8041 |
+
multiPaste = map(textLines, function (l) { return [l]; })
|
8042 |
+
}
|
8043 |
+
}
|
8044 |
+
|
8045 |
+
var updateInput
|
8046 |
+
// Normal behavior is to insert the new text into every selection
|
8047 |
+
for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
|
8048 |
+
var range = sel.ranges[i$1]
|
8049 |
+
var from = range.from(), to = range.to()
|
8050 |
+
if (range.empty()) {
|
8051 |
+
if (deleted && deleted > 0) // Handle deletion
|
8052 |
+
{ from = Pos(from.line, from.ch - deleted) }
|
8053 |
+
else if (cm.state.overwrite && !paste) // Handle overwrite
|
8054 |
+
{ to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)) }
|
8055 |
+
else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
|
8056 |
+
{ from = to = Pos(from.line, 0) }
|
8057 |
+
}
|
8058 |
+
updateInput = cm.curOp.updateInput
|
8059 |
+
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
|
8060 |
+
origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")}
|
8061 |
+
makeChange(cm.doc, changeEvent)
|
8062 |
+
signalLater(cm, "inputRead", cm, changeEvent)
|
8063 |
+
}
|
8064 |
+
if (inserted && !paste)
|
8065 |
+
{ triggerElectric(cm, inserted) }
|
8066 |
+
|
8067 |
+
ensureCursorVisible(cm)
|
8068 |
+
cm.curOp.updateInput = updateInput
|
8069 |
+
cm.curOp.typing = true
|
8070 |
+
cm.state.pasteIncoming = cm.state.cutIncoming = false
|
8071 |
+
}
|
8072 |
+
|
8073 |
+
function handlePaste(e, cm) {
|
8074 |
+
var pasted = e.clipboardData && e.clipboardData.getData("Text")
|
8075 |
+
if (pasted) {
|
8076 |
+
e.preventDefault()
|
8077 |
+
if (!cm.isReadOnly() && !cm.options.disableInput)
|
8078 |
+
{ runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }) }
|
8079 |
+
return true
|
8080 |
+
}
|
8081 |
+
}
|
8082 |
+
|
8083 |
+
function triggerElectric(cm, inserted) {
|
8084 |
+
// When an 'electric' character is inserted, immediately trigger a reindent
|
8085 |
+
if (!cm.options.electricChars || !cm.options.smartIndent) { return }
|
8086 |
+
var sel = cm.doc.sel
|
8087 |
+
|
8088 |
+
for (var i = sel.ranges.length - 1; i >= 0; i--) {
|
8089 |
+
var range = sel.ranges[i]
|
8090 |
+
if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue }
|
8091 |
+
var mode = cm.getModeAt(range.head)
|
8092 |
+
var indented = false
|
8093 |
+
if (mode.electricChars) {
|
8094 |
+
for (var j = 0; j < mode.electricChars.length; j++)
|
8095 |
+
{ if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
|
8096 |
+
indented = indentLine(cm, range.head.line, "smart")
|
8097 |
+
break
|
8098 |
+
} }
|
8099 |
+
} else if (mode.electricInput) {
|
8100 |
+
if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
|
8101 |
+
{ indented = indentLine(cm, range.head.line, "smart") }
|
8102 |
+
}
|
8103 |
+
if (indented) { signalLater(cm, "electricInput", cm, range.head.line) }
|
8104 |
+
}
|
8105 |
+
}
|
8106 |
+
|
8107 |
+
function copyableRanges(cm) {
|
8108 |
+
var text = [], ranges = []
|
8109 |
+
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
|
8110 |
+
var line = cm.doc.sel.ranges[i].head.line
|
8111 |
+
var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}
|
8112 |
+
ranges.push(lineRange)
|
8113 |
+
text.push(cm.getRange(lineRange.anchor, lineRange.head))
|
8114 |
+
}
|
8115 |
+
return {text: text, ranges: ranges}
|
8116 |
+
}
|
8117 |
+
|
8118 |
+
function disableBrowserMagic(field, spellcheck) {
|
8119 |
+
field.setAttribute("autocorrect", "off")
|
8120 |
+
field.setAttribute("autocapitalize", "off")
|
8121 |
+
field.setAttribute("spellcheck", !!spellcheck)
|
8122 |
+
}
|
8123 |
+
|
8124 |
+
function hiddenTextarea() {
|
8125 |
+
var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none")
|
8126 |
+
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;")
|
8127 |
+
// The textarea is kept positioned near the cursor to prevent the
|
8128 |
+
// fact that it'll be scrolled into view on input from scrolling
|
8129 |
+
// our fake cursor out of view. On webkit, when wrap=off, paste is
|
8130 |
+
// very slow. So make the area wide instead.
|
8131 |
+
if (webkit) { te.style.width = "1000px" }
|
8132 |
+
else { te.setAttribute("wrap", "off") }
|
8133 |
+
// If border: 0; -- iOS fails to open keyboard (issue #1287)
|
8134 |
+
if (ios) { te.style.border = "1px solid black" }
|
8135 |
+
disableBrowserMagic(te)
|
8136 |
+
return div
|
8137 |
+
}
|
8138 |
+
|
8139 |
+
// The publicly visible API. Note that methodOp(f) means
|
8140 |
+
// 'wrap f in an operation, performed on its `this` parameter'.
|
8141 |
+
|
8142 |
+
// This is not the complete set of editor methods. Most of the
|
8143 |
+
// methods defined on the Doc type are also injected into
|
8144 |
+
// CodeMirror.prototype, for backwards compatibility and
|
8145 |
+
// convenience.
|
8146 |
+
|
8147 |
+
function addEditorMethods(CodeMirror) {
|
8148 |
+
var optionHandlers = CodeMirror.optionHandlers
|
8149 |
+
|
8150 |
+
var helpers = CodeMirror.helpers = {}
|
8151 |
+
|
8152 |
+
CodeMirror.prototype = {
|
8153 |
+
constructor: CodeMirror,
|
8154 |
+
focus: function(){window.focus(); this.display.input.focus()},
|
8155 |
+
|
8156 |
+
setOption: function(option, value) {
|
8157 |
+
var options = this.options, old = options[option]
|
8158 |
+
if (options[option] == value && option != "mode") { return }
|
8159 |
+
options[option] = value
|
8160 |
+
if (optionHandlers.hasOwnProperty(option))
|
8161 |
+
{ operation(this, optionHandlers[option])(this, value, old) }
|
8162 |
+
signal(this, "optionChange", this, option)
|
8163 |
+
},
|
8164 |
+
|
8165 |
+
getOption: function(option) {return this.options[option]},
|
8166 |
+
getDoc: function() {return this.doc},
|
8167 |
+
|
8168 |
+
addKeyMap: function(map, bottom) {
|
8169 |
+
this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map))
|
8170 |
+
},
|
8171 |
+
removeKeyMap: function(map) {
|
8172 |
+
var maps = this.state.keyMaps
|
8173 |
+
for (var i = 0; i < maps.length; ++i)
|
8174 |
+
{ if (maps[i] == map || maps[i].name == map) {
|
8175 |
+
maps.splice(i, 1)
|
8176 |
+
return true
|
8177 |
+
} }
|
8178 |
+
},
|
8179 |
+
|
8180 |
+
addOverlay: methodOp(function(spec, options) {
|
8181 |
+
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec)
|
8182 |
+
if (mode.startState) { throw new Error("Overlays may not be stateful.") }
|
8183 |
+
insertSorted(this.state.overlays,
|
8184 |
+
{mode: mode, modeSpec: spec, opaque: options && options.opaque,
|
8185 |
+
priority: (options && options.priority) || 0},
|
8186 |
+
function (overlay) { return overlay.priority; })
|
8187 |
+
this.state.modeGen++
|
8188 |
+
regChange(this)
|
8189 |
+
}),
|
8190 |
+
removeOverlay: methodOp(function(spec) {
|
8191 |
+
var this$1 = this;
|
8192 |
+
|
8193 |
+
var overlays = this.state.overlays
|
8194 |
+
for (var i = 0; i < overlays.length; ++i) {
|
8195 |
+
var cur = overlays[i].modeSpec
|
8196 |
+
if (cur == spec || typeof spec == "string" && cur.name == spec) {
|
8197 |
+
overlays.splice(i, 1)
|
8198 |
+
this$1.state.modeGen++
|
8199 |
+
regChange(this$1)
|
8200 |
+
return
|
8201 |
+
}
|
8202 |
+
}
|
8203 |
+
}),
|
8204 |
+
|
8205 |
+
indentLine: methodOp(function(n, dir, aggressive) {
|
8206 |
+
if (typeof dir != "string" && typeof dir != "number") {
|
8207 |
+
if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev" }
|
8208 |
+
else { dir = dir ? "add" : "subtract" }
|
8209 |
+
}
|
8210 |
+
if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive) }
|
8211 |
+
}),
|
8212 |
+
indentSelection: methodOp(function(how) {
|
8213 |
+
var this$1 = this;
|
8214 |
+
|
8215 |
+
var ranges = this.doc.sel.ranges, end = -1
|
8216 |
+
for (var i = 0; i < ranges.length; i++) {
|
8217 |
+
var range = ranges[i]
|
8218 |
+
if (!range.empty()) {
|
8219 |
+
var from = range.from(), to = range.to()
|
8220 |
+
var start = Math.max(end, from.line)
|
8221 |
+
end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1
|
8222 |
+
for (var j = start; j < end; ++j)
|
8223 |
+
{ indentLine(this$1, j, how) }
|
8224 |
+
var newRanges = this$1.doc.sel.ranges
|
8225 |
+
if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
|
8226 |
+
{ replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll) }
|
8227 |
+
} else if (range.head.line > end) {
|
8228 |
+
indentLine(this$1, range.head.line, how, true)
|
8229 |
+
end = range.head.line
|
8230 |
+
if (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1) }
|
8231 |
+
}
|
8232 |
+
}
|
8233 |
+
}),
|
8234 |
+
|
8235 |
+
// Fetch the parser token for a given character. Useful for hacks
|
8236 |
+
// that want to inspect the mode state (say, for completion).
|
8237 |
+
getTokenAt: function(pos, precise) {
|
8238 |
+
return takeToken(this, pos, precise)
|
8239 |
+
},
|
8240 |
+
|
8241 |
+
getLineTokens: function(line, precise) {
|
8242 |
+
return takeToken(this, Pos(line), precise, true)
|
8243 |
+
},
|
8244 |
+
|
8245 |
+
getTokenTypeAt: function(pos) {
|
8246 |
+
pos = clipPos(this.doc, pos)
|
8247 |
+
var styles = getLineStyles(this, getLine(this.doc, pos.line))
|
8248 |
+
var before = 0, after = (styles.length - 1) / 2, ch = pos.ch
|
8249 |
+
var type
|
8250 |
+
if (ch == 0) { type = styles[2] }
|
8251 |
+
else { for (;;) {
|
8252 |
+
var mid = (before + after) >> 1
|
8253 |
+
if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid }
|
8254 |
+
else if (styles[mid * 2 + 1] < ch) { before = mid + 1 }
|
8255 |
+
else { type = styles[mid * 2 + 2]; break }
|
8256 |
+
} }
|
8257 |
+
var cut = type ? type.indexOf("overlay ") : -1
|
8258 |
+
return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)
|
8259 |
+
},
|
8260 |
+
|
8261 |
+
getModeAt: function(pos) {
|
8262 |
+
var mode = this.doc.mode
|
8263 |
+
if (!mode.innerMode) { return mode }
|
8264 |
+
return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode
|
8265 |
+
},
|
8266 |
+
|
8267 |
+
getHelper: function(pos, type) {
|
8268 |
+
return this.getHelpers(pos, type)[0]
|
8269 |
+
},
|
8270 |
+
|
8271 |
+
getHelpers: function(pos, type) {
|
8272 |
+
var this$1 = this;
|
8273 |
+
|
8274 |
+
var found = []
|
8275 |
+
if (!helpers.hasOwnProperty(type)) { return found }
|
8276 |
+
var help = helpers[type], mode = this.getModeAt(pos)
|
8277 |
+
if (typeof mode[type] == "string") {
|
8278 |
+
if (help[mode[type]]) { found.push(help[mode[type]]) }
|
8279 |
+
} else if (mode[type]) {
|
8280 |
+
for (var i = 0; i < mode[type].length; i++) {
|
8281 |
+
var val = help[mode[type][i]]
|
8282 |
+
if (val) { found.push(val) }
|
8283 |
+
}
|
8284 |
+
} else if (mode.helperType && help[mode.helperType]) {
|
8285 |
+
found.push(help[mode.helperType])
|
8286 |
+
} else if (help[mode.name]) {
|
8287 |
+
found.push(help[mode.name])
|
8288 |
+
}
|
8289 |
+
for (var i$1 = 0; i$1 < help._global.length; i$1++) {
|
8290 |
+
var cur = help._global[i$1]
|
8291 |
+
if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)
|
8292 |
+
{ found.push(cur.val) }
|
8293 |
+
}
|
8294 |
+
return found
|
8295 |
+
},
|
8296 |
+
|
8297 |
+
getStateAfter: function(line, precise) {
|
8298 |
+
var doc = this.doc
|
8299 |
+
line = clipLine(doc, line == null ? doc.first + doc.size - 1: line)
|
8300 |
+
return getContextBefore(this, line + 1, precise).state
|
8301 |
+
},
|
8302 |
+
|
8303 |
+
cursorCoords: function(start, mode) {
|
8304 |
+
var pos, range = this.doc.sel.primary()
|
8305 |
+
if (start == null) { pos = range.head }
|
8306 |
+
else if (typeof start == "object") { pos = clipPos(this.doc, start) }
|
8307 |
+
else { pos = start ? range.from() : range.to() }
|
8308 |
+
return cursorCoords(this, pos, mode || "page")
|
8309 |
+
},
|
8310 |
+
|
8311 |
+
charCoords: function(pos, mode) {
|
8312 |
+
return charCoords(this, clipPos(this.doc, pos), mode || "page")
|
8313 |
+
},
|
8314 |
+
|
8315 |
+
coordsChar: function(coords, mode) {
|
8316 |
+
coords = fromCoordSystem(this, coords, mode || "page")
|
8317 |
+
return coordsChar(this, coords.left, coords.top)
|
8318 |
+
},
|
8319 |
+
|
8320 |
+
lineAtHeight: function(height, mode) {
|
8321 |
+
height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top
|
8322 |
+
return lineAtHeight(this.doc, height + this.display.viewOffset)
|
8323 |
+
},
|
8324 |
+
heightAtLine: function(line, mode, includeWidgets) {
|
8325 |
+
var end = false, lineObj
|
8326 |
+
if (typeof line == "number") {
|
8327 |
+
var last = this.doc.first + this.doc.size - 1
|
8328 |
+
if (line < this.doc.first) { line = this.doc.first }
|
8329 |
+
else if (line > last) { line = last; end = true }
|
8330 |
+
lineObj = getLine(this.doc, line)
|
8331 |
+
} else {
|
8332 |
+
lineObj = line
|
8333 |
+
}
|
8334 |
+
return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
|
8335 |
+
(end ? this.doc.height - heightAtLine(lineObj) : 0)
|
8336 |
+
},
|
8337 |
+
|
8338 |
+
defaultTextHeight: function() { return textHeight(this.display) },
|
8339 |
+
defaultCharWidth: function() { return charWidth(this.display) },
|
8340 |
+
|
8341 |
+
getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
|
8342 |
+
|
8343 |
+
addWidget: function(pos, node, scroll, vert, horiz) {
|
8344 |
+
var display = this.display
|
8345 |
+
pos = cursorCoords(this, clipPos(this.doc, pos))
|
8346 |
+
var top = pos.bottom, left = pos.left
|
8347 |
+
node.style.position = "absolute"
|
8348 |
+
node.setAttribute("cm-ignore-events", "true")
|
8349 |
+
this.display.input.setUneditable(node)
|
8350 |
+
display.sizer.appendChild(node)
|
8351 |
+
if (vert == "over") {
|
8352 |
+
top = pos.top
|
8353 |
+
} else if (vert == "above" || vert == "near") {
|
8354 |
+
var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
|
8355 |
+
hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth)
|
8356 |
+
// Default to positioning above (if specified and possible); otherwise default to positioning below
|
8357 |
+
if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
|
8358 |
+
{ top = pos.top - node.offsetHeight }
|
8359 |
+
else if (pos.bottom + node.offsetHeight <= vspace)
|
8360 |
+
{ top = pos.bottom }
|
8361 |
+
if (left + node.offsetWidth > hspace)
|
8362 |
+
{ left = hspace - node.offsetWidth }
|
8363 |
+
}
|
8364 |
+
node.style.top = top + "px"
|
8365 |
+
node.style.left = node.style.right = ""
|
8366 |
+
if (horiz == "right") {
|
8367 |
+
left = display.sizer.clientWidth - node.offsetWidth
|
8368 |
+
node.style.right = "0px"
|
8369 |
+
} else {
|
8370 |
+
if (horiz == "left") { left = 0 }
|
8371 |
+
else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2 }
|
8372 |
+
node.style.left = left + "px"
|
8373 |
+
}
|
8374 |
+
if (scroll)
|
8375 |
+
{ scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}) }
|
8376 |
+
},
|
8377 |
+
|
8378 |
+
triggerOnKeyDown: methodOp(onKeyDown),
|
8379 |
+
triggerOnKeyPress: methodOp(onKeyPress),
|
8380 |
+
triggerOnKeyUp: onKeyUp,
|
8381 |
+
triggerOnMouseDown: methodOp(onMouseDown),
|
8382 |
+
|
8383 |
+
execCommand: function(cmd) {
|
8384 |
+
if (commands.hasOwnProperty(cmd))
|
8385 |
+
{ return commands[cmd].call(null, this) }
|
8386 |
+
},
|
8387 |
+
|
8388 |
+
triggerElectric: methodOp(function(text) { triggerElectric(this, text) }),
|
8389 |
+
|
8390 |
+
findPosH: function(from, amount, unit, visually) {
|
8391 |
+
var this$1 = this;
|
8392 |
+
|
8393 |
+
var dir = 1
|
8394 |
+
if (amount < 0) { dir = -1; amount = -amount }
|
8395 |
+
var cur = clipPos(this.doc, from)
|
8396 |
+
for (var i = 0; i < amount; ++i) {
|
8397 |
+
cur = findPosH(this$1.doc, cur, dir, unit, visually)
|
8398 |
+
if (cur.hitSide) { break }
|
8399 |
+
}
|
8400 |
+
return cur
|
8401 |
+
},
|
8402 |
+
|
8403 |
+
moveH: methodOp(function(dir, unit) {
|
8404 |
+
var this$1 = this;
|
8405 |
+
|
8406 |
+
this.extendSelectionsBy(function (range) {
|
8407 |
+
if (this$1.display.shift || this$1.doc.extend || range.empty())
|
8408 |
+
{ return findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) }
|
8409 |
+
else
|
8410 |
+
{ return dir < 0 ? range.from() : range.to() }
|
8411 |
+
}, sel_move)
|
8412 |
+
}),
|
8413 |
+
|
8414 |
+
deleteH: methodOp(function(dir, unit) {
|
8415 |
+
var sel = this.doc.sel, doc = this.doc
|
8416 |
+
if (sel.somethingSelected())
|
8417 |
+
{ doc.replaceSelection("", null, "+delete") }
|
8418 |
+
else
|
8419 |
+
{ deleteNearSelection(this, function (range) {
|
8420 |
+
var other = findPosH(doc, range.head, dir, unit, false)
|
8421 |
+
return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}
|
8422 |
+
}) }
|
8423 |
+
}),
|
8424 |
+
|
8425 |
+
findPosV: function(from, amount, unit, goalColumn) {
|
8426 |
+
var this$1 = this;
|
8427 |
+
|
8428 |
+
var dir = 1, x = goalColumn
|
8429 |
+
if (amount < 0) { dir = -1; amount = -amount }
|
8430 |
+
var cur = clipPos(this.doc, from)
|
8431 |
+
for (var i = 0; i < amount; ++i) {
|
8432 |
+
var coords = cursorCoords(this$1, cur, "div")
|
8433 |
+
if (x == null) { x = coords.left }
|
8434 |
+
else { coords.left = x }
|
8435 |
+
cur = findPosV(this$1, coords, dir, unit)
|
8436 |
+
if (cur.hitSide) { break }
|
8437 |
+
}
|
8438 |
+
return cur
|
8439 |
+
},
|
8440 |
+
|
8441 |
+
moveV: methodOp(function(dir, unit) {
|
8442 |
+
var this$1 = this;
|
8443 |
+
|
8444 |
+
var doc = this.doc, goals = []
|
8445 |
+
var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected()
|
8446 |
+
doc.extendSelectionsBy(function (range) {
|
8447 |
+
if (collapse)
|
8448 |
+
{ return dir < 0 ? range.from() : range.to() }
|
8449 |
+
var headPos = cursorCoords(this$1, range.head, "div")
|
8450 |
+
if (range.goalColumn != null) { headPos.left = range.goalColumn }
|
8451 |
+
goals.push(headPos.left)
|
8452 |
+
var pos = findPosV(this$1, headPos, dir, unit)
|
8453 |
+
if (unit == "page" && range == doc.sel.primary())
|
8454 |
+
{ addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top) }
|
8455 |
+
return pos
|
8456 |
+
}, sel_move)
|
8457 |
+
if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)
|
8458 |
+
{ doc.sel.ranges[i].goalColumn = goals[i] } }
|
8459 |
+
}),
|
8460 |
+
|
8461 |
+
// Find the word at the given position (as returned by coordsChar).
|
8462 |
+
findWordAt: function(pos) {
|
8463 |
+
var doc = this.doc, line = getLine(doc, pos.line).text
|
8464 |
+
var start = pos.ch, end = pos.ch
|
8465 |
+
if (line) {
|
8466 |
+
var helper = this.getHelper(pos, "wordChars")
|
8467 |
+
if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end }
|
8468 |
+
var startChar = line.charAt(start)
|
8469 |
+
var check = isWordChar(startChar, helper)
|
8470 |
+
? function (ch) { return isWordChar(ch, helper); }
|
8471 |
+
: /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); }
|
8472 |
+
: function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); }
|
8473 |
+
while (start > 0 && check(line.charAt(start - 1))) { --start }
|
8474 |
+
while (end < line.length && check(line.charAt(end))) { ++end }
|
8475 |
+
}
|
8476 |
+
return new Range(Pos(pos.line, start), Pos(pos.line, end))
|
8477 |
+
},
|
8478 |
+
|
8479 |
+
toggleOverwrite: function(value) {
|
8480 |
+
if (value != null && value == this.state.overwrite) { return }
|
8481 |
+
if (this.state.overwrite = !this.state.overwrite)
|
8482 |
+
{ addClass(this.display.cursorDiv, "CodeMirror-overwrite") }
|
8483 |
+
else
|
8484 |
+
{ rmClass(this.display.cursorDiv, "CodeMirror-overwrite") }
|
8485 |
+
|
8486 |
+
signal(this, "overwriteToggle", this, this.state.overwrite)
|
8487 |
+
},
|
8488 |
+
hasFocus: function() { return this.display.input.getField() == activeElt() },
|
8489 |
+
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
|
8490 |
+
|
8491 |
+
scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y) }),
|
8492 |
+
getScrollInfo: function() {
|
8493 |
+
var scroller = this.display.scroller
|
8494 |
+
return {left: scroller.scrollLeft, top: scroller.scrollTop,
|
8495 |
+
height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
|
8496 |
+
width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
|
8497 |
+
clientHeight: displayHeight(this), clientWidth: displayWidth(this)}
|
8498 |
+
},
|
8499 |
+
|
8500 |
+
scrollIntoView: methodOp(function(range, margin) {
|
8501 |
+
if (range == null) {
|
8502 |
+
range = {from: this.doc.sel.primary().head, to: null}
|
8503 |
+
if (margin == null) { margin = this.options.cursorScrollMargin }
|
8504 |
+
} else if (typeof range == "number") {
|
8505 |
+
range = {from: Pos(range, 0), to: null}
|
8506 |
+
} else if (range.from == null) {
|
8507 |
+
range = {from: range, to: null}
|
8508 |
+
}
|
8509 |
+
if (!range.to) { range.to = range.from }
|
8510 |
+
range.margin = margin || 0
|
8511 |
+
|
8512 |
+
if (range.from.line != null) {
|
8513 |
+
scrollToRange(this, range)
|
8514 |
+
} else {
|
8515 |
+
scrollToCoordsRange(this, range.from, range.to, range.margin)
|
8516 |
+
}
|
8517 |
+
}),
|
8518 |
+
|
8519 |
+
setSize: methodOp(function(width, height) {
|
8520 |
+
var this$1 = this;
|
8521 |
+
|
8522 |
+
var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; }
|
8523 |
+
if (width != null) { this.display.wrapper.style.width = interpret(width) }
|
8524 |
+
if (height != null) { this.display.wrapper.style.height = interpret(height) }
|
8525 |
+
if (this.options.lineWrapping) { clearLineMeasurementCache(this) }
|
8526 |
+
var lineNo = this.display.viewFrom
|
8527 |
+
this.doc.iter(lineNo, this.display.viewTo, function (line) {
|
8528 |
+
if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)
|
8529 |
+
{ if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break } } }
|
8530 |
+
++lineNo
|
8531 |
+
})
|
8532 |
+
this.curOp.forceUpdate = true
|
8533 |
+
signal(this, "refresh", this)
|
8534 |
+
}),
|
8535 |
+
|
8536 |
+
operation: function(f){return runInOp(this, f)},
|
8537 |
+
startOperation: function(){return startOperation(this)},
|
8538 |
+
endOperation: function(){return endOperation(this)},
|
8539 |
+
|
8540 |
+
refresh: methodOp(function() {
|
8541 |
+
var oldHeight = this.display.cachedTextHeight
|
8542 |
+
regChange(this)
|
8543 |
+
this.curOp.forceUpdate = true
|
8544 |
+
clearCaches(this)
|
8545 |
+
scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop)
|
8546 |
+
updateGutterSpace(this)
|
8547 |
+
if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
|
8548 |
+
{ estimateLineHeights(this) }
|
8549 |
+
signal(this, "refresh", this)
|
8550 |
+
}),
|
8551 |
+
|
8552 |
+
swapDoc: methodOp(function(doc) {
|
8553 |
+
var old = this.doc
|
8554 |
+
old.cm = null
|
8555 |
+
attachDoc(this, doc)
|
8556 |
+
clearCaches(this)
|
8557 |
+
this.display.input.reset()
|
8558 |
+
scrollToCoords(this, doc.scrollLeft, doc.scrollTop)
|
8559 |
+
this.curOp.forceScroll = true
|
8560 |
+
signalLater(this, "swapDoc", this, old)
|
8561 |
+
return old
|
8562 |
+
}),
|
8563 |
+
|
8564 |
+
getInputField: function(){return this.display.input.getField()},
|
8565 |
+
getWrapperElement: function(){return this.display.wrapper},
|
8566 |
+
getScrollerElement: function(){return this.display.scroller},
|
8567 |
+
getGutterElement: function(){return this.display.gutters}
|
8568 |
+
}
|
8569 |
+
eventMixin(CodeMirror)
|
8570 |
+
|
8571 |
+
CodeMirror.registerHelper = function(type, name, value) {
|
8572 |
+
if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []} }
|
8573 |
+
helpers[type][name] = value
|
8574 |
+
}
|
8575 |
+
CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
|
8576 |
+
CodeMirror.registerHelper(type, name, value)
|
8577 |
+
helpers[type]._global.push({pred: predicate, val: value})
|
8578 |
+
}
|
8579 |
+
}
|
8580 |
+
|
8581 |
+
// Used for horizontal relative motion. Dir is -1 or 1 (left or
|
8582 |
+
// right), unit can be "char", "column" (like char, but doesn't
|
8583 |
+
// cross line boundaries), "word" (across next word), or "group" (to
|
8584 |
+
// the start of next group of word or non-word-non-whitespace
|
8585 |
+
// chars). The visually param controls whether, in right-to-left
|
8586 |
+
// text, direction 1 means to move towards the next index in the
|
8587 |
+
// string, or towards the character to the right of the current
|
8588 |
+
// position. The resulting position will have a hitSide=true
|
8589 |
+
// property if it reached the end of the document.
|
8590 |
+
function findPosH(doc, pos, dir, unit, visually) {
|
8591 |
+
var oldPos = pos
|
8592 |
+
var origDir = dir
|
8593 |
+
var lineObj = getLine(doc, pos.line)
|
8594 |
+
function findNextLine() {
|
8595 |
+
var l = pos.line + dir
|
8596 |
+
if (l < doc.first || l >= doc.first + doc.size) { return false }
|
8597 |
+
pos = new Pos(l, pos.ch, pos.sticky)
|
8598 |
+
return lineObj = getLine(doc, l)
|
8599 |
+
}
|
8600 |
+
function moveOnce(boundToLine) {
|
8601 |
+
var next
|
8602 |
+
if (visually) {
|
8603 |
+
next = moveVisually(doc.cm, lineObj, pos, dir)
|
8604 |
+
} else {
|
8605 |
+
next = moveLogically(lineObj, pos, dir)
|
8606 |
+
}
|
8607 |
+
if (next == null) {
|
8608 |
+
if (!boundToLine && findNextLine())
|
8609 |
+
{ pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir) }
|
8610 |
+
else
|
8611 |
+
{ return false }
|
8612 |
+
} else {
|
8613 |
+
pos = next
|
8614 |
+
}
|
8615 |
+
return true
|
8616 |
+
}
|
8617 |
+
|
8618 |
+
if (unit == "char") {
|
8619 |
+
moveOnce()
|
8620 |
+
} else if (unit == "column") {
|
8621 |
+
moveOnce(true)
|
8622 |
+
} else if (unit == "word" || unit == "group") {
|
8623 |
+
var sawType = null, group = unit == "group"
|
8624 |
+
var helper = doc.cm && doc.cm.getHelper(pos, "wordChars")
|
8625 |
+
for (var first = true;; first = false) {
|
8626 |
+
if (dir < 0 && !moveOnce(!first)) { break }
|
8627 |
+
var cur = lineObj.text.charAt(pos.ch) || "\n"
|
8628 |
+
var type = isWordChar(cur, helper) ? "w"
|
8629 |
+
: group && cur == "\n" ? "n"
|
8630 |
+
: !group || /\s/.test(cur) ? null
|
8631 |
+
: "p"
|
8632 |
+
if (group && !first && !type) { type = "s" }
|
8633 |
+
if (sawType && sawType != type) {
|
8634 |
+
if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after"}
|
8635 |
+
break
|
8636 |
+
}
|
8637 |
+
|
8638 |
+
if (type) { sawType = type }
|
8639 |
+
if (dir > 0 && !moveOnce(!first)) { break }
|
8640 |
+
}
|
8641 |
+
}
|
8642 |
+
var result = skipAtomic(doc, pos, oldPos, origDir, true)
|
8643 |
+
if (equalCursorPos(oldPos, result)) { result.hitSide = true }
|
8644 |
+
return result
|
8645 |
+
}
|
8646 |
+
|
8647 |
+
// For relative vertical movement. Dir may be -1 or 1. Unit can be
|
8648 |
+
// "page" or "line". The resulting position will have a hitSide=true
|
8649 |
+
// property if it reached the end of the document.
|
8650 |
+
function findPosV(cm, pos, dir, unit) {
|
8651 |
+
var doc = cm.doc, x = pos.left, y
|
8652 |
+
if (unit == "page") {
|
8653 |
+
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight)
|
8654 |
+
var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3)
|
8655 |
+
y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount
|
8656 |
+
|
8657 |
+
} else if (unit == "line") {
|
8658 |
+
y = dir > 0 ? pos.bottom + 3 : pos.top - 3
|
8659 |
+
}
|
8660 |
+
var target
|
8661 |
+
for (;;) {
|
8662 |
+
target = coordsChar(cm, x, y)
|
8663 |
+
if (!target.outside) { break }
|
8664 |
+
if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }
|
8665 |
+
y += dir * 5
|
8666 |
+
}
|
8667 |
+
return target
|
8668 |
+
}
|
8669 |
+
|
8670 |
+
// CONTENTEDITABLE INPUT STYLE
|
8671 |
+
|
8672 |
+
var ContentEditableInput = function(cm) {
|
8673 |
+
this.cm = cm
|
8674 |
+
this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null
|
8675 |
+
this.polling = new Delayed()
|
8676 |
+
this.composing = null
|
8677 |
+
this.gracePeriod = false
|
8678 |
+
this.readDOMTimeout = null
|
8679 |
+
};
|
8680 |
+
|
8681 |
+
ContentEditableInput.prototype.init = function (display) {
|
8682 |
+
var this$1 = this;
|
8683 |
+
|
8684 |
+
var input = this, cm = input.cm
|
8685 |
+
var div = input.div = display.lineDiv
|
8686 |
+
disableBrowserMagic(div, cm.options.spellcheck)
|
8687 |
+
|
8688 |
+
on(div, "paste", function (e) {
|
8689 |
+
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
|
8690 |
+
// IE doesn't fire input events, so we schedule a read for the pasted content in this way
|
8691 |
+
if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20) }
|
8692 |
+
})
|
8693 |
+
|
8694 |
+
on(div, "compositionstart", function (e) {
|
8695 |
+
this$1.composing = {data: e.data, done: false}
|
8696 |
+
})
|
8697 |
+
on(div, "compositionupdate", function (e) {
|
8698 |
+
if (!this$1.composing) { this$1.composing = {data: e.data, done: false} }
|
8699 |
+
})
|
8700 |
+
on(div, "compositionend", function (e) {
|
8701 |
+
if (this$1.composing) {
|
8702 |
+
if (e.data != this$1.composing.data) { this$1.readFromDOMSoon() }
|
8703 |
+
this$1.composing.done = true
|
8704 |
+
}
|
8705 |
+
})
|
8706 |
+
|
8707 |
+
on(div, "touchstart", function () { return input.forceCompositionEnd(); })
|
8708 |
+
|
8709 |
+
on(div, "input", function () {
|
8710 |
+
if (!this$1.composing) { this$1.readFromDOMSoon() }
|
8711 |
+
})
|
8712 |
+
|
8713 |
+
function onCopyCut(e) {
|
8714 |
+
if (signalDOMEvent(cm, e)) { return }
|
8715 |
+
if (cm.somethingSelected()) {
|
8716 |
+
setLastCopied({lineWise: false, text: cm.getSelections()})
|
8717 |
+
if (e.type == "cut") { cm.replaceSelection("", null, "cut") }
|
8718 |
+
} else if (!cm.options.lineWiseCopyCut) {
|
8719 |
+
return
|
8720 |
+
} else {
|
8721 |
+
var ranges = copyableRanges(cm)
|
8722 |
+
setLastCopied({lineWise: true, text: ranges.text})
|
8723 |
+
if (e.type == "cut") {
|
8724 |
+
cm.operation(function () {
|
8725 |
+
cm.setSelections(ranges.ranges, 0, sel_dontScroll)
|
8726 |
+
cm.replaceSelection("", null, "cut")
|
8727 |
+
})
|
8728 |
+
}
|
8729 |
+
}
|
8730 |
+
if (e.clipboardData) {
|
8731 |
+
e.clipboardData.clearData()
|
8732 |
+
var content = lastCopied.text.join("\n")
|
8733 |
+
// iOS exposes the clipboard API, but seems to discard content inserted into it
|
8734 |
+
e.clipboardData.setData("Text", content)
|
8735 |
+
if (e.clipboardData.getData("Text") == content) {
|
8736 |
+
e.preventDefault()
|
8737 |
+
return
|
8738 |
+
}
|
8739 |
+
}
|
8740 |
+
// Old-fashioned briefly-focus-a-textarea hack
|
8741 |
+
var kludge = hiddenTextarea(), te = kludge.firstChild
|
8742 |
+
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild)
|
8743 |
+
te.value = lastCopied.text.join("\n")
|
8744 |
+
var hadFocus = document.activeElement
|
8745 |
+
selectInput(te)
|
8746 |
+
setTimeout(function () {
|
8747 |
+
cm.display.lineSpace.removeChild(kludge)
|
8748 |
+
hadFocus.focus()
|
8749 |
+
if (hadFocus == div) { input.showPrimarySelection() }
|
8750 |
+
}, 50)
|
8751 |
+
}
|
8752 |
+
on(div, "copy", onCopyCut)
|
8753 |
+
on(div, "cut", onCopyCut)
|
8754 |
+
};
|
8755 |
+
|
8756 |
+
ContentEditableInput.prototype.prepareSelection = function () {
|
8757 |
+
var result = prepareSelection(this.cm, false)
|
8758 |
+
result.focus = this.cm.state.focused
|
8759 |
+
return result
|
8760 |
+
};
|
8761 |
+
|
8762 |
+
ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
|
8763 |
+
if (!info || !this.cm.display.view.length) { return }
|
8764 |
+
if (info.focus || takeFocus) { this.showPrimarySelection() }
|
8765 |
+
this.showMultipleSelections(info)
|
8766 |
+
};
|
8767 |
+
|
8768 |
+
ContentEditableInput.prototype.getSelection = function () {
|
8769 |
+
return this.cm.display.wrapper.ownerDocument.getSelection()
|
8770 |
+
};
|
8771 |
+
|
8772 |
+
ContentEditableInput.prototype.showPrimarySelection = function () {
|
8773 |
+
var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary()
|
8774 |
+
var from = prim.from(), to = prim.to()
|
8775 |
+
|
8776 |
+
if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
|
8777 |
+
sel.removeAllRanges()
|
8778 |
+
return
|
8779 |
+
}
|
8780 |
+
|
8781 |
+
var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)
|
8782 |
+
var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset)
|
8783 |
+
if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
|
8784 |
+
cmp(minPos(curAnchor, curFocus), from) == 0 &&
|
8785 |
+
cmp(maxPos(curAnchor, curFocus), to) == 0)
|
8786 |
+
{ return }
|
8787 |
+
|
8788 |
+
var view = cm.display.view
|
8789 |
+
var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) ||
|
8790 |
+
{node: view[0].measure.map[2], offset: 0}
|
8791 |
+
var end = to.line < cm.display.viewTo && posToDOM(cm, to)
|
8792 |
+
if (!end) {
|
8793 |
+
var measure = view[view.length - 1].measure
|
8794 |
+
var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map
|
8795 |
+
end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}
|
8796 |
+
}
|
8797 |
+
|
8798 |
+
if (!start || !end) {
|
8799 |
+
sel.removeAllRanges()
|
8800 |
+
return
|
8801 |
+
}
|
8802 |
+
|
8803 |
+
var old = sel.rangeCount && sel.getRangeAt(0), rng
|
8804 |
+
try { rng = range(start.node, start.offset, end.offset, end.node) }
|
8805 |
+
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
8806 |
+
if (rng) {
|
8807 |
+
if (!gecko && cm.state.focused) {
|
8808 |
+
sel.collapse(start.node, start.offset)
|
8809 |
+
if (!rng.collapsed) {
|
8810 |
+
sel.removeAllRanges()
|
8811 |
+
sel.addRange(rng)
|
8812 |
+
}
|
8813 |
+
} else {
|
8814 |
+
sel.removeAllRanges()
|
8815 |
+
sel.addRange(rng)
|
8816 |
+
}
|
8817 |
+
if (old && sel.anchorNode == null) { sel.addRange(old) }
|
8818 |
+
else if (gecko) { this.startGracePeriod() }
|
8819 |
+
}
|
8820 |
+
this.rememberSelection()
|
8821 |
+
};
|
8822 |
+
|
8823 |
+
ContentEditableInput.prototype.startGracePeriod = function () {
|
8824 |
+
var this$1 = this;
|
8825 |
+
|
8826 |
+
clearTimeout(this.gracePeriod)
|
8827 |
+
this.gracePeriod = setTimeout(function () {
|
8828 |
+
this$1.gracePeriod = false
|
8829 |
+
if (this$1.selectionChanged())
|
8830 |
+
{ this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }) }
|
8831 |
+
}, 20)
|
8832 |
+
};
|
8833 |
+
|
8834 |
+
ContentEditableInput.prototype.showMultipleSelections = function (info) {
|
8835 |
+
removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors)
|
8836 |
+
removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection)
|
8837 |
+
};
|
8838 |
+
|
8839 |
+
ContentEditableInput.prototype.rememberSelection = function () {
|
8840 |
+
var sel = this.getSelection()
|
8841 |
+
this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset
|
8842 |
+
this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset
|
8843 |
+
};
|
8844 |
+
|
8845 |
+
ContentEditableInput.prototype.selectionInEditor = function () {
|
8846 |
+
var sel = this.getSelection()
|
8847 |
+
if (!sel.rangeCount) { return false }
|
8848 |
+
var node = sel.getRangeAt(0).commonAncestorContainer
|
8849 |
+
return contains(this.div, node)
|
8850 |
+
};
|
8851 |
+
|
8852 |
+
ContentEditableInput.prototype.focus = function () {
|
8853 |
+
if (this.cm.options.readOnly != "nocursor") {
|
8854 |
+
if (!this.selectionInEditor())
|
8855 |
+
{ this.showSelection(this.prepareSelection(), true) }
|
8856 |
+
this.div.focus()
|
8857 |
+
}
|
8858 |
+
};
|
8859 |
+
ContentEditableInput.prototype.blur = function () { this.div.blur() };
|
8860 |
+
ContentEditableInput.prototype.getField = function () { return this.div };
|
8861 |
+
|
8862 |
+
ContentEditableInput.prototype.supportsTouch = function () { return true };
|
8863 |
+
|
8864 |
+
ContentEditableInput.prototype.receivedFocus = function () {
|
8865 |
+
var input = this
|
8866 |
+
if (this.selectionInEditor())
|
8867 |
+
{ this.pollSelection() }
|
8868 |
+
else
|
8869 |
+
{ runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }) }
|
8870 |
+
|
8871 |
+
function poll() {
|
8872 |
+
if (input.cm.state.focused) {
|
8873 |
+
input.pollSelection()
|
8874 |
+
input.polling.set(input.cm.options.pollInterval, poll)
|
8875 |
+
}
|
8876 |
+
}
|
8877 |
+
this.polling.set(this.cm.options.pollInterval, poll)
|
8878 |
+
};
|
8879 |
+
|
8880 |
+
ContentEditableInput.prototype.selectionChanged = function () {
|
8881 |
+
var sel = this.getSelection()
|
8882 |
+
return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
|
8883 |
+
sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
|
8884 |
+
};
|
8885 |
+
|
8886 |
+
ContentEditableInput.prototype.pollSelection = function () {
|
8887 |
+
if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return }
|
8888 |
+
var sel = this.getSelection(), cm = this.cm
|
8889 |
+
// On Android Chrome (version 56, at least), backspacing into an
|
8890 |
+
// uneditable block element will put the cursor in that element,
|
8891 |
+
// and then, because it's not editable, hide the virtual keyboard.
|
8892 |
+
// Because Android doesn't allow us to actually detect backspace
|
8893 |
+
// presses in a sane way, this code checks for when that happens
|
8894 |
+
// and simulates a backspace press in this case.
|
8895 |
+
if (android && chrome && this.cm.options.gutters.length && isInGutter(sel.anchorNode)) {
|
8896 |
+
this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs})
|
8897 |
+
this.blur()
|
8898 |
+
this.focus()
|
8899 |
+
return
|
8900 |
+
}
|
8901 |
+
if (this.composing) { return }
|
8902 |
+
this.rememberSelection()
|
8903 |
+
var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)
|
8904 |
+
var head = domToPos(cm, sel.focusNode, sel.focusOffset)
|
8905 |
+
if (anchor && head) { runInOp(cm, function () {
|
8906 |
+
setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll)
|
8907 |
+
if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true }
|
8908 |
+
}) }
|
8909 |
+
};
|
8910 |
+
|
8911 |
+
ContentEditableInput.prototype.pollContent = function () {
|
8912 |
+
if (this.readDOMTimeout != null) {
|
8913 |
+
clearTimeout(this.readDOMTimeout)
|
8914 |
+
this.readDOMTimeout = null
|
8915 |
+
}
|
8916 |
+
|
8917 |
+
var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary()
|
8918 |
+
var from = sel.from(), to = sel.to()
|
8919 |
+
if (from.ch == 0 && from.line > cm.firstLine())
|
8920 |
+
{ from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length) }
|
8921 |
+
if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
|
8922 |
+
{ to = Pos(to.line + 1, 0) }
|
8923 |
+
if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
|
8924 |
+
|
8925 |
+
var fromIndex, fromLine, fromNode
|
8926 |
+
if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
|
8927 |
+
fromLine = lineNo(display.view[0].line)
|
8928 |
+
fromNode = display.view[0].node
|
8929 |
+
} else {
|
8930 |
+
fromLine = lineNo(display.view[fromIndex].line)
|
8931 |
+
fromNode = display.view[fromIndex - 1].node.nextSibling
|
8932 |
+
}
|
8933 |
+
var toIndex = findViewIndex(cm, to.line)
|
8934 |
+
var toLine, toNode
|
8935 |
+
if (toIndex == display.view.length - 1) {
|
8936 |
+
toLine = display.viewTo - 1
|
8937 |
+
toNode = display.lineDiv.lastChild
|
8938 |
+
} else {
|
8939 |
+
toLine = lineNo(display.view[toIndex + 1].line) - 1
|
8940 |
+
toNode = display.view[toIndex + 1].node.previousSibling
|
8941 |
+
}
|
8942 |
+
|
8943 |
+
if (!fromNode) { return false }
|
8944 |
+
var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine))
|
8945 |
+
var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length))
|
8946 |
+
while (newText.length > 1 && oldText.length > 1) {
|
8947 |
+
if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine-- }
|
8948 |
+
else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++ }
|
8949 |
+
else { break }
|
8950 |
+
}
|
8951 |
+
|
8952 |
+
var cutFront = 0, cutEnd = 0
|
8953 |
+
var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length)
|
8954 |
+
while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
|
8955 |
+
{ ++cutFront }
|
8956 |
+
var newBot = lst(newText), oldBot = lst(oldText)
|
8957 |
+
var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
|
8958 |
+
oldBot.length - (oldText.length == 1 ? cutFront : 0))
|
8959 |
+
while (cutEnd < maxCutEnd &&
|
8960 |
+
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
|
8961 |
+
{ ++cutEnd }
|
8962 |
+
// Try to move start of change to start of selection if ambiguous
|
8963 |
+
if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {
|
8964 |
+
while (cutFront && cutFront > from.ch &&
|
8965 |
+
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
|
8966 |
+
cutFront--
|
8967 |
+
cutEnd++
|
8968 |
+
}
|
8969 |
+
}
|
8970 |
+
|
8971 |
+
newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "")
|
8972 |
+
newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "")
|
8973 |
+
|
8974 |
+
var chFrom = Pos(fromLine, cutFront)
|
8975 |
+
var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0)
|
8976 |
+
if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
|
8977 |
+
replaceRange(cm.doc, newText, chFrom, chTo, "+input")
|
8978 |
+
return true
|
8979 |
+
}
|
8980 |
+
};
|
8981 |
+
|
8982 |
+
ContentEditableInput.prototype.ensurePolled = function () {
|
8983 |
+
this.forceCompositionEnd()
|
8984 |
+
};
|
8985 |
+
ContentEditableInput.prototype.reset = function () {
|
8986 |
+
this.forceCompositionEnd()
|
8987 |
+
};
|
8988 |
+
ContentEditableInput.prototype.forceCompositionEnd = function () {
|
8989 |
+
if (!this.composing) { return }
|
8990 |
+
clearTimeout(this.readDOMTimeout)
|
8991 |
+
this.composing = null
|
8992 |
+
this.updateFromDOM()
|
8993 |
+
this.div.blur()
|
8994 |
+
this.div.focus()
|
8995 |
+
};
|
8996 |
+
ContentEditableInput.prototype.readFromDOMSoon = function () {
|
8997 |
+
var this$1 = this;
|
8998 |
+
|
8999 |
+
if (this.readDOMTimeout != null) { return }
|
9000 |
+
this.readDOMTimeout = setTimeout(function () {
|
9001 |
+
this$1.readDOMTimeout = null
|
9002 |
+
if (this$1.composing) {
|
9003 |
+
if (this$1.composing.done) { this$1.composing = null }
|
9004 |
+
else { return }
|
9005 |
+
}
|
9006 |
+
this$1.updateFromDOM()
|
9007 |
+
}, 80)
|
9008 |
+
};
|
9009 |
+
|
9010 |
+
ContentEditableInput.prototype.updateFromDOM = function () {
|
9011 |
+
var this$1 = this;
|
9012 |
+
|
9013 |
+
if (this.cm.isReadOnly() || !this.pollContent())
|
9014 |
+
{ runInOp(this.cm, function () { return regChange(this$1.cm); }) }
|
9015 |
+
};
|
9016 |
+
|
9017 |
+
ContentEditableInput.prototype.setUneditable = function (node) {
|
9018 |
+
node.contentEditable = "false"
|
9019 |
+
};
|
9020 |
+
|
9021 |
+
ContentEditableInput.prototype.onKeyPress = function (e) {
|
9022 |
+
if (e.charCode == 0 || this.composing) { return }
|
9023 |
+
e.preventDefault()
|
9024 |
+
if (!this.cm.isReadOnly())
|
9025 |
+
{ operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }
|
9026 |
+
};
|
9027 |
+
|
9028 |
+
ContentEditableInput.prototype.readOnlyChanged = function (val) {
|
9029 |
+
this.div.contentEditable = String(val != "nocursor")
|
9030 |
+
};
|
9031 |
+
|
9032 |
+
ContentEditableInput.prototype.onContextMenu = function () {};
|
9033 |
+
ContentEditableInput.prototype.resetPosition = function () {};
|
9034 |
+
|
9035 |
+
ContentEditableInput.prototype.needsContentAttribute = true
|
9036 |
+
|
9037 |
+
function posToDOM(cm, pos) {
|
9038 |
+
var view = findViewForLine(cm, pos.line)
|
9039 |
+
if (!view || view.hidden) { return null }
|
9040 |
+
var line = getLine(cm.doc, pos.line)
|
9041 |
+
var info = mapFromLineView(view, line, pos.line)
|
9042 |
+
|
9043 |
+
var order = getOrder(line, cm.doc.direction), side = "left"
|
9044 |
+
if (order) {
|
9045 |
+
var partPos = getBidiPartAt(order, pos.ch)
|
9046 |
+
side = partPos % 2 ? "right" : "left"
|
9047 |
+
}
|
9048 |
+
var result = nodeAndOffsetInLineMap(info.map, pos.ch, side)
|
9049 |
+
result.offset = result.collapse == "right" ? result.end : result.start
|
9050 |
+
return result
|
9051 |
+
}
|
9052 |
+
|
9053 |
+
function isInGutter(node) {
|
9054 |
+
for (var scan = node; scan; scan = scan.parentNode)
|
9055 |
+
{ if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } }
|
9056 |
+
return false
|
9057 |
+
}
|
9058 |
+
|
9059 |
+
function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
|
9060 |
+
|
9061 |
+
function domTextBetween(cm, from, to, fromLine, toLine) {
|
9062 |
+
var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false
|
9063 |
+
function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
|
9064 |
+
function close() {
|
9065 |
+
if (closing) {
|
9066 |
+
text += lineSep
|
9067 |
+
if (extraLinebreak) { text += lineSep }
|
9068 |
+
closing = extraLinebreak = false
|
9069 |
+
}
|
9070 |
+
}
|
9071 |
+
function addText(str) {
|
9072 |
+
if (str) {
|
9073 |
+
close()
|
9074 |
+
text += str
|
9075 |
+
}
|
9076 |
+
}
|
9077 |
+
function walk(node) {
|
9078 |
+
if (node.nodeType == 1) {
|
9079 |
+
var cmText = node.getAttribute("cm-text")
|
9080 |
+
if (cmText) {
|
9081 |
+
addText(cmText)
|
9082 |
+
return
|
9083 |
+
}
|
9084 |
+
var markerID = node.getAttribute("cm-marker"), range
|
9085 |
+
if (markerID) {
|
9086 |
+
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
|
9087 |
+
if (found.length && (range = found[0].find(0)))
|
9088 |
+
{ addText(getBetween(cm.doc, range.from, range.to).join(lineSep)) }
|
9089 |
+
return
|
9090 |
+
}
|
9091 |
+
if (node.getAttribute("contenteditable") == "false") { return }
|
9092 |
+
var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName)
|
9093 |
+
if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return }
|
9094 |
+
|
9095 |
+
if (isBlock) { close() }
|
9096 |
+
for (var i = 0; i < node.childNodes.length; i++)
|
9097 |
+
{ walk(node.childNodes[i]) }
|
9098 |
+
|
9099 |
+
if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true }
|
9100 |
+
if (isBlock) { closing = true }
|
9101 |
+
} else if (node.nodeType == 3) {
|
9102 |
+
addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "))
|
9103 |
+
}
|
9104 |
+
}
|
9105 |
+
for (;;) {
|
9106 |
+
walk(from)
|
9107 |
+
if (from == to) { break }
|
9108 |
+
from = from.nextSibling
|
9109 |
+
extraLinebreak = false
|
9110 |
+
}
|
9111 |
+
return text
|
9112 |
+
}
|
9113 |
+
|
9114 |
+
function domToPos(cm, node, offset) {
|
9115 |
+
var lineNode
|
9116 |
+
if (node == cm.display.lineDiv) {
|
9117 |
+
lineNode = cm.display.lineDiv.childNodes[offset]
|
9118 |
+
if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }
|
9119 |
+
node = null; offset = 0
|
9120 |
+
} else {
|
9121 |
+
for (lineNode = node;; lineNode = lineNode.parentNode) {
|
9122 |
+
if (!lineNode || lineNode == cm.display.lineDiv) { return null }
|
9123 |
+
if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }
|
9124 |
+
}
|
9125 |
+
}
|
9126 |
+
for (var i = 0; i < cm.display.view.length; i++) {
|
9127 |
+
var lineView = cm.display.view[i]
|
9128 |
+
if (lineView.node == lineNode)
|
9129 |
+
{ return locateNodeInLineView(lineView, node, offset) }
|
9130 |
+
}
|
9131 |
+
}
|
9132 |
+
|
9133 |
+
function locateNodeInLineView(lineView, node, offset) {
|
9134 |
+
var wrapper = lineView.text.firstChild, bad = false
|
9135 |
+
if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
|
9136 |
+
if (node == wrapper) {
|
9137 |
+
bad = true
|
9138 |
+
node = wrapper.childNodes[offset]
|
9139 |
+
offset = 0
|
9140 |
+
if (!node) {
|
9141 |
+
var line = lineView.rest ? lst(lineView.rest) : lineView.line
|
9142 |
+
return badPos(Pos(lineNo(line), line.text.length), bad)
|
9143 |
+
}
|
9144 |
+
}
|
9145 |
+
|
9146 |
+
var textNode = node.nodeType == 3 ? node : null, topNode = node
|
9147 |
+
if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
|
9148 |
+
textNode = node.firstChild
|
9149 |
+
if (offset) { offset = textNode.nodeValue.length }
|
9150 |
+
}
|
9151 |
+
while (topNode.parentNode != wrapper) { topNode = topNode.parentNode }
|
9152 |
+
var measure = lineView.measure, maps = measure.maps
|
9153 |
+
|
9154 |
+
function find(textNode, topNode, offset) {
|
9155 |
+
for (var i = -1; i < (maps ? maps.length : 0); i++) {
|
9156 |
+
var map = i < 0 ? measure.map : maps[i]
|
9157 |
+
for (var j = 0; j < map.length; j += 3) {
|
9158 |
+
var curNode = map[j + 2]
|
9159 |
+
if (curNode == textNode || curNode == topNode) {
|
9160 |
+
var line = lineNo(i < 0 ? lineView.line : lineView.rest[i])
|
9161 |
+
var ch = map[j] + offset
|
9162 |
+
if (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)] }
|
9163 |
+
return Pos(line, ch)
|
9164 |
+
}
|
9165 |
+
}
|
9166 |
+
}
|
9167 |
+
}
|
9168 |
+
var found = find(textNode, topNode, offset)
|
9169 |
+
if (found) { return badPos(found, bad) }
|
9170 |
+
|
9171 |
+
// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
|
9172 |
+
for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
|
9173 |
+
found = find(after, after.firstChild, 0)
|
9174 |
+
if (found)
|
9175 |
+
{ return badPos(Pos(found.line, found.ch - dist), bad) }
|
9176 |
+
else
|
9177 |
+
{ dist += after.textContent.length }
|
9178 |
+
}
|
9179 |
+
for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
|
9180 |
+
found = find(before, before.firstChild, -1)
|
9181 |
+
if (found)
|
9182 |
+
{ return badPos(Pos(found.line, found.ch + dist$1), bad) }
|
9183 |
+
else
|
9184 |
+
{ dist$1 += before.textContent.length }
|
9185 |
+
}
|
9186 |
+
}
|
9187 |
+
|
9188 |
+
// TEXTAREA INPUT STYLE
|
9189 |
+
|
9190 |
+
var TextareaInput = function(cm) {
|
9191 |
+
this.cm = cm
|
9192 |
+
// See input.poll and input.reset
|
9193 |
+
this.prevInput = ""
|
9194 |
+
|
9195 |
+
// Flag that indicates whether we expect input to appear real soon
|
9196 |
+
// now (after some event like 'keypress' or 'input') and are
|
9197 |
+
// polling intensively.
|
9198 |
+
this.pollingFast = false
|
9199 |
+
// Self-resetting timeout for the poller
|
9200 |
+
this.polling = new Delayed()
|
9201 |
+
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
|
9202 |
+
this.hasSelection = false
|
9203 |
+
this.composing = null
|
9204 |
+
};
|
9205 |
+
|
9206 |
+
TextareaInput.prototype.init = function (display) {
|
9207 |
+
var this$1 = this;
|
9208 |
+
|
9209 |
+
var input = this, cm = this.cm
|
9210 |
+
this.createField(display)
|
9211 |
+
var te = this.textarea
|
9212 |
+
|
9213 |
+
display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild)
|
9214 |
+
|
9215 |
+
// Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
|
9216 |
+
if (ios) { te.style.width = "0px" }
|
9217 |
+
|
9218 |
+
on(te, "input", function () {
|
9219 |
+
if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null }
|
9220 |
+
input.poll()
|
9221 |
+
})
|
9222 |
+
|
9223 |
+
on(te, "paste", function (e) {
|
9224 |
+
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
|
9225 |
+
|
9226 |
+
cm.state.pasteIncoming = true
|
9227 |
+
input.fastPoll()
|
9228 |
+
})
|
9229 |
+
|
9230 |
+
function prepareCopyCut(e) {
|
9231 |
+
if (signalDOMEvent(cm, e)) { return }
|
9232 |
+
if (cm.somethingSelected()) {
|
9233 |
+
setLastCopied({lineWise: false, text: cm.getSelections()})
|
9234 |
+
} else if (!cm.options.lineWiseCopyCut) {
|
9235 |
+
return
|
9236 |
+
} else {
|
9237 |
+
var ranges = copyableRanges(cm)
|
9238 |
+
setLastCopied({lineWise: true, text: ranges.text})
|
9239 |
+
if (e.type == "cut") {
|
9240 |
+
cm.setSelections(ranges.ranges, null, sel_dontScroll)
|
9241 |
+
} else {
|
9242 |
+
input.prevInput = ""
|
9243 |
+
te.value = ranges.text.join("\n")
|
9244 |
+
selectInput(te)
|
9245 |
+
}
|
9246 |
+
}
|
9247 |
+
if (e.type == "cut") { cm.state.cutIncoming = true }
|
9248 |
+
}
|
9249 |
+
on(te, "cut", prepareCopyCut)
|
9250 |
+
on(te, "copy", prepareCopyCut)
|
9251 |
+
|
9252 |
+
on(display.scroller, "paste", function (e) {
|
9253 |
+
if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
|
9254 |
+
cm.state.pasteIncoming = true
|
9255 |
+
input.focus()
|
9256 |
+
})
|
9257 |
+
|
9258 |
+
// Prevent normal selection in the editor (we handle our own)
|
9259 |
+
on(display.lineSpace, "selectstart", function (e) {
|
9260 |
+
if (!eventInWidget(display, e)) { e_preventDefault(e) }
|
9261 |
+
})
|
9262 |
+
|
9263 |
+
on(te, "compositionstart", function () {
|
9264 |
+
var start = cm.getCursor("from")
|
9265 |
+
if (input.composing) { input.composing.range.clear() }
|
9266 |
+
input.composing = {
|
9267 |
+
start: start,
|
9268 |
+
range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
|
9269 |
+
}
|
9270 |
+
})
|
9271 |
+
on(te, "compositionend", function () {
|
9272 |
+
if (input.composing) {
|
9273 |
+
input.poll()
|
9274 |
+
input.composing.range.clear()
|
9275 |
+
input.composing = null
|
9276 |
+
}
|
9277 |
+
})
|
9278 |
+
};
|
9279 |
+
|
9280 |
+
TextareaInput.prototype.createField = function (_display) {
|
9281 |
+
// Wraps and hides input textarea
|
9282 |
+
this.wrapper = hiddenTextarea()
|
9283 |
+
// The semihidden textarea that is focused when the editor is
|
9284 |
+
// focused, and receives input.
|
9285 |
+
this.textarea = this.wrapper.firstChild
|
9286 |
+
};
|
9287 |
+
|
9288 |
+
TextareaInput.prototype.prepareSelection = function () {
|
9289 |
+
// Redraw the selection and/or cursor
|
9290 |
+
var cm = this.cm, display = cm.display, doc = cm.doc
|
9291 |
+
var result = prepareSelection(cm)
|
9292 |
+
|
9293 |
+
// Move the hidden textarea near the cursor to prevent scrolling artifacts
|
9294 |
+
if (cm.options.moveInputWithCursor) {
|
9295 |
+
var headPos = cursorCoords(cm, doc.sel.primary().head, "div")
|
9296 |
+
var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect()
|
9297 |
+
result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
|
9298 |
+
headPos.top + lineOff.top - wrapOff.top))
|
9299 |
+
result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
|
9300 |
+
headPos.left + lineOff.left - wrapOff.left))
|
9301 |
+
}
|
9302 |
+
|
9303 |
+
return result
|
9304 |
+
};
|
9305 |
+
|
9306 |
+
TextareaInput.prototype.showSelection = function (drawn) {
|
9307 |
+
var cm = this.cm, display = cm.display
|
9308 |
+
removeChildrenAndAdd(display.cursorDiv, drawn.cursors)
|
9309 |
+
removeChildrenAndAdd(display.selectionDiv, drawn.selection)
|
9310 |
+
if (drawn.teTop != null) {
|
9311 |
+
this.wrapper.style.top = drawn.teTop + "px"
|
9312 |
+
this.wrapper.style.left = drawn.teLeft + "px"
|
9313 |
+
}
|
9314 |
+
};
|
9315 |
+
|
9316 |
+
// Reset the input to correspond to the selection (or to be empty,
|
9317 |
+
// when not typing and nothing is selected)
|
9318 |
+
TextareaInput.prototype.reset = function (typing) {
|
9319 |
+
if (this.contextMenuPending || this.composing) { return }
|
9320 |
+
var cm = this.cm
|
9321 |
+
if (cm.somethingSelected()) {
|
9322 |
+
this.prevInput = ""
|
9323 |
+
var content = cm.getSelection()
|
9324 |
+
this.textarea.value = content
|
9325 |
+
if (cm.state.focused) { selectInput(this.textarea) }
|
9326 |
+
if (ie && ie_version >= 9) { this.hasSelection = content }
|
9327 |
+
} else if (!typing) {
|
9328 |
+
this.prevInput = this.textarea.value = ""
|
9329 |
+
if (ie && ie_version >= 9) { this.hasSelection = null }
|
9330 |
+
}
|
9331 |
+
};
|
9332 |
+
|
9333 |
+
TextareaInput.prototype.getField = function () { return this.textarea };
|
9334 |
+
|
9335 |
+
TextareaInput.prototype.supportsTouch = function () { return false };
|
9336 |
+
|
9337 |
+
TextareaInput.prototype.focus = function () {
|
9338 |
+
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
|
9339 |
+
try { this.textarea.focus() }
|
9340 |
+
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
|
9341 |
+
}
|
9342 |
+
};
|
9343 |
+
|
9344 |
+
TextareaInput.prototype.blur = function () { this.textarea.blur() };
|
9345 |
+
|
9346 |
+
TextareaInput.prototype.resetPosition = function () {
|
9347 |
+
this.wrapper.style.top = this.wrapper.style.left = 0
|
9348 |
+
};
|
9349 |
+
|
9350 |
+
TextareaInput.prototype.receivedFocus = function () { this.slowPoll() };
|
9351 |
+
|
9352 |
+
// Poll for input changes, using the normal rate of polling. This
|
9353 |
+
// runs as long as the editor is focused.
|
9354 |
+
TextareaInput.prototype.slowPoll = function () {
|
9355 |
+
var this$1 = this;
|
9356 |
+
|
9357 |
+
if (this.pollingFast) { return }
|
9358 |
+
this.polling.set(this.cm.options.pollInterval, function () {
|
9359 |
+
this$1.poll()
|
9360 |
+
if (this$1.cm.state.focused) { this$1.slowPoll() }
|
9361 |
+
})
|
9362 |
+
};
|
9363 |
+
|
9364 |
+
// When an event has just come in that is likely to add or change
|
9365 |
+
// something in the input textarea, we poll faster, to ensure that
|
9366 |
+
// the change appears on the screen quickly.
|
9367 |
+
TextareaInput.prototype.fastPoll = function () {
|
9368 |
+
var missed = false, input = this
|
9369 |
+
input.pollingFast = true
|
9370 |
+
function p() {
|
9371 |
+
var changed = input.poll()
|
9372 |
+
if (!changed && !missed) {missed = true; input.polling.set(60, p)}
|
9373 |
+
else {input.pollingFast = false; input.slowPoll()}
|
9374 |
+
}
|
9375 |
+
input.polling.set(20, p)
|
9376 |
+
};
|
9377 |
+
|
9378 |
+
// Read input from the textarea, and update the document to match.
|
9379 |
+
// When something is selected, it is present in the textarea, and
|
9380 |
+
// selected (unless it is huge, in which case a placeholder is
|
9381 |
+
// used). When nothing is selected, the cursor sits after previously
|
9382 |
+
// seen text (can be empty), which is stored in prevInput (we must
|
9383 |
+
// not reset the textarea when typing, because that breaks IME).
|
9384 |
+
TextareaInput.prototype.poll = function () {
|
9385 |
+
var this$1 = this;
|
9386 |
+
|
9387 |
+
var cm = this.cm, input = this.textarea, prevInput = this.prevInput
|
9388 |
+
// Since this is called a *lot*, try to bail out as cheaply as
|
9389 |
+
// possible when it is clear that nothing happened. hasSelection
|
9390 |
+
// will be the case when there is a lot of text in the textarea,
|
9391 |
+
// in which case reading its value would be expensive.
|
9392 |
+
if (this.contextMenuPending || !cm.state.focused ||
|
9393 |
+
(hasSelection(input) && !prevInput && !this.composing) ||
|
9394 |
+
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
|
9395 |
+
{ return false }
|
9396 |
+
|
9397 |
+
var text = input.value
|
9398 |
+
// If nothing changed, bail.
|
9399 |
+
if (text == prevInput && !cm.somethingSelected()) { return false }
|
9400 |
+
// Work around nonsensical selection resetting in IE9/10, and
|
9401 |
+
// inexplicable appearance of private area unicode characters on
|
9402 |
+
// some key combos in Mac (#2689).
|
9403 |
+
if (ie && ie_version >= 9 && this.hasSelection === text ||
|
9404 |
+
mac && /[\uf700-\uf7ff]/.test(text)) {
|
9405 |
+
cm.display.input.reset()
|
9406 |
+
return false
|
9407 |
+
}
|
9408 |
+
|
9409 |
+
if (cm.doc.sel == cm.display.selForContextMenu) {
|
9410 |
+
var first = text.charCodeAt(0)
|
9411 |
+
if (first == 0x200b && !prevInput) { prevInput = "\u200b" }
|
9412 |
+
if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
|
9413 |
+
}
|
9414 |
+
// Find the part of the input that is actually new
|
9415 |
+
var same = 0, l = Math.min(prevInput.length, text.length)
|
9416 |
+
while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same }
|
9417 |
+
|
9418 |
+
runInOp(cm, function () {
|
9419 |
+
applyTextInput(cm, text.slice(same), prevInput.length - same,
|
9420 |
+
null, this$1.composing ? "*compose" : null)
|
9421 |
+
|
9422 |
+
// Don't leave long text in the textarea, since it makes further polling slow
|
9423 |
+
if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = "" }
|
9424 |
+
else { this$1.prevInput = text }
|
9425 |
+
|
9426 |
+
if (this$1.composing) {
|
9427 |
+
this$1.composing.range.clear()
|
9428 |
+
this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
|
9429 |
+
{className: "CodeMirror-composing"})
|
9430 |
+
}
|
9431 |
+
})
|
9432 |
+
return true
|
9433 |
+
};
|
9434 |
+
|
9435 |
+
TextareaInput.prototype.ensurePolled = function () {
|
9436 |
+
if (this.pollingFast && this.poll()) { this.pollingFast = false }
|
9437 |
+
};
|
9438 |
+
|
9439 |
+
TextareaInput.prototype.onKeyPress = function () {
|
9440 |
+
if (ie && ie_version >= 9) { this.hasSelection = null }
|
9441 |
+
this.fastPoll()
|
9442 |
+
};
|
9443 |
+
|
9444 |
+
TextareaInput.prototype.onContextMenu = function (e) {
|
9445 |
+
var input = this, cm = input.cm, display = cm.display, te = input.textarea
|
9446 |
+
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop
|
9447 |
+
if (!pos || presto) { return } // Opera is difficult.
|
9448 |
+
|
9449 |
+
// Reset the current text selection only if the click is done outside of the selection
|
9450 |
+
// and 'resetSelectionOnContextMenu' option is true.
|
9451 |
+
var reset = cm.options.resetSelectionOnContextMenu
|
9452 |
+
if (reset && cm.doc.sel.contains(pos) == -1)
|
9453 |
+
{ operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll) }
|
9454 |
+
|
9455 |
+
var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText
|
9456 |
+
input.wrapper.style.cssText = "position: absolute"
|
9457 |
+
var wrapperBox = input.wrapper.getBoundingClientRect()
|
9458 |
+
te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"
|
9459 |
+
var oldScrollY
|
9460 |
+
if (webkit) { oldScrollY = window.scrollY } // Work around Chrome issue (#2712)
|
9461 |
+
display.input.focus()
|
9462 |
+
if (webkit) { window.scrollTo(null, oldScrollY) }
|
9463 |
+
display.input.reset()
|
9464 |
+
// Adds "Select all" to context menu in FF
|
9465 |
+
if (!cm.somethingSelected()) { te.value = input.prevInput = " " }
|
9466 |
+
input.contextMenuPending = true
|
9467 |
+
display.selForContextMenu = cm.doc.sel
|
9468 |
+
clearTimeout(display.detectingSelectAll)
|
9469 |
+
|
9470 |
+
// Select-all will be greyed out if there's nothing to select, so
|
9471 |
+
// this adds a zero-width space so that we can later check whether
|
9472 |
+
// it got selected.
|
9473 |
+
function prepareSelectAllHack() {
|
9474 |
+
if (te.selectionStart != null) {
|
9475 |
+
var selected = cm.somethingSelected()
|
9476 |
+
var extval = "\u200b" + (selected ? te.value : "")
|
9477 |
+
te.value = "\u21da" // Used to catch context-menu undo
|
9478 |
+
te.value = extval
|
9479 |
+
input.prevInput = selected ? "" : "\u200b"
|
9480 |
+
te.selectionStart = 1; te.selectionEnd = extval.length
|
9481 |
+
// Re-set this, in case some other handler touched the
|
9482 |
+
// selection in the meantime.
|
9483 |
+
display.selForContextMenu = cm.doc.sel
|
9484 |
+
}
|
9485 |
+
}
|
9486 |
+
function rehide() {
|
9487 |
+
input.contextMenuPending = false
|
9488 |
+
input.wrapper.style.cssText = oldWrapperCSS
|
9489 |
+
te.style.cssText = oldCSS
|
9490 |
+
if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos) }
|
9491 |
+
|
9492 |
+
// Try to detect the user choosing select-all
|
9493 |
+
if (te.selectionStart != null) {
|
9494 |
+
if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack() }
|
9495 |
+
var i = 0, poll = function () {
|
9496 |
+
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
|
9497 |
+
te.selectionEnd > 0 && input.prevInput == "\u200b") {
|
9498 |
+
operation(cm, selectAll)(cm)
|
9499 |
+
} else if (i++ < 10) {
|
9500 |
+
display.detectingSelectAll = setTimeout(poll, 500)
|
9501 |
+
} else {
|
9502 |
+
display.selForContextMenu = null
|
9503 |
+
display.input.reset()
|
9504 |
+
}
|
9505 |
+
}
|
9506 |
+
display.detectingSelectAll = setTimeout(poll, 200)
|
9507 |
+
}
|
9508 |
+
}
|
9509 |
+
|
9510 |
+
if (ie && ie_version >= 9) { prepareSelectAllHack() }
|
9511 |
+
if (captureRightClick) {
|
9512 |
+
e_stop(e)
|
9513 |
+
var mouseup = function () {
|
9514 |
+
off(window, "mouseup", mouseup)
|
9515 |
+
setTimeout(rehide, 20)
|
9516 |
+
}
|
9517 |
+
on(window, "mouseup", mouseup)
|
9518 |
+
} else {
|
9519 |
+
setTimeout(rehide, 50)
|
9520 |
+
}
|
9521 |
+
};
|
9522 |
+
|
9523 |
+
TextareaInput.prototype.readOnlyChanged = function (val) {
|
9524 |
+
if (!val) { this.reset() }
|
9525 |
+
this.textarea.disabled = val == "nocursor"
|
9526 |
+
};
|
9527 |
+
|
9528 |
+
TextareaInput.prototype.setUneditable = function () {};
|
9529 |
+
|
9530 |
+
TextareaInput.prototype.needsContentAttribute = false
|
9531 |
+
|
9532 |
+
function fromTextArea(textarea, options) {
|
9533 |
+
options = options ? copyObj(options) : {}
|
9534 |
+
options.value = textarea.value
|
9535 |
+
if (!options.tabindex && textarea.tabIndex)
|
9536 |
+
{ options.tabindex = textarea.tabIndex }
|
9537 |
+
if (!options.placeholder && textarea.placeholder)
|
9538 |
+
{ options.placeholder = textarea.placeholder }
|
9539 |
+
// Set autofocus to true if this textarea is focused, or if it has
|
9540 |
+
// autofocus and no other element is focused.
|
9541 |
+
if (options.autofocus == null) {
|
9542 |
+
var hasFocus = activeElt()
|
9543 |
+
options.autofocus = hasFocus == textarea ||
|
9544 |
+
textarea.getAttribute("autofocus") != null && hasFocus == document.body
|
9545 |
+
}
|
9546 |
+
|
9547 |
+
function save() {textarea.value = cm.getValue()}
|
9548 |
+
|
9549 |
+
var realSubmit
|
9550 |
+
if (textarea.form) {
|
9551 |
+
on(textarea.form, "submit", save)
|
9552 |
+
// Deplorable hack to make the submit method do the right thing.
|
9553 |
+
if (!options.leaveSubmitMethodAlone) {
|
9554 |
+
var form = textarea.form
|
9555 |
+
realSubmit = form.submit
|
9556 |
+
try {
|
9557 |
+
var wrappedSubmit = form.submit = function () {
|
9558 |
+
save()
|
9559 |
+
form.submit = realSubmit
|
9560 |
+
form.submit()
|
9561 |
+
form.submit = wrappedSubmit
|
9562 |
+
}
|
9563 |
+
} catch(e) {}
|
9564 |
+
}
|
9565 |
+
}
|
9566 |
+
|
9567 |
+
options.finishInit = function (cm) {
|
9568 |
+
cm.save = save
|
9569 |
+
cm.getTextArea = function () { return textarea; }
|
9570 |
+
cm.toTextArea = function () {
|
9571 |
+
cm.toTextArea = isNaN // Prevent this from being ran twice
|
9572 |
+
save()
|
9573 |
+
textarea.parentNode.removeChild(cm.getWrapperElement())
|
9574 |
+
textarea.style.display = ""
|
9575 |
+
if (textarea.form) {
|
9576 |
+
off(textarea.form, "submit", save)
|
9577 |
+
if (typeof textarea.form.submit == "function")
|
9578 |
+
{ textarea.form.submit = realSubmit }
|
9579 |
+
}
|
9580 |
+
}
|
9581 |
+
}
|
9582 |
+
|
9583 |
+
textarea.style.display = "none"
|
9584 |
+
var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
|
9585 |
+
options)
|
9586 |
+
return cm
|
9587 |
+
}
|
9588 |
+
|
9589 |
+
function addLegacyProps(CodeMirror) {
|
9590 |
+
CodeMirror.off = off
|
9591 |
+
CodeMirror.on = on
|
9592 |
+
CodeMirror.wheelEventPixels = wheelEventPixels
|
9593 |
+
CodeMirror.Doc = Doc
|
9594 |
+
CodeMirror.splitLines = splitLinesAuto
|
9595 |
+
CodeMirror.countColumn = countColumn
|
9596 |
+
CodeMirror.findColumn = findColumn
|
9597 |
+
CodeMirror.isWordChar = isWordCharBasic
|
9598 |
+
CodeMirror.Pass = Pass
|
9599 |
+
CodeMirror.signal = signal
|
9600 |
+
CodeMirror.Line = Line
|
9601 |
+
CodeMirror.changeEnd = changeEnd
|
9602 |
+
CodeMirror.scrollbarModel = scrollbarModel
|
9603 |
+
CodeMirror.Pos = Pos
|
9604 |
+
CodeMirror.cmpPos = cmp
|
9605 |
+
CodeMirror.modes = modes
|
9606 |
+
CodeMirror.mimeModes = mimeModes
|
9607 |
+
CodeMirror.resolveMode = resolveMode
|
9608 |
+
CodeMirror.getMode = getMode
|
9609 |
+
CodeMirror.modeExtensions = modeExtensions
|
9610 |
+
CodeMirror.extendMode = extendMode
|
9611 |
+
CodeMirror.copyState = copyState
|
9612 |
+
CodeMirror.startState = startState
|
9613 |
+
CodeMirror.innerMode = innerMode
|
9614 |
+
CodeMirror.commands = commands
|
9615 |
+
CodeMirror.keyMap = keyMap
|
9616 |
+
CodeMirror.keyName = keyName
|
9617 |
+
CodeMirror.isModifierKey = isModifierKey
|
9618 |
+
CodeMirror.lookupKey = lookupKey
|
9619 |
+
CodeMirror.normalizeKeyMap = normalizeKeyMap
|
9620 |
+
CodeMirror.StringStream = StringStream
|
9621 |
+
CodeMirror.SharedTextMarker = SharedTextMarker
|
9622 |
+
CodeMirror.TextMarker = TextMarker
|
9623 |
+
CodeMirror.LineWidget = LineWidget
|
9624 |
+
CodeMirror.e_preventDefault = e_preventDefault
|
9625 |
+
CodeMirror.e_stopPropagation = e_stopPropagation
|
9626 |
+
CodeMirror.e_stop = e_stop
|
9627 |
+
CodeMirror.addClass = addClass
|
9628 |
+
CodeMirror.contains = contains
|
9629 |
+
CodeMirror.rmClass = rmClass
|
9630 |
+
CodeMirror.keyNames = keyNames
|
9631 |
+
}
|
9632 |
+
|
9633 |
+
// EDITOR CONSTRUCTOR
|
9634 |
+
|
9635 |
+
defineOptions(CodeMirror)
|
9636 |
+
|
9637 |
+
addEditorMethods(CodeMirror)
|
9638 |
+
|
9639 |
+
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
|
9640 |
+
var dontDelegate = "iter insert remove copy getEditor constructor".split(" ")
|
9641 |
+
for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
|
9642 |
+
{ CodeMirror.prototype[prop] = (function(method) {
|
9643 |
+
return function() {return method.apply(this.doc, arguments)}
|
9644 |
+
})(Doc.prototype[prop]) } }
|
9645 |
+
|
9646 |
+
eventMixin(Doc)
|
9647 |
+
|
9648 |
+
// INPUT HANDLING
|
9649 |
+
|
9650 |
+
CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}
|
9651 |
+
|
9652 |
+
// MODE DEFINITION AND QUERYING
|
9653 |
+
|
9654 |
+
// Extra arguments are stored as the mode's dependencies, which is
|
9655 |
+
// used by (legacy) mechanisms like loadmode.js to automatically
|
9656 |
+
// load a mode. (Preferred mechanism is the require/define calls.)
|
9657 |
+
CodeMirror.defineMode = function(name/*, mode, …*/) {
|
9658 |
+
if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name }
|
9659 |
+
defineMode.apply(this, arguments)
|
9660 |
+
}
|
9661 |
+
|
9662 |
+
CodeMirror.defineMIME = defineMIME
|
9663 |
+
|
9664 |
+
// Minimal default mode.
|
9665 |
+
CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); })
|
9666 |
+
CodeMirror.defineMIME("text/plain", "null")
|
9667 |
+
|
9668 |
+
// EXTENSIONS
|
9669 |
+
|
9670 |
+
CodeMirror.defineExtension = function (name, func) {
|
9671 |
+
CodeMirror.prototype[name] = func
|
9672 |
+
}
|
9673 |
+
CodeMirror.defineDocExtension = function (name, func) {
|
9674 |
+
Doc.prototype[name] = func
|
9675 |
+
}
|
9676 |
+
|
9677 |
+
CodeMirror.fromTextArea = fromTextArea
|
9678 |
+
|
9679 |
+
addLegacyProps(CodeMirror)
|
9680 |
+
|
9681 |
+
CodeMirror.version = "5.38.0"
|
9682 |
+
|
9683 |
+
return CodeMirror;
|
9684 |
+
|
9685 |
+
})));
|
inc/lib/codemirror/mode/clike/clike.js
ADDED
@@ -0,0 +1,823 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
function Context(indented, column, type, info, align, prev) {
|
15 |
+
this.indented = indented;
|
16 |
+
this.column = column;
|
17 |
+
this.type = type;
|
18 |
+
this.info = info;
|
19 |
+
this.align = align;
|
20 |
+
this.prev = prev;
|
21 |
+
}
|
22 |
+
function pushContext(state, col, type, info) {
|
23 |
+
var indent = state.indented;
|
24 |
+
if (state.context && state.context.type == "statement" && type != "statement")
|
25 |
+
indent = state.context.indented;
|
26 |
+
return state.context = new Context(indent, col, type, info, null, state.context);
|
27 |
+
}
|
28 |
+
function popContext(state) {
|
29 |
+
var t = state.context.type;
|
30 |
+
if (t == ")" || t == "]" || t == "}")
|
31 |
+
state.indented = state.context.indented;
|
32 |
+
return state.context = state.context.prev;
|
33 |
+
}
|
34 |
+
|
35 |
+
function typeBefore(stream, state, pos) {
|
36 |
+
if (state.prevToken == "variable" || state.prevToken == "type") return true;
|
37 |
+
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
|
38 |
+
if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
|
39 |
+
}
|
40 |
+
|
41 |
+
function isTopScope(context) {
|
42 |
+
for (;;) {
|
43 |
+
if (!context || context.type == "top") return true;
|
44 |
+
if (context.type == "}" && context.prev.info != "namespace") return false;
|
45 |
+
context = context.prev;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
50 |
+
var indentUnit = config.indentUnit,
|
51 |
+
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
52 |
+
dontAlignCalls = parserConfig.dontAlignCalls,
|
53 |
+
keywords = parserConfig.keywords || {},
|
54 |
+
types = parserConfig.types || {},
|
55 |
+
builtin = parserConfig.builtin || {},
|
56 |
+
blockKeywords = parserConfig.blockKeywords || {},
|
57 |
+
defKeywords = parserConfig.defKeywords || {},
|
58 |
+
atoms = parserConfig.atoms || {},
|
59 |
+
hooks = parserConfig.hooks || {},
|
60 |
+
multiLineStrings = parserConfig.multiLineStrings,
|
61 |
+
indentStatements = parserConfig.indentStatements !== false,
|
62 |
+
indentSwitch = parserConfig.indentSwitch !== false,
|
63 |
+
namespaceSeparator = parserConfig.namespaceSeparator,
|
64 |
+
isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/,
|
65 |
+
numberStart = parserConfig.numberStart || /[\d\.]/,
|
66 |
+
number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
|
67 |
+
isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
|
68 |
+
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/;
|
69 |
+
|
70 |
+
var curPunc, isDefKeyword;
|
71 |
+
|
72 |
+
function tokenBase(stream, state) {
|
73 |
+
var ch = stream.next();
|
74 |
+
if (hooks[ch]) {
|
75 |
+
var result = hooks[ch](stream, state);
|
76 |
+
if (result !== false) return result;
|
77 |
+
}
|
78 |
+
if (ch == '"' || ch == "'") {
|
79 |
+
state.tokenize = tokenString(ch);
|
80 |
+
return state.tokenize(stream, state);
|
81 |
+
}
|
82 |
+
if (isPunctuationChar.test(ch)) {
|
83 |
+
curPunc = ch;
|
84 |
+
return null;
|
85 |
+
}
|
86 |
+
if (numberStart.test(ch)) {
|
87 |
+
stream.backUp(1)
|
88 |
+
if (stream.match(number)) return "number"
|
89 |
+
stream.next()
|
90 |
+
}
|
91 |
+
if (ch == "/") {
|
92 |
+
if (stream.eat("*")) {
|
93 |
+
state.tokenize = tokenComment;
|
94 |
+
return tokenComment(stream, state);
|
95 |
+
}
|
96 |
+
if (stream.eat("/")) {
|
97 |
+
stream.skipToEnd();
|
98 |
+
return "comment";
|
99 |
+
}
|
100 |
+
}
|
101 |
+
if (isOperatorChar.test(ch)) {
|
102 |
+
while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {}
|
103 |
+
return "operator";
|
104 |
+
}
|
105 |
+
stream.eatWhile(isIdentifierChar);
|
106 |
+
if (namespaceSeparator) while (stream.match(namespaceSeparator))
|
107 |
+
stream.eatWhile(isIdentifierChar);
|
108 |
+
|
109 |
+
var cur = stream.current();
|
110 |
+
if (contains(keywords, cur)) {
|
111 |
+
if (contains(blockKeywords, cur)) curPunc = "newstatement";
|
112 |
+
if (contains(defKeywords, cur)) isDefKeyword = true;
|
113 |
+
return "keyword";
|
114 |
+
}
|
115 |
+
if (contains(types, cur)) return "type";
|
116 |
+
if (contains(builtin, cur)) {
|
117 |
+
if (contains(blockKeywords, cur)) curPunc = "newstatement";
|
118 |
+
return "builtin";
|
119 |
+
}
|
120 |
+
if (contains(atoms, cur)) return "atom";
|
121 |
+
return "variable";
|
122 |
+
}
|
123 |
+
|
124 |
+
function tokenString(quote) {
|
125 |
+
return function(stream, state) {
|
126 |
+
var escaped = false, next, end = false;
|
127 |
+
while ((next = stream.next()) != null) {
|
128 |
+
if (next == quote && !escaped) {end = true; break;}
|
129 |
+
escaped = !escaped && next == "\\";
|
130 |
+
}
|
131 |
+
if (end || !(escaped || multiLineStrings))
|
132 |
+
state.tokenize = null;
|
133 |
+
return "string";
|
134 |
+
};
|
135 |
+
}
|
136 |
+
|
137 |
+
function tokenComment(stream, state) {
|
138 |
+
var maybeEnd = false, ch;
|
139 |
+
while (ch = stream.next()) {
|
140 |
+
if (ch == "/" && maybeEnd) {
|
141 |
+
state.tokenize = null;
|
142 |
+
break;
|
143 |
+
}
|
144 |
+
maybeEnd = (ch == "*");
|
145 |
+
}
|
146 |
+
return "comment";
|
147 |
+
}
|
148 |
+
|
149 |
+
function maybeEOL(stream, state) {
|
150 |
+
if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context))
|
151 |
+
state.typeAtEndOfLine = typeBefore(stream, state, stream.pos)
|
152 |
+
}
|
153 |
+
|
154 |
+
// Interface
|
155 |
+
|
156 |
+
return {
|
157 |
+
startState: function(basecolumn) {
|
158 |
+
return {
|
159 |
+
tokenize: null,
|
160 |
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false),
|
161 |
+
indented: 0,
|
162 |
+
startOfLine: true,
|
163 |
+
prevToken: null
|
164 |
+
};
|
165 |
+
},
|
166 |
+
|
167 |
+
token: function(stream, state) {
|
168 |
+
var ctx = state.context;
|
169 |
+
if (stream.sol()) {
|
170 |
+
if (ctx.align == null) ctx.align = false;
|
171 |
+
state.indented = stream.indentation();
|
172 |
+
state.startOfLine = true;
|
173 |
+
}
|
174 |
+
if (stream.eatSpace()) { maybeEOL(stream, state); return null; }
|
175 |
+
curPunc = isDefKeyword = null;
|
176 |
+
var style = (state.tokenize || tokenBase)(stream, state);
|
177 |
+
if (style == "comment" || style == "meta") return style;
|
178 |
+
if (ctx.align == null) ctx.align = true;
|
179 |
+
|
180 |
+
if (curPunc == ";" || curPunc == ":" || (curPunc == "," && stream.match(/^\s*(?:\/\/.*)?$/, false)))
|
181 |
+
while (state.context.type == "statement") popContext(state);
|
182 |
+
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
183 |
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
184 |
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
185 |
+
else if (curPunc == "}") {
|
186 |
+
while (ctx.type == "statement") ctx = popContext(state);
|
187 |
+
if (ctx.type == "}") ctx = popContext(state);
|
188 |
+
while (ctx.type == "statement") ctx = popContext(state);
|
189 |
+
}
|
190 |
+
else if (curPunc == ctx.type) popContext(state);
|
191 |
+
else if (indentStatements &&
|
192 |
+
(((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
|
193 |
+
(ctx.type == "statement" && curPunc == "newstatement"))) {
|
194 |
+
pushContext(state, stream.column(), "statement", stream.current());
|
195 |
+
}
|
196 |
+
|
197 |
+
if (style == "variable" &&
|
198 |
+
((state.prevToken == "def" ||
|
199 |
+
(parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) &&
|
200 |
+
isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
|
201 |
+
style = "def";
|
202 |
+
|
203 |
+
if (hooks.token) {
|
204 |
+
var result = hooks.token(stream, state, style);
|
205 |
+
if (result !== undefined) style = result;
|
206 |
+
}
|
207 |
+
|
208 |
+
if (style == "def" && parserConfig.styleDefs === false) style = "variable";
|
209 |
+
|
210 |
+
state.startOfLine = false;
|
211 |
+
state.prevToken = isDefKeyword ? "def" : style || curPunc;
|
212 |
+
maybeEOL(stream, state);
|
213 |
+
return style;
|
214 |
+
},
|
215 |
+
|
216 |
+
indent: function(state, textAfter) {
|
217 |
+
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
|
218 |
+
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
219 |
+
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
220 |
+
if (parserConfig.dontIndentStatements)
|
221 |
+
while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
|
222 |
+
ctx = ctx.prev
|
223 |
+
if (hooks.indent) {
|
224 |
+
var hook = hooks.indent(state, ctx, textAfter);
|
225 |
+
if (typeof hook == "number") return hook
|
226 |
+
}
|
227 |
+
var closing = firstChar == ctx.type;
|
228 |
+
var switchBlock = ctx.prev && ctx.prev.info == "switch";
|
229 |
+
if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
|
230 |
+
while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
|
231 |
+
return ctx.indented
|
232 |
+
}
|
233 |
+
if (ctx.type == "statement")
|
234 |
+
return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
235 |
+
if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
|
236 |
+
return ctx.column + (closing ? 0 : 1);
|
237 |
+
if (ctx.type == ")" && !closing)
|
238 |
+
return ctx.indented + statementIndentUnit;
|
239 |
+
|
240 |
+
return ctx.indented + (closing ? 0 : indentUnit) +
|
241 |
+
(!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? indentUnit : 0);
|
242 |
+
},
|
243 |
+
|
244 |
+
electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/,
|
245 |
+
blockCommentStart: "/*",
|
246 |
+
blockCommentEnd: "*/",
|
247 |
+
blockCommentContinue: " * ",
|
248 |
+
lineComment: "//",
|
249 |
+
fold: "brace"
|
250 |
+
};
|
251 |
+
});
|
252 |
+
|
253 |
+
function words(str) {
|
254 |
+
var obj = {}, words = str.split(" ");
|
255 |
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
256 |
+
return obj;
|
257 |
+
}
|
258 |
+
function contains(words, word) {
|
259 |
+
if (typeof words === "function") {
|
260 |
+
return words(word);
|
261 |
+
} else {
|
262 |
+
return words.propertyIsEnumerable(word);
|
263 |
+
}
|
264 |
+
}
|
265 |
+
var cKeywords = "auto if break case register continue return default do sizeof " +
|
266 |
+
"static else struct switch extern typedef union for goto while enum const volatile";
|
267 |
+
var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t";
|
268 |
+
|
269 |
+
function cppHook(stream, state) {
|
270 |
+
if (!state.startOfLine) return false
|
271 |
+
for (var ch, next = null; ch = stream.peek();) {
|
272 |
+
if (ch == "\\" && stream.match(/^.$/)) {
|
273 |
+
next = cppHook
|
274 |
+
break
|
275 |
+
} else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) {
|
276 |
+
break
|
277 |
+
}
|
278 |
+
stream.next()
|
279 |
+
}
|
280 |
+
state.tokenize = next
|
281 |
+
return "meta"
|
282 |
+
}
|
283 |
+
|
284 |
+
function pointerHook(_stream, state) {
|
285 |
+
if (state.prevToken == "type") return "type";
|
286 |
+
return false;
|
287 |
+
}
|
288 |
+
|
289 |
+
function cpp14Literal(stream) {
|
290 |
+
stream.eatWhile(/[\w\.']/);
|
291 |
+
return "number";
|
292 |
+
}
|
293 |
+
|
294 |
+
function cpp11StringHook(stream, state) {
|
295 |
+
stream.backUp(1);
|
296 |
+
// Raw strings.
|
297 |
+
if (stream.match(/(R|u8R|uR|UR|LR)/)) {
|
298 |
+
var match = stream.match(/"([^\s\\()]{0,16})\(/);
|
299 |
+
if (!match) {
|
300 |
+
return false;
|
301 |
+
}
|
302 |
+
state.cpp11RawStringDelim = match[1];
|
303 |
+
state.tokenize = tokenRawString;
|
304 |
+
return tokenRawString(stream, state);
|
305 |
+
}
|
306 |
+
// Unicode strings/chars.
|
307 |
+
if (stream.match(/(u8|u|U|L)/)) {
|
308 |
+
if (stream.match(/["']/, /* eat */ false)) {
|
309 |
+
return "string";
|
310 |
+
}
|
311 |
+
return false;
|
312 |
+
}
|
313 |
+
// Ignore this hook.
|
314 |
+
stream.next();
|
315 |
+
return false;
|
316 |
+
}
|
317 |
+
|
318 |
+
function cppLooksLikeConstructor(word) {
|
319 |
+
var lastTwo = /(\w+)::~?(\w+)$/.exec(word);
|
320 |
+
return lastTwo && lastTwo[1] == lastTwo[2];
|
321 |
+
}
|
322 |
+
|
323 |
+
// C#-style strings where "" escapes a quote.
|
324 |
+
function tokenAtString(stream, state) {
|
325 |
+
var next;
|
326 |
+
while ((next = stream.next()) != null) {
|
327 |
+
if (next == '"' && !stream.eat('"')) {
|
328 |
+
state.tokenize = null;
|
329 |
+
break;
|
330 |
+
}
|
331 |
+
}
|
332 |
+
return "string";
|
333 |
+
}
|
334 |
+
|
335 |
+
// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
|
336 |
+
// <delim> can be a string up to 16 characters long.
|
337 |
+
function tokenRawString(stream, state) {
|
338 |
+
// Escape characters that have special regex meanings.
|
339 |
+
var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
|
340 |
+
var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
|
341 |
+
if (match)
|
342 |
+
state.tokenize = null;
|
343 |
+
else
|
344 |
+
stream.skipToEnd();
|
345 |
+
return "string";
|
346 |
+
}
|
347 |
+
|
348 |
+
function def(mimes, mode) {
|
349 |
+
if (typeof mimes == "string") mimes = [mimes];
|
350 |
+
var words = [];
|
351 |
+
function add(obj) {
|
352 |
+
if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
|
353 |
+
words.push(prop);
|
354 |
+
}
|
355 |
+
add(mode.keywords);
|
356 |
+
add(mode.types);
|
357 |
+
add(mode.builtin);
|
358 |
+
add(mode.atoms);
|
359 |
+
if (words.length) {
|
360 |
+
mode.helperType = mimes[0];
|
361 |
+
CodeMirror.registerHelper("hintWords", mimes[0], words);
|
362 |
+
}
|
363 |
+
|
364 |
+
for (var i = 0; i < mimes.length; ++i)
|
365 |
+
CodeMirror.defineMIME(mimes[i], mode);
|
366 |
+
}
|
367 |
+
|
368 |
+
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
369 |
+
name: "clike",
|
370 |
+
keywords: words(cKeywords),
|
371 |
+
types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " +
|
372 |
+
"int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " +
|
373 |
+
"uint32_t uint64_t"),
|
374 |
+
blockKeywords: words("case do else for if switch while struct"),
|
375 |
+
defKeywords: words("struct"),
|
376 |
+
typeFirstDefinitions: true,
|
377 |
+
atoms: words("NULL true false"),
|
378 |
+
hooks: {"#": cppHook, "*": pointerHook},
|
379 |
+
modeProps: {fold: ["brace", "include"]}
|
380 |
+
});
|
381 |
+
|
382 |
+
def(["text/x-c++src", "text/x-c++hdr"], {
|
383 |
+
name: "clike",
|
384 |
+
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " +
|
385 |
+
"static_cast typeid catch operator template typename class friend private " +
|
386 |
+
"this using const_cast inline public throw virtual delete mutable protected " +
|
387 |
+
"alignas alignof constexpr decltype nullptr noexcept thread_local final " +
|
388 |
+
"static_assert override"),
|
389 |
+
types: words(cTypes + " bool wchar_t"),
|
390 |
+
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
391 |
+
defKeywords: words("class namespace struct enum union"),
|
392 |
+
typeFirstDefinitions: true,
|
393 |
+
atoms: words("true false NULL"),
|
394 |
+
dontIndentStatements: /^template$/,
|
395 |
+
isIdentifierChar: /[\w\$_~\xa1-\uffff]/,
|
396 |
+
hooks: {
|
397 |
+
"#": cppHook,
|
398 |
+
"*": pointerHook,
|
399 |
+
"u": cpp11StringHook,
|
400 |
+
"U": cpp11StringHook,
|
401 |
+
"L": cpp11StringHook,
|
402 |
+
"R": cpp11StringHook,
|
403 |
+
"0": cpp14Literal,
|
404 |
+
"1": cpp14Literal,
|
405 |
+
"2": cpp14Literal,
|
406 |
+
"3": cpp14Literal,
|
407 |
+
"4": cpp14Literal,
|
408 |
+
"5": cpp14Literal,
|
409 |
+
"6": cpp14Literal,
|
410 |
+
"7": cpp14Literal,
|
411 |
+
"8": cpp14Literal,
|
412 |
+
"9": cpp14Literal,
|
413 |
+
token: function(stream, state, style) {
|
414 |
+
if (style == "variable" && stream.peek() == "(" &&
|
415 |
+
(state.prevToken == ";" || state.prevToken == null ||
|
416 |
+
state.prevToken == "}") &&
|
417 |
+
cppLooksLikeConstructor(stream.current()))
|
418 |
+
return "def";
|
419 |
+
}
|
420 |
+
},
|
421 |
+
namespaceSeparator: "::",
|
422 |
+
modeProps: {fold: ["brace", "include"]}
|
423 |
+
});
|
424 |
+
|
425 |
+
def("text/x-java", {
|
426 |
+
name: "clike",
|
427 |
+
keywords: words("abstract assert break case catch class const continue default " +
|
428 |
+
"do else enum extends final finally float for goto if implements import " +
|
429 |
+
"instanceof interface native new package private protected public " +
|
430 |
+
"return static strictfp super switch synchronized this throw throws transient " +
|
431 |
+
"try volatile while @interface"),
|
432 |
+
types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " +
|
433 |
+
"Integer Long Number Object Short String StringBuffer StringBuilder Void"),
|
434 |
+
blockKeywords: words("catch class do else finally for if switch try while"),
|
435 |
+
defKeywords: words("class interface enum @interface"),
|
436 |
+
typeFirstDefinitions: true,
|
437 |
+
atoms: words("true false null"),
|
438 |
+
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
|
439 |
+
hooks: {
|
440 |
+
"@": function(stream) {
|
441 |
+
// Don't match the @interface keyword.
|
442 |
+
if (stream.match('interface', false)) return false;
|
443 |
+
|
444 |
+
stream.eatWhile(/[\w\$_]/);
|
445 |
+
return "meta";
|
446 |
+
}
|
447 |
+
},
|
448 |
+
modeProps: {fold: ["brace", "import"]}
|
449 |
+
});
|
450 |
+
|
451 |
+
def("text/x-csharp", {
|
452 |
+
name: "clike",
|
453 |
+
keywords: words("abstract as async await base break case catch checked class const continue" +
|
454 |
+
" default delegate do else enum event explicit extern finally fixed for" +
|
455 |
+
" foreach goto if implicit in interface internal is lock namespace new" +
|
456 |
+
" operator out override params private protected public readonly ref return sealed" +
|
457 |
+
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
458 |
+
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
459 |
+
" global group into join let orderby partial remove select set value var yield"),
|
460 |
+
types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" +
|
461 |
+
" Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" +
|
462 |
+
" UInt64 bool byte char decimal double short int long object" +
|
463 |
+
" sbyte float string ushort uint ulong"),
|
464 |
+
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
465 |
+
defKeywords: words("class interface namespace struct var"),
|
466 |
+
typeFirstDefinitions: true,
|
467 |
+
atoms: words("true false null"),
|
468 |
+
hooks: {
|
469 |
+
"@": function(stream, state) {
|
470 |
+
if (stream.eat('"')) {
|
471 |
+
state.tokenize = tokenAtString;
|
472 |
+
return tokenAtString(stream, state);
|
473 |
+
}
|
474 |
+
stream.eatWhile(/[\w\$_]/);
|
475 |
+
return "meta";
|
476 |
+
}
|
477 |
+
}
|
478 |
+
});
|
479 |
+
|
480 |
+
function tokenTripleString(stream, state) {
|
481 |
+
var escaped = false;
|
482 |
+
while (!stream.eol()) {
|
483 |
+
if (!escaped && stream.match('"""')) {
|
484 |
+
state.tokenize = null;
|
485 |
+
break;
|
486 |
+
}
|
487 |
+
escaped = stream.next() == "\\" && !escaped;
|
488 |
+
}
|
489 |
+
return "string";
|
490 |
+
}
|
491 |
+
|
492 |
+
function tokenNestedComment(depth) {
|
493 |
+
return function (stream, state) {
|
494 |
+
var ch
|
495 |
+
while (ch = stream.next()) {
|
496 |
+
if (ch == "*" && stream.eat("/")) {
|
497 |
+
if (depth == 1) {
|
498 |
+
state.tokenize = null
|
499 |
+
break
|
500 |
+
} else {
|
501 |
+
state.tokenize = tokenNestedComment(depth - 1)
|
502 |
+
return state.tokenize(stream, state)
|
503 |
+
}
|
504 |
+
} else if (ch == "/" && stream.eat("*")) {
|
505 |
+
state.tokenize = tokenNestedComment(depth + 1)
|
506 |
+
return state.tokenize(stream, state)
|
507 |
+
}
|
508 |
+
}
|
509 |
+
return "comment"
|
510 |
+
}
|
511 |
+
}
|
512 |
+
|
513 |
+
def("text/x-scala", {
|
514 |
+
name: "clike",
|
515 |
+
keywords: words(
|
516 |
+
|
517 |
+
/* scala */
|
518 |
+
"abstract case catch class def do else extends final finally for forSome if " +
|
519 |
+
"implicit import lazy match new null object override package private protected return " +
|
520 |
+
"sealed super this throw trait try type val var while with yield _ " +
|
521 |
+
|
522 |
+
/* package scala */
|
523 |
+
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
524 |
+
"readChar readInt readLong readFloat readDouble"
|
525 |
+
),
|
526 |
+
types: words(
|
527 |
+
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
528 |
+
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Integral Iterable " +
|
529 |
+
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
530 |
+
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
531 |
+
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +
|
532 |
+
|
533 |
+
/* package java.lang */
|
534 |
+
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
535 |
+
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
536 |
+
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
537 |
+
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
538 |
+
),
|
539 |
+
multiLineStrings: true,
|
540 |
+
blockKeywords: words("catch class enum do else finally for forSome if match switch try while"),
|
541 |
+
defKeywords: words("class enum def object package trait type val var"),
|
542 |
+
atoms: words("true false null"),
|
543 |
+
indentStatements: false,
|
544 |
+
indentSwitch: false,
|
545 |
+
isOperatorChar: /[+\-*&%=<>!?|\/#:@]/,
|
546 |
+
hooks: {
|
547 |
+
"@": function(stream) {
|
548 |
+
stream.eatWhile(/[\w\$_]/);
|
549 |
+
return "meta";
|
550 |
+
},
|
551 |
+
'"': function(stream, state) {
|
552 |
+
if (!stream.match('""')) return false;
|
553 |
+
state.tokenize = tokenTripleString;
|
554 |
+
return state.tokenize(stream, state);
|
555 |
+
},
|
556 |
+
"'": function(stream) {
|
557 |
+
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
558 |
+
return "atom";
|
559 |
+
},
|
560 |
+
"=": function(stream, state) {
|
561 |
+
var cx = state.context
|
562 |
+
if (cx.type == "}" && cx.align && stream.eat(">")) {
|
563 |
+
state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev)
|
564 |
+
return "operator"
|
565 |
+
} else {
|
566 |
+
return false
|
567 |
+
}
|
568 |
+
},
|
569 |
+
|
570 |
+
"/": function(stream, state) {
|
571 |
+
if (!stream.eat("*")) return false
|
572 |
+
state.tokenize = tokenNestedComment(1)
|
573 |
+
return state.tokenize(stream, state)
|
574 |
+
}
|
575 |
+
},
|
576 |
+
modeProps: {closeBrackets: {triples: '"'}}
|
577 |
+
});
|
578 |
+
|
579 |
+
function tokenKotlinString(tripleString){
|
580 |
+
return function (stream, state) {
|
581 |
+
var escaped = false, next, end = false;
|
582 |
+
while (!stream.eol()) {
|
583 |
+
if (!tripleString && !escaped && stream.match('"') ) {end = true; break;}
|
584 |
+
if (tripleString && stream.match('"""')) {end = true; break;}
|
585 |
+
next = stream.next();
|
586 |
+
if(!escaped && next == "$" && stream.match('{'))
|
587 |
+
stream.skipTo("}");
|
588 |
+
escaped = !escaped && next == "\\" && !tripleString;
|
589 |
+
}
|
590 |
+
if (end || !tripleString)
|
591 |
+
state.tokenize = null;
|
592 |
+
return "string";
|
593 |
+
}
|
594 |
+
}
|
595 |
+
|
596 |
+
def("text/x-kotlin", {
|
597 |
+
name: "clike",
|
598 |
+
keywords: words(
|
599 |
+
/*keywords*/
|
600 |
+
"package as typealias class interface this super val operator " +
|
601 |
+
"var fun for is in This throw return annotation " +
|
602 |
+
"break continue object if else while do try when !in !is as? " +
|
603 |
+
|
604 |
+
/*soft keywords*/
|
605 |
+
"file import where by get set abstract enum open inner override private public internal " +
|
606 |
+
"protected catch finally out final vararg reified dynamic companion constructor init " +
|
607 |
+
"sealed field property receiver param sparam lateinit data inline noinline tailrec " +
|
608 |
+
"external annotation crossinline const operator infix suspend actual expect setparam"
|
609 |
+
),
|
610 |
+
types: words(
|
611 |
+
/* package java.lang */
|
612 |
+
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
613 |
+
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
614 |
+
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
615 |
+
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void Annotation Any BooleanArray " +
|
616 |
+
"ByteArray Char CharArray DeprecationLevel DoubleArray Enum FloatArray Function Int IntArray Lazy " +
|
617 |
+
"LazyThreadSafetyMode LongArray Nothing ShortArray Unit"
|
618 |
+
),
|
619 |
+
intendSwitch: false,
|
620 |
+
indentStatements: false,
|
621 |
+
multiLineStrings: true,
|
622 |
+
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+(\.\d+)?|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
|
623 |
+
blockKeywords: words("catch class do else finally for if where try while enum"),
|
624 |
+
defKeywords: words("class val var object interface fun"),
|
625 |
+
atoms: words("true false null this"),
|
626 |
+
hooks: {
|
627 |
+
"@": function(stream) {
|
628 |
+
stream.eatWhile(/[\w\$_]/);
|
629 |
+
return "meta";
|
630 |
+
},
|
631 |
+
'"': function(stream, state) {
|
632 |
+
state.tokenize = tokenKotlinString(stream.match('""'));
|
633 |
+
return state.tokenize(stream, state);
|
634 |
+
}
|
635 |
+
},
|
636 |
+
modeProps: {closeBrackets: {triples: '"'}}
|
637 |
+
});
|
638 |
+
|
639 |
+
def(["x-shader/x-vertex", "x-shader/x-fragment"], {
|
640 |
+
name: "clike",
|
641 |
+
keywords: words("sampler1D sampler2D sampler3D samplerCube " +
|
642 |
+
"sampler1DShadow sampler2DShadow " +
|
643 |
+
"const attribute uniform varying " +
|
644 |
+
"break continue discard return " +
|
645 |
+
"for while do if else struct " +
|
646 |
+
"in out inout"),
|
647 |
+
types: words("float int bool void " +
|
648 |
+
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
649 |
+
"mat2 mat3 mat4"),
|
650 |
+
blockKeywords: words("for while do if else struct"),
|
651 |
+
builtin: words("radians degrees sin cos tan asin acos atan " +
|
652 |
+
"pow exp log exp2 sqrt inversesqrt " +
|
653 |
+
"abs sign floor ceil fract mod min max clamp mix step smoothstep " +
|
654 |
+
"length distance dot cross normalize ftransform faceforward " +
|
655 |
+
"reflect refract matrixCompMult " +
|
656 |
+
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
657 |
+
"equal notEqual any all not " +
|
658 |
+
"texture1D texture1DProj texture1DLod texture1DProjLod " +
|
659 |
+
"texture2D texture2DProj texture2DLod texture2DProjLod " +
|
660 |
+
"texture3D texture3DProj texture3DLod texture3DProjLod " +
|
661 |
+
"textureCube textureCubeLod " +
|
662 |
+
"shadow1D shadow2D shadow1DProj shadow2DProj " +
|
663 |
+
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
|
664 |
+
"dFdx dFdy fwidth " +
|
665 |
+
"noise1 noise2 noise3 noise4"),
|
666 |
+
atoms: words("true false " +
|
667 |
+
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
|
668 |
+
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
|
669 |
+
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
|
670 |
+
"gl_FogCoord gl_PointCoord " +
|
671 |
+
"gl_Position gl_PointSize gl_ClipVertex " +
|
672 |
+
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
|
673 |
+
"gl_TexCoord gl_FogFragCoord " +
|
674 |
+
"gl_FragCoord gl_FrontFacing " +
|
675 |
+
"gl_FragData gl_FragDepth " +
|
676 |
+
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
|
677 |
+
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
|
678 |
+
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
|
679 |
+
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
|
680 |
+
"gl_ProjectionMatrixInverseTranspose " +
|
681 |
+
"gl_ModelViewProjectionMatrixInverseTranspose " +
|
682 |
+
"gl_TextureMatrixInverseTranspose " +
|
683 |
+
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
|
684 |
+
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
|
685 |
+
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
|
686 |
+
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
|
687 |
+
"gl_FogParameters " +
|
688 |
+
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
|
689 |
+
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
|
690 |
+
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
|
691 |
+
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
|
692 |
+
"gl_MaxDrawBuffers"),
|
693 |
+
indentSwitch: false,
|
694 |
+
hooks: {"#": cppHook},
|
695 |
+
modeProps: {fold: ["brace", "include"]}
|
696 |
+
});
|
697 |
+
|
698 |
+
def("text/x-nesc", {
|
699 |
+
name: "clike",
|
700 |
+
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
|
701 |
+
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
702 |
+
"signal task uses abstract extends"),
|
703 |
+
types: words(cTypes),
|
704 |
+
blockKeywords: words("case do else for if switch while struct"),
|
705 |
+
atoms: words("null true false"),
|
706 |
+
hooks: {"#": cppHook},
|
707 |
+
modeProps: {fold: ["brace", "include"]}
|
708 |
+
});
|
709 |
+
|
710 |
+
def("text/x-objectivec", {
|
711 |
+
name: "clike",
|
712 |
+
keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in " +
|
713 |
+
"inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),
|
714 |
+
types: words(cTypes),
|
715 |
+
atoms: words("YES NO NULL NILL ON OFF true false"),
|
716 |
+
hooks: {
|
717 |
+
"@": function(stream) {
|
718 |
+
stream.eatWhile(/[\w\$]/);
|
719 |
+
return "keyword";
|
720 |
+
},
|
721 |
+
"#": cppHook,
|
722 |
+
indent: function(_state, ctx, textAfter) {
|
723 |
+
if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented
|
724 |
+
}
|
725 |
+
},
|
726 |
+
modeProps: {fold: "brace"}
|
727 |
+
});
|
728 |
+
|
729 |
+
def("text/x-squirrel", {
|
730 |
+
name: "clike",
|
731 |
+
keywords: words("base break clone continue const default delete enum extends function in class" +
|
732 |
+
" foreach local resume return this throw typeof yield constructor instanceof static"),
|
733 |
+
types: words(cTypes),
|
734 |
+
blockKeywords: words("case catch class else for foreach if switch try while"),
|
735 |
+
defKeywords: words("function local class"),
|
736 |
+
typeFirstDefinitions: true,
|
737 |
+
atoms: words("true false null"),
|
738 |
+
hooks: {"#": cppHook},
|
739 |
+
modeProps: {fold: ["brace", "include"]}
|
740 |
+
});
|
741 |
+
|
742 |
+
// Ceylon Strings need to deal with interpolation
|
743 |
+
var stringTokenizer = null;
|
744 |
+
function tokenCeylonString(type) {
|
745 |
+
return function(stream, state) {
|
746 |
+
var escaped = false, next, end = false;
|
747 |
+
while (!stream.eol()) {
|
748 |
+
if (!escaped && stream.match('"') &&
|
749 |
+
(type == "single" || stream.match('""'))) {
|
750 |
+
end = true;
|
751 |
+
break;
|
752 |
+
}
|
753 |
+
if (!escaped && stream.match('``')) {
|
754 |
+
stringTokenizer = tokenCeylonString(type);
|
755 |
+
end = true;
|
756 |
+
break;
|
757 |
+
}
|
758 |
+
next = stream.next();
|
759 |
+
escaped = type == "single" && !escaped && next == "\\";
|
760 |
+
}
|
761 |
+
if (end)
|
762 |
+
state.tokenize = null;
|
763 |
+
return "string";
|
764 |
+
}
|
765 |
+
}
|
766 |
+
|
767 |
+
def("text/x-ceylon", {
|
768 |
+
name: "clike",
|
769 |
+
keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" +
|
770 |
+
" exists extends finally for function given if import in interface is let module new" +
|
771 |
+
" nonempty object of out outer package return satisfies super switch then this throw" +
|
772 |
+
" try value void while"),
|
773 |
+
types: function(word) {
|
774 |
+
// In Ceylon all identifiers that start with an uppercase are types
|
775 |
+
var first = word.charAt(0);
|
776 |
+
return (first === first.toUpperCase() && first !== first.toLowerCase());
|
777 |
+
},
|
778 |
+
blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"),
|
779 |
+
defKeywords: words("class dynamic function interface module object package value"),
|
780 |
+
builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" +
|
781 |
+
" native optional sealed see serializable shared suppressWarnings tagged throws variable"),
|
782 |
+
isPunctuationChar: /[\[\]{}\(\),;\:\.`]/,
|
783 |
+
isOperatorChar: /[+\-*&%=<>!?|^~:\/]/,
|
784 |
+
numberStart: /[\d#$]/,
|
785 |
+
number: /^(?:#[\da-fA-F_]+|\$[01_]+|[\d_]+[kMGTPmunpf]?|[\d_]+\.[\d_]+(?:[eE][-+]?\d+|[kMGTPmunpf]|)|)/i,
|
786 |
+
multiLineStrings: true,
|
787 |
+
typeFirstDefinitions: true,
|
788 |
+
atoms: words("true false null larger smaller equal empty finished"),
|
789 |
+
indentSwitch: false,
|
790 |
+
styleDefs: false,
|
791 |
+
hooks: {
|
792 |
+
"@": function(stream) {
|
793 |
+
stream.eatWhile(/[\w\$_]/);
|
794 |
+
return "meta";
|
795 |
+
},
|
796 |
+
'"': function(stream, state) {
|
797 |
+
state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single");
|
798 |
+
return state.tokenize(stream, state);
|
799 |
+
},
|
800 |
+
'`': function(stream, state) {
|
801 |
+
if (!stringTokenizer || !stream.match('`')) return false;
|
802 |
+
state.tokenize = stringTokenizer;
|
803 |
+
stringTokenizer = null;
|
804 |
+
return state.tokenize(stream, state);
|
805 |
+
},
|
806 |
+
"'": function(stream) {
|
807 |
+
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
808 |
+
return "atom";
|
809 |
+
},
|
810 |
+
token: function(_stream, state, style) {
|
811 |
+
if ((style == "variable" || style == "type") &&
|
812 |
+
state.prevToken == ".") {
|
813 |
+
return "variable-2";
|
814 |
+
}
|
815 |
+
}
|
816 |
+
},
|
817 |
+
modeProps: {
|
818 |
+
fold: ["brace", "import"],
|
819 |
+
closeBrackets: {triples: '"'}
|
820 |
+
}
|
821 |
+
});
|
822 |
+
|
823 |
+
});
|
inc/lib/codemirror/mode/clike/index.html
ADDED
@@ -0,0 +1,360 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: C-like mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
10 |
+
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
11 |
+
<script src="../../addon/hint/show-hint.js"></script>
|
12 |
+
<script src="clike.js"></script>
|
13 |
+
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
14 |
+
<div id=nav>
|
15 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
16 |
+
|
17 |
+
<ul>
|
18 |
+
<li><a href="../../index.html">Home</a>
|
19 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
20 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
21 |
+
</ul>
|
22 |
+
<ul>
|
23 |
+
<li><a href="../index.html">Language modes</a>
|
24 |
+
<li><a class=active href="#">C-like</a>
|
25 |
+
</ul>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<article>
|
29 |
+
<h2>C-like mode</h2>
|
30 |
+
|
31 |
+
<div><textarea id="c-code">
|
32 |
+
/* C demo code */
|
33 |
+
|
34 |
+
#include <zmq.h>
|
35 |
+
#include <pthread.h>
|
36 |
+
#include <semaphore.h>
|
37 |
+
#include <time.h>
|
38 |
+
#include <stdio.h>
|
39 |
+
#include <fcntl.h>
|
40 |
+
#include <malloc.h>
|
41 |
+
|
42 |
+
typedef struct {
|
43 |
+
void* arg_socket;
|
44 |
+
zmq_msg_t* arg_msg;
|
45 |
+
char* arg_string;
|
46 |
+
unsigned long arg_len;
|
47 |
+
int arg_int, arg_command;
|
48 |
+
|
49 |
+
int signal_fd;
|
50 |
+
int pad;
|
51 |
+
void* context;
|
52 |
+
sem_t sem;
|
53 |
+
} acl_zmq_context;
|
54 |
+
|
55 |
+
#define p(X) (context->arg_##X)
|
56 |
+
|
57 |
+
void* zmq_thread(void* context_pointer) {
|
58 |
+
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
59 |
+
char ok = 'K', err = 'X';
|
60 |
+
int res;
|
61 |
+
|
62 |
+
while (1) {
|
63 |
+
while ((res = sem_wait(&context->sem)) == EINTR);
|
64 |
+
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
65 |
+
switch(p(command)) {
|
66 |
+
case 0: goto cleanup;
|
67 |
+
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
68 |
+
case 2: p(int) = zmq_close(p(socket)); break;
|
69 |
+
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
70 |
+
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
71 |
+
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
72 |
+
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
73 |
+
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
74 |
+
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
75 |
+
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
76 |
+
}
|
77 |
+
p(command) = errno;
|
78 |
+
write(context->signal_fd, &ok, 1);
|
79 |
+
}
|
80 |
+
cleanup:
|
81 |
+
close(context->signal_fd);
|
82 |
+
free(context_pointer);
|
83 |
+
return 0;
|
84 |
+
}
|
85 |
+
|
86 |
+
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
87 |
+
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
88 |
+
pthread_t thread;
|
89 |
+
|
90 |
+
context->context = zmq_context;
|
91 |
+
context->signal_fd = signal_fd;
|
92 |
+
sem_init(&context->sem, 1, 0);
|
93 |
+
pthread_create(&thread, 0, &zmq_thread, context);
|
94 |
+
pthread_detach(thread);
|
95 |
+
return context;
|
96 |
+
}
|
97 |
+
</textarea></div>
|
98 |
+
|
99 |
+
<h2>C++ example</h2>
|
100 |
+
|
101 |
+
<div><textarea id="cpp-code">
|
102 |
+
#include <iostream>
|
103 |
+
#include "mystuff/util.h"
|
104 |
+
|
105 |
+
namespace {
|
106 |
+
enum Enum {
|
107 |
+
VAL1, VAL2, VAL3
|
108 |
+
};
|
109 |
+
|
110 |
+
char32_t unicode_string = U"\U0010FFFF";
|
111 |
+
string raw_string = R"delim(anything
|
112 |
+
you
|
113 |
+
want)delim";
|
114 |
+
|
115 |
+
int Helper(const MyType& param) {
|
116 |
+
return 0;
|
117 |
+
}
|
118 |
+
} // namespace
|
119 |
+
|
120 |
+
class ForwardDec;
|
121 |
+
|
122 |
+
template <class T, class V>
|
123 |
+
class Class : public BaseClass {
|
124 |
+
const MyType<T, V> member_;
|
125 |
+
|
126 |
+
public:
|
127 |
+
const MyType<T, V>& Method() const {
|
128 |
+
return member_;
|
129 |
+
}
|
130 |
+
|
131 |
+
void Method2(MyType<T, V>* value);
|
132 |
+
}
|
133 |
+
|
134 |
+
template <class T, class V>
|
135 |
+
void Class::Method2(MyType<T, V>* value) {
|
136 |
+
std::out << 1 >> method();
|
137 |
+
value->Method3(member_);
|
138 |
+
member_ = value;
|
139 |
+
}
|
140 |
+
</textarea></div>
|
141 |
+
|
142 |
+
<h2>Objective-C example</h2>
|
143 |
+
|
144 |
+
<div><textarea id="objectivec-code">
|
145 |
+
/*
|
146 |
+
This is a longer comment
|
147 |
+
That spans two lines
|
148 |
+
*/
|
149 |
+
|
150 |
+
#import <Test/Test.h>
|
151 |
+
@implementation YourAppDelegate
|
152 |
+
|
153 |
+
// This is a one-line comment
|
154 |
+
|
155 |
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
156 |
+
char myString[] = "This is a C character array";
|
157 |
+
int test = 5;
|
158 |
+
return YES;
|
159 |
+
}
|
160 |
+
</textarea></div>
|
161 |
+
|
162 |
+
<h2>Java example</h2>
|
163 |
+
|
164 |
+
<div><textarea id="java-code">
|
165 |
+
import com.demo.util.MyType;
|
166 |
+
import com.demo.util.MyInterface;
|
167 |
+
|
168 |
+
public enum Enum {
|
169 |
+
VAL1, VAL2, VAL3
|
170 |
+
}
|
171 |
+
|
172 |
+
public class Class<T, V> implements MyInterface {
|
173 |
+
public static final MyType<T, V> member;
|
174 |
+
|
175 |
+
private class InnerClass {
|
176 |
+
public int zero() {
|
177 |
+
return 0;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
@Override
|
182 |
+
public MyType method() {
|
183 |
+
return member;
|
184 |
+
}
|
185 |
+
|
186 |
+
public void method2(MyType<T, V> value) {
|
187 |
+
method();
|
188 |
+
value.method3();
|
189 |
+
member = value;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
</textarea></div>
|
193 |
+
|
194 |
+
<h2>Scala example</h2>
|
195 |
+
|
196 |
+
<div><textarea id="scala-code">
|
197 |
+
object FilterTest extends App {
|
198 |
+
def filter(xs: List[Int], threshold: Int) = {
|
199 |
+
def process(ys: List[Int]): List[Int] =
|
200 |
+
if (ys.isEmpty) ys
|
201 |
+
else if (ys.head < threshold) ys.head :: process(ys.tail)
|
202 |
+
else process(ys.tail)
|
203 |
+
process(xs)
|
204 |
+
}
|
205 |
+
println(filter(List(1, 9, 2, 8, 3, 7, 4), 5))
|
206 |
+
}
|
207 |
+
</textarea></div>
|
208 |
+
|
209 |
+
<h2>Kotlin mode</h2>
|
210 |
+
|
211 |
+
<div><textarea id="kotlin-code">
|
212 |
+
package org.wasabi.http
|
213 |
+
|
214 |
+
import java.util.concurrent.Executors
|
215 |
+
import java.net.InetSocketAddress
|
216 |
+
import org.wasabi.app.AppConfiguration
|
217 |
+
import io.netty.bootstrap.ServerBootstrap
|
218 |
+
import io.netty.channel.nio.NioEventLoopGroup
|
219 |
+
import io.netty.channel.socket.nio.NioServerSocketChannel
|
220 |
+
import org.wasabi.app.AppServer
|
221 |
+
|
222 |
+
public class HttpServer(private val appServer: AppServer) {
|
223 |
+
|
224 |
+
val bootstrap: ServerBootstrap
|
225 |
+
val primaryGroup: NioEventLoopGroup
|
226 |
+
val workerGroup: NioEventLoopGroup
|
227 |
+
|
228 |
+
init {
|
229 |
+
// Define worker groups
|
230 |
+
primaryGroup = NioEventLoopGroup()
|
231 |
+
workerGroup = NioEventLoopGroup()
|
232 |
+
|
233 |
+
// Initialize bootstrap of server
|
234 |
+
bootstrap = ServerBootstrap()
|
235 |
+
|
236 |
+
bootstrap.group(primaryGroup, workerGroup)
|
237 |
+
bootstrap.channel(javaClass<NioServerSocketChannel>())
|
238 |
+
bootstrap.childHandler(NettyPipelineInitializer(appServer))
|
239 |
+
}
|
240 |
+
|
241 |
+
public fun start(wait: Boolean = true) {
|
242 |
+
val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel()
|
243 |
+
|
244 |
+
if (wait) {
|
245 |
+
channel?.closeFuture()?.sync()
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
public fun stop() {
|
250 |
+
// Shutdown all event loops
|
251 |
+
primaryGroup.shutdownGracefully()
|
252 |
+
workerGroup.shutdownGracefully()
|
253 |
+
|
254 |
+
// Wait till all threads are terminated
|
255 |
+
primaryGroup.terminationFuture().sync()
|
256 |
+
workerGroup.terminationFuture().sync()
|
257 |
+
}
|
258 |
+
}
|
259 |
+
</textarea></div>
|
260 |
+
|
261 |
+
<h2>Ceylon mode</h2>
|
262 |
+
|
263 |
+
<div><textarea id="ceylon-code">
|
264 |
+
"Produces the [[stream|Iterable]] that results from repeated
|
265 |
+
application of the given [[function|next]] to the given
|
266 |
+
[[first]] element of the stream, until the function first
|
267 |
+
returns [[finished]]. If the given function never returns
|
268 |
+
`finished`, the resulting stream is infinite.
|
269 |
+
|
270 |
+
For example:
|
271 |
+
|
272 |
+
loop(0)(2.plus).takeWhile(10.largerThan)
|
273 |
+
|
274 |
+
produces the stream `{ 0, 2, 4, 6, 8 }`."
|
275 |
+
tagged("Streams")
|
276 |
+
shared {Element+} loop<Element>(
|
277 |
+
"The first element of the resulting stream."
|
278 |
+
Element first)(
|
279 |
+
"The function that produces the next element of the
|
280 |
+
stream, given the current element. The function may
|
281 |
+
return [[finished]] to indicate the end of the
|
282 |
+
stream."
|
283 |
+
Element|Finished next(Element element))
|
284 |
+
=> let (start = first)
|
285 |
+
object satisfies {Element+} {
|
286 |
+
first => start;
|
287 |
+
empty => false;
|
288 |
+
function nextElement(Element element)
|
289 |
+
=> next(element);
|
290 |
+
iterator()
|
291 |
+
=> object satisfies Iterator<Element> {
|
292 |
+
variable Element|Finished current = start;
|
293 |
+
shared actual Element|Finished next() {
|
294 |
+
if (!is Finished result = current) {
|
295 |
+
current = nextElement(result);
|
296 |
+
return result;
|
297 |
+
}
|
298 |
+
else {
|
299 |
+
return finished;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
};
|
303 |
+
};
|
304 |
+
</textarea></div>
|
305 |
+
|
306 |
+
<script>
|
307 |
+
var cEditor = CodeMirror.fromTextArea(document.getElementById("c-code"), {
|
308 |
+
lineNumbers: true,
|
309 |
+
matchBrackets: true,
|
310 |
+
mode: "text/x-csrc"
|
311 |
+
});
|
312 |
+
var cppEditor = CodeMirror.fromTextArea(document.getElementById("cpp-code"), {
|
313 |
+
lineNumbers: true,
|
314 |
+
matchBrackets: true,
|
315 |
+
mode: "text/x-c++src"
|
316 |
+
});
|
317 |
+
var javaEditor = CodeMirror.fromTextArea(document.getElementById("java-code"), {
|
318 |
+
lineNumbers: true,
|
319 |
+
matchBrackets: true,
|
320 |
+
mode: "text/x-java"
|
321 |
+
});
|
322 |
+
var objectivecEditor = CodeMirror.fromTextArea(document.getElementById("objectivec-code"), {
|
323 |
+
lineNumbers: true,
|
324 |
+
matchBrackets: true,
|
325 |
+
mode: "text/x-objectivec"
|
326 |
+
});
|
327 |
+
var scalaEditor = CodeMirror.fromTextArea(document.getElementById("scala-code"), {
|
328 |
+
lineNumbers: true,
|
329 |
+
matchBrackets: true,
|
330 |
+
mode: "text/x-scala"
|
331 |
+
});
|
332 |
+
var kotlinEditor = CodeMirror.fromTextArea(document.getElementById("kotlin-code"), {
|
333 |
+
lineNumbers: true,
|
334 |
+
matchBrackets: true,
|
335 |
+
mode: "text/x-kotlin"
|
336 |
+
});
|
337 |
+
var ceylonEditor = CodeMirror.fromTextArea(document.getElementById("ceylon-code"), {
|
338 |
+
lineNumbers: true,
|
339 |
+
matchBrackets: true,
|
340 |
+
mode: "text/x-ceylon"
|
341 |
+
});
|
342 |
+
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
|
343 |
+
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
|
344 |
+
</script>
|
345 |
+
|
346 |
+
<p>Simple mode that tries to handle C-like languages as well as it
|
347 |
+
can. Takes two configuration parameters: <code>keywords</code>, an
|
348 |
+
object whose property names are the keywords in the language,
|
349 |
+
and <code>useCPP</code>, which determines whether C preprocessor
|
350 |
+
directives are recognized.</p>
|
351 |
+
|
352 |
+
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
353 |
+
(C), <code>text/x-c++src</code> (C++), <code>text/x-java</code>
|
354 |
+
(Java), <code>text/x-csharp</code> (C#),
|
355 |
+
<code>text/x-objectivec</code> (Objective-C),
|
356 |
+
<code>text/x-scala</code> (Scala), <code>text/x-vertex</code>
|
357 |
+
<code>x-shader/x-fragment</code> (shader programs),
|
358 |
+
<code>text/x-squirrel</code> (Squirrel) and
|
359 |
+
<code>text/x-ceylon</code> (Ceylon)</p>
|
360 |
+
</article>
|
inc/lib/codemirror/mode/clike/scala.html
ADDED
@@ -0,0 +1,767 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: Scala mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<link rel="stylesheet" href="../../theme/ambiance.css">
|
9 |
+
<script src="../../lib/codemirror.js"></script>
|
10 |
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
11 |
+
<script src="clike.js"></script>
|
12 |
+
<div id=nav>
|
13 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
14 |
+
|
15 |
+
<ul>
|
16 |
+
<li><a href="../../index.html">Home</a>
|
17 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
18 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
19 |
+
</ul>
|
20 |
+
<ul>
|
21 |
+
<li><a href="../index.html">Language modes</a>
|
22 |
+
<li><a class=active href="#">Scala</a>
|
23 |
+
</ul>
|
24 |
+
</div>
|
25 |
+
|
26 |
+
<article>
|
27 |
+
<h2>Scala mode</h2>
|
28 |
+
<form>
|
29 |
+
<textarea id="code" name="code">
|
30 |
+
|
31 |
+
/* __ *\
|
32 |
+
** ________ ___ / / ___ Scala API **
|
33 |
+
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
|
34 |
+
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
35 |
+
** /____/\___/_/ |_/____/_/ | | **
|
36 |
+
** |/ **
|
37 |
+
\* */
|
38 |
+
|
39 |
+
package scala.collection
|
40 |
+
|
41 |
+
import generic._
|
42 |
+
import mutable.{ Builder, ListBuffer }
|
43 |
+
import annotation.{tailrec, migration, bridge}
|
44 |
+
import annotation.unchecked.{ uncheckedVariance => uV }
|
45 |
+
import parallel.ParIterable
|
46 |
+
|
47 |
+
/** A template trait for traversable collections of type `Traversable[A]`.
|
48 |
+
*
|
49 |
+
* $traversableInfo
|
50 |
+
* @define mutability
|
51 |
+
* @define traversableInfo
|
52 |
+
* This is a base trait of all kinds of $mutability Scala collections. It
|
53 |
+
* implements the behavior common to all collections, in terms of a method
|
54 |
+
* `foreach` with signature:
|
55 |
+
* {{{
|
56 |
+
* def foreach[U](f: Elem => U): Unit
|
57 |
+
* }}}
|
58 |
+
* Collection classes mixing in this trait provide a concrete
|
59 |
+
* `foreach` method which traverses all the
|
60 |
+
* elements contained in the collection, applying a given function to each.
|
61 |
+
* They also need to provide a method `newBuilder`
|
62 |
+
* which creates a builder for collections of the same kind.
|
63 |
+
*
|
64 |
+
* A traversable class might or might not have two properties: strictness
|
65 |
+
* and orderedness. Neither is represented as a type.
|
66 |
+
*
|
67 |
+
* The instances of a strict collection class have all their elements
|
68 |
+
* computed before they can be used as values. By contrast, instances of
|
69 |
+
* a non-strict collection class may defer computation of some of their
|
70 |
+
* elements until after the instance is available as a value.
|
71 |
+
* A typical example of a non-strict collection class is a
|
72 |
+
* <a href="../immutable/Stream.html" target="ContentFrame">
|
73 |
+
* `scala.collection.immutable.Stream`</a>.
|
74 |
+
* A more general class of examples are `TraversableViews`.
|
75 |
+
*
|
76 |
+
* If a collection is an instance of an ordered collection class, traversing
|
77 |
+
* its elements with `foreach` will always visit elements in the
|
78 |
+
* same order, even for different runs of the program. If the class is not
|
79 |
+
* ordered, `foreach` can visit elements in different orders for
|
80 |
+
* different runs (but it will keep the same order in the same run).'
|
81 |
+
*
|
82 |
+
* A typical example of a collection class which is not ordered is a
|
83 |
+
* `HashMap` of objects. The traversal order for hash maps will
|
84 |
+
* depend on the hash codes of its elements, and these hash codes might
|
85 |
+
* differ from one run to the next. By contrast, a `LinkedHashMap`
|
86 |
+
* is ordered because it's `foreach` method visits elements in the
|
87 |
+
* order they were inserted into the `HashMap`.
|
88 |
+
*
|
89 |
+
* @author Martin Odersky
|
90 |
+
* @version 2.8
|
91 |
+
* @since 2.8
|
92 |
+
* @tparam A the element type of the collection
|
93 |
+
* @tparam Repr the type of the actual collection containing the elements.
|
94 |
+
*
|
95 |
+
* @define Coll Traversable
|
96 |
+
* @define coll traversable collection
|
97 |
+
*/
|
98 |
+
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
|
99 |
+
with FilterMonadic[A, Repr]
|
100 |
+
with TraversableOnce[A]
|
101 |
+
with GenTraversableLike[A, Repr]
|
102 |
+
with Parallelizable[A, ParIterable[A]]
|
103 |
+
{
|
104 |
+
self =>
|
105 |
+
|
106 |
+
import Traversable.breaks._
|
107 |
+
|
108 |
+
/** The type implementing this traversable */
|
109 |
+
protected type Self = Repr
|
110 |
+
|
111 |
+
/** The collection of type $coll underlying this `TraversableLike` object.
|
112 |
+
* By default this is implemented as the `TraversableLike` object itself,
|
113 |
+
* but this can be overridden.
|
114 |
+
*/
|
115 |
+
def repr: Repr = this.asInstanceOf[Repr]
|
116 |
+
|
117 |
+
/** The underlying collection seen as an instance of `$Coll`.
|
118 |
+
* By default this is implemented as the current collection object itself,
|
119 |
+
* but this can be overridden.
|
120 |
+
*/
|
121 |
+
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
|
122 |
+
|
123 |
+
/** A conversion from collections of type `Repr` to `$Coll` objects.
|
124 |
+
* By default this is implemented as just a cast, but this can be overridden.
|
125 |
+
*/
|
126 |
+
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
|
127 |
+
|
128 |
+
/** Creates a new builder for this collection type.
|
129 |
+
*/
|
130 |
+
protected[this] def newBuilder: Builder[A, Repr]
|
131 |
+
|
132 |
+
protected[this] def parCombiner = ParIterable.newCombiner[A]
|
133 |
+
|
134 |
+
/** Applies a function `f` to all elements of this $coll.
|
135 |
+
*
|
136 |
+
* Note: this method underlies the implementation of most other bulk operations.
|
137 |
+
* It's important to implement this method in an efficient way.
|
138 |
+
*
|
139 |
+
*
|
140 |
+
* @param f the function that is applied for its side-effect to every element.
|
141 |
+
* The result of function `f` is discarded.
|
142 |
+
*
|
143 |
+
* @tparam U the type parameter describing the result of function `f`.
|
144 |
+
* This result will always be ignored. Typically `U` is `Unit`,
|
145 |
+
* but this is not necessary.
|
146 |
+
*
|
147 |
+
* @usecase def foreach(f: A => Unit): Unit
|
148 |
+
*/
|
149 |
+
def foreach[U](f: A => U): Unit
|
150 |
+
|
151 |
+
/** Tests whether this $coll is empty.
|
152 |
+
*
|
153 |
+
* @return `true` if the $coll contain no elements, `false` otherwise.
|
154 |
+
*/
|
155 |
+
def isEmpty: Boolean = {
|
156 |
+
var result = true
|
157 |
+
breakable {
|
158 |
+
for (x <- this) {
|
159 |
+
result = false
|
160 |
+
break
|
161 |
+
}
|
162 |
+
}
|
163 |
+
result
|
164 |
+
}
|
165 |
+
|
166 |
+
/** Tests whether this $coll is known to have a finite size.
|
167 |
+
* All strict collections are known to have finite size. For a non-strict collection
|
168 |
+
* such as `Stream`, the predicate returns `true` if all elements have been computed.
|
169 |
+
* It returns `false` if the stream is not yet evaluated to the end.
|
170 |
+
*
|
171 |
+
* Note: many collection methods will not work on collections of infinite sizes.
|
172 |
+
*
|
173 |
+
* @return `true` if this collection is known to have finite size, `false` otherwise.
|
174 |
+
*/
|
175 |
+
def hasDefiniteSize = true
|
176 |
+
|
177 |
+
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
178 |
+
val b = bf(repr)
|
179 |
+
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
|
180 |
+
b ++= thisCollection
|
181 |
+
b ++= that.seq
|
182 |
+
b.result
|
183 |
+
}
|
184 |
+
|
185 |
+
@bridge
|
186 |
+
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
187 |
+
++(that: GenTraversableOnce[B])(bf)
|
188 |
+
|
189 |
+
/** Concatenates this $coll with the elements of a traversable collection.
|
190 |
+
* It differs from ++ in that the right operand determines the type of the
|
191 |
+
* resulting collection rather than the left one.
|
192 |
+
*
|
193 |
+
* @param that the traversable to append.
|
194 |
+
* @tparam B the element type of the returned collection.
|
195 |
+
* @tparam That $thatinfo
|
196 |
+
* @param bf $bfinfo
|
197 |
+
* @return a new collection of type `That` which contains all elements
|
198 |
+
* of this $coll followed by all elements of `that`.
|
199 |
+
*
|
200 |
+
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
|
201 |
+
*
|
202 |
+
* @return a new $coll which contains all elements of this $coll
|
203 |
+
* followed by all elements of `that`.
|
204 |
+
*/
|
205 |
+
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
206 |
+
val b = bf(repr)
|
207 |
+
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
|
208 |
+
b ++= that
|
209 |
+
b ++= thisCollection
|
210 |
+
b.result
|
211 |
+
}
|
212 |
+
|
213 |
+
/** This overload exists because: for the implementation of ++: we should reuse
|
214 |
+
* that of ++ because many collections override it with more efficient versions.
|
215 |
+
* Since TraversableOnce has no '++' method, we have to implement that directly,
|
216 |
+
* but Traversable and down can use the overload.
|
217 |
+
*/
|
218 |
+
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
219 |
+
(that ++ seq)(breakOut)
|
220 |
+
|
221 |
+
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
222 |
+
val b = bf(repr)
|
223 |
+
b.sizeHint(this)
|
224 |
+
for (x <- this) b += f(x)
|
225 |
+
b.result
|
226 |
+
}
|
227 |
+
|
228 |
+
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
229 |
+
val b = bf(repr)
|
230 |
+
for (x <- this) b ++= f(x).seq
|
231 |
+
b.result
|
232 |
+
}
|
233 |
+
|
234 |
+
/** Selects all elements of this $coll which satisfy a predicate.
|
235 |
+
*
|
236 |
+
* @param p the predicate used to test elements.
|
237 |
+
* @return a new $coll consisting of all elements of this $coll that satisfy the given
|
238 |
+
* predicate `p`. The order of the elements is preserved.
|
239 |
+
*/
|
240 |
+
def filter(p: A => Boolean): Repr = {
|
241 |
+
val b = newBuilder
|
242 |
+
for (x <- this)
|
243 |
+
if (p(x)) b += x
|
244 |
+
b.result
|
245 |
+
}
|
246 |
+
|
247 |
+
/** Selects all elements of this $coll which do not satisfy a predicate.
|
248 |
+
*
|
249 |
+
* @param p the predicate used to test elements.
|
250 |
+
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
|
251 |
+
* predicate `p`. The order of the elements is preserved.
|
252 |
+
*/
|
253 |
+
def filterNot(p: A => Boolean): Repr = filter(!p(_))
|
254 |
+
|
255 |
+
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
256 |
+
val b = bf(repr)
|
257 |
+
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
|
258 |
+
b.result
|
259 |
+
}
|
260 |
+
|
261 |
+
/** Builds a new collection by applying an option-valued function to all
|
262 |
+
* elements of this $coll on which the function is defined.
|
263 |
+
*
|
264 |
+
* @param f the option-valued function which filters and maps the $coll.
|
265 |
+
* @tparam B the element type of the returned collection.
|
266 |
+
* @tparam That $thatinfo
|
267 |
+
* @param bf $bfinfo
|
268 |
+
* @return a new collection of type `That` resulting from applying the option-valued function
|
269 |
+
* `f` to each element and collecting all defined results.
|
270 |
+
* The order of the elements is preserved.
|
271 |
+
*
|
272 |
+
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
|
273 |
+
*
|
274 |
+
* @param pf the partial function which filters and maps the $coll.
|
275 |
+
* @return a new $coll resulting from applying the given option-valued function
|
276 |
+
* `f` to each element and collecting all defined results.
|
277 |
+
* The order of the elements is preserved.
|
278 |
+
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
279 |
+
val b = bf(repr)
|
280 |
+
for (x <- this)
|
281 |
+
f(x) match {
|
282 |
+
case Some(y) => b += y
|
283 |
+
case _ =>
|
284 |
+
}
|
285 |
+
b.result
|
286 |
+
}
|
287 |
+
*/
|
288 |
+
|
289 |
+
/** Partitions this $coll in two ${coll}s according to a predicate.
|
290 |
+
*
|
291 |
+
* @param p the predicate on which to partition.
|
292 |
+
* @return a pair of ${coll}s: the first $coll consists of all elements that
|
293 |
+
* satisfy the predicate `p` and the second $coll consists of all elements
|
294 |
+
* that don't. The relative order of the elements in the resulting ${coll}s
|
295 |
+
* is the same as in the original $coll.
|
296 |
+
*/
|
297 |
+
def partition(p: A => Boolean): (Repr, Repr) = {
|
298 |
+
val l, r = newBuilder
|
299 |
+
for (x <- this) (if (p(x)) l else r) += x
|
300 |
+
(l.result, r.result)
|
301 |
+
}
|
302 |
+
|
303 |
+
def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
|
304 |
+
val m = mutable.Map.empty[K, Builder[A, Repr]]
|
305 |
+
for (elem <- this) {
|
306 |
+
val key = f(elem)
|
307 |
+
val bldr = m.getOrElseUpdate(key, newBuilder)
|
308 |
+
bldr += elem
|
309 |
+
}
|
310 |
+
val b = immutable.Map.newBuilder[K, Repr]
|
311 |
+
for ((k, v) <- m)
|
312 |
+
b += ((k, v.result))
|
313 |
+
|
314 |
+
b.result
|
315 |
+
}
|
316 |
+
|
317 |
+
/** Tests whether a predicate holds for all elements of this $coll.
|
318 |
+
*
|
319 |
+
* $mayNotTerminateInf
|
320 |
+
*
|
321 |
+
* @param p the predicate used to test elements.
|
322 |
+
* @return `true` if the given predicate `p` holds for all elements
|
323 |
+
* of this $coll, otherwise `false`.
|
324 |
+
*/
|
325 |
+
def forall(p: A => Boolean): Boolean = {
|
326 |
+
var result = true
|
327 |
+
breakable {
|
328 |
+
for (x <- this)
|
329 |
+
if (!p(x)) { result = false; break }
|
330 |
+
}
|
331 |
+
result
|
332 |
+
}
|
333 |
+
|
334 |
+
/** Tests whether a predicate holds for some of the elements of this $coll.
|
335 |
+
*
|
336 |
+
* $mayNotTerminateInf
|
337 |
+
*
|
338 |
+
* @param p the predicate used to test elements.
|
339 |
+
* @return `true` if the given predicate `p` holds for some of the
|
340 |
+
* elements of this $coll, otherwise `false`.
|
341 |
+
*/
|
342 |
+
def exists(p: A => Boolean): Boolean = {
|
343 |
+
var result = false
|
344 |
+
breakable {
|
345 |
+
for (x <- this)
|
346 |
+
if (p(x)) { result = true; break }
|
347 |
+
}
|
348 |
+
result
|
349 |
+
}
|
350 |
+
|
351 |
+
/** Finds the first element of the $coll satisfying a predicate, if any.
|
352 |
+
*
|
353 |
+
* $mayNotTerminateInf
|
354 |
+
* $orderDependent
|
355 |
+
*
|
356 |
+
* @param p the predicate used to test elements.
|
357 |
+
* @return an option value containing the first element in the $coll
|
358 |
+
* that satisfies `p`, or `None` if none exists.
|
359 |
+
*/
|
360 |
+
def find(p: A => Boolean): Option[A] = {
|
361 |
+
var result: Option[A] = None
|
362 |
+
breakable {
|
363 |
+
for (x <- this)
|
364 |
+
if (p(x)) { result = Some(x); break }
|
365 |
+
}
|
366 |
+
result
|
367 |
+
}
|
368 |
+
|
369 |
+
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
|
370 |
+
|
371 |
+
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
372 |
+
val b = bf(repr)
|
373 |
+
b.sizeHint(this, 1)
|
374 |
+
var acc = z
|
375 |
+
b += acc
|
376 |
+
for (x <- this) { acc = op(acc, x); b += acc }
|
377 |
+
b.result
|
378 |
+
}
|
379 |
+
|
380 |
+
@migration(2, 9,
|
381 |
+
"This scanRight definition has changed in 2.9.\n" +
|
382 |
+
"The previous behavior can be reproduced with scanRight.reverse."
|
383 |
+
)
|
384 |
+
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
385 |
+
var scanned = List(z)
|
386 |
+
var acc = z
|
387 |
+
for (x <- reversed) {
|
388 |
+
acc = op(x, acc)
|
389 |
+
scanned ::= acc
|
390 |
+
}
|
391 |
+
val b = bf(repr)
|
392 |
+
for (elem <- scanned) b += elem
|
393 |
+
b.result
|
394 |
+
}
|
395 |
+
|
396 |
+
/** Selects the first element of this $coll.
|
397 |
+
* $orderDependent
|
398 |
+
* @return the first element of this $coll.
|
399 |
+
* @throws `NoSuchElementException` if the $coll is empty.
|
400 |
+
*/
|
401 |
+
def head: A = {
|
402 |
+
var result: () => A = () => throw new NoSuchElementException
|
403 |
+
breakable {
|
404 |
+
for (x <- this) {
|
405 |
+
result = () => x
|
406 |
+
break
|
407 |
+
}
|
408 |
+
}
|
409 |
+
result()
|
410 |
+
}
|
411 |
+
|
412 |
+
/** Optionally selects the first element.
|
413 |
+
* $orderDependent
|
414 |
+
* @return the first element of this $coll if it is nonempty, `None` if it is empty.
|
415 |
+
*/
|
416 |
+
def headOption: Option[A] = if (isEmpty) None else Some(head)
|
417 |
+
|
418 |
+
/** Selects all elements except the first.
|
419 |
+
* $orderDependent
|
420 |
+
* @return a $coll consisting of all elements of this $coll
|
421 |
+
* except the first one.
|
422 |
+
* @throws `UnsupportedOperationException` if the $coll is empty.
|
423 |
+
*/
|
424 |
+
override def tail: Repr = {
|
425 |
+
if (isEmpty) throw new UnsupportedOperationException("empty.tail")
|
426 |
+
drop(1)
|
427 |
+
}
|
428 |
+
|
429 |
+
/** Selects the last element.
|
430 |
+
* $orderDependent
|
431 |
+
* @return The last element of this $coll.
|
432 |
+
* @throws NoSuchElementException If the $coll is empty.
|
433 |
+
*/
|
434 |
+
def last: A = {
|
435 |
+
var lst = head
|
436 |
+
for (x <- this)
|
437 |
+
lst = x
|
438 |
+
lst
|
439 |
+
}
|
440 |
+
|
441 |
+
/** Optionally selects the last element.
|
442 |
+
* $orderDependent
|
443 |
+
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
|
444 |
+
*/
|
445 |
+
def lastOption: Option[A] = if (isEmpty) None else Some(last)
|
446 |
+
|
447 |
+
/** Selects all elements except the last.
|
448 |
+
* $orderDependent
|
449 |
+
* @return a $coll consisting of all elements of this $coll
|
450 |
+
* except the last one.
|
451 |
+
* @throws `UnsupportedOperationException` if the $coll is empty.
|
452 |
+
*/
|
453 |
+
def init: Repr = {
|
454 |
+
if (isEmpty) throw new UnsupportedOperationException("empty.init")
|
455 |
+
var lst = head
|
456 |
+
var follow = false
|
457 |
+
val b = newBuilder
|
458 |
+
b.sizeHint(this, -1)
|
459 |
+
for (x <- this.seq) {
|
460 |
+
if (follow) b += lst
|
461 |
+
else follow = true
|
462 |
+
lst = x
|
463 |
+
}
|
464 |
+
b.result
|
465 |
+
}
|
466 |
+
|
467 |
+
def take(n: Int): Repr = slice(0, n)
|
468 |
+
|
469 |
+
def drop(n: Int): Repr =
|
470 |
+
if (n <= 0) {
|
471 |
+
val b = newBuilder
|
472 |
+
b.sizeHint(this)
|
473 |
+
b ++= thisCollection result
|
474 |
+
}
|
475 |
+
else sliceWithKnownDelta(n, Int.MaxValue, -n)
|
476 |
+
|
477 |
+
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
|
478 |
+
|
479 |
+
// Precondition: from >= 0, until > 0, builder already configured for building.
|
480 |
+
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
|
481 |
+
var i = 0
|
482 |
+
breakable {
|
483 |
+
for (x <- this.seq) {
|
484 |
+
if (i >= from) b += x
|
485 |
+
i += 1
|
486 |
+
if (i >= until) break
|
487 |
+
}
|
488 |
+
}
|
489 |
+
b.result
|
490 |
+
}
|
491 |
+
// Precondition: from >= 0
|
492 |
+
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
|
493 |
+
val b = newBuilder
|
494 |
+
if (until <= from) b.result
|
495 |
+
else {
|
496 |
+
b.sizeHint(this, delta)
|
497 |
+
sliceInternal(from, until, b)
|
498 |
+
}
|
499 |
+
}
|
500 |
+
// Precondition: from >= 0
|
501 |
+
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
|
502 |
+
val b = newBuilder
|
503 |
+
if (until <= from) b.result
|
504 |
+
else {
|
505 |
+
b.sizeHintBounded(until - from, this)
|
506 |
+
sliceInternal(from, until, b)
|
507 |
+
}
|
508 |
+
}
|
509 |
+
|
510 |
+
def takeWhile(p: A => Boolean): Repr = {
|
511 |
+
val b = newBuilder
|
512 |
+
breakable {
|
513 |
+
for (x <- this) {
|
514 |
+
if (!p(x)) break
|
515 |
+
b += x
|
516 |
+
}
|
517 |
+
}
|
518 |
+
b.result
|
519 |
+
}
|
520 |
+
|
521 |
+
def dropWhile(p: A => Boolean): Repr = {
|
522 |
+
val b = newBuilder
|
523 |
+
var go = false
|
524 |
+
for (x <- this) {
|
525 |
+
if (!p(x)) go = true
|
526 |
+
if (go) b += x
|
527 |
+
}
|
528 |
+
b.result
|
529 |
+
}
|
530 |
+
|
531 |
+
def span(p: A => Boolean): (Repr, Repr) = {
|
532 |
+
val l, r = newBuilder
|
533 |
+
var toLeft = true
|
534 |
+
for (x <- this) {
|
535 |
+
toLeft = toLeft && p(x)
|
536 |
+
(if (toLeft) l else r) += x
|
537 |
+
}
|
538 |
+
(l.result, r.result)
|
539 |
+
}
|
540 |
+
|
541 |
+
def splitAt(n: Int): (Repr, Repr) = {
|
542 |
+
val l, r = newBuilder
|
543 |
+
l.sizeHintBounded(n, this)
|
544 |
+
if (n >= 0) r.sizeHint(this, -n)
|
545 |
+
var i = 0
|
546 |
+
for (x <- this) {
|
547 |
+
(if (i < n) l else r) += x
|
548 |
+
i += 1
|
549 |
+
}
|
550 |
+
(l.result, r.result)
|
551 |
+
}
|
552 |
+
|
553 |
+
/** Iterates over the tails of this $coll. The first value will be this
|
554 |
+
* $coll and the final one will be an empty $coll, with the intervening
|
555 |
+
* values the results of successive applications of `tail`.
|
556 |
+
*
|
557 |
+
* @return an iterator over all the tails of this $coll
|
558 |
+
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
|
559 |
+
*/
|
560 |
+
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
|
561 |
+
|
562 |
+
/** Iterates over the inits of this $coll. The first value will be this
|
563 |
+
* $coll and the final one will be an empty $coll, with the intervening
|
564 |
+
* values the results of successive applications of `init`.
|
565 |
+
*
|
566 |
+
* @return an iterator over all the inits of this $coll
|
567 |
+
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
|
568 |
+
*/
|
569 |
+
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
|
570 |
+
|
571 |
+
/** Copies elements of this $coll to an array.
|
572 |
+
* Fills the given array `xs` with at most `len` elements of
|
573 |
+
* this $coll, starting at position `start`.
|
574 |
+
* Copying will stop once either the end of the current $coll is reached,
|
575 |
+
* or the end of the array is reached, or `len` elements have been copied.
|
576 |
+
*
|
577 |
+
* $willNotTerminateInf
|
578 |
+
*
|
579 |
+
* @param xs the array to fill.
|
580 |
+
* @param start the starting index.
|
581 |
+
* @param len the maximal number of elements to copy.
|
582 |
+
* @tparam B the type of the elements of the array.
|
583 |
+
*
|
584 |
+
*
|
585 |
+
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
|
586 |
+
*/
|
587 |
+
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
|
588 |
+
var i = start
|
589 |
+
val end = (start + len) min xs.length
|
590 |
+
breakable {
|
591 |
+
for (x <- this) {
|
592 |
+
if (i >= end) break
|
593 |
+
xs(i) = x
|
594 |
+
i += 1
|
595 |
+
}
|
596 |
+
}
|
597 |
+
}
|
598 |
+
|
599 |
+
def toTraversable: Traversable[A] = thisCollection
|
600 |
+
def toIterator: Iterator[A] = toStream.iterator
|
601 |
+
def toStream: Stream[A] = toBuffer.toStream
|
602 |
+
|
603 |
+
/** Converts this $coll to a string.
|
604 |
+
*
|
605 |
+
* @return a string representation of this collection. By default this
|
606 |
+
* string consists of the `stringPrefix` of this $coll,
|
607 |
+
* followed by all elements separated by commas and enclosed in parentheses.
|
608 |
+
*/
|
609 |
+
override def toString = mkString(stringPrefix + "(", ", ", ")")
|
610 |
+
|
611 |
+
/** Defines the prefix of this object's `toString` representation.
|
612 |
+
*
|
613 |
+
* @return a string representation which starts the result of `toString`
|
614 |
+
* applied to this $coll. By default the string prefix is the
|
615 |
+
* simple name of the collection class $coll.
|
616 |
+
*/
|
617 |
+
def stringPrefix : String = {
|
618 |
+
var string = repr.asInstanceOf[AnyRef].getClass.getName
|
619 |
+
val idx1 = string.lastIndexOf('.' : Int)
|
620 |
+
if (idx1 != -1) string = string.substring(idx1 + 1)
|
621 |
+
val idx2 = string.indexOf('$')
|
622 |
+
if (idx2 != -1) string = string.substring(0, idx2)
|
623 |
+
string
|
624 |
+
}
|
625 |
+
|
626 |
+
/** Creates a non-strict view of this $coll.
|
627 |
+
*
|
628 |
+
* @return a non-strict view of this $coll.
|
629 |
+
*/
|
630 |
+
def view = new TraversableView[A, Repr] {
|
631 |
+
protected lazy val underlying = self.repr
|
632 |
+
override def foreach[U](f: A => U) = self foreach f
|
633 |
+
}
|
634 |
+
|
635 |
+
/** Creates a non-strict view of a slice of this $coll.
|
636 |
+
*
|
637 |
+
* Note: the difference between `view` and `slice` is that `view` produces
|
638 |
+
* a view of the current $coll, whereas `slice` produces a new $coll.
|
639 |
+
*
|
640 |
+
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
|
641 |
+
* $orderDependent
|
642 |
+
*
|
643 |
+
* @param from the index of the first element of the view
|
644 |
+
* @param until the index of the element following the view
|
645 |
+
* @return a non-strict view of a slice of this $coll, starting at index `from`
|
646 |
+
* and extending up to (but not including) index `until`.
|
647 |
+
*/
|
648 |
+
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
|
649 |
+
|
650 |
+
/** Creates a non-strict filter of this $coll.
|
651 |
+
*
|
652 |
+
* Note: the difference between `c filter p` and `c withFilter p` is that
|
653 |
+
* the former creates a new collection, whereas the latter only
|
654 |
+
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
|
655 |
+
* and `withFilter` operations.
|
656 |
+
* $orderDependent
|
657 |
+
*
|
658 |
+
* @param p the predicate used to test elements.
|
659 |
+
* @return an object of class `WithFilter`, which supports
|
660 |
+
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
661 |
+
* All these operations apply to those elements of this $coll which
|
662 |
+
* satisfy the predicate `p`.
|
663 |
+
*/
|
664 |
+
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
|
665 |
+
|
666 |
+
/** A class supporting filtered operations. Instances of this class are
|
667 |
+
* returned by method `withFilter`.
|
668 |
+
*/
|
669 |
+
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
|
670 |
+
|
671 |
+
/** Builds a new collection by applying a function to all elements of the
|
672 |
+
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
|
673 |
+
*
|
674 |
+
* @param f the function to apply to each element.
|
675 |
+
* @tparam B the element type of the returned collection.
|
676 |
+
* @tparam That $thatinfo
|
677 |
+
* @param bf $bfinfo
|
678 |
+
* @return a new collection of type `That` resulting from applying
|
679 |
+
* the given function `f` to each element of the outer $coll
|
680 |
+
* that satisfies predicate `p` and collecting the results.
|
681 |
+
*
|
682 |
+
* @usecase def map[B](f: A => B): $Coll[B]
|
683 |
+
*
|
684 |
+
* @return a new $coll resulting from applying the given function
|
685 |
+
* `f` to each element of the outer $coll that satisfies
|
686 |
+
* predicate `p` and collecting the results.
|
687 |
+
*/
|
688 |
+
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
689 |
+
val b = bf(repr)
|
690 |
+
for (x <- self)
|
691 |
+
if (p(x)) b += f(x)
|
692 |
+
b.result
|
693 |
+
}
|
694 |
+
|
695 |
+
/** Builds a new collection by applying a function to all elements of the
|
696 |
+
* outer $coll containing this `WithFilter` instance that satisfy
|
697 |
+
* predicate `p` and concatenating the results.
|
698 |
+
*
|
699 |
+
* @param f the function to apply to each element.
|
700 |
+
* @tparam B the element type of the returned collection.
|
701 |
+
* @tparam That $thatinfo
|
702 |
+
* @param bf $bfinfo
|
703 |
+
* @return a new collection of type `That` resulting from applying
|
704 |
+
* the given collection-valued function `f` to each element
|
705 |
+
* of the outer $coll that satisfies predicate `p` and
|
706 |
+
* concatenating the results.
|
707 |
+
*
|
708 |
+
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
|
709 |
+
*
|
710 |
+
* @return a new $coll resulting from applying the given collection-valued function
|
711 |
+
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
|
712 |
+
*/
|
713 |
+
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
714 |
+
val b = bf(repr)
|
715 |
+
for (x <- self)
|
716 |
+
if (p(x)) b ++= f(x).seq
|
717 |
+
b.result
|
718 |
+
}
|
719 |
+
|
720 |
+
/** Applies a function `f` to all elements of the outer $coll containing
|
721 |
+
* this `WithFilter` instance that satisfy predicate `p`.
|
722 |
+
*
|
723 |
+
* @param f the function that is applied for its side-effect to every element.
|
724 |
+
* The result of function `f` is discarded.
|
725 |
+
*
|
726 |
+
* @tparam U the type parameter describing the result of function `f`.
|
727 |
+
* This result will always be ignored. Typically `U` is `Unit`,
|
728 |
+
* but this is not necessary.
|
729 |
+
*
|
730 |
+
* @usecase def foreach(f: A => Unit): Unit
|
731 |
+
*/
|
732 |
+
def foreach[U](f: A => U): Unit =
|
733 |
+
for (x <- self)
|
734 |
+
if (p(x)) f(x)
|
735 |
+
|
736 |
+
/** Further refines the filter for this $coll.
|
737 |
+
*
|
738 |
+
* @param q the predicate used to test elements.
|
739 |
+
* @return an object of class `WithFilter`, which supports
|
740 |
+
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
741 |
+
* All these operations apply to those elements of this $coll which
|
742 |
+
* satisfy the predicate `q` in addition to the predicate `p`.
|
743 |
+
*/
|
744 |
+
def withFilter(q: A => Boolean): WithFilter =
|
745 |
+
new WithFilter(x => p(x) && q(x))
|
746 |
+
}
|
747 |
+
|
748 |
+
// A helper for tails and inits.
|
749 |
+
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
|
750 |
+
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
|
751 |
+
it ++ Iterator(Nil) map (newBuilder ++= _ result)
|
752 |
+
}
|
753 |
+
}
|
754 |
+
|
755 |
+
|
756 |
+
</textarea>
|
757 |
+
</form>
|
758 |
+
|
759 |
+
<script>
|
760 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
761 |
+
lineNumbers: true,
|
762 |
+
matchBrackets: true,
|
763 |
+
theme: "ambiance",
|
764 |
+
mode: "text/x-scala"
|
765 |
+
});
|
766 |
+
</script>
|
767 |
+
</article>
|
inc/lib/codemirror/mode/clike/test.js
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
|
6 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
7 |
+
|
8 |
+
MT("indent",
|
9 |
+
"[type void] [def foo]([type void*] [variable a], [type int] [variable b]) {",
|
10 |
+
" [type int] [variable c] [operator =] [variable b] [operator +]",
|
11 |
+
" [number 1];",
|
12 |
+
" [keyword return] [operator *][variable a];",
|
13 |
+
"}");
|
14 |
+
|
15 |
+
MT("indent_switch",
|
16 |
+
"[keyword switch] ([variable x]) {",
|
17 |
+
" [keyword case] [number 10]:",
|
18 |
+
" [keyword return] [number 20];",
|
19 |
+
" [keyword default]:",
|
20 |
+
" [variable printf]([string \"foo %c\"], [variable x]);",
|
21 |
+
"}");
|
22 |
+
|
23 |
+
MT("def",
|
24 |
+
"[type void] [def foo]() {}",
|
25 |
+
"[keyword struct] [def bar]{}",
|
26 |
+
"[type int] [type *][def baz]() {}");
|
27 |
+
|
28 |
+
MT("def_new_line",
|
29 |
+
"::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
|
30 |
+
"[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
|
31 |
+
|
32 |
+
MT("double_block",
|
33 |
+
"[keyword for] (;;)",
|
34 |
+
" [keyword for] (;;)",
|
35 |
+
" [variable x][operator ++];",
|
36 |
+
"[keyword return];");
|
37 |
+
|
38 |
+
MT("preprocessor",
|
39 |
+
"[meta #define FOO 3]",
|
40 |
+
"[type int] [variable foo];",
|
41 |
+
"[meta #define BAR\\]",
|
42 |
+
"[meta 4]",
|
43 |
+
"[type unsigned] [type int] [variable bar] [operator =] [number 8];",
|
44 |
+
"[meta #include <baz> ][comment // comment]")
|
45 |
+
|
46 |
+
|
47 |
+
var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
|
48 |
+
function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
|
49 |
+
|
50 |
+
MTCPP("cpp14_literal",
|
51 |
+
"[number 10'000];",
|
52 |
+
"[number 0b10'000];",
|
53 |
+
"[number 0x10'000];",
|
54 |
+
"[string '100000'];");
|
55 |
+
|
56 |
+
MTCPP("ctor_dtor",
|
57 |
+
"[def Foo::Foo]() {}",
|
58 |
+
"[def Foo::~Foo]() {}");
|
59 |
+
|
60 |
+
var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala");
|
61 |
+
function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); }
|
62 |
+
MTSCALA("nested_comments",
|
63 |
+
"[comment /*]",
|
64 |
+
"[comment But wait /* this is a nested comment */ for real]",
|
65 |
+
"[comment /**** let * me * show * you ****/]",
|
66 |
+
"[comment ///// let / me / show / you /////]",
|
67 |
+
"[comment */]");
|
68 |
+
|
69 |
+
})();
|
inc/lib/codemirror/mode/css/css.js
ADDED
@@ -0,0 +1,832 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.defineMode("css", function(config, parserConfig) {
|
15 |
+
var inline = parserConfig.inline
|
16 |
+
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
|
17 |
+
|
18 |
+
var indentUnit = config.indentUnit,
|
19 |
+
tokenHooks = parserConfig.tokenHooks,
|
20 |
+
documentTypes = parserConfig.documentTypes || {},
|
21 |
+
mediaTypes = parserConfig.mediaTypes || {},
|
22 |
+
mediaFeatures = parserConfig.mediaFeatures || {},
|
23 |
+
mediaValueKeywords = parserConfig.mediaValueKeywords || {},
|
24 |
+
propertyKeywords = parserConfig.propertyKeywords || {},
|
25 |
+
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
26 |
+
fontProperties = parserConfig.fontProperties || {},
|
27 |
+
counterDescriptors = parserConfig.counterDescriptors || {},
|
28 |
+
colorKeywords = parserConfig.colorKeywords || {},
|
29 |
+
valueKeywords = parserConfig.valueKeywords || {},
|
30 |
+
allowNested = parserConfig.allowNested,
|
31 |
+
lineComment = parserConfig.lineComment,
|
32 |
+
supportsAtComponent = parserConfig.supportsAtComponent === true;
|
33 |
+
|
34 |
+
var type, override;
|
35 |
+
function ret(style, tp) { type = tp; return style; }
|
36 |
+
|
37 |
+
// Tokenizers
|
38 |
+
|
39 |
+
function tokenBase(stream, state) {
|
40 |
+
var ch = stream.next();
|
41 |
+
if (tokenHooks[ch]) {
|
42 |
+
var result = tokenHooks[ch](stream, state);
|
43 |
+
if (result !== false) return result;
|
44 |
+
}
|
45 |
+
if (ch == "@") {
|
46 |
+
stream.eatWhile(/[\w\\\-]/);
|
47 |
+
return ret("def", stream.current());
|
48 |
+
} else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
|
49 |
+
return ret(null, "compare");
|
50 |
+
} else if (ch == "\"" || ch == "'") {
|
51 |
+
state.tokenize = tokenString(ch);
|
52 |
+
return state.tokenize(stream, state);
|
53 |
+
} else if (ch == "#") {
|
54 |
+
stream.eatWhile(/[\w\\\-]/);
|
55 |
+
return ret("atom", "hash");
|
56 |
+
} else if (ch == "!") {
|
57 |
+
stream.match(/^\s*\w*/);
|
58 |
+
return ret("keyword", "important");
|
59 |
+
} else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
|
60 |
+
stream.eatWhile(/[\w.%]/);
|
61 |
+
return ret("number", "unit");
|
62 |
+
} else if (ch === "-") {
|
63 |
+
if (/[\d.]/.test(stream.peek())) {
|
64 |
+
stream.eatWhile(/[\w.%]/);
|
65 |
+
return ret("number", "unit");
|
66 |
+
} else if (stream.match(/^-[\w\\\-]+/)) {
|
67 |
+
stream.eatWhile(/[\w\\\-]/);
|
68 |
+
if (stream.match(/^\s*:/, false))
|
69 |
+
return ret("variable-2", "variable-definition");
|
70 |
+
return ret("variable-2", "variable");
|
71 |
+
} else if (stream.match(/^\w+-/)) {
|
72 |
+
return ret("meta", "meta");
|
73 |
+
}
|
74 |
+
} else if (/[,+>*\/]/.test(ch)) {
|
75 |
+
return ret(null, "select-op");
|
76 |
+
} else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
|
77 |
+
return ret("qualifier", "qualifier");
|
78 |
+
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
|
79 |
+
return ret(null, ch);
|
80 |
+
} else if (((ch == "u" || ch == "U") && stream.match(/rl(-prefix)?\(/i)) ||
|
81 |
+
((ch == "d" || ch == "D") && stream.match("omain(", true, true)) ||
|
82 |
+
((ch == "r" || ch == "R") && stream.match("egexp(", true, true))) {
|
83 |
+
stream.backUp(1);
|
84 |
+
state.tokenize = tokenParenthesized;
|
85 |
+
return ret("property", "word");
|
86 |
+
} else if (/[\w\\\-]/.test(ch)) {
|
87 |
+
stream.eatWhile(/[\w\\\-]/);
|
88 |
+
return ret("property", "word");
|
89 |
+
} else {
|
90 |
+
return ret(null, null);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
function tokenString(quote) {
|
95 |
+
return function(stream, state) {
|
96 |
+
var escaped = false, ch;
|
97 |
+
while ((ch = stream.next()) != null) {
|
98 |
+
if (ch == quote && !escaped) {
|
99 |
+
if (quote == ")") stream.backUp(1);
|
100 |
+
break;
|
101 |
+
}
|
102 |
+
escaped = !escaped && ch == "\\";
|
103 |
+
}
|
104 |
+
if (ch == quote || !escaped && quote != ")") state.tokenize = null;
|
105 |
+
return ret("string", "string");
|
106 |
+
};
|
107 |
+
}
|
108 |
+
|
109 |
+
function tokenParenthesized(stream, state) {
|
110 |
+
stream.next(); // Must be '('
|
111 |
+
if (!stream.match(/\s*[\"\')]/, false))
|
112 |
+
state.tokenize = tokenString(")");
|
113 |
+
else
|
114 |
+
state.tokenize = null;
|
115 |
+
return ret(null, "(");
|
116 |
+
}
|
117 |
+
|
118 |
+
// Context management
|
119 |
+
|
120 |
+
function Context(type, indent, prev) {
|
121 |
+
this.type = type;
|
122 |
+
this.indent = indent;
|
123 |
+
this.prev = prev;
|
124 |
+
}
|
125 |
+
|
126 |
+
function pushContext(state, stream, type, indent) {
|
127 |
+
state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
|
128 |
+
return type;
|
129 |
+
}
|
130 |
+
|
131 |
+
function popContext(state) {
|
132 |
+
if (state.context.prev)
|
133 |
+
state.context = state.context.prev;
|
134 |
+
return state.context.type;
|
135 |
+
}
|
136 |
+
|
137 |
+
function pass(type, stream, state) {
|
138 |
+
return states[state.context.type](type, stream, state);
|
139 |
+
}
|
140 |
+
function popAndPass(type, stream, state, n) {
|
141 |
+
for (var i = n || 1; i > 0; i--)
|
142 |
+
state.context = state.context.prev;
|
143 |
+
return pass(type, stream, state);
|
144 |
+
}
|
145 |
+
|
146 |
+
// Parser
|
147 |
+
|
148 |
+
function wordAsValue(stream) {
|
149 |
+
var word = stream.current().toLowerCase();
|
150 |
+
if (valueKeywords.hasOwnProperty(word))
|
151 |
+
override = "atom";
|
152 |
+
else if (colorKeywords.hasOwnProperty(word))
|
153 |
+
override = "keyword";
|
154 |
+
else
|
155 |
+
override = "variable";
|
156 |
+
}
|
157 |
+
|
158 |
+
var states = {};
|
159 |
+
|
160 |
+
states.top = function(type, stream, state) {
|
161 |
+
if (type == "{") {
|
162 |
+
return pushContext(state, stream, "block");
|
163 |
+
} else if (type == "}" && state.context.prev) {
|
164 |
+
return popContext(state);
|
165 |
+
} else if (supportsAtComponent && /@component/i.test(type)) {
|
166 |
+
return pushContext(state, stream, "atComponentBlock");
|
167 |
+
} else if (/^@(-moz-)?document$/i.test(type)) {
|
168 |
+
return pushContext(state, stream, "documentTypes");
|
169 |
+
} else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) {
|
170 |
+
return pushContext(state, stream, "atBlock");
|
171 |
+
} else if (/^@(font-face|counter-style)/i.test(type)) {
|
172 |
+
state.stateArg = type;
|
173 |
+
return "restricted_atBlock_before";
|
174 |
+
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) {
|
175 |
+
return "keyframes";
|
176 |
+
} else if (type && type.charAt(0) == "@") {
|
177 |
+
return pushContext(state, stream, "at");
|
178 |
+
} else if (type == "hash") {
|
179 |
+
override = "builtin";
|
180 |
+
} else if (type == "word") {
|
181 |
+
override = "tag";
|
182 |
+
} else if (type == "variable-definition") {
|
183 |
+
return "maybeprop";
|
184 |
+
} else if (type == "interpolation") {
|
185 |
+
return pushContext(state, stream, "interpolation");
|
186 |
+
} else if (type == ":") {
|
187 |
+
return "pseudo";
|
188 |
+
} else if (allowNested && type == "(") {
|
189 |
+
return pushContext(state, stream, "parens");
|
190 |
+
}
|
191 |
+
return state.context.type;
|
192 |
+
};
|
193 |
+
|
194 |
+
states.block = function(type, stream, state) {
|
195 |
+
if (type == "word") {
|
196 |
+
var word = stream.current().toLowerCase();
|
197 |
+
if (propertyKeywords.hasOwnProperty(word)) {
|
198 |
+
override = "property";
|
199 |
+
return "maybeprop";
|
200 |
+
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
|
201 |
+
override = "string-2";
|
202 |
+
return "maybeprop";
|
203 |
+
} else if (allowNested) {
|
204 |
+
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
|
205 |
+
return "block";
|
206 |
+
} else {
|
207 |
+
override += " error";
|
208 |
+
return "maybeprop";
|
209 |
+
}
|
210 |
+
} else if (type == "meta") {
|
211 |
+
return "block";
|
212 |
+
} else if (!allowNested && (type == "hash" || type == "qualifier")) {
|
213 |
+
override = "error";
|
214 |
+
return "block";
|
215 |
+
} else {
|
216 |
+
return states.top(type, stream, state);
|
217 |
+
}
|
218 |
+
};
|
219 |
+
|
220 |
+
states.maybeprop = function(type, stream, state) {
|
221 |
+
if (type == ":") return pushContext(state, stream, "prop");
|
222 |
+
return pass(type, stream, state);
|
223 |
+
};
|
224 |
+
|
225 |
+
states.prop = function(type, stream, state) {
|
226 |
+
if (type == ";") return popContext(state);
|
227 |
+
if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
|
228 |
+
if (type == "}" || type == "{") return popAndPass(type, stream, state);
|
229 |
+
if (type == "(") return pushContext(state, stream, "parens");
|
230 |
+
|
231 |
+
if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
|
232 |
+
override += " error";
|
233 |
+
} else if (type == "word") {
|
234 |
+
wordAsValue(stream);
|
235 |
+
} else if (type == "interpolation") {
|
236 |
+
return pushContext(state, stream, "interpolation");
|
237 |
+
}
|
238 |
+
return "prop";
|
239 |
+
};
|
240 |
+
|
241 |
+
states.propBlock = function(type, _stream, state) {
|
242 |
+
if (type == "}") return popContext(state);
|
243 |
+
if (type == "word") { override = "property"; return "maybeprop"; }
|
244 |
+
return state.context.type;
|
245 |
+
};
|
246 |
+
|
247 |
+
states.parens = function(type, stream, state) {
|
248 |
+
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
249 |
+
if (type == ")") return popContext(state);
|
250 |
+
if (type == "(") return pushContext(state, stream, "parens");
|
251 |
+
if (type == "interpolation") return pushContext(state, stream, "interpolation");
|
252 |
+
if (type == "word") wordAsValue(stream);
|
253 |
+
return "parens";
|
254 |
+
};
|
255 |
+
|
256 |
+
states.pseudo = function(type, stream, state) {
|
257 |
+
if (type == "meta") return "pseudo";
|
258 |
+
|
259 |
+
if (type == "word") {
|
260 |
+
override = "variable-3";
|
261 |
+
return state.context.type;
|
262 |
+
}
|
263 |
+
return pass(type, stream, state);
|
264 |
+
};
|
265 |
+
|
266 |
+
states.documentTypes = function(type, stream, state) {
|
267 |
+
if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
|
268 |
+
override = "tag";
|
269 |
+
return state.context.type;
|
270 |
+
} else {
|
271 |
+
return states.atBlock(type, stream, state);
|
272 |
+
}
|
273 |
+
};
|
274 |
+
|
275 |
+
states.atBlock = function(type, stream, state) {
|
276 |
+
if (type == "(") return pushContext(state, stream, "atBlock_parens");
|
277 |
+
if (type == "}" || type == ";") return popAndPass(type, stream, state);
|
278 |
+
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
279 |
+
|
280 |
+
if (type == "interpolation") return pushContext(state, stream, "interpolation");
|
281 |
+
|
282 |
+
if (type == "word") {
|
283 |
+
var word = stream.current().toLowerCase();
|
284 |
+
if (word == "only" || word == "not" || word == "and" || word == "or")
|
285 |
+
override = "keyword";
|
286 |
+
else if (mediaTypes.hasOwnProperty(word))
|
287 |
+
override = "attribute";
|
288 |
+
else if (mediaFeatures.hasOwnProperty(word))
|
289 |
+
override = "property";
|
290 |
+
else if (mediaValueKeywords.hasOwnProperty(word))
|
291 |
+
override = "keyword";
|
292 |
+
else if (propertyKeywords.hasOwnProperty(word))
|
293 |
+
override = "property";
|
294 |
+
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
|
295 |
+
override = "string-2";
|
296 |
+
else if (valueKeywords.hasOwnProperty(word))
|
297 |
+
override = "atom";
|
298 |
+
else if (colorKeywords.hasOwnProperty(word))
|
299 |
+
override = "keyword";
|
300 |
+
else
|
301 |
+
override = "error";
|
302 |
+
}
|
303 |
+
return state.context.type;
|
304 |
+
};
|
305 |
+
|
306 |
+
states.atComponentBlock = function(type, stream, state) {
|
307 |
+
if (type == "}")
|
308 |
+
return popAndPass(type, stream, state);
|
309 |
+
if (type == "{")
|
310 |
+
return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
|
311 |
+
if (type == "word")
|
312 |
+
override = "error";
|
313 |
+
return state.context.type;
|
314 |
+
};
|
315 |
+
|
316 |
+
states.atBlock_parens = function(type, stream, state) {
|
317 |
+
if (type == ")") return popContext(state);
|
318 |
+
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
319 |
+
return states.atBlock(type, stream, state);
|
320 |
+
};
|
321 |
+
|
322 |
+
states.restricted_atBlock_before = function(type, stream, state) {
|
323 |
+
if (type == "{")
|
324 |
+
return pushContext(state, stream, "restricted_atBlock");
|
325 |
+
if (type == "word" && state.stateArg == "@counter-style") {
|
326 |
+
override = "variable";
|
327 |
+
return "restricted_atBlock_before";
|
328 |
+
}
|
329 |
+
return pass(type, stream, state);
|
330 |
+
};
|
331 |
+
|
332 |
+
states.restricted_atBlock = function(type, stream, state) {
|
333 |
+
if (type == "}") {
|
334 |
+
state.stateArg = null;
|
335 |
+
return popContext(state);
|
336 |
+
}
|
337 |
+
if (type == "word") {
|
338 |
+
if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
|
339 |
+
(state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
|
340 |
+
override = "error";
|
341 |
+
else
|
342 |
+
override = "property";
|
343 |
+
return "maybeprop";
|
344 |
+
}
|
345 |
+
return "restricted_atBlock";
|
346 |
+
};
|
347 |
+
|
348 |
+
states.keyframes = function(type, stream, state) {
|
349 |
+
if (type == "word") { override = "variable"; return "keyframes"; }
|
350 |
+
if (type == "{") return pushContext(state, stream, "top");
|
351 |
+
return pass(type, stream, state);
|
352 |
+
};
|
353 |
+
|
354 |
+
states.at = function(type, stream, state) {
|
355 |
+
if (type == ";") return popContext(state);
|
356 |
+
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
357 |
+
if (type == "word") override = "tag";
|
358 |
+
else if (type == "hash") override = "builtin";
|
359 |
+
return "at";
|
360 |
+
};
|
361 |
+
|
362 |
+
states.interpolation = function(type, stream, state) {
|
363 |
+
if (type == "}") return popContext(state);
|
364 |
+
if (type == "{" || type == ";") return popAndPass(type, stream, state);
|
365 |
+
if (type == "word") override = "variable";
|
366 |
+
else if (type != "variable" && type != "(" && type != ")") override = "error";
|
367 |
+
return "interpolation";
|
368 |
+
};
|
369 |
+
|
370 |
+
return {
|
371 |
+
startState: function(base) {
|
372 |
+
return {tokenize: null,
|
373 |
+
state: inline ? "block" : "top",
|
374 |
+
stateArg: null,
|
375 |
+
context: new Context(inline ? "block" : "top", base || 0, null)};
|
376 |
+
},
|
377 |
+
|
378 |
+
token: function(stream, state) {
|
379 |
+
if (!state.tokenize && stream.eatSpace()) return null;
|
380 |
+
var style = (state.tokenize || tokenBase)(stream, state);
|
381 |
+
if (style && typeof style == "object") {
|
382 |
+
type = style[1];
|
383 |
+
style = style[0];
|
384 |
+
}
|
385 |
+
override = style;
|
386 |
+
if (type != "comment")
|
387 |
+
state.state = states[state.state](type, stream, state);
|
388 |
+
return override;
|
389 |
+
},
|
390 |
+
|
391 |
+
indent: function(state, textAfter) {
|
392 |
+
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
393 |
+
var indent = cx.indent;
|
394 |
+
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
395 |
+
if (cx.prev) {
|
396 |
+
if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
|
397 |
+
cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
|
398 |
+
// Resume indentation from parent context.
|
399 |
+
cx = cx.prev;
|
400 |
+
indent = cx.indent;
|
401 |
+
} else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
|
402 |
+
ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
|
403 |
+
// Dedent relative to current context.
|
404 |
+
indent = Math.max(0, cx.indent - indentUnit);
|
405 |
+
}
|
406 |
+
}
|
407 |
+
return indent;
|
408 |
+
},
|
409 |
+
|
410 |
+
electricChars: "}",
|
411 |
+
blockCommentStart: "/*",
|
412 |
+
blockCommentEnd: "*/",
|
413 |
+
blockCommentContinue: " * ",
|
414 |
+
lineComment: lineComment,
|
415 |
+
fold: "brace"
|
416 |
+
};
|
417 |
+
});
|
418 |
+
|
419 |
+
function keySet(array) {
|
420 |
+
var keys = {};
|
421 |
+
for (var i = 0; i < array.length; ++i) {
|
422 |
+
keys[array[i].toLowerCase()] = true;
|
423 |
+
}
|
424 |
+
return keys;
|
425 |
+
}
|
426 |
+
|
427 |
+
var documentTypes_ = [
|
428 |
+
"domain", "regexp", "url", "url-prefix"
|
429 |
+
], documentTypes = keySet(documentTypes_);
|
430 |
+
|
431 |
+
var mediaTypes_ = [
|
432 |
+
"all", "aural", "braille", "handheld", "print", "projection", "screen",
|
433 |
+
"tty", "tv", "embossed"
|
434 |
+
], mediaTypes = keySet(mediaTypes_);
|
435 |
+
|
436 |
+
var mediaFeatures_ = [
|
437 |
+
"width", "min-width", "max-width", "height", "min-height", "max-height",
|
438 |
+
"device-width", "min-device-width", "max-device-width", "device-height",
|
439 |
+
"min-device-height", "max-device-height", "aspect-ratio",
|
440 |
+
"min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
|
441 |
+
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
|
442 |
+
"max-color", "color-index", "min-color-index", "max-color-index",
|
443 |
+
"monochrome", "min-monochrome", "max-monochrome", "resolution",
|
444 |
+
"min-resolution", "max-resolution", "scan", "grid", "orientation",
|
445 |
+
"device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
|
446 |
+
"pointer", "any-pointer", "hover", "any-hover"
|
447 |
+
], mediaFeatures = keySet(mediaFeatures_);
|
448 |
+
|
449 |
+
var mediaValueKeywords_ = [
|
450 |
+
"landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
|
451 |
+
"interlace", "progressive"
|
452 |
+
], mediaValueKeywords = keySet(mediaValueKeywords_);
|
453 |
+
|
454 |
+
var propertyKeywords_ = [
|
455 |
+
"align-content", "align-items", "align-self", "alignment-adjust",
|
456 |
+
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
457 |
+
"animation-direction", "animation-duration", "animation-fill-mode",
|
458 |
+
"animation-iteration-count", "animation-name", "animation-play-state",
|
459 |
+
"animation-timing-function", "appearance", "azimuth", "backface-visibility",
|
460 |
+
"background", "background-attachment", "background-blend-mode", "background-clip",
|
461 |
+
"background-color", "background-image", "background-origin", "background-position",
|
462 |
+
"background-repeat", "background-size", "baseline-shift", "binding",
|
463 |
+
"bleed", "bookmark-label", "bookmark-level", "bookmark-state",
|
464 |
+
"bookmark-target", "border", "border-bottom", "border-bottom-color",
|
465 |
+
"border-bottom-left-radius", "border-bottom-right-radius",
|
466 |
+
"border-bottom-style", "border-bottom-width", "border-collapse",
|
467 |
+
"border-color", "border-image", "border-image-outset",
|
468 |
+
"border-image-repeat", "border-image-slice", "border-image-source",
|
469 |
+
"border-image-width", "border-left", "border-left-color",
|
470 |
+
"border-left-style", "border-left-width", "border-radius", "border-right",
|
471 |
+
"border-right-color", "border-right-style", "border-right-width",
|
472 |
+
"border-spacing", "border-style", "border-top", "border-top-color",
|
473 |
+
"border-top-left-radius", "border-top-right-radius", "border-top-style",
|
474 |
+
"border-top-width", "border-width", "bottom", "box-decoration-break",
|
475 |
+
"box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
|
476 |
+
"caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
|
477 |
+
"column-fill", "column-gap", "column-rule", "column-rule-color",
|
478 |
+
"column-rule-style", "column-rule-width", "column-span", "column-width",
|
479 |
+
"columns", "content", "counter-increment", "counter-reset", "crop", "cue",
|
480 |
+
"cue-after", "cue-before", "cursor", "direction", "display",
|
481 |
+
"dominant-baseline", "drop-initial-after-adjust",
|
482 |
+
"drop-initial-after-align", "drop-initial-before-adjust",
|
483 |
+
"drop-initial-before-align", "drop-initial-size", "drop-initial-value",
|
484 |
+
"elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
|
485 |
+
"flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
|
486 |
+
"float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
|
487 |
+
"font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
|
488 |
+
"font-stretch", "font-style", "font-synthesis", "font-variant",
|
489 |
+
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
|
490 |
+
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
|
491 |
+
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
|
492 |
+
"grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
|
493 |
+
"grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
|
494 |
+
"grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
|
495 |
+
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
|
496 |
+
"icon", "image-orientation", "image-rendering", "image-resolution",
|
497 |
+
"inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
|
498 |
+
"line-break", "line-height", "line-stacking", "line-stacking-ruby",
|
499 |
+
"line-stacking-shift", "line-stacking-strategy", "list-style",
|
500 |
+
"list-style-image", "list-style-position", "list-style-type", "margin",
|
501 |
+
"margin-bottom", "margin-left", "margin-right", "margin-top",
|
502 |
+
"marks", "marquee-direction", "marquee-loop",
|
503 |
+
"marquee-play-count", "marquee-speed", "marquee-style", "max-height",
|
504 |
+
"max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
|
505 |
+
"nav-left", "nav-right", "nav-up", "object-fit", "object-position",
|
506 |
+
"opacity", "order", "orphans", "outline",
|
507 |
+
"outline-color", "outline-offset", "outline-style", "outline-width",
|
508 |
+
"overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
|
509 |
+
"padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
|
510 |
+
"page", "page-break-after", "page-break-before", "page-break-inside",
|
511 |
+
"page-policy", "pause", "pause-after", "pause-before", "perspective",
|
512 |
+
"perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
|
513 |
+
"presentation-level", "punctuation-trim", "quotes", "region-break-after",
|
514 |
+
"region-break-before", "region-break-inside", "region-fragment",
|
515 |
+
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
|
516 |
+
"right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
|
517 |
+
"ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
|
518 |
+
"shape-outside", "size", "speak", "speak-as", "speak-header",
|
519 |
+
"speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
|
520 |
+
"tab-size", "table-layout", "target", "target-name", "target-new",
|
521 |
+
"target-position", "text-align", "text-align-last", "text-decoration",
|
522 |
+
"text-decoration-color", "text-decoration-line", "text-decoration-skip",
|
523 |
+
"text-decoration-style", "text-emphasis", "text-emphasis-color",
|
524 |
+
"text-emphasis-position", "text-emphasis-style", "text-height",
|
525 |
+
"text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
|
526 |
+
"text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
|
527 |
+
"text-wrap", "top", "transform", "transform-origin", "transform-style",
|
528 |
+
"transition", "transition-delay", "transition-duration",
|
529 |
+
"transition-property", "transition-timing-function", "unicode-bidi",
|
530 |
+
"user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
|
531 |
+
"voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
|
532 |
+
"voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
|
533 |
+
"word-spacing", "word-wrap", "z-index",
|
534 |
+
// SVG-specific
|
535 |
+
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
|
536 |
+
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
|
537 |
+
"color-interpolation", "color-interpolation-filters",
|
538 |
+
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
|
539 |
+
"marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
|
540 |
+
"stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
|
541 |
+
"stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
|
542 |
+
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
|
543 |
+
"glyph-orientation-vertical", "text-anchor", "writing-mode"
|
544 |
+
], propertyKeywords = keySet(propertyKeywords_);
|
545 |
+
|
546 |
+
var nonStandardPropertyKeywords_ = [
|
547 |
+
"scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
|
548 |
+
"scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
|
549 |
+
"scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
|
550 |
+
"searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
|
551 |
+
"searchfield-results-decoration", "zoom"
|
552 |
+
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
|
553 |
+
|
554 |
+
var fontProperties_ = [
|
555 |
+
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
|
556 |
+
"font-stretch", "font-weight", "font-style"
|
557 |
+
], fontProperties = keySet(fontProperties_);
|
558 |
+
|
559 |
+
var counterDescriptors_ = [
|
560 |
+
"additive-symbols", "fallback", "negative", "pad", "prefix", "range",
|
561 |
+
"speak-as", "suffix", "symbols", "system"
|
562 |
+
], counterDescriptors = keySet(counterDescriptors_);
|
563 |
+
|
564 |
+
var colorKeywords_ = [
|
565 |
+
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
|
566 |
+
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
|
567 |
+
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
|
568 |
+
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
|
569 |
+
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
|
570 |
+
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
571 |
+
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
|
572 |
+
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
|
573 |
+
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
574 |
+
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
|
575 |
+
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
|
576 |
+
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
|
577 |
+
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
|
578 |
+
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
|
579 |
+
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
|
580 |
+
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
|
581 |
+
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
582 |
+
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
|
583 |
+
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
|
584 |
+
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
|
585 |
+
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
586 |
+
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
|
587 |
+
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
|
588 |
+
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
|
589 |
+
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
|
590 |
+
"whitesmoke", "yellow", "yellowgreen"
|
591 |
+
], colorKeywords = keySet(colorKeywords_);
|
592 |
+
|
593 |
+
var valueKeywords_ = [
|
594 |
+
"above", "absolute", "activeborder", "additive", "activecaption", "afar",
|
595 |
+
"after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
|
596 |
+
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
|
597 |
+
"arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
|
598 |
+
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
|
599 |
+
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
|
600 |
+
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
|
601 |
+
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
|
602 |
+
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
603 |
+
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
|
604 |
+
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
|
605 |
+
"col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
|
606 |
+
"compact", "condensed", "contain", "content", "contents",
|
607 |
+
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
|
608 |
+
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
|
609 |
+
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
|
610 |
+
"destination-in", "destination-out", "destination-over", "devanagari", "difference",
|
611 |
+
"disc", "discard", "disclosure-closed", "disclosure-open", "document",
|
612 |
+
"dot-dash", "dot-dot-dash",
|
613 |
+
"dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
|
614 |
+
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
|
615 |
+
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
|
616 |
+
"ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
|
617 |
+
"ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
|
618 |
+
"ethiopic-halehame-gez", "ethiopic-halehame-om-et",
|
619 |
+
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
|
620 |
+
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
|
621 |
+
"ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
|
622 |
+
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
|
623 |
+
"forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
|
624 |
+
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
|
625 |
+
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
|
626 |
+
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
|
627 |
+
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
|
628 |
+
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
|
629 |
+
"inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
|
630 |
+
"italic", "japanese-formal", "japanese-informal", "justify", "kannada",
|
631 |
+
"katakana", "katakana-iroha", "keep-all", "khmer",
|
632 |
+
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
|
633 |
+
"landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
|
634 |
+
"line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
|
635 |
+
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
|
636 |
+
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
|
637 |
+
"lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
|
638 |
+
"media-controls-background", "media-current-time-display",
|
639 |
+
"media-fullscreen-button", "media-mute-button", "media-play-button",
|
640 |
+
"media-return-to-realtime-button", "media-rewind-button",
|
641 |
+
"media-seek-back-button", "media-seek-forward-button", "media-slider",
|
642 |
+
"media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
|
643 |
+
"media-volume-slider-container", "media-volume-sliderthumb", "medium",
|
644 |
+
"menu", "menulist", "menulist-button", "menulist-text",
|
645 |
+
"menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
|
646 |
+
"mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
|
647 |
+
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
|
648 |
+
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
|
649 |
+
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
|
650 |
+
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
|
651 |
+
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
|
652 |
+
"painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
|
653 |
+
"pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
|
654 |
+
"progress", "push-button", "radial-gradient", "radio", "read-only",
|
655 |
+
"read-write", "read-write-plaintext-only", "rectangle", "region",
|
656 |
+
"relative", "repeat", "repeating-linear-gradient",
|
657 |
+
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
658 |
+
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
|
659 |
+
"rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
|
660 |
+
"s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
|
661 |
+
"scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
|
662 |
+
"searchfield-cancel-button", "searchfield-decoration",
|
663 |
+
"searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
|
664 |
+
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
|
665 |
+
"simp-chinese-formal", "simp-chinese-informal", "single",
|
666 |
+
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
667 |
+
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
668 |
+
"small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
|
669 |
+
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
|
670 |
+
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
671 |
+
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
|
672 |
+
"table-caption", "table-cell", "table-column", "table-column-group",
|
673 |
+
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
674 |
+
"tamil",
|
675 |
+
"telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
|
676 |
+
"thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
|
677 |
+
"threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
|
678 |
+
"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
|
679 |
+
"trad-chinese-formal", "trad-chinese-informal", "transform",
|
680 |
+
"translate", "translate3d", "translateX", "translateY", "translateZ",
|
681 |
+
"transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
|
682 |
+
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
|
683 |
+
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
684 |
+
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
685 |
+
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
686 |
+
"window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
|
687 |
+
"xx-large", "xx-small"
|
688 |
+
], valueKeywords = keySet(valueKeywords_);
|
689 |
+
|
690 |
+
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
|
691 |
+
.concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
|
692 |
+
.concat(valueKeywords_);
|
693 |
+
CodeMirror.registerHelper("hintWords", "css", allWords);
|
694 |
+
|
695 |
+
function tokenCComment(stream, state) {
|
696 |
+
var maybeEnd = false, ch;
|
697 |
+
while ((ch = stream.next()) != null) {
|
698 |
+
if (maybeEnd && ch == "/") {
|
699 |
+
state.tokenize = null;
|
700 |
+
break;
|
701 |
+
}
|
702 |
+
maybeEnd = (ch == "*");
|
703 |
+
}
|
704 |
+
return ["comment", "comment"];
|
705 |
+
}
|
706 |
+
|
707 |
+
CodeMirror.defineMIME("text/css", {
|
708 |
+
documentTypes: documentTypes,
|
709 |
+
mediaTypes: mediaTypes,
|
710 |
+
mediaFeatures: mediaFeatures,
|
711 |
+
mediaValueKeywords: mediaValueKeywords,
|
712 |
+
propertyKeywords: propertyKeywords,
|
713 |
+
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
714 |
+
fontProperties: fontProperties,
|
715 |
+
counterDescriptors: counterDescriptors,
|
716 |
+
colorKeywords: colorKeywords,
|
717 |
+
valueKeywords: valueKeywords,
|
718 |
+
tokenHooks: {
|
719 |
+
"/": function(stream, state) {
|
720 |
+
if (!stream.eat("*")) return false;
|
721 |
+
state.tokenize = tokenCComment;
|
722 |
+
return tokenCComment(stream, state);
|
723 |
+
}
|
724 |
+
},
|
725 |
+
name: "css"
|
726 |
+
});
|
727 |
+
|
728 |
+
CodeMirror.defineMIME("text/x-scss", {
|
729 |
+
mediaTypes: mediaTypes,
|
730 |
+
mediaFeatures: mediaFeatures,
|
731 |
+
mediaValueKeywords: mediaValueKeywords,
|
732 |
+
propertyKeywords: propertyKeywords,
|
733 |
+
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
734 |
+
colorKeywords: colorKeywords,
|
735 |
+
valueKeywords: valueKeywords,
|
736 |
+
fontProperties: fontProperties,
|
737 |
+
allowNested: true,
|
738 |
+
lineComment: "//",
|
739 |
+
tokenHooks: {
|
740 |
+
"/": function(stream, state) {
|
741 |
+
if (stream.eat("/")) {
|
742 |
+
stream.skipToEnd();
|
743 |
+
return ["comment", "comment"];
|
744 |
+
} else if (stream.eat("*")) {
|
745 |
+
state.tokenize = tokenCComment;
|
746 |
+
return tokenCComment(stream, state);
|
747 |
+
} else {
|
748 |
+
return ["operator", "operator"];
|
749 |
+
}
|
750 |
+
},
|
751 |
+
":": function(stream) {
|
752 |
+
if (stream.match(/\s*\{/, false))
|
753 |
+
return [null, null]
|
754 |
+
return false;
|
755 |
+
},
|
756 |
+
"$": function(stream) {
|
757 |
+
stream.match(/^[\w-]+/);
|
758 |
+
if (stream.match(/^\s*:/, false))
|
759 |
+
return ["variable-2", "variable-definition"];
|
760 |
+
return ["variable-2", "variable"];
|
761 |
+
},
|
762 |
+
"#": function(stream) {
|
763 |
+
if (!stream.eat("{")) return false;
|
764 |
+
return [null, "interpolation"];
|
765 |
+
}
|
766 |
+
},
|
767 |
+
name: "css",
|
768 |
+
helperType: "scss"
|
769 |
+
});
|
770 |
+
|
771 |
+
CodeMirror.defineMIME("text/x-less", {
|
772 |
+
mediaTypes: mediaTypes,
|
773 |
+
mediaFeatures: mediaFeatures,
|
774 |
+
mediaValueKeywords: mediaValueKeywords,
|
775 |
+
propertyKeywords: propertyKeywords,
|
776 |
+
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
777 |
+
colorKeywords: colorKeywords,
|
778 |
+
valueKeywords: valueKeywords,
|
779 |
+
fontProperties: fontProperties,
|
780 |
+
allowNested: true,
|
781 |
+
lineComment: "//",
|
782 |
+
tokenHooks: {
|
783 |
+
"/": function(stream, state) {
|
784 |
+
if (stream.eat("/")) {
|
785 |
+
stream.skipToEnd();
|
786 |
+
return ["comment", "comment"];
|
787 |
+
} else if (stream.eat("*")) {
|
788 |
+
state.tokenize = tokenCComment;
|
789 |
+
return tokenCComment(stream, state);
|
790 |
+
} else {
|
791 |
+
return ["operator", "operator"];
|
792 |
+
}
|
793 |
+
},
|
794 |
+
"@": function(stream) {
|
795 |
+
if (stream.eat("{")) return [null, "interpolation"];
|
796 |
+
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false;
|
797 |
+
stream.eatWhile(/[\w\\\-]/);
|
798 |
+
if (stream.match(/^\s*:/, false))
|
799 |
+
return ["variable-2", "variable-definition"];
|
800 |
+
return ["variable-2", "variable"];
|
801 |
+
},
|
802 |
+
"&": function() {
|
803 |
+
return ["atom", "atom"];
|
804 |
+
}
|
805 |
+
},
|
806 |
+
name: "css",
|
807 |
+
helperType: "less"
|
808 |
+
});
|
809 |
+
|
810 |
+
CodeMirror.defineMIME("text/x-gss", {
|
811 |
+
documentTypes: documentTypes,
|
812 |
+
mediaTypes: mediaTypes,
|
813 |
+
mediaFeatures: mediaFeatures,
|
814 |
+
propertyKeywords: propertyKeywords,
|
815 |
+
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
816 |
+
fontProperties: fontProperties,
|
817 |
+
counterDescriptors: counterDescriptors,
|
818 |
+
colorKeywords: colorKeywords,
|
819 |
+
valueKeywords: valueKeywords,
|
820 |
+
supportsAtComponent: true,
|
821 |
+
tokenHooks: {
|
822 |
+
"/": function(stream, state) {
|
823 |
+
if (!stream.eat("*")) return false;
|
824 |
+
state.tokenize = tokenCComment;
|
825 |
+
return tokenCComment(stream, state);
|
826 |
+
}
|
827 |
+
},
|
828 |
+
name: "css",
|
829 |
+
helperType: "gss"
|
830 |
+
});
|
831 |
+
|
832 |
+
});
|
inc/lib/codemirror/mode/css/gss.html
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: Closure Stylesheets (GSS) mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
9 |
+
<script src="../../lib/codemirror.js"></script>
|
10 |
+
<script src="css.js"></script>
|
11 |
+
<script src="../../addon/hint/show-hint.js"></script>
|
12 |
+
<script src="../../addon/hint/css-hint.js"></script>
|
13 |
+
<style>.CodeMirror {background: #f8f8f8;}</style>
|
14 |
+
<div id=nav>
|
15 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
16 |
+
|
17 |
+
<ul>
|
18 |
+
<li><a href="../../index.html">Home</a>
|
19 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
20 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
21 |
+
</ul>
|
22 |
+
<ul>
|
23 |
+
<li><a href="../index.html">Language modes</a>
|
24 |
+
<li><a class=active href="#">Closure Stylesheets (GSS)</a>
|
25 |
+
</ul>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<article>
|
29 |
+
<h2>Closure Stylesheets (GSS) mode</h2>
|
30 |
+
<form><textarea id="code" name="code">
|
31 |
+
/* Some example Closure Stylesheets */
|
32 |
+
|
33 |
+
@provide 'some.styles';
|
34 |
+
|
35 |
+
@require 'other.styles';
|
36 |
+
|
37 |
+
@component {
|
38 |
+
|
39 |
+
@def FONT_FAMILY "Times New Roman", Georgia, Serif;
|
40 |
+
@def FONT_SIZE_NORMAL 15px;
|
41 |
+
@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
|
42 |
+
|
43 |
+
@def BG_COLOR rgb(235, 239, 249);
|
44 |
+
|
45 |
+
@def DIALOG_BORDER_COLOR rgb(107, 144, 218);
|
46 |
+
@def DIALOG_BG_COLOR BG_COLOR;
|
47 |
+
|
48 |
+
@def LEFT_HAND_NAV_WIDTH 180px;
|
49 |
+
@def LEFT_HAND_NAV_PADDING 3px;
|
50 |
+
|
51 |
+
@defmixin size(WIDTH, HEIGHT) {
|
52 |
+
width: WIDTH;
|
53 |
+
height: HEIGHT;
|
54 |
+
}
|
55 |
+
|
56 |
+
body {
|
57 |
+
background-color: BG_COLOR;
|
58 |
+
margin: 0;
|
59 |
+
padding: 3em 6em;
|
60 |
+
font: FONT_NORMAL;
|
61 |
+
color: #000;
|
62 |
+
}
|
63 |
+
|
64 |
+
#navigation a {
|
65 |
+
font-weight: bold;
|
66 |
+
text-decoration: none !important;
|
67 |
+
}
|
68 |
+
|
69 |
+
.dialog {
|
70 |
+
background-color: DIALOG_BG_COLOR;
|
71 |
+
border: 1px solid DIALOG_BORDER_COLOR;
|
72 |
+
}
|
73 |
+
|
74 |
+
.content {
|
75 |
+
position: absolute;
|
76 |
+
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
|
77 |
+
LEFT_HAND_NAV_WIDTH,
|
78 |
+
LEFT_HAND_NAV_PADDING); /* padding right */
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
.logo {
|
83 |
+
@mixin size(150px, 55px);
|
84 |
+
background-image: url('http://www.google.com/images/logo_sm.gif');
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
</textarea></form>
|
89 |
+
<script>
|
90 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
91 |
+
extraKeys: {"Ctrl-Space": "autocomplete"},
|
92 |
+
lineNumbers: true,
|
93 |
+
matchBrackets: "text/x-less",
|
94 |
+
mode: "text/x-gss"
|
95 |
+
});
|
96 |
+
</script>
|
97 |
+
|
98 |
+
<p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
|
99 |
+
<p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
|
100 |
+
|
101 |
+
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
|
102 |
+
|
103 |
+
</article>
|
inc/lib/codemirror/mode/css/gss_test.js
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
"use strict";
|
6 |
+
|
7 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss");
|
8 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); }
|
9 |
+
|
10 |
+
MT("atComponent",
|
11 |
+
"[def @component] {",
|
12 |
+
"[tag foo] {",
|
13 |
+
" [property color]: [keyword black];",
|
14 |
+
"}",
|
15 |
+
"}");
|
16 |
+
|
17 |
+
})();
|
inc/lib/codemirror/mode/css/index.html
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: CSS mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
9 |
+
<script src="../../lib/codemirror.js"></script>
|
10 |
+
<script src="css.js"></script>
|
11 |
+
<script src="../../addon/hint/show-hint.js"></script>
|
12 |
+
<script src="../../addon/hint/css-hint.js"></script>
|
13 |
+
<style>.CodeMirror {background: #f8f8f8;}</style>
|
14 |
+
<div id=nav>
|
15 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
16 |
+
|
17 |
+
<ul>
|
18 |
+
<li><a href="../../index.html">Home</a>
|
19 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
20 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
21 |
+
</ul>
|
22 |
+
<ul>
|
23 |
+
<li><a href="../index.html">Language modes</a>
|
24 |
+
<li><a class=active href="#">CSS</a>
|
25 |
+
</ul>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<article>
|
29 |
+
<h2>CSS mode</h2>
|
30 |
+
<form><textarea id="code" name="code">
|
31 |
+
/* Some example CSS */
|
32 |
+
|
33 |
+
@import url("something.css");
|
34 |
+
|
35 |
+
body {
|
36 |
+
margin: 0;
|
37 |
+
padding: 3em 6em;
|
38 |
+
font-family: tahoma, arial, sans-serif;
|
39 |
+
color: #000;
|
40 |
+
}
|
41 |
+
|
42 |
+
#navigation a {
|
43 |
+
font-weight: bold;
|
44 |
+
text-decoration: none !important;
|
45 |
+
}
|
46 |
+
|
47 |
+
h1 {
|
48 |
+
font-size: 2.5em;
|
49 |
+
}
|
50 |
+
|
51 |
+
h2 {
|
52 |
+
font-size: 1.7em;
|
53 |
+
}
|
54 |
+
|
55 |
+
h1:before, h2:before {
|
56 |
+
content: "::";
|
57 |
+
}
|
58 |
+
|
59 |
+
code {
|
60 |
+
font-family: courier, monospace;
|
61 |
+
font-size: 80%;
|
62 |
+
color: #418A8A;
|
63 |
+
}
|
64 |
+
</textarea></form>
|
65 |
+
<script>
|
66 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
67 |
+
extraKeys: {"Ctrl-Space": "autocomplete"}
|
68 |
+
});
|
69 |
+
</script>
|
70 |
+
|
71 |
+
<p><strong>MIME types defined:</strong> <code>text/css</code>, <code>text/x-scss</code> (<a href="scss.html">demo</a>), <code>text/x-less</code> (<a href="less.html">demo</a>).</p>
|
72 |
+
|
73 |
+
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#css_*">normal</a>, <a href="../../test/index.html#verbose,css_*">verbose</a>.</p>
|
74 |
+
|
75 |
+
</article>
|
inc/lib/codemirror/mode/css/less.html
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: LESS mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
10 |
+
<script src="css.js"></script>
|
11 |
+
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style>
|
12 |
+
<div id=nav>
|
13 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
14 |
+
|
15 |
+
<ul>
|
16 |
+
<li><a href="../../index.html">Home</a>
|
17 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
18 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
19 |
+
</ul>
|
20 |
+
<ul>
|
21 |
+
<li><a href="../index.html">Language modes</a>
|
22 |
+
<li><a class=active href="#">LESS</a>
|
23 |
+
</ul>
|
24 |
+
</div>
|
25 |
+
|
26 |
+
<article>
|
27 |
+
<h2>LESS mode</h2>
|
28 |
+
<form><textarea id="code" name="code">@media screen and (device-aspect-ratio: 16/9) { … }
|
29 |
+
@media screen and (device-aspect-ratio: 1280/720) { … }
|
30 |
+
@media screen and (device-aspect-ratio: 2560/1440) { … }
|
31 |
+
|
32 |
+
html:lang(fr-be)
|
33 |
+
|
34 |
+
tr:nth-child(2n+1) /* represents every odd row of an HTML table */
|
35 |
+
|
36 |
+
img:nth-of-type(2n+1) { float: right; }
|
37 |
+
img:nth-of-type(2n) { float: left; }
|
38 |
+
|
39 |
+
body > h2:not(:first-of-type):not(:last-of-type)
|
40 |
+
|
41 |
+
html|*:not(:link):not(:visited)
|
42 |
+
*|*:not(:hover)
|
43 |
+
p::first-line { text-transform: uppercase }
|
44 |
+
|
45 |
+
@namespace foo url(http://www.example.com);
|
46 |
+
foo|h1 { color: blue } /* first rule */
|
47 |
+
|
48 |
+
span[hello="Ocean"][goodbye="Land"]
|
49 |
+
|
50 |
+
E[foo]{
|
51 |
+
padding:65px;
|
52 |
+
}
|
53 |
+
|
54 |
+
input[type="search"]::-webkit-search-decoration,
|
55 |
+
input[type="search"]::-webkit-search-cancel-button {
|
56 |
+
-webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
|
57 |
+
}
|
58 |
+
button::-moz-focus-inner,
|
59 |
+
input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
|
60 |
+
padding: 0;
|
61 |
+
border: 0;
|
62 |
+
}
|
63 |
+
.btn {
|
64 |
+
// reset here as of 2.0.3 due to Recess property order
|
65 |
+
border-color: #ccc;
|
66 |
+
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
|
67 |
+
}
|
68 |
+
fieldset span button, fieldset span input[type="file"] {
|
69 |
+
font-size:12px;
|
70 |
+
font-family:Arial, Helvetica, sans-serif;
|
71 |
+
}
|
72 |
+
|
73 |
+
.rounded-corners (@radius: 5px) {
|
74 |
+
border-radius: @radius;
|
75 |
+
-webkit-border-radius: @radius;
|
76 |
+
-moz-border-radius: @radius;
|
77 |
+
}
|
78 |
+
|
79 |
+
@import url("something.css");
|
80 |
+
|
81 |
+
@light-blue: hsl(190, 50%, 65%);
|
82 |
+
|
83 |
+
#menu {
|
84 |
+
position: absolute;
|
85 |
+
width: 100%;
|
86 |
+
z-index: 3;
|
87 |
+
clear: both;
|
88 |
+
display: block;
|
89 |
+
background-color: @blue;
|
90 |
+
height: 42px;
|
91 |
+
border-top: 2px solid lighten(@alpha-blue, 20%);
|
92 |
+
border-bottom: 2px solid darken(@alpha-blue, 25%);
|
93 |
+
.box-shadow(0, 1px, 8px, 0.6);
|
94 |
+
-moz-box-shadow: 0 0 0 #000; // Because firefox sucks.
|
95 |
+
|
96 |
+
&.docked {
|
97 |
+
background-color: hsla(210, 60%, 40%, 0.4);
|
98 |
+
}
|
99 |
+
&:hover {
|
100 |
+
background-color: @blue;
|
101 |
+
}
|
102 |
+
|
103 |
+
#dropdown {
|
104 |
+
margin: 0 0 0 117px;
|
105 |
+
padding: 0;
|
106 |
+
padding-top: 5px;
|
107 |
+
display: none;
|
108 |
+
width: 190px;
|
109 |
+
border-top: 2px solid @medium;
|
110 |
+
color: @highlight;
|
111 |
+
border: 2px solid darken(@medium, 25%);
|
112 |
+
border-left-color: darken(@medium, 15%);
|
113 |
+
border-right-color: darken(@medium, 15%);
|
114 |
+
border-top-width: 0;
|
115 |
+
background-color: darken(@medium, 10%);
|
116 |
+
ul {
|
117 |
+
padding: 0px;
|
118 |
+
}
|
119 |
+
li {
|
120 |
+
font-size: 14px;
|
121 |
+
display: block;
|
122 |
+
text-align: left;
|
123 |
+
padding: 0;
|
124 |
+
border: 0;
|
125 |
+
a {
|
126 |
+
display: block;
|
127 |
+
padding: 0px 15px;
|
128 |
+
text-decoration: none;
|
129 |
+
color: white;
|
130 |
+
&:hover {
|
131 |
+
background-color: darken(@medium, 15%);
|
132 |
+
text-decoration: none;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
.border-radius(5px, bottom);
|
137 |
+
.box-shadow(0, 6px, 8px, 0.5);
|
138 |
+
}
|
139 |
+
}
|
140 |
+
</textarea></form>
|
141 |
+
<script>
|
142 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
143 |
+
lineNumbers : true,
|
144 |
+
matchBrackets : true,
|
145 |
+
mode: "text/x-less"
|
146 |
+
});
|
147 |
+
</script>
|
148 |
+
|
149 |
+
<p>The LESS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
|
150 |
+
|
151 |
+
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#less_*">normal</a>, <a href="../../test/index.html#verbose,less_*">verbose</a>.</p>
|
152 |
+
</article>
|
inc/lib/codemirror/mode/css/less_test.js
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
"use strict";
|
6 |
+
|
7 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less");
|
8 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); }
|
9 |
+
|
10 |
+
MT("variable",
|
11 |
+
"[variable-2 @base]: [atom #f04615];",
|
12 |
+
"[qualifier .class] {",
|
13 |
+
" [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]",
|
14 |
+
" [property color]: [variable saturate]([variable-2 @base], [number 5%]);",
|
15 |
+
"}");
|
16 |
+
|
17 |
+
MT("amp",
|
18 |
+
"[qualifier .child], [qualifier .sibling] {",
|
19 |
+
" [qualifier .parent] [atom &] {",
|
20 |
+
" [property color]: [keyword black];",
|
21 |
+
" }",
|
22 |
+
" [atom &] + [atom &] {",
|
23 |
+
" [property color]: [keyword red];",
|
24 |
+
" }",
|
25 |
+
"}");
|
26 |
+
|
27 |
+
MT("mixin",
|
28 |
+
"[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
|
29 |
+
" [property color]: [atom darken]([variable-2 @color], [number 10%]);",
|
30 |
+
"}",
|
31 |
+
"[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
|
32 |
+
" [property color]: [atom lighten]([variable-2 @color], [number 10%]);",
|
33 |
+
"}",
|
34 |
+
"[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
|
35 |
+
" [property display]: [atom block];",
|
36 |
+
"}",
|
37 |
+
"[variable-2 @switch]: [variable light];",
|
38 |
+
"[qualifier .class] {",
|
39 |
+
" [qualifier .mixin]([variable-2 @switch]; [atom #888]);",
|
40 |
+
"}");
|
41 |
+
|
42 |
+
MT("nest",
|
43 |
+
"[qualifier .one] {",
|
44 |
+
" [def @media] ([property width]: [number 400px]) {",
|
45 |
+
" [property font-size]: [number 1.2em];",
|
46 |
+
" [def @media] [attribute print] [keyword and] [property color] {",
|
47 |
+
" [property color]: [keyword blue];",
|
48 |
+
" }",
|
49 |
+
" }",
|
50 |
+
"}");
|
51 |
+
|
52 |
+
|
53 |
+
MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }");
|
54 |
+
})();
|
inc/lib/codemirror/mode/css/scss.html
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: SCSS mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="css.js"></script>
|
10 |
+
<style>.CodeMirror {background: #f8f8f8;}</style>
|
11 |
+
<div id=nav>
|
12 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
13 |
+
|
14 |
+
<ul>
|
15 |
+
<li><a href="../../index.html">Home</a>
|
16 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
17 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
18 |
+
</ul>
|
19 |
+
<ul>
|
20 |
+
<li><a href="../index.html">Language modes</a>
|
21 |
+
<li><a class=active href="#">SCSS</a>
|
22 |
+
</ul>
|
23 |
+
</div>
|
24 |
+
|
25 |
+
<article>
|
26 |
+
<h2>SCSS mode</h2>
|
27 |
+
<form><textarea id="code" name="code">
|
28 |
+
/* Some example SCSS */
|
29 |
+
|
30 |
+
@import "compass/css3";
|
31 |
+
$variable: #333;
|
32 |
+
|
33 |
+
$blue: #3bbfce;
|
34 |
+
$margin: 16px;
|
35 |
+
|
36 |
+
.content-navigation {
|
37 |
+
#nested {
|
38 |
+
background-color: black;
|
39 |
+
}
|
40 |
+
border-color: $blue;
|
41 |
+
color:
|
42 |
+
darken($blue, 9%);
|
43 |
+
}
|
44 |
+
|
45 |
+
.border {
|
46 |
+
padding: $margin / 2;
|
47 |
+
margin: $margin / 2;
|
48 |
+
border-color: $blue;
|
49 |
+
}
|
50 |
+
|
51 |
+
@mixin table-base {
|
52 |
+
th {
|
53 |
+
text-align: center;
|
54 |
+
font-weight: bold;
|
55 |
+
}
|
56 |
+
td, th {padding: 2px}
|
57 |
+
}
|
58 |
+
|
59 |
+
table.hl {
|
60 |
+
margin: 2em 0;
|
61 |
+
td.ln {
|
62 |
+
text-align: right;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
li {
|
67 |
+
font: {
|
68 |
+
family: serif;
|
69 |
+
weight: bold;
|
70 |
+
size: 1.2em;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
@mixin left($dist) {
|
75 |
+
float: left;
|
76 |
+
margin-left: $dist;
|
77 |
+
}
|
78 |
+
|
79 |
+
#data {
|
80 |
+
@include left(10px);
|
81 |
+
@include table-base;
|
82 |
+
}
|
83 |
+
|
84 |
+
.source {
|
85 |
+
@include flow-into(target);
|
86 |
+
border: 10px solid green;
|
87 |
+
margin: 20px;
|
88 |
+
width: 200px; }
|
89 |
+
|
90 |
+
.new-container {
|
91 |
+
@include flow-from(target);
|
92 |
+
border: 10px solid red;
|
93 |
+
margin: 20px;
|
94 |
+
width: 200px; }
|
95 |
+
|
96 |
+
body {
|
97 |
+
margin: 0;
|
98 |
+
padding: 3em 6em;
|
99 |
+
font-family: tahoma, arial, sans-serif;
|
100 |
+
color: #000;
|
101 |
+
}
|
102 |
+
|
103 |
+
@mixin yellow() {
|
104 |
+
background: yellow;
|
105 |
+
}
|
106 |
+
|
107 |
+
.big {
|
108 |
+
font-size: 14px;
|
109 |
+
}
|
110 |
+
|
111 |
+
.nested {
|
112 |
+
@include border-radius(3px);
|
113 |
+
@extend .big;
|
114 |
+
p {
|
115 |
+
background: whitesmoke;
|
116 |
+
a {
|
117 |
+
color: red;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
#navigation a {
|
123 |
+
font-weight: bold;
|
124 |
+
text-decoration: none !important;
|
125 |
+
}
|
126 |
+
|
127 |
+
h1 {
|
128 |
+
font-size: 2.5em;
|
129 |
+
}
|
130 |
+
|
131 |
+
h2 {
|
132 |
+
font-size: 1.7em;
|
133 |
+
}
|
134 |
+
|
135 |
+
h1:before, h2:before {
|
136 |
+
content: "::";
|
137 |
+
}
|
138 |
+
|
139 |
+
code {
|
140 |
+
font-family: courier, monospace;
|
141 |
+
font-size: 80%;
|
142 |
+
color: #418A8A;
|
143 |
+
}
|
144 |
+
</textarea></form>
|
145 |
+
<script>
|
146 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
147 |
+
lineNumbers: true,
|
148 |
+
matchBrackets: true,
|
149 |
+
mode: "text/x-scss"
|
150 |
+
});
|
151 |
+
</script>
|
152 |
+
|
153 |
+
<p>The SCSS mode is a sub-mode of the <a href="index.html">CSS mode</a> (defined in <code>css.js</code>).</p>
|
154 |
+
|
155 |
+
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p>
|
156 |
+
|
157 |
+
</article>
|
inc/lib/codemirror/mode/css/scss_test.js
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-scss");
|
6 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }
|
7 |
+
|
8 |
+
MT('url_with_quotation',
|
9 |
+
"[tag foo] { [property background]:[atom url]([string test.jpg]) }");
|
10 |
+
|
11 |
+
MT('url_with_double_quotes',
|
12 |
+
"[tag foo] { [property background]:[atom url]([string \"test.jpg\"]) }");
|
13 |
+
|
14 |
+
MT('url_with_single_quotes',
|
15 |
+
"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) }");
|
16 |
+
|
17 |
+
MT('string',
|
18 |
+
"[def @import] [string \"compass/css3\"]");
|
19 |
+
|
20 |
+
MT('important_keyword',
|
21 |
+
"[tag foo] { [property background]:[atom url]([string \'test.jpg\']) [keyword !important] }");
|
22 |
+
|
23 |
+
MT('variable',
|
24 |
+
"[variable-2 $blue]:[atom #333]");
|
25 |
+
|
26 |
+
MT('variable_as_attribute',
|
27 |
+
"[tag foo] { [property color]:[variable-2 $blue] }");
|
28 |
+
|
29 |
+
MT('numbers',
|
30 |
+
"[tag foo] { [property padding]:[number 10px] [number 10] [number 10em] [number 8in] }");
|
31 |
+
|
32 |
+
MT('number_percentage',
|
33 |
+
"[tag foo] { [property width]:[number 80%] }");
|
34 |
+
|
35 |
+
MT('selector',
|
36 |
+
"[builtin #hello][qualifier .world]{}");
|
37 |
+
|
38 |
+
MT('singleline_comment',
|
39 |
+
"[comment // this is a comment]");
|
40 |
+
|
41 |
+
MT('multiline_comment',
|
42 |
+
"[comment /*foobar*/]");
|
43 |
+
|
44 |
+
MT('attribute_with_hyphen',
|
45 |
+
"[tag foo] { [property font-size]:[number 10px] }");
|
46 |
+
|
47 |
+
MT('string_after_attribute',
|
48 |
+
"[tag foo] { [property content]:[string \"::\"] }");
|
49 |
+
|
50 |
+
MT('directives',
|
51 |
+
"[def @include] [qualifier .mixin]");
|
52 |
+
|
53 |
+
MT('basic_structure',
|
54 |
+
"[tag p] { [property background]:[keyword red]; }");
|
55 |
+
|
56 |
+
MT('nested_structure',
|
57 |
+
"[tag p] { [tag a] { [property color]:[keyword red]; } }");
|
58 |
+
|
59 |
+
MT('mixin',
|
60 |
+
"[def @mixin] [tag table-base] {}");
|
61 |
+
|
62 |
+
MT('number_without_semicolon',
|
63 |
+
"[tag p] {[property width]:[number 12]}",
|
64 |
+
"[tag a] {[property color]:[keyword red];}");
|
65 |
+
|
66 |
+
MT('atom_in_nested_block',
|
67 |
+
"[tag p] { [tag a] { [property color]:[atom #000]; } }");
|
68 |
+
|
69 |
+
MT('interpolation_in_property',
|
70 |
+
"[tag foo] { #{[variable-2 $hello]}:[number 2]; }");
|
71 |
+
|
72 |
+
MT('interpolation_in_selector',
|
73 |
+
"[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }");
|
74 |
+
|
75 |
+
MT('interpolation_error',
|
76 |
+
"[tag foo]#{[variable foo]} { [property color]:[atom #000]; }");
|
77 |
+
|
78 |
+
MT("divide_operator",
|
79 |
+
"[tag foo] { [property width]:[number 4] [operator /] [number 2] }");
|
80 |
+
|
81 |
+
MT('nested_structure_with_id_selector',
|
82 |
+
"[tag p] { [builtin #hello] { [property color]:[keyword red]; } }");
|
83 |
+
|
84 |
+
MT('indent_mixin',
|
85 |
+
"[def @mixin] [tag container] (",
|
86 |
+
" [variable-2 $a]: [number 10],",
|
87 |
+
" [variable-2 $b]: [number 10])",
|
88 |
+
"{}");
|
89 |
+
|
90 |
+
MT('indent_nested',
|
91 |
+
"[tag foo] {",
|
92 |
+
" [tag bar] {",
|
93 |
+
" }",
|
94 |
+
"}");
|
95 |
+
|
96 |
+
MT('indent_parentheses',
|
97 |
+
"[tag foo] {",
|
98 |
+
" [property color]: [atom darken]([variable-2 $blue],",
|
99 |
+
" [number 9%]);",
|
100 |
+
"}");
|
101 |
+
|
102 |
+
MT('indent_vardef',
|
103 |
+
"[variable-2 $name]:",
|
104 |
+
" [string 'val'];",
|
105 |
+
"[tag tag] {",
|
106 |
+
" [tag inner] {",
|
107 |
+
" [property margin]: [number 3px];",
|
108 |
+
" }",
|
109 |
+
"}");
|
110 |
+
})();
|
inc/lib/codemirror/mode/css/test.js
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "css");
|
6 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
7 |
+
|
8 |
+
// Error, because "foobarhello" is neither a known type or property, but
|
9 |
+
// property was expected (after "and"), and it should be in parentheses.
|
10 |
+
MT("atMediaUnknownType",
|
11 |
+
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
|
12 |
+
|
13 |
+
// Soft error, because "foobarhello" is not a known property or type.
|
14 |
+
MT("atMediaUnknownProperty",
|
15 |
+
"[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
|
16 |
+
|
17 |
+
// Make sure nesting works with media queries
|
18 |
+
MT("atMediaMaxWidthNested",
|
19 |
+
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
|
20 |
+
|
21 |
+
MT("atMediaFeatureValueKeyword",
|
22 |
+
"[def @media] ([property orientation]: [keyword landscape]) { }");
|
23 |
+
|
24 |
+
MT("atMediaUnknownFeatureValueKeyword",
|
25 |
+
"[def @media] ([property orientation]: [error upsidedown]) { }");
|
26 |
+
|
27 |
+
MT("atMediaUppercase",
|
28 |
+
"[def @MEDIA] ([property orienTAtion]: [keyword landScape]) { }");
|
29 |
+
|
30 |
+
MT("tagSelector",
|
31 |
+
"[tag foo] { }");
|
32 |
+
|
33 |
+
MT("classSelector",
|
34 |
+
"[qualifier .foo-bar_hello] { }");
|
35 |
+
|
36 |
+
MT("idSelector",
|
37 |
+
"[builtin #foo] { [error #foo] }");
|
38 |
+
|
39 |
+
MT("tagSelectorUnclosed",
|
40 |
+
"[tag foo] { [property margin]: [number 0] } [tag bar] { }");
|
41 |
+
|
42 |
+
MT("tagStringNoQuotes",
|
43 |
+
"[tag foo] { [property font-family]: [variable hello] [variable world]; }");
|
44 |
+
|
45 |
+
MT("tagStringDouble",
|
46 |
+
"[tag foo] { [property font-family]: [string \"hello world\"]; }");
|
47 |
+
|
48 |
+
MT("tagStringSingle",
|
49 |
+
"[tag foo] { [property font-family]: [string 'hello world']; }");
|
50 |
+
|
51 |
+
MT("tagColorKeyword",
|
52 |
+
"[tag foo] {",
|
53 |
+
" [property color]: [keyword black];",
|
54 |
+
" [property color]: [keyword navy];",
|
55 |
+
" [property color]: [keyword yellow];",
|
56 |
+
"}");
|
57 |
+
|
58 |
+
MT("tagColorHex3",
|
59 |
+
"[tag foo] { [property background]: [atom #fff]; }");
|
60 |
+
|
61 |
+
MT("tagColorHex4",
|
62 |
+
"[tag foo] { [property background]: [atom #ffff]; }");
|
63 |
+
|
64 |
+
MT("tagColorHex6",
|
65 |
+
"[tag foo] { [property background]: [atom #ffffff]; }");
|
66 |
+
|
67 |
+
MT("tagColorHex8",
|
68 |
+
"[tag foo] { [property background]: [atom #ffffffff]; }");
|
69 |
+
|
70 |
+
MT("tagColorHex5Invalid",
|
71 |
+
"[tag foo] { [property background]: [atom&error #fffff]; }");
|
72 |
+
|
73 |
+
MT("tagColorHexInvalid",
|
74 |
+
"[tag foo] { [property background]: [atom&error #ffg]; }");
|
75 |
+
|
76 |
+
MT("tagNegativeNumber",
|
77 |
+
"[tag foo] { [property margin]: [number -5px]; }");
|
78 |
+
|
79 |
+
MT("tagPositiveNumber",
|
80 |
+
"[tag foo] { [property padding]: [number 5px]; }");
|
81 |
+
|
82 |
+
MT("tagVendor",
|
83 |
+
"[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
|
84 |
+
|
85 |
+
MT("tagBogusProperty",
|
86 |
+
"[tag foo] { [property&error barhelloworld]: [number 0]; }");
|
87 |
+
|
88 |
+
MT("tagTwoProperties",
|
89 |
+
"[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
|
90 |
+
|
91 |
+
MT("tagTwoPropertiesURL",
|
92 |
+
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
93 |
+
|
94 |
+
MT("indent_tagSelector",
|
95 |
+
"[tag strong], [tag em] {",
|
96 |
+
" [property background]: [atom rgba](",
|
97 |
+
" [number 255], [number 255], [number 0], [number .2]",
|
98 |
+
" );",
|
99 |
+
"}");
|
100 |
+
|
101 |
+
MT("indent_atMedia",
|
102 |
+
"[def @media] {",
|
103 |
+
" [tag foo] {",
|
104 |
+
" [property color]:",
|
105 |
+
" [keyword yellow];",
|
106 |
+
" }",
|
107 |
+
"}");
|
108 |
+
|
109 |
+
MT("indent_comma",
|
110 |
+
"[tag foo] {",
|
111 |
+
" [property font-family]: [variable verdana],",
|
112 |
+
" [atom sans-serif];",
|
113 |
+
"}");
|
114 |
+
|
115 |
+
MT("indent_parentheses",
|
116 |
+
"[tag foo]:[variable-3 before] {",
|
117 |
+
" [property background]: [atom url](",
|
118 |
+
"[string blahblah]",
|
119 |
+
"[string etc]",
|
120 |
+
"[string ]) [keyword !important];",
|
121 |
+
"}");
|
122 |
+
|
123 |
+
MT("font_face",
|
124 |
+
"[def @font-face] {",
|
125 |
+
" [property font-family]: [string 'myfont'];",
|
126 |
+
" [error nonsense]: [string 'abc'];",
|
127 |
+
" [property src]: [atom url]([string http://blah]),",
|
128 |
+
" [atom url]([string http://foo]);",
|
129 |
+
"}");
|
130 |
+
|
131 |
+
MT("empty_url",
|
132 |
+
"[def @import] [atom url]() [attribute screen];");
|
133 |
+
|
134 |
+
MT("parens",
|
135 |
+
"[qualifier .foo] {",
|
136 |
+
" [property background-image]: [variable fade]([atom #000], [number 20%]);",
|
137 |
+
" [property border-image]: [atom linear-gradient](",
|
138 |
+
" [atom to] [atom bottom],",
|
139 |
+
" [variable fade]([atom #000], [number 20%]) [number 0%],",
|
140 |
+
" [variable fade]([atom #000], [number 20%]) [number 100%]",
|
141 |
+
" );",
|
142 |
+
"}");
|
143 |
+
|
144 |
+
MT("css_variable",
|
145 |
+
":[variable-3 root] {",
|
146 |
+
" [variable-2 --main-color]: [atom #06c];",
|
147 |
+
"}",
|
148 |
+
"[tag h1][builtin #foo] {",
|
149 |
+
" [property color]: [atom var]([variable-2 --main-color]);",
|
150 |
+
"}");
|
151 |
+
|
152 |
+
MT("supports",
|
153 |
+
"[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
|
154 |
+
" [property text-align-last]: [atom justify];",
|
155 |
+
"}");
|
156 |
+
|
157 |
+
MT("document",
|
158 |
+
"[def @document] [tag url]([string http://blah]),",
|
159 |
+
" [tag url-prefix]([string https://]),",
|
160 |
+
" [tag domain]([string blah.com]),",
|
161 |
+
" [tag regexp]([string \".*blah.+\"]) {",
|
162 |
+
" [builtin #id] {",
|
163 |
+
" [property background-color]: [keyword white];",
|
164 |
+
" }",
|
165 |
+
" [tag foo] {",
|
166 |
+
" [property font-family]: [variable Verdana], [atom sans-serif];",
|
167 |
+
" }",
|
168 |
+
"}");
|
169 |
+
|
170 |
+
MT("document_url",
|
171 |
+
"[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
|
172 |
+
|
173 |
+
MT("document_urlPrefix",
|
174 |
+
"[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }");
|
175 |
+
|
176 |
+
MT("document_domain",
|
177 |
+
"[def @document] [tag domain]([string blah.com]) { [tag foo] { } }");
|
178 |
+
|
179 |
+
MT("document_regexp",
|
180 |
+
"[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
|
181 |
+
|
182 |
+
MT("counter-style",
|
183 |
+
"[def @counter-style] [variable binary] {",
|
184 |
+
" [property system]: [atom numeric];",
|
185 |
+
" [property symbols]: [number 0] [number 1];",
|
186 |
+
" [property suffix]: [string \".\"];",
|
187 |
+
" [property range]: [atom infinite];",
|
188 |
+
" [property speak-as]: [atom numeric];",
|
189 |
+
"}");
|
190 |
+
|
191 |
+
MT("counter-style-additive-symbols",
|
192 |
+
"[def @counter-style] [variable simple-roman] {",
|
193 |
+
" [property system]: [atom additive];",
|
194 |
+
" [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
|
195 |
+
" [property range]: [number 1] [number 49];",
|
196 |
+
"}");
|
197 |
+
|
198 |
+
MT("counter-style-use",
|
199 |
+
"[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
|
200 |
+
|
201 |
+
MT("counter-style-symbols",
|
202 |
+
"[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
|
203 |
+
|
204 |
+
MT("comment-does-not-disrupt",
|
205 |
+
"[def @font-face] [comment /* foo */] {",
|
206 |
+
" [property src]: [atom url]([string x]);",
|
207 |
+
" [property font-family]: [variable One];",
|
208 |
+
"}")
|
209 |
+
})();
|
inc/lib/codemirror/mode/htmlmixed/htmlmixed.js
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var defaultTags = {
|
15 |
+
script: [
|
16 |
+
["lang", /(javascript|babel)/i, "javascript"],
|
17 |
+
["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"],
|
18 |
+
["type", /./, "text/plain"],
|
19 |
+
[null, null, "javascript"]
|
20 |
+
],
|
21 |
+
style: [
|
22 |
+
["lang", /^css$/i, "css"],
|
23 |
+
["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
|
24 |
+
["type", /./, "text/plain"],
|
25 |
+
[null, null, "css"]
|
26 |
+
]
|
27 |
+
};
|
28 |
+
|
29 |
+
function maybeBackup(stream, pat, style) {
|
30 |
+
var cur = stream.current(), close = cur.search(pat);
|
31 |
+
if (close > -1) {
|
32 |
+
stream.backUp(cur.length - close);
|
33 |
+
} else if (cur.match(/<\/?$/)) {
|
34 |
+
stream.backUp(cur.length);
|
35 |
+
if (!stream.match(pat, false)) stream.match(cur);
|
36 |
+
}
|
37 |
+
return style;
|
38 |
+
}
|
39 |
+
|
40 |
+
var attrRegexpCache = {};
|
41 |
+
function getAttrRegexp(attr) {
|
42 |
+
var regexp = attrRegexpCache[attr];
|
43 |
+
if (regexp) return regexp;
|
44 |
+
return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
|
45 |
+
}
|
46 |
+
|
47 |
+
function getAttrValue(text, attr) {
|
48 |
+
var match = text.match(getAttrRegexp(attr))
|
49 |
+
return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
|
50 |
+
}
|
51 |
+
|
52 |
+
function getTagRegexp(tagName, anchored) {
|
53 |
+
return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
|
54 |
+
}
|
55 |
+
|
56 |
+
function addTags(from, to) {
|
57 |
+
for (var tag in from) {
|
58 |
+
var dest = to[tag] || (to[tag] = []);
|
59 |
+
var source = from[tag];
|
60 |
+
for (var i = source.length - 1; i >= 0; i--)
|
61 |
+
dest.unshift(source[i])
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
function findMatchingMode(tagInfo, tagText) {
|
66 |
+
for (var i = 0; i < tagInfo.length; i++) {
|
67 |
+
var spec = tagInfo[i];
|
68 |
+
if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
|
73 |
+
var htmlMode = CodeMirror.getMode(config, {
|
74 |
+
name: "xml",
|
75 |
+
htmlMode: true,
|
76 |
+
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
|
77 |
+
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
|
78 |
+
});
|
79 |
+
|
80 |
+
var tags = {};
|
81 |
+
var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
|
82 |
+
addTags(defaultTags, tags);
|
83 |
+
if (configTags) addTags(configTags, tags);
|
84 |
+
if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
|
85 |
+
tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
|
86 |
+
|
87 |
+
function html(stream, state) {
|
88 |
+
var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName
|
89 |
+
if (tag && !/[<>\s\/]/.test(stream.current()) &&
|
90 |
+
(tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) &&
|
91 |
+
tags.hasOwnProperty(tagName)) {
|
92 |
+
state.inTag = tagName + " "
|
93 |
+
} else if (state.inTag && tag && />$/.test(stream.current())) {
|
94 |
+
var inTag = /^([\S]+) (.*)/.exec(state.inTag)
|
95 |
+
state.inTag = null
|
96 |
+
var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])
|
97 |
+
var mode = CodeMirror.getMode(config, modeSpec)
|
98 |
+
var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
|
99 |
+
state.token = function (stream, state) {
|
100 |
+
if (stream.match(endTagA, false)) {
|
101 |
+
state.token = html;
|
102 |
+
state.localState = state.localMode = null;
|
103 |
+
return null;
|
104 |
+
}
|
105 |
+
return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
|
106 |
+
};
|
107 |
+
state.localMode = mode;
|
108 |
+
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
|
109 |
+
} else if (state.inTag) {
|
110 |
+
state.inTag += stream.current()
|
111 |
+
if (stream.eol()) state.inTag += " "
|
112 |
+
}
|
113 |
+
return style;
|
114 |
+
};
|
115 |
+
|
116 |
+
return {
|
117 |
+
startState: function () {
|
118 |
+
var state = CodeMirror.startState(htmlMode);
|
119 |
+
return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
|
120 |
+
},
|
121 |
+
|
122 |
+
copyState: function (state) {
|
123 |
+
var local;
|
124 |
+
if (state.localState) {
|
125 |
+
local = CodeMirror.copyState(state.localMode, state.localState);
|
126 |
+
}
|
127 |
+
return {token: state.token, inTag: state.inTag,
|
128 |
+
localMode: state.localMode, localState: local,
|
129 |
+
htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
|
130 |
+
},
|
131 |
+
|
132 |
+
token: function (stream, state) {
|
133 |
+
return state.token(stream, state);
|
134 |
+
},
|
135 |
+
|
136 |
+
indent: function (state, textAfter, line) {
|
137 |
+
if (!state.localMode || /^\s*<\//.test(textAfter))
|
138 |
+
return htmlMode.indent(state.htmlState, textAfter);
|
139 |
+
else if (state.localMode.indent)
|
140 |
+
return state.localMode.indent(state.localState, textAfter, line);
|
141 |
+
else
|
142 |
+
return CodeMirror.Pass;
|
143 |
+
},
|
144 |
+
|
145 |
+
innerMode: function (state) {
|
146 |
+
return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
|
147 |
+
}
|
148 |
+
};
|
149 |
+
}, "xml", "javascript", "css");
|
150 |
+
|
151 |
+
CodeMirror.defineMIME("text/html", "htmlmixed");
|
152 |
+
});
|
inc/lib/codemirror/mode/htmlmixed/index.html
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: HTML mixed mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="../../addon/selection/selection-pointer.js"></script>
|
10 |
+
<script src="../xml/xml.js"></script>
|
11 |
+
<script src="../javascript/javascript.js"></script>
|
12 |
+
<script src="../css/css.js"></script>
|
13 |
+
<script src="../vbscript/vbscript.js"></script>
|
14 |
+
<script src="htmlmixed.js"></script>
|
15 |
+
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
16 |
+
<div id=nav>
|
17 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
18 |
+
|
19 |
+
<ul>
|
20 |
+
<li><a href="../../index.html">Home</a>
|
21 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
22 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
23 |
+
</ul>
|
24 |
+
<ul>
|
25 |
+
<li><a href="../index.html">Language modes</a>
|
26 |
+
<li><a class=active href="#">HTML mixed</a>
|
27 |
+
</ul>
|
28 |
+
</div>
|
29 |
+
|
30 |
+
<article>
|
31 |
+
<h2>HTML mixed mode</h2>
|
32 |
+
<form><textarea id="code" name="code">
|
33 |
+
<html style="color: green">
|
34 |
+
<!-- this is a comment -->
|
35 |
+
<head>
|
36 |
+
<title>Mixed HTML Example</title>
|
37 |
+
<style type="text/css">
|
38 |
+
h1 {font-family: comic sans; color: #f0f;}
|
39 |
+
div {background: yellow !important;}
|
40 |
+
body {
|
41 |
+
max-width: 50em;
|
42 |
+
margin: 1em 2em 1em 5em;
|
43 |
+
}
|
44 |
+
</style>
|
45 |
+
</head>
|
46 |
+
<body>
|
47 |
+
<h1>Mixed HTML Example</h1>
|
48 |
+
<script>
|
49 |
+
function jsFunc(arg1, arg2) {
|
50 |
+
if (arg1 && arg2) document.body.innerHTML = "achoo";
|
51 |
+
}
|
52 |
+
</script>
|
53 |
+
</body>
|
54 |
+
</html>
|
55 |
+
</textarea></form>
|
56 |
+
<script>
|
57 |
+
// Define an extended mixed-mode that understands vbscript and
|
58 |
+
// leaves mustache/handlebars embedded templates in html mode
|
59 |
+
var mixedMode = {
|
60 |
+
name: "htmlmixed",
|
61 |
+
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
|
62 |
+
mode: null},
|
63 |
+
{matches: /(text|application)\/(x-)?vb(a|script)/i,
|
64 |
+
mode: "vbscript"}]
|
65 |
+
};
|
66 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
67 |
+
mode: mixedMode,
|
68 |
+
selectionPointer: true
|
69 |
+
});
|
70 |
+
</script>
|
71 |
+
|
72 |
+
<p>The HTML mixed mode depends on the XML, JavaScript, and CSS modes.</p>
|
73 |
+
|
74 |
+
<p>It takes an optional mode configuration
|
75 |
+
option, <code>tags</code>, which can be used to add custom
|
76 |
+
behavior for specific tags. When given, it should be an object
|
77 |
+
mapping tag names (for example <code>script</code>) to arrays or
|
78 |
+
three-element arrays. Those inner arrays indicate [attributeName,
|
79 |
+
valueRegexp, <a href="../../doc/manual.html#option_mode">modeSpec</a>]
|
80 |
+
specifications. For example, you could use <code>["type", /^foo$/,
|
81 |
+
"foo"]</code> to map the attribute <code>type="foo"</code> to
|
82 |
+
the <code>foo</code> mode. When the first two fields are null
|
83 |
+
(<code>[null, null, "mode"]</code>), the given mode is used for
|
84 |
+
any such tag that doesn't match any of the previously given
|
85 |
+
attributes. For example:</p>
|
86 |
+
|
87 |
+
<pre>var myModeSpec = {
|
88 |
+
name: "htmlmixed",
|
89 |
+
tags: {
|
90 |
+
style: [["type", /^text\/(x-)?scss$/, "text/x-scss"],
|
91 |
+
[null, null, "css"]],
|
92 |
+
custom: [[null, null, "customMode"]]
|
93 |
+
}
|
94 |
+
}</pre>
|
95 |
+
|
96 |
+
<p><strong>MIME types defined:</strong> <code>text/html</code>
|
97 |
+
(redefined, only takes effect if you load this parser after the
|
98 |
+
XML parser).</p>
|
99 |
+
|
100 |
+
</article>
|
inc/lib/codemirror/mode/index.html
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: Language Modes</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../doc/docs.css">
|
6 |
+
|
7 |
+
<div id=nav>
|
8 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
|
9 |
+
|
10 |
+
<ul>
|
11 |
+
<li><a href="../index.html">Home</a>
|
12 |
+
<li><a href="../doc/manual.html">Manual</a>
|
13 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
14 |
+
</ul>
|
15 |
+
<ul>
|
16 |
+
<li><a class=active href="#">Language modes</a>
|
17 |
+
</ul>
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<article>
|
21 |
+
|
22 |
+
<h2>Language modes</h2>
|
23 |
+
|
24 |
+
<p>This is a list of every mode in the distribution. Each mode lives
|
25 |
+
in a subdirectory of the <code>mode/</code> directory, and typically
|
26 |
+
defines a single JavaScript file that implements the mode. Loading
|
27 |
+
such file will make the language available to CodeMirror, through
|
28 |
+
the <a href="../doc/manual.html#option_mode"><code>mode</code></a>
|
29 |
+
option.</p>
|
30 |
+
|
31 |
+
<div style="-webkit-columns: 100px 2; -moz-columns: 100px 2; columns: 100px 2;">
|
32 |
+
<ul style="margin-top: 0">
|
33 |
+
<li><a href="apl/index.html">APL</a></li>
|
34 |
+
<li><a href="asn.1/index.html">ASN.1</a></li>
|
35 |
+
<li><a href="asterisk/index.html">Asterisk dialplan</a></li>
|
36 |
+
<li><a href="brainfuck/index.html">Brainfuck</a></li>
|
37 |
+
<li><a href="clike/index.html">C, C++, C#</a></li>
|
38 |
+
<li><a href="clike/index.html">Ceylon</a></li>
|
39 |
+
<li><a href="clojure/index.html">Clojure</a></li>
|
40 |
+
<li><a href="css/gss.html">Closure Stylesheets (GSS)</a></li>
|
41 |
+
<li><a href="cmake/index.html">CMake</a></li>
|
42 |
+
<li><a href="cobol/index.html">COBOL</a></li>
|
43 |
+
<li><a href="coffeescript/index.html">CoffeeScript</a></li>
|
44 |
+
<li><a href="commonlisp/index.html">Common Lisp</a></li>
|
45 |
+
<li><a href="crystal/index.html">Crystal</a></li>
|
46 |
+
<li><a href="css/index.html">CSS</a></li>
|
47 |
+
<li><a href="cypher/index.html">Cypher</a></li>
|
48 |
+
<li><a href="python/index.html">Cython</a></li>
|
49 |
+
<li><a href="d/index.html">D</a></li>
|
50 |
+
<li><a href="dart/index.html">Dart</a></li>
|
51 |
+
<li><a href="django/index.html">Django</a> (templating language)</li>
|
52 |
+
<li><a href="dockerfile/index.html">Dockerfile</a></li>
|
53 |
+
<li><a href="diff/index.html">diff</a></li>
|
54 |
+
<li><a href="dtd/index.html">DTD</a></li>
|
55 |
+
<li><a href="dylan/index.html">Dylan</a></li>
|
56 |
+
<li><a href="ebnf/index.html">EBNF</a></li>
|
57 |
+
<li><a href="ecl/index.html">ECL</a></li>
|
58 |
+
<li><a href="eiffel/index.html">Eiffel</a></li>
|
59 |
+
<li><a href="https://github.com/optick/codemirror-mode-elixir">Elixir</a></li>
|
60 |
+
<li><a href="elm/index.html">Elm</a></li>
|
61 |
+
<li><a href="erlang/index.html">Erlang</a></li>
|
62 |
+
<li><a href="factor/index.html">Factor</a></li>
|
63 |
+
<li><a href="fcl/index.html">FCL</a></li>
|
64 |
+
<li><a href="forth/index.html">Forth</a></li>
|
65 |
+
<li><a href="fortran/index.html">Fortran</a></li>
|
66 |
+
<li><a href="mllike/index.html">F#</a></li>
|
67 |
+
<li><a href="gas/index.html">Gas</a> (AT&T-style assembly)</li>
|
68 |
+
<li><a href="gherkin/index.html">Gherkin</a></li>
|
69 |
+
<li><a href="go/index.html">Go</a></li>
|
70 |
+
<li><a href="groovy/index.html">Groovy</a></li>
|
71 |
+
<li><a href="haml/index.html">HAML</a></li>
|
72 |
+
<li><a href="handlebars/index.html">Handlebars</a></li>
|
73 |
+
<li><a href="haskell/index.html">Haskell</a> (<a href="haskell-literate/index.html">Literate</a>)</li>
|
74 |
+
<li><a href="haxe/index.html">Haxe</a></li>
|
75 |
+
<li><a href="htmlembedded/index.html">HTML embedded</a> (JSP, ASP.NET)</li>
|
76 |
+
<li><a href="htmlmixed/index.html">HTML mixed-mode</a></li>
|
77 |
+
<li><a href="http/index.html">HTTP</a></li>
|
78 |
+
<li><a href="idl/index.html">IDL</a></li>
|
79 |
+
<li><a href="clike/index.html">Java</a></li>
|
80 |
+
<li><a href="javascript/index.html">JavaScript</a> (<a href="jsx/index.html">JSX</a>)</li>
|
81 |
+
<li><a href="jinja2/index.html">Jinja2</a></li>
|
82 |
+
<li><a href="julia/index.html">Julia</a></li>
|
83 |
+
<li><a href="clike/index.html">Kotlin</a></li>
|
84 |
+
<li><a href="css/less.html">LESS</a></li>
|
85 |
+
<li><a href="livescript/index.html">LiveScript</a></li>
|
86 |
+
<li><a href="lua/index.html">Lua</a></li>
|
87 |
+
<li><a href="markdown/index.html">Markdown</a> (<a href="gfm/index.html">GitHub-flavour</a>)</li>
|
88 |
+
<li><a href="mathematica/index.html">Mathematica</a></li>
|
89 |
+
<li><a href="mbox/index.html">mbox</a></li>
|
90 |
+
<li><a href="mirc/index.html">mIRC</a></li>
|
91 |
+
<li><a href="modelica/index.html">Modelica</a></li>
|
92 |
+
<li><a href="mscgen/index.html">MscGen</a></li>
|
93 |
+
<li><a href="mumps/index.html">MUMPS</a></li>
|
94 |
+
<li><a href="nginx/index.html">Nginx</a></li>
|
95 |
+
<li><a href="nsis/index.html">NSIS</a></li>
|
96 |
+
<li><a href="ntriples/index.html">N-Triples/N-Quads</a></li>
|
97 |
+
<li><a href="clike/index.html">Objective C</a></li>
|
98 |
+
<li><a href="mllike/index.html">OCaml</a></li>
|
99 |
+
<li><a href="octave/index.html">Octave</a> (MATLAB)</li>
|
100 |
+
<li><a href="oz/index.html">Oz</a></li>
|
101 |
+
<li><a href="pascal/index.html">Pascal</a></li>
|
102 |
+
<li><a href="pegjs/index.html">PEG.js</a></li>
|
103 |
+
<li><a href="perl/index.html">Perl</a></li>
|
104 |
+
<li><a href="asciiarmor/index.html">PGP (ASCII armor)</a></li>
|
105 |
+
<li><a href="php/index.html">PHP</a></li>
|
106 |
+
<li><a href="pig/index.html">Pig Latin</a></li>
|
107 |
+
<li><a href="powershell/index.html">PowerShell</a></li>
|
108 |
+
<li><a href="properties/index.html">Properties files</a></li>
|
109 |
+
<li><a href="protobuf/index.html">ProtoBuf</a></li>
|
110 |
+
<li><a href="pug/index.html">Pug</a></li>
|
111 |
+
<li><a href="puppet/index.html">Puppet</a></li>
|
112 |
+
<li><a href="python/index.html">Python</a></li>
|
113 |
+
<li><a href="q/index.html">Q</a></li>
|
114 |
+
<li><a href="r/index.html">R</a></li>
|
115 |
+
<li><a href="rpm/index.html">RPM</a></li>
|
116 |
+
<li><a href="rst/index.html">reStructuredText</a></li>
|
117 |
+
<li><a href="ruby/index.html">Ruby</a></li>
|
118 |
+
<li><a href="rust/index.html">Rust</a></li>
|
119 |
+
<li><a href="sas/index.html">SAS</a></li>
|
120 |
+
<li><a href="sass/index.html">Sass</a></li>
|
121 |
+
<li><a href="spreadsheet/index.html">Spreadsheet</a></li>
|
122 |
+
<li><a href="clike/scala.html">Scala</a></li>
|
123 |
+
<li><a href="scheme/index.html">Scheme</a></li>
|
124 |
+
<li><a href="css/scss.html">SCSS</a></li>
|
125 |
+
<li><a href="shell/index.html">Shell</a></li>
|
126 |
+
<li><a href="sieve/index.html">Sieve</a></li>
|
127 |
+
<li><a href="slim/index.html">Slim</a></li>
|
128 |
+
<li><a href="smalltalk/index.html">Smalltalk</a></li>
|
129 |
+
<li><a href="smarty/index.html">Smarty</a></li>
|
130 |
+
<li><a href="solr/index.html">Solr</a></li>
|
131 |
+
<li><a href="soy/index.html">Soy</a></li>
|
132 |
+
<li><a href="stylus/index.html">Stylus</a></li>
|
133 |
+
<li><a href="sql/index.html">SQL</a> (several dialects)</li>
|
134 |
+
<li><a href="sparql/index.html">SPARQL</a></li>
|
135 |
+
<li><a href="clike/index.html">Squirrel</a></li>
|
136 |
+
<li><a href="swift/index.html">Swift</a></li>
|
137 |
+
<li><a href="stex/index.html">sTeX, LaTeX</a></li>
|
138 |
+
<li><a href="tcl/index.html">Tcl</a></li>
|
139 |
+
<li><a href="textile/index.html">Textile</a></li>
|
140 |
+
<li><a href="tiddlywiki/index.html">Tiddlywiki</a></li>
|
141 |
+
<li><a href="tiki/index.html">Tiki wiki</a></li>
|
142 |
+
<li><a href="toml/index.html">TOML</a></li>
|
143 |
+
<li><a href="tornado/index.html">Tornado</a> (templating language)</li>
|
144 |
+
<li><a href="troff/index.html">troff</a> (for manpages)</li>
|
145 |
+
<li><a href="ttcn/index.html">TTCN</a></li>
|
146 |
+
<li><a href="ttcn-cfg/index.html">TTCN Configuration</a></li>
|
147 |
+
<li><a href="turtle/index.html">Turtle</a></li>
|
148 |
+
<li><a href="twig/index.html">Twig</a></li>
|
149 |
+
<li><a href="vb/index.html">VB.NET</a></li>
|
150 |
+
<li><a href="vbscript/index.html">VBScript</a></li>
|
151 |
+
<li><a href="velocity/index.html">Velocity</a></li>
|
152 |
+
<li><a href="verilog/index.html">Verilog/SystemVerilog</a></li>
|
153 |
+
<li><a href="vhdl/index.html">VHDL</a></li>
|
154 |
+
<li><a href="vue/index.html">Vue.js app</a></li>
|
155 |
+
<li><a href="webidl/index.html">Web IDL</a></li>
|
156 |
+
<li><a href="xml/index.html">XML/HTML</a></li>
|
157 |
+
<li><a href="xquery/index.html">XQuery</a></li>
|
158 |
+
<li><a href="yacas/index.html">Yacas</a></li>
|
159 |
+
<li><a href="yaml/index.html">YAML</a></li>
|
160 |
+
<li><a href="yaml-frontmatter/index.html">YAML frontmatter</a></li>
|
161 |
+
<li><a href="z80/index.html">Z80</a></li>
|
162 |
+
</ul>
|
163 |
+
</div>
|
164 |
+
|
165 |
+
</article>
|
inc/lib/codemirror/mode/javascript/index.html
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: JavaScript mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
10 |
+
<script src="../../addon/comment/continuecomment.js"></script>
|
11 |
+
<script src="../../addon/comment/comment.js"></script>
|
12 |
+
<script src="javascript.js"></script>
|
13 |
+
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
14 |
+
<div id=nav>
|
15 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
16 |
+
|
17 |
+
<ul>
|
18 |
+
<li><a href="../../index.html">Home</a>
|
19 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
20 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
21 |
+
</ul>
|
22 |
+
<ul>
|
23 |
+
<li><a href="../index.html">Language modes</a>
|
24 |
+
<li><a class=active href="#">JavaScript</a>
|
25 |
+
</ul>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<article>
|
29 |
+
<h2>JavaScript mode</h2>
|
30 |
+
|
31 |
+
|
32 |
+
<div><textarea id="code" name="code">
|
33 |
+
// Demo code (the actual new parser character stream implementation)
|
34 |
+
|
35 |
+
function StringStream(string) {
|
36 |
+
this.pos = 0;
|
37 |
+
this.string = string;
|
38 |
+
}
|
39 |
+
|
40 |
+
StringStream.prototype = {
|
41 |
+
done: function() {return this.pos >= this.string.length;},
|
42 |
+
peek: function() {return this.string.charAt(this.pos);},
|
43 |
+
next: function() {
|
44 |
+
if (this.pos < this.string.length)
|
45 |
+
return this.string.charAt(this.pos++);
|
46 |
+
},
|
47 |
+
eat: function(match) {
|
48 |
+
var ch = this.string.charAt(this.pos);
|
49 |
+
if (typeof match == "string") var ok = ch == match;
|
50 |
+
else var ok = ch && match.test ? match.test(ch) : match(ch);
|
51 |
+
if (ok) {this.pos++; return ch;}
|
52 |
+
},
|
53 |
+
eatWhile: function(match) {
|
54 |
+
var start = this.pos;
|
55 |
+
while (this.eat(match));
|
56 |
+
if (this.pos > start) return this.string.slice(start, this.pos);
|
57 |
+
},
|
58 |
+
backUp: function(n) {this.pos -= n;},
|
59 |
+
column: function() {return this.pos;},
|
60 |
+
eatSpace: function() {
|
61 |
+
var start = this.pos;
|
62 |
+
while (/\s/.test(this.string.charAt(this.pos))) this.pos++;
|
63 |
+
return this.pos - start;
|
64 |
+
},
|
65 |
+
match: function(pattern, consume, caseInsensitive) {
|
66 |
+
if (typeof pattern == "string") {
|
67 |
+
function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}
|
68 |
+
if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
|
69 |
+
if (consume !== false) this.pos += str.length;
|
70 |
+
return true;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
else {
|
74 |
+
var match = this.string.slice(this.pos).match(pattern);
|
75 |
+
if (match && consume !== false) this.pos += match[0].length;
|
76 |
+
return match;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
};
|
80 |
+
</textarea></div>
|
81 |
+
|
82 |
+
<script>
|
83 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
84 |
+
lineNumbers: true,
|
85 |
+
matchBrackets: true,
|
86 |
+
continueComments: "Enter",
|
87 |
+
extraKeys: {"Ctrl-Q": "toggleComment"}
|
88 |
+
});
|
89 |
+
</script>
|
90 |
+
|
91 |
+
<p>
|
92 |
+
JavaScript mode supports several configuration options:
|
93 |
+
<ul>
|
94 |
+
<li><code>json</code> which will set the mode to expect JSON
|
95 |
+
data rather than a JavaScript program.</li>
|
96 |
+
<li><code>jsonld</code> which will set the mode to expect
|
97 |
+
<a href="http://json-ld.org">JSON-LD</a> linked data rather
|
98 |
+
than a JavaScript program (<a href="json-ld.html">demo</a>).</li>
|
99 |
+
<li><code>typescript</code> which will activate additional
|
100 |
+
syntax highlighting and some other things for TypeScript code
|
101 |
+
(<a href="typescript.html">demo</a>).</li>
|
102 |
+
<li><code>statementIndent</code> which (given a number) will
|
103 |
+
determine the amount of indentation to use for statements
|
104 |
+
continued on a new line.</li>
|
105 |
+
<li><code>wordCharacters</code>, a regexp that indicates which
|
106 |
+
characters should be considered part of an identifier.
|
107 |
+
Defaults to <code>/[\w$]/</code>, which does not handle
|
108 |
+
non-ASCII identifiers. Can be set to something more elaborate
|
109 |
+
to improve Unicode support.</li>
|
110 |
+
</ul>
|
111 |
+
</p>
|
112 |
+
|
113 |
+
<p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>, <code>application/ld+json</code>, <code>text/typescript</code>, <code>application/typescript</code>.</p>
|
114 |
+
</article>
|
inc/lib/codemirror/mode/javascript/javascript.js
ADDED
@@ -0,0 +1,896 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
15 |
+
var indentUnit = config.indentUnit;
|
16 |
+
var statementIndent = parserConfig.statementIndent;
|
17 |
+
var jsonldMode = parserConfig.jsonld;
|
18 |
+
var jsonMode = parserConfig.json || jsonldMode;
|
19 |
+
var isTS = parserConfig.typescript;
|
20 |
+
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
|
21 |
+
|
22 |
+
// Tokenizer
|
23 |
+
|
24 |
+
var keywords = function(){
|
25 |
+
function kw(type) {return {type: type, style: "keyword"};}
|
26 |
+
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
|
27 |
+
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
28 |
+
|
29 |
+
return {
|
30 |
+
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
31 |
+
"return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
|
32 |
+
"debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
|
33 |
+
"function": kw("function"), "catch": kw("catch"),
|
34 |
+
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
35 |
+
"in": operator, "typeof": operator, "instanceof": operator,
|
36 |
+
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
37 |
+
"this": kw("this"), "class": kw("class"), "super": kw("atom"),
|
38 |
+
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
|
39 |
+
"await": C
|
40 |
+
};
|
41 |
+
}();
|
42 |
+
|
43 |
+
var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
|
44 |
+
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
45 |
+
|
46 |
+
function readRegexp(stream) {
|
47 |
+
var escaped = false, next, inSet = false;
|
48 |
+
while ((next = stream.next()) != null) {
|
49 |
+
if (!escaped) {
|
50 |
+
if (next == "/" && !inSet) return;
|
51 |
+
if (next == "[") inSet = true;
|
52 |
+
else if (inSet && next == "]") inSet = false;
|
53 |
+
}
|
54 |
+
escaped = !escaped && next == "\\";
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
// Used as scratch variables to communicate multiple values without
|
59 |
+
// consing up tons of objects.
|
60 |
+
var type, content;
|
61 |
+
function ret(tp, style, cont) {
|
62 |
+
type = tp; content = cont;
|
63 |
+
return style;
|
64 |
+
}
|
65 |
+
function tokenBase(stream, state) {
|
66 |
+
var ch = stream.next();
|
67 |
+
if (ch == '"' || ch == "'") {
|
68 |
+
state.tokenize = tokenString(ch);
|
69 |
+
return state.tokenize(stream, state);
|
70 |
+
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
|
71 |
+
return ret("number", "number");
|
72 |
+
} else if (ch == "." && stream.match("..")) {
|
73 |
+
return ret("spread", "meta");
|
74 |
+
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
75 |
+
return ret(ch);
|
76 |
+
} else if (ch == "=" && stream.eat(">")) {
|
77 |
+
return ret("=>", "operator");
|
78 |
+
} else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) {
|
79 |
+
return ret("number", "number");
|
80 |
+
} else if (/\d/.test(ch)) {
|
81 |
+
stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/);
|
82 |
+
return ret("number", "number");
|
83 |
+
} else if (ch == "/") {
|
84 |
+
if (stream.eat("*")) {
|
85 |
+
state.tokenize = tokenComment;
|
86 |
+
return tokenComment(stream, state);
|
87 |
+
} else if (stream.eat("/")) {
|
88 |
+
stream.skipToEnd();
|
89 |
+
return ret("comment", "comment");
|
90 |
+
} else if (expressionAllowed(stream, state, 1)) {
|
91 |
+
readRegexp(stream);
|
92 |
+
stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
|
93 |
+
return ret("regexp", "string-2");
|
94 |
+
} else {
|
95 |
+
stream.eat("=");
|
96 |
+
return ret("operator", "operator", stream.current());
|
97 |
+
}
|
98 |
+
} else if (ch == "`") {
|
99 |
+
state.tokenize = tokenQuasi;
|
100 |
+
return tokenQuasi(stream, state);
|
101 |
+
} else if (ch == "#") {
|
102 |
+
stream.skipToEnd();
|
103 |
+
return ret("error", "error");
|
104 |
+
} else if (isOperatorChar.test(ch)) {
|
105 |
+
if (ch != ">" || !state.lexical || state.lexical.type != ">") {
|
106 |
+
if (stream.eat("=")) {
|
107 |
+
if (ch == "!" || ch == "=") stream.eat("=")
|
108 |
+
} else if (/[<>*+\-]/.test(ch)) {
|
109 |
+
stream.eat(ch)
|
110 |
+
if (ch == ">") stream.eat(ch)
|
111 |
+
}
|
112 |
+
}
|
113 |
+
return ret("operator", "operator", stream.current());
|
114 |
+
} else if (wordRE.test(ch)) {
|
115 |
+
stream.eatWhile(wordRE);
|
116 |
+
var word = stream.current()
|
117 |
+
if (state.lastType != ".") {
|
118 |
+
if (keywords.propertyIsEnumerable(word)) {
|
119 |
+
var kw = keywords[word]
|
120 |
+
return ret(kw.type, kw.style, word)
|
121 |
+
}
|
122 |
+
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
|
123 |
+
return ret("async", "keyword", word)
|
124 |
+
}
|
125 |
+
return ret("variable", "variable", word)
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
function tokenString(quote) {
|
130 |
+
return function(stream, state) {
|
131 |
+
var escaped = false, next;
|
132 |
+
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
|
133 |
+
state.tokenize = tokenBase;
|
134 |
+
return ret("jsonld-keyword", "meta");
|
135 |
+
}
|
136 |
+
while ((next = stream.next()) != null) {
|
137 |
+
if (next == quote && !escaped) break;
|
138 |
+
escaped = !escaped && next == "\\";
|
139 |
+
}
|
140 |
+
if (!escaped) state.tokenize = tokenBase;
|
141 |
+
return ret("string", "string");
|
142 |
+
};
|
143 |
+
}
|
144 |
+
|
145 |
+
function tokenComment(stream, state) {
|
146 |
+
var maybeEnd = false, ch;
|
147 |
+
while (ch = stream.next()) {
|
148 |
+
if (ch == "/" && maybeEnd) {
|
149 |
+
state.tokenize = tokenBase;
|
150 |
+
break;
|
151 |
+
}
|
152 |
+
maybeEnd = (ch == "*");
|
153 |
+
}
|
154 |
+
return ret("comment", "comment");
|
155 |
+
}
|
156 |
+
|
157 |
+
function tokenQuasi(stream, state) {
|
158 |
+
var escaped = false, next;
|
159 |
+
while ((next = stream.next()) != null) {
|
160 |
+
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
|
161 |
+
state.tokenize = tokenBase;
|
162 |
+
break;
|
163 |
+
}
|
164 |
+
escaped = !escaped && next == "\\";
|
165 |
+
}
|
166 |
+
return ret("quasi", "string-2", stream.current());
|
167 |
+
}
|
168 |
+
|
169 |
+
var brackets = "([{}])";
|
170 |
+
// This is a crude lookahead trick to try and notice that we're
|
171 |
+
// parsing the argument patterns for a fat-arrow function before we
|
172 |
+
// actually hit the arrow token. It only works if the arrow is on
|
173 |
+
// the same line as the arguments and there's no strange noise
|
174 |
+
// (comments) in between. Fallback is to only notice when we hit the
|
175 |
+
// arrow, and not declare the arguments as locals for the arrow
|
176 |
+
// body.
|
177 |
+
function findFatArrow(stream, state) {
|
178 |
+
if (state.fatArrowAt) state.fatArrowAt = null;
|
179 |
+
var arrow = stream.string.indexOf("=>", stream.start);
|
180 |
+
if (arrow < 0) return;
|
181 |
+
|
182 |
+
if (isTS) { // Try to skip TypeScript return type declarations after the arguments
|
183 |
+
var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow))
|
184 |
+
if (m) arrow = m.index
|
185 |
+
}
|
186 |
+
|
187 |
+
var depth = 0, sawSomething = false;
|
188 |
+
for (var pos = arrow - 1; pos >= 0; --pos) {
|
189 |
+
var ch = stream.string.charAt(pos);
|
190 |
+
var bracket = brackets.indexOf(ch);
|
191 |
+
if (bracket >= 0 && bracket < 3) {
|
192 |
+
if (!depth) { ++pos; break; }
|
193 |
+
if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
|
194 |
+
} else if (bracket >= 3 && bracket < 6) {
|
195 |
+
++depth;
|
196 |
+
} else if (wordRE.test(ch)) {
|
197 |
+
sawSomething = true;
|
198 |
+
} else if (/["'\/]/.test(ch)) {
|
199 |
+
return;
|
200 |
+
} else if (sawSomething && !depth) {
|
201 |
+
++pos;
|
202 |
+
break;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
if (sawSomething && !depth) state.fatArrowAt = pos;
|
206 |
+
}
|
207 |
+
|
208 |
+
// Parser
|
209 |
+
|
210 |
+
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
|
211 |
+
|
212 |
+
function JSLexical(indented, column, type, align, prev, info) {
|
213 |
+
this.indented = indented;
|
214 |
+
this.column = column;
|
215 |
+
this.type = type;
|
216 |
+
this.prev = prev;
|
217 |
+
this.info = info;
|
218 |
+
if (align != null) this.align = align;
|
219 |
+
}
|
220 |
+
|
221 |
+
function inScope(state, varname) {
|
222 |
+
for (var v = state.localVars; v; v = v.next)
|
223 |
+
if (v.name == varname) return true;
|
224 |
+
for (var cx = state.context; cx; cx = cx.prev) {
|
225 |
+
for (var v = cx.vars; v; v = v.next)
|
226 |
+
if (v.name == varname) return true;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
function parseJS(state, style, type, content, stream) {
|
231 |
+
var cc = state.cc;
|
232 |
+
// Communicate our context to the combinators.
|
233 |
+
// (Less wasteful than consing up a hundred closures on every call.)
|
234 |
+
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
|
235 |
+
|
236 |
+
if (!state.lexical.hasOwnProperty("align"))
|
237 |
+
state.lexical.align = true;
|
238 |
+
|
239 |
+
while(true) {
|
240 |
+
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
241 |
+
if (combinator(type, content)) {
|
242 |
+
while(cc.length && cc[cc.length - 1].lex)
|
243 |
+
cc.pop()();
|
244 |
+
if (cx.marked) return cx.marked;
|
245 |
+
if (type == "variable" && inScope(state, content)) return "variable-2";
|
246 |
+
return style;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
// Combinator utils
|
252 |
+
|
253 |
+
var cx = {state: null, column: null, marked: null, cc: null};
|
254 |
+
function pass() {
|
255 |
+
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
256 |
+
}
|
257 |
+
function cont() {
|
258 |
+
pass.apply(null, arguments);
|
259 |
+
return true;
|
260 |
+
}
|
261 |
+
function inList(name, list) {
|
262 |
+
for (var v = list; v; v = v.next) if (v.name == name) return true
|
263 |
+
return false;
|
264 |
+
}
|
265 |
+
function register(varname) {
|
266 |
+
var state = cx.state;
|
267 |
+
cx.marked = "def";
|
268 |
+
if (state.context) {
|
269 |
+
if (state.lexical.info == "var" && state.context && state.context.block) {
|
270 |
+
// FIXME function decls are also not block scoped
|
271 |
+
var newContext = registerVarScoped(varname, state.context)
|
272 |
+
if (newContext != null) {
|
273 |
+
state.context = newContext
|
274 |
+
return
|
275 |
+
}
|
276 |
+
} else if (!inList(varname, state.localVars)) {
|
277 |
+
state.localVars = new Var(varname, state.localVars)
|
278 |
+
return
|
279 |
+
}
|
280 |
+
}
|
281 |
+
// Fall through means this is global
|
282 |
+
if (parserConfig.globalVars && !inList(varname, state.globalVars))
|
283 |
+
state.globalVars = new Var(varname, state.globalVars)
|
284 |
+
}
|
285 |
+
function registerVarScoped(varname, context) {
|
286 |
+
if (!context) {
|
287 |
+
return null
|
288 |
+
} else if (context.block) {
|
289 |
+
var inner = registerVarScoped(varname, context.prev)
|
290 |
+
if (!inner) return null
|
291 |
+
if (inner == context.prev) return context
|
292 |
+
return new Context(inner, context.vars, true)
|
293 |
+
} else if (inList(varname, context.vars)) {
|
294 |
+
return context
|
295 |
+
} else {
|
296 |
+
return new Context(context.prev, new Var(varname, context.vars), false)
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
function isModifier(name) {
|
301 |
+
return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
|
302 |
+
}
|
303 |
+
|
304 |
+
// Combinators
|
305 |
+
|
306 |
+
function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }
|
307 |
+
function Var(name, next) { this.name = name; this.next = next }
|
308 |
+
|
309 |
+
var defaultVars = new Var("this", new Var("arguments", null))
|
310 |
+
function pushcontext() {
|
311 |
+
cx.state.context = new Context(cx.state.context, cx.state.localVars, false)
|
312 |
+
cx.state.localVars = defaultVars
|
313 |
+
}
|
314 |
+
function pushblockcontext() {
|
315 |
+
cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
|
316 |
+
cx.state.localVars = null
|
317 |
+
}
|
318 |
+
function popcontext() {
|
319 |
+
cx.state.localVars = cx.state.context.vars
|
320 |
+
cx.state.context = cx.state.context.prev
|
321 |
+
}
|
322 |
+
popcontext.lex = true
|
323 |
+
function pushlex(type, info) {
|
324 |
+
var result = function() {
|
325 |
+
var state = cx.state, indent = state.indented;
|
326 |
+
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
327 |
+
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
|
328 |
+
indent = outer.indented;
|
329 |
+
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
330 |
+
};
|
331 |
+
result.lex = true;
|
332 |
+
return result;
|
333 |
+
}
|
334 |
+
function poplex() {
|
335 |
+
var state = cx.state;
|
336 |
+
if (state.lexical.prev) {
|
337 |
+
if (state.lexical.type == ")")
|
338 |
+
state.indented = state.lexical.indented;
|
339 |
+
state.lexical = state.lexical.prev;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
poplex.lex = true;
|
343 |
+
|
344 |
+
function expect(wanted) {
|
345 |
+
function exp(type) {
|
346 |
+
if (type == wanted) return cont();
|
347 |
+
else if (wanted == ";") return pass();
|
348 |
+
else return cont(exp);
|
349 |
+
};
|
350 |
+
return exp;
|
351 |
+
}
|
352 |
+
|
353 |
+
function statement(type, value) {
|
354 |
+
if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
|
355 |
+
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
|
356 |
+
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
357 |
+
if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
|
358 |
+
if (type == "debugger") return cont(expect(";"));
|
359 |
+
if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
|
360 |
+
if (type == ";") return cont();
|
361 |
+
if (type == "if") {
|
362 |
+
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
363 |
+
cx.state.cc.pop()();
|
364 |
+
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
|
365 |
+
}
|
366 |
+
if (type == "function") return cont(functiondef);
|
367 |
+
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
368 |
+
if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), className, poplex); }
|
369 |
+
if (type == "variable") {
|
370 |
+
if (isTS && value == "declare") {
|
371 |
+
cx.marked = "keyword"
|
372 |
+
return cont(statement)
|
373 |
+
} else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
|
374 |
+
cx.marked = "keyword"
|
375 |
+
if (value == "enum") return cont(enumdef);
|
376 |
+
else if (value == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
377 |
+
else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
|
378 |
+
} else if (isTS && value == "namespace") {
|
379 |
+
cx.marked = "keyword"
|
380 |
+
return cont(pushlex("form"), expression, block, poplex)
|
381 |
+
} else if (isTS && value == "abstract") {
|
382 |
+
cx.marked = "keyword"
|
383 |
+
return cont(statement)
|
384 |
+
} else {
|
385 |
+
return cont(pushlex("stat"), maybelabel);
|
386 |
+
}
|
387 |
+
}
|
388 |
+
if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
|
389 |
+
block, poplex, poplex, popcontext);
|
390 |
+
if (type == "case") return cont(expression, expect(":"));
|
391 |
+
if (type == "default") return cont(expect(":"));
|
392 |
+
if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
|
393 |
+
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
394 |
+
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
395 |
+
if (type == "async") return cont(statement)
|
396 |
+
if (value == "@") return cont(expression, statement)
|
397 |
+
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
398 |
+
}
|
399 |
+
function maybeCatchBinding(type) {
|
400 |
+
if (type == "(") return cont(funarg, expect(")"))
|
401 |
+
}
|
402 |
+
function expression(type, value) {
|
403 |
+
return expressionInner(type, value, false);
|
404 |
+
}
|
405 |
+
function expressionNoComma(type, value) {
|
406 |
+
return expressionInner(type, value, true);
|
407 |
+
}
|
408 |
+
function parenExpr(type) {
|
409 |
+
if (type != "(") return pass()
|
410 |
+
return cont(pushlex(")"), expression, expect(")"), poplex)
|
411 |
+
}
|
412 |
+
function expressionInner(type, value, noComma) {
|
413 |
+
if (cx.state.fatArrowAt == cx.stream.start) {
|
414 |
+
var body = noComma ? arrowBodyNoComma : arrowBody;
|
415 |
+
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
|
416 |
+
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
417 |
+
}
|
418 |
+
|
419 |
+
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
420 |
+
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
421 |
+
if (type == "function") return cont(functiondef, maybeop);
|
422 |
+
if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
|
423 |
+
if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
|
424 |
+
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
|
425 |
+
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
426 |
+
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
427 |
+
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
428 |
+
if (type == "quasi") return pass(quasi, maybeop);
|
429 |
+
if (type == "new") return cont(maybeTarget(noComma));
|
430 |
+
if (type == "import") return cont(expression);
|
431 |
+
return cont();
|
432 |
+
}
|
433 |
+
function maybeexpression(type) {
|
434 |
+
if (type.match(/[;\}\)\],]/)) return pass();
|
435 |
+
return pass(expression);
|
436 |
+
}
|
437 |
+
|
438 |
+
function maybeoperatorComma(type, value) {
|
439 |
+
if (type == ",") return cont(expression);
|
440 |
+
return maybeoperatorNoComma(type, value, false);
|
441 |
+
}
|
442 |
+
function maybeoperatorNoComma(type, value, noComma) {
|
443 |
+
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
444 |
+
var expr = noComma == false ? expression : expressionNoComma;
|
445 |
+
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
446 |
+
if (type == "operator") {
|
447 |
+
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
|
448 |
+
if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
|
449 |
+
return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
|
450 |
+
if (value == "?") return cont(expression, expect(":"), expr);
|
451 |
+
return cont(expr);
|
452 |
+
}
|
453 |
+
if (type == "quasi") { return pass(quasi, me); }
|
454 |
+
if (type == ";") return;
|
455 |
+
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
456 |
+
if (type == ".") return cont(property, me);
|
457 |
+
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
458 |
+
if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
|
459 |
+
if (type == "regexp") {
|
460 |
+
cx.state.lastType = cx.marked = "operator"
|
461 |
+
cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)
|
462 |
+
return cont(expr)
|
463 |
+
}
|
464 |
+
}
|
465 |
+
function quasi(type, value) {
|
466 |
+
if (type != "quasi") return pass();
|
467 |
+
if (value.slice(value.length - 2) != "${") return cont(quasi);
|
468 |
+
return cont(expression, continueQuasi);
|
469 |
+
}
|
470 |
+
function continueQuasi(type) {
|
471 |
+
if (type == "}") {
|
472 |
+
cx.marked = "string-2";
|
473 |
+
cx.state.tokenize = tokenQuasi;
|
474 |
+
return cont(quasi);
|
475 |
+
}
|
476 |
+
}
|
477 |
+
function arrowBody(type) {
|
478 |
+
findFatArrow(cx.stream, cx.state);
|
479 |
+
return pass(type == "{" ? statement : expression);
|
480 |
+
}
|
481 |
+
function arrowBodyNoComma(type) {
|
482 |
+
findFatArrow(cx.stream, cx.state);
|
483 |
+
return pass(type == "{" ? statement : expressionNoComma);
|
484 |
+
}
|
485 |
+
function maybeTarget(noComma) {
|
486 |
+
return function(type) {
|
487 |
+
if (type == ".") return cont(noComma ? targetNoComma : target);
|
488 |
+
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
|
489 |
+
else return pass(noComma ? expressionNoComma : expression);
|
490 |
+
};
|
491 |
+
}
|
492 |
+
function target(_, value) {
|
493 |
+
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
|
494 |
+
}
|
495 |
+
function targetNoComma(_, value) {
|
496 |
+
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
|
497 |
+
}
|
498 |
+
function maybelabel(type) {
|
499 |
+
if (type == ":") return cont(poplex, statement);
|
500 |
+
return pass(maybeoperatorComma, expect(";"), poplex);
|
501 |
+
}
|
502 |
+
function property(type) {
|
503 |
+
if (type == "variable") {cx.marked = "property"; return cont();}
|
504 |
+
}
|
505 |
+
function objprop(type, value) {
|
506 |
+
if (type == "async") {
|
507 |
+
cx.marked = "property";
|
508 |
+
return cont(objprop);
|
509 |
+
} else if (type == "variable" || cx.style == "keyword") {
|
510 |
+
cx.marked = "property";
|
511 |
+
if (value == "get" || value == "set") return cont(getterSetter);
|
512 |
+
var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
|
513 |
+
if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
|
514 |
+
cx.state.fatArrowAt = cx.stream.pos + m[0].length
|
515 |
+
return cont(afterprop);
|
516 |
+
} else if (type == "number" || type == "string") {
|
517 |
+
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
518 |
+
return cont(afterprop);
|
519 |
+
} else if (type == "jsonld-keyword") {
|
520 |
+
return cont(afterprop);
|
521 |
+
} else if (isTS && isModifier(value)) {
|
522 |
+
cx.marked = "keyword"
|
523 |
+
return cont(objprop)
|
524 |
+
} else if (type == "[") {
|
525 |
+
return cont(expression, maybetype, expect("]"), afterprop);
|
526 |
+
} else if (type == "spread") {
|
527 |
+
return cont(expressionNoComma, afterprop);
|
528 |
+
} else if (value == "*") {
|
529 |
+
cx.marked = "keyword";
|
530 |
+
return cont(objprop);
|
531 |
+
} else if (type == ":") {
|
532 |
+
return pass(afterprop)
|
533 |
+
}
|
534 |
+
}
|
535 |
+
function getterSetter(type) {
|
536 |
+
if (type != "variable") return pass(afterprop);
|
537 |
+
cx.marked = "property";
|
538 |
+
return cont(functiondef);
|
539 |
+
}
|
540 |
+
function afterprop(type) {
|
541 |
+
if (type == ":") return cont(expressionNoComma);
|
542 |
+
if (type == "(") return pass(functiondef);
|
543 |
+
}
|
544 |
+
function commasep(what, end, sep) {
|
545 |
+
function proceed(type, value) {
|
546 |
+
if (sep ? sep.indexOf(type) > -1 : type == ",") {
|
547 |
+
var lex = cx.state.lexical;
|
548 |
+
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
549 |
+
return cont(function(type, value) {
|
550 |
+
if (type == end || value == end) return pass()
|
551 |
+
return pass(what)
|
552 |
+
}, proceed);
|
553 |
+
}
|
554 |
+
if (type == end || value == end) return cont();
|
555 |
+
return cont(expect(end));
|
556 |
+
}
|
557 |
+
return function(type, value) {
|
558 |
+
if (type == end || value == end) return cont();
|
559 |
+
return pass(what, proceed);
|
560 |
+
};
|
561 |
+
}
|
562 |
+
function contCommasep(what, end, info) {
|
563 |
+
for (var i = 3; i < arguments.length; i++)
|
564 |
+
cx.cc.push(arguments[i]);
|
565 |
+
return cont(pushlex(end, info), commasep(what, end), poplex);
|
566 |
+
}
|
567 |
+
function block(type) {
|
568 |
+
if (type == "}") return cont();
|
569 |
+
return pass(statement, block);
|
570 |
+
}
|
571 |
+
function maybetype(type, value) {
|
572 |
+
if (isTS) {
|
573 |
+
if (type == ":") return cont(typeexpr);
|
574 |
+
if (value == "?") return cont(maybetype);
|
575 |
+
}
|
576 |
+
}
|
577 |
+
function mayberettype(type) {
|
578 |
+
if (isTS && type == ":") {
|
579 |
+
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
|
580 |
+
else return cont(typeexpr)
|
581 |
+
}
|
582 |
+
}
|
583 |
+
function isKW(_, value) {
|
584 |
+
if (value == "is") {
|
585 |
+
cx.marked = "keyword"
|
586 |
+
return cont()
|
587 |
+
}
|
588 |
+
}
|
589 |
+
function typeexpr(type, value) {
|
590 |
+
if (value == "keyof" || value == "typeof") {
|
591 |
+
cx.marked = "keyword"
|
592 |
+
return cont(value == "keyof" ? typeexpr : expressionNoComma)
|
593 |
+
}
|
594 |
+
if (type == "variable" || value == "void") {
|
595 |
+
cx.marked = "type"
|
596 |
+
return cont(afterType)
|
597 |
+
}
|
598 |
+
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
|
599 |
+
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
|
600 |
+
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
|
601 |
+
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
602 |
+
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
|
603 |
+
}
|
604 |
+
function maybeReturnType(type) {
|
605 |
+
if (type == "=>") return cont(typeexpr)
|
606 |
+
}
|
607 |
+
function typeprop(type, value) {
|
608 |
+
if (type == "variable" || cx.style == "keyword") {
|
609 |
+
cx.marked = "property"
|
610 |
+
return cont(typeprop)
|
611 |
+
} else if (value == "?") {
|
612 |
+
return cont(typeprop)
|
613 |
+
} else if (type == ":") {
|
614 |
+
return cont(typeexpr)
|
615 |
+
} else if (type == "[") {
|
616 |
+
return cont(expression, maybetype, expect("]"), typeprop)
|
617 |
+
}
|
618 |
+
}
|
619 |
+
function typearg(type, value) {
|
620 |
+
if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
|
621 |
+
if (type == ":") return cont(typeexpr)
|
622 |
+
return pass(typeexpr)
|
623 |
+
}
|
624 |
+
function afterType(type, value) {
|
625 |
+
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
626 |
+
if (value == "|" || type == "." || value == "&") return cont(typeexpr)
|
627 |
+
if (type == "[") return cont(expect("]"), afterType)
|
628 |
+
if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
|
629 |
+
}
|
630 |
+
function maybeTypeArgs(_, value) {
|
631 |
+
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
632 |
+
}
|
633 |
+
function typeparam() {
|
634 |
+
return pass(typeexpr, maybeTypeDefault)
|
635 |
+
}
|
636 |
+
function maybeTypeDefault(_, value) {
|
637 |
+
if (value == "=") return cont(typeexpr)
|
638 |
+
}
|
639 |
+
function vardef(_, value) {
|
640 |
+
if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
|
641 |
+
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
642 |
+
}
|
643 |
+
function pattern(type, value) {
|
644 |
+
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
|
645 |
+
if (type == "variable") { register(value); return cont(); }
|
646 |
+
if (type == "spread") return cont(pattern);
|
647 |
+
if (type == "[") return contCommasep(pattern, "]");
|
648 |
+
if (type == "{") return contCommasep(proppattern, "}");
|
649 |
+
}
|
650 |
+
function proppattern(type, value) {
|
651 |
+
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
|
652 |
+
register(value);
|
653 |
+
return cont(maybeAssign);
|
654 |
+
}
|
655 |
+
if (type == "variable") cx.marked = "property";
|
656 |
+
if (type == "spread") return cont(pattern);
|
657 |
+
if (type == "}") return pass();
|
658 |
+
return cont(expect(":"), pattern, maybeAssign);
|
659 |
+
}
|
660 |
+
function maybeAssign(_type, value) {
|
661 |
+
if (value == "=") return cont(expressionNoComma);
|
662 |
+
}
|
663 |
+
function vardefCont(type) {
|
664 |
+
if (type == ",") return cont(vardef);
|
665 |
+
}
|
666 |
+
function maybeelse(type, value) {
|
667 |
+
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
668 |
+
}
|
669 |
+
function forspec(type, value) {
|
670 |
+
if (value == "await") return cont(forspec);
|
671 |
+
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
672 |
+
}
|
673 |
+
function forspec1(type) {
|
674 |
+
if (type == "var") return cont(vardef, expect(";"), forspec2);
|
675 |
+
if (type == ";") return cont(forspec2);
|
676 |
+
if (type == "variable") return cont(formaybeinof);
|
677 |
+
return pass(expression, expect(";"), forspec2);
|
678 |
+
}
|
679 |
+
function formaybeinof(_type, value) {
|
680 |
+
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
681 |
+
return cont(maybeoperatorComma, forspec2);
|
682 |
+
}
|
683 |
+
function forspec2(type, value) {
|
684 |
+
if (type == ";") return cont(forspec3);
|
685 |
+
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
686 |
+
return pass(expression, expect(";"), forspec3);
|
687 |
+
}
|
688 |
+
function forspec3(type) {
|
689 |
+
if (type != ")") cont(expression);
|
690 |
+
}
|
691 |
+
function functiondef(type, value) {
|
692 |
+
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
693 |
+
if (type == "variable") {register(value); return cont(functiondef);}
|
694 |
+
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
|
695 |
+
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
|
696 |
+
}
|
697 |
+
function funarg(type, value) {
|
698 |
+
if (value == "@") cont(expression, funarg)
|
699 |
+
if (type == "spread") return cont(funarg);
|
700 |
+
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
|
701 |
+
return pass(pattern, maybetype, maybeAssign);
|
702 |
+
}
|
703 |
+
function classExpression(type, value) {
|
704 |
+
// Class expressions may have an optional name.
|
705 |
+
if (type == "variable") return className(type, value);
|
706 |
+
return classNameAfter(type, value);
|
707 |
+
}
|
708 |
+
function className(type, value) {
|
709 |
+
if (type == "variable") {register(value); return cont(classNameAfter);}
|
710 |
+
}
|
711 |
+
function classNameAfter(type, value) {
|
712 |
+
if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
|
713 |
+
if (value == "extends" || value == "implements" || (isTS && type == ",")) {
|
714 |
+
if (value == "implements") cx.marked = "keyword";
|
715 |
+
return cont(isTS ? typeexpr : expression, classNameAfter);
|
716 |
+
}
|
717 |
+
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
718 |
+
}
|
719 |
+
function classBody(type, value) {
|
720 |
+
if (type == "async" ||
|
721 |
+
(type == "variable" &&
|
722 |
+
(value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
|
723 |
+
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
|
724 |
+
cx.marked = "keyword";
|
725 |
+
return cont(classBody);
|
726 |
+
}
|
727 |
+
if (type == "variable" || cx.style == "keyword") {
|
728 |
+
cx.marked = "property";
|
729 |
+
return cont(isTS ? classfield : functiondef, classBody);
|
730 |
+
}
|
731 |
+
if (type == "[")
|
732 |
+
return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
|
733 |
+
if (value == "*") {
|
734 |
+
cx.marked = "keyword";
|
735 |
+
return cont(classBody);
|
736 |
+
}
|
737 |
+
if (type == ";") return cont(classBody);
|
738 |
+
if (type == "}") return cont();
|
739 |
+
if (value == "@") return cont(expression, classBody)
|
740 |
+
}
|
741 |
+
function classfield(type, value) {
|
742 |
+
if (value == "?") return cont(classfield)
|
743 |
+
if (type == ":") return cont(typeexpr, maybeAssign)
|
744 |
+
if (value == "=") return cont(expressionNoComma)
|
745 |
+
return pass(functiondef)
|
746 |
+
}
|
747 |
+
function afterExport(type, value) {
|
748 |
+
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
749 |
+
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
750 |
+
if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
|
751 |
+
return pass(statement);
|
752 |
+
}
|
753 |
+
function exportField(type, value) {
|
754 |
+
if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
|
755 |
+
if (type == "variable") return pass(expressionNoComma, exportField);
|
756 |
+
}
|
757 |
+
function afterImport(type) {
|
758 |
+
if (type == "string") return cont();
|
759 |
+
if (type == "(") return pass(expression);
|
760 |
+
return pass(importSpec, maybeMoreImports, maybeFrom);
|
761 |
+
}
|
762 |
+
function importSpec(type, value) {
|
763 |
+
if (type == "{") return contCommasep(importSpec, "}");
|
764 |
+
if (type == "variable") register(value);
|
765 |
+
if (value == "*") cx.marked = "keyword";
|
766 |
+
return cont(maybeAs);
|
767 |
+
}
|
768 |
+
function maybeMoreImports(type) {
|
769 |
+
if (type == ",") return cont(importSpec, maybeMoreImports)
|
770 |
+
}
|
771 |
+
function maybeAs(_type, value) {
|
772 |
+
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
|
773 |
+
}
|
774 |
+
function maybeFrom(_type, value) {
|
775 |
+
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
|
776 |
+
}
|
777 |
+
function arrayLiteral(type) {
|
778 |
+
if (type == "]") return cont();
|
779 |
+
return pass(commasep(expressionNoComma, "]"));
|
780 |
+
}
|
781 |
+
function enumdef() {
|
782 |
+
return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
|
783 |
+
}
|
784 |
+
function enummember() {
|
785 |
+
return pass(pattern, maybeAssign);
|
786 |
+
}
|
787 |
+
|
788 |
+
function isContinuedStatement(state, textAfter) {
|
789 |
+
return state.lastType == "operator" || state.lastType == "," ||
|
790 |
+
isOperatorChar.test(textAfter.charAt(0)) ||
|
791 |
+
/[,.]/.test(textAfter.charAt(0));
|
792 |
+
}
|
793 |
+
|
794 |
+
function expressionAllowed(stream, state, backUp) {
|
795 |
+
return state.tokenize == tokenBase &&
|
796 |
+
/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
797 |
+
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
798 |
+
}
|
799 |
+
|
800 |
+
// Interface
|
801 |
+
|
802 |
+
return {
|
803 |
+
startState: function(basecolumn) {
|
804 |
+
var state = {
|
805 |
+
tokenize: tokenBase,
|
806 |
+
lastType: "sof",
|
807 |
+
cc: [],
|
808 |
+
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
809 |
+
localVars: parserConfig.localVars,
|
810 |
+
context: parserConfig.localVars && new Context(null, null, false),
|
811 |
+
indented: basecolumn || 0
|
812 |
+
};
|
813 |
+
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
814 |
+
state.globalVars = parserConfig.globalVars;
|
815 |
+
return state;
|
816 |
+
},
|
817 |
+
|
818 |
+
token: function(stream, state) {
|
819 |
+
if (stream.sol()) {
|
820 |
+
if (!state.lexical.hasOwnProperty("align"))
|
821 |
+
state.lexical.align = false;
|
822 |
+
state.indented = stream.indentation();
|
823 |
+
findFatArrow(stream, state);
|
824 |
+
}
|
825 |
+
if (state.tokenize != tokenComment && stream.eatSpace()) return null;
|
826 |
+
var style = state.tokenize(stream, state);
|
827 |
+
if (type == "comment") return style;
|
828 |
+
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
829 |
+
return parseJS(state, style, type, content, stream);
|
830 |
+
},
|
831 |
+
|
832 |
+
indent: function(state, textAfter) {
|
833 |
+
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
834 |
+
if (state.tokenize != tokenBase) return 0;
|
835 |
+
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
|
836 |
+
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
837 |
+
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
838 |
+
var c = state.cc[i];
|
839 |
+
if (c == poplex) lexical = lexical.prev;
|
840 |
+
else if (c != maybeelse) break;
|
841 |
+
}
|
842 |
+
while ((lexical.type == "stat" || lexical.type == "form") &&
|
843 |
+
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
|
844 |
+
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
|
845 |
+
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
|
846 |
+
lexical = lexical.prev;
|
847 |
+
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
848 |
+
lexical = lexical.prev;
|
849 |
+
var type = lexical.type, closing = firstChar == type;
|
850 |
+
|
851 |
+
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
|
852 |
+
else if (type == "form" && firstChar == "{") return lexical.indented;
|
853 |
+
else if (type == "form") return lexical.indented + indentUnit;
|
854 |
+
else if (type == "stat")
|
855 |
+
return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
|
856 |
+
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
857 |
+
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
858 |
+
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
859 |
+
else return lexical.indented + (closing ? 0 : indentUnit);
|
860 |
+
},
|
861 |
+
|
862 |
+
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
|
863 |
+
blockCommentStart: jsonMode ? null : "/*",
|
864 |
+
blockCommentEnd: jsonMode ? null : "*/",
|
865 |
+
blockCommentContinue: jsonMode ? null : " * ",
|
866 |
+
lineComment: jsonMode ? null : "//",
|
867 |
+
fold: "brace",
|
868 |
+
closeBrackets: "()[]{}''\"\"``",
|
869 |
+
|
870 |
+
helperType: jsonMode ? "json" : "javascript",
|
871 |
+
jsonldMode: jsonldMode,
|
872 |
+
jsonMode: jsonMode,
|
873 |
+
|
874 |
+
expressionAllowed: expressionAllowed,
|
875 |
+
|
876 |
+
skipExpression: function(state) {
|
877 |
+
var top = state.cc[state.cc.length - 1]
|
878 |
+
if (top == expression || top == expressionNoComma) state.cc.pop()
|
879 |
+
}
|
880 |
+
};
|
881 |
+
});
|
882 |
+
|
883 |
+
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
884 |
+
|
885 |
+
CodeMirror.defineMIME("text/javascript", "javascript");
|
886 |
+
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
887 |
+
CodeMirror.defineMIME("application/javascript", "javascript");
|
888 |
+
CodeMirror.defineMIME("application/x-javascript", "javascript");
|
889 |
+
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
890 |
+
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
891 |
+
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
892 |
+
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
|
893 |
+
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
894 |
+
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
895 |
+
|
896 |
+
});
|
inc/lib/codemirror/mode/javascript/json-ld.html
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: JSON-LD mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
10 |
+
<script src="../../addon/comment/continuecomment.js"></script>
|
11 |
+
<script src="../../addon/comment/comment.js"></script>
|
12 |
+
<script src="javascript.js"></script>
|
13 |
+
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
14 |
+
<div id="nav">
|
15 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"/></a>
|
16 |
+
|
17 |
+
<ul>
|
18 |
+
<li><a href="../../index.html">Home</a>
|
19 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
20 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
21 |
+
</ul>
|
22 |
+
<ul>
|
23 |
+
<li><a href="../index.html">Language modes</a>
|
24 |
+
<li><a class=active href="#">JSON-LD</a>
|
25 |
+
</ul>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<article>
|
29 |
+
<h2>JSON-LD mode</h2>
|
30 |
+
|
31 |
+
|
32 |
+
<div><textarea id="code" name="code">
|
33 |
+
{
|
34 |
+
"@context": {
|
35 |
+
"name": "http://schema.org/name",
|
36 |
+
"description": "http://schema.org/description",
|
37 |
+
"image": {
|
38 |
+
"@id": "http://schema.org/image",
|
39 |
+
"@type": "@id"
|
40 |
+
},
|
41 |
+
"geo": "http://schema.org/geo",
|
42 |
+
"latitude": {
|
43 |
+
"@id": "http://schema.org/latitude",
|
44 |
+
"@type": "xsd:float"
|
45 |
+
},
|
46 |
+
"longitude": {
|
47 |
+
"@id": "http://schema.org/longitude",
|
48 |
+
"@type": "xsd:float"
|
49 |
+
},
|
50 |
+
"xsd": "http://www.w3.org/2001/XMLSchema#"
|
51 |
+
},
|
52 |
+
"name": "The Empire State Building",
|
53 |
+
"description": "The Empire State Building is a 102-story landmark in New York City.",
|
54 |
+
"image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
|
55 |
+
"geo": {
|
56 |
+
"latitude": "40.75",
|
57 |
+
"longitude": "73.98"
|
58 |
+
}
|
59 |
+
}
|
60 |
+
</textarea></div>
|
61 |
+
|
62 |
+
<script>
|
63 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
64 |
+
matchBrackets: true,
|
65 |
+
autoCloseBrackets: true,
|
66 |
+
mode: "application/ld+json",
|
67 |
+
lineWrapping: true
|
68 |
+
});
|
69 |
+
</script>
|
70 |
+
|
71 |
+
<p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
|
72 |
+
</article>
|
inc/lib/codemirror/mode/javascript/test.js
ADDED
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "javascript");
|
6 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
7 |
+
|
8 |
+
MT("locals",
|
9 |
+
"[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");
|
10 |
+
|
11 |
+
MT("comma-and-binop",
|
12 |
+
"[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");
|
13 |
+
|
14 |
+
MT("destructuring",
|
15 |
+
"([keyword function]([def a], [[[def b], [def c] ]]) {",
|
16 |
+
" [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);",
|
17 |
+
" [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
|
18 |
+
"})();");
|
19 |
+
|
20 |
+
MT("destructure_trailing_comma",
|
21 |
+
"[keyword let] {[def a], [def b],} [operator =] [variable foo];",
|
22 |
+
"[keyword let] [def c];"); // Parser still in good state?
|
23 |
+
|
24 |
+
MT("class_body",
|
25 |
+
"[keyword class] [def Foo] {",
|
26 |
+
" [property constructor]() {}",
|
27 |
+
" [property sayName]() {",
|
28 |
+
" [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",
|
29 |
+
" }",
|
30 |
+
"}");
|
31 |
+
|
32 |
+
MT("class",
|
33 |
+
"[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
|
34 |
+
" [keyword get] [property prop]() { [keyword return] [number 24]; }",
|
35 |
+
" [property constructor]([def x], [def y]) {",
|
36 |
+
" [keyword super]([string 'something']);",
|
37 |
+
" [keyword this].[property x] [operator =] [variable-2 x];",
|
38 |
+
" }",
|
39 |
+
"}");
|
40 |
+
|
41 |
+
MT("anonymous_class_expression",
|
42 |
+
"[keyword const] [def Adder] [operator =] [keyword class] [keyword extends] [variable Arithmetic] {",
|
43 |
+
" [property add]([def a], [def b]) {}",
|
44 |
+
"};");
|
45 |
+
|
46 |
+
MT("named_class_expression",
|
47 |
+
"[keyword const] [def Subber] [operator =] [keyword class] [def Subtract] {",
|
48 |
+
" [property sub]([def a], [def b]) {}",
|
49 |
+
"};");
|
50 |
+
|
51 |
+
MT("class_async_method",
|
52 |
+
"[keyword class] [def Foo] {",
|
53 |
+
" [property sayName1]() {}",
|
54 |
+
" [keyword async] [property sayName2]() {}",
|
55 |
+
"}");
|
56 |
+
|
57 |
+
MT("import",
|
58 |
+
"[keyword function] [def foo]() {",
|
59 |
+
" [keyword import] [def $] [keyword from] [string 'jquery'];",
|
60 |
+
" [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
|
61 |
+
"}");
|
62 |
+
|
63 |
+
MT("import_trailing_comma",
|
64 |
+
"[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']")
|
65 |
+
|
66 |
+
MT("import_dynamic",
|
67 |
+
"[keyword import]([string 'baz']).[property then]")
|
68 |
+
|
69 |
+
MT("import_dynamic",
|
70 |
+
"[keyword const] [def t] [operator =] [keyword import]([string 'baz']).[property then]")
|
71 |
+
|
72 |
+
MT("const",
|
73 |
+
"[keyword function] [def f]() {",
|
74 |
+
" [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
|
75 |
+
"}");
|
76 |
+
|
77 |
+
MT("for/of",
|
78 |
+
"[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}");
|
79 |
+
|
80 |
+
MT("for await",
|
81 |
+
"[keyword for] [keyword await]([keyword let] [def of] [keyword of] [variable something]) {}");
|
82 |
+
|
83 |
+
MT("generator",
|
84 |
+
"[keyword function*] [def repeat]([def n]) {",
|
85 |
+
" [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
|
86 |
+
" [keyword yield] [variable-2 i];",
|
87 |
+
"}");
|
88 |
+
|
89 |
+
MT("let_scoping",
|
90 |
+
"[keyword function] [def scoped]([def n]) {",
|
91 |
+
" { [keyword var] [def i]; } [variable-2 i];",
|
92 |
+
" { [keyword let] [def j]; [variable-2 j]; } [variable j];",
|
93 |
+
" [keyword if] ([atom true]) { [keyword const] [def k]; [variable-2 k]; } [variable k];",
|
94 |
+
"}");
|
95 |
+
|
96 |
+
MT("switch_scoping",
|
97 |
+
"[keyword switch] ([variable x]) {",
|
98 |
+
" [keyword default]:",
|
99 |
+
" [keyword let] [def j];",
|
100 |
+
" [keyword return] [variable-2 j]",
|
101 |
+
"}",
|
102 |
+
"[variable j];")
|
103 |
+
|
104 |
+
MT("leaving_scope",
|
105 |
+
"[keyword function] [def a]() {",
|
106 |
+
" {",
|
107 |
+
" [keyword const] [def x] [operator =] [number 1]",
|
108 |
+
" [keyword if] ([atom true]) {",
|
109 |
+
" [keyword let] [def y] [operator =] [number 2]",
|
110 |
+
" [keyword var] [def z] [operator =] [number 3]",
|
111 |
+
" [variable console].[property log]([variable-2 x], [variable-2 y], [variable-2 z])",
|
112 |
+
" }",
|
113 |
+
" [variable console].[property log]([variable-2 x], [variable y], [variable-2 z])",
|
114 |
+
" }",
|
115 |
+
" [variable console].[property log]([variable x], [variable y], [variable-2 z])",
|
116 |
+
"}")
|
117 |
+
|
118 |
+
MT("quotedStringAddition",
|
119 |
+
"[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");
|
120 |
+
|
121 |
+
MT("quotedFatArrow",
|
122 |
+
"[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");
|
123 |
+
|
124 |
+
MT("fatArrow",
|
125 |
+
"[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
|
126 |
+
"[variable a];", // No longer in scope
|
127 |
+
"[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
|
128 |
+
"[variable c];");
|
129 |
+
|
130 |
+
MT("spread",
|
131 |
+
"[keyword function] [def f]([def a], [meta ...][def b]) {",
|
132 |
+
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
|
133 |
+
"}");
|
134 |
+
|
135 |
+
MT("quasi",
|
136 |
+
"[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
|
137 |
+
|
138 |
+
MT("quasi_no_function",
|
139 |
+
"[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
|
140 |
+
|
141 |
+
MT("indent_statement",
|
142 |
+
"[keyword var] [def x] [operator =] [number 10]",
|
143 |
+
"[variable x] [operator +=] [variable y] [operator +]",
|
144 |
+
" [atom Infinity]",
|
145 |
+
"[keyword debugger];");
|
146 |
+
|
147 |
+
MT("indent_if",
|
148 |
+
"[keyword if] ([number 1])",
|
149 |
+
" [keyword break];",
|
150 |
+
"[keyword else] [keyword if] ([number 2])",
|
151 |
+
" [keyword continue];",
|
152 |
+
"[keyword else]",
|
153 |
+
" [number 10];",
|
154 |
+
"[keyword if] ([number 1]) {",
|
155 |
+
" [keyword break];",
|
156 |
+
"} [keyword else] [keyword if] ([number 2]) {",
|
157 |
+
" [keyword continue];",
|
158 |
+
"} [keyword else] {",
|
159 |
+
" [number 10];",
|
160 |
+
"}");
|
161 |
+
|
162 |
+
MT("indent_for",
|
163 |
+
"[keyword for] ([keyword var] [def i] [operator =] [number 0];",
|
164 |
+
" [variable i] [operator <] [number 100];",
|
165 |
+
" [variable i][operator ++])",
|
166 |
+
" [variable doSomething]([variable i]);",
|
167 |
+
"[keyword debugger];");
|
168 |
+
|
169 |
+
MT("indent_c_style",
|
170 |
+
"[keyword function] [def foo]()",
|
171 |
+
"{",
|
172 |
+
" [keyword debugger];",
|
173 |
+
"}");
|
174 |
+
|
175 |
+
MT("indent_else",
|
176 |
+
"[keyword for] (;;)",
|
177 |
+
" [keyword if] ([variable foo])",
|
178 |
+
" [keyword if] ([variable bar])",
|
179 |
+
" [number 1];",
|
180 |
+
" [keyword else]",
|
181 |
+
" [number 2];",
|
182 |
+
" [keyword else]",
|
183 |
+
" [number 3];");
|
184 |
+
|
185 |
+
MT("indent_funarg",
|
186 |
+
"[variable foo]([number 10000],",
|
187 |
+
" [keyword function]([def a]) {",
|
188 |
+
" [keyword debugger];",
|
189 |
+
"};");
|
190 |
+
|
191 |
+
MT("indent_below_if",
|
192 |
+
"[keyword for] (;;)",
|
193 |
+
" [keyword if] ([variable foo])",
|
194 |
+
" [number 1];",
|
195 |
+
"[number 2];");
|
196 |
+
|
197 |
+
MT("indent_semicolonless_if",
|
198 |
+
"[keyword function] [def foo]() {",
|
199 |
+
" [keyword if] ([variable x])",
|
200 |
+
" [variable foo]()",
|
201 |
+
"}")
|
202 |
+
|
203 |
+
MT("indent_semicolonless_if_with_statement",
|
204 |
+
"[keyword function] [def foo]() {",
|
205 |
+
" [keyword if] ([variable x])",
|
206 |
+
" [variable foo]()",
|
207 |
+
" [variable bar]()",
|
208 |
+
"}")
|
209 |
+
|
210 |
+
MT("multilinestring",
|
211 |
+
"[keyword var] [def x] [operator =] [string 'foo\\]",
|
212 |
+
"[string bar'];");
|
213 |
+
|
214 |
+
MT("scary_regexp",
|
215 |
+
"[string-2 /foo[[/]]bar/];");
|
216 |
+
|
217 |
+
MT("indent_strange_array",
|
218 |
+
"[keyword var] [def x] [operator =] [[",
|
219 |
+
" [number 1],,",
|
220 |
+
" [number 2],",
|
221 |
+
"]];",
|
222 |
+
"[number 10];");
|
223 |
+
|
224 |
+
MT("param_default",
|
225 |
+
"[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
|
226 |
+
" [keyword return] [variable-2 x];",
|
227 |
+
"}");
|
228 |
+
|
229 |
+
MT("new_target",
|
230 |
+
"[keyword function] [def F]([def target]) {",
|
231 |
+
" [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",
|
232 |
+
" [keyword return] [keyword new]",
|
233 |
+
" .[keyword target];",
|
234 |
+
" }",
|
235 |
+
"}");
|
236 |
+
|
237 |
+
MT("async",
|
238 |
+
"[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");
|
239 |
+
|
240 |
+
MT("async_assignment",
|
241 |
+
"[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };");
|
242 |
+
|
243 |
+
MT("async_object",
|
244 |
+
"[keyword let] [def obj] [operator =] { [property async]: [atom false] };");
|
245 |
+
|
246 |
+
// async be highlighet as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173
|
247 |
+
MT("async_object_function",
|
248 |
+
"[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };");
|
249 |
+
|
250 |
+
MT("async_object_properties",
|
251 |
+
"[keyword let] [def obj] [operator =] {",
|
252 |
+
" [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
|
253 |
+
" [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },",
|
254 |
+
" [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },",
|
255 |
+
"};");
|
256 |
+
|
257 |
+
MT("async_arrow",
|
258 |
+
"[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };");
|
259 |
+
|
260 |
+
MT("async_jquery",
|
261 |
+
"[variable $].[property ajax]({",
|
262 |
+
" [property url]: [variable url],",
|
263 |
+
" [property async]: [atom true],",
|
264 |
+
" [property method]: [string 'GET']",
|
265 |
+
"});");
|
266 |
+
|
267 |
+
MT("async_variable",
|
268 |
+
"[keyword const] [def async] [operator =] {[property a]: [number 1]};",
|
269 |
+
"[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];")
|
270 |
+
|
271 |
+
MT("bigint", "[number 1n] [operator +] [number 0x1afn] [operator +] [number 0o064n] [operator +] [number 0b100n];")
|
272 |
+
|
273 |
+
MT("async_comment",
|
274 |
+
"[keyword async] [comment /**/] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }");
|
275 |
+
|
276 |
+
MT("indent_switch",
|
277 |
+
"[keyword switch] ([variable x]) {",
|
278 |
+
" [keyword default]:",
|
279 |
+
" [keyword return] [number 2]",
|
280 |
+
"}")
|
281 |
+
|
282 |
+
MT("regexp_corner_case",
|
283 |
+
"[operator +]{} [operator /] [atom undefined];",
|
284 |
+
"[[[meta ...][string-2 /\\//] ]];",
|
285 |
+
"[keyword void] [string-2 /\\//];",
|
286 |
+
"[keyword do] [string-2 /\\//]; [keyword while] ([number 0]);",
|
287 |
+
"[keyword if] ([number 0]) {} [keyword else] [string-2 /\\//];",
|
288 |
+
"[string-2 `${][variable async][operator ++][string-2 }//`];",
|
289 |
+
"[string-2 `${]{} [operator /] [string-2 /\\//}`];")
|
290 |
+
|
291 |
+
MT("return_eol",
|
292 |
+
"[keyword return]",
|
293 |
+
"{} [string-2 /5/]")
|
294 |
+
|
295 |
+
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
|
296 |
+
function TS(name) {
|
297 |
+
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
|
298 |
+
}
|
299 |
+
|
300 |
+
TS("typescript_extend_type",
|
301 |
+
"[keyword class] [def Foo] [keyword extends] [type Some][operator <][type Type][operator >] {}")
|
302 |
+
|
303 |
+
TS("typescript_arrow_type",
|
304 |
+
"[keyword let] [def x]: ([variable arg]: [type Type]) [operator =>] [type ReturnType]")
|
305 |
+
|
306 |
+
TS("typescript_class",
|
307 |
+
"[keyword class] [def Foo] {",
|
308 |
+
" [keyword public] [keyword static] [property main]() {}",
|
309 |
+
" [keyword private] [property _foo]: [type string];",
|
310 |
+
"}")
|
311 |
+
|
312 |
+
TS("typescript_literal_types",
|
313 |
+
"[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];",
|
314 |
+
"[keyword interface] [def MyAttributes] {",
|
315 |
+
" [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
|
316 |
+
" [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
|
317 |
+
"}",
|
318 |
+
"[keyword interface] [def MyInstance] [keyword extends] [type Sequelize].[type Instance] [operator <] [type MyAttributes] [operator >] {",
|
319 |
+
" [property rawAttributes]: [type MyAttributes];",
|
320 |
+
" [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];",
|
321 |
+
" [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];",
|
322 |
+
"}")
|
323 |
+
|
324 |
+
TS("typescript_extend_operators",
|
325 |
+
"[keyword export] [keyword interface] [def UserModel] [keyword extends]",
|
326 |
+
" [type Sequelize].[type Model] [operator <] [type UserInstance], [type UserAttributes] [operator >] {",
|
327 |
+
" [property findById]: (",
|
328 |
+
" [variable userId]: [type number]",
|
329 |
+
" ) [operator =>] [type Promise] [operator <] [type Array] [operator <] { [property id], [property name] } [operator >>];",
|
330 |
+
" [property updateById]: (",
|
331 |
+
" [variable userId]: [type number],",
|
332 |
+
" [variable isActive]: [type boolean]",
|
333 |
+
" ) [operator =>] [type Promise] [operator <] [type AccountHolderNotificationPreferenceInstance] [operator >];",
|
334 |
+
" }")
|
335 |
+
|
336 |
+
TS("typescript_interface_with_const",
|
337 |
+
"[keyword const] [def hello]: {",
|
338 |
+
" [property prop1][operator ?]: [type string];",
|
339 |
+
" [property prop2][operator ?]: [type string];",
|
340 |
+
"} [operator =] {};")
|
341 |
+
|
342 |
+
TS("typescript_double_extend",
|
343 |
+
"[keyword export] [keyword interface] [def UserAttributes] {",
|
344 |
+
" [property id][operator ?]: [type number];",
|
345 |
+
" [property createdAt][operator ?]: [type Date];",
|
346 |
+
"}",
|
347 |
+
"[keyword export] [keyword interface] [def UserInstance] [keyword extends] [type Sequelize].[type Instance][operator <][type UserAttributes][operator >], [type UserAttributes] {",
|
348 |
+
" [property id]: [type number];",
|
349 |
+
" [property createdAt]: [type Date];",
|
350 |
+
"}");
|
351 |
+
|
352 |
+
TS("typescript_index_signature",
|
353 |
+
"[keyword interface] [def A] {",
|
354 |
+
" [[ [variable prop]: [type string] ]]: [type any];",
|
355 |
+
" [property prop1]: [type any];",
|
356 |
+
"}");
|
357 |
+
|
358 |
+
TS("typescript_generic_class",
|
359 |
+
"[keyword class] [def Foo][operator <][type T][operator >] {",
|
360 |
+
" [property bar]() {}",
|
361 |
+
" [property foo](): [type Foo] {}",
|
362 |
+
"}")
|
363 |
+
|
364 |
+
TS("typescript_type_when_keyword",
|
365 |
+
"[keyword export] [keyword type] [type AB] [operator =] [type A] [operator |] [type B];",
|
366 |
+
"[keyword type] [type Flags] [operator =] {",
|
367 |
+
" [property p1]: [type string];",
|
368 |
+
" [property p2]: [type boolean];",
|
369 |
+
"};")
|
370 |
+
|
371 |
+
TS("typescript_type_when_not_keyword",
|
372 |
+
"[keyword class] [def HasType] {",
|
373 |
+
" [property type]: [type string];",
|
374 |
+
" [property constructor]([def type]: [type string]) {",
|
375 |
+
" [keyword this].[property type] [operator =] [variable-2 type];",
|
376 |
+
" }",
|
377 |
+
" [property setType]({ [def type] }: { [property type]: [type string]; }) {",
|
378 |
+
" [keyword this].[property type] [operator =] [variable-2 type];",
|
379 |
+
" }",
|
380 |
+
"}")
|
381 |
+
|
382 |
+
TS("typescript_function_generics",
|
383 |
+
"[keyword function] [def a]() {}",
|
384 |
+
"[keyword function] [def b][operator <][type IA] [keyword extends] [type object], [type IB] [keyword extends] [type object][operator >]() {}",
|
385 |
+
"[keyword function] [def c]() {}")
|
386 |
+
|
387 |
+
TS("typescript_complex_return_type",
|
388 |
+
"[keyword function] [def A]() {",
|
389 |
+
" [keyword return] [keyword this].[property property];",
|
390 |
+
"}",
|
391 |
+
"[keyword function] [def B](): [type Promise][operator <]{ [[ [variable key]: [type string] ]]: [type any] } [operator |] [atom null][operator >] {",
|
392 |
+
" [keyword return] [keyword this].[property property];",
|
393 |
+
"}")
|
394 |
+
|
395 |
+
TS("typescript_complex_type_casting",
|
396 |
+
"[keyword const] [def giftpay] [operator =] [variable config].[property get]([string 'giftpay']) [keyword as] { [[ [variable platformUuid]: [type string] ]]: { [property version]: [type number]; [property apiCode]: [type string]; } };")
|
397 |
+
|
398 |
+
TS("typescript_keyof",
|
399 |
+
"[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {",
|
400 |
+
" [keyword return]")
|
401 |
+
|
402 |
+
TS("typescript_new_typeargs",
|
403 |
+
"[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])")
|
404 |
+
|
405 |
+
TS("modifiers",
|
406 |
+
"[keyword class] [def Foo] {",
|
407 |
+
" [keyword public] [keyword abstract] [property bar]() {}",
|
408 |
+
" [property constructor]([keyword readonly] [keyword private] [def x]) {}",
|
409 |
+
"}")
|
410 |
+
|
411 |
+
TS("arrow prop",
|
412 |
+
"({[property a]: [def p] [operator =>] [variable-2 p]})")
|
413 |
+
|
414 |
+
TS("generic in function call",
|
415 |
+
"[keyword this].[property a][operator <][type Type][operator >]([variable foo]);",
|
416 |
+
"[keyword this].[property a][operator <][variable Type][operator >][variable foo];")
|
417 |
+
|
418 |
+
TS("type guard",
|
419 |
+
"[keyword class] [def Appler] {",
|
420 |
+
" [keyword static] [property assertApple]([def fruit]: [type Fruit]): [variable-2 fruit] [keyword is] [type Apple] {",
|
421 |
+
" [keyword if] ([operator !]([variable-2 fruit] [keyword instanceof] [variable Apple]))",
|
422 |
+
" [keyword throw] [keyword new] [variable Error]();",
|
423 |
+
" }",
|
424 |
+
"}")
|
425 |
+
|
426 |
+
TS("type as variable",
|
427 |
+
"[variable type] [operator =] [variable x] [keyword as] [type Bar];");
|
428 |
+
|
429 |
+
TS("enum body",
|
430 |
+
"[keyword export] [keyword const] [keyword enum] [def CodeInspectionResultType] {",
|
431 |
+
" [def ERROR] [operator =] [string 'problem_type_error'],",
|
432 |
+
" [def WARNING] [operator =] [string 'problem_type_warning'],",
|
433 |
+
" [def META],",
|
434 |
+
"}")
|
435 |
+
|
436 |
+
TS("parenthesized type",
|
437 |
+
"[keyword class] [def Foo] {",
|
438 |
+
" [property x] [operator =] [keyword new] [variable A][operator <][type B], [type string][operator |](() [operator =>] [type void])[operator >]();",
|
439 |
+
" [keyword private] [property bar]();",
|
440 |
+
"}")
|
441 |
+
|
442 |
+
TS("abstract class",
|
443 |
+
"[keyword export] [keyword abstract] [keyword class] [def Foo] {}")
|
444 |
+
|
445 |
+
var jsonld_mode = CodeMirror.getMode(
|
446 |
+
{indentUnit: 2},
|
447 |
+
{name: "javascript", jsonld: true}
|
448 |
+
);
|
449 |
+
function LD(name) {
|
450 |
+
test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1));
|
451 |
+
}
|
452 |
+
|
453 |
+
LD("json_ld_keywords",
|
454 |
+
'{',
|
455 |
+
' [meta "@context"]: {',
|
456 |
+
' [meta "@base"]: [string "http://example.com"],',
|
457 |
+
' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],',
|
458 |
+
' [property "likesFlavor"]: {',
|
459 |
+
' [meta "@container"]: [meta "@list"]',
|
460 |
+
' [meta "@reverse"]: [string "@beFavoriteOf"]',
|
461 |
+
' },',
|
462 |
+
' [property "nick"]: { [meta "@container"]: [meta "@set"] },',
|
463 |
+
' [property "nick"]: { [meta "@container"]: [meta "@index"] }',
|
464 |
+
' },',
|
465 |
+
' [meta "@graph"]: [[ {',
|
466 |
+
' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],',
|
467 |
+
' [property "name"]: [string "John Lennon"],',
|
468 |
+
' [property "modified"]: {',
|
469 |
+
' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],',
|
470 |
+
' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]',
|
471 |
+
' }',
|
472 |
+
' } ]]',
|
473 |
+
'}');
|
474 |
+
|
475 |
+
LD("json_ld_fake",
|
476 |
+
'{',
|
477 |
+
' [property "@fake"]: [string "@fake"],',
|
478 |
+
' [property "@contextual"]: [string "@identifier"],',
|
479 |
+
' [property "user@domain.com"]: [string "@graphical"],',
|
480 |
+
' [property "@ID"]: [string "@@ID"]',
|
481 |
+
'}');
|
482 |
+
})();
|
inc/lib/codemirror/mode/javascript/typescript.html
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: TypeScript mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="javascript.js"></script>
|
10 |
+
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
11 |
+
<div id=nav>
|
12 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
13 |
+
|
14 |
+
<ul>
|
15 |
+
<li><a href="../../index.html">Home</a>
|
16 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
17 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
18 |
+
</ul>
|
19 |
+
<ul>
|
20 |
+
<li><a href="../index.html">Language modes</a>
|
21 |
+
<li><a class=active href="#">TypeScript</a>
|
22 |
+
</ul>
|
23 |
+
</div>
|
24 |
+
|
25 |
+
<article>
|
26 |
+
<h2>TypeScript mode</h2>
|
27 |
+
|
28 |
+
|
29 |
+
<div><textarea id="code" name="code">
|
30 |
+
class Greeter {
|
31 |
+
greeting: string;
|
32 |
+
constructor (message: string) {
|
33 |
+
this.greeting = message;
|
34 |
+
}
|
35 |
+
greet() {
|
36 |
+
return "Hello, " + this.greeting;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
var greeter = new Greeter("world");
|
41 |
+
|
42 |
+
var button = document.createElement('button')
|
43 |
+
button.innerText = "Say Hello"
|
44 |
+
button.onclick = function() {
|
45 |
+
alert(greeter.greet())
|
46 |
+
}
|
47 |
+
|
48 |
+
document.body.appendChild(button)
|
49 |
+
|
50 |
+
</textarea></div>
|
51 |
+
|
52 |
+
<script>
|
53 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
54 |
+
lineNumbers: true,
|
55 |
+
matchBrackets: true,
|
56 |
+
mode: "text/typescript"
|
57 |
+
});
|
58 |
+
</script>
|
59 |
+
|
60 |
+
<p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
|
61 |
+
</article>
|
inc/lib/codemirror/mode/meta.js
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
CodeMirror.modeInfo = [
|
15 |
+
{name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
|
16 |
+
{name: "PGP", mimes: ["application/pgp", "application/pgp-encrypted", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["asc", "pgp", "sig"]},
|
17 |
+
{name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]},
|
18 |
+
{name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i},
|
19 |
+
{name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
|
20 |
+
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]},
|
21 |
+
{name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
|
22 |
+
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
|
23 |
+
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
|
24 |
+
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
|
25 |
+
{name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
|
26 |
+
{name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
|
27 |
+
{name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
|
28 |
+
{name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
|
29 |
+
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
|
30 |
+
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
|
31 |
+
{name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
|
32 |
+
{name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
|
33 |
+
{name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
|
34 |
+
{name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
|
35 |
+
{name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
|
36 |
+
{name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]},
|
37 |
+
{name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
|
38 |
+
{name: "Django", mime: "text/x-django", mode: "django"},
|
39 |
+
{name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/},
|
40 |
+
{name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
|
41 |
+
{name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
|
42 |
+
{name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
|
43 |
+
{name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
|
44 |
+
{name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
|
45 |
+
{name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
|
46 |
+
{name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
|
47 |
+
{name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
|
48 |
+
{name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
|
49 |
+
{name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
|
50 |
+
{name: "Esper", mime: "text/x-esper", mode: "sql"},
|
51 |
+
{name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
|
52 |
+
{name: "FCL", mime: "text/x-fcl", mode: "fcl"},
|
53 |
+
{name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
|
54 |
+
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
|
55 |
+
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
|
56 |
+
{name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
|
57 |
+
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
|
58 |
+
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
|
59 |
+
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
|
60 |
+
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
|
61 |
+
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
62 |
+
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
|
63 |
+
{name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
|
64 |
+
{name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
|
65 |
+
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
|
66 |
+
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
|
67 |
+
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm", "handlebars", "hbs"], alias: ["xhtml"]},
|
68 |
+
{name: "HTTP", mime: "message/http", mode: "http"},
|
69 |
+
{name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
|
70 |
+
{name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
|
71 |
+
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
|
72 |
+
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
|
73 |
+
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
|
74 |
+
mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
|
75 |
+
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
|
76 |
+
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
|
77 |
+
{name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
|
78 |
+
{name: "Jinja2", mime: "null", mode: "jinja2"},
|
79 |
+
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
|
80 |
+
{name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
|
81 |
+
{name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
|
82 |
+
{name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
|
83 |
+
{name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
|
84 |
+
{name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
|
85 |
+
{name: "mIRC", mime: "text/mirc", mode: "mirc"},
|
86 |
+
{name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
|
87 |
+
{name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]},
|
88 |
+
{name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
|
89 |
+
{name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]},
|
90 |
+
{name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
|
91 |
+
{name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]},
|
92 |
+
{name: "MySQL", mime: "text/x-mysql", mode: "sql"},
|
93 |
+
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
|
94 |
+
{name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
|
95 |
+
{name: "NTriples", mimes: ["application/n-triples", "application/n-quads", "text/n-triples"],
|
96 |
+
mode: "ntriples", ext: ["nt", "nq"]},
|
97 |
+
{name: "Objective-C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"], alias: ["objective-c", "objc"]},
|
98 |
+
{name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
|
99 |
+
{name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
|
100 |
+
{name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]},
|
101 |
+
{name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
|
102 |
+
{name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]},
|
103 |
+
{name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
|
104 |
+
{name: "PHP", mimes: ["text/x-php", "application/x-httpd-php", "application/x-httpd-php-open"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"]},
|
105 |
+
{name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
|
106 |
+
{name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
|
107 |
+
{name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
|
108 |
+
{name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
|
109 |
+
{name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
|
110 |
+
{name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
|
111 |
+
{name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/},
|
112 |
+
{name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
|
113 |
+
{name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
|
114 |
+
{name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]},
|
115 |
+
{name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]},
|
116 |
+
{name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"},
|
117 |
+
{name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
|
118 |
+
{name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
|
119 |
+
{name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
|
120 |
+
{name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]},
|
121 |
+
{name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
|
122 |
+
{name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
|
123 |
+
{name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
|
124 |
+
{name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
|
125 |
+
{name: "Shell", mimes: ["text/x-sh", "application/x-sh"], mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/},
|
126 |
+
{name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]},
|
127 |
+
{name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]},
|
128 |
+
{name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
|
129 |
+
{name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
|
130 |
+
{name: "Solr", mime: "text/x-solr", mode: "solr"},
|
131 |
+
{name: "SML", mime: "text/x-sml", mode: "mllike", ext: ["sml", "sig", "fun", "smackspec"]},
|
132 |
+
{name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]},
|
133 |
+
{name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
|
134 |
+
{name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]},
|
135 |
+
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
|
136 |
+
{name: "SQLite", mime: "text/x-sqlite", mode: "sql"},
|
137 |
+
{name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
|
138 |
+
{name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"]},
|
139 |
+
{name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
|
140 |
+
{name: "sTeX", mime: "text/x-stex", mode: "stex"},
|
141 |
+
{name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx", "tex"], alias: ["tex"]},
|
142 |
+
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]},
|
143 |
+
{name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
|
144 |
+
{name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
|
145 |
+
{name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
|
146 |
+
{name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
|
147 |
+
{name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
|
148 |
+
{name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
|
149 |
+
{name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]},
|
150 |
+
{name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]},
|
151 |
+
{name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]},
|
152 |
+
{name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
|
153 |
+
{name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
|
154 |
+
{name: "TypeScript-JSX", mime: "text/typescript-jsx", mode: "jsx", ext: ["tsx"], alias: ["tsx"]},
|
155 |
+
{name: "Twig", mime: "text/x-twig", mode: "twig"},
|
156 |
+
{name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]},
|
157 |
+
{name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
|
158 |
+
{name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]},
|
159 |
+
{name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
|
160 |
+
{name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
|
161 |
+
{name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]},
|
162 |
+
{name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]},
|
163 |
+
{name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"]},
|
164 |
+
{name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
|
165 |
+
{name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]},
|
166 |
+
{name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]},
|
167 |
+
{name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
|
168 |
+
{name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
|
169 |
+
{name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
|
170 |
+
{name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
|
171 |
+
];
|
172 |
+
// Ensure all modes have a mime property for backwards compatibility
|
173 |
+
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
174 |
+
var info = CodeMirror.modeInfo[i];
|
175 |
+
if (info.mimes) info.mime = info.mimes[0];
|
176 |
+
}
|
177 |
+
|
178 |
+
CodeMirror.findModeByMIME = function(mime) {
|
179 |
+
mime = mime.toLowerCase();
|
180 |
+
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
181 |
+
var info = CodeMirror.modeInfo[i];
|
182 |
+
if (info.mime == mime) return info;
|
183 |
+
if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
|
184 |
+
if (info.mimes[j] == mime) return info;
|
185 |
+
}
|
186 |
+
if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME("application/xml")
|
187 |
+
if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME("application/json")
|
188 |
+
};
|
189 |
+
|
190 |
+
CodeMirror.findModeByExtension = function(ext) {
|
191 |
+
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
192 |
+
var info = CodeMirror.modeInfo[i];
|
193 |
+
if (info.ext) for (var j = 0; j < info.ext.length; j++)
|
194 |
+
if (info.ext[j] == ext) return info;
|
195 |
+
}
|
196 |
+
};
|
197 |
+
|
198 |
+
CodeMirror.findModeByFileName = function(filename) {
|
199 |
+
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
200 |
+
var info = CodeMirror.modeInfo[i];
|
201 |
+
if (info.file && info.file.test(filename)) return info;
|
202 |
+
}
|
203 |
+
var dot = filename.lastIndexOf(".");
|
204 |
+
var ext = dot > -1 && filename.substring(dot + 1, filename.length);
|
205 |
+
if (ext) return CodeMirror.findModeByExtension(ext);
|
206 |
+
};
|
207 |
+
|
208 |
+
CodeMirror.findModeByName = function(name) {
|
209 |
+
name = name.toLowerCase();
|
210 |
+
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
211 |
+
var info = CodeMirror.modeInfo[i];
|
212 |
+
if (info.name.toLowerCase() == name) return info;
|
213 |
+
if (info.alias) for (var j = 0; j < info.alias.length; j++)
|
214 |
+
if (info.alias[j].toLowerCase() == name) return info;
|
215 |
+
}
|
216 |
+
};
|
217 |
+
});
|
inc/lib/codemirror/mode/php/index.html
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: PHP mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
10 |
+
<script src="../htmlmixed/htmlmixed.js"></script>
|
11 |
+
<script src="../xml/xml.js"></script>
|
12 |
+
<script src="../javascript/javascript.js"></script>
|
13 |
+
<script src="../css/css.js"></script>
|
14 |
+
<script src="../clike/clike.js"></script>
|
15 |
+
<script src="php.js"></script>
|
16 |
+
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
17 |
+
<div id=nav>
|
18 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
19 |
+
|
20 |
+
<ul>
|
21 |
+
<li><a href="../../index.html">Home</a>
|
22 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
23 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
24 |
+
</ul>
|
25 |
+
<ul>
|
26 |
+
<li><a href="../index.html">Language modes</a>
|
27 |
+
<li><a class=active href="#">PHP</a>
|
28 |
+
</ul>
|
29 |
+
</div>
|
30 |
+
|
31 |
+
<article>
|
32 |
+
<h2>PHP mode</h2>
|
33 |
+
<form><textarea id="code" name="code">
|
34 |
+
<?php
|
35 |
+
$a = array('a' => 1, 'b' => 2, 3 => 'c');
|
36 |
+
|
37 |
+
echo "$a[a] ${a[3] /* } comment */} {$a[b]} \$a[a]";
|
38 |
+
|
39 |
+
function hello($who) {
|
40 |
+
return "Hello $who!";
|
41 |
+
}
|
42 |
+
?>
|
43 |
+
<p>The program says <?= hello("World") ?>.</p>
|
44 |
+
<script>
|
45 |
+
alert("And here is some JS code"); // also colored
|
46 |
+
</script>
|
47 |
+
</textarea></form>
|
48 |
+
|
49 |
+
<script>
|
50 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
51 |
+
lineNumbers: true,
|
52 |
+
matchBrackets: true,
|
53 |
+
mode: "application/x-httpd-php",
|
54 |
+
indentUnit: 4,
|
55 |
+
indentWithTabs: true
|
56 |
+
});
|
57 |
+
</script>
|
58 |
+
|
59 |
+
<p>Simple HTML/PHP mode based on
|
60 |
+
the <a href="../clike/">C-like</a> mode. Depends on XML,
|
61 |
+
JavaScript, CSS, HTMLMixed, and C-like modes.</p>
|
62 |
+
|
63 |
+
<p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
|
64 |
+
</article>
|
inc/lib/codemirror/mode/php/php.js
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../clike/clike"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../clike/clike"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
function keywords(str) {
|
15 |
+
var obj = {}, words = str.split(" ");
|
16 |
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
17 |
+
return obj;
|
18 |
+
}
|
19 |
+
|
20 |
+
// Helper for phpString
|
21 |
+
function matchSequence(list, end, escapes) {
|
22 |
+
if (list.length == 0) return phpString(end);
|
23 |
+
return function (stream, state) {
|
24 |
+
var patterns = list[0];
|
25 |
+
for (var i = 0; i < patterns.length; i++) if (stream.match(patterns[i][0])) {
|
26 |
+
state.tokenize = matchSequence(list.slice(1), end);
|
27 |
+
return patterns[i][1];
|
28 |
+
}
|
29 |
+
state.tokenize = phpString(end, escapes);
|
30 |
+
return "string";
|
31 |
+
};
|
32 |
+
}
|
33 |
+
function phpString(closing, escapes) {
|
34 |
+
return function(stream, state) { return phpString_(stream, state, closing, escapes); };
|
35 |
+
}
|
36 |
+
function phpString_(stream, state, closing, escapes) {
|
37 |
+
// "Complex" syntax
|
38 |
+
if (escapes !== false && stream.match("${", false) || stream.match("{$", false)) {
|
39 |
+
state.tokenize = null;
|
40 |
+
return "string";
|
41 |
+
}
|
42 |
+
|
43 |
+
// Simple syntax
|
44 |
+
if (escapes !== false && stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
|
45 |
+
// After the variable name there may appear array or object operator.
|
46 |
+
if (stream.match("[", false)) {
|
47 |
+
// Match array operator
|
48 |
+
state.tokenize = matchSequence([
|
49 |
+
[["[", null]],
|
50 |
+
[[/\d[\w\.]*/, "number"],
|
51 |
+
[/\$[a-zA-Z_][a-zA-Z0-9_]*/, "variable-2"],
|
52 |
+
[/[\w\$]+/, "variable"]],
|
53 |
+
[["]", null]]
|
54 |
+
], closing, escapes);
|
55 |
+
}
|
56 |
+
if (stream.match(/\-\>\w/, false)) {
|
57 |
+
// Match object operator
|
58 |
+
state.tokenize = matchSequence([
|
59 |
+
[["->", null]],
|
60 |
+
[[/[\w]+/, "variable"]]
|
61 |
+
], closing, escapes);
|
62 |
+
}
|
63 |
+
return "variable-2";
|
64 |
+
}
|
65 |
+
|
66 |
+
var escaped = false;
|
67 |
+
// Normal string
|
68 |
+
while (!stream.eol() &&
|
69 |
+
(escaped || escapes === false ||
|
70 |
+
(!stream.match("{$", false) &&
|
71 |
+
!stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) {
|
72 |
+
if (!escaped && stream.match(closing)) {
|
73 |
+
state.tokenize = null;
|
74 |
+
state.tokStack.pop(); state.tokStack.pop();
|
75 |
+
break;
|
76 |
+
}
|
77 |
+
escaped = stream.next() == "\\" && !escaped;
|
78 |
+
}
|
79 |
+
return "string";
|
80 |
+
}
|
81 |
+
|
82 |
+
var phpKeywords = "abstract and array as break case catch class clone const continue declare default " +
|
83 |
+
"do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final " +
|
84 |
+
"for foreach function global goto if implements interface instanceof namespace " +
|
85 |
+
"new or private protected public static switch throw trait try use var while xor " +
|
86 |
+
"die echo empty exit eval include include_once isset list require require_once return " +
|
87 |
+
"print unset __halt_compiler self static parent yield insteadof finally";
|
88 |
+
var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__";
|
89 |
+
var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents file_put_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists array_intersect_key array_combine array_column pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once json_decode json_encode json_last_error json_last_error_msg curl_close curl_copy_handle curl_errno curl_error curl_escape curl_exec curl_file_create curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_setopt curl_share_close curl_share_init curl_share_setopt curl_strerror curl_unescape curl_version mysqli_affected_rows mysqli_autocommit mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect_errno mysqli_connect_error mysqli_connect mysqli_data_seek mysqli_debug mysqli_dump_debug_info mysqli_errno mysqli_error_list mysqli_error mysqli_fetch_all mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_charset mysqli_get_client_info mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_num_fields mysqli_num_rows mysqli_options mysqli_ping mysqli_prepare mysqli_query mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reap_async_query mysqli_refresh mysqli_rollback mysqli_select_db mysqli_set_charset mysqli_set_local_infile_default mysqli_set_local_infile_handler mysqli_sqlstate mysqli_ssl_set mysqli_stat mysqli_stmt_init mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count";
|
90 |
+
CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" "));
|
91 |
+
CodeMirror.registerHelper("wordChars", "php", /[\w$]/);
|
92 |
+
|
93 |
+
var phpConfig = {
|
94 |
+
name: "clike",
|
95 |
+
helperType: "php",
|
96 |
+
keywords: keywords(phpKeywords),
|
97 |
+
blockKeywords: keywords("catch do else elseif for foreach if switch try while finally"),
|
98 |
+
defKeywords: keywords("class function interface namespace trait"),
|
99 |
+
atoms: keywords(phpAtoms),
|
100 |
+
builtin: keywords(phpBuiltin),
|
101 |
+
multiLineStrings: true,
|
102 |
+
hooks: {
|
103 |
+
"$": function(stream) {
|
104 |
+
stream.eatWhile(/[\w\$_]/);
|
105 |
+
return "variable-2";
|
106 |
+
},
|
107 |
+
"<": function(stream, state) {
|
108 |
+
var before;
|
109 |
+
if (before = stream.match(/<<\s*/)) {
|
110 |
+
var quoted = stream.eat(/['"]/);
|
111 |
+
stream.eatWhile(/[\w\.]/);
|
112 |
+
var delim = stream.current().slice(before[0].length + (quoted ? 2 : 1));
|
113 |
+
if (quoted) stream.eat(quoted);
|
114 |
+
if (delim) {
|
115 |
+
(state.tokStack || (state.tokStack = [])).push(delim, 0);
|
116 |
+
state.tokenize = phpString(delim, quoted != "'");
|
117 |
+
return "string";
|
118 |
+
}
|
119 |
+
}
|
120 |
+
return false;
|
121 |
+
},
|
122 |
+
"#": function(stream) {
|
123 |
+
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
124 |
+
return "comment";
|
125 |
+
},
|
126 |
+
"/": function(stream) {
|
127 |
+
if (stream.eat("/")) {
|
128 |
+
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
129 |
+
return "comment";
|
130 |
+
}
|
131 |
+
return false;
|
132 |
+
},
|
133 |
+
'"': function(_stream, state) {
|
134 |
+
(state.tokStack || (state.tokStack = [])).push('"', 0);
|
135 |
+
state.tokenize = phpString('"');
|
136 |
+
return "string";
|
137 |
+
},
|
138 |
+
"{": function(_stream, state) {
|
139 |
+
if (state.tokStack && state.tokStack.length)
|
140 |
+
state.tokStack[state.tokStack.length - 1]++;
|
141 |
+
return false;
|
142 |
+
},
|
143 |
+
"}": function(_stream, state) {
|
144 |
+
if (state.tokStack && state.tokStack.length > 0 &&
|
145 |
+
!--state.tokStack[state.tokStack.length - 1]) {
|
146 |
+
state.tokenize = phpString(state.tokStack[state.tokStack.length - 2]);
|
147 |
+
}
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
};
|
152 |
+
|
153 |
+
CodeMirror.defineMode("php", function(config, parserConfig) {
|
154 |
+
var htmlMode = CodeMirror.getMode(config, (parserConfig && parserConfig.htmlMode) || "text/html");
|
155 |
+
var phpMode = CodeMirror.getMode(config, phpConfig);
|
156 |
+
|
157 |
+
function dispatch(stream, state) {
|
158 |
+
var isPHP = state.curMode == phpMode;
|
159 |
+
if (stream.sol() && state.pending && state.pending != '"' && state.pending != "'") state.pending = null;
|
160 |
+
if (!isPHP) {
|
161 |
+
if (stream.match(/^<\?\w*/)) {
|
162 |
+
state.curMode = phpMode;
|
163 |
+
if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, ""))
|
164 |
+
state.curState = state.php;
|
165 |
+
return "meta";
|
166 |
+
}
|
167 |
+
if (state.pending == '"' || state.pending == "'") {
|
168 |
+
while (!stream.eol() && stream.next() != state.pending) {}
|
169 |
+
var style = "string";
|
170 |
+
} else if (state.pending && stream.pos < state.pending.end) {
|
171 |
+
stream.pos = state.pending.end;
|
172 |
+
var style = state.pending.style;
|
173 |
+
} else {
|
174 |
+
var style = htmlMode.token(stream, state.curState);
|
175 |
+
}
|
176 |
+
if (state.pending) state.pending = null;
|
177 |
+
var cur = stream.current(), openPHP = cur.search(/<\?/), m;
|
178 |
+
if (openPHP != -1) {
|
179 |
+
if (style == "string" && (m = cur.match(/[\'\"]$/)) && !/\?>/.test(cur)) state.pending = m[0];
|
180 |
+
else state.pending = {end: stream.pos, style: style};
|
181 |
+
stream.backUp(cur.length - openPHP);
|
182 |
+
}
|
183 |
+
return style;
|
184 |
+
} else if (isPHP && state.php.tokenize == null && stream.match("?>")) {
|
185 |
+
state.curMode = htmlMode;
|
186 |
+
state.curState = state.html;
|
187 |
+
if (!state.php.context.prev) state.php = null;
|
188 |
+
return "meta";
|
189 |
+
} else {
|
190 |
+
return phpMode.token(stream, state.curState);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
return {
|
195 |
+
startState: function() {
|
196 |
+
var html = CodeMirror.startState(htmlMode)
|
197 |
+
var php = parserConfig.startOpen ? CodeMirror.startState(phpMode) : null
|
198 |
+
return {html: html,
|
199 |
+
php: php,
|
200 |
+
curMode: parserConfig.startOpen ? phpMode : htmlMode,
|
201 |
+
curState: parserConfig.startOpen ? php : html,
|
202 |
+
pending: null};
|
203 |
+
},
|
204 |
+
|
205 |
+
copyState: function(state) {
|
206 |
+
var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
|
207 |
+
php = state.php, phpNew = php && CodeMirror.copyState(phpMode, php), cur;
|
208 |
+
if (state.curMode == htmlMode) cur = htmlNew;
|
209 |
+
else cur = phpNew;
|
210 |
+
return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
|
211 |
+
pending: state.pending};
|
212 |
+
},
|
213 |
+
|
214 |
+
token: dispatch,
|
215 |
+
|
216 |
+
indent: function(state, textAfter) {
|
217 |
+
if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) ||
|
218 |
+
(state.curMode == phpMode && /^\?>/.test(textAfter)))
|
219 |
+
return htmlMode.indent(state.html, textAfter);
|
220 |
+
return state.curMode.indent(state.curState, textAfter);
|
221 |
+
},
|
222 |
+
|
223 |
+
blockCommentStart: "/*",
|
224 |
+
blockCommentEnd: "*/",
|
225 |
+
lineComment: "//",
|
226 |
+
|
227 |
+
innerMode: function(state) { return {state: state.curState, mode: state.curMode}; }
|
228 |
+
};
|
229 |
+
}, "htmlmixed", "clike");
|
230 |
+
|
231 |
+
CodeMirror.defineMIME("application/x-httpd-php", "php");
|
232 |
+
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
233 |
+
CodeMirror.defineMIME("text/x-php", phpConfig);
|
234 |
+
});
|
inc/lib/codemirror/mode/php/test.js
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "php");
|
6 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
7 |
+
|
8 |
+
MT('simple_test',
|
9 |
+
'[meta <?php] ' +
|
10 |
+
'[keyword echo] [string "aaa"]; ' +
|
11 |
+
'[meta ?>]');
|
12 |
+
|
13 |
+
MT('variable_interpolation_non_alphanumeric',
|
14 |
+
'[meta <?php]',
|
15 |
+
'[keyword echo] [string "aaa$~$!$@$#$$$%$^$&$*$($)$.$<$>$/$\\$}$\\\"$:$;$?$|$[[$]]$+$=aaa"]',
|
16 |
+
'[meta ?>]');
|
17 |
+
|
18 |
+
MT('variable_interpolation_digits',
|
19 |
+
'[meta <?php]',
|
20 |
+
'[keyword echo] [string "aaa$1$2$3$4$5$6$7$8$9$0aaa"]',
|
21 |
+
'[meta ?>]');
|
22 |
+
|
23 |
+
MT('variable_interpolation_simple_syntax_1',
|
24 |
+
'[meta <?php]',
|
25 |
+
'[keyword echo] [string "aaa][variable-2 $aaa][string .aaa"];',
|
26 |
+
'[meta ?>]');
|
27 |
+
|
28 |
+
MT('variable_interpolation_simple_syntax_2',
|
29 |
+
'[meta <?php]',
|
30 |
+
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2]', ']][string aa"];',
|
31 |
+
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2345]', ']][string aa"];',
|
32 |
+
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2.3]', ']][string aa"];',
|
33 |
+
'[keyword echo] [string "][variable-2 $aaaa][[','[variable aaaaa]', ']][string aa"];',
|
34 |
+
'[keyword echo] [string "][variable-2 $aaaa][[','[variable-2 $aaaaa]',']][string aa"];',
|
35 |
+
|
36 |
+
'[keyword echo] [string "1aaa][variable-2 $aaaa][[','[number 2]', ']][string aa"];',
|
37 |
+
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[number 2345]', ']][string aa"];',
|
38 |
+
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[number 2.3]', ']][string aa"];',
|
39 |
+
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[variable aaaaa]', ']][string aa"];',
|
40 |
+
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[variable-2 $aaaaa]',']][string aa"];',
|
41 |
+
'[meta ?>]');
|
42 |
+
|
43 |
+
MT('variable_interpolation_simple_syntax_3',
|
44 |
+
'[meta <?php]',
|
45 |
+
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string .aaaaaa"];',
|
46 |
+
'[keyword echo] [string "aaa][variable-2 $aaaa][string ->][variable-2 $aaaaa][string .aaaaaa"];',
|
47 |
+
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string [[2]].aaaaaa"];',
|
48 |
+
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string ->aaaa2.aaaaaa"];',
|
49 |
+
'[meta ?>]');
|
50 |
+
|
51 |
+
MT('variable_interpolation_escaping',
|
52 |
+
'[meta <?php] [comment /* Escaping */]',
|
53 |
+
'[keyword echo] [string "aaa\\$aaaa->aaa.aaa"];',
|
54 |
+
'[keyword echo] [string "aaa\\$aaaa[[2]]aaa.aaa"];',
|
55 |
+
'[keyword echo] [string "aaa\\$aaaa[[asd]]aaa.aaa"];',
|
56 |
+
'[keyword echo] [string "aaa{\\$aaaa->aaa.aaa"];',
|
57 |
+
'[keyword echo] [string "aaa{\\$aaaa[[2]]aaa.aaa"];',
|
58 |
+
'[keyword echo] [string "aaa{\\aaaaa[[asd]]aaa.aaa"];',
|
59 |
+
'[keyword echo] [string "aaa\\${aaaa->aaa.aaa"];',
|
60 |
+
'[keyword echo] [string "aaa\\${aaaa[[2]]aaa.aaa"];',
|
61 |
+
'[keyword echo] [string "aaa\\${aaaa[[asd]]aaa.aaa"];',
|
62 |
+
'[meta ?>]');
|
63 |
+
|
64 |
+
MT('variable_interpolation_complex_syntax_1',
|
65 |
+
'[meta <?php]',
|
66 |
+
'[keyword echo] [string "aaa][variable-2 $]{[variable aaaa]}[string ->aaa.aaa"];',
|
67 |
+
'[keyword echo] [string "aaa][variable-2 $]{[variable-2 $aaaa]}[string ->aaa.aaa"];',
|
68 |
+
'[keyword echo] [string "aaa][variable-2 $]{[variable-2 $aaaa][[',' [number 42]',']]}[string ->aaa.aaa"];',
|
69 |
+
'[keyword echo] [string "aaa][variable-2 $]{[variable aaaa][meta ?>]aaaaaa');
|
70 |
+
|
71 |
+
MT('variable_interpolation_complex_syntax_2',
|
72 |
+
'[meta <?php] [comment /* Monsters */]',
|
73 |
+
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*}?>} $aaa<?php } */]}[string ->aaa.aaa"];',
|
74 |
+
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*}?>*/][[',' [string "aaa][variable-2 $aaa][string {}][variable-2 $]{[variable aaa]}[string "]',']]}[string ->aaa.aaa"];',
|
75 |
+
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*} } $aaa } */]}[string ->aaa.aaa"];');
|
76 |
+
|
77 |
+
|
78 |
+
function build_recursive_monsters(nt, t, n){
|
79 |
+
var monsters = [t];
|
80 |
+
for (var i = 1; i <= n; ++i)
|
81 |
+
monsters[i] = nt.join(monsters[i - 1]);
|
82 |
+
return monsters;
|
83 |
+
}
|
84 |
+
|
85 |
+
var m1 = build_recursive_monsters(
|
86 |
+
['[string "][variable-2 $]{[variable aaa] [operator +] ', '}[string "]'],
|
87 |
+
'[comment /* }?>} */] [string "aaa][variable-2 $aaa][string .aaa"]',
|
88 |
+
10
|
89 |
+
);
|
90 |
+
|
91 |
+
MT('variable_interpolation_complex_syntax_3_1',
|
92 |
+
'[meta <?php] [comment /* Recursive monsters */]',
|
93 |
+
'[keyword echo] ' + m1[4] + ';',
|
94 |
+
'[keyword echo] ' + m1[7] + ';',
|
95 |
+
'[keyword echo] ' + m1[8] + ';',
|
96 |
+
'[keyword echo] ' + m1[5] + ';',
|
97 |
+
'[keyword echo] ' + m1[1] + ';',
|
98 |
+
'[keyword echo] ' + m1[6] + ';',
|
99 |
+
'[keyword echo] ' + m1[9] + ';',
|
100 |
+
'[keyword echo] ' + m1[0] + ';',
|
101 |
+
'[keyword echo] ' + m1[10] + ';',
|
102 |
+
'[keyword echo] ' + m1[2] + ';',
|
103 |
+
'[keyword echo] ' + m1[3] + ';',
|
104 |
+
'[keyword echo] [string "end"];',
|
105 |
+
'[meta ?>]');
|
106 |
+
|
107 |
+
var m2 = build_recursive_monsters(
|
108 |
+
['[string "a][variable-2 $]{[variable aaa] [operator +] ', ' [operator +] ', '}[string .a"]'],
|
109 |
+
'[comment /* }?>{{ */] [string "a?>}{{aa][variable-2 $aaa][string .a}a?>a"]',
|
110 |
+
5
|
111 |
+
);
|
112 |
+
|
113 |
+
MT('variable_interpolation_complex_syntax_3_2',
|
114 |
+
'[meta <?php] [comment /* Recursive monsters 2 */]',
|
115 |
+
'[keyword echo] ' + m2[0] + ';',
|
116 |
+
'[keyword echo] ' + m2[1] + ';',
|
117 |
+
'[keyword echo] ' + m2[5] + ';',
|
118 |
+
'[keyword echo] ' + m2[4] + ';',
|
119 |
+
'[keyword echo] ' + m2[2] + ';',
|
120 |
+
'[keyword echo] ' + m2[3] + ';',
|
121 |
+
'[keyword echo] [string "end"];',
|
122 |
+
'[meta ?>]');
|
123 |
+
|
124 |
+
function build_recursive_monsters_2(mf1, mf2, nt, t, n){
|
125 |
+
var monsters = [t];
|
126 |
+
for (var i = 1; i <= n; ++i)
|
127 |
+
monsters[i] = nt[0] + mf1[i - 1] + nt[1] + mf2[i - 1] + nt[2] + monsters[i - 1] + nt[3];
|
128 |
+
return monsters;
|
129 |
+
}
|
130 |
+
|
131 |
+
var m3 = build_recursive_monsters_2(
|
132 |
+
m1,
|
133 |
+
m2,
|
134 |
+
['[string "a][variable-2 $]{[variable aaa] [operator +] ', ' [operator +] ', ' [operator +] ', '}[string .a"]'],
|
135 |
+
'[comment /* }?>{{ */] [string "a?>}{{aa][variable-2 $aaa][string .a}a?>a"]',
|
136 |
+
4
|
137 |
+
);
|
138 |
+
|
139 |
+
MT('variable_interpolation_complex_syntax_3_3',
|
140 |
+
'[meta <?php] [comment /* Recursive monsters 2 */]',
|
141 |
+
'[keyword echo] ' + m3[4] + ';',
|
142 |
+
'[keyword echo] ' + m3[0] + ';',
|
143 |
+
'[keyword echo] ' + m3[3] + ';',
|
144 |
+
'[keyword echo] ' + m3[1] + ';',
|
145 |
+
'[keyword echo] ' + m3[2] + ';',
|
146 |
+
'[keyword echo] [string "end"];',
|
147 |
+
'[meta ?>]');
|
148 |
+
|
149 |
+
MT("variable_interpolation_heredoc",
|
150 |
+
"[meta <?php]",
|
151 |
+
"[string <<<here]",
|
152 |
+
"[string doc ][variable-2 $]{[variable yay]}[string more]",
|
153 |
+
"[string here]; [comment // normal]");
|
154 |
+
})();
|
inc/lib/codemirror/mode/xml/index.html
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: XML mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<script src="../../lib/codemirror.js"></script>
|
9 |
+
<script src="xml.js"></script>
|
10 |
+
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
11 |
+
<div id=nav>
|
12 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
13 |
+
|
14 |
+
<ul>
|
15 |
+
<li><a href="../../index.html">Home</a>
|
16 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
17 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
18 |
+
</ul>
|
19 |
+
<ul>
|
20 |
+
<li><a href="../index.html">Language modes</a>
|
21 |
+
<li><a class=active href="#">XML</a>
|
22 |
+
</ul>
|
23 |
+
</div>
|
24 |
+
|
25 |
+
<article>
|
26 |
+
<h2>XML mode</h2>
|
27 |
+
<form><textarea id="code" name="code">
|
28 |
+
<html style="color: green">
|
29 |
+
<!-- this is a comment -->
|
30 |
+
<head>
|
31 |
+
<title>HTML Example</title>
|
32 |
+
</head>
|
33 |
+
<body>
|
34 |
+
The indentation tries to be <em>somewhat &quot;do what
|
35 |
+
I mean&quot;</em>... but might not match your style.
|
36 |
+
</body>
|
37 |
+
</html>
|
38 |
+
</textarea></form>
|
39 |
+
<script>
|
40 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
41 |
+
mode: "text/html",
|
42 |
+
lineNumbers: true
|
43 |
+
});
|
44 |
+
</script>
|
45 |
+
<p>The XML mode supports these configuration parameters:</p>
|
46 |
+
<dl>
|
47 |
+
<dt><code>htmlMode (boolean)</code></dt>
|
48 |
+
<dd>This switches the mode to parse HTML instead of XML. This
|
49 |
+
means attributes do not have to be quoted, and some elements
|
50 |
+
(such as <code>br</code>) do not require a closing tag.</dd>
|
51 |
+
<dt><code>matchClosing (boolean)</code></dt>
|
52 |
+
<dd>Controls whether the mode checks that close tags match the
|
53 |
+
corresponding opening tag, and highlights mismatches as errors.
|
54 |
+
Defaults to true.</dd>
|
55 |
+
<dt><code>alignCDATA (boolean)</code></dt>
|
56 |
+
<dd>Setting this to true will force the opening tag of CDATA
|
57 |
+
blocks to not be indented.</dd>
|
58 |
+
</dl>
|
59 |
+
|
60 |
+
<p><strong>MIME types defined:</strong> <code>application/xml</code>, <code>text/html</code>.</p>
|
61 |
+
</article>
|
inc/lib/codemirror/mode/xml/test.js
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "xml"), mname = "xml";
|
6 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), mname); }
|
7 |
+
|
8 |
+
MT("matching",
|
9 |
+
"[tag&bracket <][tag top][tag&bracket >]",
|
10 |
+
" text",
|
11 |
+
" [tag&bracket <][tag inner][tag&bracket />]",
|
12 |
+
"[tag&bracket </][tag top][tag&bracket >]");
|
13 |
+
|
14 |
+
MT("nonmatching",
|
15 |
+
"[tag&bracket <][tag top][tag&bracket >]",
|
16 |
+
" [tag&bracket <][tag inner][tag&bracket />]",
|
17 |
+
" [tag&bracket </][tag&error tip][tag&bracket&error >]");
|
18 |
+
|
19 |
+
MT("doctype",
|
20 |
+
"[meta <!doctype foobar>]",
|
21 |
+
"[tag&bracket <][tag top][tag&bracket />]");
|
22 |
+
|
23 |
+
MT("cdata",
|
24 |
+
"[tag&bracket <][tag top][tag&bracket >]",
|
25 |
+
" [atom <![CDATA[foo]",
|
26 |
+
"[atom barbazguh]]]]>]",
|
27 |
+
"[tag&bracket </][tag top][tag&bracket >]");
|
28 |
+
|
29 |
+
// HTML tests
|
30 |
+
mode = CodeMirror.getMode({indentUnit: 2}, "text/html");
|
31 |
+
|
32 |
+
MT("selfclose",
|
33 |
+
"[tag&bracket <][tag html][tag&bracket >]",
|
34 |
+
" [tag&bracket <][tag link] [attribute rel]=[string stylesheet] [attribute href]=[string \"/foobar\"][tag&bracket >]",
|
35 |
+
"[tag&bracket </][tag html][tag&bracket >]");
|
36 |
+
|
37 |
+
MT("list",
|
38 |
+
"[tag&bracket <][tag ol][tag&bracket >]",
|
39 |
+
" [tag&bracket <][tag li][tag&bracket >]one",
|
40 |
+
" [tag&bracket <][tag li][tag&bracket >]two",
|
41 |
+
"[tag&bracket </][tag ol][tag&bracket >]");
|
42 |
+
|
43 |
+
MT("valueless",
|
44 |
+
"[tag&bracket <][tag input] [attribute type]=[string checkbox] [attribute checked][tag&bracket />]");
|
45 |
+
|
46 |
+
MT("pThenArticle",
|
47 |
+
"[tag&bracket <][tag p][tag&bracket >]",
|
48 |
+
" foo",
|
49 |
+
"[tag&bracket <][tag article][tag&bracket >]bar");
|
50 |
+
|
51 |
+
})();
|
inc/lib/codemirror/mode/xml/xml.js
ADDED
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function(mod) {
|
5 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"));
|
7 |
+
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror"], mod);
|
9 |
+
else // Plain browser env
|
10 |
+
mod(CodeMirror);
|
11 |
+
})(function(CodeMirror) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var htmlConfig = {
|
15 |
+
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
16 |
+
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
17 |
+
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
18 |
+
'track': true, 'wbr': true, 'menuitem': true},
|
19 |
+
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
20 |
+
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
21 |
+
'th': true, 'tr': true},
|
22 |
+
contextGrabbers: {
|
23 |
+
'dd': {'dd': true, 'dt': true},
|
24 |
+
'dt': {'dd': true, 'dt': true},
|
25 |
+
'li': {'li': true},
|
26 |
+
'option': {'option': true, 'optgroup': true},
|
27 |
+
'optgroup': {'optgroup': true},
|
28 |
+
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
29 |
+
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
30 |
+
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
31 |
+
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
32 |
+
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
33 |
+
'rp': {'rp': true, 'rt': true},
|
34 |
+
'rt': {'rp': true, 'rt': true},
|
35 |
+
'tbody': {'tbody': true, 'tfoot': true},
|
36 |
+
'td': {'td': true, 'th': true},
|
37 |
+
'tfoot': {'tbody': true},
|
38 |
+
'th': {'td': true, 'th': true},
|
39 |
+
'thead': {'tbody': true, 'tfoot': true},
|
40 |
+
'tr': {'tr': true}
|
41 |
+
},
|
42 |
+
doNotIndent: {"pre": true},
|
43 |
+
allowUnquoted: true,
|
44 |
+
allowMissing: true,
|
45 |
+
caseFold: true
|
46 |
+
}
|
47 |
+
|
48 |
+
var xmlConfig = {
|
49 |
+
autoSelfClosers: {},
|
50 |
+
implicitlyClosed: {},
|
51 |
+
contextGrabbers: {},
|
52 |
+
doNotIndent: {},
|
53 |
+
allowUnquoted: false,
|
54 |
+
allowMissing: false,
|
55 |
+
allowMissingTagName: false,
|
56 |
+
caseFold: false
|
57 |
+
}
|
58 |
+
|
59 |
+
CodeMirror.defineMode("xml", function(editorConf, config_) {
|
60 |
+
var indentUnit = editorConf.indentUnit
|
61 |
+
var config = {}
|
62 |
+
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
|
63 |
+
for (var prop in defaults) config[prop] = defaults[prop]
|
64 |
+
for (var prop in config_) config[prop] = config_[prop]
|
65 |
+
|
66 |
+
// Return variables for tokenizers
|
67 |
+
var type, setStyle;
|
68 |
+
|
69 |
+
function inText(stream, state) {
|
70 |
+
function chain(parser) {
|
71 |
+
state.tokenize = parser;
|
72 |
+
return parser(stream, state);
|
73 |
+
}
|
74 |
+
|
75 |
+
var ch = stream.next();
|
76 |
+
if (ch == "<") {
|
77 |
+
if (stream.eat("!")) {
|
78 |
+
if (stream.eat("[")) {
|
79 |
+
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
80 |
+
else return null;
|
81 |
+
} else if (stream.match("--")) {
|
82 |
+
return chain(inBlock("comment", "-->"));
|
83 |
+
} else if (stream.match("DOCTYPE", true, true)) {
|
84 |
+
stream.eatWhile(/[\w\._\-]/);
|
85 |
+
return chain(doctype(1));
|
86 |
+
} else {
|
87 |
+
return null;
|
88 |
+
}
|
89 |
+
} else if (stream.eat("?")) {
|
90 |
+
stream.eatWhile(/[\w\._\-]/);
|
91 |
+
state.tokenize = inBlock("meta", "?>");
|
92 |
+
return "meta";
|
93 |
+
} else {
|
94 |
+
type = stream.eat("/") ? "closeTag" : "openTag";
|
95 |
+
state.tokenize = inTag;
|
96 |
+
return "tag bracket";
|
97 |
+
}
|
98 |
+
} else if (ch == "&") {
|
99 |
+
var ok;
|
100 |
+
if (stream.eat("#")) {
|
101 |
+
if (stream.eat("x")) {
|
102 |
+
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
103 |
+
} else {
|
104 |
+
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
105 |
+
}
|
106 |
+
} else {
|
107 |
+
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
108 |
+
}
|
109 |
+
return ok ? "atom" : "error";
|
110 |
+
} else {
|
111 |
+
stream.eatWhile(/[^&<]/);
|
112 |
+
return null;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
inText.isInText = true;
|
116 |
+
|
117 |
+
function inTag(stream, state) {
|
118 |
+
var ch = stream.next();
|
119 |
+
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
120 |
+
state.tokenize = inText;
|
121 |
+
type = ch == ">" ? "endTag" : "selfcloseTag";
|
122 |
+
return "tag bracket";
|
123 |
+
} else if (ch == "=") {
|
124 |
+
type = "equals";
|
125 |
+
return null;
|
126 |
+
} else if (ch == "<") {
|
127 |
+
state.tokenize = inText;
|
128 |
+
state.state = baseState;
|
129 |
+
state.tagName = state.tagStart = null;
|
130 |
+
var next = state.tokenize(stream, state);
|
131 |
+
return next ? next + " tag error" : "tag error";
|
132 |
+
} else if (/[\'\"]/.test(ch)) {
|
133 |
+
state.tokenize = inAttribute(ch);
|
134 |
+
state.stringStartCol = stream.column();
|
135 |
+
return state.tokenize(stream, state);
|
136 |
+
} else {
|
137 |
+
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
|
138 |
+
return "word";
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
function inAttribute(quote) {
|
143 |
+
var closure = function(stream, state) {
|
144 |
+
while (!stream.eol()) {
|
145 |
+
if (stream.next() == quote) {
|
146 |
+
state.tokenize = inTag;
|
147 |
+
break;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
return "string";
|
151 |
+
};
|
152 |
+
closure.isInAttribute = true;
|
153 |
+
return closure;
|
154 |
+
}
|
155 |
+
|
156 |
+
function inBlock(style, terminator) {
|
157 |
+
return function(stream, state) {
|
158 |
+
while (!stream.eol()) {
|
159 |
+
if (stream.match(terminator)) {
|
160 |
+
state.tokenize = inText;
|
161 |
+
break;
|
162 |
+
}
|
163 |
+
stream.next();
|
164 |
+
}
|
165 |
+
return style;
|
166 |
+
};
|
167 |
+
}
|
168 |
+
function doctype(depth) {
|
169 |
+
return function(stream, state) {
|
170 |
+
var ch;
|
171 |
+
while ((ch = stream.next()) != null) {
|
172 |
+
if (ch == "<") {
|
173 |
+
state.tokenize = doctype(depth + 1);
|
174 |
+
return state.tokenize(stream, state);
|
175 |
+
} else if (ch == ">") {
|
176 |
+
if (depth == 1) {
|
177 |
+
state.tokenize = inText;
|
178 |
+
break;
|
179 |
+
} else {
|
180 |
+
state.tokenize = doctype(depth - 1);
|
181 |
+
return state.tokenize(stream, state);
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
return "meta";
|
186 |
+
};
|
187 |
+
}
|
188 |
+
|
189 |
+
function Context(state, tagName, startOfLine) {
|
190 |
+
this.prev = state.context;
|
191 |
+
this.tagName = tagName;
|
192 |
+
this.indent = state.indented;
|
193 |
+
this.startOfLine = startOfLine;
|
194 |
+
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
195 |
+
this.noIndent = true;
|
196 |
+
}
|
197 |
+
function popContext(state) {
|
198 |
+
if (state.context) state.context = state.context.prev;
|
199 |
+
}
|
200 |
+
function maybePopContext(state, nextTagName) {
|
201 |
+
var parentTagName;
|
202 |
+
while (true) {
|
203 |
+
if (!state.context) {
|
204 |
+
return;
|
205 |
+
}
|
206 |
+
parentTagName = state.context.tagName;
|
207 |
+
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
|
208 |
+
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
209 |
+
return;
|
210 |
+
}
|
211 |
+
popContext(state);
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
function baseState(type, stream, state) {
|
216 |
+
if (type == "openTag") {
|
217 |
+
state.tagStart = stream.column();
|
218 |
+
return tagNameState;
|
219 |
+
} else if (type == "closeTag") {
|
220 |
+
return closeTagNameState;
|
221 |
+
} else {
|
222 |
+
return baseState;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
function tagNameState(type, stream, state) {
|
226 |
+
if (type == "word") {
|
227 |
+
state.tagName = stream.current();
|
228 |
+
setStyle = "tag";
|
229 |
+
return attrState;
|
230 |
+
} else if (config.allowMissingTagName && type == "endTag") {
|
231 |
+
setStyle = "tag bracket";
|
232 |
+
return attrState(type, stream, state);
|
233 |
+
} else {
|
234 |
+
setStyle = "error";
|
235 |
+
return tagNameState;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
function closeTagNameState(type, stream, state) {
|
239 |
+
if (type == "word") {
|
240 |
+
var tagName = stream.current();
|
241 |
+
if (state.context && state.context.tagName != tagName &&
|
242 |
+
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
243 |
+
popContext(state);
|
244 |
+
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
|
245 |
+
setStyle = "tag";
|
246 |
+
return closeState;
|
247 |
+
} else {
|
248 |
+
setStyle = "tag error";
|
249 |
+
return closeStateErr;
|
250 |
+
}
|
251 |
+
} else if (config.allowMissingTagName && type == "endTag") {
|
252 |
+
setStyle = "tag bracket";
|
253 |
+
return closeState(type, stream, state);
|
254 |
+
} else {
|
255 |
+
setStyle = "error";
|
256 |
+
return closeStateErr;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
function closeState(type, _stream, state) {
|
261 |
+
if (type != "endTag") {
|
262 |
+
setStyle = "error";
|
263 |
+
return closeState;
|
264 |
+
}
|
265 |
+
popContext(state);
|
266 |
+
return baseState;
|
267 |
+
}
|
268 |
+
function closeStateErr(type, stream, state) {
|
269 |
+
setStyle = "error";
|
270 |
+
return closeState(type, stream, state);
|
271 |
+
}
|
272 |
+
|
273 |
+
function attrState(type, _stream, state) {
|
274 |
+
if (type == "word") {
|
275 |
+
setStyle = "attribute";
|
276 |
+
return attrEqState;
|
277 |
+
} else if (type == "endTag" || type == "selfcloseTag") {
|
278 |
+
var tagName = state.tagName, tagStart = state.tagStart;
|
279 |
+
state.tagName = state.tagStart = null;
|
280 |
+
if (type == "selfcloseTag" ||
|
281 |
+
config.autoSelfClosers.hasOwnProperty(tagName)) {
|
282 |
+
maybePopContext(state, tagName);
|
283 |
+
} else {
|
284 |
+
maybePopContext(state, tagName);
|
285 |
+
state.context = new Context(state, tagName, tagStart == state.indented);
|
286 |
+
}
|
287 |
+
return baseState;
|
288 |
+
}
|
289 |
+
setStyle = "error";
|
290 |
+
return attrState;
|
291 |
+
}
|
292 |
+
function attrEqState(type, stream, state) {
|
293 |
+
if (type == "equals") return attrValueState;
|
294 |
+
if (!config.allowMissing) setStyle = "error";
|
295 |
+
return attrState(type, stream, state);
|
296 |
+
}
|
297 |
+
function attrValueState(type, stream, state) {
|
298 |
+
if (type == "string") return attrContinuedState;
|
299 |
+
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
|
300 |
+
setStyle = "error";
|
301 |
+
return attrState(type, stream, state);
|
302 |
+
}
|
303 |
+
function attrContinuedState(type, stream, state) {
|
304 |
+
if (type == "string") return attrContinuedState;
|
305 |
+
return attrState(type, stream, state);
|
306 |
+
}
|
307 |
+
|
308 |
+
return {
|
309 |
+
startState: function(baseIndent) {
|
310 |
+
var state = {tokenize: inText,
|
311 |
+
state: baseState,
|
312 |
+
indented: baseIndent || 0,
|
313 |
+
tagName: null, tagStart: null,
|
314 |
+
context: null}
|
315 |
+
if (baseIndent != null) state.baseIndent = baseIndent
|
316 |
+
return state
|
317 |
+
},
|
318 |
+
|
319 |
+
token: function(stream, state) {
|
320 |
+
if (!state.tagName && stream.sol())
|
321 |
+
state.indented = stream.indentation();
|
322 |
+
|
323 |
+
if (stream.eatSpace()) return null;
|
324 |
+
type = null;
|
325 |
+
var style = state.tokenize(stream, state);
|
326 |
+
if ((style || type) && style != "comment") {
|
327 |
+
setStyle = null;
|
328 |
+
state.state = state.state(type || style, stream, state);
|
329 |
+
if (setStyle)
|
330 |
+
style = setStyle == "error" ? style + " error" : setStyle;
|
331 |
+
}
|
332 |
+
return style;
|
333 |
+
},
|
334 |
+
|
335 |
+
indent: function(state, textAfter, fullLine) {
|
336 |
+
var context = state.context;
|
337 |
+
// Indent multi-line strings (e.g. css).
|
338 |
+
if (state.tokenize.isInAttribute) {
|
339 |
+
if (state.tagStart == state.indented)
|
340 |
+
return state.stringStartCol + 1;
|
341 |
+
else
|
342 |
+
return state.indented + indentUnit;
|
343 |
+
}
|
344 |
+
if (context && context.noIndent) return CodeMirror.Pass;
|
345 |
+
if (state.tokenize != inTag && state.tokenize != inText)
|
346 |
+
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
347 |
+
// Indent the starts of attribute names.
|
348 |
+
if (state.tagName) {
|
349 |
+
if (config.multilineTagIndentPastTag !== false)
|
350 |
+
return state.tagStart + state.tagName.length + 2;
|
351 |
+
else
|
352 |
+
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
|
353 |
+
}
|
354 |
+
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
355 |
+
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
356 |
+
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
357 |
+
while (context) {
|
358 |
+
if (context.tagName == tagAfter[2]) {
|
359 |
+
context = context.prev;
|
360 |
+
break;
|
361 |
+
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
362 |
+
context = context.prev;
|
363 |
+
} else {
|
364 |
+
break;
|
365 |
+
}
|
366 |
+
}
|
367 |
+
} else if (tagAfter) { // Opening tag spotted
|
368 |
+
while (context) {
|
369 |
+
var grabbers = config.contextGrabbers[context.tagName];
|
370 |
+
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
371 |
+
context = context.prev;
|
372 |
+
else
|
373 |
+
break;
|
374 |
+
}
|
375 |
+
}
|
376 |
+
while (context && context.prev && !context.startOfLine)
|
377 |
+
context = context.prev;
|
378 |
+
if (context) return context.indent + indentUnit;
|
379 |
+
else return state.baseIndent || 0;
|
380 |
+
},
|
381 |
+
|
382 |
+
electricInput: /<\/[\s\w:]+>$/,
|
383 |
+
blockCommentStart: "<!--",
|
384 |
+
blockCommentEnd: "-->",
|
385 |
+
|
386 |
+
configuration: config.htmlMode ? "html" : "xml",
|
387 |
+
helperType: config.htmlMode ? "html" : "xml",
|
388 |
+
|
389 |
+
skipAttribute: function(state) {
|
390 |
+
if (state.state == attrValueState)
|
391 |
+
state.state = attrState
|
392 |
+
}
|
393 |
+
};
|
394 |
+
});
|
395 |
+
|
396 |
+
CodeMirror.defineMIME("text/xml", "xml");
|
397 |
+
CodeMirror.defineMIME("application/xml", "xml");
|
398 |
+
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
399 |
+
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
400 |
+
|
401 |
+
});
|
inc/lib/codemirror/package.json
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "codemirror",
|
3 |
+
"version": "5.38.0",
|
4 |
+
"main": "lib/codemirror.js",
|
5 |
+
"style": "lib/codemirror.css",
|
6 |
+
"description": "Full-featured in-browser code editor",
|
7 |
+
"license": "MIT",
|
8 |
+
"directories": {
|
9 |
+
"lib": "./lib"
|
10 |
+
},
|
11 |
+
"scripts": {
|
12 |
+
"build": "rollup -c",
|
13 |
+
"watch": "rollup -w -c",
|
14 |
+
"prepare": "npm run-script build",
|
15 |
+
"test": "node ./test/run.js",
|
16 |
+
"lint": "bin/lint"
|
17 |
+
},
|
18 |
+
"devDependencies": {
|
19 |
+
"blint": "^1",
|
20 |
+
"node-static": "0.6.0",
|
21 |
+
"phantomjs-prebuilt": "^2.1.12",
|
22 |
+
"rollup": "^0.41.0",
|
23 |
+
"rollup-plugin-buble": "^0.15.0",
|
24 |
+
"rollup-watch": "^3.2.0"
|
25 |
+
},
|
26 |
+
"bugs": "http://github.com/codemirror/CodeMirror/issues",
|
27 |
+
"keywords": [
|
28 |
+
"JavaScript",
|
29 |
+
"CodeMirror",
|
30 |
+
"Editor"
|
31 |
+
],
|
32 |
+
"homepage": "http://codemirror.net",
|
33 |
+
"maintainers": [
|
34 |
+
{
|
35 |
+
"name": "Marijn Haverbeke",
|
36 |
+
"email": "marijnh@gmail.com",
|
37 |
+
"web": "http://marijnhaverbeke.nl"
|
38 |
+
}
|
39 |
+
],
|
40 |
+
"repository": {
|
41 |
+
"type": "git",
|
42 |
+
"url": "https://github.com/codemirror/CodeMirror.git"
|
43 |
+
},
|
44 |
+
"jspm": {
|
45 |
+
"directories": {},
|
46 |
+
"dependencies": {},
|
47 |
+
"devDependencies": {}
|
48 |
+
}
|
49 |
+
}
|
inc/php/enqueue.php
CHANGED
@@ -32,9 +32,16 @@ function spacexchimp_p001_load_scripts_admin( $hook ) {
|
|
32 |
wp_enqueue_style( $prefix . '-font-awesome-css', $url . 'inc/lib/font-awesome/css/font-awesome.css', array(), $version, 'screen' );
|
33 |
|
34 |
// CodeMirror library
|
35 |
-
wp_enqueue_style( $prefix . '-codemirror-css', $url . 'inc/lib/codemirror/codemirror.css', array(), $version, 'all' );
|
36 |
-
wp_enqueue_script( $prefix . '-codemirror-js', $url . 'inc/lib/codemirror/codemirror
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
// Other libraries
|
40 |
wp_enqueue_script( $prefix . '-bootstrap-checkbox-js', $url . 'inc/lib/bootstrap-checkbox.js', array(), $version, false );
|
32 |
wp_enqueue_style( $prefix . '-font-awesome-css', $url . 'inc/lib/font-awesome/css/font-awesome.css', array(), $version, 'screen' );
|
33 |
|
34 |
// CodeMirror library
|
35 |
+
wp_enqueue_style( $prefix . '-codemirror-css', $url . 'inc/lib/codemirror/lib/codemirror.css', array(), $version, 'all' );
|
36 |
+
wp_enqueue_script( $prefix . '-codemirror-js', $url . 'inc/lib/codemirror/lib/codemirror.js', array(), $version, false );
|
37 |
+
$modes = array( 'clike', 'css', 'htmlmixed', 'javascript', 'php', 'xml' );
|
38 |
+
foreach ( $modes as $mode ) {
|
39 |
+
wp_enqueue_script( $prefix . '-codemirror-mode-' . $mode . '-js', $url . 'inc/lib/codemirror/mode/' . $mode . '/' . $mode . '.js', array(), $version, true );
|
40 |
+
}
|
41 |
+
$addons = array( 'active-line' );
|
42 |
+
foreach ( $addons as $addon ) {
|
43 |
+
wp_enqueue_script( $prefix . '-codemirror-addon-' . $addon . '-js', $url . 'inc/lib/codemirror/addon/selection/' . $addon . '.js', array(), $version, false );
|
44 |
+
}
|
45 |
|
46 |
// Other libraries
|
47 |
wp_enqueue_script( $prefix . '-bootstrap-checkbox-js', $url . 'inc/lib/bootstrap-checkbox.js', array(), $version, false );
|
my-custom-functions.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Easily and safely add your custom functions (PHP code) directly out of your WordPress Admin Area, without the need to have an external editor.
|
6 |
* Author: Space X-Chimp
|
7 |
* Author URI: https://www.spacexchimp.com
|
8 |
-
* Version: 4.
|
9 |
* License: GPL3
|
10 |
* Text Domain: my-custom-functions
|
11 |
* Domain Path: /languages/
|
5 |
* Description: Easily and safely add your custom functions (PHP code) directly out of your WordPress Admin Area, without the need to have an external editor.
|
6 |
* Author: Space X-Chimp
|
7 |
* Author URI: https://www.spacexchimp.com
|
8 |
+
* Version: 4.19
|
9 |
* License: GPL3
|
10 |
* Text Domain: my-custom-functions
|
11 |
* Domain Path: /languages/
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: code, php, function, snippet, custom, execute, edit, editing, editor, func
|
|
4 |
Donate link: https://www.spacexchimp.com/donate.html
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 4.
|
8 |
License: GPL3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -210,9 +210,13 @@ Commercial licensing (e.g. for projects that can’t use an open-source license)
|
|
210 |
|
211 |
== Changelog ==
|
212 |
|
|
|
|
|
|
|
|
|
213 |
= 4.18 =
|
214 |
* Fixed a bug due to which the plugin data that stored in the database to not be deleted during the uninstallation of the plugin.
|
215 |
-
* The contents of the file 'uninstall.php is moved to the file 'core.php'. The file 'uninstall.php' is deleted.
|
216 |
* The upgrade banner has moved from an external source to the plugin folder.
|
217 |
* Some texts are corrected.
|
218 |
|
4 |
Donate link: https://www.spacexchimp.com/donate.html
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 4.19
|
8 |
License: GPL3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
210 |
|
211 |
== Changelog ==
|
212 |
|
213 |
+
= 4.19 =
|
214 |
+
* CodeMirror library updated to the latest version v5.38.0. The directory structure is changed (files are better organized). Added a test files for the CodeMirror modes.
|
215 |
+
* Updated the method of loading the modes and addons of the CodeMirror library.
|
216 |
+
|
217 |
= 4.18 =
|
218 |
* Fixed a bug due to which the plugin data that stored in the database to not be deleted during the uninstallation of the plugin.
|
219 |
+
* The contents of the file 'uninstall.php' is moved to the file 'core.php'. The file 'uninstall.php' is deleted.
|
220 |
* The upgrade banner has moved from an external source to the plugin folder.
|
221 |
* Some texts are corrected.
|
222 |
|