Codebase list codemirror-js / 1171f45
New upstream version 5.19.0 Gordon Ball 6 years ago
259 changed file(s) with 13316 addition(s) and 4492 deletion(s). Raw diff Collapse all Expand all
0 /node_modules
1 /demo
2 /doc
3 /test
4 /test*.html
5 /index.html
6 /mode/*/*test.js
7 /mode/*/*.html
8 /mode/index.html
9 .*
00 language: node_js
11 node_js:
2 - 0.10
2 - stable
3 sudo: false
1313 Ahmad M. Zawawi
1414 ahoward
1515 Akeksandr Motsjonov
16 Alasdair Smith
1617 Alberto González Palomo
1718 Alberto Pose
1819 Albert Xing
2425 alexey-k
2526 Alex Piggott
2627 Aliaksei Chapyzhenka
28 Allen Sarkisyan
2729 Amin Shali
30 Amin Ullah Khan
31 amshali@google.com
2832 Amsul
2933 amuntean
3034 Amy
3337 AndersMad
3438 Anders Nawroth
3539 Anderson Mesquita
40 Anders Wåglund
3641 Andrea G
3742 Andreas Reischuck
43 Andres Taylor
3844 Andre von Houck
3945 Andrey Fedorov
4046 Andrey Klyuchnikov
4147 Andrey Lushnikov
48 Andrey Shchekin
4249 Andy Joslin
4350 Andy Kimball
4451 Andy Li
4956 Ankit Ahuja
5057 Ansel Santosa
5158 Anthony Dugois
59 anthonygego
60 Anthony Gégo
5261 Anthony Grimes
5362 Anton Kovalyov
5463 AQNOUCH Mohammed
5564 areos
65 Arnab Bose
5666 as3boyan
5767 AtomicPages LLC
5868 Atul Bhouraskar
5969 Aurelian Oancea
70 Barret Rennie
71 Basarat Ali Syed
6072 Bastian Müller
73 belhaj
6174 Bem Jones-Bey
6275 benbro
6376 Beni Cherniavsky-Paskin
6477 Benjamin DeCoste
6578 Ben Keen
79 Ben Miller
80 Ben Mosher
6681 Bernhard Sirlinger
6782 Bert Chang
83 Bharad
6884 Billy Moon
6985 binny
7086 B Krishna Chaitanya
7995 Brian Grinstead
8096 Brian Sletten
8197 Bruce Mitchener
98 Caitlin Potter
8299 Calin Barbat
100 callodacity
101 Camilo Roca
102 Chad Jolly
83103 Chandra Sekhar Pydi
84104 Charles Skelton
85105 Cheah Chu Yeow
86106 Chris Coyier
107 Chris Ford
87108 Chris Granger
88109 Chris Houseknecht
89110 Chris Lohfink
90111 Chris Morgan
112 Chris Smith
91113 Christian Oyarzun
92114 Christian Petrov
93115 Christopher Brown
94116 Christopher Mitchell
95117 Christopher Pfohl
118 Chunliang Lyu
96119 ciaranj
97120 CodeAnimal
98121 coderaiser
122 Cole R Lawrence
99123 ComFreek
100124 Curtis Gagliardi
101125 dagsta
107131 Daniele Di Sarli
108132 Daniel Faust
109133 Daniel Huigens
134 Daniel Kesler
110135 Daniel KJ
111136 Daniel Neel
112137 Daniel Parnell
113138 Danny Yoo
114139 darealshinji
115140 Darius Roberts
141 Dave Brondsema
116142 Dave Myers
117143 David Barnett
144 David H. Bronke
118145 David Mignot
119146 David Pathakjee
120147 David Vázquez
148 David Whittington
121149 deebugger
122150 Deep Thought
151 Devin Abbott
123152 Devon Carew
124153 dignifiedquire
125154 Dimage Sapelkin
131160 Drew Bratcher
132161 Drew Hintz
133162 Drew Khoury
163 Drini Cami
134164 Dror BG
135165 duralog
136166 eborden
137167 edsharp
138168 ekhaled
169 Elisée
139170 Enam Mijbah Noor
140171 Eric Allam
172 Erik Welander
141173 eustas
142174 Fabien O'Carroll
143175 Fabio Zendhi Nagao
148180 Felipe Lalanne
149181 Felix Raab
150182 Filip Noetzel
183 Filip Stollár
151184 flack
152185 ForbesLindesay
153186 Forbes Lindesay
158191 Gabriel Horner
159192 Gabriel Nahmias
160193 galambalazs
194 Gary Sheng
161195 Gautam Mehta
196 Gavin Douglas
162197 gekkoe
198 geowarin
163199 Gerard Braad
164200 Gergely Hegykozi
165201 Giovanni Calò
202 Glebov Boris
166203 Glenn Jorde
167204 Glenn Ruehle
168205 Golevka
206 Google Inc.
169207 Gordon Smith
170208 Grant Skinner
171209 greengiant
172210 Gregory Koberger
211 Grzegorz Mazur
173212 Guillaume Massé
174213 Guillaume Massé
214 guraga
175215 Gustavo Rodrigues
176216 Hakan Tunc
177217 Hans Engel
178218 Hardest
219 Harshvardhan Gupta
179220 Hasan Karahan
180221 Hector Oswaldo Caballero
222 Hendrik Wallbaum
181223 Herculano Campos
182224 Hiroyuki Makino
183225 hitsthings
184226 Hocdoc
227 Hugues Malphettes
185228 Ian Beck
186229 Ian Dickinson
187230 Ian Wehrman
188231 Ian Wetherbee
189232 Ice White
190233 ICHIKAWA, Yuji
234 idleberg
191235 ilvalle
192236 Ingo Richter
193237 Irakli Gozalishvili
198242 Jakub Vrana
199243 Jakub Vrána
200244 James Campos
245 James Howard
201246 James Thorne
202247 Jamie Hill
203248 Jan Jongboom
204249 jankeromnes
205250 Jan Keromnes
206251 Jan Odvarko
252 Jan Schär
207253 Jan T. Sott
254 Jared Dean
208255 Jared Forsyth
256 Jared Jacobs
209257 Jason
210258 Jason Barnabe
211259 Jason Grout
214262 Jason Siefken
215263 Jaydeep Solanki
216264 Jean Boussier
265 Jeff Blaisdell
266 Jeff Jenkins
217267 jeffkenton
218268 Jeff Pickhardt
219269 jem (graphite)
220270 Jeremy Parmenter
271 Jim
272 JobJob
273 jochenberger
221274 Jochen Berger
275 Joel Einbinder
276 joelpinheiro
222277 Johan Ask
223278 John Connor
279 John Engler
224280 John Lees-Miller
225281 John Snelson
226282 John Van Der Loo
283 Jon Ander Peñalba
227284 Jonas Döbertin
228285 Jonathan Malmaud
229286 jongalloway
231288 Jon Sangster
232289 Joost-Wim Boekesteijn
233290 Joseph Pecoraro
291 Josh Cohen
292 Josh Soref
234293 Joshua Newman
235294 Josh Watzman
236295 jots
239298 Juan Benavides Romero
240299 Jucovschi Constantin
241300 Juho Vuori
301 Julien Rebetez
302 Justin Andresen
242303 Justin Hileman
243304 jwallers@gmail.com
244305 kaniga
306 karevn
307 Kayur Patel
245308 Ken Newman
309 ken restivo
246310 Ken Rockot
247311 Kevin Earls
248312 Kevin Sawicki
252316 komakino
253317 Konstantin Lopuhin
254318 koops
319 Kris Ciccarello
255320 ks-ifware
256321 kubelsmieci
257322 KwanEsq
269334 lochel
270335 Lorenzo Stoakes
271336 Luciano Longo
337 Lu Fangjian
338 Luke Granger-Brown
272339 Luke Stagner
273340 lynschinzer
341 M1cha
274342 Madhura Jayaratne
275343 Maksim Lin
276344 Maksym Taran
277345 Malay Majithia
346 Manideep
278347 Manuel Rego Casasnovas
279348 Marat Dreizin
280349 Marcel Gerber
285354 Marijn Haverbeke
286355 Mário Gonçalves
287356 Mario Pietsch
357 Mark Anderson
288358 Mark Lentczner
289359 Marko Bonaci
360 Markus Bordihn
290361 Martin Balek
291362 Martín Gaitán
292363 Martin Hasoň
293364 Martin Hunt
365 Martin Laine
366 Martin Zagora
294367 Mason Malone
295368 Mateusz Paprocki
296369 Mathias Bynens
297370 mats cronqvist
371 Matt Gaide
372 Matthew Bauer
298373 Matthew Beale
374 matthewhayes
299375 Matthew Rathbone
300376 Matthias Bussonnier
301377 Matthias BUSSONNIER
306382 Maximilian Hils
307383 Maxim Kraev
308384 Max Kirsch
385 Max Schaefer
309386 Max Xiantu
310387 mbarkhau
388 McBrainy
389 melpon
311390 Metatheos
312391 Micah Dubinko
392 Michael
393 Michael Goderbauer
313394 Michael Grey
314395 Michael Kaminsky
315396 Michael Lehenbauer
323404 Mike Diaz
324405 Mike Ivanov
325406 Mike Kadin
407 Mike Kobit
326408 MinRK
327409 Miraculix87
328410 misfo
411 mkaminsky11
329412 mloginov
330413 Moritz Schwörer
331414 mps
343426 Nicholas Bollweg (Nick)
344427 Nick Kreeger
345428 Nick Small
429 Nicolò Ribaudo
346430 Niels van Groningen
347431 nightwing
348432 Nikita Beloglazov
353437 nlwillia
354438 noragrossman
355439 Norman Rzepka
440 Oreoluwa Onatemowo
356441 pablo
442 pabloferz
357443 Page
358444 Panupong Pasupat
359445 paris
363449 Patrick Strawderman
364450 Paul Garvin
365451 Paul Ivanov
452 Paul Masson
453 Pavel
366454 Pavel Feldman
455 Pavel Petržela
367456 Pavel Strashkin
368457 Paweł Bartkiewicz
369458 peteguhl
459 peter
370460 Peter Flynn
371461 peterkroon
372462 Peter Kroon
463 Philipp A
464 Philip Stadermann
465 Pierre Gerold
466 Piët Delport
467 Pontus Melke
373468 prasanthj
374469 Prasanth J
470 Prayag Verma
375471 Radek Piórkowski
376472 Rahul
473 Rahul Anand
474 ramwin1
377475 Randall Mason
378476 Randy Burden
379477 Randy Edmunds
380478 Rasmus Erik Voel Jensen
381479 ray ratchup
382480 Ray Ratchup
481 Remi Nyborg
482 Richard Denton
383483 Richard van der Meer
384484 Richard Z.H. Wang
385485 Robert Crossfield
386486 Roberto Abdelkader Martínez Pérez
387487 robertop23
388488 Robert Plummer
489 Rrandom
389490 Ruslan Osmanov
390491 Ryan Prior
391492 sabaca
493 Sam Lee
392494 Samuel Ainsworth
495 Sam Wilson
393496 sandeepshetty
394497 Sander AKA Redsandro
395498 santec
397500 satamas
398501 satchmorun
399502 sathyamoorthi
503 S. Chris Colbert
400504 SCLINIC\jdecker
401505 Scott Aikin
402506 Scott Goodhew
403507 Sebastian Zaha
508 Sergey Goder
509 Sergey Tselovalnikov
510 Se-Won Kim
404511 shaund
405512 shaun gilchrist
406513 Shawn A
514 Shea Bunge
407515 sheopory
408516 Shiv Deepak
409517 Shmuel Englard
410518 Shubham Jain
519 Siamak Mokhtari
411520 silverwind
521 sinkuu
412522 snasa
413523 soliton4
414524 sonson
418528 Stas Kobzar
419529 Stefan Borsje
420530 Steffen Beyer
531 Steffen Bruchmann
532 Stephen Lavelle
533 Steve Champagne
421534 Steve O'Hara
422535 stoskov
536 Stu Kennedy
537 Sungho Kim
538 sverweij
423539 Taha Jahangir
540 Tako Schotanus
424541 Takuji Shimokawa
425542 Tarmil
543 TDaglis
426544 tel
427545 tfjgeorge
428546 Thaddee Tyl
547 thanasis
429548 TheHowl
430549 think
431550 Thomas Dvornik
551 Thomas Kluyver
432552 Thomas Schmid
433553 Tim Alby
434554 Tim Baumann
435555 Timothy Farrell
556 Timothy Gu
436557 Timothy Hatcher
437558 TobiasBg
438559 Tomas-A
442563 Tony Jian
443564 Travis Heppe
444565 Triangle717
566 Tristan Tarrant
567 TSUYUSATO Kitsune
445568 twifkak
569 VapidWorx
446570 Vestimir Markov
447571 vf
572 Victor Bocharsky
448573 Vincent Woo
449574 Volker Mische
575 Weiyan Shao
450576 wenli
577 Wes Cossick
451578 Wesley Wiser
452579 Will Binns-Smith
580 Will Dean
453581 William Jamieson
454582 William Stein
455583 Willy
456584 Wojtek Ptak
585 Wu Cheng-Han
457586 Xavier Mendez
458587 Yassin N. Hassan
459588 YNH Webdev
460589 Yunchi Luo
461590 Yuvi Panda
591 Zac Anger
462592 Zachary Dremann
463593 Zhang Hao
464594 zziuni
0 ## 5.19.0 (2016-09-20)
1
2 ### Bugfixes
3
4 [erlang mode](http://codemirror.net/mode/erlang): Fix mode crash when trying to read an empty context.
5
6 [comment addon](http://codemirror.net/doc/manual.html#addon_comment): Fix broken behavior when toggling comments inside a comment.
7
8 xml-fold addon: Fix a null-dereference bug.
9
10 Page up and page down now do something even in single-line documents.
11
12 Fix an issue where the cursor position could be off in really long (~8000 character) tokens.
13
14 ### New features
15
16 [javascript mode](http://codemirror.net/mode/javascript): Better indentation when semicolons are missing. Better support for TypeScript classes, optional parameters, and the `type` keyword.
17
18 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.
19
20 ## 5.18.2 (2016-08-23)
21
22 ### Bugfixes
23
24 [vue mode](http://codemirror.net/mode/vue): Fix outdated references to renamed Pug mode dependency.
25
26 ## 5.18.0 (2016-08-22)
27
28 ### Bugfixes
29
30 Make sure [gutter backgrounds](http://codemirror.net/doc/manual.html#addLineClass) stick to the rest of the gutter during horizontal scrolling.
31
32 The contenteditable [`inputStyle`](http://codemirror.net/doc/manual.html#option_inputStyle) now properly supports pasting on pre-Edge IE versions.
33
34 [javascript mode](http://codemirror.net/mode/javascript): Fix some small parsing bugs and improve TypeScript support.
35
36 [matchbrackets addon](http://codemirror.net/doc/manual.html#addon_matchbrackets): Fix bug where active highlighting was left in editor when the addon was disabled.
37
38 [match-highlighter addon](http://codemirror.net/doc/manual.html#addon_match-highlighter): Only start highlighting things when the editor gains focus.
39
40 [javascript-hint addon](http://codemirror.net/doc/manual.html#addon_javascript-hint): Also complete non-enumerable properties.
41
42 ### New features
43
44 The [`addOverlay`](http://codemirror.net/doc/manual.html#addOverlay) method now supports a `priority` option to control the order in which overlays are applied.
45
46 MIME types that end in `+json` now default to the JSON mode when the MIME itself is not defined.
47
48 ### Breaking changes
49
50 The mode formerly known as Jade was renamed to [Pug](http://codemirror.net/mode/pug).
51
52 The [Python mode](http://codemirror.net/mode/python) now defaults to Python 3 (rather than 2) syntax.
53
54 ## 5.17.0 (2016-07-19)
55
56 ### Bugfixes
57
58 Fix problem with wrapped trailing whitespace displaying incorrectly.
59
60 Prevent IME dialog from overlapping typed content in Chrome.
61
62 Improve measuring of characters near a line wrap.
63
64 [javascript mode](http://codemirror.net/mode/javascript): Improve support for `async`, allow trailing commas in `import` lists.
65
66 [vim bindings](http://codemirror.net/demo/vim.html): Fix backspace in replace mode.
67
68 [sublime bindings](http://codemirror.net/demo/sublime.html): Fix some key bindings on OS X to match Sublime Text.
69
70 ### New features
71
72 [markdown mode](http://codemirror.net/mode/markdown): Add more classes to image links in highlight-formatting mode.
73
74 ## 5.16.0 (2016-06-20)
75
76 ### Bugfixes
77
78 Fix glitches when dragging content caused by the drop indicator receiving mouse events.
79
80 Make Control-drag work on Firefox.
81
82 Make clicking or selection-dragging at the end of a wrapped line select the right position.
83
84 [show-hint addon](http://codemirror.net/doc/manual.html#addon_show-hint): Prevent widget scrollbar from hiding part of the hint text.
85
86 [rulers addon](http://codemirror.net/doc/manual.html#addon_rulers): Prevent rulers from forcing a horizontal editor scrollbar.
87
88 ### New features
89
90 [search addon](http://codemirror.net/doc/manual.html#addon_search): Automatically bind search-related keys in persistent dialog.
91
92 [sublime keymap](http://codemirror.net/demo/sublime.html): Add a multi-cursor aware smart backspace binding.
93
94 ## 5.15.2 (2016-05-20)
95
96 ### Bugfixes
97
98 Fix a critical document corruption bug that occurs when a document is gradually grown.
99
100 ## 5.15.0 (2016-05-20)
101
102 ### Bugfixes
103
104 Fix bug that caused the selection to reset when focusing the editor in contentEditable input mode.
105
106 Fix issue where not all ASCII control characters were being replaced by placeholders.
107
108 Remove the assumption that all modes have a `startState` method from several wrapping modes.
109
110 Fix issue where the editor would complain about overlapping collapsed ranges when there weren't any.
111
112 Optimize document tree building when loading or pasting huge chunks of content.
113
114 [markdown mode](http://codemirror.net/mode/markdown/): Fix several issues in matching link targets.
115
116 [clike mode](http://codemirror.net/mode/clike/): Improve indentation of C++ template declarations.
117
118 ### New features
119
120 Explicitly bind Ctrl-O on OS X to make that binding (“open line”) act as expected.
121
122 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.
123
124 [javascript mode](http://codemirror.net/mode/javascript/): Support `async`/`await` and improve support for TypeScript type syntax.
125
126 ## 5.14.2 (2016-04-20)
127
128 ### Bugfixes
129
130 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.
131
132 Set `dataTransfer.effectAllowed` in `dragstart` handler to help browsers use the right drag icon.
133
134 Add the [mbox mode](http://codemirror.net/mode/mbox/index.html) to `mode/meta.js`.
135
136 ## 5.14.0 (2016-04-20)
137
138 ### Bugfixes
139
140 [`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.
141
142 [vim bindings](http://codemirror.net/demo/vim.html): Only call `.save()` when it is actually available.
143
144 [comment addon](http://codemirror.net/doc/manual.html#addon_comment): Be careful not to mangle multi-line strings.
145
146 [Python mode](http://codemirror.net/mode/python/index.html): Improve distinguishing of decorators from `@` operators.
147
148 [`findMarks`](http://codemirror.net/doc/manual.html#findMarks): No longer return marks that touch but don't overlap given range.
149
150 ### New features
151
152 [vim bindings](http://codemirror.net/demo/vim.html): Add yank command.
153
154 [match-highlighter addon](http://codemirror.net/doc/manual.html#addon_match-highlighter): Add `trim` option to disable ignoring of whitespace.
155
156 [PowerShell mode](http://codemirror.net/mode/powershell/index.html): Added.
157
158 [Yacas mode](http://codemirror.net/mode/yacas/index.html): Added.
159
160 [Web IDL mode](http://codemirror.net/mode/webidl/index.html): Added.
161
162 [SAS mode](http://codemirror.net/mode/sas/index.html): Added.
163
164 [mbox mode](http://codemirror.net/mode/mbox/index.html): Added.
165
166 ## 5.13.2 (2016-03-23)
167
168 ### Bugfixes
169
170 Solves a problem where the gutter would sometimes not extend all the way to the end of the document.
171
172 ## 5.13.0 (2016-03-21)
173
174 ### New features
175
176 New DOM event forwarded: [`"dragleave"`](http://codemirror.net/doc/manual.html#event_dom).
177
178 [protobuf mode](http://codemirror.net/mode/protobuf/index.html): Newly added.
179
180 ### Bugfixes
181
182 Fix problem where [`findMarks`](http://codemirror.net/doc/manual.html#findMarks) sometimes failed to find multi-line marks.
183
184 Fix crash that showed up when atomic ranges and bidi text were combined.
185
186 [show-hint addon](http://codemirror.net/demo/complete.html): Completion widgets no longer close when the line indented or dedented.
187
188 [merge addon](http://codemirror.net/demo/merge.html): Fix bug when merging chunks at the end of the file.
189
190 [placeholder addon](http://codemirror.net/doc/manual.html#addon_placeholder): No longer gets confused by [`swapDoc`](http://codemirror.net/doc/manual.html#swapDoc).
191
192 [simplescrollbars addon](http://codemirror.net/doc/manual.html#addon_simplescrollbars): Fix invalid state when deleting at end of document.
193
194 [clike mode](http://codemirror.net/mode/clike/index.html): No longer gets confused when a comment starts after an operator.
195
196 [markdown mode](http://codemirror.net/mode/markdown/index.html): Now supports CommonMark-style flexible list indentation.
197
198 [dylan mode](http://codemirror.net/mode/dylan/index.html): Several improvements and fixes.
199
200 ## 5.12.0 (2016-02-19)
201
202 ### New features
203
204 [Vim bindings](http://codemirror.net/demo/vim.html): Ctrl-Q is now an alias for Ctrl-V.
205
206 [Vim bindings](http://codemirror.net/demo/vim.html): The Vim API now exposes an `unmap` method to unmap bindings.
207
208 [active-line addon](http://codemirror.net/demo/activeline.html): This addon can now style the active line's gutter.
209
210 [FCL mode](http://codemirror.net/mode/fcl/): Newly added.
211
212 [SQL mode](http://codemirror.net/mode/sql/): Now has a Postgresql dialect.
213
214 ### Bugfixes
215
216 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.
217
218 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.
219
220 Solve a [problem](https://github.com/codemirror/CodeMirror/issues/3821) where the horizontal scrollbar could hide text in Firefox.
221
222 Fix a [bug](https://github.com/codemirror/CodeMirror/issues/3834) that caused phantom scroll space under the text in some situations.
223
224 [Sublime Text bindings](http://codemirror.net/demo/sublime.html): Bind delete-line to Shift-Ctrl-K on OS X.
225
226 [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.
227
228 [Markdown mode](http://codemirror.net/mode/markdown/): Ignore backslashes in code fragments.
229
230 [Markdown mode](http://codemirror.net/mode/markdown/): Use whichever mode is registered as `text/html` to parse HTML.
231
232 [Clike mode](http://codemirror.net/mode/clike/): Improve indentation of Scala `=>` functions.
233
234 [Python mode](http://codemirror.net/mode/python/): Improve indentation of bracketed code.
235
236 [HTMLMixed mode](http://codemirror.net/mode/htmlmixed/): Support multi-line opening tags for sub-languages (`<script>`, `<style>`, etc).
237
238 [Spreadsheet mode](http://codemirror.net/mode/spreadsheet/): Fix bug where the mode did not advance the stream when finding a backslash.
239
240 [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.
241
242 ## 5.11.0 (2016-01-20)
243
244 * New modes: [JSX](http://codemirror.net/mode/jsx/index.html), [literate Haskell](http://codemirror.net/mode/haskell-literate/index.html)
245 * 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
246 * Fixes a bug where bookmarks next to collapsed spans were not rendered
247 * The [Swift](http://codemirror.net/mode/swift/index.html) mode now supports auto-indentation
248 * Frontmatters in the [YAML frontmatter](http://codemirror.net/mode/yaml-frontmatter/index.html) mode are now optional as intended
249
250 ## 5.10.0 (2015-12-21)
251
252 * Modify the way [atomic ranges](http://codemirror.net/doc/manual.html#mark_atomic) are skipped by selection to try and make it less surprising.
253 * The [Swift mode](http://codemirror.net/mode/swift/index.html) was rewritten.
254 * New addon: [jump-to-line](http://codemirror.net/doc/manual.html#addon_jump-to-line).
255 * New method: [`isReadOnly`](http://codemirror.net/doc/manual.html#isReadOnly).
256 * The [show-hint addon](http://codemirror.net/doc/manual.html#addon_show-hint) now defaults to picking completions on single click.
257 * The object passed to [`"beforeSelectionChange"`](http://codemirror.net/doc/manual.html#event_beforeSelectionChange) events now has an `origin` property.
258 * New mode: [Crystal](http://codemirror.net/mode/crystal/index.html).
259
260 ## 5.9.0 (2015-11-23)
261
262 * Improve the way overlay (OS X-style) scrollbars are handled
263 * Make [annotatescrollbar](http://codemirror.net/doc/manual.html#addon_annotatescrollbar) and scrollpastend addons work properly together
264 * 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
265 * Properly fold comments that include block-comment-start markers
266 * Many small language mode fixes
267
268 ## 5.8.0 (2015-10-20)
269
270 * Fixes an infinite loop in the [hardwrap addon](http://codemirror.net/doc/manual.html#addon_hardwrap)
271 * New modes: [NSIS](http://codemirror.net/mode/nsis/index.html), [Ceylon](http://codemirror.net/mode/clike/index.html)
272 * The Kotlin mode is now a [clike](http://codemirror.net/mode/clike/index.html) dialect, rather than a stand-alone mode
273 * New option: [`allowDropFileTypes`](http://codemirror.net/doc/manual.html#option_allowDropFileTypes). Binary files can no longer be dropped into CodeMirror
274 * 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)
275
276 ## 5.7.0 (2015-09-21)
277
278 * 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)
279 * Implement [CommonMark](http://commonmark.org)-style flexible list indent and cross-line code spans in [Markdown](http://codemirror.net/mode/markdown/index.html) mode
280 * 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
281 * Handle `acync`/`await` and ocal and binary numbers in [JavaScript mode](http://codemirror.net/mode/javascript/index.html)
282 * Fix various issues with the [Haxe mode](http://codemirror.net/mode/haxe/index.html)
283 * Make the [closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets) select only the wrapped text when wrapping selection in brackets
284 * Tokenize properties as properties in the [CoffeeScript mode](http://codemirror.net/mode/coffeescript/index.html)
285 * The [placeholder addon](http://codemirror.net/doc/manual.html#addon_placeholder) now accepts a DOM node as well as a string placeholder
286
287 ## 5.6.0 (2015-08-20)
288
289 * Fix bug where you could paste into a `readOnly` editor
290 * Show a cursor at the drop location when dragging over the editor
291 * The [Rust mode](http://codemirror.net/mode/rust/index.html) was rewritten to handle modern Rust
292 * The editor and theme CSS was cleaned up. Some selectors are now less specific than before
293 * New theme: [abcdef](http://codemirror.net/demo/theme.html#abcdef)
294 * Lines longer than [`maxHighlightLength`](http://codemirror.net/doc/manual.html#option_maxHighlightLength) are now less likely to mess up indentation
295 * 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/)
296 * The [`search`](http://codemirror.net/doc/manual.html#addon_search) addon now recognizes `\r` and `\n` in pattern and replacement input
297
298 ## 5.5.0 (2015-07-20)
299
300 * New option: [`lineSeparator`](http://codemirror.net/doc/manual.html#option_lineSeparator) (with corresponding [method](http://codemirror.net/doc/manual.html#lineSeparator))
301 * 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)
302 * 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)
303 * 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
304 * From this release on, the NPM module doesn't include documentation and demos
305 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.4.0...5.5.0)
306
307 ## 5.4.0 (2015-06-25)
308
309 * 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)
310 * Prefer clipboard API (if available) when pasting
311 * Refined definition highlighting in [clike](http://codemirror.net/mode/clike/index.html) mode
312 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.3.0...5.4.0)
313
314 ## 5.3.0 (2015-05-20)
315
316 * Fix several regressions in the [`show-hint`](http://codemirror.net/doc/manual.html#addon_show-hint) addon (`completeSingle` option, `"shown"` and `"close"` events)
317 * The [vim mode](http://codemirror.net/demo/vim.html) API was [documented](http://codemirror.net/doc/manual.html#vimapi)
318 * 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)
319 * The [clike](http://codemirror.net/mode/clike/index.html) mode can now deep-indent `switch` statements, and roughly recognizes types and defined identifiers
320 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.2.0...5.3.0)
321
322 ## 5.2.0 (2015-04-20)
323
324 * Fix several race conditions in [`show-hint`](http://codemirror.net/doc/manual.html#addon_show-hint)'s asynchronous mode
325 * Fix backspace binding in [Sublime bindings](http://codemirror.net/demo/sublime.html)
326 * Change the way IME is handled in the `"textarea"` [input style](http://codemirror.net/doc/manual.html#option_inputStyle)
327 * New modes: [MUMPS](http://codemirror.net/mode/mumps/index.html), [Handlebars](http://codemirror.net/mode/handlebars/index.html)
328 * Rewritten modes: [Django](http://codemirror.net/mode/django/index.html), [Z80](http://codemirror.net/mode/z80/index.html)
329 * New theme: [Liquibyte](http://codemirror.net/demo/theme.html#liquibyte)
330 * New option: [`lineWiseCopyCut`](http://codemirror.net/doc/manual.html#option_lineWiseCopyCut)
331 * The [Vim mode](http://codemirror.net/demo/vim.html) now supports buffer-local options and the `filetype` setting
332 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.1.0...5.2.0)
333
334 ## 5.1.0 (2015-03-23)
335
336 * 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).
337 * Remove SmartyMixed mode, rewrite [Smarty](http://codemirror.net/mode/smarty/index.html) mode to supersede it.
338 * New commands in the [merge addon](http://codemirror.net/doc/manual.html#addon_merge): `goNextDiff` and `goPrevDiff`.
339 * The [closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets) can now be configured per mode.
340 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/5.0.0...5.1.0).
341
342 ## 5.0.0 (2015-02-20)
343
344 * Experimental mobile support (tested on iOS, Android Chrome, stock Android browser)
345 * New option [`inputStyle`](http://codemirror.net/doc/manual.html#option_inputStyle) to switch between hidden textarea and contenteditable input.
346 * The [`getInputField`](http://codemirror.net/doc/manual.html#getInputField) method is no longer guaranteed to return a textarea.
347 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.13.0...5.0.0).
348
349 ## 4.13.0 (2015-02-20)
350
351 * Fix the way the [`closetag`](http://codemirror.net/demo/closetag.html) demo handles the slash character.
352 * New modes: [Forth](http://codemirror.net/mode/forth/index.html), [Stylus](http://codemirror.net/mode/stylus/index.html).
353 * Make the [CSS mode](http://codemirror.net/mode/css/index.html) understand some modern CSS extensions.
354 * Have the [Scala mode](http://codemirror.net/mode/clike/index.html) handle symbols and triple-quoted strings.
355 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.12.0...4.13.0).
356
357 ## 4.12.0 (2015-01-22)
358
359 * The [`closetag`](http://codemirror.net/doc/manual.html#addon_closetag) addon now defines a `"closeTag"` command.
360 * Adds a `findModeByFileName` to the [mode metadata](http://codemirror.net/doc/manual.html#addon_meta) addon.
361 * [Simple mode](http://codemirror.net/demo/simplemode.html) rules can now contain a `sol` property to only match at the start of a line.
362 * New addon: [`selection-pointer`](http://codemirror.net/doc/manual.html#addon_selection-pointer) to style the mouse cursor over the selection.
363 * Improvements to the [Sass mode](http://codemirror.net/mode/sass/index.html)'s indentation.
364 * The [Vim keymap](http://codemirror.net/demo/vim.html)'s search functionality now supports [scrollbar annotation](http://codemirror.net/doc/manual.html#addon_matchesonscrollbar).
365 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.11.0...4.12.0).
366
367 ## 4.11.0 (2015-01-09)
368
369 Unfortunately, 4.10 did not take care of the Firefox scrolling issue entirely. This release adds two more patches to address that.
370
371 ## 4.10.0 (2014-12-29)
372
373 Emergency single-patch update to 4.9\. Fixes Firefox-specific problem where the cursor could end up behind the horizontal scrollbar.
374
375 ## 4.9.0 (2014-12-23)
376
377 * Overhauled scroll bar handling. Add pluggable [scrollbar implementations](http://codemirror.net/demo/simplescrollbars.html).
378 * Tweaked behavior for the [completion addons](http://codemirror.net/doc/manual.html#addon_show-hint) to not take text after cursor into account.
379 * Two new optional features in the [merge addon](http://codemirror.net/doc/manual.html#addon_merge): aligning editors, and folding unchanged text.
380 * 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).
381 * New [addon](http://codemirror.net/demo/panel.html) to show persistent panels below/above an editor.
382 * New themes: [zenburn](http://codemirror.net/demo/theme.html#zenburn) and [tomorrow night bright](http://codemirror.net/demo/theme.html#tomorrow-night-bright).
383 * Allow ctrl-click to clear existing cursors.
384 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.8.0...4.9.0).
385
386 ## 4.8.0 (2014-11-22)
387
388 * Built-in support for [multi-stroke key bindings](http://codemirror.net/doc/manual.html#normalizeKeyMap).
389 * New method: [`getLineTokens`](http://codemirror.net/doc/manual.html#getLineTokens).
390 * 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).
391 * Support styling of gutter backgrounds, allow `"gutter"` styles in [`addLineClass`](http://codemirror.net/doc/manual.html#addLineClass).
392 * Many improvements to the [Vim mode](http://codemirror.net/demo/vim.html), rewritten visual mode.
393 * 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).
394 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.7.0...4.8.0).
395
396 ## 4.7.0 (2014-10-20)
397
398 * **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.
399 * Improved handling of unicode identifiers in modes for languages that support them.
400 * 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).
401 * New modes: [Textile](http://codemirror.net/mode/textile/index.html) and [Tornado templates](http://codemirror.net/mode/tornado/index.html).
402 * Experimental new [way to define modes](http://codemirror.net/demo/simplemode.html).
403 * 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.
404 * 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`.
405 * New logo!
406 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.6.0...4.7.0).
407
408 ## 4.6.0 (2014-09-19)
409
410 * New mode: [Modelica](http://codemirror.net/mode/modelica/index.html)
411 * New method: [`findWordAt`](http://codemirror.net/doc/manual.html#findWordAt)
412 * Make it easier to [use text background styling](http://codemirror.net/demo/markselection.html)
413 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.5.0...4.6.0).
414
415 ## 4.5.0 (2014-08-21)
416
417 * Fix several serious bugs with horizontal scrolling
418 * New mode: [Slim](http://codemirror.net/mode/slim/index.html)
419 * New command: [`goLineLeftSmart`](http://codemirror.net/doc/manual.html#command_goLineLeftSmart)
420 * More fixes and extensions for the [Vim](http://codemirror.net/demo/vim.html) visual block mode
421 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.4.0...4.5.0).
422
423 ## 4.4.0 (2014-07-21)
424
425 * **Note:** Some events might now fire in slightly different order (`"change"` is still guaranteed to fire before `"cursorActivity"`)
426 * Nested operations in multiple editors are now synced (complete at same time, reducing DOM reflows)
427 * Visual block mode for [vim](http://codemirror.net/demo/vim.html) (<C-v>) is nearly complete
428 * New mode: [Kotlin](http://codemirror.net/mode/kotlin/index.html)
429 * Better multi-selection paste for text copied from multiple CodeMirror selections
430 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.3.0...4.4.0).
431
432 ## 4.3.0 (2014-06-23)
433
434 * Several [vim bindings](http://codemirror.net/demo/vim.html) improvements: search and exCommand history, global flag for `:substitute`, `:global` command.
435 * Allow hiding the cursor by setting [`cursorBlinkRate`](http://codemirror.net/doc/manual.html#option_cursorBlinkRate) to a negative value.
436 * Make gutter markers themeable, use this in foldgutter.
437 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.2.0...4.3.0).
438
439 ## 4.2.0 (2014-05-19)
440
441 * Fix problem where some modes were broken by the fact that empty tokens were forbidden.
442 * Several fixes to context menu handling.
443 * On undo, scroll _change_, not cursor, into view.
444 * Rewritten [Jade](http://codemirror.net/mode/jade/index.html) mode.
445 * 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.
446 * New mode: [Cypher](http://codemirror.net/mode/cypher/index.html).
447 * New theme: [Neo](http://codemirror.net/demo/theme.html#neo).
448 * Support direct styling options (color, line style, width) in the [rulers](http://codemirror.net/doc/manual.html#addon_rulers) addon.
449 * 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.
450 * More intelligent scanning for existing close tags in [closetag](http://codemirror.net/doc/manual.html#addon_closetag) addon.
451 * In the [Vim bindings](http://codemirror.net/demo/vim.html): Fix bracket matching, support case conversion in visual mode, visual paste, append action.
452 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.1.0...4.2.0).
453
454 ## 4.1.0 (2014-04-22)
455
456 * _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).
457 * New command: [`insertSoftTab`](http://codemirror.net/doc/manual.html#command_insertSoftTab).
458 * New mode: [Django](http://codemirror.net/mode/django/index.html).
459 * 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).
460 * Many small issues from the 3.x→4.x transition were found and fixed.
461 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/4.0.3...4.1.0).
462
463 ## 3.24.0 (2014-04-22)
464
465 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.
466
467 ## 3.23.0 (2014-03-20)
468
469 * In the [XML mode](http://codemirror.net/mode/xml/index.html), add `brackets` style to angle brackets, fix case-sensitivity of tags for HTML.
470 * New mode: [Dylan](http://codemirror.net/mode/dylan/index.html).
471 * Many improvements to the [Vim bindings](http://codemirror.net/demo/vim.html).
472
473 ## 3.22.0 (2014-02-21)
474
475 * Adds the [`findMarks`](http://codemirror.net/doc/manual.html#findMarks) method.
476 * New addons: [rulers](http://codemirror.net/doc/manual.html#addon_rulers), markdown-fold, yaml-lint.
477 * New theme: [mdn-like](http://codemirror.net/demo/theme.html#mdn-like).
478 * New mode: [Solr](http://codemirror.net/mode/solr/index.html).
479 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.21.0...3.22.0).
480
481 ## 3.21.0 (2014-01-16)
482
483 * Auto-indenting a block will no longer add trailing whitespace to blank lines.
484 * Marking text has a new option [`clearWhenEmpty`](http://codemirror.net/doc/manual.html#markText) to control auto-removal.
485 * Several bugfixes in the handling of bidirectional text.
486 * 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.
487 * The OCaml mode was moved to an [mllike](http://codemirror.net/mode/mllike/index.html) mode, F# support added.
488 * 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).
489 * New theme [pastel-on-dark](http://codemirror.net/demo/theme.html#pastel-on-dark).
490 * Better ECMAScript 6 support in [JavaScript](http://codemirror.net/mode/javascript/index.html) mode.
491 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.20.0...3.21.0).
492
493 ## 3.20.0 (2013-11-21)
494
495 * New modes: [Julia](http://codemirror.net/mode/julia/index.html) and [PEG.js](http://codemirror.net/mode/pegjs/index.html).
496 * Support ECMAScript 6 in the [JavaScript mode](http://codemirror.net/mode/javascript/index.html).
497 * Improved indentation for the [CoffeeScript mode](http://codemirror.net/mode/coffeescript/index.html).
498 * Make non-printable-character representation [configurable](http://codemirror.net/doc/manual.html#option_specialChars).
499 * Add ‘notification’ functionality to [dialog](http://codemirror.net/doc/manual.html#addon_dialog) addon.
500 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.19.0...3.20.0).
501
502 ## 3.19.0 (2013-10-21)
503
504 * 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).
505 * New addons: [hardwrap](http://codemirror.net/doc/manual.html#addon_hardwrap), [sql-hint](http://codemirror.net/doc/manual.html#addon_sql-hint).
506 * New theme: [MBO](http://codemirror.net/demo/theme.html#mbo).
507 * Add [support](http://codemirror.net/doc/manual.html#token_style_line) for line-level styling from mode tokenizers.
508 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.18.0...3.19.0).
509
510 ## 3.18.0 (2013-09-23)
511
512 Emergency release to fix a problem in 3.17 where `.setOption("lineNumbers", false)` would raise an error.
513
514 ## 3.17.0 (2013-09-23)
515
516 * 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).
517 * New addons: [`css-lint`](http://codemirror.net/addon/lint/css-lint.js), [`css-hint`](http://codemirror.net/doc/manual.html#addon_css-hint).
518 * Improve resilience to CSS 'frameworks' that globally mess up `box-sizing`.
519 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.16.0...3.17.0).
520
521 ## 3.16.0 (2013-08-21)
522
523 * The whole codebase is now under a single [license](http://codemirror.net/LICENSE) file.
524 * The project page was overhauled and redesigned.
525 * 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).
526 * 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.
527 * New [folding](http://codemirror.net/doc/manual.html#addon_foldcode) function `CodeMirror.fold.comment`.
528 * Added [fullscreen](http://codemirror.net/doc/manual.html#addon_fullscreen) addon.
529 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.15.0...3.16.0).
530
531 ## 3.15.0 (2013-07-29)
532
533 * New modes: [Jade](http://codemirror.net/mode/jade/index.html), [Nginx](http://codemirror.net/mode/nginx/index.html).
534 * 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).
535 * Introduced [_helper_](http://codemirror.net/doc/manual.html#getHelper) concept ([context](https://groups.google.com/forum/#!msg/codemirror/cOc0xvUUEUU/nLrX1-qnidgJ)).
536 * New method: [`getModeAt`](http://codemirror.net/doc/manual.html#getModeAt).
537 * 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).
538 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.14.0...3.15.0).
539
540 ## 3.14.0 (2013-06-20)
541
542 * 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).
543 * [`markText`](http://codemirror.net/doc/manual.html#markText) and [`addLineWidget`](http://codemirror.net/doc/manual.html#addLineWidget) now take a `handleMouseEvents` option.
544 * New methods: [`lineAtHeight`](http://codemirror.net/doc/manual.html#lineAtHeight), [`getTokenTypeAt`](http://codemirror.net/doc/manual.html#getTokenTypeAt).
545 * More precise cleanness-tracking using [`changeGeneration`](http://codemirror.net/doc/manual.html#changeGeneration) and [`isClean`](http://codemirror.net/doc/manual.html#isClean).
546 * Many extensions to [Emacs](http://codemirror.net/demo/emacs.html) mode (prefixes, more navigation units, and more).
547 * New events [`"keyHandled"`](http://codemirror.net/doc/manual.html#event_keyHandled) and [`"inputRead"`](http://codemirror.net/doc/manual.html#event_inputRead).
548 * 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.
549 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/3.13.0...3.14.0).
550
551 ## 3.13.0 (2013-05-20)
552
553 * New modes: [COBOL](http://codemirror.net/mode/cobol/index.html) and [HAML](http://codemirror.net/mode/haml/index.html).
554 * New options: [`cursorScrollMargin`](http://codemirror.net/doc/manual.html#option_cursorScrollMargin) and [`coverGutterNextToScrollbar`](http://codemirror.net/doc/manual.html#option_coverGutterNextToScrollbar).
555 * New addon: [commenting](http://codemirror.net/doc/manual.html#addon_comment).
556 * More features added to the [Vim keymap](http://codemirror.net/demo/vim.html).
557 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.12...3.13.0).
558
559 ## 3.12.0 (2013-04-19)
560
561 * New mode: [GNU assembler](http://codemirror.net/mode/gas/index.html).
562 * New options: [`maxHighlightLength`](http://codemirror.net/doc/manual.html#option_maxHighlightLength) and [`historyEventDelay`](http://codemirror.net/doc/manual.html#option_historyEventDelay).
563 * Added [`addToHistory`](http://codemirror.net/doc/manual.html#mark_addToHistory) option for `markText`.
564 * Various fixes to JavaScript tokenization and indentation corner cases.
565 * Further improvements to the vim mode.
566 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.11...v3.12).
567
568 ## 3.11.0 (2013-03-20)
569
570 * **Removed code:** `collapserange`, `formatting`, and `simple-hint` addons. `plsql` and `mysql` modes (use [`sql`](http://codemirror.net/mode/sql/index.html) mode).
571 * **Moved code:** the range-finding functions for folding now have [their own files](http://codemirror.net/addon/fold/).
572 * **Changed interface:** the [`continuecomment`](http://codemirror.net/doc/manual.html#addon_continuecomment) addon now exposes an option, rather than a command.
573 * 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).
574 * New addons: [`placeholder`](http://codemirror.net/demo/placeholder.html), [HTML completion](http://codemirror.net/demo/html5complete.html).
575 * New methods: [`hasFocus`](http://codemirror.net/doc/manual.html#hasFocus), [`defaultCharWidth`](http://codemirror.net/doc/manual.html#defaultCharWidth).
576 * New events: [`beforeCursorEnter`](http://codemirror.net/doc/manual.html#event_beforeCursorEnter), [`renderLine`](http://codemirror.net/doc/manual.html#event_renderLine).
577 * Many improvements to the [`show-hint`](http://codemirror.net/doc/manual.html#addon_show-hint) completion dialog addon.
578 * Tweak behavior of by-word cursor motion.
579 * Further improvements to the [vim mode](http://codemirror.net/demo/vim.html).
580 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.1...v3.11).
581
582 ## 3.02.0 (2013-01-25)
583
584 Single-bugfix release. Fixes a problem that prevents CodeMirror instances from being garbage-collected after they become unused.
585
586 ## 3.01.0 (2013-01-21)
587
588 * Move all add-ons into an organized directory structure under [`/addon`](http://codemirror.net/addon/). **You might have to adjust your paths.**
589 * 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).
590 * Several bugfixes in right-to-left text support.
591 * Add [`rtlMoveVisually`](http://codemirror.net/doc/manual.html#option_rtlMoveVisually) option.
592 * Improvements to vim keymap.
593 * Add built-in (lightweight) [overlay mode](http://codemirror.net/doc/manual.html#addOverlay) support.
594 * Support `showIfHidden` option for [line widgets](http://codemirror.net/doc/manual.html#addLineWidget).
595 * Add simple [Python hinter](http://codemirror.net/doc/manual.html#addon_python-hint).
596 * Bring back the [`fixedGutter`](http://codemirror.net/doc/manual.html#option_fixedGutter) option.
597 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.0...v3.01).
598
599 ## 3.1.0 (2013-02-21)
600
601 * **Incompatible:** key handlers may now _return_, rather than _throw_ `CodeMirror.Pass` to signal they didn't handle the key.
602 * Make documents a [first-class construct](http://codemirror.net/doc/manual.html#api_doc), support split views and subviews.
603 * Add a [new module](http://codemirror.net/doc/manual.html#addon_show-hint) for showing completion hints. Deprecate `simple-hint.js`.
604 * Extend [htmlmixed mode](http://codemirror.net/mode/htmlmixed/index.html) to allow custom handling of script types.
605 * Support an `insertLeft` option to [`setBookmark`](http://codemirror.net/doc/manual.html#setBookmark).
606 * Add an [`eachLine`](http://codemirror.net/doc/manual.html#eachLine) method to iterate over a document.
607 * 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).
608 * Add [`"beforeChange"`](http://codemirror.net/doc/manual.html#event_beforeChange) and [`"beforeSelectionChange"`](http://codemirror.net/doc/manual.html#event_beforeSelectionChange) events.
609 * Add [`"hide"`](http://codemirror.net/doc/manual.html#event_hide) and [`"unhide"`](http://codemirror.net/doc/manual.html#event_unhide) events to marked ranges.
610 * Fix [`coordsChar`](http://codemirror.net/doc/manual.html#coordsChar)'s interpretation of its argument to match the documentation.
611 * New modes: [Turtle](http://codemirror.net/mode/turtle/index.html) and [Q](http://codemirror.net/mode/q/index.html).
612 * Further improvements to the [vim mode](http://codemirror.net/demo/vim.html).
613 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.01...v3.1).
614
615 ## 3.0.0 (2012-12-10)
616
617 **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:
618
619 * Rewritten VIM mode.
620 * Fix a few minor scrolling and sizing issues.
621 * Work around Safari segfault when dragging.
622 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v3.0rc2...v3.0).
623
624 ## 2.38.0 (2013-01-21)
625
626 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.
627
628 ## 2.37.0 (2012-12-20)
629
630 * 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).
631 * Further work on the new VIM mode.
632 * Fix Cmd/Ctrl keys on recent Operas on OS X.
633 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v2.36...v2.37).
634
635 ## 2.36.0 (2012-11-20)
636
637 * New mode: [Z80 assembly](http://codemirror.net/mode/z80/index.html).
638 * New theme: [Twilight](http://codemirror.net/demo/theme.html#twilight).
639 * Add command-line compression helper.
640 * Make [`scrollIntoView`](http://codemirror.net/doc/manual.html#scrollIntoView) public.
641 * Add [`defaultTextHeight`](http://codemirror.net/doc/manual.html#defaultTextHeight) method.
642 * Various extensions to the vim keymap.
643 * Make [PHP mode](http://codemirror.net/mode/php/index.html) build on [mixed HTML mode](http://codemirror.net/mode/htmlmixed/index.html).
644 * Add [comment-continuing](http://codemirror.net/doc/manual.html#addon_continuecomment) add-on.
645 * Full [list of patches](http://codemirror.net/https://github.com/codemirror/CodeMirror/compare/v2.35...v2.36).
646
647 ## 2.35.0 (2012-10-22)
648
649 * New (sub) mode: [TypeScript](http://codemirror.net/mode/javascript/typescript.html).
650 * Don't overwrite (insert key) when pasting.
651 * Fix several bugs in [`markText`](http://codemirror.net/doc/manual.html#markText)/undo interaction.
652 * Better indentation of JavaScript code without semicolons.
653 * Add [`defineInitHook`](http://codemirror.net/doc/manual.html#defineInitHook) function.
654 * Full [list of patches](https://github.com/codemirror/CodeMirror/compare/v2.34...v2.35).
655
656 ## 2.34.0 (2012-09-19)
657
658 * New mode: [Common Lisp](http://codemirror.net/mode/commonlisp/index.html).
659 * Fix right-click select-all on most browsers.
660 * Change the way highlighting happens:
661 Saves memory and CPU cycles.
662 `compareStates` is no longer needed.
663 `onHighlightComplete` no longer works.
664 * Integrate mode (Markdown, XQuery, CSS, sTex) tests in central testsuite.
665 * Add a [`CodeMirror.version`](http://codemirror.net/doc/manual.html#version) property.
666 * More robust handling of nested modes in [formatting](http://codemirror.net/demo/formatting.html) and [closetag](http://codemirror.net/demo/closetag.html) plug-ins.
667 * Un/redo now preserves [marked text](http://codemirror.net/doc/manual.html#markText) and bookmarks.
668 * [Full list](https://github.com/codemirror/CodeMirror/compare/v2.33...v2.34) of patches.
669
670 ## 2.33.0 (2012-08-23)
671
672 * New mode: [Sieve](http://codemirror.net/mode/sieve/index.html).
673 * New [`getViewPort`](http://codemirror.net/doc/manual.html#getViewport) and [`onViewportChange`](http://codemirror.net/doc/manual.html#option_onViewportChange) API.
674 * [Configurable](http://codemirror.net/doc/manual.html#option_cursorBlinkRate) cursor blink rate.
675 * Make binding a key to `false` disabling handling (again).
676 * Show non-printing characters as red dots.
677 * More tweaks to the scrolling model.
678 * Expanded testsuite. Basic linter added.
679 * Remove most uses of `innerHTML`. Remove `CodeMirror.htmlEscape`.
680 * [Full list](https://github.com/codemirror/CodeMirror/compare/v2.32...v2.33) of patches.
681
682 ## 2.32.0 (2012-07-23)
683
684 Emergency fix for a bug where an editor with line wrapping on IE will break when there is _no_ scrollbar.
685
686 ## 2.31.0 (2012-07-20)
687
688 * 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).
689 * Several fixes to the new scrolling model.
690 * Add a [`setSize`](http://codemirror.net/doc/manual.html#setSize) method for programmatic resizing.
691 * Add [`getHistory`](http://codemirror.net/doc/manual.html#getHistory) and [`setHistory`](http://codemirror.net/doc/manual.html#setHistory) methods.
692 * Allow custom line separator string in [`getValue`](http://codemirror.net/doc/manual.html#getValue) and [`getRange`](http://codemirror.net/doc/manual.html#getRange).
693 * Support double- and triple-click drag, double-clicking whitespace.
694 * And more... [(all patches)](https://github.com/codemirror/CodeMirror/compare/v2.3...v2.31)
695
696 ## 2.30.0 (2012-06-22)
697
698 * **New scrollbar implementation**. Should flicker less. Changes DOM structure of the editor.
699 * New theme: [vibrant-ink](http://codemirror.net/demo/theme.html#vibrant-ink).
700 * Many extensions to the VIM keymap (including text objects).
701 * Add [mode-multiplexing](http://codemirror.net/demo/multiplex.html) utility script.
702 * Fix bug where right-click paste works in read-only mode.
703 * Add a [`getScrollInfo`](http://codemirror.net/doc/manual.html#getScrollInfo) method.
704 * Lots of other [fixes](https://github.com/codemirror/CodeMirror/compare/v2.25...v2.3).
705
706 ## 2.25.0 (2012-05-23)
707
708 * New mode: [Erlang](http://codemirror.net/mode/erlang/index.html).
709 * **Remove xmlpure mode** (use [xml.js](http://codemirror.net/mode/xml/index.html)).
710 * Fix line-wrapping in Opera.
711 * Fix X Windows middle-click paste in Chrome.
712 * Fix bug that broke pasting of huge documents.
713 * Fix backspace and tab key repeat in Opera.
714
715 ## 2.24.0 (2012-04-23)
716
717 * **Drop support for Internet Explorer 6**.
718 * 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).
719 * New themes: [Ambiance](http://codemirror.net/demo/theme.html#ambiance), [Blackboard](http://codemirror.net/demo/theme.html#blackboard).
720 * 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.
721 * Make HTML mode a bit less pedantic.
722 * Add [`compoundChange`](http://codemirror.net/doc/manual.html#compoundChange) API method.
723 * Several fixes in undo history and line hiding.
724 * Remove (broken) support for `catchall` in key maps, add `nofallthrough` boolean field instead.
725
726 ## 2.23.0 (2012-03-26)
727
728 * Change **default binding for tab**. Starting in 2.23, these bindings are default:
729 * Tab: Insert tab character
730 * Shift-tab: Reset line indentation to default
731 * Ctrl/Cmd-[: Reduce line indentation (old tab behaviour)
732 * Ctrl/Cmd-]: Increase line indentation (old shift-tab behaviour)
733 * New modes: [XQuery](http://codemirror.net/mode/xquery/index.html) and [VBScript](http://codemirror.net/mode/vbscript/index.html).
734 * Two new themes: [lesser-dark](http://codemirror.net/mode/less/index.html) and [xq-dark](http://codemirror.net/mode/xquery/index.html).
735 * Differentiate between background and text styles in [`setLineClass`](http://codemirror.net/doc/manual.html#setLineClass).
736 * Fix drag-and-drop in IE9+.
737 * Extend [`charCoords`](http://codemirror.net/doc/manual.html#charCoords) and [`cursorCoords`](http://codemirror.net/doc/manual.html#cursorCoords) with a `mode` argument.
738 * Add [`autofocus`](http://codemirror.net/doc/manual.html#option_autofocus) option.
739 * Add [`findMarksAt`](http://codemirror.net/doc/manual.html#findMarksAt) method.
740
741 ## 2.22.0 (2012-02-27)
742
743 * Allow [key handlers](http://codemirror.net/doc/manual.html#keymaps) to pass up events, allow binding characters.
744 * Add [`autoClearEmptyLines`](http://codemirror.net/doc/manual.html#option_autoClearEmptyLines) option.
745 * Properly use tab stops when rendering tabs.
746 * Make PHP mode more robust.
747 * Support indentation blocks in [code folder](http://codemirror.net/doc/manual.html#addon_foldcode).
748 * Add a script for [highlighting instances of the selection](http://codemirror.net/doc/manual.html#addon_match-highlighter).
749 * New [.properties](http://codemirror.net/mode/properties/index.html) mode.
750 * Fix many bugs.
751
752 ## 2.21.0 (2012-01-27)
753
754 * 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.
755 * Add [`smartIndent`](http://codemirror.net/doc/manual.html#option_smartIndent) option.
756 * Support a cursor in [`readOnly`](http://codemirror.net/doc/manual.html#option_readOnly)-mode.
757 * Support assigning multiple styles to a token.
758 * Use a new approach to drawing the selection.
759 * Add [`scrollTo`](http://codemirror.net/doc/manual.html#scrollTo) method.
760 * Allow undo/redo events to span non-adjacent lines.
761 * Lots and lots of bugfixes.
762
763 ## 2.20.0 (2011-12-20)
764
765 * Slightly incompatible API changes. Read [this](http://codemirror.net/doc/upgrade_v2.2.html).
766 * 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).
767 * Support for overwrite (insert).
768 * [Custom-width](http://codemirror.net/doc/manual.html#option_tabSize) and [stylable](http://codemirror.net/demo/visibletabs.html) tabs.
769 * Moved more code into [add-on scripts](http://codemirror.net/doc/manual.html#addons).
770 * Support for sane vertical cursor movement in wrapped lines.
771 * More reliable handling of editing [marked text](http://codemirror.net/doc/manual.html#markText).
772 * Add minimal [emacs](http://codemirror.net/demo/emacs.html) and [vim](http://codemirror.net/demo/vim.html) bindings.
773 * Rename `coordsFromIndex` to [`posFromIndex`](http://codemirror.net/doc/manual.html#posFromIndex), add [`indexFromPos`](http://codemirror.net/doc/manual.html#indexFromPos) method.
774
775 ## 2.18.0 (2011-11-21)
776
777 Fixes `TextMarker.clear`, which is broken in 2.17.
778
779 ## 2.17.0 (2011-11-21)
780
781 * Add support for [line wrapping](http://codemirror.net/doc/manual.html#option_lineWrapping) and [code folding](http://codemirror.net/doc/manual.html#hideLine).
782 * Add [Github-style Markdown](http://codemirror.net/mode/gfm/index.html) mode.
783 * Add [Monokai](http://codemirror.net/theme/monokai.css) and [Rubyblue](http://codemirror.net/theme/rubyblue.css) themes.
784 * Add [`setBookmark`](http://codemirror.net/doc/manual.html#setBookmark) method.
785 * Move some of the demo code into reusable components under [`lib/util`](http://codemirror.net/addon/).
786 * Make screen-coord-finding code faster and more reliable.
787 * Fix drag-and-drop in Firefox.
788 * Improve support for IME.
789 * Speed up content rendering.
790 * Fix browser's built-in search in Webkit.
791 * Make double- and triple-click work in IE.
792 * Various fixes to modes.
793
794 ## 2.16.0 (2011-10-27)
795
796 * 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.
797 * Dragging text inside the editor now moves, rather than copies.
798 * Add a [`coordsFromIndex`](http://codemirror.net/doc/manual.html#coordsFromIndex) method.
799 * **API change**: `setValue` now no longer clears history. Use [`clearHistory`](http://codemirror.net/doc/manual.html#clearHistory) for that.
800 * **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.
801 * Fix editing code with tabs in Internet Explorer.
802
803 ## 2.15.0 (2011-09-26)
804
805 Fix bug that snuck into 2.14: Clicking the character that currently has the cursor didn't re-focus the editor.
806
807 ## 2.14.0 (2011-09-26)
808
809 * 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.
810 * Add [Cobalt](http://codemirror.net/theme/cobalt.css) and [Eclipse](http://codemirror.net/theme/eclipse.css) themes.
811 * Add a [`fixedGutter`](http://codemirror.net/doc/manual.html#option_fixedGutter) option.
812 * Fix bug with `setValue` breaking cursor movement.
813 * Make gutter updates much more efficient.
814 * Allow dragging of text out of the editor (on modern browsers).
815
816 ## 2.13.0 (2011-08-23)
817
818 * 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.
819 * Add [`getGutterElement`](http://codemirror.net/doc/manual.html#getGutterElement) to API.
820 * Several fixes to scrolling and positioning.
821 * Add [`smartHome`](http://codemirror.net/doc/manual.html#option_smartHome) option.
822 * Add an experimental [pure XML](http://codemirror.net/mode/xmlpure/index.html) mode.
823
824 ## 2.12.0 (2011-07-25)
825
826 * Add a [SPARQL](http://codemirror.net/mode/sparql/index.html) mode.
827 * Fix bug with cursor jumping around in an unfocused editor in IE.
828 * Allow key and mouse events to bubble out of the editor. Ignore widget clicks.
829 * Solve cursor flakiness after undo/redo.
830 * Fix block-reindent ignoring the last few lines.
831 * Fix parsing of multi-line attrs in XML mode.
832 * Use `innerHTML` for HTML-escaping.
833 * Some fixes to indentation in C-like mode.
834 * Shrink horiz scrollbars when long lines removed.
835 * Fix width feedback loop bug that caused the width of an inner DIV to shrink.
836
837 ## 2.11.0 (2011-07-04)
838
839 * Add a [Scheme mode](http://codemirror.net/mode/scheme/index.html).
840 * Add a `replace` method to search cursors, for cursor-preserving replacements.
841 * Make the [C-like mode](http://codemirror.net/mode/clike/index.html) mode more customizable.
842 * Update XML mode to spot mismatched tags.
843 * Add `getStateAfter` API and `compareState` mode API methods for finer-grained mode magic.
844 * Add a `getScrollerElement` API method to manipulate the scrolling DIV.
845 * Fix drag-and-drop for Firefox.
846 * Add a C# configuration for the [C-like mode](http://codemirror.net/mode/clike/index.html).
847 * Add [full-screen editing](http://codemirror.net/demo/fullscreen.html) and [mode-changing](http://codemirror.net/demo/changemode.html) demos.
848
849 ## 2.10.0 (2011-06-07)
850
851 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!
852
853 ## 2.2.0 (2011-06-07)
854
855 * Add a [Lua mode](http://codemirror.net/mode/lua/index.html).
856 * Fix reverse-searching for a regexp.
857 * Empty lines can no longer break highlighting.
858 * Rework scrolling model (the outer wrapper no longer does the scrolling).
859 * Solve horizontal jittering on long lines.
860 * Add [runmode.js](http://codemirror.net/demo/runmode.html).
861 * Immediately re-highlight text when typing.
862 * Fix problem with 'sticking' horizontal scrollbar.
863
864 ## 2.1.0 (2011-05-26)
865
866 * Add a [Smalltalk mode](http://codemirror.net/mode/smalltalk/index.html).
867 * Add a [reStructuredText mode](http://codemirror.net/mode/rst/index.html).
868 * Add a [Python mode](http://codemirror.net/mode/python/index.html).
869 * Add a [PL/SQL mode](http://codemirror.net/mode/plsql/index.html).
870 * `coordsChar` now works
871 * Fix a problem where `onCursorActivity` interfered with `onChange`.
872 * Fix a number of scrolling and mouse-click-position glitches.
873 * Pass information about the changed lines to `onChange`.
874 * Support cmd-up/down on OS X.
875 * Add triple-click line selection.
876 * Don't handle shift when changing the selection through the API.
877 * Support `"nocursor"` mode for `readOnly` option.
878 * Add an `onHighlightComplete` option.
879 * Fix the context menu for Firefox.
880
881 ## 2.0.0 (2011-03-28)
882
883 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.
00 # How to contribute
11
2 - [Getting help](#getting-help-)
3 - [Submitting bug reports](#submitting-bug-reports-)
4 - [Contributing code](#contributing-code-)
2 - [Getting help](#getting-help)
3 - [Submitting bug reports](#submitting-bug-reports)
4 - [Contributing code](#contributing-code)
55
66 ## Getting help
77
6060 - Make sure all tests pass. Visit `test/index.html` in your browser to
6161 run them.
6262 - Submit a pull request
63 ([how to create a pull request](https://help.github.com/articles/fork-a-repo))
63 ([how to create a pull request](https://help.github.com/articles/fork-a-repo)).
64 Don't put more than one feature/fix in a single pull request.
6465
6566 By contributing code to CodeMirror you
6667
7677 ### Coding standards
7778
7879 - 2 spaces per indentation level, no tabs.
79 - Include semicolons after statements.
80
8081 - Note that the linter (`bin/lint`) which is run after each commit
8182 complains about unused variables and functions. Prefix their names
8283 with an underscore to muffle it.
0 Copyright (C) 2015 by Marijn Haverbeke <marijnh@gmail.com> and others
0 Copyright (C) 2016 by Marijn Haverbeke <marijnh@gmail.com> and others
11
22 Permission is hereby granted, free of charge, to any person obtaining a copy
33 of this software and associated documentation files (the "Software"), to deal
00 # CodeMirror
11 [![Build Status](https://travis-ci.org/codemirror/CodeMirror.svg)](https://travis-ci.org/codemirror/CodeMirror)
2 [![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
2 [![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
3 [![Join the chat at https://gitter.im/codemirror/CodeMirror](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/codemirror/CodeMirror)
34 [Funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png?again)](https://marijnhaverbeke.nl/fund/)
45
5 CodeMirror is a JavaScript component that provides a code editor in
6 the browser. When a mode is available for the language you are coding
7 in, it will color your code, and optionally help with indentation.
6 CodeMirror is a versatile text editor implemented in JavaScript for
7 the browser. It is specialized for editing code, and comes with over
8 100 language modes and various addons that implement more advanced
9 editing functionality.
810
9 The project page is http://codemirror.net
10 The manual is at http://codemirror.net/doc/manual.html
11 The contributing guidelines are in [CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
11 A rich programming API and a CSS theming system are available for
12 customizing CodeMirror to fit your application, and extending it with
13 new functionality.
14
15 You can find more information (and the
16 [manual](http://codemirror.net/doc/manual.html)) on the [project
17 page](http://codemirror.net). For questions and discussion, use the
18 [discussion forum](https://discuss.codemirror.net/).
19
20 See
21 [CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
22 for contributing guidelines.
23
24 The CodeMirror community aims to be welcoming to everybody. We use the
25 [Contributor Covenant
26 (1.1)](http://contributor-covenant.org/version/1/1/0/) as our code of
27 conduct.
2020 }
2121
2222 CodeMirror.commands.toggleComment = function(cm) {
23 var minLine = Infinity, ranges = cm.listSelections(), mode = null;
23 cm.toggleComment();
24 };
25
26 CodeMirror.defineExtension("toggleComment", function(options) {
27 if (!options) options = noOptions;
28 var cm = this;
29 var minLine = Infinity, ranges = this.listSelections(), mode = null;
2430 for (var i = ranges.length - 1; i >= 0; i--) {
2531 var from = ranges[i].from(), to = ranges[i].to();
2632 if (from.line >= minLine) continue;
2733 if (to.line >= minLine) to = Pos(minLine, 0);
2834 minLine = from.line;
2935 if (mode == null) {
30 if (cm.uncomment(from, to)) mode = "un";
31 else { cm.lineComment(from, to); mode = "line"; }
36 if (cm.uncomment(from, to, options)) mode = "un";
37 else { cm.lineComment(from, to, options); mode = "line"; }
3238 } else if (mode == "un") {
33 cm.uncomment(from, to);
39 cm.uncomment(from, to, options);
3440 } else {
35 cm.lineComment(from, to);
36 }
37 }
38 };
41 cm.lineComment(from, to, options);
42 }
43 }
44 });
45
46 // Rough heuristic to try and detect lines that are part of multi-line string
47 function probablyInsideString(cm, pos, line) {
48 return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"`]/.test(line)
49 }
3950
4051 CodeMirror.defineExtension("lineComment", function(from, to, options) {
4152 if (!options) options = noOptions;
4253 var self = this, mode = self.getModeAt(from);
54 var firstLine = self.getLine(from.line);
55 if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
56
4357 var commentString = options.lineComment || mode.lineComment;
4458 if (!commentString) {
4559 if (options.blockCommentStart || mode.blockCommentStart) {
4862 }
4963 return;
5064 }
51 var firstLine = self.getLine(from.line);
52 if (firstLine == null) return;
65
5366 var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
5467 var pad = options.padding == null ? " " : options.padding;
5568 var blankLines = options.commentBlankLines || from.line == to.line;
5669
5770 self.operation(function() {
5871 if (options.indent) {
59 var baseString = firstLine.slice(0, firstNonWS(firstLine));
72 var baseString = null;
73 for (var i = from.line; i < end; ++i) {
74 var line = self.getLine(i);
75 var whitespace = line.slice(0, firstNonWS(line));
76 if (baseString == null || baseString.length > whitespace.length) {
77 baseString = whitespace;
78 }
79 }
6080 for (var i = from.line; i < end; ++i) {
6181 var line = self.getLine(i), cut = baseString.length;
6282 if (!blankLines && !nonWS.test(line)) continue;
82102 self.lineComment(from, to, options);
83103 return;
84104 }
105 if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
85106
86107 var end = Math.min(to.line, self.lastLine());
87108 if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
119140 var line = self.getLine(i);
120141 var found = line.indexOf(lineString);
121142 if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
122 if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
143 if (found == -1 && nonWS.test(line)) break lineComment;
123144 if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
124145 lines.push(line);
125146 }
141162 var endString = options.blockCommentEnd || mode.blockCommentEnd;
142163 if (!startString || !endString) return false;
143164 var lead = options.blockCommentLead || mode.blockCommentLead;
144 var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
145 var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
165 var startLine = self.getLine(start), open = startLine.indexOf(startString)
166 if (open == -1) return false
167 var endLine = end == start ? startLine : self.getLine(end)
168 var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
146169 if (close == -1 && start != end) {
147170 endLine = self.getLine(--end);
148 close = endLine.lastIndexOf(endString);
149 }
150 if (open == -1 || close == -1 ||
171 close = endLine.indexOf(endString);
172 }
173 if (close == -1 ||
151174 !/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
152175 !/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
153176 return false;
5555
5656 var inp = dialog.getElementsByTagName("input")[0], button;
5757 if (inp) {
58 inp.focus();
59
5860 if (options.value) {
5961 inp.value = options.value;
6062 if (options.selectValueOnOpen !== false) {
7880 });
7981
8082 if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
81
82 inp.focus();
8383 } else if (button = dialog.getElementsByTagName("button")[0]) {
8484 CodeMirror.on(button, "click", function() {
8585 close();
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"))
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod)
8 else // Plain browser env
9 mod(CodeMirror)
10 })(function(CodeMirror) {
11 "use strict"
12
13 CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
14 if (cm.state.autoRefresh) {
15 stopListening(cm, cm.state.autoRefresh)
16 cm.state.autoRefresh = null
17 }
18 if (val && cm.display.wrapper.offsetHeight == 0)
19 startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
20 })
21
22 function startListening(cm, state) {
23 function check() {
24 if (cm.display.wrapper.offsetHeight) {
25 stopListening(cm, state)
26 if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
27 cm.refresh()
28 } else {
29 state.timeout = setTimeout(check, state.delay)
30 }
31 }
32 state.timeout = setTimeout(check, state.delay)
33 state.hurry = function() {
34 clearTimeout(state.timeout)
35 state.timeout = setTimeout(check, 50)
36 }
37 CodeMirror.on(window, "mouseup", state.hurry)
38 CodeMirror.on(window, "keyup", state.hurry)
39 }
40
41 function stopListening(_cm, state) {
42 clearTimeout(state.timeout)
43 CodeMirror.off(window, "mouseup", state.hurry)
44 CodeMirror.off(window, "keyup", state.hurry)
45 }
46 });
1313 if (val && !prev) {
1414 cm.on("blur", onBlur);
1515 cm.on("change", onChange);
16 cm.on("swapDoc", onChange);
1617 onChange(cm);
1718 } else if (!val && prev) {
1819 cm.off("blur", onBlur);
1920 cm.off("change", onChange);
21 cm.off("swapDoc", onChange);
2022 clearPlaceholder(cm);
2123 var wrapper = cm.getWrapperElement();
2224 wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
3638 var elt = cm.state.placeholder = document.createElement("pre");
3739 elt.style.cssText = "height: 0; overflow: visible";
3840 elt.className = "CodeMirror-placeholder";
39 elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
41 var placeHolder = cm.getOption("placeholder")
42 if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
43 elt.appendChild(placeHolder)
4044 cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
4145 }
4246
1010 })(function(CodeMirror) {
1111 "use strict";
1212
13 CodeMirror.defineOption("rulers", false, function(cm, val, old) {
14 if (old && old != CodeMirror.Init) {
15 clearRulers(cm);
16 cm.off("refresh", refreshRulers);
13 CodeMirror.defineOption("rulers", false, function(cm, val) {
14 if (cm.state.rulerDiv) {
15 cm.display.lineSpace.removeChild(cm.state.rulerDiv)
16 cm.state.rulerDiv = null
17 cm.off("refresh", drawRulers)
1718 }
1819 if (val && val.length) {
19 setRulers(cm);
20 cm.on("refresh", refreshRulers);
20 cm.state.rulerDiv = cm.display.lineSpace.insertBefore(document.createElement("div"), cm.display.cursorDiv)
21 cm.state.rulerDiv.className = "CodeMirror-rulers"
22 drawRulers(cm)
23 cm.on("refresh", drawRulers)
2124 }
2225 });
2326
24 function clearRulers(cm) {
25 for (var i = cm.display.lineSpace.childNodes.length - 1; i >= 0; i--) {
26 var node = cm.display.lineSpace.childNodes[i];
27 if (/(^|\s)CodeMirror-ruler($|\s)/.test(node.className))
28 node.parentNode.removeChild(node);
29 }
30 }
31
32 function setRulers(cm) {
27 function drawRulers(cm) {
28 cm.state.rulerDiv.textContent = ""
3329 var val = cm.getOption("rulers");
3430 var cw = cm.defaultCharWidth();
3531 var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
36 var minH = cm.display.scroller.offsetHeight + 30;
32 cm.state.rulerDiv.style.minHeight = (cm.display.scroller.offsetHeight + 30) + "px";
3733 for (var i = 0; i < val.length; i++) {
3834 var elt = document.createElement("div");
3935 elt.className = "CodeMirror-ruler";
4844 if (conf.width) elt.style.borderLeftWidth = conf.width;
4945 }
5046 elt.style.left = (left + col * cw) + "px";
51 elt.style.top = "-50px";
52 elt.style.bottom = "-20px";
53 elt.style.minHeight = minH + "px";
54 cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv);
47 cm.state.rulerDiv.appendChild(elt)
5548 }
5649 }
57
58 function refreshRulers(cm) {
59 clearRulers(cm);
60 setRulers(cm);
61 }
6250 });
6262 }
6363 for (var i = ranges.length - 1; i >= 0; i--) {
6464 var cur = ranges[i].head;
65 cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
65 cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
6666 }
6767 }
6868
8989 });
9090 }
9191
92 function contractSelection(sel) {
93 var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
94 return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
95 head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))};
96 }
97
9298 function handleChar(cm, ch) {
9399 var conf = getConfig(cm);
94100 if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
102108 var ranges = cm.listSelections();
103109 var opening = pos % 2 == 0;
104110
105 var type, next;
111 var type;
106112 for (var i = 0; i < ranges.length; i++) {
107113 var range = ranges[i], cur = range.head, curType;
108114 var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
144150 for (var i = 0; i < sels.length; i++)
145151 sels[i] = left + sels[i] + right;
146152 cm.replaceSelections(sels, "around");
153 sels = cm.listSelections().slice();
154 for (var i = 0; i < sels.length; i++)
155 sels[i] = contractSelection(sels[i]);
156 cm.setSelections(sels);
147157 } else if (type == "both") {
148158 cm.replaceSelection(left + right, null);
149159 cm.triggerElectric(left + right);
107107 // when completing in JS/CSS snippet in htmlmixed mode. Does not
108108 // work for other XML embedded languages (there is no general
109109 // way to go from a mixed mode to its current XML state).
110 var replacement;
110111 if (inner.mode.name != "xml") {
111112 if (cm.getMode().name == "htmlmixed" && inner.mode.name == "javascript")
112 replacements[i] = head + "script>";
113 replacement = head + "script";
113114 else if (cm.getMode().name == "htmlmixed" && inner.mode.name == "css")
114 replacements[i] = head + "style>";
115 replacement = head + "style";
115116 else
116117 return CodeMirror.Pass;
117118 } else {
118119 if (!state.context || !state.context.tagName ||
119120 closingTagExists(cm, state.context.tagName, pos, state))
120121 return CodeMirror.Pass;
121 replacements[i] = head + state.context.tagName + ">";
122 replacement = head + state.context.tagName;
122123 }
124 if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
125 replacements[i] = replacement;
123126 }
124127 cm.replaceSelections(replacements);
125128 ranges = cm.listSelections();
101101 }
102102
103103 CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
104 if (old && old != CodeMirror.Init)
104 if (old && old != CodeMirror.Init) {
105105 cm.off("cursorActivity", doMatchBrackets);
106 if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
107 }
106108 if (val) {
107109 cm.state.matchBrackets = typeof val == "object" ? val : {};
108110 cm.on("cursorActivity", doMatchBrackets);
1212
1313 CodeMirror.registerHelper("fold", "brace", function(cm, start) {
1414 var line = start.line, lineText = cm.getLine(line);
15 var startCh, tokenType;
15 var tokenType;
1616
1717 function findOpening(openCh) {
1818 for (var at = start.ch, pass = 0;;) {
7171 }
7272 }
7373
74 var start = start.line, has = hasImport(start), prev;
75 if (!has || hasImport(start - 1) || ((prev = hasImport(start - 2)) && prev.end.line == start - 1))
74 var startLine = start.line, has = hasImport(startLine), prev;
75 if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1))
7676 return null;
7777 for (var end = has.end;;) {
7878 var next = hasImport(end.line + 1);
7979 if (next == null) break;
8080 end = next.end;
8181 }
82 return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
82 return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end};
8383 });
8484
8585 CodeMirror.registerHelper("fold", "include", function(cm, start) {
9090 if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
9191 }
9292
93 var start = start.line, has = hasInclude(start);
94 if (has == null || hasInclude(start - 1) != null) return null;
95 for (var end = start;;) {
93 var startLine = start.line, has = hasInclude(startLine);
94 if (has == null || hasInclude(startLine - 1) != null) return null;
95 for (var end = startLine;;) {
9696 var next = hasInclude(end + 1);
9797 if (next == null) break;
9898 ++end;
9999 }
100 return {from: CodeMirror.Pos(start, has + 1),
100 return {from: CodeMirror.Pos(startLine, has + 1),
101101 to: cm.clipPos(CodeMirror.Pos(end))};
102102 });
103103
2727 continue;
2828 }
2929 if (pass == 1 && found < start.ch) return;
30 if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
30 if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
31 (found == 0 || lineText.slice(found - endToken.length, found) == endToken ||
32 !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
3133 startCh = found + startToken.length;
3234 break;
3335 }
4848 });
4949 var myRange = cm.markText(range.from, range.to, {
5050 replacedWith: myWidget,
51 clearOnEnter: true,
51 clearOnEnter: getOption(cm, options, "clearOnEnter"),
5252 __isFold: true
5353 });
5454 myRange.on("clear", function(from, to) {
128128 rangeFinder: CodeMirror.fold.auto,
129129 widget: "\u2194",
130130 minFoldSize: 0,
131 scanUp: false
131 scanUp: false,
132 clearOnEnter: true
132133 };
133134
134135 CodeMirror.defineOption("foldOptions", null);
1919 cm.off("viewportChange", onViewportChange);
2020 cm.off("fold", onFold);
2121 cm.off("unfold", onFold);
22 cm.off("swapDoc", updateInViewport);
22 cm.off("swapDoc", onChange);
2323 }
2424 if (val) {
2525 cm.state.foldGutter = new State(parseOptions(val));
2929 cm.on("viewportChange", onViewportChange);
3030 cm.on("fold", onFold);
3131 cm.on("unfold", onFold);
32 cm.on("swapDoc", updateInViewport);
32 cm.on("swapDoc", onChange);
3333 }
3434 });
3535
4949 }
5050
5151 function isFolded(cm, line) {
52 var marks = cm.findMarksAt(Pos(line));
52 var marks = cm.findMarks(Pos(line, 0), Pos(line + 1, 0));
5353 for (var i = 0; i < marks.length; ++i)
5454 if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i];
5555 }
2020 function Iter(cm, line, ch, range) {
2121 this.line = line; this.ch = ch;
2222 this.cm = cm; this.text = cm.getLine(line);
23 this.min = range ? range.from : cm.firstLine();
24 this.max = range ? range.to - 1 : cm.lastLine();
23 this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine();
24 this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine();
2525 }
2626
2727 function tagAt(iter, ch) {
139139 var openTag = toNextTag(iter), end;
140140 if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return;
141141 if (!openTag[1] && end != "selfClose") {
142 var start = Pos(iter.line, iter.ch);
143 var close = findMatchingClose(iter, openTag[2]);
144 return close && {from: start, to: close.from};
142 var startPos = Pos(iter.line, iter.ch);
143 var endPos = findMatchingClose(iter, openTag[2]);
144 return endPos && {from: startPos, to: endPos.from};
145145 }
146146 }
147147 });
2020 while (start && word.test(curLine.charAt(start - 1))) --start;
2121 var curWord = start != end && curLine.slice(start, end);
2222
23 var list = [], seen = {};
23 var list = options && options.list || [], seen = {};
2424 var re = new RegExp(word.source, "g");
2525 for (var dir = -1; dir <= 1; dir += 2) {
2626 var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
9696 var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
9797 "if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
9898
99 function forAllProps(obj, callback) {
100 if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
101 for (var name in obj) callback(name)
102 } else {
103 for (var o = obj; o; o = Object.getPrototypeOf(o))
104 Object.getOwnPropertyNames(o).forEach(callback)
105 }
106 }
107
99108 function getCompletions(token, context, keywords, options) {
100109 var found = [], start = token.string, global = options && options.globalScope || window;
101110 function maybeAdd(str) {
105114 if (typeof obj == "string") forEach(stringProps, maybeAdd);
106115 else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
107116 else if (obj instanceof Function) forEach(funcProps, maybeAdd);
108 for (var name in obj) maybeAdd(name);
117 forAllProps(obj, maybeAdd)
109118 }
110119
111120 if (context && context.length) {
2424 margin: 0;
2525 padding: 0 4px;
2626 border-radius: 2px;
27 max-width: 19em;
28 overflow: hidden;
2927 white-space: pre;
3028 color: black;
3129 cursor: pointer;
2424 };
2525
2626 CodeMirror.defineExtension("showHint", function(options) {
27 // We want a single cursor position.
28 if (this.listSelections().length > 1 || this.somethingSelected()) return;
27 options = parseOptions(this, this.getCursor("start"), options);
28 var selections = this.listSelections()
29 if (selections.length > 1) return;
30 // By default, don't allow completion when something is selected.
31 // A hint function can have a `supportsSelection` property to
32 // indicate that it can handle selections.
33 if (this.somethingSelected()) {
34 if (!options.hint.supportsSelection) return;
35 // Don't try with cross-line selections
36 for (var i = 0; i < selections.length; i++)
37 if (selections[i].head.line != selections[i].anchor.line) return;
38 }
2939
3040 if (this.state.completionActive) this.state.completionActive.close();
3141 var completion = this.state.completionActive = new Completion(this, options);
3747
3848 function Completion(cm, options) {
3949 this.cm = cm;
40 this.options = this.buildOptions(options);
50 this.options = options;
4151 this.widget = null;
4252 this.debounce = 0;
4353 this.tick = 0;
44 this.startPos = this.cm.getCursor();
45 this.startLen = this.cm.getLine(this.startPos.line).length;
54 this.startPos = this.cm.getCursor("start");
55 this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
4656
4757 var self = this;
4858 cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
97107 },
98108
99109 update: function(first) {
100 if (this.tick == null) return;
110 if (this.tick == null) return
111 var self = this, myTick = ++this.tick
112 fetchHints(this.options.hint, this.cm, this.options, function(data) {
113 if (self.tick == myTick) self.finishUpdate(data, first)
114 })
115 },
116
117 finishUpdate: function(data, first) {
101118 if (this.data) CodeMirror.signal(this.data, "update");
102 if (!this.options.hint.async) {
103 this.finishUpdate(this.options.hint(this.cm, this.options), first);
104 } else {
105 var myTick = ++this.tick, self = this;
106 this.options.hint(this.cm, function(data) {
107 if (self.tick == myTick) self.finishUpdate(data, first);
108 }, this.options);
109 }
110 },
111
112 finishUpdate: function(data, first) {
113 this.data = data;
114119
115120 var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
116121 if (this.widget) this.widget.close();
122
123 if (data && this.data && isNewCompletion(this.data, data)) return;
124 this.data = data;
125
117126 if (data && data.list.length) {
118127 if (picked && data.list.length == 1) {
119128 this.pick(data, 0);
122131 CodeMirror.signal(data, "shown");
123132 }
124133 }
125 },
126
127 buildOptions: function(options) {
128 var editor = this.cm.options.hintOptions;
129 var out = {};
130 for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
131 if (editor) for (var prop in editor)
132 if (editor[prop] !== undefined) out[prop] = editor[prop];
133 if (options) for (var prop in options)
134 if (options[prop] !== undefined) out[prop] = options[prop];
135 return out;
136134 }
137135 };
136
137 function isNewCompletion(old, nw) {
138 var moved = CodeMirror.cmpPos(nw.from, old.from)
139 return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
140 }
141
142 function parseOptions(cm, pos, options) {
143 var editor = cm.options.hintOptions;
144 var out = {};
145 for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
146 if (editor) for (var prop in editor)
147 if (editor[prop] !== undefined) out[prop] = editor[prop];
148 if (options) for (var prop in options)
149 if (options[prop] !== undefined) out[prop] = options[prop];
150 if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
151 return out;
152 }
138153
139154 function getText(completion) {
140155 if (typeof completion == "string") return completion;
213228 var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
214229 (completion.options.container || document.body).appendChild(hints);
215230 var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
231 var scrolls = hints.scrollHeight > hints.clientHeight + 1
232 var startScroll = cm.getScrollInfo();
233
216234 if (overlapY > 0) {
217235 var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
218236 if (curTop - height > 0) { // Fits above cursor
237255 }
238256 hints.style.left = (left = pos.left - overlapX) + "px";
239257 }
258 if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
259 node.style.paddingRight = cm.display.nativeBarWidth + "px"
240260
241261 cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
242262 moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
254274 cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
255275 }
256276
257 var startScroll = cm.getScrollInfo();
258277 cm.on("scroll", this.onScroll = function() {
259278 var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
260279 var newTop = top + startScroll.top - curScroll.top;
334353 }
335354 };
336355
337 CodeMirror.registerHelper("hint", "auto", function(cm, options) {
338 var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
356 function applicableHelpers(cm, helpers) {
357 if (!cm.somethingSelected()) return helpers
358 var result = []
359 for (var i = 0; i < helpers.length; i++)
360 if (helpers[i].supportsSelection) result.push(helpers[i])
361 return result
362 }
363
364 function fetchHints(hint, cm, options, callback) {
365 if (hint.async) {
366 hint(cm, callback, options)
367 } else {
368 var result = hint(cm, options)
369 if (result && result.then) result.then(callback)
370 else callback(result)
371 }
372 }
373
374 function resolveAutoHints(cm, pos) {
375 var helpers = cm.getHelpers(pos, "hint"), words
339376 if (helpers.length) {
340 for (var i = 0; i < helpers.length; i++) {
341 var cur = helpers[i](cm, options);
342 if (cur && cur.list.length) return cur;
343 }
377 var resolved = function(cm, callback, options) {
378 var app = applicableHelpers(cm, helpers);
379 function run(i) {
380 if (i == app.length) return callback(null)
381 fetchHints(app[i], cm, options, function(result) {
382 if (result && result.list.length > 0) callback(result)
383 else run(i + 1)
384 })
385 }
386 run(0)
387 }
388 resolved.async = true
389 resolved.supportsSelection = true
390 return resolved
344391 } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
345 if (words) return CodeMirror.hint.fromList(cm, {words: words});
392 return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
346393 } else if (CodeMirror.hint.anyword) {
347 return CodeMirror.hint.anyword(cm, options);
348 }
394 return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
395 } else {
396 return function() {}
397 }
398 }
399
400 CodeMirror.registerHelper("hint", "auto", {
401 resolve: resolveAutoHints
349402 });
350403
351404 CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
352405 var cur = cm.getCursor(), token = cm.getTokenAt(cur);
406 var to = CodeMirror.Pos(cur.line, token.end);
407 if (token.string && /\w/.test(token.string[token.string.length - 1])) {
408 var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
409 } else {
410 var term = "", from = to;
411 }
353412 var found = [];
354413 for (var i = 0; i < options.words.length; i++) {
355414 var word = options.words[i];
356 if (word.slice(0, token.string.length) == token.string)
415 if (word.slice(0, term.length) == term)
357416 found.push(word);
358417 }
359418
360 if (found.length) return {
361 list: found,
362 from: CodeMirror.Pos(cur.line, token.start),
363 to: CodeMirror.Pos(cur.line, token.end)
364 };
419 if (found.length) return {list: found, from: from, to: to};
365420 });
366421
367422 CodeMirror.commands.autocomplete = CodeMirror.showHint;
372427 alignWithWord: true,
373428 closeCharacters: /[\s()\[\]{};:>,]/,
374429 closeOnUnfocus: true,
375 completeOnSingleClick: false,
430 completeOnSingleClick: true,
376431 container: null,
377432 customKeys: null,
378433 extraKeys: null
1717 QUERY_DIV: ";",
1818 ALIAS_KEYWORD: "AS"
1919 };
20 var Pos = CodeMirror.Pos;
20 var Pos = CodeMirror.Pos, cmpPos = CodeMirror.cmpPos;
21
22 function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
2123
2224 function getKeywords(editor) {
2325 var mode = editor.doc.modeOption;
2931 return typeof item == "string" ? item : item.text;
3032 }
3133
32 function getItem(list, item) {
33 if (!list.slice) return list[item];
34 for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
35 return list[i];
34 function wrapTable(name, value) {
35 if (isArray(value)) value = {columns: value}
36 if (!value.text) value.text = name
37 return value
38 }
39
40 function parseTables(input) {
41 var result = {}
42 if (isArray(input)) {
43 for (var i = input.length - 1; i >= 0; i--) {
44 var item = input[i]
45 result[getText(item).toUpperCase()] = wrapTable(getText(item), item)
46 }
47 } else if (input) {
48 for (var name in input)
49 result[name.toUpperCase()] = wrapTable(name, input[name])
50 }
51 return result
52 }
53
54 function getTable(name) {
55 return tables[name.toUpperCase()]
3656 }
3757
3858 function shallowClone(object) {
4969 }
5070
5171 function addMatches(result, search, wordlist, formatter) {
52 for (var word in wordlist) {
53 if (!wordlist.hasOwnProperty(word)) continue;
54 if (wordlist.slice) word = wordlist[word];
55
56 if (match(search, word)) result.push(formatter(word));
72 if (isArray(wordlist)) {
73 for (var i = 0; i < wordlist.length; i++)
74 if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))
75 } else {
76 for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {
77 var val = wordlist[word]
78 if (!val || val === true)
79 val = word
80 else
81 val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text
82 if (match(search, val)) result.push(formatter(val))
83 }
5784 }
5885 }
5986
77104 }
78105
79106 function nameCompletion(cur, token, result, editor) {
80 // Try to complete table, colunm names and return start position of completion
107 // Try to complete table, column names and return start position of completion
81108 var useBacktick = false;
82109 var nameParts = [];
83110 var start = token.start;
114141 var alias = false;
115142 var aliasTable = table;
116143 // Check if table is available. If not, find table by Alias
117 if (!getItem(tables, table)) {
144 if (!getTable(table)) {
118145 var oldTable = table;
119146 table = findTableByAlias(table, editor);
120147 if (table !== oldTable) alias = true;
121148 }
122149
123 var columns = getItem(tables, table);
150 var columns = getTable(table);
124151 if (columns && columns.columns)
125152 columns = columns.columns;
126153
150177 }
151178 }
152179
153 function convertCurToNumber(cur) {
154 // max characters of a line is 999,999.
155 return cur.line + cur.ch / Math.pow(10, 6);
156 }
157
158 function convertNumberToCur(num) {
159 return Pos(Math.floor(num), +num.toString().split('.').pop());
160 }
161
162180 function findTableByAlias(alias, editor) {
163181 var doc = editor.doc;
164182 var fullQuery = doc.getValue();
181199 separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
182200
183201 //find valid range
184 var prevItem = 0;
185 var current = convertCurToNumber(editor.getCursor());
186 for (var i=0; i< separator.length; i++) {
187 var _v = convertCurToNumber(separator[i]);
188 if (current > prevItem && current <= _v) {
189 validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
202 var prevItem = null;
203 var current = editor.getCursor()
204 for (var i = 0; i < separator.length; i++) {
205 if ((prevItem == null || cmpPos(current, prevItem) > 0) && cmpPos(current, separator[i]) <= 0) {
206 validRange = {start: prevItem, end: separator[i]};
190207 break;
191208 }
192 prevItem = _v;
209 prevItem = separator[i];
193210 }
194211
195212 var query = doc.getRange(validRange.start, validRange.end, false);
198215 var lineText = query[i];
199216 eachWord(lineText, function(word) {
200217 var wordUpperCase = word.toUpperCase();
201 if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
218 if (wordUpperCase === aliasUpperCase && getTable(previousWord))
202219 table = previousWord;
203220 if (wordUpperCase !== CONS.ALIAS_KEYWORD)
204221 previousWord = word;
209226 }
210227
211228 CodeMirror.registerHelper("hint", "sql", function(editor, options) {
212 tables = (options && options.tables) || {};
229 tables = parseTables(options && options.tables)
213230 var defaultTableName = options && options.defaultTable;
214231 var disableKeywords = options && options.disableKeywords;
215 defaultTable = defaultTableName && getItem(tables, defaultTableName);
216 keywords = keywords || getKeywords(editor);
232 defaultTable = defaultTableName && getTable(defaultTableName);
233 keywords = getKeywords(editor);
217234
218235 if (defaultTableName && !defaultTable)
219236 defaultTable = findTableByAlias(defaultTableName, editor);
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 // Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
4
5 // declare global: HTMLHint
6
7 (function(mod) {
8 if (typeof exports == "object" && typeof module == "object") // CommonJS
9 mod(require("../../lib/codemirror"), require("htmlhint"));
10 else if (typeof define == "function" && define.amd) // AMD
11 define(["../../lib/codemirror", "htmlhint"], mod);
12 else // Plain browser env
13 mod(CodeMirror);
14 })(function(CodeMirror) {
15 "use strict";
16
17 var defaultRules = {
18 "tagname-lowercase": true,
19 "attr-lowercase": true,
20 "attr-value-double-quotes": true,
21 "doctype-first": false,
22 "tag-pair": true,
23 "spec-char-escape": true,
24 "id-unique": true,
25 "src-not-empty": true,
26 "attr-no-duplication": true
27 };
28
29 CodeMirror.registerHelper("lint", "html", function(text, options) {
30 var found = [];
31 if (!window.HTMLHint) return found;
32 var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
33 for (var i = 0; i < messages.length; i++) {
34 var message = messages[i];
35 var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
36 found.push({
37 from: CodeMirror.Pos(startLine, startCol),
38 to: CodeMirror.Pos(endLine, endCol),
39 message: message.message,
40 severity : message.type
41 });
42 }
43 return found;
44 });
45 });
33 }
44
55 .CodeMirror-lint-tooltip {
6 background-color: infobackground;
6 background-color: #ffd;
77 border: 1px solid black;
88 border-radius: 4px 4px 4px 4px;
9 color: infotext;
9 color: black;
1010 font-family: monospace;
1111 font-size: 10pt;
1212 overflow: hidden;
6060 this.timeout = null;
6161 this.hasGutter = hasGutter;
6262 this.onMouseOver = function(e) { onMouseOver(cm, e); };
63 this.waitingFor = 0
6364 }
6465
6566 function parseOptions(_cm, options) {
114115 return tip;
115116 }
116117
118 function lintAsync(cm, getAnnotations, passOptions) {
119 var state = cm.state.lint
120 var id = ++state.waitingFor
121 function abort() {
122 id = -1
123 cm.off("change", abort)
124 }
125 cm.on("change", abort)
126 getAnnotations(cm.getValue(), function(annotations, arg2) {
127 cm.off("change", abort)
128 if (state.waitingFor != id) return
129 if (arg2 && annotations instanceof CodeMirror) annotations = arg2
130 updateLinting(cm, annotations)
131 }, passOptions, cm);
132 }
133
117134 function startLinting(cm) {
118135 var state = cm.state.lint, options = state.options;
119136 var passOptions = options.options || options; // Support deprecated passing of `options` property in options
120137 var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
121138 if (!getAnnotations) return;
122 if (options.async || getAnnotations.async)
123 getAnnotations(cm.getValue(), updateLinting, passOptions, cm);
124 else
139 if (options.async || getAnnotations.async) {
140 lintAsync(cm, getAnnotations, passOptions)
141 } else {
125142 updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm));
143 }
126144 }
127145
128146 function updateLinting(cm, annotationsNotSorted) {
167185 state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
168186 }
169187
170 function popupSpanTooltip(ann, e) {
188 function popupTooltips(annotations, e) {
171189 var target = e.target || e.srcElement;
172 showTooltipFor(e, annotationTooltip(ann), target);
190 var tooltip = document.createDocumentFragment();
191 for (var i = 0; i < annotations.length; i++) {
192 var ann = annotations[i];
193 tooltip.appendChild(annotationTooltip(ann));
194 }
195 showTooltipFor(e, tooltip, target);
173196 }
174197
175198 function onMouseOver(cm, e) {
177200 if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
178201 var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
179202 var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
203
204 var annotations = [];
180205 for (var i = 0; i < spans.length; ++i) {
181206 var ann = spans[i].__annotation;
182 if (ann) return popupSpanTooltip(ann, e);
183 }
207 if (ann) annotations.push(ann);
208 }
209 if (annotations.length) popupTooltips(annotations, e);
184210 }
185211
186212 CodeMirror.defineOption("lint", false, function(cm, val, old) {
187213 if (old && old != CodeMirror.Init) {
188214 clearMarks(cm);
189 cm.off("change", onChange);
215 if (cm.state.lint.options.lintOnChange !== false)
216 cm.off("change", onChange);
190217 CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
191218 clearTimeout(cm.state.lint.timeout);
192219 delete cm.state.lint;
196223 var gutters = cm.getOption("gutters"), hasLintGutter = false;
197224 for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
198225 var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
199 cm.on("change", onChange);
226 if (state.options.lintOnChange !== false)
227 cm.on("change", onChange);
200228 if (state.options.tooltips != false)
201229 CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
202230
203231 startLinting(cm);
204232 }
205233 });
234
235 CodeMirror.defineExtension("performLint", function() {
236 if (this.state.lint) startLinting(this);
237 });
206238 });
5959 position: absolute;
6060 cursor: pointer;
6161 color: #44c;
62 z-index: 3;
6263 }
6364
6465 .CodeMirror-merge-copy-reverse {
44
55 (function(mod) {
66 if (typeof exports == "object" && typeof module == "object") // CommonJS
7 mod(require("../../lib/codemirror"), require("diff_match_patch"));
7 mod(require("../../lib/codemirror")); // Note non-packaged dependency diff_match_patch
88 else if (typeof define == "function" && define.amd) // AMD
99 define(["../../lib/codemirror", "diff_match_patch"], mod);
1010 else // Plain browser env
11 mod(CodeMirror, diff_match_patch);
12 })(function(CodeMirror, diff_match_patch) {
11 mod(CodeMirror);
12 })(function(CodeMirror) {
1313 "use strict";
1414 var Pos = CodeMirror.Pos;
1515 var svgNS = "http://www.w3.org/2000/svg";
283283 if (dv.copyButtons) clear(dv.copyButtons);
284284
285285 var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
286 var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top;
286 var outerTop = dv.mv.wrap.getBoundingClientRect().top
287 var sTopEdit = outerTop - dv.edit.getScrollerElement().getBoundingClientRect().top + dv.edit.getScrollInfo().top
288 var sTopOrig = outerTop - dv.orig.getScrollerElement().getBoundingClientRect().top + dv.orig.getScrollInfo().top;
287289 for (var i = 0; i < dv.chunks.length; i++) {
288290 var ch = dv.chunks[i];
289291 if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from &&
426428
427429 function copyChunk(dv, to, from, chunk) {
428430 if (dv.diffOutOfDate) return;
429 to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
430 Pos(chunk.editFrom, 0), Pos(chunk.editTo, 0));
431 var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
432 var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
433 to.replaceRange(from.getRange(origStart, Pos(chunk.origTo, 0)), editStart, Pos(chunk.editTo, 0))
431434 }
432435
433436 // Merge view, containing 0, 1, or 2 diff views.
470473 if (left) left.init(leftPane, origLeft, options);
471474 if (right) right.init(rightPane, origRight, options);
472475
473 if (options.collapseIdentical) {
474 updating = true;
476 if (options.collapseIdentical)
475477 this.editor().operation(function() {
476478 collapseIdenticalStretches(self, options.collapseIdentical);
477479 });
478 updating = false;
479 }
480480 if (options.connect == "align") {
481481 this.aligners = [];
482482 alignChunks(this.left || this.right, true);
639639 mark.clear();
640640 cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
641641 }
642 widget.addEventListener("click", clear);
642 CodeMirror.on(widget, "click", clear);
643643 return {mark: mark, clear: clear};
644644 }
645645
5050 if (!other.parseDelimiters) stream.match(other.open);
5151 state.innerActive = other;
5252 state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);
53 return other.delimStyle;
53 return other.delimStyle && (other.delimStyle + " " + other.delimStyle + "-open");
5454 } else if (found != -1 && found < cutOff) {
5555 cutOff = found;
5656 }
6969 if (found == stream.pos && !curInner.parseDelimiters) {
7070 stream.match(curInner.close);
7171 state.innerActive = state.inner = null;
72 return curInner.delimStyle;
72 return curInner.delimStyle && (curInner.delimStyle + " " + curInner.delimStyle + "-close");
7373 }
7474 if (found > -1) stream.string = oldContent.slice(0, found);
7575 var innerToken = curInner.mode.token(stream, state.inner);
7979 state.innerActive = state.inner = null;
8080
8181 if (curInner.innerStyle) {
82 if (innerToken) innerToken = innerToken + ' ' + curInner.innerStyle;
82 if (innerToken) innerToken = innerToken + " " + curInner.innerStyle;
8383 else innerToken = curInner.innerStyle;
8484 }
8585
2828
2929 MT(
3030 "stexInsideMarkdown",
31 "[strong **Equation:**] [delim $][inner&tag \\pi][delim $]");
31 "[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]");
3232 })();
5959
6060 function ensureState(states, name) {
6161 if (!states.hasOwnProperty(name))
62 throw new Error("Undefined state " + name + "in simple mode");
62 throw new Error("Undefined state " + name + " in simple mode");
6363 }
6464
6565 function toRegex(val, caret) {
1515 var ie = /MSIE \d/.test(navigator.userAgent);
1616 var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
1717
18 if (callback.nodeType == 1) {
18 if (callback.appendChild) {
1919 var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
2020 var node = callback, col = 0;
2121 node.innerHTML = "";
175175 };
176176
177177 require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")];
178 require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")];
5050 Annotation.prototype.computeScale = function() {
5151 var cm = this.cm;
5252 var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
53 cm.heightAtLine(cm.lastLine() + 1, "local");
53 cm.getScrollerElement().scrollHeight
5454 if (hScale != this.hScale) {
5555 this.hScale = hScale;
5656 return true;
9999 elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
100100 + (top + this.buttonHeight) + "px; height: " + height + "px";
101101 elt.className = this.options.className;
102 if (ann.id) {
103 elt.setAttribute("annotation-id", ann.id);
104 }
102105 }
103106 this.div.textContent = "";
104107 this.div.appendChild(frag);
3939 if (cm.state.scrollPastEndPadding != padding) {
4040 cm.state.scrollPastEndPadding = padding;
4141 cm.display.lineSpace.parentNode.style.paddingBottom = padding;
42 cm.off("refresh", updateBottomMargin);
4243 cm.setSize();
44 cm.on("refresh", updateBottomMargin);
4345 }
4446 }
4547 });
5858 CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
5959 }
6060
61 Bar.prototype.moveTo = function(pos, update) {
61 Bar.prototype.setPos = function(pos, force) {
6262 if (pos < 0) pos = 0;
6363 if (pos > this.total - this.screen) pos = this.total - this.screen;
64 if (pos == this.pos) return;
64 if (!force && pos == this.pos) return false;
6565 this.pos = pos;
6666 this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
6767 (pos * (this.size / this.total)) + "px";
68 if (update !== false) this.scroll(pos, this.orientation);
68 return true
6969 };
70
71 Bar.prototype.moveTo = function(pos) {
72 if (this.setPos(pos)) this.scroll(pos, this.orientation);
73 }
7074
7175 var minButtonSize = 10;
7276
7377 Bar.prototype.update = function(scrollSize, clientSize, barSize) {
74 this.screen = clientSize;
75 this.total = scrollSize;
76 this.size = barSize;
78 var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize
79 if (sizeChanged) {
80 this.screen = clientSize;
81 this.total = scrollSize;
82 this.size = barSize;
83 }
7784
7885 var buttonSize = this.screen * (this.size / this.total);
7986 if (buttonSize < minButtonSize) {
8289 }
8390 this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
8491 buttonSize + "px";
85 this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
86 this.pos * (this.size / this.total) + "px";
92 this.setPos(this.pos, sizeChanged);
8793 };
8894
8995 function SimpleScrollbars(cls, place, scroll) {
110116 if (needsV) {
111117 this.vert.update(measure.scrollHeight, measure.clientHeight,
112118 measure.viewHeight - (needsH ? width : 0));
113 this.vert.node.style.display = "block";
114119 this.vert.node.style.bottom = needsH ? width + "px" : "0";
115120 }
116121 if (needsH) {
124129 };
125130
126131 SimpleScrollbars.prototype.setScrollTop = function(pos) {
127 this.vert.moveTo(pos, false);
132 this.vert.setPos(pos);
128133 };
129134
130135 SimpleScrollbars.prototype.setScrollLeft = function(pos) {
131 this.horiz.moveTo(pos, false);
136 this.horiz.setPos(pos);
132137 };
133138
134139 SimpleScrollbars.prototype.clear = function() {
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 // Defines jumpToLine command. Uses dialog.js if present.
4
5 (function(mod) {
6 if (typeof exports == "object" && typeof module == "object") // CommonJS
7 mod(require("../../lib/codemirror"), require("../dialog/dialog"));
8 else if (typeof define == "function" && define.amd) // AMD
9 define(["../../lib/codemirror", "../dialog/dialog"], mod);
10 else // Plain browser env
11 mod(CodeMirror);
12 })(function(CodeMirror) {
13 "use strict";
14
15 function dialog(cm, text, shortText, deflt, f) {
16 if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
17 else f(prompt(shortText, deflt));
18 }
19
20 var jumpDialog =
21 'Jump to line: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use line:column or scroll% syntax)</span>';
22
23 function interpretLine(cm, string) {
24 var num = Number(string)
25 if (/^[-+]/.test(string)) return cm.getCursor().line + num
26 else return num - 1
27 }
28
29 CodeMirror.commands.jumpToLine = function(cm) {
30 var cur = cm.getCursor();
31 dialog(cm, jumpDialog, "Jump to line:", (cur.line + 1) + ":" + cur.ch, function(posStr) {
32 if (!posStr) return;
33
34 var match;
35 if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) {
36 cm.setCursor(interpretLine(cm, match[1]), Number(match[2]))
37 } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
38 var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
39 if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
40 cm.setCursor(line - 1, cur.ch);
41 } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) {
42 cm.setCursor(interpretLine(cm, match[1]), cur.ch);
43 }
44 });
45 };
46
47 CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine";
48 });
1515 // highlighted only if the selected text is a word. showToken, when enabled,
1616 // will cause the current token to be highlighted when nothing is selected.
1717 // delay is used to specify how much time to wait, in milliseconds, before
18 // highlighting the matches.
18 // highlighting the matches. If annotateScrollbar is enabled, the occurences
19 // will be highlighted on the scrollbar via the matchesonscrollbar addon.
1920
2021 (function(mod) {
2122 if (typeof exports == "object" && typeof module == "object") // CommonJS
22 mod(require("../../lib/codemirror"));
23 mod(require("../../lib/codemirror"), require("./matchesonscrollbar"));
2324 else if (typeof define == "function" && define.amd) // AMD
24 define(["../../lib/codemirror"], mod);
25 define(["../../lib/codemirror", "./matchesonscrollbar"], mod);
2526 else // Plain browser env
2627 mod(CodeMirror);
2728 })(function(CodeMirror) {
2829 "use strict";
2930
30 var DEFAULT_MIN_CHARS = 2;
31 var DEFAULT_TOKEN_STYLE = "matchhighlight";
32 var DEFAULT_DELAY = 100;
33 var DEFAULT_WORDS_ONLY = false;
31 var defaults = {
32 style: "matchhighlight",
33 minChars: 2,
34 delay: 100,
35 wordsOnly: false,
36 annotateScrollbar: false,
37 showToken: false,
38 trim: true
39 }
3440
3541 function State(options) {
36 if (typeof options == "object") {
37 this.minChars = options.minChars;
38 this.style = options.style;
39 this.showToken = options.showToken;
40 this.delay = options.delay;
41 this.wordsOnly = options.wordsOnly;
42 }
43 if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
44 if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
45 if (this.delay == null) this.delay = DEFAULT_DELAY;
46 if (this.wordsOnly == null) this.wordsOnly = DEFAULT_WORDS_ONLY;
42 this.options = {}
43 for (var name in defaults)
44 this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
4745 this.overlay = this.timeout = null;
46 this.matchesonscroll = null;
47 this.active = false;
4848 }
4949
5050 CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
5151 if (old && old != CodeMirror.Init) {
52 var over = cm.state.matchHighlighter.overlay;
53 if (over) cm.removeOverlay(over);
52 removeOverlay(cm);
5453 clearTimeout(cm.state.matchHighlighter.timeout);
5554 cm.state.matchHighlighter = null;
5655 cm.off("cursorActivity", cursorActivity);
56 cm.off("focus", onFocus)
5757 }
5858 if (val) {
59 cm.state.matchHighlighter = new State(val);
60 highlightMatches(cm);
59 var state = cm.state.matchHighlighter = new State(val);
60 if (cm.hasFocus()) {
61 state.active = true
62 highlightMatches(cm)
63 } else {
64 cm.on("focus", onFocus)
65 }
6166 cm.on("cursorActivity", cursorActivity);
6267 }
6368 });
6469
6570 function cursorActivity(cm) {
6671 var state = cm.state.matchHighlighter;
72 if (state.active || cm.hasFocus()) scheduleHighlight(cm, state)
73 }
74
75 function onFocus(cm) {
76 var state = cm.state.matchHighlighter
77 if (!state.active) {
78 state.active = true
79 scheduleHighlight(cm, state)
80 }
81 }
82
83 function scheduleHighlight(cm, state) {
6784 clearTimeout(state.timeout);
68 state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay);
85 state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
86 }
87
88 function addOverlay(cm, query, hasBoundary, style) {
89 var state = cm.state.matchHighlighter;
90 cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
91 if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
92 var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
93 state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
94 {className: "CodeMirror-selection-highlight-scrollbar"});
95 }
96 }
97
98 function removeOverlay(cm) {
99 var state = cm.state.matchHighlighter;
100 if (state.overlay) {
101 cm.removeOverlay(state.overlay);
102 state.overlay = null;
103 if (state.matchesonscroll) {
104 state.matchesonscroll.clear();
105 state.matchesonscroll = null;
106 }
107 }
69108 }
70109
71110 function highlightMatches(cm) {
72111 cm.operation(function() {
73112 var state = cm.state.matchHighlighter;
74 if (state.overlay) {
75 cm.removeOverlay(state.overlay);
76 state.overlay = null;
77 }
78 if (!cm.somethingSelected() && state.showToken) {
79 var re = state.showToken === true ? /[\w$]/ : state.showToken;
113 removeOverlay(cm);
114 if (!cm.somethingSelected() && state.options.showToken) {
115 var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
80116 var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
81117 while (start && re.test(line.charAt(start - 1))) --start;
82118 while (end < line.length && re.test(line.charAt(end))) ++end;
83119 if (start < end)
84 cm.addOverlay(state.overlay = makeOverlay(line.slice(start, end), re, state.style));
120 addOverlay(cm, line.slice(start, end), re, state.options.style);
85121 return;
86122 }
87123 var from = cm.getCursor("from"), to = cm.getCursor("to");
88124 if (from.line != to.line) return;
89 if (state.wordsOnly && !isWord(cm, from, to)) return;
90 var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
91 if (selection.length >= state.minChars)
92 cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style));
125 if (state.options.wordsOnly && !isWord(cm, from, to)) return;
126 var selection = cm.getRange(from, to)
127 if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "")
128 if (selection.length >= state.options.minChars)
129 addOverlay(cm, selection, false, state.options.style);
93130 });
94131 }
95132
1717 mod(CodeMirror);
1818 })(function(CodeMirror) {
1919 "use strict";
20
2021 function searchOverlay(query, caseInsensitive) {
2122 if (typeof query == "string")
2223 query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
2728 query.lastIndex = stream.pos;
2829 var match = query.exec(stream.string);
2930 if (match && match.index == stream.pos) {
30 stream.pos += match[0].length;
31 stream.pos += match[0].length || 1;
3132 return "searching";
3233 } else if (match) {
3334 stream.pos = match.index;
4142 this.posFrom = this.posTo = this.lastQuery = this.query = null;
4243 this.overlay = null;
4344 }
45
4446 function getSearchState(cm) {
4547 return cm.state.search || (cm.state.search = new SearchState());
4648 }
49
4750 function queryCaseInsensitive(query) {
4851 return typeof query == "string" && query == query.toLowerCase();
4952 }
53
5054 function getSearchCursor(cm, query, pos) {
5155 // Heuristic: if the query string is all lowercase, do a case insensitive search.
5256 return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
5357 }
58
59 function persistentDialog(cm, text, deflt, onEnter, onKeyDown) {
60 cm.openDialog(text, onEnter, {
61 value: deflt,
62 selectValueOnOpen: true,
63 closeOnEnter: false,
64 onClose: function() { clearSearch(cm); },
65 onKeyDown: onKeyDown
66 });
67 }
68
5469 function dialog(cm, text, shortText, deflt, f) {
5570 if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
5671 else f(prompt(shortText, deflt));
5772 }
73
5874 function confirmDialog(cm, text, shortText, fs) {
5975 if (cm.openConfirm) cm.openConfirm(text, fs);
6076 else if (confirm(shortText)) fs[0]();
6177 }
78
79 function parseString(string) {
80 return string.replace(/\\(.)/g, function(_, ch) {
81 if (ch == "n") return "\n"
82 if (ch == "r") return "\r"
83 return ch
84 })
85 }
86
6287 function parseQuery(query) {
6388 var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
6489 if (isRE) {
6590 try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
6691 catch(e) {} // Not a regular expression after all, do a string search
92 } else {
93 query = parseString(query)
6794 }
6895 if (typeof query == "string" ? query == "" : query.test(""))
6996 query = /x^/;
7097 return query;
7198 }
99
72100 var queryDialog =
73101 'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
74 function doSearch(cm, rev) {
102
103 function startSearch(cm, state, query) {
104 state.queryText = query;
105 state.query = parseQuery(query);
106 cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
107 state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
108 cm.addOverlay(state.overlay);
109 if (cm.showMatchesOnScrollbar) {
110 if (state.annotate) { state.annotate.clear(); state.annotate = null; }
111 state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
112 }
113 }
114
115 function doSearch(cm, rev, persistent, immediate) {
75116 var state = getSearchState(cm);
76117 if (state.query) return findNext(cm, rev);
77118 var q = cm.getSelection() || state.lastQuery;
78 dialog(cm, queryDialog, "Search for:", q, function(query) {
79 cm.operation(function() {
80 if (!query || state.query) return;
81 state.query = parseQuery(query);
82 cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
83 state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
84 cm.addOverlay(state.overlay);
85 if (cm.showMatchesOnScrollbar) {
86 if (state.annotate) { state.annotate.clear(); state.annotate = null; }
87 state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
119 if (persistent && cm.openDialog) {
120 var hiding = null
121 var searchNext = function(query, event) {
122 CodeMirror.e_stop(event);
123 if (!query) return;
124 if (query != state.queryText) {
125 startSearch(cm, state, query);
126 state.posFrom = state.posTo = cm.getCursor();
88127 }
89 state.posFrom = state.posTo = cm.getCursor();
128 if (hiding) hiding.style.opacity = 1
129 findNext(cm, event.shiftKey, function(_, to) {
130 var dialog
131 if (to.line < 3 && document.querySelector &&
132 (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
133 dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
134 (hiding = dialog).style.opacity = .4
135 })
136 };
137 persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
138 var keyName = CodeMirror.keyName(event)
139 var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
140 if (!cmd) cmd = cm.getOption('extraKeys')[keyName]
141 if (cmd == "findNext" || cmd == "findPrev" ||
142 cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
143 CodeMirror.e_stop(event);
144 startSearch(cm, getSearchState(cm), query);
145 cm.execCommand(cmd);
146 } else if (cmd == "find" || cmd == "findPersistent") {
147 CodeMirror.e_stop(event);
148 searchNext(query, event);
149 }
150 });
151 if (immediate && q) {
152 startSearch(cm, state, q);
90153 findNext(cm, rev);
154 }
155 } else {
156 dialog(cm, queryDialog, "Search for:", q, function(query) {
157 if (query && !state.query) cm.operation(function() {
158 startSearch(cm, state, query);
159 state.posFrom = state.posTo = cm.getCursor();
160 findNext(cm, rev);
161 });
91162 });
92 });
93 }
94 function findNext(cm, rev) {cm.operation(function() {
163 }
164 }
165
166 function findNext(cm, rev, callback) {cm.operation(function() {
95167 var state = getSearchState(cm);
96168 var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
97169 if (!cursor.find(rev)) {
99171 if (!cursor.find(rev)) return;
100172 }
101173 cm.setSelection(cursor.from(), cursor.to());
102 cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
174 cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20);
103175 state.posFrom = cursor.from(); state.posTo = cursor.to();
176 if (callback) callback(cursor.from(), cursor.to())
104177 });}
178
105179 function clearSearch(cm) {cm.operation(function() {
106180 var state = getSearchState(cm);
107181 state.lastQuery = state.query;
108182 if (!state.query) return;
109 state.query = null;
183 state.query = state.queryText = null;
110184 cm.removeOverlay(state.overlay);
111185 if (state.annotate) { state.annotate.clear(); state.annotate = null; }
112186 });}
113187
114188 var replaceQueryDialog =
115 'Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
189 ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
116190 var replacementQueryDialog = 'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
117 var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";
191 var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>All</button> <button>Stop</button>";
192
193 function replaceAll(cm, query, text) {
194 cm.operation(function() {
195 for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
196 if (typeof query != "string") {
197 var match = cm.getRange(cursor.from(), cursor.to()).match(query);
198 cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
199 } else cursor.replace(text);
200 }
201 });
202 }
203
118204 function replace(cm, all) {
119205 if (cm.getOption("readOnly")) return;
120206 var query = cm.getSelection() || getSearchState(cm).lastQuery;
121 dialog(cm, replaceQueryDialog, "Replace:", query, function(query) {
207 var dialogText = all ? "Replace all:" : "Replace:"
208 dialog(cm, dialogText + replaceQueryDialog, dialogText, query, function(query) {
122209 if (!query) return;
123210 query = parseQuery(query);
124211 dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
212 text = parseString(text)
125213 if (all) {
126 cm.operation(function() {
127 for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
128 if (typeof query != "string") {
129 var match = cm.getRange(cursor.from(), cursor.to()).match(query);
130 cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
131 } else cursor.replace(text);
132 }
133 });
214 replaceAll(cm, query, text)
134215 } else {
135216 clearSearch(cm);
136 var cursor = getSearchCursor(cm, query, cm.getCursor());
217 var cursor = getSearchCursor(cm, query, cm.getCursor("from"));
137218 var advance = function() {
138219 var start = cursor.from(), match;
139220 if (!(match = cursor.findNext())) {
144225 cm.setSelection(cursor.from(), cursor.to());
145226 cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
146227 confirmDialog(cm, doReplaceConfirm, "Replace?",
147 [function() {doReplace(match);}, advance]);
228 [function() {doReplace(match);}, advance,
229 function() {replaceAll(cm, query, text)}]);
148230 };
149231 var doReplace = function(match) {
150232 cursor.replace(typeof query == "string" ? text :
158240 }
159241
160242 CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
243 CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
244 CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);};
245 CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);};
161246 CodeMirror.commands.findNext = doSearch;
162247 CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
163248 CodeMirror.commands.clearSearch = clearSearch;
1717 "use strict";
1818 var WRAP_CLASS = "CodeMirror-activeline";
1919 var BACK_CLASS = "CodeMirror-activeline-background";
20 var GUTT_CLASS = "CodeMirror-activeline-gutter";
2021
2122 CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
2223 var prev = old && old != CodeMirror.Init;
3536 for (var i = 0; i < cm.state.activeLines.length; i++) {
3637 cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
3738 cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
39 cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
3840 }
3941 }
4042
5961 for (var i = 0; i < active.length; i++) {
6062 cm.addLineClass(active[i], "wrap", WRAP_CLASS);
6163 cm.addLineClass(active[i], "background", BACK_CLASS);
64 cm.addLineClass(active[i], "gutter", GUTT_CLASS);
6265 }
6366 cm.state.activeLines = active;
6467 });
00 .CodeMirror-Tern-completion {
11 padding-left: 22px;
22 position: relative;
3 line-height: 1.5;
34 }
45 .CodeMirror-Tern-completion:before {
56 position: absolute;
134134 },
135135
136136 destroy: function () {
137 closeArgHints(this)
137138 if (this.worker) {
138139 this.worker.terminate();
139140 this.worker = null;
177178 var data = findDoc(ts, doc);
178179
179180 var argHints = ts.cachedArgHints;
180 if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) <= 0)
181 if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) >= 0)
181182 ts.cachedArgHints = null;
182183
183184 var changed = data.changed;
215216 var completion = data.completions[i], className = typeToIcon(completion.type);
216217 if (data.guess) className += " " + cls + "guess";
217218 completions.push({text: completion.name + after,
218 displayText: completion.name,
219 displayText: completion.displayName || completion.name,
219220 className: className,
220221 data: completion});
221222 }
265266 child.target = "_blank";
266267 }
267268 }
268 tempTooltip(cm, tip);
269 tempTooltip(cm, tip, ts);
269270 if (c) c();
270271 }, pos);
271272 }
304305 ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) {
305306 if (error || !data.type || !(/^fn\(/).test(data.type)) return;
306307 ts.cachedArgHints = {
307 start: pos,
308 start: start,
308309 type: parseFnType(data.type),
309310 name: data.exprName || data.name || "fn",
310311 guess: data.guess,
465466 ts.request(cm, {type: "refs"}, function(error, data) {
466467 if (error) return showError(ts, cm, error);
467468 var ranges = [], cur = 0;
469 var curPos = cm.getCursor();
468470 for (var i = 0; i < data.refs.length; i++) {
469471 var ref = data.refs[i];
470472 if (ref.file == name) {
471473 ranges.push({anchor: ref.start, head: ref.end});
472 if (cmpPos(cur, ref.start) >= 0 && cmpPos(cur, ref.end) <= 0)
474 if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0)
473475 cur = ranges.length - 1;
474476 }
475477 }
591593
592594 // Tooltips
593595
594 function tempTooltip(cm, content) {
596 function tempTooltip(cm, content, ts) {
595597 if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
596598 var where = cm.cursorCoords();
597599 var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
615617 else mouseOnTip = false;
616618 }
617619 });
618 setTimeout(maybeClear, 1700);
620 setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700);
619621 cm.on("cursorActivity", clear);
620622 cm.on('blur', clear);
621623 cm.on('scroll', clear);
643645 if (ts.options.showError)
644646 ts.options.showError(cm, msg);
645647 else
646 tempTooltip(cm, String(msg));
648 tempTooltip(cm, String(msg), ts);
647649 }
648650
649651 function closeArgHints(ts) {
2929 }
3030
3131 function findBreakPoint(text, column, wrapOn, killTrailingSpace) {
32 for (var at = column; at > 0; --at)
32 var at = column
33 while (at < text.length && text.charAt(at) == " ") at++
34 for (; at > 0; --at)
3335 if (wrapOn.test(text.slice(at - 1, at + 1))) break;
34 if (at == 0) at = column;
35 var endOfText = at;
36 if (killTrailingSpace)
37 while (text.charAt(endOfText - 1) == " ") --endOfText;
38 return {from: endOfText, to: at};
36 for (var first = true;; first = false) {
37 var endOfText = at;
38 if (killTrailingSpace)
39 while (text.charAt(endOfText - 1) == " ") --endOfText;
40 if (endOfText == 0 && first) at = column;
41 else return {from: endOfText, to: at};
42 }
3943 }
4044
4145 function wrapRange(cm, from, to, options) {
8589 if (changes.length) cm.operation(function() {
8690 for (var i = 0; i < changes.length; ++i) {
8791 var change = changes[i];
88 cm.replaceRange(change.text, change.from, change.to);
92 if (change.text || CodeMirror.cmpPos(change.from, change.to))
93 cm.replaceRange(change.text, change.from, change.to);
8994 }
9095 });
9196 return changes.length ? {from: changes[0].from, to: CodeMirror.changeEnd(changes[changes.length - 1])} : null;
1717 // Script files are specified without .js ending. Prefixing them with
1818 // their full (local) path is optional. So you may say lib/codemirror
1919 // or mode/xml/xml to be more precise. In fact, even the .js suffix
20 // may be speficied, if wanted.
20 // may be specified, if wanted.
2121
2222 "use strict";
2323
6767 if (!local && !blob) help(false);
6868
6969 if (files.length) {
70 console.log("Some speficied files were not found: " +
70 console.log("Some specified files were not found: " +
7171 files.map(function(a){return a.name;}).join(", "));
7272 process.exit(1);
7373 }
3131
3232 child.exec("bash bin/authors.sh", function(){});
3333
34 var simple = number.slice(0, number.lastIndexOf("."));
35
3634 rewrite("doc/compress.html", function(cmp) {
3735 return cmp.replace(/<option value="http:\/\/codemirror.net\/">HEAD<\/option>/,
38 "<option value=\"http://codemirror.net/\">HEAD</option>\n <option value=\"http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=" + number + ";f=\">" + simple + "</option>");
36 "<option value=\"http://codemirror.net/\">HEAD</option>\n <option value=\"http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=" + number + ";f=\">" + number + "</option>");
3937 });
4038
4139 rewrite("index.html", function(index) {
42 return index.replace(/\.zip">\d+\.\d+<\/a>/,
43 ".zip\">" + simple + "</a>");
40 return index.replace(/\.zip">\d+\.\d+\.\d+<\/a>/,
41 ".zip\">" + number + "</a>");
4442 });
0 "use strict"
1
2 let version = process.argv[2]
3 let auth = process.argv[3]
4
5 if (!auth) {
6 console.log("Usage: upload-release.js [TAG] [github-user:password]")
7 process.exit(1)
8 }
9
10 require('child_process').exec("git --no-pager show -s --format='%s' " + version, (error, stdout) => {
11 if (error) throw error
12 let message = stdout.split("\n").slice(2)
13 message = message.slice(0, message.indexOf("-----BEGIN PGP SIGNATURE-----")).join("\n")
14
15 let req = require("https").request({
16 host: "api.github.com",
17 auth: auth,
18 headers: {"user-agent": "Release uploader"},
19 path: "/repos/codemirror/codemirror/releases",
20 method: "POST"
21 }, res => {
22 if (res.statusCode >= 300) {
23 console.error(res.statusMessage)
24 res.on("data", d => console.log(d.toString()))
25 res.on("end", process.exit(1))
26 }
27 })
28 req.write(JSON.stringify({
29 tag_name: version,
30 name: version,
31 body: message
32 }))
33 req.end()
34 })
0 <!doctype html>
0 <!doctype html>
11
22 <title>CodeMirror: B-Tree visualization</title>
33 <meta charset="utf-8"/>
2525 <article>
2626 <h2>B-Tree visualization</h2>
2727 <form><textarea id="code" name="code">type here, see a summary of the document b-tree below</textarea></form>
28 </div>
2928 <div style="display: inline-block; height: 402px; overflow-y: auto" id="output"></div>
30 </div>
3129
3230 <script id="me">
3331 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
99 <script src="../addon/hint/show-hint.js"></script>
1010 <script src="../addon/hint/javascript-hint.js"></script>
1111 <script src="../mode/javascript/javascript.js"></script>
12 <script src="../mode/markdown/markdown.js"></script>
1213
1314 <div id=nav>
1415 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
6869 and <a href="../doc/manual.html#addon_javascript-hint"><code>javascript-hint</code></a>
6970 addons.</p>
7071
71 <script>
72 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
73 lineNumbers: true,
74 extraKeys: {"Ctrl-Space": "autocomplete"},
75 mode: {name: "javascript", globalVars: true}
76 });
77 </script>
78 </article>
72 <form><textarea style="display: none" id="synonyms" name="synonyms">
73 Here, the completion use an asynchronous hinting functions to provide
74 synonyms for each words. If your browser support `Promises`, the
75 hinting function can also return one.
76 </textarea></form>
77
78 <script>
79 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
80 lineNumbers: true,
81 extraKeys: {"Ctrl-Space": "autocomplete"},
82 mode: {name: "javascript", globalVars: true}
83 });
84
85 if (typeof Promise !== undefined) {
86 var comp = [
87 ["here", "hither"],
88 ["asynchronous", "nonsynchronous"],
89 ["completion", "achievement", "conclusion", "culmination", "expirations"],
90 ["hinting", "advive", "broach", "imply"],
91 ["function","action"],
92 ["provide", "add", "bring", "give"],
93 ["synonyms", "equivalents"],
94 ["words", "token"],
95 ["each", "every"],
96 ]
97
98 function synonyms(cm, option) {
99 return new Promise(function(accept) {
100 setTimeout(function() {
101 var cursor = cm.getCursor(), line = cm.getLine(cursor.line)
102 var start = cursor.ch, end = cursor.ch
103 while (start && /\w/.test(line.charAt(start - 1))) --start
104 while (end < line.length && /\w/.test(line.charAt(end))) ++end
105 var word = line.slice(start, end).toLowerCase()
106 for (var i = 0; i < comp.length; i++) if (comp[i].indexOf(word) != -1)
107 return accept({list: comp[i],
108 from: CodeMirror.Pos(cursor.line, start),
109 to: CodeMirror.Pos(cursor.line, end)})
110 return accept(null)
111 }, 100)
112 })
113 }
114
115 var editor2 = CodeMirror.fromTextArea(document.getElementById("synonyms"), {
116 extraKeys: {"Ctrl-Space": "autocomplete"},
117 lineNumbers: true,
118 lineWrapping: true,
119 mode: "text/x-markdown",
120 hintOptions: {hint: synonyms}
121 })
122 }
123 </script>
124
125 </article>
5959 "Ctrl-Q": function(cm) { cm.wrapParagraph(cm.getCursor(), options); }
6060 }
6161 });
62 var wait, options = {column: 60};
62 var wait, options = {column: 60}, changing = false;
6363 editor.on("change", function(cm, change) {
64 if (changing) return;
6465 clearTimeout(wait);
6566 wait = setTimeout(function() {
66 console.log(cm.wrapParagraphsInRange(change.from, CodeMirror.changeEnd(change), options));
67 changing = true;
68 cm.wrapParagraphsInRange(change.from, CodeMirror.changeEnd(change), options);
69 changing = false;
6770 }, 200);
6871 });
6972 </script>
1010 <script src="../mode/css/css.js"></script>
1111 <script src="//ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>
1212 <script src="https://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>
13 <script src="https://rawgithub.com/stubbornella/csslint/master/release/csslint.js"></script>
1413 <script src="../addon/lint/lint.js"></script>
1514 <script src="../addon/lint/javascript-lint.js"></script>
1615 <script src="../addon/lint/json-lint.js"></script>
17 <script src="../addon/lint/css-lint.js"></script>
1816 <style type="text/css">
1917 .CodeMirror {border: 1px solid black;}
2018 </style>
8482 ]
8583 </textarea></p>
8684
87 <p><textarea id="code-css">@charset "UTF-8";
88
89 @import url("booya.css") print, screen;
90 @import "whatup.css" screen;
91 @import "wicked.css";
92
93 /*Error*/
94 @charset "UTF-8";
95
96
97 @namespace "http://www.w3.org/1999/xhtml";
98 @namespace svg "http://www.w3.org/2000/svg";
99
100 /*Warning: empty ruleset */
101 .foo {
102 }
103
104 h1 {
105 font-weight: bold;
106 }
107
108 /*Warning: qualified heading */
109 .foo h1 {
110 font-weight: bold;
111 }
112
113 /*Warning: adjoining classes */
114 .foo.bar {
115 zoom: 1;
116 }
117
118 li.inline {
119 width: 100%; /*Warning: 100% can be problematic*/
120 }
121
122 li.last {
123 display: inline;
124 padding-left: 3px !important;
125 padding-right: 3px;
126 border-right: 0px;
127 }
128
129 @media print {
130 li.inline {
131 color: black;
132 }
133 }
134
135 @page {
136 margin: 10%;
137 counter-increment: page;
138
139 @top-center {
140 font-family: sans-serif;
141 font-weight: bold;
142 font-size: 2em;
143 content: counter(page);
144 }
145 }
146 </textarea></p>
14785 <script>
14886 var editor = CodeMirror.fromTextArea(document.getElementById("code-js"), {
14987 lineNumbers: true,
15997 lint: true
16098 });
16199
162 var editor_css = CodeMirror.fromTextArea(document.getElementById("code-css"), {
163 lineNumbers: true,
164 mode: "css",
165 gutters: ["CodeMirror-lint-markers"],
166 lint: true
167 });
168100 </script>
169101
170102 </article>
55
66 <link rel="stylesheet" href="../lib/codemirror.css">
77 <script src="../lib/codemirror.js"></script>
8 <script src="../addon/scroll/annotatescrollbar.js"></script>
9 <script src="../addon/search/matchesonscrollbar.js"></script>
810 <script src="../addon/search/searchcursor.js"></script>
911 <script src="../addon/search/match-highlighter.js"></script>
1012 <style type="text/css">
1416 background-position: bottom;
1517 background-repeat: repeat-x;
1618 }
19 .cm-matchhighlight {background-color: lightgreen}
20 .CodeMirror-selection-highlight-scrollbar {background-color: green}
1721 </style>
1822 <div id=nav>
1923 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
3034
3135 <article>
3236 <h2>Match Highlighter Demo</h2>
33 <form><textarea id="code" name="code">Select this text: hardToSpotVar
34 And everywhere else in your code where hardToSpotVar appears will automatically illuminate.
35 Give it a try! No more hardToSpotVars.</textarea></form>
37 <form><textarea id="code" name="code">Select this text: hardtospot
38 And everywhere else in your code where hardtospot appears will
39 automatically illuminate. Give it a try! No more hard to spot
40 variables - stay in context of your code all the time.
41
42 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut pharetra
43 interdum dui eu pulvinar. Mauris maximus ligula venenatis tempus
44 interdum. Cras hendrerit, ipsum sed ultrices pharetra, ligula diam
45 porttitor lacus, ac tempor eros est a massa. Nam orci elit, vulputate
46 in tristique quis, consectetur vitae metus. Pellentesque et enim
47 elementum, lobortis augue in, lacinia sapien. Morbi eu nunc semper,
48 sagittis felis a, pellentesque mauris. Lorem ipsum dolor sit amet,
49 consectetur adipiscing elit. Aenean quis diam turpis.
50
51 Fusce lobortis nisl quis aliquet euismod. Aenean vitae nulla non ipsum
52 efficitur scelerisque. Curabitur auctor, lorem non rhoncus porttitor,
53 augue ligula lacinia dolor, et vehicula magna lorem imperdiet velit.
54 Fusce risus sem, hardtospot commodo eleifend hendrerit vitae, mollis
55 quis risus. Cras tincidunt, justo vitae hendrerit venenatis, urna
56 dolor placerat tortor, eu lobortis lectus dolor in ligula. Nullam non
57 erat non nisl vulputate ultrices sit amet vestibulum dolor. Quisque in
58 tortor porta, pellentesque odio nec, malesuada nibh.
59
60 In a dui feugiat, ullamcorper urna in, accumsan magna. Donec egestas
61 sem nec eros rhoncus, vel gravida purus ornare. Nulla orci mauris,
62 porta nec pharetra sed, ornare et lorem. Donec luctus turpis nunc,
63 eget dictum felis mollis et. Sed sodales hardtospot nunc vitae leo
64 rhoncus imperdiet. Donec elementum malesuada velit quis placerat.
65 Proin accumsan lorem id nisi volutpat ullamcorper. Vivamus laoreet
66 dolor ac sem malesuada, ac scelerisque ex efficitur. Aliquam tempus
67 libero velit, vel tristique augue vulputate nec.
68
69 Mauris ultrices leo felis, sit amet congue augue aliquam condimentum.
70 Vivamus purus leo, mattis vitae dignissim vel, ultricies ac ex. Mauris
71 eu dolor eu purus ultricies ultrices. Sed euismod feugiat ex et
72 mattis. Morbi cursus laoreet pharetra. Donec eu dolor sodales,
73 ultricies nisi et, malesuada urna. Praesent sit amet fringilla felis.
74 Nam rhoncus, est blandit auctor auctor, lorem ipsum laoreet ipsum,
75 quis sodales libero odio in lorem. Phasellus odio dolor, elementum
76 sagittis nibh non, fermentum semper libero. Mauris hendrerit
77 hardtospot lectus sit amet commodo eleifend. Morbi pulvinar eget nisl
78 at eleifend. Fusce eget porta erat, vitae lobortis libero.
79
80 Phasellus sit amet massa in massa pharetra malesuada. Vestibulum at
81 quam vel libero aliquam volutpat at ut dui. Praesent scelerisque vel
82 mauris sit amet vehicula. Phasellus at mi nec ligula cursus interdum
83 sit amet non quam. Aliquam tempus sollicitudin euismod. Nulla euismod
84 mollis enim tincidunt placerat. Proin ac scelerisque enim, quis
85 sollicitudin metus. Pellentesque congue nec sapien ut rhoncus. Sed
86 eget ornare diam, ut consectetur ante. Aenean eleifend mauris quis
87 ornare accumsan. In hac habitasse hardtospot platea dictumst.
88
89 </textarea></form>
3690
3791 <script>
3892 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
3993 lineNumbers: true,
40 highlightSelectionMatches: {showToken: /\w/}
94 // To highlight on scrollbars as well, pass annotateScrollbar in options
95 // as below.
96 highlightSelectionMatches: {showToken: /\w/, annotateScrollbar: true}
4197 });
4298 </script>
4399
1010 <script src="../mode/css/css.js"></script>
1111 <script src="../mode/javascript/javascript.js"></script>
1212 <script src="../mode/htmlmixed/htmlmixed.js"></script>
13 <script src="//cdnjs.cloudflare.com/ajax/libs/diff_match_patch/20121119/diff_match_patch.js"></script>
13 <script src="https://cdnjs.cloudflare.com/ajax/libs/diff_match_patch/20121119/diff_match_patch.js"></script>
1414 <script src="../addon/merge/merge.js"></script>
1515 <style>
1616 .CodeMirror { line-height: 1.2; }
4242
4343 <p>Running a CodeMirror mode outside of the editor.
4444 The <code>CodeMirror.runMode</code> function, defined
45 in <code><a href="../addon/runmode/runmode.js">lib/runmode.js</a></code> takes the following arguments:</p>
45 in <code><a href="../addon/runmode/runmode.js">addon/runmode/runmode.js</a></code> takes the following arguments:</p>
4646
4747 <dl>
4848 <dt><code>text (string)</code></dt>
1313 <script src="../addon/search/search.js"></script>
1414 <script src="../addon/scroll/annotatescrollbar.js"></script>
1515 <script src="../addon/search/matchesonscrollbar.js"></script>
16 <script src="../addon/search/jump-to-line.js"></script>
1617 <style type="text/css">
1718 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
1819 dt {font-family: monospace; color: #666;}
7071 <script>
7172 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
7273 mode: "text/html",
73 lineNumbers: true
74 lineNumbers: true,
75 extraKeys: {"Alt-F": "findPersistent"}
7476 });
7577 </script>
7678
7779 <p>Demonstration of primitive search/replace functionality. The
78 keybindings (which can be overridden by custom keymaps) are:</p>
80 keybindings (which can be configured with custom keymaps) are:</p>
7981 <dl>
8082 <dt>Ctrl-F / Cmd-F</dt><dd>Start searching</dd>
8183 <dt>Ctrl-G / Cmd-G</dt><dd>Find next</dd>
8284 <dt>Shift-Ctrl-G / Shift-Cmd-G</dt><dd>Find previous</dd>
8385 <dt>Shift-Ctrl-F / Cmd-Option-F</dt><dd>Replace</dd>
8486 <dt>Shift-Ctrl-R / Shift-Cmd-Option-F</dt><dd>Replace all</dd>
87 <dt>Alt-F</dt><dd>Persistent search (dialog doesn't autoclose,
88 enter to find next, Shift-Enter to find previous)</dd>
89 <dt>Alt-G</dt><dd>Jump to line</dd>
8590 </dl>
8691 <p>Searching is enabled by
8792 including <a href="../addon/search/search.js">addon/search/search.js</a>
8893 and <a href="../addon/search/searchcursor.js">addon/search/searchcursor.js</a>.
89 For good-looking input dialogs, you also want to include
94 Jump to line - including <a href="../addon/search/jumpToLine.js">addon/search/jumpToLine.js</a>.</p>
95 <p>For good-looking input dialogs, you also want to include
9096 <a href="../addon/dialog/dialog.js">addon/dialog/dialog.js</a>
9197 and <a href="../addon/dialog/dialog.css">addon/dialog/dialog.css</a>.</p>
9298 </article>
131131 // The start state contains the rules that are intially used
132132 start: [
133133 // The regex matches the token, the token property contains the type
134 {regex: /"(?:[^\\]|\\.)*?"/, token: "string"},
134 {regex: /"(?:[^\\]|\\.)*?(?:"|$)/, token: "string"},
135135 // You can match multiple tokens at once. Note that the captured
136136 // groups must span the whole string in this case
137137 {regex: /(function)(\s+)([a-z$][\w$]*)/,
6868 autoCloseBrackets: true,
6969 matchBrackets: true,
7070 showCursorWhenSelecting: true,
71 theme: "monokai"
71 theme: "monokai",
72 tabSize: 2
7273 });
7374 </script>
7475
1212 <script src="../addon/dialog/dialog.js"></script>
1313 <script src="../addon/hint/show-hint.js"></script>
1414 <script src="../addon/tern/tern.js"></script>
15 <script src="http://ternjs.net/node_modules/acorn/dist/acorn.js"></script>
16 <script src="http://ternjs.net/node_modules/acorn/dist/acorn_loose.js"></script>
17 <script src="http://ternjs.net/node_modules/acorn/dist/walk.js"></script>
18 <script src="http://ternjs.net/doc/demo/polyfill.js"></script>
19 <script src="http://ternjs.net/lib/signal.js"></script>
20 <script src="http://ternjs.net/lib/tern.js"></script>
21 <script src="http://ternjs.net/lib/def.js"></script>
22 <script src="http://ternjs.net/lib/comment.js"></script>
23 <script src="http://ternjs.net/lib/infer.js"></script>
24 <script src="http://ternjs.net/plugin/doc_comment.js"></script>
15 <script src="//ternjs.net/node_modules/acorn/dist/acorn.js"></script>
16 <script src="//ternjs.net/node_modules/acorn/dist/acorn_loose.js"></script>
17 <script src="//ternjs.net/node_modules/acorn/dist/walk.js"></script>
18 <script src="//ternjs.net/doc/demo/polyfill.js"></script>
19 <script src="//ternjs.net/lib/signal.js"></script>
20 <script src="//ternjs.net/lib/tern.js"></script>
21 <script src="//ternjs.net/lib/def.js"></script>
22 <script src="//ternjs.net/lib/comment.js"></script>
23 <script src="//ternjs.net/lib/infer.js"></script>
24 <script src="//ternjs.net/plugin/doc_comment.js"></script>
2525 <style>
2626 .CodeMirror {border: 1px solid #ddd;}
2727 </style>
7575
7676 var randomStr = myMod.randomElt(myMod.strList);
7777 var randomInt = myMod.randomElt(myMod.intList);
78 </textarea></p>
78 </textarea></form>
7979
8080 <p>Demonstrates integration of <a href="http://ternjs.net/">Tern</a>
8181 and CodeMirror. The following keys are bound:</p>
108108 }
109109
110110 var server;
111 getURL("http://ternjs.net/defs/ecma5.json", function(err, code) {
112 if (err) throw new Error("Request for ecma5.json: " + err);
111 getURL("//ternjs.net/defs/ecmascript.json", function(err, code) {
112 if (err) throw new Error("Request for ecmascript.json: " + err);
113113 server = new CodeMirror.TernServer({defs: [JSON.parse(code)]});
114114 editor.setOption("extraKeys", {
115115 "Ctrl-Space": function(cm) { server.complete(cm); },
66 <link rel="stylesheet" href="../lib/codemirror.css">
77 <link rel="stylesheet" href="../theme/3024-day.css">
88 <link rel="stylesheet" href="../theme/3024-night.css">
9 <link rel="stylesheet" href="../theme/abcdef.css">
910 <link rel="stylesheet" href="../theme/ambiance.css">
1011 <link rel="stylesheet" href="../theme/base16-dark.css">
12 <link rel="stylesheet" href="../theme/bespin.css">
1113 <link rel="stylesheet" href="../theme/base16-light.css">
1214 <link rel="stylesheet" href="../theme/blackboard.css">
1315 <link rel="stylesheet" href="../theme/cobalt.css">
1416 <link rel="stylesheet" href="../theme/colorforth.css">
17 <link rel="stylesheet" href="../theme/dracula.css">
1518 <link rel="stylesheet" href="../theme/eclipse.css">
1619 <link rel="stylesheet" href="../theme/elegant.css">
1720 <link rel="stylesheet" href="../theme/erlang-dark.css">
21 <link rel="stylesheet" href="../theme/hopscotch.css">
22 <link rel="stylesheet" href="../theme/icecoder.css">
23 <link rel="stylesheet" href="../theme/isotope.css">
1824 <link rel="stylesheet" href="../theme/lesser-dark.css">
1925 <link rel="stylesheet" href="../theme/liquibyte.css">
26 <link rel="stylesheet" href="../theme/material.css">
2027 <link rel="stylesheet" href="../theme/mbo.css">
2128 <link rel="stylesheet" href="../theme/mdn-like.css">
2229 <link rel="stylesheet" href="../theme/midnight.css">
2431 <link rel="stylesheet" href="../theme/neat.css">
2532 <link rel="stylesheet" href="../theme/neo.css">
2633 <link rel="stylesheet" href="../theme/night.css">
34 <link rel="stylesheet" href="../theme/panda-syntax.css">
2735 <link rel="stylesheet" href="../theme/paraiso-dark.css">
2836 <link rel="stylesheet" href="../theme/paraiso-light.css">
2937 <link rel="stylesheet" href="../theme/pastel-on-dark.css">
38 <link rel="stylesheet" href="../theme/railscasts.css">
3039 <link rel="stylesheet" href="../theme/rubyblue.css">
40 <link rel="stylesheet" href="../theme/seti.css">
3141 <link rel="stylesheet" href="../theme/solarized.css">
3242 <link rel="stylesheet" href="../theme/the-matrix.css">
3343 <link rel="stylesheet" href="../theme/tomorrow-night-bright.css">
3747 <link rel="stylesheet" href="../theme/vibrant-ink.css">
3848 <link rel="stylesheet" href="../theme/xq-dark.css">
3949 <link rel="stylesheet" href="../theme/xq-light.css">
50 <link rel="stylesheet" href="../theme/yeti.css">
4051 <link rel="stylesheet" href="../theme/zenburn.css">
4152 <script src="../lib/codemirror.js"></script>
4253 <script src="../mode/javascript/javascript.js"></script>
7889 <option selected>default</option>
7990 <option>3024-day</option>
8091 <option>3024-night</option>
92 <option>abcdef</option>
8193 <option>ambiance</option>
8294 <option>base16-dark</option>
8395 <option>base16-light</option>
96 <option>bespin</option>
8497 <option>blackboard</option>
8598 <option>cobalt</option>
8699 <option>colorforth</option>
100 <option>dracula</option>
87101 <option>eclipse</option>
88102 <option>elegant</option>
89103 <option>erlang-dark</option>
104 <option>hopscotch</option>
105 <option>icecoder</option>
106 <option>isotope</option>
90107 <option>lesser-dark</option>
91108 <option>liquibyte</option>
109 <option>material</option>
92110 <option>mbo</option>
93111 <option>mdn-like</option>
94112 <option>midnight</option>
96114 <option>neat</option>
97115 <option>neo</option>
98116 <option>night</option>
117 <option>panda-syntax</option>
99118 <option>paraiso-dark</option>
100119 <option>paraiso-light</option>
101120 <option>pastel-on-dark</option>
121 <option>railscasts</option>
102122 <option>rubyblue</option>
123 <option>seti</option>
103124 <option>solarized dark</option>
104125 <option>solarized light</option>
105126 <option>the-matrix</option>
110131 <option>vibrant-ink</option>
111132 <option>xq-dark</option>
112133 <option>xq-light</option>
134 <option>yeti</option>
113135 <option>zenburn</option>
114136 </select>
115137 </p>
122144 });
123145 var input = document.getElementById("select");
124146 function selectTheme() {
125 var theme = input.options[input.selectedIndex].innerHTML;
147 var theme = input.options[input.selectedIndex].textContent;
126148 editor.setOption("theme", theme);
149 location.hash = "#" + theme;
127150 }
128 var choice = document.location.search &&
129 decodeURIComponent(document.location.search.slice(1));
151 var choice = (location.hash && location.hash.slice(1)) ||
152 (document.location.search &&
153 decodeURIComponent(document.location.search.slice(1)));
130154 if (choice) {
131155 input.value = choice;
132156 editor.setOption("theme", choice);
133157 }
158 CodeMirror.on(window, "hashchange", function() {
159 var theme = location.hash.slice(1);
160 if (theme) { input.value = theme; selectTheme(); }
161 });
134162 </script>
135163 </article>
3131
3232 <article>
3333 <h2>Vim bindings demo</h2>
34
35 <p><strong style="color: #c33; text-decoration: none">Note:</strong> The CodeMirror vim bindings do not have an
36 active maintainer. That means that if you report bugs in it, they are
37 likely to go unanswered. It also means that if you want to help, you
38 are very welcome to look
39 at <a href="https://github.com/codemirror/codemirror/issues?q=is%3Aissue+is%3Aopen+label%3Avim">the
40 open issues</a> and see which ones you can solve.</p>
41
3442 <form><textarea id="code" name="code">
3543 #include "syscalls.h"
3644 /* getchar: simple buffered version */
0 <!doctype html>
0 <!doctype html>
11
22 <title>CodeMirror: XML Autocomplete Demo</title>
33 <meta charset="utf-8"/>
3030 <form><textarea id="code" name="code"><!-- write some xml below -->
3131 </textarea></form>
3232
33 <p>Press <strong>ctrl-space</strong>, or type a '<' character to
33 <p>Press <strong>ctrl-space</strong>, or type a '&lt;' character to
3434 activate autocompletion. This demo defines a simple schema that
3535 guides completion. The schema can be customized—see
3636 the <a href="../doc/manual.html#addon_xml-hint">manual</a>.</p>
3535 <input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
3636 <p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px;">
3737 <option value="http://codemirror.net/">HEAD</option>
38 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.4.0;f=">5.4</option>
39 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.3.0;f=">5.3</option>
40 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.2.0;f=">5.2</option>
41 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.1.0;f=">5.1</option>
42 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.0.0;f=">5.0</option>
38 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.19.0;f=">5.19.0</option>
39 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.18.2;f=">5.18.2</option>
40 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.18.0;f=">5.18.0</option>
41 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.17.0;f=">5.17.0</option>
42 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.16.0;f=">5.16.0</option>
43 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.15.2;f=">5.15.2</option>
44 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.15.0;f=">5.15.0</option>
45 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.14.2;f=">5.14.2</option>
46 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.14.0;f=">5.14.0</option>
47 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.13.2;f=">5.13.2</option>
48 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.13.0;f=">5.13.0</option>
49 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.12.0;f=">5.12.0</option>
50 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.11.0;f=">5.11.0</option>
51 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.10.0;f=">5.10.0</option>
52 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.9.0;f=">5.9.0</option>
53 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.8.0;f=">5.8.0</option>
54 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.7.0;f=">5.7.0</option>
55 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.6.0;f=">5.6.0</option>
56 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.5.0;f=">5.5.0</option>
57 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.4.0;f=">5.4.0</option>
58 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.3.0;f=">5.3.0</option>
59 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.2.0;f=">5.2.0</option>
60 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.1.0;f=">5.1.0</option>
61 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.0.0;f=">5.0.0</option>
4362 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.13.0;f=">4.13</option>
4463 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.12.0;f=">4.12</option>
4564 <option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.11.0;f=">4.11</option>
109128 <option value="http://codemirror.net/mode/asn.1/asn.1.js">asn.1.js</option>
110129 <option value="http://codemirror.net/mode/asterisk/asterisk.js">asterisk.js</option>
111130 <option value="http://codemirror.net/mode/asciiarmor/asciiarmor.js">asciiarmor.js</option>
131 <option value="http://codemirror.net/mode/brainfuck/brainfuck.js">brainfuck.js</option>
112132 <option value="http://codemirror.net/mode/clike/clike.js">clike.js</option>
113133 <option value="http://codemirror.net/mode/clojure/clojure.js">clojure.js</option>
114134 <option value="http://codemirror.net/mode/cmake/cmake.js">cmake.js</option>
115135 <option value="http://codemirror.net/mode/cobol/cobol.js">cobol.js</option>
116136 <option value="http://codemirror.net/mode/coffeescript/coffeescript.js">coffeescript.js</option>
117137 <option value="http://codemirror.net/mode/commonlisp/commonlisp.js">commonlisp.js</option>
138 <option value="http://codemirror.net/mode/crystal/crystal.js">crystal.js</option>
118139 <option value="http://codemirror.net/mode/css/css.js">css.js</option>
119140 <option value="http://codemirror.net/mode/cypher/cypher.js">cypher.js</option>
120141 <option value="http://codemirror.net/mode/d/d.js">d.js</option>
130151 <option value="http://codemirror.net/mode/elm/elm.js">eml.js</option>
131152 <option value="http://codemirror.net/mode/erlang/erlang.js">erlang.js</option>
132153 <option value="http://codemirror.net/mode/factor/factor.js">factor.js</option>
154 <option value="http://codemirror.net/mode/fcl/fcl.js">fcl.js</option>
133155 <option value="http://codemirror.net/mode/forth/forth.js">forth.js</option>
134156 <option value="http://codemirror.net/mode/fortran/fortran.js">fortran.js</option>
135157 <option value="http://codemirror.net/mode/gfm/gfm.js">gfm.js</option>
140162 <option value="http://codemirror.net/mode/haml/haml.js">haml.js</option>
141163 <option value="http://codemirror.net/mode/handlebars/handlebars.js">handlebars.js</option>
142164 <option value="http://codemirror.net/mode/haskell/haskell.js">haskell.js</option>
165 <option value="http://codemirror.net/mode/haskell-literate/haskell-literate.js">haskell-literate.js</option>
143166 <option value="http://codemirror.net/mode/haxe/haxe.js">haxe.js</option>
144167 <option value="http://codemirror.net/mode/htmlembedded/htmlembedded.js">htmlembedded.js</option>
145168 <option value="http://codemirror.net/mode/htmlmixed/htmlmixed.js">htmlmixed.js</option>
146169 <option value="http://codemirror.net/mode/http/http.js">http.js</option>
147170 <option value="http://codemirror.net/mode/idl/idl.js">idl.js</option>
148 <option value="http://codemirror.net/mode/jade/jade.js">jade.js</option>
149171 <option value="http://codemirror.net/mode/javascript/javascript.js">javascript.js</option>
150172 <option value="http://codemirror.net/mode/jinja2/jinja2.js">jinja2.js</option>
151173 <option value="http://codemirror.net/mode/julia/julia.js">julia.js</option>
152 <option value="http://codemirror.net/mode/kotlin/kotlin.js">kotlin.js</option>
153 <option value="http://codemirror.net/mode/livescript/livescript.js">livescript.js</option>
174 <option value="http://codemirror.net/mode/jsx/jsx.js">jsx.js</option>
154175 <option value="http://codemirror.net/mode/lua/lua.js">lua.js</option>
155176 <option value="http://codemirror.net/mode/markdown/markdown.js">markdown.js</option>
156177 <option value="http://codemirror.net/mode/mathematica/mathematica.js">mathematica.js</option>
178 <option value="http://codemirror.net/mode/mbox/mbox.js">mbox.js</option>
157179 <option value="http://codemirror.net/mode/mirc/mirc.js">mirc.js</option>
158180 <option value="http://codemirror.net/mode/mllike/mllike.js">mllike.js</option>
159181 <option value="http://codemirror.net/mode/modelica/modelica.js">modelica.js</option>
182 <option value="http://codemirror.net/mode/mscgen/mscgen.js">mscgen.js</option>
160183 <option value="http://codemirror.net/mode/mumps/mumps.js">mumps.js</option>
161184 <option value="http://codemirror.net/mode/nginx/nginx.js">nginx.js</option>
162185 <option value="http://codemirror.net/mode/ntriples/ntriples.js">ntriples.js</option>
163186 <option value="http://codemirror.net/mode/octave/octave.js">octave.js</option>
187 <option value="http://codemirror.net/mode/oz/oz.js">oz.js</option>
164188 <option value="http://codemirror.net/mode/pascal/pascal.js">pascal.js</option>
165189 <option value="http://codemirror.net/mode/pegjs/pegjs.js">pegjs.js</option>
166190 <option value="http://codemirror.net/mode/perl/perl.js">perl.js</option>
167191 <option value="http://codemirror.net/mode/php/php.js">php.js</option>
168192 <option value="http://codemirror.net/mode/pig/pig.js">pig.js</option>
193 <option value="http://codemirror.net/mode/powershell/powershell.js">powershell.js</option>
169194 <option value="http://codemirror.net/mode/properties/properties.js">properties.js</option>
195 <option value="http://codemirror.net/mode/protobuf/protobuf.js">protobuf.js</option>
170196 <option value="http://codemirror.net/mode/python/python.js">python.js</option>
197 <option value="http://codemirror.net/mode/pug/pug.js">pug.js</option>
171198 <option value="http://codemirror.net/mode/puppet/puppet.js">puppet.js</option>
172199 <option value="http://codemirror.net/mode/q/q.js">q.js</option>
173200 <option value="http://codemirror.net/mode/r/r.js">r.js</option>
206233 <option value="http://codemirror.net/mode/vbscript/vbscript.js">vbscript.js</option>
207234 <option value="http://codemirror.net/mode/velocity/velocity.js">velocity.js</option>
208235 <option value="http://codemirror.net/mode/verilog/verilog.js">verilog.js</option>
236 <option value="http://codemirror.net/mode/vhdl/vhdl.js">vhdl.js</option>
237 <option value="http://codemirror.net/mode/vue/vue.js">vue.js</option>
238 <option value="http://codemirror.net/mode/webidl/webidl.js">webidl.js</option>
209239 <option value="http://codemirror.net/mode/xml/xml.js">xml.js</option>
210240 <option value="http://codemirror.net/mode/xquery/xquery.js">xquery.js</option>
211241 <option value="http://codemirror.net/mode/yaml/yaml.js">yaml.js</option>
242 <option value="http://codemirror.net/mode/yaml-frontmatter/yaml-frontmatter.js">yaml-frontmatter.js</option>
212243 <option value="http://codemirror.net/mode/z80/z80.js">z80.js</option>
213244 </optgroup>
214245 <optgroup label="Add-ons">
223254 <option value="http://codemirror.net/addon/comment/continuecomment.js">continuecomment.js</option>
224255 <option value="http://codemirror.net/addon/edit/continuelist.js">continuelist.js</option>
225256 <option value="http://codemirror.net/addon/hint/css-hint.js">css-hint.js</option>
257 <option value="http://codemirror.net/addon/lint/css-lint.js">css-lint.js</option>
226258 <option value="http://codemirror.net/addon/dialog/dialog.js">dialog.js</option>
227259 <option value="http://codemirror.net/addon/fold/foldcode.js">foldcode.js</option>
228260 <option value="http://codemirror.net/addon/fold/foldgutter.js">foldgutter.js</option>
229261 <option value="http://codemirror.net/addon/display/fullscreen.js">fullscreen.js</option>
230262 <option value="http://codemirror.net/addon/wrap/hardwrap.js">hardwrap.js</option>
231263 <option value="http://codemirror.net/addon/hint/html-hint.js">html-hint.js</option>
264 <option value="http://codemirror.net/addon/lint/html-lint.js">html-lint.js</option>
232265 <option value="http://codemirror.net/addon/fold/indent-fold.js">indent-fold.js</option>
233266 <option value="http://codemirror.net/addon/hint/javascript-hint.js">javascript-hint.js</option>
234267 <option value="http://codemirror.net/addon/lint/javascript-lint.js">javascript-lint.js</option>
235268 <option value="http://codemirror.net/addon/lint/json-lint.js">json-lint.js</option>
269 <option value="http://codemirror.net/addon/search/jump-to-line.js">jump-to-line.js</option>
236270 <option value="http://codemirror.net/addon/lint/lint.js">lint.js</option>
237271 <option value="http://codemirror.net/addon/mode/loadmode.js">loadmode.js</option>
238272 <option value="http://codemirror.net/addon/fold/markdown-fold.js">markdown-fold.js</option>
0 <!doctype html>
0 <!doctype html>
11
22 <title>CodeMirror: Internals</title>
33 <meta charset="utf-8"/>
499499 is updated <em>during</em> composition. So we poll, whenever the
500500 editor is focused, to provide immediate updates of the display.</p>
501501
502 </section>
502503 </article>
6868 <section class=first id=overview>
6969 <h2 style="position: relative">
7070 User manual and reference guide
71 <span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 5.4.0</span>
71 <span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 5.19.0</span>
7272 </h2>
7373
7474 <p>CodeMirror is a code-editor component that can be embedded in
9999 easy way to combine scripts.) For example:</p>
100100
101101 <pre data-lang="text/html">&lt;script src="lib/codemirror.js">&lt;/script>
102 &lt;link rel="stylesheet" href="../lib/codemirror.css">
102 &lt;link rel="stylesheet" href="lib/codemirror.css">
103103 &lt;script src="mode/javascript/javascript.js">&lt;/script></pre>
104104
105105 <p>(Alternatively, use a module loader. <a href="#modloader">More
235235 mode names to their constructors, and the second maps MIME types
236236 to mode specs.</dd>
237237
238 <dt id="option_lineSeparator"><code><strong>lineSeparator</strong>: string|null</code></dt>
239 <dd>Explicitly set the line separator for the editor. By default
240 (value <code>null</code>), the document will be split on CRLFs
241 as well as lone CRs and LFs, and a single LF will be used as
242 line separator in all output (such
243 as <a href="#getValue"><code>getValue</code></a>). When a
244 specific string is given, lines will only be split on that
245 string, and output will, by default, use that same
246 separator.</dd>
247
238248 <dt id="option_theme"><code><strong>theme</strong>: string</code></dt>
239249 <dd>The theme to style the editor with. You must make sure the
240250 CSS file defining the corresponding <code>.cm-s-[name]</code>
274284 should be replaced by a
275285 special <a href="#option_specialCharPlaceholder">placeholder</a>.
276286 Mostly useful for non-printing special characters. The default
277 is <code>/[\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/</code>.</dd>
287 is <code>/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/</code>.</dd>
278288 <dt id="option_specialCharPlaceholder"><code><strong>specialCharPlaceholder</strong>: function(char) → Element</code></dt>
279289 <dd>A function that, given a special character identified by
280290 the <a href="#option_specialChars"><code>specialChars</code></a>
409419 <dl>
410420 <dt id="option_dragDrop"><code><strong>dragDrop</strong>: boolean</code></dt>
411421 <dd>Controls whether drag-and-drop is enabled. On by default.</dd>
422
423 <dt id="option_allowDropFileTypes"><code><strong>allowDropFileTypes</strong>: array&lt;string&gt;</code></dt>
424 <dd>When set (default is <code>null</code>) only files whose
425 type is in the array can be dropped into the editor. The strings
426 should be MIME types, and will be checked against
427 the <a href="https://w3c.github.io/FileAPI/#dfn-type"><code>type</code></a>
428 of the <code>File</code> object as reported by the browser.</dd>
412429
413430 <dt id="option_cursorBlinkRate"><code><strong>cursorBlinkRate</strong>: number</code></dt>
414431 <dd>Half-period in milliseconds used for cursor blinking. The default blink
509526 an array of strings representing the text that replaced the
510527 changed range (split by line). <code>removed</code> is the text
511528 that used to be between <code>from</code> and <code>to</code>,
512 which is overwritten by this change.</dd>
529 which is overwritten by this change. This event is
530 fired <em>before</em> the end of
531 an <a href="#operation">operation</a>, before the DOM updates
532 happen.</dd>
513533
514534 <dt id="event_changes"><code><strong>"changes"</strong> (instance: CodeMirror, changes: array&lt;object&gt;)</code></dt>
515535 <dd>Like the <a href="#event_change"><code>"change"</code></a>
516536 event, but batched per <a href="#operation">operation</a>,
517537 passing an array containing all the changes that happened in the
518 operation.</dd>
538 operation. This event is fired after the operation finished, and
539 display changes it makes will trigger a new operation.</dd>
519540
520541 <dt id="event_beforeChange"><code><strong>"beforeChange"</strong> (instance: CodeMirror, changeObj: object)</code></dt>
521542 <dd>This event is fired before a change is applied, and its
555576 <dd>Fired whenever new input is read from the hidden textarea
556577 (typed or pasted by the user).</dd>
557578
558 <dt id="event_electricInput"><code><strong>"electrictInput"</strong> (instance: CodeMirror, line: integer)</code></dt>
579 <dt id="event_electricInput"><code><strong>"electricInput"</strong> (instance: CodeMirror, line: integer)</code></dt>
559580 <dd>Fired if text input matched the
560581 mode's <a href="#option_electricChars">electric</a> patterns,
561582 and this caused the line's indentation to change.</dd>
562583
563 <dt id="event_beforeSelectionChange"><code><strong>"beforeSelectionChange"</strong> (instance: CodeMirror, obj: {ranges, update})</code></dt>
584 <dt id="event_beforeSelectionChange"><code><strong>"beforeSelectionChange"</strong> (instance: CodeMirror, obj: {ranges, origin, update})</code></dt>
564585 <dd>This event is fired before the selection is moved. Its
565586 handler may inspect the set of selection ranges, present as an
566587 array of <code>{anchor, head}</code> objects in
567588 the <code>ranges</code> property of the <code>obj</code>
568589 argument, and optionally change them by calling
569590 the <code>update</code> method on this object, passing an array
570 of ranges in the same format. Handlers for this event have the
571 same restriction
591 of ranges in the same format. The object also contains
592 an <code>origin</code> property holding the origin string passed
593 to the selection-changing method, if any. Handlers for this
594 event have the same restriction
572595 as <a href="#event_beforeChange"><code>"beforeChange"</code></a>
573596 handlers — they should not do anything to directly update the
574597 state of the editor.</dd>
602625 You can <code>preventDefault</code> the event, to signal that
603626 CodeMirror should do no further handling.</dd>
604627
605 <dt id="event_focus"><code><strong>"focus"</strong> (instance: CodeMirror)</code></dt>
628 <dt id="event_focus"><code><strong>"focus"</strong> (instance: CodeMirror, event: Event)</code></dt>
606629 <dd>Fires whenever the editor is focused.</dd>
607630
608 <dt id="event_blur"><code><strong>"blur"</strong> (instance: CodeMirror)</code></dt>
631 <dt id="event_blur"><code><strong>"blur"</strong> (instance: CodeMirror, event: Event)</code></dt>
609632 <dd>Fires whenever the editor is unfocused.</dd>
610633
611634 <dt id="event_scroll"><code><strong>"scroll"</strong> (instance: CodeMirror)</code></dt>
629652 should <em>not</em> try to change the state of the editor.</dd>
630653
631654 <dt id="event_dom"><code><strong>"mousedown"</strong>,
632 <strong>"dblclick"</strong>, <strong>"contextmenu"</strong>, <strong>"keydown"</strong>, <strong>"keypress"</strong>,
633 <strong>"keyup"</strong>, <strong>"dragstart"</strong>, <strong>"dragenter"</strong>,
634 <strong>"dragover"</strong>, <strong>"drop"</strong>
655 <strong>"dblclick"</strong>, <strong>"touchstart"</strong>, <strong>"contextmenu"</strong>,
656 <strong>"keydown"</strong>, <strong>"keypress"</strong>,
657 <strong>"keyup"</strong>, <strong>"cut"</strong>, <strong>"copy"</strong>, <strong>"paste"</strong>,
658 <strong>"dragstart"</strong>, <strong>"dragenter"</strong>,
659 <strong>"dragover"</strong>, <strong>"dragleave"</strong>,
660 <strong>"drop"</strong>
635661 (instance: CodeMirror, event: Event)</code></dt>
636662 <dd>Fired when CodeMirror is handling a DOM event of this type.
637663 You can <code>preventDefault</code> the event, or give it a
12271253 separator to put between the lines in the output. When multiple
12281254 selections are present, they are concatenated with instances
12291255 of <code>lineSep</code> in between.</dd>
1230 <dt id="getSelections"><code><strong>doc.getSelections</strong>(?lineSep: string) → string</code></dt>
1256 <dt id="getSelections"><code><strong>doc.getSelections</strong>(?lineSep: string) → array&lt;string&gt;</code></dt>
12311257 <dd>Returns an array containing a string for each selection,
12321258 representing the content of the selections.</dd>
12331259
12471273
12481274 <dt id="getCursor"><code><strong>doc.getCursor</strong>(?start: string) → {line, ch}</code></dt>
12491275 <dd>Retrieve one end of the <em>primary</em>
1250 selection. <code>start</code> is a an optional string indicating
1276 selection. <code>start</code> is an optional string indicating
12511277 which end of the selection to return. It may
12521278 be <code>"from"</code>, <code>"to"</code>, <code>"head"</code>
12531279 (the side of the selection that moves when you press
12811307 <dd>Determines whether the selection head should be scrolled
12821308 into view. Defaults to true.</dd>
12831309 <dt id="selection_origin"><code><strong>origin</strong>: string</code></dt>
1284 <dd>Detemines whether the selection history event may be
1310 <dd>Determines whether the selection history event may be
12851311 merged with the previous one. When an origin starts with the
12861312 character <code>+</code>, and the last recorded selection had
12871313 the same origin and was similar (close
12891315 collapsed or both non-collapsed), the new one will replace the
12901316 old one. When it starts with <code>*</code>, it will always
12911317 replace the previous event (if that had the same origin).
1292 Built-in motion uses the <code>"+move"</code> origin.</dd>
1318 Built-in motion uses the <code>"+move"</code> origin. User input uses the <code>"+input"</code> origin.</dd>
12931319 <dt id="selection_bias"><code><strong>bias</strong>: number</code></dt>
12941320 <dd>Determine the direction into which the selection endpoints
12951321 should be adjusted when they fall inside
13281354 <dd>An equivalent
13291355 of <a href="#extendSelection"><code>extendSelection</code></a>
13301356 that acts on all selections at once.</dd>
1331 <dt id="extendSelectionsBy"><code><strong>doc.extendSelectionsBy</strong>(f: function(range: {anchor, head}) → {anchor, head}), ?options: object)</code></dt>
1357 <dt id="extendSelectionsBy"><code><strong>doc.extendSelectionsBy</strong>(f: function(range: {anchor, head}) → {line, ch}), ?options: object)</code></dt>
13321358 <dd>Applies the given function to all existing selections, and
13331359 calls <a href="#extendSelections"><code>extendSelections</code></a>
13341360 on the result.</dd>
14081434 spec</a> or a mode object (an object with
14091435 a <a href="#token"><code>token</code></a> method).
14101436 The <code>options</code> parameter is optional. If given, it
1411 should be an object. Currently, only the <code>opaque</code>
1412 option is recognized. This defaults to off, but can be given to
1413 allow the overlay styling, when not <code>null</code>, to
1414 override the styling of the base mode entirely, instead of the
1415 two being applied together.</dd>
1437 should be an object, optionally containing the following options:
1438 <dl>
1439 <dt><code><strong>opaque</strong>: bool</code></dt>
1440 <dd>Defaults to off, but can be given to allow the overlay
1441 styling, when not <code>null</code>, to override the styling of
1442 the base mode entirely, instead of the two being applied
1443 together.</dd>
1444 <dt><code><strong>priority</strong>: number</code></dt>
1445 <dd>Determines the ordering in which the overlays are
1446 applied. Those with high priority are applied after those
1447 with lower priority, and able to override the opaqueness of
1448 the ones that come before. Defaults to 0.</dd>
1449 </dl>
1450 </dd>
1451
14161452 <dt id="removeOverlay"><code><strong>cm.removeOverlay</strong>(mode: string|object)</code></dt>
14171453 <dd>Pass this the exact value passed for the <code>mode</code>
14181454 parameter to <a href="#addOverlay"><code>addOverlay</code></a>,
1419 or a string that corresponds to the <code>name</code> propery of
1455 or a string that corresponds to the <code>name</code> property of
14201456 that value, to remove an overlay again.</dd>
14211457
14221458 <dt id="on"><code><strong>cm.on</strong>(type: string, func: (...args))</code></dt>
15141550 <dt id="clearHistory"><code><strong>doc.clearHistory</strong>()</code></dt>
15151551 <dd>Clears the editor's undo history.</dd>
15161552 <dt id="getHistory"><code><strong>doc.getHistory</strong>() → object</code></dt>
1517 <dd>Get a (JSON-serializeable) representation of the undo history.</dd>
1553 <dd>Get a (JSON-serializable) representation of the undo history.</dd>
15181554 <dt id="setHistory"><code><strong>doc.setHistory</strong>(history: object)</code></dt>
15191555 <dd>Replace the editor's undo history with the one provided,
15201556 which must be a value as returned
16471683
16481684 <dt id="findMarks"><code><strong>doc.findMarks</strong>(from: {line, ch}, to: {line, ch}) → array&lt;TextMarker&gt;</code></dt>
16491685 <dd>Returns an array of all the bookmarks and marked ranges
1650 found between the given positions.</dd>
1686 found between the given positions (non-inclusive).</dd>
16511687 <dt id="findMarksAt"><code><strong>doc.findMarksAt</strong>(pos: {line, ch}) → array&lt;TextMarker&gt;</code></dt>
16521688 <dd>Returns an array of all the bookmarks and marked ranges
16531689 present at the given position.</dd>
17611797
17621798 <dl>
17631799 <dt id="setSize"><code><strong>cm.setSize</strong>(width: number|string, height: number|string)</code></dt>
1764 <dd>Programatically set the size of the editor (overriding the
1800 <dd>Programmatically set the size of the editor (overriding the
17651801 applicable <a href="#css-resize">CSS
17661802 rules</a>). <code>width</code> and <code>height</code>
17671803 can be either numbers (interpreted as pixels) or CSS units
18501886 <dd>If your code does something to change the size of the editor
18511887 element (window resizes are already listened for), or unhides
18521888 it, you should probably follow up by calling this method to
1853 ensure CodeMirror is still looking as intended.</dd>
1889 ensure CodeMirror is still looking as intended. See also
1890 the <a href="#addon_autorefresh">autorefresh addon</a>.</dd>
18541891 </dl>
18551892
18561893 <h3 id="api_mode">Mode, state, and token-related methods</h3>
19772014 indentation by the given amount of spaces.</dd>
19782015 </dl></dd>
19792016
1980 <dt id="toggleOverwrite"><code><strong>cm.toggleOverwrite</strong>(?value: bool)</code></dt>
2017 <dt id="toggleOverwrite"><code><strong>cm.toggleOverwrite</strong>(?value: boolean)</code></dt>
19812018 <dd>Switches between overwrite and normal insert mode (when not
19822019 given an argument), or sets the overwrite mode to a specific
19832020 state (when given an argument).</dd>
2021
2022 <dt id="isReadOnly"><code><strong>cm.isReadOnly</strong>() → boolean</code></dt>
2023 <dd>Tells you whether the editor's content can be edited by the
2024 user.</dd>
2025
2026 <dt id="lineSeparator"><code><strong>doc.lineSeparator</strong>()</code></dt>
2027 <dd>Returns the preferred line separator string for this
2028 document, as per the <a href="#option_lineSeparator">option</a>
2029 by the same name. When that option is <code>null</code>, the
2030 string <code>"\n"</code> is returned.</dd>
19842031
19852032 <dt id="execCommand"><code><strong>cm.execCommand</strong>(name: string)</code></dt>
19862033 <dd>Runs the <a href="#commands">command</a> with the given name on the editor.</dd>
20262073 else (usually one) for dev snapshots.</dd>
20272074
20282075 <dt id="fromTextArea"><code><strong>CodeMirror.fromTextArea</strong>(textArea: TextAreaElement, ?config: object)</code></dt>
2029 <dd>
2030 The method provides another way to initialize an editor. It
2031 takes a textarea DOM node as first argument and an optional
2032 configuration object as second. It will replace the textarea
2033 with a CodeMirror instance, and wire up the form of that
2034 textarea (if any) to make sure the editor contents are put
2035 into the textarea when the form is submitted. The text in the
2036 textarea will provide the content for the editor. A CodeMirror
2037 instance created this way has three additional methods:
2038 <dl>
2039 <dt id="save"><code><strong>cm.save</strong>()</code></dt>
2040 <dd>Copy the content of the editor into the textarea.</dd>
2041
2042 <dt id="toTextArea"><code><strong>cm.toTextArea</strong>()</code></dt>
2043 <dd>Remove the editor, and restore the original textarea (with
2044 the editor's current content).</dd>
2045
2046 <dt id="getTextArea"><code><strong>cm.getTextArea</strong>() → TextAreaElement</code></dt>
2047 <dd>Returns the textarea that the instance was based on.</dd>
2048 </dl>
2076 <dd>This method provides another way to initialize an editor. It
2077 takes a textarea DOM node as first argument and an optional
2078 configuration object as second. It will replace the textarea
2079 with a CodeMirror instance, and wire up the form of that
2080 textarea (if any) to make sure the editor contents are put into
2081 the textarea when the form is submitted. The text in the
2082 textarea will provide the content for the editor. A CodeMirror
2083 instance created this way has three additional methods:
2084 <dl>
2085 <dt id="save"><code><strong>cm.save</strong>()</code></dt>
2086 <dd>Copy the content of the editor into the textarea.</dd>
2087
2088 <dt id="toTextArea"><code><strong>cm.toTextArea</strong>()</code></dt>
2089 <dd>Remove the editor, and restore the original textarea (with
2090 the editor's current content). If you dynamically create and
2091 destroy editors made with `fromTextArea`, without destroying
2092 the form they are part of, you should make sure to call
2093 `toTextArea` to remove the editor, or its `"submit"` handler
2094 on the form will cause a memory leak.</dd>
2095
2096 <dt id="getTextArea"><code><strong>cm.getTextArea</strong>() → TextAreaElement</code></dt>
2097 <dd>Returns the textarea that the instance was based on.</dd>
2098 </dl>
20492099 </dd>
20502100
20512101 <dt id="defaults"><code><strong>CodeMirror.defaults</strong>: object</code></dt>
20622112 created from then on.</dd>
20632113
20642114 <dt id="defineDocExtension"><code><strong>CodeMirror.defineDocExtension</strong>(name: string, value: any)</code></dt>
2065 <dd>Like <a href="#defineExtenstion"><code>defineExtension</code></a>,
2115 <dd>Like <a href="#defineExtension"><code>defineExtension</code></a>,
20662116 but the method will be added to the interface
20672117 for <a href="#Doc"><code>Doc</code></a> objects instead.</dd>
20682118
20752125 through <a href="#setOption"><code>setOption</code></a>.</dd>
20762126
20772127 <dt id="defineInitHook"><code><strong>CodeMirror.defineInitHook</strong>(func: function)</code></dt>
2078 <dd>If your extention just needs to run some
2128 <dd>If your extension just needs to run some
20792129 code whenever a CodeMirror instance is initialized,
20802130 use <code>CodeMirror.defineInitHook</code>. Give it a function as
20812131 its only argument, and from then on, that function will be called
21372187 which, if called, will close the dialog immediately.
21382188 <strong><code>openDialog</code></strong> takes the following options:
21392189 <dl>
2140 <dt><code><strong>closeOnEnter</strong></code>:</dt>
2190 <dt><code><strong>closeOnEnter</strong>: bool</code></dt>
21412191 <dd>If true, the dialog will be closed when the user presses
21422192 enter in the input. Defaults to <code>true</code>.</dd>
2143 <dt><code><strong>onKeyDown</strong></code>:</dt>
2144 <dd>An event handler of the signature <code>(event, value, closeFunction)</code>
2145 that will be called whenever <code>keydown</code> fires in the
2193 <dt><code><strong>closeOnBlur</strong>: bool</code></dt>
2194 <dd>Determines whether the dialog is closed when it loses focus. Defaults to <code>true</code>.</dd>
2195 <dt><code><strong>onKeyDown</strong>: fn(event: KeyboardEvent, value: string, close: fn()) → bool</code></dt>
2196 <dd>An event handler that will be called whenever <code>keydown</code> fires in the
21462197 dialog's input. If your callback returns <code>true</code>,
21472198 the dialog will not do any further processing of the event.</dd>
2148 <dt><code><strong>onKeyUp</strong></code>:</dt>
2199 <dt><code><strong>onKeyUp</strong>: fn(event: KeyboardEvent, value: string, close: fn()) → bool</code></dt>
21492200 <dd>Same as <code>onKeyDown</code> but for the
21502201 <code>keyup</code> event.</dd>
2151 <dt><code><strong>onInput</strong></code>:</dt>
2202 <dt><code><strong>onInput</strong>: fn(event: InputEvent, value: string, close: fn()) → bool</code></dt>
21522203 <dd>Same as <code>onKeyDown</code> but for the
21532204 <code>input</code> event.</dd>
2154 <dt><code><strong>onClose</strong></code>:</dt>
2155 <dd>A callback of the signature <code>(dialogInstance)</code>
2156 that will be called after the dialog has been closed and
2205 <dt><code><strong>onClose</strong>: fn(instance)</code>:</dt>
2206 <dd>A callback that will be called after the dialog has been closed and
21572207 removed from the DOM. No return value.</dd>
21582208 </dl>
21592209
22052255 of <a href="#addon_dialog"><code>openDialog</code></a> when
22062256 available to make prompting for search queries less ugly.</dd>
22072257
2258 <dt id="addon_jump-to-line"><a href="../addon/search/jump-to-line.js"><code>search/jump-to-line.js</code></a></dt>
2259 <dd>Implements a <code>jumpToLine</code> command and binding <code>Alt-G</code> to it.
2260 Accepts <code>linenumber</code>, <code>+/-linenumber</code>, <code>line:char</code>,
2261 <code>scroll%</code> and <code>:linenumber</code> formats.
2262 This will make use of <a href="#addon_dialog"><code>openDialog</code></a>
2263 when available to make prompting for line number neater.</dd>
2264
22082265 <dt id="addon_matchesonscrollbar"><a href="../addon/search/matchesonscrollbar.js"><code>search/matchesonscrollbar.js</code></a></dt>
22092266 <dd>Adds a <code>showMatchesOnScrollbar</code> method to editor
22102267 instances, which should be given a query (string or regular
22542311 the <code>CodeMirror-matchingtag</code> class). Also
22552312 defines
22562313 a <a href="#commands">command</a> <code>toMatchingTag</code>,
2257 which you can bind a key to in order to jump to the tag mathing
2314 which you can bind a key to in order to jump to the tag matching
22582315 the one under the cursor. Depends on
22592316 the <code>addon/fold/xml-fold.js</code>
22602317 addon. <a href="../demo/matchtags.html">Demo here.</a></dd>
22782335 <dt id="addon_continuelist"><a href="../addon/edit/continuelist.js"><code>edit/continuelist.js</code></a></dt>
22792336 <dd>Markdown specific. Defines
22802337 a <code>"newlineAndIndentContinueMarkdownList"</code> <a href="#commands">command</a>
2281 command that can be bound to <code>enter</code> to automatically
2338 that can be bound to <code>enter</code> to automatically
22822339 insert the leading characters for continuing a list. See
22832340 the <a href="../mode/markdown/index.html">Markdown mode
22842341 demo</a>.</dd>
22852342
22862343 <dt id="addon_comment"><a href="../addon/comment/comment.js"><code>comment/comment.js</code></a></dt>
2287 <dd>Addon for commenting and uncommenting code. Adds three
2344 <dd>Addon for commenting and uncommenting code. Adds four
22882345 methods to CodeMirror instances:
22892346 <dl>
2347 <dt id="toggleComment"><code><strong>toggleComment</strong>(from: {line, ch}, to: {line, ch}, ?options: object)</code></dt>
2348 <dd>Tries to uncomment the current selection, and if that
2349 fails, line-comments it.</dd>
22902350 <dt id="lineComment"><code><strong>lineComment</strong>(from: {line, ch}, to: {line, ch}, ?options: object)</code></dt>
22912351 <dd>Set the lines in the given range to be line comments. Will
22922352 fall back to <code>blockComment</code> when no line comment
23242384 </dl>
23252385 The addon also defines
23262386 a <code>toggleComment</code> <a href="#commands">command</a>,
2327 which will try to uncomment the current selection, and if that
2328 fails, line-comments it.</dd>
2387 which is a shorthand command for calling
2388 <code>toggleComment</code> with no options.</dd>
23292389
23302390 <dt id="addon_foldcode"><a href="../addon/fold/foldcode.js"><code>fold/foldcode.js</code></a></dt>
23312391 <dd>Helps with code folding. Adds a <code>foldCode</code> method
24132473 <dd>Can be used to run a CodeMirror mode over text without
24142474 actually opening an editor instance.
24152475 See <a href="../demo/runmode.html">the demo</a> for an example.
2416 There are alternate versions of the file avaible for
2476 There are alternate versions of the file available for
24172477 running <a href="../addon/runmode/runmode-standalone.js">stand-alone</a>
24182478 (without including all of CodeMirror) and
24192479 for <a href="../addon/runmode/runmode.node.js">running under
2420 node.js</a>.</dd>
2480 node.js</a> (see <code>bin/source-highlight</code> for an example of using the latter).</dd>
24212481
24222482 <dt id="addon_colorize"><a href="../addon/runmode/colorize.js"><code>runmode/colorize.js</code></a></dt>
24232483 <dd>Provides a convenient way to syntax-highlight code snippets
24592519 Pass <code>"\n"</code> for <code>open</code> or <code>close</code>
24602520 if you want to switch on a blank line.
24612521 <ul><li>When <code>delimStyle</code> is specified, it will be the token
2462 style returned for the delimiter tokens.</li>
2522 style returned for the delimiter tokens (as well as
2523 <code>[delimStyle]-open</code> on the opening token and
2524 <code>[delimStyle]-close</code> on the closing token).</li>
24632525 <li>When <code>innerStyle</code> is specified, it will be the token
24642526 style added for each inner mode token.</li>
24652527 <li>When <code>parseDelimiters</code> is true, the content of
24802542 is an array of strings or objects (the completions),
24812543 and <code>from</code> and <code>to</code> give the start and end
24822544 of the token that is being completed as <code>{line, ch}</code>
2483 objects.</dd>
2545 objects. An optional <code>selectedHint</code> property (an
2546 integer) can be added to the completion object to control the
2547 initially selected hint.</dd>
24842548 <dd>If no hinting function is given, the addon will
24852549 use <code>CodeMirror.hint.auto</code>, which
24862550 calls <a href="#getHelpers"><code>getHelpers</code></a> with
25132577 <dt><code><strong>to</strong>: {line, ch}</code></dt>
25142578 <dd>Optional <code>to</code> position that will be used by <code>pick()</code> instead
25152579 of the global one passed with the full list of completions.</dd>
2516 </dl>
2517 The plugin understands the following options (the options object
2580 </dl></dd>
2581
2582 <dd>The plugin understands the following options (the options object
25182583 will also be passed along to the hinting function, which may
25192584 understand additional options):
25202585 <dl>
25252590 arguments <code>(cm, callback, ?options)</code>, and the
25262591 completion interface will only be popped up when the hinting
25272592 function calls the callback, passing it the object holding the
2528 completions.</dd>
2593 completions.
2594 The hinting function can also return a promise, and the completion
2595 interface will only be popped when the promise resolves.
2596 By default, hinting only works when there is no
2597 selection. You can give a hinting function
2598 a <code>supportsSelection</code> property with a truthy value
2599 to indicate that it supports selections.</dd>
25292600 <dt><code><strong>completeSingle</strong>: boolean</code></dt>
25302601 <dd>Determines whether, when only a single completion is
25312602 available, it is completed without showing the dialog.
25432614 has <code>moveFocus(n)</code>, <code>setFocus(n)</code>, <code>pick()</code>,
25442615 and <code>close()</code> methods (see the source for details),
25452616 that can be used to change the focused element, pick the
2546 current element or close the menu. Additionnaly <code>menuSize()</code>
2617 current element or close the menu. Additionally <code>menuSize()</code>
25472618 can give you access to the size of the current dropdown menu,
2548 <code>length</code> give you the number of availlable completions, and
2619 <code>length</code> give you the number of available completions, and
25492620 <code>data</code> give you full access to the completion returned by the
25502621 hinting function.</dd>
25512622 <dt><code><strong>extraKeys</strong>: keymap</code></dt>
26382709 (default 2), <code>style</code>, for the style to be used to
26392710 highlight the matches (default <code>"matchhighlight"</code>,
26402711 which will correspond to CSS
2641 class <code>cm-matchhighlight</code>),
2712 class <code>cm-matchhighlight</code>), <code>trim</code>, which
2713 controls whether whitespace is trimmed from the selection,
26422714 and <code>showToken</code> which can be set to <code>true</code>
26432715 or to a regexp matching the characters that make up a word. When
26442716 enabled, it causes the current word to be highlighted when
26482720 <dt id="addon_lint"><a href="../addon/lint/lint.js"><code>lint/lint.js</code></a></dt>
26492721 <dd>Defines an interface component for showing linting warnings,
26502722 with pluggable warning sources
2651 (see <a href="../addon/lint/json-lint.js"><code>json-lint.js</code></a>,
2723 (see <a href="../addon/lint/html-lint.js"><code>html-lint.js</code></a>,
2724 <a href="../addon/lint/json-lint.js"><code>json-lint.js</code></a>,
26522725 <a href="../addon/lint/javascript-lint.js"><code>javascript-lint.js</code></a>,
26532726 <a href="../addon/lint/coffeescript-lint.js"><code>coffeescript-lint.js</code></a>,
26542727 and <a href="../addon/lint/css-lint.js"><code>css-lint.js</code></a>
26552728 in the same directory). Defines a <code>lint</code> option that
2656 can be set to a warning source (for
2657 example <code>CodeMirror.lint.javascript</code>), or
2658 to <code>true</code>, in which
2659 case <a href="#getHelper"><code>getHelper</code></a> with
2660 type <code>"lint"</code> is used to determined a validator
2661 function. Such a function should, when given a document string,
2662 an options object, and an editor instance, return an array of <code>{message,
2663 severity, from, to}</code> objects representing problems. When
2664 the function has an <code>async</code> property with a truthy
2665 value, it will be called with an additional second argument,
2666 which is a callback to pass the array to. Depends
2667 on <code>addon/lint/lint.css</code>. A demo can be
2729 can be set to an annotation source (for
2730 example <code>CodeMirror.lint.javascript</code>), to an options
2731 object (in which case the <code>getAnnotations</code> field is
2732 used as annotation source), or simply to <code>true</code>. When
2733 no annotation source is
2734 specified, <a href="#getHelper"><code>getHelper</code></a> with
2735 type <code>"lint"</code> is used to find an annotation function.
2736 An annotation source function should, when given a document
2737 string, an options object, and an editor instance, return an
2738 array of <code>{message, severity, from, to}</code> objects
2739 representing problems. When the function has
2740 an <code>async</code> property with a truthy value, it will be
2741 called with an additional second argument, which is a callback
2742 to pass the array to. By default, the linter will run
2743 (debounced) whenever the document is changed. You can pass
2744 a <code>lintOnChange: false</code> option to disable that.
2745 Depends on <code>addon/lint/lint.css</code>. A demo can be
26682746 found <a href="../demo/lint.html">here</a>.</dd>
26692747
26702748 <dt id="addon_mark-selection"><a href="../addon/selection/mark-selection.js"><code>selection/mark-selection.js</code></a></dt>
26762754 <dt id="addon_active-line"><a href="../addon/selection/active-line.js"><code>selection/active-line.js</code></a></dt>
26772755 <dd>Defines a <code>styleActiveLine</code> option that, when enabled,
26782756 gives the wrapper of the active line the class <code>CodeMirror-activeline</code>,
2679 and adds a background with the class <code>CodeMirror-activeline-background</code>.
2680 is enabled. See the <a href="../demo/activeline.html">demo</a>.</dd>
2757 adds a background with the class <code>CodeMirror-activeline-background</code>,
2758 and adds the class <code>CodeMirror-activeline-gutter</code> to the
2759 line's gutter space is enabled. See the
2760 <a href="../demo/activeline.html">demo</a>.</dd>
26812761
26822762 <dt id="addon_selection-pointer"><a href="../addon/selection/selection-pointer.js"><code>selection/selection-pointer.js</code></a></dt>
26832763 <dd>Defines a <code>selectionPointer</code> option which you can
27332813
27342814 <dt id="addon_placeholder"><a href="../addon/display/placeholder.js"><code>display/placeholder.js</code></a></dt>
27352815 <dd>Adds a <code>placeholder</code> option that can be used to
2736 make text appear in the editor when it is empty and not focused.
2737 Also gives the editor a <code>CodeMirror-empty</code> CSS class
2738 whenever it doesn't contain any text.
2816 make content appear in the editor when it is empty and not
2817 focused. It can hold either a string or a DOM node. Also gives
2818 the editor a <code>CodeMirror-empty</code> CSS class whenever it
2819 doesn't contain any text.
27392820 See <a href="../demo/placeholder.html">the demo</a>.</dd>
27402821
27412822 <dt id="addon_fullscreen"><a href="../addon/display/fullscreen.js"><code>display/fullscreen.js</code></a></dt>
27442825 taking up the whole browser window). Depends
27452826 on <a href="../addon/display/fullscreen.css"><code>fullscreen.css</code></a>. <a href="../demo/fullscreen.html">Demo
27462827 here</a>.</dd>
2828
2829 <dt id="addon_autorefresh"><a href="../addon/display/autorefresh.js"><code>display/autorefresh.js</code></a></dt>
2830 <dd>This addon can be useful when initializing an editor in a
2831 hidden DOM node, in cases where it is difficult to
2832 call <a href="#refresh"><code>refresh</code></a> when the editor
2833 becomes visible. It defines an option <code>autoRefresh</code>
2834 which you can set to true to ensure that, if the editor wasn't
2835 visible on initialization, it will be refreshed the first time
2836 it becomes visible. This is done by polling every 250
2837 milliseconds (you can pass a value like <code>{delay:
2838 500}</code> as the option value to configure this). Note that
2839 this addon will only refresh the editor <em>once</em> when it
2840 first becomes visible, and won't take care of further restyling
2841 and resizing.</dd>
27472842
27482843 <dt id="addon_simplescrollbars"><a href="../addon/scroll/simplescrollbars.js"><code>scroll/simplescrollbars.js</code></a></dt>
27492844 <dd>Defines two additional scrollbar
27642859 set of annotations. The method returns an object
27652860 whose <code>update</code> method can be called with an array
27662861 of <code>{from: Pos, to: Pos}</code> objects marking the ranges
2767 to be higlighed. To detach the annotations, call the
2862 to be highlighted. To detach the annotations, call the
27682863 object's <code>clear</code> method.</dd>
27692864
27702865 <dt id="addon_rulers"><a href="../addon/display/rulers.js"><code>display/rulers.js</code></a></dt>
27712866 <dd>Adds a <code>rulers</code> option, which can be used to show
27722867 one or more vertical rulers in the editor. The option, if
27732868 defined, should be given an array of <code>{column [, className,
2774 color, lineStyle, width]}</code> objects or numbers (wich
2869 color, lineStyle, width]}</code> objects or numbers (which
27752870 indicate a column). The ruler will be displayed at the column
27762871 indicated by the number or the <code>column</code> property.
27772872 The <code>className</code> property can be used to assign a
28292924 <dt><code><strong>wrapRange</strong>(from: {line, ch}, to: {line, ch}, ?options: object)</code></dt>
28302925 <dd>Wraps the given range as one big paragraph.</dd>
28312926 <dt><code><strong>wrapParagraphsInRange</strong>(from: {line, ch}, to: {line, ch}, ?options: object)</code></dt>
2832 <dd>Wrapps the paragraphs in (and overlapping with) the
2927 <dd>Wraps the paragraphs in (and overlapping with) the
28332928 given range individually.</dd>
28342929 </dl>
28352930 The following options are recognized:
29913086
29923087 <dt><code><strong>peek</strong>() → string</code></dt>
29933088 <dd>Returns the next character in the stream without advancing
2994 it. Will return an <code>null</code> at the end of the
3089 it. Will return a <code>null</code> at the end of the
29953090 line.</dd>
29963091 <dt><code><strong>next</strong>() → string</code></dt>
29973092 <dd>Returns the next character in the stream and advances it.
31803275 <p>CodeMirror has a robust VIM mode that attempts to faithfully
31813276 emulate VIM's most useful features. It can be enabled by
31823277 including <a href="../keymap/vim.js"><code>keymap/vim.js</code>
3183 </a> and setting the <code>keymap</code> option to
3184 <code>vim</code>.</p>
3278 </a> and setting the <code>keyMap</code> option to
3279 <code>"vim"</code>.</p>
31853280
31863281 <h3 id="vimapi_configuration">Configuration</h3>
31873282
32763371 be set to a certain position after the operation finishes, it
32773372 can return a cursor object.</dd>
32783373
3279 <dt id="vimapi_defineActon"><strong><code>defineAction(name: string, fn: function(cm: CodeMirror, ?actionArgs: object))</strong></code></dt>
3374 <dt id="vimapi_defineActon"><strong><code>defineAction(name: string, fn: function(cm: CodeMirror, ?actionArgs: object))</code></strong></dt>
32803375 <dd>Defines an action command, similar to
32813376 <strong><code>defineMotion</code></strong>. Action commands
32823377 can have arbitrary behavior, making them more flexible than
2525
2626 <ul>
2727 <li><a href="http://brackets.io">Adobe Brackets</a> (code editor)</li>
28 <li><a href="http://alm.tools">ALM Tools</a> (TypeScript powered IDE)</li>
2829 <li><a href="http://amber-lang.net/">Amber</a> (JavaScript-based Smalltalk system)</li>
2930 <li><a href="http://apachegui.ca/">Apache GUI</a></li>
3031 <li><a href="http://apeye.org/">APEye</a> (tool for testing &amp; documenting APIs)</li>
32 <li><a href="https://github.com/google/appengine-codiad">Appengine Codiad</a></li>
3133 <li><a href="https://chrome.google.com/webstore/detail/better-text-viewer/lcaidopdffhfemoefoaadecppnjdknkc">Better Text Viewer</a> (plain text reader app for Chrome)</li>
3234 <li><a href="http://blog.bitbucket.org/2013/05/14/edit-your-code-in-the-cloud-with-bitbucket/">Bitbucket</a> (code hosting)</li>
3335 <li><a href="http://buzz.blogger.com/2013/04/improvements-to-blogger-template-html.html">Blogger's template editor</a></li>
3436 <li><a href="http://bluegriffon.org/">BlueGriffon</a> (HTML editor)</li>
37 <li><a href="https://github.com/isdampe/BosonEditorExperimental">Boson Editor</a> (code editor)</li>
3538 <li><a href="http://cargocollective.com/">Cargo Collective</a> (creative publishing platform)</li>
3639 <li><a href="https://developers.google.com/chrome-developer-tools/">Chrome DevTools</a></li>
3740 <li><a href="http://clickhelp.co/">ClickHelp</a> (technical writing tool)</li>
38 <li><a href="http://codeworld.info/">CodeWorld</a> (Haskell playground)</li>
41 <li><a href="http://code.world/">CodeWorld</a> (Haskell playground)</li>
3942 <li><a href="http://complete-ly.appspot.com/playground/code.playground.html">Complete.ly playground</a></li>
4043 <li><a href="https://codeanywhere.com/">Codeanywhere</a> (multi-platform cloud editor)</li>
4144 <li><a href="http://drupal.org/project/cpn">Code per Node</a> (Drupal module)</li>
7679 <li><a href="https://github.com/simogeo/Filemanager">Filemanager</a></li>
7780 <li><a href="https://hacks.mozilla.org/2013/11/firefox-developer-tools-episode-27-edit-as-html-codemirror-more/">Firefox Developer Tools</a></li>
7881 <li><a href="http://www.firepad.io">Firepad</a> (collaborative text editor)</li>
79 <li><a href="https://code.google.com/p/gerrit/">Gerrit</a>'s diff view</li>
82 <li><a href="https://gerritcodereview.com/">Gerrit</a>'s diff view and inline editor</li>
8083 <li><a href="https://github.com/maks/git-crx">Git Crx</a> (Chrome App for browsing local git repos)</li>
8184 <li><a href="http://tour.golang.org">Go language tour</a></li>
8285 <li><a href="https://github.com/github/android">GitHub's Android app</a></li>
8386 <li><a href="https://script.google.com/">Google Apps Script</a></li>
8487 <li><a href="http://web.uvic.ca/~siefkenj/graphit/graphit.html">Graphit</a> (function graphing)</li>
88 <li><a href="https://hackmd.io">HackMD</a> (Realtime collaborative markdown notes on all platforms)</li>
8589 <li><a href="http://www.handcraft.com/">Handcraft</a> (HTML prototyping)</li>
8690 <li><a href="http://hawkee.com/">Hawkee</a></li>
8791 <li><a href="http://try.haxe.org">Haxe</a> (Haxe Playground) </li>
9094 <li><a href="http://www.homegenie.it/docs/automation_getstarted.php">Homegenie</a> (home automation server)</li>
9195 <li><a href="http://icecoder.net">ICEcoder</a> (web IDE)</li>
9296 <li><a href="http://ipython.org/">IPython</a> (interactive computing shell)</li>
97 <li><a href="joelpinheiro.github.io/itrading/">iTrading</a> (Algorithmic Trading)</li>
9398 <li><a href="http://i-mos.org/imos/">i-MOS</a> (modeling and simulation platform)</li>
9499 <li><a href="http://www.janvas.com/">Janvas</a> (vector graphics editor)</li>
95100 <li><a href="http://extensions.joomla.org/extensions/edition/editors/8723">Joomla plugin</a></li>
101106 <li><a href="http://www.jshint.com/">JSHint</a> (JS linter)</li>
102107 <li><a href="http://jumpseller.com/">Jumpseller</a> (online store builder)</li>
103108 <li><a href="http://kl1p.com/cmtest/1">kl1p</a> (paste service)</li>
109 <li><a href="http://www.kodhus.com/kodity/">Kodit</a></li>
104110 <li><a href="http://kodtest.com/">Kodtest</a> (HTML/JS/CSS playground)</li>
105111 <li><a href="http://try.kotlinlang.org">Kotlin</a> (web-based mini-IDE for Kotlin)</li>
106112 <li><a href="https://laborate.io/">Laborate</a> (collaborative coding)</li>
117123 <li><a href="https://github.com/soliton4/nodeMirror">nodeMirror</a> (IDE project)</li>
118124 <li><a href="https://notex.ch">NoTex</a> (rST authoring)</li>
119125 <li><a href="http://oakoutliner.com">Oak</a> (online outliner)</li>
126 <li><a href="http://www.greycampus.com/opencampus">OpenCampus</a></li>
120127 <li><a href="http://clrhome.org/asm/">ORG</a> (z80 assembly IDE)</li>
121128 <li><a href="https://github.com/mamacdon/orion-codemirror">Orion-CodeMirror integration</a> (running CodeMirror modes in Orion)</li>
122129 <li><a href="http://paperjs.org/">Paper.js</a> (graphics scripting)</li>
130 <li><a href="http://pharaoh.js.org/">Pharaoh</a> (browser &amp; desktop editor for the classroom)</li>
123131 <li><a href="http://prinbit.com/">PrinBit</a> (collaborative coding tool)</li>
124132 <li><a href="http://prose.io/">Prose.io</a> (github content editor)</li>
125133 <li><a href="https://pypi.python.org/pypi/PubliForge/">PubliForge</a> (online publishing system)</li>
130138 <li><a href="http://www.quivive-file-manager.com">Quivive File Manager</a></li>
131139 <li><a href="http://rascalmicro.com/docs/basic-tutorial-getting-started.html">Rascal</a> (tiny computer)</li>
132140 <li><a href="https://www.realtime.io/">RealTime.io</a> (Internet-of-Things infrastructure)</li>
141 <li><a href="http://refork.com/">Refork</a> (animation demo gallery and sharing)</li>
133142 <li><a href="https://cloud.sagemath.com/">SageMathCloud</a> (interactive mathematical software environment)</li>
134143 <li><a href="https://chrome.google.com/webstore/detail/servephp/mnpikomdchjhkhbhmbboehfdjkobbfpo">ServePHP</a> (PHP code testing in Chrome dev tools)</li>
135144 <li><a href="https://www.shadertoy.com/">Shadertoy</a> (shader sharing)</li>
144153 <li><a href="http://xuanji.appspot.com/isicp/">Structure and Interpretation of Computer Programs</a>, Interactive Version</li>
145154 <li><a href="http://syframework.alwaysdata.net">SyBox</a> (PHP playground)</li>
146155 <li><a href="http://www.tagspaces.org/">TagSpaces</a> (personal data manager)</li>
156 <li><a href="https://textbox.io/">Textbox.io</a> (WYSIWYG rich text editor)</a></li>
147157 <li><a href="https://thefiletree.com">The File Tree</a> (collab editor)</li>
148158 <li><a href="http://www.mapbox.com/tilemill/">TileMill</a> (map design tool)</li>
149159 <li><a href="http://doc.tiki.org/Syntax+Highlighter">Tiki</a> (wiki CMS groupware)</li>
151161 <li><a href="http://enjalot.com/tributary/2636296/sinwaves.js">Tributary</a> (augmented editing)</li>
152162 <li><a href="http://blog.englard.net/post/39608000629/codeintumblr">Tumblr code highlighting shim</a></li>
153163 <li><a href="http://turbopy.com/">TurboPY</a> (web publishing framework)</li>
154 <li><a href="http://uicod.com/">uiCod</a> (animation demo gallery and sharing)</li>
155164 <li><a href="http://cruise.eecs.uottawa.ca/umpleonline/">UmpleOnline</a> (model-oriented programming tool)</li>
156 <li><a href="https://upsource.jetbrains.com/#idea/view/923f30395f2603cd9f42a32bcafd13b6c28de0ff/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ReplaceAbstractClassInstanceByMapIntention.java">Upsource</a> (code viewer)</li>
165 <li><a href="https://upsource.jetbrains.com/idea-ce/file/idea-ce-7706e7832aa9e2fd0c2decdb5cbef2225692c696/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java">Upsource</a> (code browser and review tool)</li>
157166 <li><a href="https://github.com/mgaitan/waliki">Waliki</a> (wiki engine)</li>
158167 <li><a href="http://wamer.net/">Wamer</a> (web application builder)</li>
159168 <li><a href="https://github.com/brettz9/webappfind">webappfind</a> (windows file bindings for webapps)</li>
2929
3030 <h2>Version 5.x</h2>
3131
32 <p class="rel">20-09-2016: <a href="http://codemirror.net/codemirror-5.19.0.zip">Version 5.19.0</a>:</p>
33
34 <ul class=rel-note>
35 <li><a href="http://codemirror.net/mode/erlang">erlang mode</a>: Fix mode crash when trying to read an empty context.</li>
36 <li><a href="http://codemirror.net/doc/manual.html#addon_comment">comment addon</a>: Fix broken behavior when toggling comments inside a comment.</li>
37 <li>xml-fold addon: Fix a null-dereference bug.</li>
38 <li>Page up and page down now do something even in single-line documents.</li>
39 <li>Fix an issue where the cursor position could be off in really long (~8000 character) tokens.</li>
40 <li><a href="http://codemirror.net/mode/javascript">javascript mode</a>: Better indentation when semicolons are missing. Better support for TypeScript classes, optional parameters, and the <code>type</code> keyword.</li>
41 <li>The <a href="http://codemirror.net/doc/manual.html#event_blur"><code>blur</code></a> and <a href="http://codemirror.net/doc/manual.html#event_focus"><code>focus</code></a> events now pass the DOM event to their handlers.</li>
42 </ul>
43
44 <p class="rel">23-08-2016: <a href="http://codemirror.net/codemirror-5.18.2.zip">Version 5.18.2</a>:</p>
45
46 <ul class=rel-note>
47 <li><a href="http://codemirror.net/mode/vue">vue mode</a>: Fix outdated references to renamed Pug mode dependency.</li>
48 </ul>
49
50 <p class="rel">22-08-2016: <a href="http://codemirror.net/codemirror-5.18.0.zip">Version 5.18.0</a>:</p>
51
52 <ul class=rel-note>
53 <li>Make sure <a href="http://codemirror.net/doc/manual.html#addLineClass">gutter backgrounds</a> stick to the rest of the gutter during horizontal scrolling.</li>
54 <li>The contenteditable <a href="http://codemirror.net/doc/manual.html#option_inputStyle"><code>inputStyle</code></a> now properly supports pasting on pre-Edge IE versions.</li>
55 <li><a href="http://codemirror.net/mode/javascript">javascript mode</a>: Fix some small parsing bugs and improve TypeScript support.</li>
56 <li><a href="http://codemirror.net/doc/manual.html#addon_matchbrackets">matchbrackets addon</a>: Fix bug where active highlighting was left in editor when the addon was disabled.</li>
57 <li><a href="http://codemirror.net/doc/manual.html#addon_match-highlighter">match-highlighter addon</a>: Only start highlighting things when the editor gains focus.</li>
58 <li><a href="http://codemirror.net/doc/manual.html#addon_javascript-hint">javascript-hint addon</a>: Also complete non-enumerable properties.</li>
59 <li>The <a href="http://codemirror.net/doc/manual.html#addOverlay"><code>addOverlay</code></a> method now supports a <code>priority</code> option to control the order in which overlays are applied.</li>
60 <li>MIME types that end in <code>+json</code> now default to the JSON mode when the MIME itself is not defined.</li>
61 <li>The mode formerly known as Jade was renamed to <a href="http://codemirror.net/mode/pug">Pug</a>.</li>
62 <li>The <a href="http://codemirror.net/mode/python">Python mode</a> now defaults to Python 3 (rather than 2) syntax.</li>
63 </ul>
64
65 <p class="rel">19-07-2016: <a href="http://codemirror.net/codemirror-5.17.0.zip">Version 5.17.0</a>:</p>
66
67 <ul class="rel-note">
68 <li>Fix problem with wrapped trailing whitespace displaying incorrectly.</li>
69 <li>Prevent IME dialog from overlapping typed content in Chrome.</li>
70 <li>Improve measuring of characters near a line wrap.</li>
71 <li><a href="http://codemirror.net/mode/javascript">javascript mode</a>: Improve support for <code>async</code>, allow trailing commas in <code>import</code> lists.</li>
72 <li><a href="http://codemirror.net/demo/vim.html">vim bindings</a>: Fix backspace in replace mode.</li>
73 <li><a href="http://codemirror.net/demo/sublime.html">sublime bindings</a>: Fix some key bindings on OS X to match Sublime Text.</li>
74 <li><a href="http://codemirror.net/mode/markdown">markdown mode</a>: Add more classes to image links in highlight-formatting mode.</li>
75 </ul>
76
77 <p class="rel">20-06-2016: <a href="http://codemirror.net/codemirror-5.16.0.zip">Version 5.16.0</a>:</p>
78
79 <ul class="rel-note">
80 <li>Fix glitches when dragging content caused by the drop indicator receiving mouse events.</li>
81 <li>Make Control-drag work on Firefox.</li>
82 <li>Make clicking or selection-dragging at the end of a wrapped line select the right position.</li>
83 <li><a href="http://codemirror.net/doc/manual.html#addon_show-hint">show-hint addon</a>: Prevent widget scrollbar from hiding part of the hint text.</li>
84 <li><a href="http://codemirror.net/doc/manual.html#addon_rulers">rulers addon</a>: Prevent rulers from forcing a horizontal editor scrollbar.</li>
85 <li><a href="http://codemirror.net/doc/manual.html#addon_search">search addon</a>: Automatically bind search-related keys in persistent dialog.</li>
86 <li><a href="http://codemirror.net/demo/sublime.html">sublime keymap</a>: Add a multi-cursor aware smart backspace binding.</li>
87 </ul>
88
89 <p class="rel">20-05-2016: <a href="http://codemirror.net/codemirror-5.15.2.zip">Version 5.15.2</a>:</p>
90
91 <ul class="rel-note">
92 <li>Fix a critical document corruption bug that occurs when a document is gradually grown.</li>
93 </ul>
94
95 <p class="rel">20-05-2016: <a href="http://codemirror.net/codemirror-5.15.0.zip">Version 5.15.0</a>:</p>
96
97 <ul class="rel-note">
98 <li>Fix bug that caused the selection to reset when focusing the editor in contentEditable input mode.</li>
99 <li>Fix issue where not all ASCII control characters were being replaced by placeholders.</li>
100 <li>Remove the assumption that all modes have a <code>startState</code> method from several wrapping modes.</li>
101 <li>Fix issue where the editor would complain about overlapping collapsed ranges when there weren't any.</li>
102 <li>Optimize document tree building when loading or pasting huge chunks of content.</li>
103 <li>Explicitly bind Ctrl-O on OS X to make that binding (“open line”) act as expected.</li>
104 <li>Pasting <a href="http://codemirror.net/doc/manual.html#option_lineWiseCopyCut">linewise-copied</a> content when there is no selection now inserts the lines above the current line.</li>
105 <li><a href="http://codemirror.net/mode/markdown/">markdown mode</a>: Fix several issues in matching link targets.</li>
106 <li><a href="http://codemirror.net/mode/clike/">clike mode</a>: Improve indentation of C++ template declarations.</li>
107 <li><a href="http://codemirror.net/mode/javascript/">javascript mode</a>: Support <code>async</code>/<code>await</code> and improve support for TypeScript type syntax.</li>
108 </ul>
109
110 <p class="rel">20-04-2016: <a href="http://codemirror.net/codemirror-5.14.0.zip">Version 5.14.0</a>:</p>
111
112 <ul class="rel-note">
113 <li><a href="http://codemirror.net/doc/manual.html#posFromIndex"><code>posFromIndex</code></a> and <a href="http://codemirror.net/doc/manual.html#indexFromPos"><code>indexFromPos</code></a> now take <a href="http://codemirror.net/doc/manual.html#option_lineSeparator"><code>lineSeparator</code></a> into account</li>
114 <li><a href="http://codemirror.net/demo/vim.html">vim bindings</a>: Only call <code>.save()</code> when it is actually available</li>
115 <li><a href="http://codemirror.net/doc/manual.html#addon_comment">comment addon</a>: Be careful not to mangle multi-line strings</li>
116 <li><a href="http://codemirror.net/mode/python/index.html">Python mode</a>: Improve distinguishing of decorators from <code>@</code> operators</li>
117 <li><a href="http://codemirror.net/doc/manual.html#findMarks"><code>findMarks</code></a>: No longer return marks that touch but don't overlap given range</li>
118 <li><a href="http://codemirror.net/demo/vim.html">vim bindings</a>: Add yank command</li>
119 <li><a href="http://codemirror.net/doc/manual.html#addon_match-highlighter">match-highlighter addon</a>: Add <code>trim</code> option to disable ignoring of whitespace</li>
120 <li><a href="http://codemirror.net/mode/powershell/index.html">PowerShell mode</a>: Added</li>
121 <li><a href="http://codemirror.net/mode/yacas/index.html">Yacas mode</a>: Added</li>
122 <li><a href="http://codemirror.net/mode/webidl/index.html">Web IDL mode</a>: Added</li>
123 <li><a href="http://codemirror.net/mode/sas/index.html">SAS mode</a>: Added</li>
124 <li><a href="http://codemirror.net/mode/mbox/index.html">mbox mode</a>: Added</li>
125 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.13.4...5.14.0">list of patches</a></li>
126 </ul>
127
128 <p class="rel">21-03-2016: <a href="http://codemirror.net/codemirror-5.13.2.zip">Version 5.13.2</a>:</p>
129
130 <ul class="rel-note">
131 <li>Solves a problem where the gutter would sometimes not extend all the way to the end of the document.</li>
132 </ul>
133
134 <p class="rel">21-03-2016: <a href="http://codemirror.net/codemirror-5.13.zip">Version 5.13</a>:</p>
135
136 <ul class="rel-note">
137 <li>New DOM event forwarded: <a href="http://codemirror.net/doc/manual.html#event_dom"><code>&quot;dragleave&quot;</code></a>.</li>
138 <li><a href="http://codemirror.net/mode/protobuf/index.html">protobuf mode</a>: Newly added.</li>
139 <li>Fix problem where <a href="http://codemirror.net/doc/manual.html#findMarks"><code>findMarks</code></a> sometimes failed to find multi-line marks.</li>
140 <li>Fix crash that showed up when atomic ranges and bidi text were combined.</li>
141 <li><a href="http://codemirror.net/demo/complete.html">show-hint addon</a>: Completion widgets no longer close when the line indented or dedented.</li>
142 <li><a href="http://codemirror.net/demo/merge.html">merge addon</a>: Fix bug when merging chunks at the end of the file.</li>
143 <li><a href="http://codemirror.net/doc/manual.html#addon_placeholder">placeholder addon</a>: No longer gets confused by <a href="http://codemirror.net/doc/manual.html#swapDoc"><code>swapDoc</code></a>.</li>
144 <li><a href="http://codemirror.net/doc/manual.html#addon_simplescrollbars">simplescrollbars addon</a>: Fix invalid state when deleting at end of document.</li>
145 <li><a href="http://codemirror.net/mode/clike/index.html">clike mode</a>: No longer gets confused when a comment starts after an operator.</li>
146 <li><a href="http://codemirror.net/mode/markdown/index.html">markdown mode</a>: Now supports CommonMark-style flexible list indentation.</li>
147 <li><a href="http://codemirror.net/mode/dylan/index.html">dylan mode</a>: Several improvements and fixes.</li>
148 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.12.0...5.13.0">list of patches</a></li>
149 </ul>
150
151 <p class="rel">19-02-2016: <a href="http://codemirror.net/codemirror-5.12.zip">Version 5.12</a>:</p>
152
153 <ul class="rel-note">
154 <li><a href="http://codemirror.net/demo/vim.html">Vim bindings</a>: Ctrl-Q is now an alias for Ctrl-V.</li>
155 <li><a href="http://codemirror.net/demo/vim.html">Vim bindings</a>: The Vim API now exposes an <code>unmap</code> method to unmap bindings.</li>
156 <li><a href="http://codemirror.net/demo/activeline.html">active-line addon</a>: This addon can now style the active line's gutter.</li>
157 <li><a href="http://codemirror.net/mode/fcl/">FCL mode</a>: Newly added.</li>
158 <li><a href="http://codemirror.net/mode/sql/">SQL mode</a>: Now has a Postgresql dialect.</li>
159 <li>Fix <a href="https://github.com/codemirror/CodeMirror/issues/3781">issue</a> where trying to scroll to a horizontal position outside of the document's width could cause the gutter to be positioned incorrectly.</li>
160 <li>Use absolute, rather than fixed positioning in the context-menu intercept hack, to work around a <a href="https://github.com/codemirror/CodeMirror/issues/3238">problem</a> when the editor is inside a transformed parent container.</li>
161 <li>Solve a <a href="https://github.com/codemirror/CodeMirror/issues/3821">problem</a> where the horizontal scrollbar could hide text in Firefox.</li>
162 <li>Fix a <a href="https://github.com/codemirror/CodeMirror/issues/3834">bug</a> that caused phantom scroll space under the text in some situations.</li>
163 <li><a href="http://codemirror.net/demo/sublime.html">Sublime Text bindings</a>: Bind delete-line to Shift-Ctrl-K on OS X.</li>
164 <li><a href="http://codemirror.net/mode/markdown/">Markdown mode</a>: Fix <a href="https://github.com/codemirror/CodeMirror/issues/3787">issue</a> where the mode would keep state related to fenced code blocks in an unsafe way, leading to occasional corrupted parses.</li>
165 <li><a href="http://codemirror.net/mode/markdown/">Markdown mode</a>: Ignore backslashes in code fragments.</li>
166 <li><a href="http://codemirror.net/mode/markdown/">Markdown mode</a>: Use whichever mode is registered as <code>text/html</code> to parse HTML.</li>
167 <li><a href="http://codemirror.net/mode/clike/">Clike mode</a>: Improve indentation of Scala <code>=&gt;</code> functions.</li>
168 <li><a href="http://codemirror.net/mode/python/">Python mode</a>: Improve indentation of bracketed code.</li>
169 <li><a href="http://codemirror.net/mode/htmlmixed/">HTMLMixed mode</a>: Support multi-line opening tags for sub-languages (<code>&lt;script&gt;</code>, <code>&lt;style&gt;</code>, etc).</li>
170 <li><a href="http://codemirror.net/mode/spreadsheet/">Spreadsheet mode</a>: Fix bug where the mode did not advance the stream when finding a backslash.</li>
171 <li><a href="http://codemirror.net/mode/xml/">XML mode</a>: The mode now takes a <code>matchClosing</code> option to configure whether mismatched closing tags should be highlighted as errors.</li>
172 </ul>
173
174 <p class="rel">20-01-2016: <a href="http://codemirror.net/codemirror-5.11.zip">Version 5.11</a>:</p>
175
176 <ul class="rel-note">
177 <li>New modes: <a href="../mode/jsx/index.html">JSX</a>, <a href="../mode/haskell-literate/index.html">literate Haskell</a></li>
178 <li>The editor now forwards more <a href="manual.html#event_dom">DOM events</a>: <code>cut</code>, <code>copy</code>, <code>paste</code>, and <code>touchstart</code>. It will also forward <code>mousedown</code> for drag events</li>
179 <li>Fixes a bug where bookmarks next to collapsed spans were not rendered</li>
180 <li>The <a href="../mode/swift/index.html">Swift</a> mode now supports auto-indentation</li>
181 <li>Frontmatters in the <a href="../mode/yaml-frontmatter/index.html">YAML frontmatter</a> mode are now optional as intended</li>
182 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.10.0...5.11.0">list of patches</a></li>
183 </ul>
184
185 <p class="rel">21-12-2015: <a href="http://codemirror.net/codemirror-5.10.zip">Version 5.10</a>:</p>
186
187 <ul class="rel-note">
188 <li>Modify the way <a href="manual.html#mark_atomic">atomic ranges</a> are skipped by selection to try and make it less surprising.</li>
189 <li>The <a href="../mode/swift/index.html">Swift mode</a> was rewritten.</li>
190 <li>New addon: <a href="manual.html#addon_jump-to-line">jump-to-line</a>.</li>
191 <li>New method: <a href="manual.html#isReadOnly"><code>isReadOnly</code></a>.</li>
192 <li>The <a href="manual.html#addon_show-hint">show-hint addon</a> now defaults to picking completions on single click.</li>
193 <li>The object passed to <a href="manual.html#event_beforeSelectionChange"><code>&quot;beforeSelectionChange&quot;</code></a> events now has an <code>origin</code> property.</li>
194 <li>New mode: <a href="../mode/crystal/index.html">Crystal</a>.</li>
195 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.9.0...5.10.0">list of patches</a></li>
196 </ul>
197
198 <p class="rel">23-11-2015: <a href="http://codemirror.net/codemirror-5.9.zip">Version 5.9</a>:</p>
199
200 <ul class="rel-note">
201 <li>Improve the way overlay (OS X-style) scrollbars are handled</li>
202 <li>Make <a href="manual.html#addon_annotatescrollbar">annotatescrollbar</a> and scrollpastend addons work properly together</li>
203 <li>Make <a href="manual.html#addon_show-hint">show-hint</a> addon select options on single click by default, move selection to hovered item</li>
204 <li>Properly fold comments that include block-comment-start markers</li>
205 <li>Many small language mode fixes</li>
206 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.8.0...5.9.0">list of patches</a></li>
207 </ul>
208
209 <p class="rel">20-10-2015: <a href="http://codemirror.net/codemirror-5.8.zip">Version 5.8</a>:</p>
210
211 <ul class="rel-note">
212 <li>Fixes an infinite loop in
213 the <a href="manual.html#addon_hardwrap">hardwrap
214 addon</a></li>
215 <li>New modes: <a href="../mode/nsis/index.html">NSIS</a>, <a href="../mode/clike/index.html">Ceylon</a></li>
216 <li>The Kotlin mode is now a <a href="../mode/clike/index.html">clike</a> dialect, rather than a stand-alone mode</li>
217 <li>New option: <a href="manual.html#option_allowDropFileTypes"><code>allowDropFileTypes</code></a>. Binary files can no longer be dropped into CodeMirror</li>
218 <li>New themes: <a href="../demo/theme.html#bespin">bespin</a>, <a href="../demo/theme.html#hopscotch">hopscotch</a>, <a href="../demo/theme.html#isotope">isotope</a>, <a href="../demo/theme.html#railscasts">railscasts</a></li>
219 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.7.0...5.8.0">list of patches</a></li>
220 </ul>
221
222 <p class="rel">20-09-2015: <a href="http://codemirror.net/codemirror-5.7.zip">Version 5.7</a>:</p>
223
224 <ul class="rel-note">
225 <li>New modes: <a href="../mode/vue/index.html">Vue</a>, <a href="../mode/oz/index.html">Oz</a>, <a href="../mode/mscgen/index.html">MscGen</a> (and dialects), <a href="../mode/css/gss.html">Closure Stylesheets</a></li>
226 <li>Implement <a href="http://commonmark.org">CommonMark</a>-style flexible list indent and cross-line code spans in <a href="../mode/markdown/index.html">Markdown</a> mode</li>
227 <li>Add a replace-all button to the <a href="manual.html#addon_search">search addon</a>, and make the persistent search dialog transparent when it obscures the match</li>
228 <li>Handle <code>acync</code>/<code>await</code> and ocal and binary numbers in <a href="../mode/javascript/index.html">JavaScript mode</a></li>
229 <li>Fix various issues with the <a href="../mode/haxe/index.html">Haxe mode</a></li>
230 <li>Make the <a href="manual.html#addon_closebrackets">closebrackets addon</a> select only the wrapped text when wrapping selection in brackets</li>
231 <li>Tokenize properties as properties in the <a href="../mode/coffeescript/index.html">CoffeeScript mode</a></li>
232 <li>The <a href="manual.html#addon_placeholder">placeholder addon</a> now accepts a DOM node as well as a string placeholder</li>
233 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.6.0...5.7.0">list of patches</a></li>
234 </ul>
235
236 <p class="rel">20-08-2015: <a href="http://codemirror.net/codemirror-5.6.zip">Version 5.6</a>:</p>
237
238 <ul class="rel-note">
239 <li>Fix bug where you could paste into a <code>readOnly</code> editor</li>
240 <li>Show a cursor at the drop location when dragging over the editor</li>
241 <li>The <a href="../mode/rust/index.html">Rust mode</a> was rewritten to handle modern Rust</li>
242 <li>The editor and theme CSS was cleaned up. Some selectors are now less specific than before</li>
243 <li>New theme: <a href="../demo/theme.html#abcdef">abcdef</a></li>
244 <li>Lines longer than <a href="manual.html#option_maxHighlightLength"><code>maxHighlightLength</code></a> are now less likely to mess up indentation</li>
245 <li>New addons: <a href="manual.html#addon_autorefresh"><code>autorefresh</code></a> for refreshing an editor the first time it becomes visible, and <code>html-lint</code> for using <a href="http://htmlhint.com/">HTMLHint</a></li>
246 <li>The <a href="manual.html#addon_search"><code>search</code></a> addon now recognizes <code>\r</code> and <code>\n</code> in pattern and replacement input</li>
247 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.5.0...5.6.0">list of patches</a></li>
248 </ul>
249
250 <p class="rel">20-07-2015: <a href="http://codemirror.net/codemirror-5.5.zip">Version 5.5</a>:</p>
251
252 <ul class="rel-note">
253 <li>New option: <a href="manual.html#option_lineSeparator"><code>lineSeparator</code></a> (with corresponding <a href="manual.html#lineSeparator">method</a>)
254 <li>New themes: <a href="../demo/theme.html#dracula">dracula</a>, <a href="../demo/theme.html#seti">seti</a>, <a href="../demo/theme.html#yeti">yeti</a>, <a href="../demo/theme.html#material">material</a>, and <a href="../demo/theme.html#icecoder">icecoder</a></li>
255 <li>New modes: <a href="../mode/brainfuck/index.html">Brainfuck</a>, <a href="../mode/vhdl/index.html">VHDL</a>, Squirrel (<a href="../mode/clike/index.html">clike</a> dialect)</li>
256 <li>Define a <code>findPersistent</code> command in
257 the <a href="../demo/search.html">search</a> addon, for a dialog
258 that stays open as you cycle through matches</li>
259 <li>From this release on, the NPM module doesn't include documentation and demos</li>
260 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.4.0...5.5.0">list of patches</a></li>
261 </ul>
262
32263 <p class="rel">25-06-2015: <a href="http://codemirror.net/codemirror-5.4.zip">Version 5.4</a>:</p>
33264
34265 <ul class="rel-note">
56287 asynchronous mode</li>
57288 <li>Fix backspace binding in <a href="../demo/sublime.html">Sublime bindings</a></li>
58289 <li>Change the way IME is handled in the <code>"textarea"</code> <a href="manual.html#option_inputStyle">input style</a></li>
59
290
60291 <li>New modes: <a href="../mode/mumps/index.html">MUMPS</a>, <a href="../mode/handlebars/index.html">Handlebars</a></li>
61292 <li>Rewritten modes: <a href="../mode/django/index.html">Django</a>, <a href="../mode/z80/index.html">Z80</a></li>
62 <li>New theme: <a href="../demo/theme.html?liquibyte">Liquibyte</a></li>
293 <li>New theme: <a href="../demo/theme.html#liquibyte">Liquibyte</a></li>
63294 <li>New option: <a href="manual.html#option_lineWiseCopyCut"><code>lineWiseCopyCut</code></a></li>
64295 <li>The <a href="../demo/vim.html">Vim mode</a> now supports buffer-local options and the <code>filetype</code> setting</li>
65296 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.1.0...5.2.0">list of patches</a></li>
150381 modes: <a href="../mode/dart/index.html">Dart</a>, <a href="../mode/ebnf/index.html">EBNF</a>, <a href="../mode/spreadsheet/index.html">spreadsheet</a>,
151382 and <a href="../mode/soy/index.html">Soy</a>.</li>
152383 <li>New <a href="../demo/panel.html">addon</a> to show persistent panels below/above an editor.</li>
153 <li>New themes: <a href="../demo/theme.html?zenburn">zenburn</a>
154 and <a href="../demo/theme.html?tomorrow-night-bright">tomorrow night
384 <li>New themes: <a href="../demo/theme.html#zenburn">zenburn</a>
385 and <a href="../demo/theme.html#tomorrow-night-bright">tomorrow night
155386 bright</a>.</li>
156387 <li>Allow ctrl-click to clear existing cursors.</li>
157388 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/4.8.0...4.9.0">list of patches</a>.</li>
255486 <li>Rewritten <a href="../mode/jade/index.html">Jade</a> mode.</li>
256487 <li>Various improvements to <a href="../mode/shell/index.html">Shell</a> (support for more syntax) and <a href="../mode/python/index.html">Python</a> (better indentation) modes.</li>
257488 <li>New mode: <a href="../mode/cypher/index.html">Cypher</a>.</li>
258 <li>New theme: <a href="../demo/theme.html?neo">Neo</a>.</li>
489 <li>New theme: <a href="../demo/theme.html#neo">Neo</a>.</li>
259490 <li>Support direct styling options (color, line style, width) in the <a href="manual.html#addon_rulers">rulers</a> addon.</li>
260491 <li>Recognize per-editor configuration for the <a href="manual.html#addon_show-hint">show-hint</a> and <a href="manual.html#addon_foldcode">foldcode</a> addons.</li>
261492 <li>More intelligent scanning for existing close tags in <a href="manual.html#addon_closetag">closetag</a> addon.</li>
321552 <ul class="rel-note">
322553 <li>Adds the <a href="manual.html#findMarks"><code>findMarks</code></a> method.</li>
323554 <li>New addons: <a href="manual.html#addon_rulers">rulers</a>, markdown-fold, yaml-lint.</li>
324 <li>New theme: <a href="../demo/theme.html?mdn-like">mdn-like</a>.</li>
555 <li>New theme: <a href="../demo/theme.html#mdn-like">mdn-like</a>.</li>
325556 <li>New mode: <a href="../mode/solr/index.html">Solr</a>.</li>
326557 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/3.21.0...3.22.0">list of patches</a>.</li>
327558 </ul>
329560 <p class="rel">16-01-2014: <a href="http://codemirror.net/codemirror-3.21.zip">Version 3.21</a>:</p>
330561
331562 <ul class="rel-note">
332 <li>Auto-indenting a block will no longer add trailing whitespace to blank lines.</a>
563 <li>Auto-indenting a block will no longer add trailing whitespace to blank lines.</li>
333564 <li>Marking text has a new option <a href="manual.html#markText"><code>clearWhenEmpty</code></a> to control auto-removal.</li>
334565 <li>Several bugfixes in the handling of bidirectional text.</li>
335566 <li>The <a href="../mode/xml/index.html">XML</a> and <a href="../mode/css/index.html">CSS</a> modes were largely rewritten. <a href="../mode/css/less.html">LESS</a> support was added to the CSS mode.</li>
336567 <li>The OCaml mode was moved to an <a href="../mode/mllike/index.html">mllike</a> mode, F# support added.</li>
337568 <li>Make it possible to fetch multiple applicable helper values with <a href="manual.html#getHelpers"><code>getHelpers</code></a>, and to register helpers matched on predicates with <a href="manual.html#registerGlobalHelper"><code>registerGlobalHelper</code></a>.</li>
338 <li>New theme <a href="../demo/theme.html?pastel-on-dark">pastel-on-dark</a>.</li>
569 <li>New theme <a href="../demo/theme.html#pastel-on-dark">pastel-on-dark</a>.</li>
339570 <li>Better ECMAScript 6 support in <a href="../mode/javascript/index.html">JavaScript</a> mode.</li>
340571 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/3.20.0...3.21.0">list of patches</a>.</li>
341572 </ul>
356587 <ul class="rel-note">
357588 <li>New modes: <a href="../mode/eiffel/index.html">Eiffel</a>, <a href="../mode/gherkin/index.html">Gherkin</a>, <a href="../mode/sql/?mime=text/x-mssql">MSSQL dialect</a>.</li>
358589 <li>New addons: <a href="manual.html#addon_hardwrap">hardwrap</a>, <a href="manual.html#addon_sql-hint">sql-hint</a>.</li>
359 <li>New theme: <a href="../demo/theme.html?mbo">MBO</a>.</li>
590 <li>New theme: <a href="../demo/theme.html#mbo">MBO</a>.</li>
360591 <li>Add <a href="manual.html#token_style_line">support</a> for line-level styling from mode tokenizers.</li>
361592 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/3.18.0...3.19.0">list of patches</a>.</li>
362593 </ul>
381612 <ul class="rel-note">
382613 <li>The whole codebase is now under a single <a href="../LICENSE">license</a> file.</li>
383614 <li>The project page was overhauled and redesigned.</li>
384 <li>New themes: <a href="../demo/theme.html?paraiso-dark">Paraiso</a> (<a href="../demo/theme.html?paraiso-light">light</a>), <a href="../demo/theme.html?the-matrix">The Matrix</a>.</li>
615 <li>New themes: <a href="../demo/theme.html#paraiso-dark">Paraiso</a> (<a href="../demo/theme.html#paraiso-light">light</a>), <a href="../demo/theme.html#the-matrix">The Matrix</a>.</li>
385616 <li>Improved interaction between themes and <a href="manual.html#addon_active-line">active-line</a>/<a href="manual.html#addon_matchbrackets">matchbrackets</a> addons.</li>
386617 <li>New <a href="manual.html#addon_foldcode">folding</a> function <code>CodeMirror.fold.comment</code>.</li>
387618 <li>Added <a href="manual.html#addon_fullscreen">fullscreen</a> addon.</li>
395626 <li>New addons: <a href="../demo/tern.html">Tern</a>, <a href="manual.html#addon_matchtags">matchtags</a>, and <a href="manual.html#addon_foldgutter">foldgutter</a>.</li>
396627 <li>Introduced <a href="manual.html#getHelper"><em>helper</em></a> concept (<a href="https://groups.google.com/forum/#!msg/codemirror/cOc0xvUUEUU/nLrX1-qnidgJ">context</a>).</li>
397628 <li>New method: <a href="manual.html#getModeAt"><code>getModeAt</code></a>.</li>
398 <li>New themes: base16 <a href="../demo/theme.html?base16-dark">dark</a>/<a href="../demo/theme.html?base16-light">light</a>, 3024 <a href="../demo/theme.html?3024-night">dark</a>/<a href="../demo/theme.html?3024-day">light</a>, <a href="../demo/theme.html?tomorrow-night-eighties">tomorrow-night</a>.</li>
629 <li>New themes: base16 <a href="../demo/theme.html#base16-dark">dark</a>/<a href="../demo/theme.html#base16-light">light</a>, 3024 <a href="../demo/theme.html#3024-night">dark</a>/<a href="../demo/theme.html#3024-day">light</a>, <a href="../demo/theme.html#tomorrow-night-eighties">tomorrow-night</a>.</li>
399630 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/3.14.0...3.15.0">list of patches</a>.</li>
400631 </ul>
401632
510741 <li>Further improvements to the <a href="../demo/vim.html">vim mode</a>.</li>
511742 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/v3.01...v3.1">list of patches</a>.</li>
512743 </ul>
513
744
514745
515746 <p class="rel">25-01-2013: <a href="http://codemirror.net/codemirror-3.02.zip">Version 3.02</a>:</p>
516747
550781 <li>Work around Safari segfault when dragging.</li>
551782 <li>Full <a href="https://github.com/codemirror/CodeMirror/compare/v3.0rc2...v3.0">list of patches</a>.</li>
552783 </ul>
553
784
554785 <p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-3.0rc2.zip">Version 3.0, release candidate 2</a>:</p>
555786
556787 <ul class="rel-note">
566797 <p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-3.0rc1.zip">Version 3.0, release candidate 1</a>:</p>
567798
568799 <ul class="rel-note">
569 <li>New theme: <a href="../demo/theme.html?solarized%20light">Solarized</a>.</li>
800 <li>New theme: <a href="../demo/theme.html#solarized%20light">Solarized</a>.</li>
570801 <li>Introduce <a href="manual.html#addLineClass"><code>addLineClass</code></a>
571802 and <a href="manual.html#removeLineClass"><code>removeLineClass</code></a>,
572803 drop <code>setLineClass</code>.</li>
632863
633864 <ul class="rel-note">
634865 <li>New mode: <a href="../mode/z80/index.html">Z80 assembly</a>.</li>
635 <li>New theme: <a href="../demo/theme.html?twilight">Twilight</a>.</li>
866 <li>New theme: <a href="../demo/theme.html#twilight">Twilight</a>.</li>
636867 <li>Add command-line compression helper.</li>
637868 <li>Make <a href="manual.html#scrollIntoView"><code>scrollIntoView</code></a> public.</li>
638869 <li>Add <a href="manual.html#defaultTextHeight"><code>defaultTextHeight</code></a> method.</li>
702933
703934 <ul class="rel-note">
704935 <li><strong>New scrollbar implementation</strong>. Should flicker less. Changes DOM structure of the editor.</li>
705 <li>New theme: <a href="../demo/theme.html?vibrant-ink">vibrant-ink</a>.</li>
936 <li>New theme: <a href="../demo/theme.html#vibrant-ink">vibrant-ink</a>.</li>
706937 <li>Many extensions to the VIM keymap (including text objects).</li>
707938 <li>Add <a href="../demo/multiplex.html">mode-multiplexing</a> utility script.</li>
708939 <li>Fix bug where right-click paste works in read-only mode.</li>
728959 <li>New
729960 modes: <a href="../mode/shell/index.html">Shell</a>, <a href="../mode/tiki/index.html">Tiki
730961 wiki</a>, <a href="../mode/pig/index.html">Pig Latin</a>.</li>
731 <li>New themes: <a href="../demo/theme.html?ambiance">Ambiance</a>, <a href="../demo/theme.html?blackboard">Blackboard</a>.</li>
962 <li>New themes: <a href="../demo/theme.html#ambiance">Ambiance</a>, <a href="../demo/theme.html#blackboard">Blackboard</a>.</li>
732963 <li>More control over drag/drop
733964 with <a href="manual.html#option_dragDrop"><code>dragDrop</code></a>
734965 and <a href="manual.html#option_onDragEvent"><code>onDragEvent</code></a>
9595 </div>
9696 </div>
9797 <div class=actionsleft>
98 Get the current version: <a href="http://codemirror.net/codemirror.zip">5.4</a>.<br>
98 Get the current version: <a href="http://codemirror.net/codemirror.zip">5.19.0</a>.<br>
9999 You can see the <a href="https://github.com/codemirror/codemirror" title="Github repository">code</a> or<br>
100100 read the <a href="doc/releases.html">release notes</a>.<br>
101101 There is a <a href="doc/compress.html">minification helper</a>.
105105 maintainers need to subsist.<br>
106106 Current funding status = <img src="https://marijnhaverbeke.nl/fund/status_s.png" title="Current maintainer happiness" style="vertical-align: middle; height: 16px; width: 16px"><br>
107107 You can help <a href="https://marijnhaverbeke.nl/fund/" title="Set up a monthly contribution">per month</a> or
108 <a title="Donate with Paypal" href="javascript:document.getElementById('paypal').submit();">once</a>.
108 <a title="Donate with PayPal" href="javascript:document.getElementById('paypal').submit();">once</a>.
109109 <form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="paypal">
110110 <input type="hidden" name="cmd" value="_s-xclick"/>
111111 <input type="hidden" name="hosted_button_id" value="3FVHS5FGUY7CC"/>
112112 </form>
113113 </div>
114114 </div>
115
115
116116 </section>
117117
118118 <section id=features>
161161 license that CodeMirror uses.</p>
162162
163163 <p>Discussion around the project is done on
164 a <a href="http://discuss.codemirror.net">discussion forum</a>.
164 a <a href="https://discuss.codemirror.net">discussion forum</a>.
165165 There is also
166166 the <a href="http://groups.google.com/group/codemirror-announce">codemirror-announce</a>
167167 list, which is only used for major announcements (such as new
168168 versions). If needed, you can
169169 contact <a href="mailto:marijnh@gmail.com">the maintainer</a>
170 directly.</p>
170 directly. We aim to be an inclusive, welcoming community. To make
171 that explicit, we have
172 a <a href="http://contributor-covenant.org/version/1/1/0/">code of
173 conduct</a> that applies to communication around the project.</p>
171174
172175 <p>A list of CodeMirror-related software that is not part of the
173176 main distribution is maintained
376376
377377 getInput(cm, "Goto line", function(str) {
378378 var num;
379 if (str && !isNaN(num = Number(str)) && num == num|0 && num > 0)
379 if (str && !isNaN(num = Number(str)) && num == (num|0) && num > 0)
380380 cm.setCursor(num - 1);
381381 });
382382 },
5151 });
5252 }
5353
54 cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
55 cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
56
57 cmds[map[ctrl + "Up"] = "scrollLineUp"] = function(cm) {
54 var goSubwordCombo = mac ? "Ctrl-" : "Alt-";
55
56 cmds[map[goSubwordCombo + "Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
57 cmds[map[goSubwordCombo + "Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
58
59 if (mac) map["Cmd-Left"] = "goLineStartSmart";
60
61 var scrollLineCombo = mac ? "Ctrl-Alt-" : "Ctrl-";
62
63 cmds[map[scrollLineCombo + "Up"] = "scrollLineUp"] = function(cm) {
5864 var info = cm.getScrollInfo();
5965 if (!cm.somethingSelected()) {
6066 var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local");
6369 }
6470 cm.scrollTo(null, info.top - cm.defaultTextHeight());
6571 };
66 cmds[map[ctrl + "Down"] = "scrollLineDown"] = function(cm) {
72 cmds[map[scrollLineCombo + "Down"] = "scrollLineDown"] = function(cm) {
6773 var info = cm.getScrollInfo();
6874 if (!cm.somethingSelected()) {
6975 var visibleTopLine = cm.lineAtHeight(info.top, "local")+1;
102108 cm.setSelections(extended);
103109 };
104110
105 map["Shift-" + ctrl + "K"] = "deleteLine";
111 map["Shift-Ctrl-K"] = "deleteLine";
106112
107113 function insertLine(cm, above) {
114 if (cm.isReadOnly()) return CodeMirror.Pass
108115 cm.operation(function() {
109116 var len = cm.listSelections().length, newSelection = [], last = -1;
110117 for (var i = 0; i < len; i++) {
118125 }
119126 cm.setSelections(newSelection);
120127 });
121 }
122
123 cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { insertLine(cm, false); };
124
125 cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { insertLine(cm, true); };
128 cm.execCommand("indentAuto");
129 }
130
131 cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { return insertLine(cm, false); };
132
133 cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { return insertLine(cm, true); };
126134
127135 function wordAt(cm, pos) {
128136 var start = pos.ch, end = start, line = cm.getLine(pos.line);
189197 var swapLineCombo = mac ? "Cmd-Ctrl-" : "Shift-Ctrl-";
190198
191199 cmds[map[swapLineCombo + "Up"] = "swapLineUp"] = function(cm) {
200 if (cm.isReadOnly()) return CodeMirror.Pass
192201 var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = [];
193202 for (var i = 0; i < ranges.length; i++) {
194203 var range = ranges[i], from = range.from().line - 1, to = range.to().line;
215224 };
216225
217226 cmds[map[swapLineCombo + "Down"] = "swapLineDown"] = function(cm) {
227 if (cm.isReadOnly()) return CodeMirror.Pass
218228 var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;
219229 for (var i = ranges.length - 1; i >= 0; i--) {
220230 var range = ranges[i], from = range.to().line + 1, to = range.from().line;
237247 });
238248 };
239249
240 map[ctrl + "/"] = "toggleComment";
250 cmds[map[ctrl + "/"] = "toggleCommentIndented"] = function(cm) {
251 cm.toggleComment({ indent: true });
252 }
241253
242254 cmds[map[ctrl + "J"] = "joinLines"] = function(cm) {
243255 var ranges = cm.listSelections(), joined = [];
284296 map[ctrl + "T"] = "transposeChars";
285297
286298 function sortLines(cm, caseSensitive) {
299 if (cm.isReadOnly()) return CodeMirror.Pass
287300 var ranges = cm.listSelections(), toSort = [], selected;
288301 for (var i = 0; i < ranges.length; i++) {
289302 var range = ranges[i];
411424 cmds[map["Backspace"] = "smartBackspace"] = function(cm) {
412425 if (cm.somethingSelected()) return CodeMirror.Pass;
413426
414 var cursor = cm.getCursor();
415 var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
416 var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
417
418 if (toStartOfLine && !/\S/.test(toStartOfLine) && column % cm.getOption("indentUnit") == 0)
419 return cm.indentSelection("subtract");
420 else
421 return CodeMirror.Pass;
427 cm.operation(function() {
428 var cursors = cm.listSelections();
429 var indentUnit = cm.getOption("indentUnit");
430
431 for (var i = cursors.length - 1; i >= 0; i--) {
432 var cursor = cursors[i].head;
433 var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
434 var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
435
436 // Delete by one character by default
437 var deletePos = cm.findPosH(cursor, -1, "char", false);
438
439 if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) {
440 var prevIndent = new Pos(cursor.line,
441 CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit));
442
443 // Smart delete only if we found a valid prevIndent location
444 if (prevIndent.ch != cursor.ch) deletePos = prevIndent;
445 }
446
447 cm.replaceRange("", deletePos, cursor, "+delete");
448 }
449 });
422450 };
423451
424452 cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) {
473501 cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2);
474502 };
475503
476 cmds[map["Shift-Alt-Up"] = "selectLinesUpward"] = function(cm) {
504 var selectLinesCombo = mac ? "Ctrl-Shift-" : "Ctrl-Alt-";
505 cmds[map[selectLinesCombo + "Up"] = "selectLinesUpward"] = function(cm) {
477506 cm.operation(function() {
478507 var ranges = cm.listSelections();
479508 for (var i = 0; i < ranges.length; i++) {
483512 }
484513 });
485514 };
486 cmds[map["Shift-Alt-Down"] = "selectLinesDownward"] = function(cm) {
515 cmds[map[selectLinesCombo + "Down"] = "selectLinesDownward"] = function(cm) {
487516 cm.operation(function() {
488517 var ranges = cm.listSelections();
489518 for (var i = 0; i < ranges.length; i++) {
2525 * 2. Variable declarations and short basic helpers
2626 * 3. Instance (External API) implementation
2727 * 4. Internal state tracking objects (input state, counter) implementation
28 * and instanstiation
28 * and instantiation
2929 * 5. Key handler (the main command dispatcher) implementation
3030 * 6. Motion, operator, and action implementations
3131 * 7. Helper functions for the key handler, motions, operators, and actions
6363 { keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
6464 { keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
6565 { keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' },
66 { keys: 's', type: 'keyToKey', toKeys: 'xi', context: 'visual'},
66 { keys: 's', type: 'keyToKey', toKeys: 'c', context: 'visual'},
6767 { keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' },
68 { keys: 'S', type: 'keyToKey', toKeys: 'dcc', context: 'visual' },
68 { keys: 'S', type: 'keyToKey', toKeys: 'VdO', context: 'visual' },
6969 { keys: '<Home>', type: 'keyToKey', toKeys: '0' },
7070 { keys: '<End>', type: 'keyToKey', toKeys: '$' },
7171 { keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' },
7272 { keys: '<PageDown>', type: 'keyToKey', toKeys: '<C-f>' },
7373 { keys: '<CR>', type: 'keyToKey', toKeys: 'j^', context: 'normal' },
74 { keys: '<Ins>', type: 'action', action: 'toggleOverwrite', context: 'insert' },
7475 // Motions
7576 { keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }},
7677 { keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }},
163164 { keys: 'v', type: 'action', action: 'toggleVisualMode' },
164165 { keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }},
165166 { keys: '<C-v>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
167 { keys: '<C-q>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
166168 { keys: 'gv', type: 'action', action: 'reselectLastSelection' },
167169 { keys: 'J', type: 'action', action: 'joinLines', isEdit: true },
168170 { keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }},
224226 { name: 'sort', shortName: 'sor' },
225227 { name: 'substitute', shortName: 's', possiblyAsync: true },
226228 { name: 'nohlsearch', shortName: 'noh' },
229 { name: 'yank', shortName: 'y' },
227230 { name: 'delmarks', shortName: 'delm' },
228231 { name: 'registers', shortName: 'reg', excludeFromCommandHistory: true },
229232 { name: 'global', shortName: 'g' }
273276
274277 function cmKey(key, cm) {
275278 if (!cm) { return undefined; }
279 if (this[key]) { return this[key]; }
276280 var vimKey = cmKeyToVimKey(key);
277281 if (!vimKey) {
278282 return false;
285289 }
286290
287291 var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'};
288 var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del'};
292 var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del',Insert:'Ins'};
289293 function cmKeyToVimKey(key) {
290294 if (key.charAt(0) == '\'') {
291295 // Keypress character binding of format "'a'"
292296 return key.charAt(1);
293297 }
294 var pieces = key.split('-');
295 if (/-$/.test(key)) {
296 // If the - key was typed, split will result in 2 extra empty strings
297 // in the array. Replace them with 1 '-'.
298 pieces.splice(-2, 2, '-');
299 }
298 var pieces = key.split(/-(?!$)/);
300299 var lastPiece = pieces[pieces.length - 1];
301300 if (pieces.length == 1 && pieces[0].length == 1) {
302301 // No-modifier bindings use literal character bindings above. Skip.
644643 jumpList: createCircularJumpList(),
645644 macroModeState: new MacroModeState,
646645 // Recording latest f, t, F or T motion command.
647 lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''},
646 lastCharacterSearch: {increment:0, forward:true, selectedCharacter:''},
648647 registerController: new RegisterController({}),
649648 // search history buffer
650649 searchHistoryController: new HistoryController({}),
684683 map: function(lhs, rhs, ctx) {
685684 // Add user defined key bindings.
686685 exCommandDispatcher.map(lhs, rhs, ctx);
686 },
687 unmap: function(lhs, ctx) {
688 exCommandDispatcher.unmap(lhs, ctx);
687689 },
688690 // TODO: Expose setOption and getOption as instance methods. Need to decide how to namespace
689691 // them, or somehow make them work with the existing CodeMirror setOption/getOption API.
777779
778780 if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
779781 if (keysAreChars) {
780 var here = cm.getCursor();
781 cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
782 var selections = cm.listSelections();
783 for (var i = 0; i < selections.length; i++) {
784 var here = selections[i].head;
785 cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
786 }
787 vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
782788 }
783789 clearInputState(cm);
784790 return match.command;
815821 // TODO: Look into using CodeMirror's multi-key handling.
816822 // Return no-op since we are caching the key. Counts as handled, but
817823 // don't want act on it just yet.
818 return function() {};
824 return function() { return true; };
819825 } else {
820826 return function() {
821827 return cm.operation(function() {
10471053 };
10481054 function HistoryController() {
10491055 this.historyBuffer = [];
1050 this.iterator;
1056 this.iterator = 0;
10511057 this.initialPrefix = null;
10521058 }
10531059 HistoryController.prototype = {
13721378 }
13731379 },
13741380 evalInput: function(cm, vim) {
1375 // If the motion comand is set, execute both the operator and motion.
1381 // If the motion command is set, execute both the operator and motion.
13761382 // Otherwise return.
13771383 var inputState = vim.inputState;
13781384 var motion = inputState.motion;
16961702 var line = motionArgs.forward ? cur.line + repeat : cur.line - repeat;
16971703 var first = cm.firstLine();
16981704 var last = cm.lastLine();
1699 // Vim cancels linewise motions that start on an edge and move beyond
1700 // that edge. It does not cancel motions that do not start on an edge.
1701 if ((line < first && cur.line == first) ||
1702 (line > last && cur.line == last)) {
1703 return;
1705 // Vim go to line begin or line end when cursor at first/last line and
1706 // move to previous/next line is triggered.
1707 if (line < first && cur.line == first){
1708 return this.moveToStartOfLine(cm, head, motionArgs, vim);
1709 }else if (line > last && cur.line == last){
1710 return this.moveToEol(cm, head, motionArgs, vim);
17041711 }
17051712 if (motionArgs.toFirstChar){
17061713 endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));
19081915 },
19091916
19101917 repeatLastCharacterSearch: function(cm, head, motionArgs) {
1911 var lastSearch = vimGlobalState.lastChararacterSearch;
1918 var lastSearch = vimGlobalState.lastCharacterSearch;
19121919 var repeat = motionArgs.repeat;
19131920 var forward = motionArgs.forward === lastSearch.forward;
19141921 var increment = (lastSearch.increment ? 1 : 0) * (forward ? -1 : 1);
19581965 text = text.slice(0, - match[0].length);
19591966 }
19601967 }
1961 var wasLastLine = head.line - 1 == cm.lastLine();
1962 cm.replaceRange('', anchor, head);
1963 if (args.linewise && !wasLastLine) {
1968 var prevLineEnd = new Pos(anchor.line - 1, Number.MAX_VALUE);
1969 var wasLastLine = cm.firstLine() == cm.lastLine();
1970 if (head.line > cm.lastLine() && args.linewise && !wasLastLine) {
1971 cm.replaceRange('', prevLineEnd, head);
1972 } else {
1973 cm.replaceRange('', anchor, head);
1974 }
1975 if (args.linewise) {
19641976 // Push the next line back down, if there is a next line.
1965 CodeMirror.commands.newlineAndIndent(cm);
1966 // null ch so setCursor moves to end of line.
1967 anchor.ch = null;
1977 if (!wasLastLine) {
1978 cm.setCursor(prevLineEnd);
1979 CodeMirror.commands.newlineAndIndent(cm);
1980 }
1981 // make sure cursor ends up at the end of the line.
1982 anchor.ch = Number.MAX_VALUE;
19681983 }
19691984 finalHead = anchor;
19701985 } else {
21432158 switch (actionArgs.position) {
21442159 case 'center': y = y - (height / 2) + lineHeight;
21452160 break;
2146 case 'bottom': y = y - height + lineHeight*1.4;
2147 break;
2148 case 'top': y = y + lineHeight*0.4;
2161 case 'bottom': y = y - height + lineHeight;
21492162 break;
21502163 }
21512164 cm.scrollTo(null, y);
21652178 var macroModeState = vimGlobalState.macroModeState;
21662179 var registerName = actionArgs.selectedCharacter;
21672180 macroModeState.enterMacroRecordMode(cm, registerName);
2181 },
2182 toggleOverwrite: function(cm) {
2183 if (!cm.state.overwrite) {
2184 cm.toggleOverwrite(true);
2185 cm.setOption('keyMap', 'vim-replace');
2186 CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
2187 } else {
2188 cm.toggleOverwrite(false);
2189 cm.setOption('keyMap', 'vim-insert');
2190 CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
2191 }
21682192 },
21692193 enterInsertMode: function(cm, actionArgs, vim) {
21702194 if (cm.getOption('readOnly')) { return; }
22112235 return;
22122236 }
22132237 }
2214 cm.setOption('keyMap', 'vim-insert');
22152238 cm.setOption('disableInput', false);
22162239 if (actionArgs && actionArgs.replace) {
22172240 // Handle Replace-mode as a special case of insert mode.
22192242 cm.setOption('keyMap', 'vim-replace');
22202243 CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
22212244 } else {
2245 cm.toggleOverwrite(false);
22222246 cm.setOption('keyMap', 'vim-insert');
22232247 CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
22242248 }
29953019 // Only clip if the selection ends with trailing newline + whitespace
29963020 if (/\n\s*$/.test(selection)) {
29973021 var lines = selection.split('\n');
2998 // We know this is all whitepsace.
3022 // We know this is all whitespace.
29993023 lines.pop();
30003024
30013025 // Cases:
30813105 }
30823106
30833107 function recordLastCharacterSearch(increment, args) {
3084 vimGlobalState.lastChararacterSearch.increment = increment;
3085 vimGlobalState.lastChararacterSearch.forward = args.forward;
3086 vimGlobalState.lastChararacterSearch.selectedCharacter = args.selectedCharacter;
3108 vimGlobalState.lastCharacterSearch.increment = increment;
3109 vimGlobalState.lastCharacterSearch.forward = args.forward;
3110 vimGlobalState.lastCharacterSearch.selectedCharacter = args.selectedCharacter;
30873111 }
30883112
30893113 var symbolToMode = {
32073231 return cur;
32083232 }
32093233
3210 /*
3234 /**
32113235 * Returns the boundaries of the next word. If the cursor in the middle of
32123236 * the word, then returns the boundaries of the current word, starting at
32133237 * the cursor. If the cursor is at the start/end of a word, and we are going
32823306 line = cm.getLine(lineNum);
32833307 pos = (dir > 0) ? 0 : line.length;
32843308 }
3285 // Should never get here.
3286 throw new Error('The impossible happened.');
32873309 }
32883310
32893311 /**
34453467 }
34463468
34473469 // TODO: perhaps this finagling of start and end positions belonds
3448 // in codmirror/replaceRange?
3470 // in codemirror/replaceRange?
34493471 function selectCompanionObject(cm, head, symb, inclusive) {
34503472 var cur = head, start, end;
34513473
37763798 }
37773799 }
37783800 function makePrompt(prefix, desc) {
3779 var raw = '';
3780 if (prefix) {
3781 raw += '<span style="font-family: monospace">' + prefix + '</span>';
3782 }
3783 raw += '<input type="text"/> ' +
3784 '<span style="color: #888">';
3785 if (desc) {
3786 raw += '<span style="color: #888">';
3787 raw += desc;
3788 raw += '</span>';
3789 }
3801 var raw = '<span style="font-family: monospace; white-space: pre">' +
3802 (prefix || "") + '<input type="text"></span>';
3803 if (desc)
3804 raw += ' <span style="color: #888">' + desc + '</span>';
37903805 return raw;
37913806 }
37923807 var searchPromptDesc = '(Javascript regexp)';
43074322 if (decimal + hex + octal > 1) { return 'Invalid arguments'; }
43084323 number = decimal && 'decimal' || hex && 'hex' || octal && 'octal';
43094324 }
4310 if (args.eatSpace() && args.match(/\/.*\//)) { 'patterns not supported'; }
4325 if (args.match(/\/.*\//)) { return 'patterns not supported'; }
43114326 }
43124327 }
43134328 var err = parseArgs();
45074522 if (CodeMirror.commands.save) {
45084523 // If a save command is defined, call it.
45094524 CodeMirror.commands.save(cm);
4510 } else {
4511 // Saves to text area if no save command is defined.
4525 } else if (cm.save) {
4526 // Saves to text area if no save command is defined and cm.save() is available.
45124527 cm.save();
45134528 }
45144529 },
45154530 nohlsearch: function(cm) {
45164531 clearSearchHighlight(cm);
4532 },
4533 yank: function (cm) {
4534 var cur = copyCursor(cm.getCursor());
4535 var line = cur.line;
4536 var lineText = cm.getLine(line);
4537 vimGlobalState.registerController.pushText(
4538 '0', 'yank', lineText, true, true);
45174539 },
45184540 delmarks: function(cm, params) {
45194541 if (!params.argString || !trim(params.argString)) {
47654787 CodeMirror.keyMap['vim-insert'] = {
47664788 // TODO: override navigation keys so that Esc will cancel automatic
47674789 // indentation from o, O, i_<CR>
4768 'Ctrl-N': 'autocomplete',
4769 'Ctrl-P': 'autocomplete',
4770 'Enter': function(cm) {
4771 var fn = CodeMirror.commands.newlineAndIndentContinueComment ||
4772 CodeMirror.commands.newlineAndIndent;
4773 fn(cm);
4774 },
47754790 fallthrough: ['default'],
47764791 attach: attachVimMap,
47774792 detach: detachVimMap,
48624877 if (changeObj.origin == '+input' || changeObj.origin == 'paste'
48634878 || changeObj.origin === undefined /* only in testing */) {
48644879 var text = changeObj.text.join('\n');
4880 if (lastChange.maybeReset) {
4881 lastChange.changes = [];
4882 lastChange.maybeReset = false;
4883 }
48654884 lastChange.changes.push(text);
48664885 }
48674886 // Change objects may be chained with next.
48844903 lastChange.expectCursorActivityForChange = false;
48854904 } else {
48864905 // Cursor moved outside the context of an edit. Reset the change.
4887 lastChange.changes = [];
4906 lastChange.maybeReset = true;
48884907 }
48894908 } else if (!cm.curOp.isVimOp) {
48904909 handleExternalSelection(cm, vim);
49484967 var keyName = CodeMirror.keyName(e);
49494968 if (!keyName) { return; }
49504969 function onKeyFound() {
4970 if (lastChange.maybeReset) {
4971 lastChange.changes = [];
4972 lastChange.maybeReset = false;
4973 }
49514974 lastChange.changes.push(new InsertModeKey(keyName));
49524975 return true;
49534976 }
4040
4141 /* CURSOR */
4242
43 .CodeMirror div.CodeMirror-cursor {
43 .CodeMirror-cursor {
4444 border-left: 1px solid black;
45 border-right: none;
46 width: 0;
4547 }
4648 /* Shown when moving in bi-directional text */
4749 .CodeMirror div.CodeMirror-secondarycursor {
4850 border-left: 1px solid silver;
4951 }
50 .CodeMirror.cm-fat-cursor div.CodeMirror-cursor {
52 .cm-fat-cursor .CodeMirror-cursor {
5153 width: auto;
52 border: 0;
54 border: 0 !important;
5355 background: #7e7;
5456 }
55 .CodeMirror.cm-fat-cursor div.CodeMirror-cursors {
57 .cm-fat-cursor div.CodeMirror-cursors {
5658 z-index: 1;
5759 }
5860
6264 -webkit-animation: blink 1.06s steps(1) infinite;
6365 -moz-animation: blink 1.06s steps(1) infinite;
6466 animation: blink 1.06s steps(1) infinite;
67 background-color: #7e7;
6568 }
6669 @-moz-keyframes blink {
67 0% { background: #7e7; }
68 50% { background: none; }
69 100% { background: #7e7; }
70 0% {}
71 50% { background-color: transparent; }
72 100% {}
7073 }
7174 @-webkit-keyframes blink {
72 0% { background: #7e7; }
73 50% { background: none; }
74 100% { background: #7e7; }
75 0% {}
76 50% { background-color: transparent; }
77 100% {}
7578 }
7679 @keyframes blink {
77 0% { background: #7e7; }
78 50% { background: none; }
79 100% { background: #7e7; }
80 0% {}
81 50% { background-color: transparent; }
82 100% {}
8083 }
8184
8285 /* Can style cursor different in overwrite (non-insert) mode */
83 div.CodeMirror-overwrite div.CodeMirror-cursor {}
86 .CodeMirror-overwrite .CodeMirror-cursor {}
8487
8588 .cm-tab { display: inline-block; text-decoration: inherit; }
8689
90 .CodeMirror-rulers {
91 position: absolute;
92 left: 0; right: 0; top: -50px; bottom: -20px;
93 overflow: hidden;
94 }
8795 .CodeMirror-ruler {
8896 border-left: 1px solid #ccc;
97 top: 0; bottom: 0;
8998 position: absolute;
9099 }
91100
161170 }
162171
163172 /* The fake, visible scrollbars. Used to force redraw during scrolling
164 before actuall scrolling happens, thus preventing shaking and
173 before actual scrolling happens, thus preventing shaking and
165174 flickering artifacts. */
166175 .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
167176 position: absolute;
187196
188197 .CodeMirror-gutters {
189198 position: absolute; left: 0; top: 0;
199 min-height: 100%;
190200 z-index: 3;
191201 }
192202 .CodeMirror-gutter {
193203 white-space: normal;
194204 height: 100%;
195205 display: inline-block;
206 vertical-align: top;
196207 margin-bottom: -30px;
197208 /* Hack to make IE7 behave */
198209 *zoom:1;
201212 .CodeMirror-gutter-wrapper {
202213 position: absolute;
203214 z-index: 4;
204 height: 100%;
215 background: none !important;
216 border: none !important;
217 }
218 .CodeMirror-gutter-background {
219 position: absolute;
220 top: 0; bottom: 0;
221 z-index: 4;
205222 }
206223 .CodeMirror-gutter-elt {
207224 position: absolute;
234251 position: relative;
235252 overflow: visible;
236253 -webkit-tap-highlight-color: transparent;
254 -webkit-font-variant-ligatures: none;
255 font-variant-ligatures: none;
237256 }
238257 .CodeMirror-wrap pre {
239258 word-wrap: break-word;
276295 overflow: hidden;
277296 visibility: hidden;
278297 }
298
299 .CodeMirror-cursor {
300 position: absolute;
301 pointer-events: none;
302 }
279303 .CodeMirror-measure pre { position: static; }
280
281 .CodeMirror div.CodeMirror-cursor {
282 position: absolute;
283 border-right: none;
284 width: 0;
285 }
286304
287305 div.CodeMirror-cursors {
288306 visibility: hidden;
289307 position: relative;
290308 z-index: 3;
291309 }
310 div.CodeMirror-dragcursors {
311 visibility: visible;
312 }
313
292314 .CodeMirror-focused div.CodeMirror-cursors {
293315 visibility: visible;
294316 }
296318 .CodeMirror-selected { background: #d9d9d9; }
297319 .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
298320 .CodeMirror-crosshair { cursor: crosshair; }
299 .CodeMirror ::selection { background: #d7d4f0; }
300 .CodeMirror ::-moz-selection { background: #d7d4f0; }
321 .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
322 .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
301323
302324 .cm-searching {
303325 background: #ffa;
1212 else if (typeof define == "function" && define.amd) // AMD
1313 return define([], mod);
1414 else // Plain browser env
15 this.CodeMirror = mod();
15 (this || window).CodeMirror = mod();
1616 })(function() {
1717 "use strict";
1818
2020
2121 // Kludges for bugs and behavior differences that can't be feature
2222 // detected are enabled based on userAgent etc sniffing.
23
24 var gecko = /gecko\/\d/i.test(navigator.userAgent);
25 var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
26 var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
23 var userAgent = navigator.userAgent;
24 var platform = navigator.platform;
25
26 var gecko = /gecko\/\d/i.test(userAgent);
27 var ie_upto10 = /MSIE \d/.test(userAgent);
28 var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
2729 var ie = ie_upto10 || ie_11up;
2830 var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
29 var webkit = /WebKit\//.test(navigator.userAgent);
30 var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
31 var chrome = /Chrome\//.test(navigator.userAgent);
32 var presto = /Opera\//.test(navigator.userAgent);
31 var webkit = /WebKit\//.test(userAgent);
32 var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
33 var chrome = /Chrome\//.test(userAgent);
34 var presto = /Opera\//.test(userAgent);
3335 var safari = /Apple Computer/.test(navigator.vendor);
34 var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
35 var phantom = /PhantomJS/.test(navigator.userAgent);
36
37 var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
36 var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
37 var phantom = /PhantomJS/.test(userAgent);
38
39 var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
3840 // This is woefully incomplete. Suggestions for alternative methods welcome.
39 var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
40 var mac = ios || /Mac/.test(navigator.platform);
41 var windows = /win/i.test(navigator.platform);
42
43 var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
41 var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
42 var mac = ios || /Mac/.test(platform);
43 var chromeOS = /\bCrOS\b/.test(userAgent);
44 var windows = /win/i.test(platform);
45
46 var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
4447 if (presto_version) presto_version = Number(presto_version[1]);
4548 if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
4649 // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
6467 setGuttersForLineNumbers(options);
6568
6669 var doc = options.value;
67 if (typeof doc == "string") doc = new Doc(doc, options.mode);
70 if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
6871 this.doc = doc;
6972
7073 var input = new CodeMirror.inputStyles[options.inputStyle](this);
8689 focused: false,
8790 suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
8891 pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
92 selectingText: false,
8993 draggingText: false,
9094 highlight: new Delayed(), // stores highlight worker timeout
9195 keySeq: null, // Unfinished key sequence
406410 if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
407411 });
408412
409 this.checkedOverlay = false;
413 this.checkedZeroWidth = false;
410414 // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
411415 if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
412416 }
441445 this.horiz.firstChild.style.width = "0";
442446 }
443447
444 if (!this.checkedOverlay && measure.clientHeight > 0) {
445 if (sWidth == 0) this.overlayHack();
446 this.checkedOverlay = true;
448 if (!this.checkedZeroWidth && measure.clientHeight > 0) {
449 if (sWidth == 0) this.zeroWidthHack();
450 this.checkedZeroWidth = true;
447451 }
448452
449453 return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
450454 },
451455 setScrollLeft: function(pos) {
452456 if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
457 if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz);
453458 },
454459 setScrollTop: function(pos) {
455460 if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
456 },
457 overlayHack: function() {
461 if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert);
462 },
463 zeroWidthHack: function() {
458464 var w = mac && !mac_geMountainLion ? "12px" : "18px";
459 this.horiz.style.minHeight = this.vert.style.minWidth = w;
460 var self = this;
461 var barMouseDown = function(e) {
462 if (e_target(e) != self.vert && e_target(e) != self.horiz)
463 operation(self.cm, onMouseDown)(e);
464 };
465 on(this.vert, "mousedown", barMouseDown);
466 on(this.horiz, "mousedown", barMouseDown);
465 this.horiz.style.height = this.vert.style.width = w;
466 this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
467 this.disableHoriz = new Delayed;
468 this.disableVert = new Delayed;
469 },
470 enableZeroWidthBar: function(bar, delay) {
471 bar.style.pointerEvents = "auto";
472 function maybeDisable() {
473 // To find out whether the scrollbar is still visible, we
474 // check whether the element under the pixel in the bottom
475 // left corner of the scrollbar box is the scrollbar box
476 // itself (when the bar is still visible) or its filler child
477 // (when the bar is hidden). If it is still visible, we keep
478 // it enabled, if it's hidden, we disable pointer events.
479 var box = bar.getBoundingClientRect();
480 var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
481 if (elt != bar) bar.style.pointerEvents = "none";
482 else delay.set(1000, maybeDisable);
483 }
484 delay.set(1000, maybeDisable);
467485 },
468486 clear: function() {
469487 var parent = this.horiz.parentNode;
525543
526544 d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
527545 d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
546 d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
528547
529548 if (sizes.right && sizes.bottom) {
530549 d.scrollbarFiller.style.display = "block";
572591 var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
573592 var gutterW = display.gutters.offsetWidth, left = comp + "px";
574593 for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
575 if (cm.options.fixedGutter && view[i].gutter)
576 view[i].gutter.style.left = left;
594 if (cm.options.fixedGutter) {
595 if (view[i].gutter)
596 view[i].gutter.style.left = left;
597 if (view[i].gutterBackground)
598 view[i].gutterBackground.style.left = left;
599 }
577600 var align = view[i].alignable;
578601 if (align) for (var j = 0; j < align.length; j++)
579602 align[j].style.left = left;
713736 // width and height.
714737 removeChildren(display.cursorDiv);
715738 removeChildren(display.selectionDiv);
716 display.gutters.style.height = 0;
739 display.gutters.style.height = display.sizer.style.minHeight = 0;
717740
718741 if (different) {
719742 display.lastWrapHeight = update.wrapperHeight;
728751
729752 function postUpdateDisplay(cm, update) {
730753 var viewport = update.viewport;
754
731755 for (var first = true;; first = false) {
732756 if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
733757 // Clip forced viewport to actual scrollable area.
743767 updateHeightsInViewport(cm);
744768 var barMeasure = measureForScrollbars(cm);
745769 updateSelection(cm);
770 updateScrollbars(cm, barMeasure);
746771 setDocumentHeight(cm, barMeasure);
747 updateScrollbars(cm, barMeasure);
748772 }
749773
750774 update.signal(cm, "update", cm);
761785 postUpdateDisplay(cm, update);
762786 var barMeasure = measureForScrollbars(cm);
763787 updateSelection(cm);
788 updateScrollbars(cm, barMeasure);
764789 setDocumentHeight(cm, barMeasure);
765 updateScrollbars(cm, barMeasure);
766790 update.finish();
767791 }
768792 }
769793
770794 function setDocumentHeight(cm, measure) {
771795 cm.display.sizer.style.minHeight = measure.docHeight + "px";
772 var total = measure.docHeight + cm.display.barHeight;
773 cm.display.heightForcer.style.top = total + "px";
774 cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
796 cm.display.heightForcer.style.top = measure.docHeight + "px";
797 cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
775798 }
776799
777800 // Read the actual heights of the rendered lines, and update their
805828 // given line.
806829 function updateWidgetHeight(line) {
807830 if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
808 line.widgets[i].height = line.widgets[i].node.offsetHeight;
831 line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight;
809832 }
810833
811834 // Do a bulk-read of the DOM positions and sizes needed to draw the
954977 lineView.node.removeChild(lineView.gutter);
955978 lineView.gutter = null;
956979 }
980 if (lineView.gutterBackground) {
981 lineView.node.removeChild(lineView.gutterBackground);
982 lineView.gutterBackground = null;
983 }
984 if (lineView.line.gutterClass) {
985 var wrap = ensureLineWrapped(lineView);
986 lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
987 "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
988 "px; width: " + dims.gutterTotalWidth + "px");
989 wrap.insertBefore(lineView.gutterBackground, lineView.text);
990 }
957991 var markers = lineView.line.gutterMarkers;
958992 if (cm.options.lineNumbers || markers) {
959993 var wrap = ensureLineWrapped(lineView);
960994 var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
961 (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
962 "px; width: " + dims.gutterTotalWidth + "px");
995 (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
963996 cm.display.input.setUneditable(gutterWrap);
964997 wrap.insertBefore(gutterWrap, lineView.text);
965998 if (lineView.line.gutterClass)
10661099 if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
10671100 }
10681101
1069 function isReadOnly(cm) {
1070 return cm.options.readOnly || cm.doc.cantEdit;
1071 }
1072
1073 // This will be set to an array of strings when copying, so that,
1074 // when pasting, we know what kind of selections the copied text
1075 // was made out of.
1102 // This will be set to a {lineWise: bool, text: [string]} object, so
1103 // that, when pasting, we know what kind of selections the copied
1104 // text was made out of.
10761105 var lastCopied = null;
10771106
10781107 function applyTextInput(cm, inserted, deleted, sel, origin) {
10811110 if (!sel) sel = doc.sel;
10821111
10831112 var paste = cm.state.pasteIncoming || origin == "paste";
1084 var textLines = splitLines(inserted), multiPaste = null;
1113 var textLines = doc.splitLines(inserted), multiPaste = null
10851114 // When pasing N lines into N selections, insert one line per selection
10861115 if (paste && sel.ranges.length > 1) {
1087 if (lastCopied && lastCopied.join("\n") == inserted)
1088 multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines);
1089 else if (textLines.length == sel.ranges.length)
1116 if (lastCopied && lastCopied.text.join("\n") == inserted) {
1117 if (sel.ranges.length % lastCopied.text.length == 0) {
1118 multiPaste = [];
1119 for (var i = 0; i < lastCopied.text.length; i++)
1120 multiPaste.push(doc.splitLines(lastCopied.text[i]));
1121 }
1122 } else if (textLines.length == sel.ranges.length) {
10901123 multiPaste = map(textLines, function(l) { return [l]; });
1124 }
10911125 }
10921126
10931127 // Normal behavior is to insert the new text into every selection
10991133 from = Pos(from.line, from.ch - deleted);
11001134 else if (cm.state.overwrite && !paste) // Handle overwrite
11011135 to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
1136 else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
1137 from = to = Pos(from.line, 0)
11021138 }
11031139 var updateInput = cm.curOp.updateInput;
11041140 var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
11161152 }
11171153
11181154 function handlePaste(e, cm) {
1119 var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
1155 var pasted = e.clipboardData && e.clipboardData.getData("Text");
11201156 if (pasted) {
11211157 e.preventDefault();
1122 runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
1158 if (!cm.isReadOnly() && !cm.options.disableInput)
1159 runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
11231160 return true;
11241161 }
11251162 }
11591196 return {text: text, ranges: ranges};
11601197 }
11611198
1162 function disableBrowserMagic(field) {
1199 function disableBrowserMagic(field, spellcheck) {
11631200 field.setAttribute("autocorrect", "off");
11641201 field.setAttribute("autocapitalize", "off");
1165 field.setAttribute("spellcheck", "false");
1202 field.setAttribute("spellcheck", !!spellcheck);
11661203 }
11671204
11681205 // TEXTAREA INPUT STYLE
11871224 };
11881225
11891226 function hiddenTextarea() {
1190 var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
1227 var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
11911228 var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
11921229 // The textarea is kept positioned near the cursor to prevent the
11931230 // fact that it'll be scrolled into view on input from scrolling
12211258 });
12221259
12231260 on(te, "paste", function(e) {
1224 if (handlePaste(e, cm)) return true;
1261 if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
12251262
12261263 cm.state.pasteIncoming = true;
12271264 input.fastPoll();
12281265 });
12291266
12301267 function prepareCopyCut(e) {
1268 if (signalDOMEvent(cm, e)) return
12311269 if (cm.somethingSelected()) {
1232 lastCopied = cm.getSelections();
1270 lastCopied = {lineWise: false, text: cm.getSelections()};
12331271 if (input.inaccurateSelection) {
12341272 input.prevInput = "";
12351273 input.inaccurateSelection = false;
1236 te.value = lastCopied.join("\n");
1274 te.value = lastCopied.text.join("\n");
12371275 selectInput(te);
12381276 }
12391277 } else if (!cm.options.lineWiseCopyCut) {
12401278 return;
12411279 } else {
12421280 var ranges = copyableRanges(cm);
1243 lastCopied = ranges.text;
1281 lastCopied = {lineWise: true, text: ranges.text};
12441282 if (e.type == "cut") {
12451283 cm.setSelections(ranges.ranges, null, sel_dontScroll);
12461284 } else {
12551293 on(te, "copy", prepareCopyCut);
12561294
12571295 on(display.scroller, "paste", function(e) {
1258 if (eventInWidget(display, e)) return;
1296 if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return;
12591297 cm.state.pasteIncoming = true;
12601298 input.focus();
12611299 });
12671305
12681306 on(te, "compositionstart", function() {
12691307 var start = cm.getCursor("from");
1308 if (input.composing) input.composing.range.clear()
12701309 input.composing = {
12711310 start: start,
12721311 range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
13871426 // will be the case when there is a lot of text in the textarea,
13881427 // in which case reading its value would be expensive.
13891428 if (this.contextMenuPending || !cm.state.focused ||
1390 (hasSelection(input) && !prevInput) ||
1391 isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
1429 (hasSelection(input) && !prevInput && !this.composing) ||
1430 cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
13921431 return false;
13931432
13941433 var text = input.value;
14501489 if (reset && cm.doc.sel.contains(pos) == -1)
14511490 operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
14521491
1453 var oldCSS = te.style.cssText;
1454 input.wrapper.style.position = "absolute";
1455 te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
1456 "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
1492 var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
1493 input.wrapper.style.cssText = "position: absolute"
1494 var wrapperBox = input.wrapper.getBoundingClientRect()
1495 te.style.cssText = "position: absolute; width: 30px; height: 30px; top: " + (e.clientY - wrapperBox.top - 5) +
1496 "px; left: " + (e.clientX - wrapperBox.left - 5) + "px; z-index: 1000; background: " +
14571497 (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
14581498 "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
14591499 if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
14841524 }
14851525 function rehide() {
14861526 input.contextMenuPending = false;
1487 input.wrapper.style.position = "relative";
1527 input.wrapper.style.cssText = oldWrapperCSS
14881528 te.style.cssText = oldCSS;
14891529 if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
14901530
15151555 }
15161556 },
15171557
1558 readOnlyChanged: function(val) {
1559 if (!val) this.reset();
1560 },
1561
15181562 setUneditable: nothing,
15191563
15201564 needsContentAttribute: false
15331577 init: function(display) {
15341578 var input = this, cm = input.cm;
15351579 var div = input.div = display.lineDiv;
1536 div.contentEditable = "true";
1537 disableBrowserMagic(div);
1538
1539 on(div, "paste", function(e) { handlePaste(e, cm); })
1580 disableBrowserMagic(div, cm.options.spellcheck);
1581
1582 on(div, "paste", function(e) {
1583 if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
1584 // IE doesn't fire input events, so we schedule a read for the pasted content in this way
1585 if (ie_version <= 11) setTimeout(operation(cm, function() {
1586 if (!input.pollContent()) regChange(cm);
1587 }), 20)
1588 })
15401589
15411590 on(div, "compositionstart", function(e) {
15421591 var data = e.data;
15741623
15751624 on(div, "input", function() {
15761625 if (input.composing) return;
1577 if (!input.pollContent())
1626 if (cm.isReadOnly() || !input.pollContent())
15781627 runInOp(input.cm, function() {regChange(cm);});
15791628 });
15801629
15811630 function onCopyCut(e) {
1631 if (signalDOMEvent(cm, e)) return
15821632 if (cm.somethingSelected()) {
1583 lastCopied = cm.getSelections();
1633 lastCopied = {lineWise: false, text: cm.getSelections()};
15841634 if (e.type == "cut") cm.replaceSelection("", null, "cut");
15851635 } else if (!cm.options.lineWiseCopyCut) {
15861636 return;
15871637 } else {
15881638 var ranges = copyableRanges(cm);
1589 lastCopied = ranges.text;
1639 lastCopied = {lineWise: true, text: ranges.text};
15901640 if (e.type == "cut") {
15911641 cm.operation(function() {
15921642 cm.setSelections(ranges.ranges, 0, sel_dontScroll);
15941644 });
15951645 }
15961646 }
1597 // iOS exposes the clipboard API, but seems to discard content inserted into it
1598 if (e.clipboardData && !ios) {
1599 e.preventDefault();
1647 if (e.clipboardData) {
16001648 e.clipboardData.clearData();
1601 e.clipboardData.setData("text/plain", lastCopied.join("\n"));
1602 } else {
1603 // Old-fashioned briefly-focus-a-textarea hack
1604 var kludge = hiddenTextarea(), te = kludge.firstChild;
1605 cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
1606 te.value = lastCopied.join("\n");
1607 var hadFocus = document.activeElement;
1608 selectInput(te);
1609 setTimeout(function() {
1610 cm.display.lineSpace.removeChild(kludge);
1611 hadFocus.focus();
1612 }, 50);
1649 var content = lastCopied.text.join("\n")
1650 // iOS exposes the clipboard API, but seems to discard content inserted into it
1651 e.clipboardData.setData("Text", content);
1652 if (e.clipboardData.getData("Text") == content) {
1653 e.preventDefault();
1654 return
1655 }
16131656 }
1657 // Old-fashioned briefly-focus-a-textarea hack
1658 var kludge = hiddenTextarea(), te = kludge.firstChild;
1659 cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
1660 te.value = lastCopied.text.join("\n");
1661 var hadFocus = document.activeElement;
1662 selectInput(te);
1663 setTimeout(function() {
1664 cm.display.lineSpace.removeChild(kludge);
1665 hadFocus.focus();
1666 if (hadFocus == div) input.showPrimarySelection()
1667 }, 50);
16141668 }
16151669 on(div, "copy", onCopyCut);
16161670 on(div, "cut", onCopyCut);
16221676 return result;
16231677 },
16241678
1625 showSelection: function(info) {
1679 showSelection: function(info, takeFocus) {
16261680 if (!info || !this.cm.display.view.length) return;
1627 if (info.focus) this.showPrimarySelection();
1681 if (info.focus || takeFocus) this.showPrimarySelection();
16281682 this.showMultipleSelections(info);
16291683 },
16301684
16541708 try { var rng = range(start.node, start.offset, end.offset, end.node); }
16551709 catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
16561710 if (rng) {
1657 sel.removeAllRanges();
1658 sel.addRange(rng);
1711 if (!gecko && this.cm.state.focused) {
1712 sel.collapse(start.node, start.offset);
1713 if (!rng.collapsed) sel.addRange(rng);
1714 } else {
1715 sel.removeAllRanges();
1716 sel.addRange(rng);
1717 }
16591718 if (old && sel.anchorNode == null) sel.addRange(old);
16601719 else if (gecko) this.startGracePeriod();
16611720 }
17551814 var toNode = display.view[toIndex + 1].node.previousSibling;
17561815 }
17571816
1758 var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
1817 var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
17591818 var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
17601819 while (newText.length > 1 && oldText.length > 1) {
17611820 if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
17991858 this.div.focus();
18001859 },
18011860 applyComposition: function(composing) {
1802 if (composing.data && composing.data != composing.startData)
1861 if (this.cm.isReadOnly())
1862 operation(this.cm, regChange)(this.cm)
1863 else if (composing.data && composing.data != composing.startData)
18031864 operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
18041865 },
18051866
18061867 setUneditable: function(node) {
1807 node.setAttribute("contenteditable", "false");
1868 node.contentEditable = "false"
18081869 },
18091870
18101871 onKeyPress: function(e) {
18111872 e.preventDefault();
1812 operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
1873 if (!this.cm.isReadOnly())
1874 operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
1875 },
1876
1877 readOnlyChanged: function(val) {
1878 this.div.contentEditable = String(val != "nocursor")
18131879 },
18141880
18151881 onContextMenu: nothing,
19061972 if (found)
19071973 return badPos(Pos(found.line, found.ch + dist), bad);
19081974 else
1909 dist += after.textContent.length;
1975 dist += before.textContent.length;
19101976 }
19111977 }
19121978
19131979 function domTextBetween(cm, from, to, fromLine, toLine) {
1914 var text = "", closing = false;
1980 var text = "", closing = false, lineSep = cm.doc.lineSeparator();
19151981 function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
19161982 function walk(node) {
19171983 if (node.nodeType == 1) {
19251991 if (markerID) {
19261992 var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
19271993 if (found.length && (range = found[0].find()))
1928 text += getBetween(cm.doc, range.from, range.to).join("\n");
1994 text += getBetween(cm.doc, range.from, range.to).join(lineSep);
19291995 return;
19301996 }
19311997 if (node.getAttribute("contenteditable") == "false") return;
19372003 var val = node.nodeValue;
19382004 if (!val) return;
19392005 if (closing) {
1940 text += "\n";
2006 text += lineSep;
19412007 closing = false;
19422008 }
19432009 text += val;
21092175
21102176 // Give beforeSelectionChange handlers a change to influence a
21112177 // selection update.
2112 function filterSelectionChange(doc, sel) {
2178 function filterSelectionChange(doc, sel, options) {
21132179 var obj = {
21142180 ranges: sel.ranges,
21152181 update: function(ranges) {
21172183 for (var i = 0; i < ranges.length; i++)
21182184 this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
21192185 clipPos(doc, ranges[i].head));
2120 }
2186 },
2187 origin: options && options.origin
21212188 };
21222189 signal(doc, "beforeSelectionChange", doc, obj);
21232190 if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
21432210
21442211 function setSelectionNoUndo(doc, sel, options) {
21452212 if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
2146 sel = filterSelectionChange(doc, sel);
2213 sel = filterSelectionChange(doc, sel, options);
21472214
21482215 var bias = options && options.bias ||
21492216 (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
21772244 var out;
21782245 for (var i = 0; i < sel.ranges.length; i++) {
21792246 var range = sel.ranges[i];
2180 var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
2181 var newHead = skipAtomic(doc, range.head, bias, mayClear);
2247 var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
2248 var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
2249 var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
21822250 if (out || newAnchor != range.anchor || newHead != range.head) {
21832251 if (!out) out = sel.ranges.slice(0, i);
21842252 out[i] = new Range(newAnchor, newHead);
21872255 return out ? normalizeSelection(out, sel.primIndex) : sel;
21882256 }
21892257
2190 // Ensure a given position is not inside an atomic range.
2191 function skipAtomic(doc, pos, bias, mayClear) {
2192 var flipped = false, curPos = pos;
2193 var dir = bias || 1;
2194 doc.cantEdit = false;
2195 search: for (;;) {
2196 var line = getLine(doc, curPos.line);
2197 if (line.markedSpans) {
2198 for (var i = 0; i < line.markedSpans.length; ++i) {
2199 var sp = line.markedSpans[i], m = sp.marker;
2200 if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
2201 (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
2202 if (mayClear) {
2203 signal(m, "beforeCursorEnter");
2204 if (m.explicitlyCleared) {
2205 if (!line.markedSpans) break;
2206 else {--i; continue;}
2207 }
2208 }
2209 if (!m.atomic) continue;
2210 var newPos = m.find(dir < 0 ? -1 : 1);
2211 if (cmp(newPos, curPos) == 0) {
2212 newPos.ch += dir;
2213 if (newPos.ch < 0) {
2214 if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
2215 else newPos = null;
2216 } else if (newPos.ch > line.text.length) {
2217 if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
2218 else newPos = null;
2219 }
2220 if (!newPos) {
2221 if (flipped) {
2222 // Driven in a corner -- no valid cursor position found at all
2223 // -- try again *with* clearing, if we didn't already
2224 if (!mayClear) return skipAtomic(doc, pos, bias, true);
2225 // Otherwise, turn off editing until further notice, and return the start of the doc
2226 doc.cantEdit = true;
2227 return Pos(doc.first, 0);
2228 }
2229 flipped = true; newPos = pos; dir = -dir;
2230 }
2231 }
2232 curPos = newPos;
2233 continue search;
2258 function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
2259 var line = getLine(doc, pos.line);
2260 if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
2261 var sp = line.markedSpans[i], m = sp.marker;
2262 if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
2263 (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
2264 if (mayClear) {
2265 signal(m, "beforeCursorEnter");
2266 if (m.explicitlyCleared) {
2267 if (!line.markedSpans) break;
2268 else {--i; continue;}
22342269 }
22352270 }
2236 }
2237 return curPos;
2271 if (!m.atomic) continue;
2272
2273 if (oldPos) {
2274 var near = m.find(dir < 0 ? 1 : -1), diff;
2275 if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
2276 near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null);
2277 if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
2278 return skipAtomicInner(doc, near, pos, dir, mayClear);
2279 }
2280
2281 var far = m.find(dir < 0 ? -1 : 1);
2282 if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
2283 far = movePos(doc, far, dir, far.line == pos.line ? line : null);
2284 return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
2285 }
2286 }
2287 return pos;
2288 }
2289
2290 // Ensure a given position is not inside an atomic range.
2291 function skipAtomic(doc, pos, oldPos, bias, mayClear) {
2292 var dir = bias || 1;
2293 var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
2294 (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
2295 skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
2296 (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
2297 if (!found) {
2298 doc.cantEdit = true;
2299 return Pos(doc.first, 0);
2300 }
2301 return found;
2302 }
2303
2304 function movePos(doc, pos, dir, line) {
2305 if (dir < 0 && pos.ch == 0) {
2306 if (pos.line > doc.first) return clipPos(doc, Pos(pos.line - 1));
2307 else return null;
2308 } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
2309 if (pos.line < doc.first + doc.size - 1) return Pos(pos.line + 1, 0);
2310 else return null;
2311 } else {
2312 return new Pos(pos.line, pos.ch + dir);
22382313 }
22392314 }
22402315
22522327 for (var i = 0; i < doc.sel.ranges.length; i++) {
22532328 if (primary === false && i == doc.sel.primIndex) continue;
22542329 var range = doc.sel.ranges[i];
2330 if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) continue;
22552331 var collapsed = range.empty();
22562332 if (collapsed || cm.options.showCursorWhenSelecting)
2257 drawSelectionCursor(cm, range, curFragment);
2333 drawSelectionCursor(cm, range.head, curFragment);
22582334 if (!collapsed)
22592335 drawSelectionRange(cm, range, selFragment);
22602336 }
22622338 }
22632339
22642340 // Draws a cursor for the given range
2265 function drawSelectionCursor(cm, range, output) {
2266 var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine);
2341 function drawSelectionCursor(cm, head, output) {
2342 var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
22672343
22682344 var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
22692345 cursor.style.left = pos.left + "px";
23872463
23882464 doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
23892465 if (doc.frontier >= cm.display.viewFrom) { // Visible
2390 var oldStyles = line.styles;
2391 var highlighted = highlightLine(cm, line, state, true);
2466 var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
2467 var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
23922468 line.styles = highlighted.styles;
23932469 var oldCls = line.styleClasses, newCls = highlighted.classes;
23942470 if (newCls) line.styleClasses = newCls;
23972473 oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
23982474 for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
23992475 if (ischange) changedLines.push(doc.frontier);
2400 line.stateAfter = copyState(doc.mode, state);
2476 line.stateAfter = tooLong ? state : copyState(doc.mode, state);
24012477 } else {
2402 processLine(cm, line.text, state);
2478 if (line.text.length <= cm.options.maxHighlightLength)
2479 processLine(cm, line.text, state);
24032480 line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
24042481 }
24052482 ++doc.frontier;
25442621 function prepareMeasureForLine(cm, line) {
25452622 var lineN = lineNo(line);
25462623 var view = findViewForLine(cm, lineN);
2547 if (view && !view.text)
2624 if (view && !view.text) {
25482625 view = null;
2549 else if (view && view.changes)
2626 } else if (view && view.changes) {
25502627 updateLineForChanges(cm, view, lineN, getDimensions(cm));
2628 cm.curOp.forceUpdate = true;
2629 }
25512630 if (!view)
25522631 view = updateExternalMeasurement(cm, line);
25532632
26202699 return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
26212700 }
26222701
2702 function getUsefulRect(rects, bias) {
2703 var rect = nullRect
2704 if (bias == "left") for (var i = 0; i < rects.length; i++) {
2705 if ((rect = rects[i]).left != rect.right) break
2706 } else for (var i = rects.length - 1; i >= 0; i--) {
2707 if ((rect = rects[i]).left != rect.right) break
2708 }
2709 return rect
2710 }
2711
26232712 function measureCharInner(cm, prepared, ch, bias) {
26242713 var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
26252714 var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
26292718 for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
26302719 while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
26312720 while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
2632 if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
2721 if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
26332722 rect = node.parentNode.getBoundingClientRect();
2634 } else if (ie && cm.options.lineWrapping) {
2635 var rects = range(node, start, end).getClientRects();
2636 if (rects.length)
2637 rect = rects[bias == "right" ? rects.length - 1 : 0];
2638 else
2639 rect = nullRect;
2640 } else {
2641 rect = range(node, start, end).getBoundingClientRect() || nullRect;
2642 }
2723 else
2724 rect = getUsefulRect(range(node, start, end).getClientRects(), bias)
26432725 if (rect.left || rect.right || start == 0) break;
26442726 end = start;
26452727 start = start - 1;
28652947 for (;;) {
28662948 if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
28672949 var ch = x < fromX || x - fromX <= toX - x ? from : to;
2950 var outside = ch == from ? fromOutside : toOutside
28682951 var xDiff = x - (ch == from ? fromX : toX);
2952 // This is a kludge to handle the case where the coordinates
2953 // are after a line-wrapped line. We should replace it with a
2954 // more general handling of cursor positions around line
2955 // breaks. (Issue #4078)
2956 if (toOutside && !bidi && !/\s/.test(lineObj.text.charAt(ch)) && xDiff > 0 &&
2957 ch < lineObj.text.length && preparedMeasure.view.measure.heights.length > 1) {
2958 var charSize = measureCharPrepared(cm, preparedMeasure, ch, "right");
2959 if (innerOff <= charSize.bottom && innerOff >= charSize.top && Math.abs(x - charSize.right) < xDiff) {
2960 outside = false
2961 ch++
2962 xDiff = x - charSize.right
2963 }
2964 }
28692965 while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
2870 var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
2871 xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
2966 var pos = PosWithInfo(lineNo, ch, outside, xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
28722967 return pos;
28732968 }
28742969 var step = Math.ceil(dist / 2), middle = from + step;
29603055 var callbacks = group.delayedCallbacks, i = 0;
29613056 do {
29623057 for (; i < callbacks.length; i++)
2963 callbacks[i]();
3058 callbacks[i].call(null);
29643059 for (var j = 0; j < group.ops.length; j++) {
29653060 var op = group.ops[j];
29663061 if (op.cursorActivityHandlers)
29673062 while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
2968 op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
3063 op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm);
29693064 }
29703065 } while (i < callbacks.length);
29713066 }
30353130 }
30363131
30373132 if (op.updatedDisplay || op.selectionChanged)
3038 op.preparedSelection = display.input.prepareSelection();
3133 op.preparedSelection = display.input.prepareSelection(op.focus);
30393134 }
30403135
30413136 function endOperation_W2(op) {
30483143 cm.display.maxLineChanged = false;
30493144 }
30503145
3146 var takeFocus = op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus())
30513147 if (op.preparedSelection)
3052 cm.display.input.showSelection(op.preparedSelection);
3148 cm.display.input.showSelection(op.preparedSelection, takeFocus);
3149 if (op.updatedDisplay || op.startHeight != cm.doc.height)
3150 updateScrollbars(cm, op.barMeasure);
30533151 if (op.updatedDisplay)
30543152 setDocumentHeight(cm, op.barMeasure);
3055 if (op.updatedDisplay || op.startHeight != cm.doc.height)
3056 updateScrollbars(cm, op.barMeasure);
30573153
30583154 if (op.selectionChanged) restartBlink(cm);
30593155
30603156 if (cm.state.focused && op.updateInput)
30613157 cm.display.input.reset(op.typing);
3062 if (op.focus && op.focus == activeElt()) ensureFocus(op.cm);
3158 if (takeFocus) ensureFocus(op.cm);
30633159 }
30643160
30653161 function endOperation_finish(op) {
30783174 display.scroller.scrollTop = doc.scrollTop;
30793175 }
30803176 if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
3081 doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
3177 doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft));
30823178 display.scrollbars.setScrollLeft(doc.scrollLeft);
30833179 display.scroller.scrollLeft = doc.scrollLeft;
30843180 alignHorizontally(cm);
33743470 return dx * dx + dy * dy > 20 * 20;
33753471 }
33763472 on(d.scroller, "touchstart", function(e) {
3377 if (!isMouseLikeTouchEvent(e)) {
3473 if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) {
33783474 clearTimeout(touchFinished);
33793475 var now = +new Date;
33803476 d.activeTouch = {start: now, moved: false,
34253521 on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
34263522
34273523 d.dragFunctions = {
3428 simple: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
3524 enter: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
3525 over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
34293526 start: function(e){onDragStart(cm, e);},
3430 drop: operation(cm, onDrop)
3527 drop: operation(cm, onDrop),
3528 leave: function(e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
34313529 };
34323530
34333531 var inp = d.input.getField();
34343532 on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
34353533 on(inp, "keydown", operation(cm, onKeyDown));
34363534 on(inp, "keypress", operation(cm, onKeyPress));
3437 on(inp, "focus", bind(onFocus, cm));
3438 on(inp, "blur", bind(onBlur, cm));
3535 on(inp, "focus", function (e) { onFocus(cm, e); });
3536 on(inp, "blur", function (e) { onBlur(cm, e); });
34393537 }
34403538
34413539 function dragDropChanged(cm, value, old) {
34443542 var funcs = cm.display.dragFunctions;
34453543 var toggle = value ? on : off;
34463544 toggle(cm.display.scroller, "dragstart", funcs.start);
3447 toggle(cm.display.scroller, "dragenter", funcs.simple);
3448 toggle(cm.display.scroller, "dragover", funcs.simple);
3545 toggle(cm.display.scroller, "dragenter", funcs.enter);
3546 toggle(cm.display.scroller, "dragover", funcs.over);
3547 toggle(cm.display.scroller, "dragleave", funcs.leave);
34493548 toggle(cm.display.scroller, "drop", funcs.drop);
34503549 }
34513550 }
35003599 // not interfere with, such as a scrollbar or widget.
35013600 function onMouseDown(e) {
35023601 var cm = this, display = cm.display;
3503 if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return;
3602 if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return;
35043603 display.shift = e.shiftKey;
35053604
35063605 if (eventInWidget(display, e)) {
35183617
35193618 switch (e_button(e)) {
35203619 case 1:
3521 if (start)
3620 // #3261: make sure, that we're not starting a second selection
3621 if (cm.state.selectingText)
3622 cm.state.selectingText(e);
3623 else if (start)
35223624 leftButtonDown(cm, e, start);
35233625 else if (e_target(e) == display.scroller)
35243626 e_preventDefault(e);
35533655 }
35543656
35553657 var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
3556 if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
3658 if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
35573659 type == "single" && (contained = sel.contains(start)) > -1 &&
35583660 (cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
35593661 (cmp(contained.to(), start) > 0 || start.xRel < 0))
35853687 // Let the drag handler handle this.
35863688 if (webkit) display.scroller.draggable = true;
35873689 cm.state.draggingText = dragEnd;
3690 dragEnd.copy = mac ? e.altKey : e.ctrlKey
35883691 // IE's approach to draggable
35893692 if (display.scroller.dragDrop) display.scroller.dragDrop();
35903693 on(document, "mouseup", dragEnd);
36083711 ourIndex = doc.sel.primIndex;
36093712 }
36103713
3611 if (e.altKey) {
3714 if (chromeOS ? e.shiftKey && e.metaKey : e.altKey) {
36123715 type = "rect";
36133716 if (!addNew) ourRange = new Range(start, start);
36143717 start = posFromMouse(cm, e, true, true);
36383741 setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
36393742 {scroll: false, origin: "*mouse"});
36403743 } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
3641 setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0));
3744 setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
3745 {scroll: false, origin: "*mouse"});
36423746 startSel = doc.sel;
36433747 } else {
36443748 replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
37163820 }
37173821
37183822 function done(e) {
3823 cm.state.selectingText = false;
37193824 counter = Infinity;
37203825 e_preventDefault(e);
37213826 display.input.focus();
37293834 else extend(e);
37303835 });
37313836 var up = operation(cm, done);
3837 cm.state.selectingText = up;
37323838 on(document, "mousemove", move);
37333839 on(document, "mouseup", up);
37343840 }
37353841
37363842 // Determines whether an event happened in the gutter, and fires the
37373843 // handlers for the corresponding event.
3738 function gutterEvent(cm, e, type, prevent, signalfn) {
3844 function gutterEvent(cm, e, type, prevent) {
37393845 try { var mX = e.clientX, mY = e.clientY; }
37403846 catch(e) { return false; }
37413847 if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
37523858 if (g && g.getBoundingClientRect().right >= mX) {
37533859 var line = lineAtHeight(cm.doc, mY);
37543860 var gutter = cm.options.gutters[i];
3755 signalfn(cm, type, cm, line, gutter, e);
3861 signal(cm, type, cm, line, gutter, e);
37563862 return e_defaultPrevented(e);
37573863 }
37583864 }
37593865 }
37603866
37613867 function clickInGutter(cm, e) {
3762 return gutterEvent(cm, e, "gutterClick", true, signalLater);
3868 return gutterEvent(cm, e, "gutterClick", true);
37633869 }
37643870
37653871 // Kludge to work around strange IE behavior where it'll sometimes
37683874
37693875 function onDrop(e) {
37703876 var cm = this;
3877 clearDragCursor(cm);
37713878 if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
37723879 return;
37733880 e_preventDefault(e);
37743881 if (ie) lastDrop = +new Date;
37753882 var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
3776 if (!pos || isReadOnly(cm)) return;
3883 if (!pos || cm.isReadOnly()) return;
37773884 // Might be a file drop, in which case we simply extract the text
37783885 // and insert it.
37793886 if (files && files.length && window.FileReader && window.File) {
37803887 var n = files.length, text = Array(n), read = 0;
37813888 var loadFile = function(file, i) {
3889 if (cm.options.allowDropFileTypes &&
3890 indexOf(cm.options.allowDropFileTypes, file.type) == -1)
3891 return;
3892
37823893 var reader = new FileReader;
37833894 reader.onload = operation(cm, function() {
3784 text[i] = reader.result;
3895 var content = reader.result;
3896 if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = "";
3897 text[i] = content;
37853898 if (++read == n) {
37863899 pos = clipPos(cm.doc, pos);
3787 var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
3900 var change = {from: pos, to: pos,
3901 text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
3902 origin: "paste"};
37883903 makeChange(cm.doc, change);
37893904 setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
37903905 }
38033918 try {
38043919 var text = e.dataTransfer.getData("Text");
38053920 if (text) {
3806 if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey))
3921 if (cm.state.draggingText && !cm.state.draggingText.copy)
38073922 var selected = cm.listSelections();
38083923 setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
38093924 if (selected) for (var i = 0; i < selected.length; ++i)
38213936 if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
38223937
38233938 e.dataTransfer.setData("Text", cm.getSelection());
3939 e.dataTransfer.effectAllowed = "copyMove"
38243940
38253941 // Use dummy image instead of default browsers image.
38263942 // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
38353951 }
38363952 e.dataTransfer.setDragImage(img, 0, 0);
38373953 if (presto) img.parentNode.removeChild(img);
3954 }
3955 }
3956
3957 function onDragOver(cm, e) {
3958 var pos = posFromMouse(cm, e);
3959 if (!pos) return;
3960 var frag = document.createDocumentFragment();
3961 drawSelectionCursor(cm, pos, frag);
3962 if (!cm.display.dragCursor) {
3963 cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
3964 cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
3965 }
3966 removeChildrenAndAdd(cm.display.dragCursor, frag);
3967 }
3968
3969 function clearDragCursor(cm) {
3970 if (cm.display.dragCursor) {
3971 cm.display.lineSpace.removeChild(cm.display.dragCursor);
3972 cm.display.dragCursor = null;
38383973 }
38393974 }
38403975
39024037
39034038 var display = cm.display, scroll = display.scroller;
39044039 // Quit if there's nothing to scroll here
3905 if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
3906 dy && scroll.scrollHeight > scroll.clientHeight)) return;
4040 var canScrollX = scroll.scrollWidth > scroll.clientWidth;
4041 var canScrollY = scroll.scrollHeight > scroll.clientHeight;
4042 if (!(dx && canScrollX || dy && canScrollY)) return;
39074043
39084044 // Webkit browsers on OS X abort momentum scrolls when the target
39094045 // of the scroll event is removed from the scrollable element.
39274063 // scrolling entirely here. It'll be slightly off from native, but
39284064 // better than glitching out.
39294065 if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
3930 if (dy)
4066 if (dy && canScrollY)
39314067 setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
39324068 setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
3933 e_preventDefault(e);
4069 // Only prevent default scrolling if vertical scrolling is
4070 // actually possible. Otherwise, it causes vertical scroll
4071 // jitter on OSX trackpads when deltaX is small and deltaY
4072 // is large (issue #3579)
4073 if (!dy || (dy && canScrollY))
4074 e_preventDefault(e);
39344075 display.wheelStartX = null; // Abort measurement, if in progress
39354076 return;
39364077 }
39794120 cm.display.input.ensurePolled();
39804121 var prevShift = cm.display.shift, done = false;
39814122 try {
3982 if (isReadOnly(cm)) cm.state.suppressEdits = true;
4123 if (cm.isReadOnly()) cm.state.suppressEdits = true;
39834124 if (dropShift) cm.display.shift = false;
39844125 done = bound(cm) != Pass;
39854126 } finally {
41204261 }, 100);
41214262 }
41224263
4123 function onFocus(cm) {
4264 function onFocus(cm, e) {
41244265 if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
41254266
41264267 if (cm.options.readOnly == "nocursor") return;
41274268 if (!cm.state.focused) {
4128 signal(cm, "focus", cm);
4269 signal(cm, "focus", cm, e);
41294270 cm.state.focused = true;
41304271 addClass(cm.display.wrapper, "CodeMirror-focused");
41314272 // This test prevents this from firing when a context
41394280 }
41404281 restartBlink(cm);
41414282 }
4142 function onBlur(cm) {
4283 function onBlur(cm, e) {
41434284 if (cm.state.delayingBlurEvent) return;
41444285
41454286 if (cm.state.focused) {
4146 signal(cm, "blur", cm);
4287 signal(cm, "blur", cm, e);
41474288 cm.state.focused = false;
41484289 rmClass(cm.display.wrapper, "CodeMirror-focused");
41494290 }
41584299 // right-click take effect on it.
41594300 function onContextMenu(cm, e) {
41604301 if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
4302 if (signalDOMEvent(cm, e, "contextmenu")) return;
41614303 cm.display.input.onContextMenu(e);
41624304 }
41634305
41644306 function contextMenuInGutter(cm, e) {
41654307 if (!hasHandler(cm, "gutterContextMenu")) return false;
4166 return gutterEvent(cm, e, "gutterContextMenu", false, signal);
4308 return gutterEvent(cm, e, "gutterContextMenu", false);
41674309 }
41684310
41694311 // UPDATING
42914433
42924434 // Revert a change stored in a document's history.
42934435 function makeChangeFromHistory(doc, type, allowSelectionOnly) {
4294 if (doc.cm && doc.cm.state.suppressEdits) return;
4436 if (doc.cm && doc.cm.state.suppressEdits && !allowSelectionOnly) return;
42954437
42964438 var hist = doc.history, event, selAfter = doc.sel;
42974439 var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
44674609 function replaceRange(doc, code, from, to, origin) {
44684610 if (!to) to = from;
44694611 if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
4470 if (typeof code == "string") code = splitLines(code);
4612 if (typeof code == "string") code = doc.splitLines(code);
44714613 makeChange(doc, {from: from, to: to, text: code, origin: origin});
44724614 }
44734615
47114853 function findPosH(doc, pos, dir, unit, visually) {
47124854 var line = pos.line, ch = pos.ch, origDir = dir;
47134855 var lineObj = getLine(doc, line);
4714 var possible = true;
47154856 function findNextLine() {
47164857 var l = line + dir;
4717 if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
4858 if (l < doc.first || l >= doc.first + doc.size) return false
47184859 line = l;
47194860 return lineObj = getLine(doc, l);
47204861 }
47244865 if (!boundToLine && findNextLine()) {
47254866 if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
47264867 else ch = dir < 0 ? lineObj.text.length : 0;
4727 } else return (possible = false);
4868 } else return false
47284869 } else ch = next;
47294870 return true;
47304871 }
47314872
4732 if (unit == "char") moveOnce();
4733 else if (unit == "column") moveOnce(true);
4734 else if (unit == "word" || unit == "group") {
4873 if (unit == "char") {
4874 moveOnce()
4875 } else if (unit == "column") {
4876 moveOnce(true)
4877 } else if (unit == "word" || unit == "group") {
47354878 var sawType = null, group = unit == "group";
47364879 var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
47374880 for (var first = true;; first = false) {
47514894 if (dir > 0 && !moveOnce(!first)) break;
47524895 }
47534896 }
4754 var result = skipAtomic(doc, Pos(line, ch), origDir, true);
4755 if (!possible) result.hitSide = true;
4897 var result = skipAtomic(doc, Pos(line, ch), pos, origDir, true);
4898 if (!cmp(pos, result)) result.hitSide = true;
47564899 return result;
47574900 }
47584901
47634906 var doc = cm.doc, x = pos.left, y;
47644907 if (unit == "page") {
47654908 var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
4766 y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
4909 var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
4910 y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
47674911 } else if (unit == "line") {
47684912 y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
47694913 }
48164960 addOverlay: methodOp(function(spec, options) {
48174961 var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
48184962 if (mode.startState) throw new Error("Overlays may not be stateful.");
4819 this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
4963 insertSorted(this.state.overlays,
4964 {mode: mode, modeSpec: spec, opaque: options && options.opaque,
4965 priority: (options && options.priority) || 0},
4966 function(overlay) { return overlay.priority })
48204967 this.state.modeGen++;
48214968 regChange(this);
48224969 }),
50445191
50455192 execCommand: function(cmd) {
50465193 if (commands.hasOwnProperty(cmd))
5047 return commands[cmd](this);
5194 return commands[cmd].call(null, this);
50485195 },
50495196
50505197 triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
51395286 signal(this, "overwriteToggle", this, this.state.overwrite);
51405287 },
51415288 hasFocus: function() { return this.display.input.getField() == activeElt(); },
5289 isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit); },
51425290
51435291 scrollTo: methodOp(function(x, y) {
51445292 if (x != null || y != null) resolveScrollToPos(this);
52625410 clearCaches(cm);
52635411 regChange(cm);
52645412 }, true);
5265 option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
5413 option("lineSeparator", null, function(cm, val) {
5414 cm.doc.lineSep = val;
5415 if (!val) return;
5416 var newBreaks = [], lineNo = cm.doc.first;
5417 cm.doc.iter(function(line) {
5418 for (var pos = 0;;) {
5419 var found = line.text.indexOf(val, pos);
5420 if (found == -1) break;
5421 pos = found + val.length;
5422 newBreaks.push(Pos(lineNo, found));
5423 }
5424 lineNo++;
5425 });
5426 for (var i = newBreaks.length - 1; i >= 0; i--)
5427 replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length))
5428 });
5429 option("specialChars", /[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
52665430 cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
52675431 if (old != CodeMirror.Init) cm.refresh();
52685432 });
52705434 option("electricChars", true);
52715435 option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
52725436 throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
5437 }, true);
5438 option("spellcheck", false, function(cm, val) {
5439 cm.getInputField().spellcheck = val
52735440 }, true);
52745441 option("rtlMoveVisually", !windows);
52755442 option("wholeLineUpdateBefore", true);
53205487 cm.display.disabled = true;
53215488 } else {
53225489 cm.display.disabled = false;
5323 if (!val) cm.display.input.reset();
5324 }
5490 }
5491 cm.display.input.readOnlyChanged(val)
53255492 });
53265493 option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
53275494 option("dragDrop", true, dragDropChanged);
5495 option("allowDropFileTypes", null);
53285496
53295497 option("cursorBlinkRate", 530);
53305498 option("cursorScrollMargin", 0);
53795547 spec.name = found.name;
53805548 } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
53815549 return CodeMirror.resolveMode("application/xml");
5550 } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
5551 return CodeMirror.resolveMode("application/json");
53825552 }
53835553 if (typeof spec == "string") return {name: spec};
53845554 else return spec || {name: "null"};
55905760 for (var i = 0; i < ranges.length; i++) {
55915761 var pos = ranges[i].from();
55925762 var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
5593 spaces.push(new Array(tabSize - col % tabSize + 1).join(" "));
5763 spaces.push(spaceStr(tabSize - col % tabSize));
55945764 }
55955765 cm.replaceSelections(spaces);
55965766 },
56125782 } else if (cur.line > cm.doc.first) {
56135783 var prev = getLine(cm.doc, cur.line - 1).text;
56145784 if (prev)
5615 cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1),
5785 cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
5786 prev.charAt(prev.length - 1),
56165787 Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
56175788 }
56185789 }
56265797 var len = cm.listSelections().length;
56275798 for (var i = 0; i < len; i++) {
56285799 var range = cm.listSelections()[i];
5629 cm.replaceRange("\n", range.anchor, range.head, "+input");
5800 cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input");
56305801 cm.indentLine(range.from().line + 1, null, true);
5631 ensureCursorVisible(cm);
56325802 }
5803 ensureCursorVisible(cm);
56335804 });
56345805 },
5806 openLine: function(cm) {cm.replaceSelection("\n", "start")},
56355807 toggleOverwrite: function(cm) {cm.toggleOverwrite();}
56365808 };
56375809
56665838 "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
56675839 "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
56685840 "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
5669 "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
5841 "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
5842 "Ctrl-O": "openLine"
56705843 };
56715844 keyMap.macDefault = {
56725845 "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
64286601 var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
64296602 var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
64306603 if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
6431 if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) ||
6432 fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight)))
6604 if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
6605 fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
64336606 return true;
64346607 }
64356608 }
65576730 parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
65586731 removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
65596732 }
6560 return widget.height = widget.node.offsetHeight;
6733 return widget.height = widget.node.parentNode.offsetHeight;
65616734 }
65626735
65636736 function addLineWidget(doc, handle, node, options) {
66876860 }
66886861 if (!flattenSpans || curStyle != style) {
66896862 while (curStart < stream.start) {
6690 curStart = Math.min(stream.start, curStart + 50000);
6863 curStart = Math.min(stream.start, curStart + 5000);
66916864 f(curStart, curStyle);
66926865 }
66936866 curStyle = style;
66956868 stream.start = stream.pos;
66966869 }
66976870 while (curStart < stream.pos) {
6698 // Webkit seems to refuse to render text nodes longer than 57444 characters
6699 var pos = Math.min(stream.pos, curStart + 50000);
6871 // Webkit seems to refuse to render text nodes longer than 57444
6872 // characters, and returns inaccurate measurements in nodes
6873 // starting around 5000 chars.
6874 var pos = Math.min(stream.pos, curStart + 5000);
67006875 f(pos, curStyle);
67016876 curStart = pos;
67026877 }
67466921
67476922 function getLineStyles(cm, line, updateFrontier) {
67486923 if (!line.styles || line.styles[0] != cm.state.modeGen) {
6749 var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
6924 var state = getStateBefore(cm, lineNo(line));
6925 var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state);
6926 line.stateAfter = state;
67506927 line.styles = result.styles;
67516928 if (result.classes) line.styleClasses = result.classes;
67526929 else if (line.styleClasses) line.styleClasses = null;
67636940 var stream = new StringStream(text, cm.options.tabSize);
67646941 stream.start = stream.pos = startAt || 0;
67656942 if (text == "") callBlankLine(mode, state);
6766 while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
6943 while (!stream.eol()) {
67676944 readToken(mode, stream, state);
67686945 stream.start = stream.pos;
67696946 }
67906967 // is needed on Webkit to be able to get line-level bounding
67916968 // rectangles for it (in measureChar).
67926969 var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
6793 var builder = {pre: elt("pre", [content]), content: content,
6970 var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
67946971 col: 0, pos: 0, cm: cm,
6972 trailingSpace: false,
67956973 splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
67966974 lineView.measure = {};
67976975
68297007 }
68307008
68317009 // See issue #2901
6832 if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className))
6833 builder.content.className = "cm-tab-wrap-hack";
7010 if (webkit) {
7011 var last = builder.content.lastChild
7012 if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
7013 builder.content.className = "cm-tab-wrap-hack";
7014 }
68347015
68357016 signal(cm, "renderLine", cm, lineView.line, builder.pre);
68367017 if (builder.pre.className)
68507031 // the line map. Takes care to render special characters separately.
68517032 function buildToken(builder, text, style, startStyle, endStyle, title, css) {
68527033 if (!text) return;
6853 var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text;
7034 var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text
68547035 var special = builder.cm.state.specialChars, mustWrap = false;
68557036 if (!special.test(text)) {
68567037 builder.col += text.length;
68807061 txt.setAttribute("role", "presentation");
68817062 txt.setAttribute("cm-text", "\t");
68827063 builder.col += tabWidth;
7064 } else if (m[0] == "\r" || m[0] == "\n") {
7065 var txt = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
7066 txt.setAttribute("cm-text", m[0]);
7067 builder.col += 1;
68837068 } else {
68847069 var txt = builder.cm.options.specialCharPlaceholder(m[0]);
68857070 txt.setAttribute("cm-text", m[0]);
68917076 builder.pos++;
68927077 }
68937078 }
7079 builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32
68947080 if (style || startStyle || endStyle || mustWrap || css) {
68957081 var fullStyle = style || "";
68967082 if (startStyle) fullStyle += startStyle;
69027088 builder.content.appendChild(content);
69037089 }
69047090
6905 function splitSpaces(old) {
6906 var out = " ";
6907 for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
6908 out += " ";
6909 return out;
7091 function splitSpaces(text, trailingBefore) {
7092 if (text.length > 1 && !/ /.test(text)) return text
7093 var spaceBefore = trailingBefore, result = ""
7094 for (var i = 0; i < text.length; i++) {
7095 var ch = text.charAt(i)
7096 if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
7097 ch = "\u00a0"
7098 result += ch
7099 spaceBefore = ch == " "
7100 }
7101 return result
69107102 }
69117103
69127104 // Work around nonsense dimensions being reported for stretches of
69437135 builder.content.appendChild(widget);
69447136 }
69457137 builder.pos += size;
7138 builder.trailingSpace = false
69467139 }
69477140
69487141 // Outputs a number of spans to make up a line, taking highlighting
69617154 if (nextChange == pos) { // Update current marker set
69627155 spanStyle = spanEndStyle = spanStartStyle = title = css = "";
69637156 collapsed = null; nextChange = Infinity;
6964 var foundBookmarks = [];
7157 var foundBookmarks = [], endStyles
69657158 for (var j = 0; j < spans.length; ++j) {
69667159 var sp = spans[j], m = sp.marker;
69677160 if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
69727165 spanEndStyle = "";
69737166 }
69747167 if (m.className) spanStyle += " " + m.className;
6975 if (m.css) css = m.css;
7168 if (m.css) css = (css ? css + ";" : "") + m.css;
69767169 if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
6977 if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
7170 if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to)
69787171 if (m.title && !title) title = m.title;
69797172 if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
69807173 collapsed = sp;
69827175 nextChange = sp.from;
69837176 }
69847177 }
7178 if (endStyles) for (var j = 0; j < endStyles.length; j += 2)
7179 if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j]
7180
7181 if (!collapsed || collapsed.from == pos) for (var j = 0; j < foundBookmarks.length; ++j)
7182 buildCollapsedSpan(builder, 0, foundBookmarks[j]);
69857183 if (collapsed && (collapsed.from || 0) == pos) {
69867184 buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
69877185 collapsed.marker, collapsed.from == null);
69887186 if (collapsed.to == null) return;
69897187 if (collapsed.to == pos) collapsed = false;
69907188 }
6991 if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
6992 buildCollapsedSpan(builder, 0, foundBookmarks[j]);
69937189 }
69947190 if (pos >= len) break;
69957191
71757371 if (at <= sz) {
71767372 child.insertInner(at, lines, height);
71777373 if (child.lines && child.lines.length > 50) {
7178 while (child.lines.length > 50) {
7179 var spilled = child.lines.splice(child.lines.length - 25, 25);
7180 var newleaf = new LeafChunk(spilled);
7181 child.height -= newleaf.height;
7182 this.children.splice(i + 1, 0, newleaf);
7183 newleaf.parent = this;
7374 // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
7375 // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
7376 var remaining = child.lines.length % 25 + 25
7377 for (var pos = remaining; pos < child.lines.length;) {
7378 var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
7379 child.height -= leaf.height;
7380 this.children.splice(++i, 0, leaf);
7381 leaf.parent = this;
71847382 }
7383 child.lines = child.lines.slice(0, remaining);
71857384 this.maybeSpill();
71867385 }
71877386 break;
72017400 copy.parent = me;
72027401 me.children = [copy, sibling];
72037402 me = copy;
7204 } else {
7403 } else {
72057404 me.size -= sibling.size;
72067405 me.height -= sibling.height;
72077406 var myIndex = indexOf(me.parent.children, me);
72257424 };
72267425
72277426 var nextDocId = 0;
7228 var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
7229 if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
7427 var Doc = CodeMirror.Doc = function(text, mode, firstLine, lineSep) {
7428 if (!(this instanceof Doc)) return new Doc(text, mode, firstLine, lineSep);
72307429 if (firstLine == null) firstLine = 0;
72317430
72327431 BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
72407439 this.history = new History(null);
72417440 this.id = ++nextDocId;
72427441 this.modeOption = mode;
7243
7244 if (typeof text == "string") text = splitLines(text);
7442 this.lineSep = lineSep;
7443 this.extend = false;
7444
7445 if (typeof text == "string") text = this.splitLines(text);
72457446 updateDoc(this, {from: start, to: start, text: text});
72467447 setSelection(this, simpleSelection(start), sel_dontScroll);
72477448 };
72717472 getValue: function(lineSep) {
72727473 var lines = getLines(this, this.first, this.first + this.size);
72737474 if (lineSep === false) return lines;
7274 return lines.join(lineSep || "\n");
7475 return lines.join(lineSep || this.lineSeparator());
72757476 },
72767477 setValue: docMethodOp(function(code) {
72777478 var top = Pos(this.first, 0), last = this.first + this.size - 1;
72787479 makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
7279 text: splitLines(code), origin: "setValue", full: true}, true);
7480 text: this.splitLines(code), origin: "setValue", full: true}, true);
72807481 setSelection(this, simpleSelection(top));
72817482 }),
72827483 replaceRange: function(code, from, to, origin) {
72877488 getRange: function(from, to, lineSep) {
72887489 var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
72897490 if (lineSep === false) return lines;
7290 return lines.join(lineSep || "\n");
7491 return lines.join(lineSep || this.lineSeparator());
72917492 },
72927493
72937494 getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
73277528 extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
73287529 }),
73297530 extendSelections: docMethodOp(function(heads, options) {
7330 extendSelections(this, clipPosArray(this, heads, options));
7531 extendSelections(this, clipPosArray(this, heads), options);
73317532 }),
73327533 extendSelectionsBy: docMethodOp(function(f, options) {
7333 extendSelections(this, map(this.sel.ranges, f), options);
7534 var heads = map(this.sel.ranges, f);
7535 extendSelections(this, clipPosArray(this, heads), options);
73347536 }),
73357537 setSelections: docMethodOp(function(ranges, primary, options) {
73367538 if (!ranges.length) return;
73537555 lines = lines ? lines.concat(sel) : sel;
73547556 }
73557557 if (lineSep === false) return lines;
7356 else return lines.join(lineSep || "\n");
7558 else return lines.join(lineSep || this.lineSeparator());
73577559 },
73587560 getSelections: function(lineSep) {
73597561 var parts = [], ranges = this.sel.ranges;
73607562 for (var i = 0; i < ranges.length; i++) {
73617563 var sel = getBetween(this, ranges[i].from(), ranges[i].to());
7362 if (lineSep !== false) sel = sel.join(lineSep || "\n");
7564 if (lineSep !== false) sel = sel.join(lineSep || this.lineSeparator());
73637565 parts[i] = sel;
73647566 }
73657567 return parts;
73747576 var changes = [], sel = this.sel;
73757577 for (var i = 0; i < sel.ranges.length; i++) {
73767578 var range = sel.ranges[i];
7377 changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};
7579 changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin};
73787580 }
73797581 var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
73807582 for (var i = changes.length - 1; i >= 0; i--)
74557657 removeLineWidget: function(widget) { widget.clear(); },
74567658
74577659 markText: function(from, to, options) {
7458 return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
7660 return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range");
74597661 },
74607662 setBookmark: function(pos, options) {
74617663 var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
74837685 var spans = line.markedSpans;
74847686 if (spans) for (var i = 0; i < spans.length; i++) {
74857687 var span = spans[i];
7486 if (!(lineNo == from.line && from.ch > span.to ||
7487 span.from == null && lineNo != from.line||
7488 lineNo == to.line && span.from > to.ch) &&
7688 if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
7689 span.from == null && lineNo != from.line ||
7690 span.from != null && lineNo == to.line && span.from >= to.ch) &&
74897691 (!filter || filter(span.marker)))
74907692 found.push(span.marker.parent || span.marker);
74917693 }
75047706 },
75057707
75067708 posFromIndex: function(off) {
7507 var ch, lineNo = this.first;
7709 var ch, lineNo = this.first, sepSize = this.lineSeparator().length;
75087710 this.iter(function(line) {
7509 var sz = line.text.length + 1;
7711 var sz = line.text.length + sepSize;
75107712 if (sz > off) { ch = off; return true; }
75117713 off -= sz;
75127714 ++lineNo;
75177719 coords = clipPos(this, coords);
75187720 var index = coords.ch;
75197721 if (coords.line < this.first || coords.ch < 0) return 0;
7722 var sepSize = this.lineSeparator().length;
75207723 this.iter(this.first, coords.line, function (line) {
7521 index += line.text.length + 1;
7724 index += line.text.length + sepSize;
75227725 });
75237726 return index;
75247727 },
75257728
75267729 copy: function(copyHistory) {
7527 var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
7730 var doc = new Doc(getLines(this, this.first, this.first + this.size),
7731 this.modeOption, this.first, this.lineSep);
75287732 doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
75297733 doc.sel = this.sel;
75307734 doc.extend = false;
75407744 var from = this.first, to = this.first + this.size;
75417745 if (options.from != null && options.from > from) from = options.from;
75427746 if (options.to != null && options.to < to) to = options.to;
7543 var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
7747 var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep);
75447748 if (options.sharedHist) copy.history = this.history;
75457749 (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
75467750 copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
75697773 iterLinkedDocs: function(f) {linkedDocs(this, f);},
75707774
75717775 getMode: function() {return this.mode;},
7572 getEditor: function() {return this.cm;}
7776 getEditor: function() {return this.cm;},
7777
7778 splitLines: function(str) {
7779 if (this.lineSep) return str.split(this.lineSep);
7780 return splitLinesAuto(str);
7781 },
7782 lineSeparator: function() { return this.lineSep || "\n"; }
75737783 });
75747784
75757785 // Public alias.
77707980 }
77717981
77727982 // Register a change in the history. Merges changes that are within
7773 // a single operation, ore are close together with an origin that
7983 // a single operation, or are close together with an origin that
77747984 // allows merging (starting with "+") into a single event.
77757985 function addChangeToHistory(doc, change, selAfter, opId) {
77767986 var hist = doc.history;
80098219 }
80108220 };
80118221
8222 var noHandlers = []
8223 function getHandlers(emitter, type, copy) {
8224 var arr = emitter._handlers && emitter._handlers[type]
8225 if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers
8226 else return arr || noHandlers
8227 }
8228
80128229 var off = CodeMirror.off = function(emitter, type, f) {
80138230 if (emitter.removeEventListener)
80148231 emitter.removeEventListener(type, f, false);
80158232 else if (emitter.detachEvent)
80168233 emitter.detachEvent("on" + type, f);
80178234 else {
8018 var arr = emitter._handlers && emitter._handlers[type];
8019 if (!arr) return;
8020 for (var i = 0; i < arr.length; ++i)
8021 if (arr[i] == f) { arr.splice(i, 1); break; }
8235 var handlers = getHandlers(emitter, type, false)
8236 for (var i = 0; i < handlers.length; ++i)
8237 if (handlers[i] == f) { handlers.splice(i, 1); break; }
80228238 }
80238239 };
80248240
80258241 var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
8026 var arr = emitter._handlers && emitter._handlers[type];
8027 if (!arr) return;
8242 var handlers = getHandlers(emitter, type, true)
8243 if (!handlers.length) return;
80288244 var args = Array.prototype.slice.call(arguments, 2);
8029 for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
8245 for (var i = 0; i < handlers.length; ++i) handlers[i].apply(null, args);
80308246 };
80318247
80328248 var orphanDelayedCallbacks = null;
80398255 // them to be executed when the last operation ends, or, if no
80408256 // operation is active, when a timeout fires.
80418257 function signalLater(emitter, type /*, values...*/) {
8042 var arr = emitter._handlers && emitter._handlers[type];
8043 if (!arr) return;
8258 var arr = getHandlers(emitter, type, false)
8259 if (!arr.length) return;
80448260 var args = Array.prototype.slice.call(arguments, 2), list;
80458261 if (operationGroup) {
80468262 list = operationGroup.delayedCallbacks;
80808296 }
80818297
80828298 function hasHandler(emitter, type) {
8083 var arr = emitter._handlers && emitter._handlers[type];
8084 return arr && arr.length > 0;
8299 return getHandlers(emitter, type).length > 0
80858300 }
80868301
80878302 // Add on and off methods to a constructor's prototype, to make
81288343
81298344 // The inverse of countColumn -- find the offset that corresponds to
81308345 // a particular column.
8131 function findColumn(string, goal, tabSize) {
8346 var findColumn = CodeMirror.findColumn = function(string, goal, tabSize) {
81328347 for (var pos = 0, col = 0;;) {
81338348 var nextTab = string.indexOf("\t", pos);
81348349 if (nextTab == -1) nextTab = string.length;
81668381 var out = [];
81678382 for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
81688383 return out;
8384 }
8385
8386 function insertSorted(array, value, score) {
8387 var pos = 0, priority = score(value)
8388 while (pos < array.length && score(array[pos]) <= priority) pos++
8389 array.splice(pos, 0, value)
81698390 }
81708391
81718392 function nothing() {}
82688489 } while (child = child.parentNode);
82698490 };
82708491
8271 function activeElt() { return document.activeElement; }
8492 function activeElt() {
8493 var activeElement = document.activeElement;
8494 while (activeElement && activeElement.root && activeElement.root.activeElement)
8495 activeElement = activeElement.root.activeElement;
8496 return activeElement;
8497 }
82728498 // Older versions of IE throws unspecified error when touching
82738499 // document.activeElement in some cases (during loading, in iframe)
82748500 if (ie && ie_version < 11) activeElt = function() {
83638589 if (badBidiRects != null) return badBidiRects;
83648590 var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
83658591 var r0 = range(txt, 0, 1).getBoundingClientRect();
8592 var r1 = range(txt, 1, 2).getBoundingClientRect();
8593 removeChildren(measure);
83668594 if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
8367 var r1 = range(txt, 1, 2).getBoundingClientRect();
83688595 return badBidiRects = (r1.right - r0.right < 3);
83698596 }
83708597
83718598 // See if "".split is the broken IE version, if so, provide an
83728599 // alternative way to split lines.
8373 var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
8600 var splitLinesAuto = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
83748601 var pos = 0, result = [], l = string.length;
83758602 while (pos <= l) {
83768603 var nl = string.indexOf("\n", pos);
84168643
84178644 // KEY NAMES
84188645
8419 var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
8420 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
8421 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
8422 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
8423 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
8424 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
8425 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
8426 CodeMirror.keyNames = keyNames;
8646 var keyNames = CodeMirror.keyNames = {
8647 3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
8648 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
8649 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
8650 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
8651 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete",
8652 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
8653 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
8654 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
8655 };
84278656 (function() {
84288657 // Number keys
84298658 for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
87288957
87298958 // THE END
87308959
8731 CodeMirror.version = "5.4.0";
8960 CodeMirror.version = "5.19.0";
87328961
87338962 return CodeMirror;
87348963 });
0 <!doctype html>
0 <!doctype html>
11
22 <title>CodeMirror: ASN.1 mode</title>
33 <meta charset="utf-8"/>
7272 <p>The development of this mode has been sponsored by <a href="http://www.ericsson.com/">Ericsson
7373 </a>.</p>
7474 <p>Coded by Asmelash Tsegay Gebretsadkan </p>
75 </article>
7675 </article>
7776
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 // Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11
4
5 (function(mod) {
6 if (typeof exports == "object" && typeof module == "object")
7 mod(require("../../lib/codemirror"))
8 else if (typeof define == "function" && define.amd)
9 define(["../../lib/codemirror"], mod)
10 else
11 mod(CodeMirror)
12 })(function(CodeMirror) {
13 "use strict"
14 var reserve = "><+-.,[]".split("");
15 /*
16 comments can be either:
17 placed behind lines
18
19 +++ this is a comment
20
21 where reserved characters cannot be used
22 or in a loop
23 [
24 this is ok to use [ ] and stuff
25 ]
26 or preceded by #
27 */
28 CodeMirror.defineMode("brainfuck", function() {
29 return {
30 startState: function() {
31 return {
32 commentLine: false,
33 left: 0,
34 right: 0,
35 commentLoop: false
36 }
37 },
38 token: function(stream, state) {
39 if (stream.eatSpace()) return null
40 if(stream.sol()){
41 state.commentLine = false;
42 }
43 var ch = stream.next().toString();
44 if(reserve.indexOf(ch) !== -1){
45 if(state.commentLine === true){
46 if(stream.eol()){
47 state.commentLine = false;
48 }
49 return "comment";
50 }
51 if(ch === "]" || ch === "["){
52 if(ch === "["){
53 state.left++;
54 }
55 else{
56 state.right++;
57 }
58 return "bracket";
59 }
60 else if(ch === "+" || ch === "-"){
61 return "keyword";
62 }
63 else if(ch === "<" || ch === ">"){
64 return "atom";
65 }
66 else if(ch === "." || ch === ","){
67 return "def";
68 }
69 }
70 else{
71 state.commentLine = true;
72 if(stream.eol()){
73 state.commentLine = false;
74 }
75 return "comment";
76 }
77 if(stream.eol()){
78 state.commentLine = false;
79 }
80 }
81 };
82 });
83 CodeMirror.defineMIME("text/x-brainfuck","brainfuck")
84 });
0 <!doctype html>
1
2 <title>CodeMirror: Brainfuck mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="./brainfuck.js"></script>
10 <style>
11 .CodeMirror { border: 2px inset #dee; }
12 </style>
13 <div id=nav>
14 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
15
16 <ul>
17 <li><a href="../../index.html">Home</a>
18 <li><a href="../../doc/manual.html">Manual</a>
19 <li><a href="https://github.com/codemirror/codemirror">Code</a>
20 </ul>
21 <ul>
22 <li><a href="../index.html">Language modes</a>
23 <li><a class=active href="#"></a>
24 </ul>
25 </div>
26
27 <article>
28 <h2>Brainfuck mode</h2>
29 <form><textarea id="code" name="code">
30 [ This program prints "Hello World!" and a newline to the screen, its
31 length is 106 active command characters [it is not the shortest.]
32
33 This loop is a "comment loop", it's a simple way of adding a comment
34 to a BF program such that you don't have to worry about any command
35 characters. Any ".", ",", "+", "-", "&lt;" and "&gt;" characters are simply
36 ignored, the "[" and "]" characters just have to be balanced.
37 ]
38 +++++ +++ Set Cell #0 to 8
39 [
40 &gt;++++ Add 4 to Cell #1; this will always set Cell #1 to 4
41 [ as the cell will be cleared by the loop
42 &gt;++ Add 2 to Cell #2
43 &gt;+++ Add 3 to Cell #3
44 &gt;+++ Add 3 to Cell #4
45 &gt;+ Add 1 to Cell #5
46 &lt;&lt;&lt;&lt;- Decrement the loop counter in Cell #1
47 ] Loop till Cell #1 is zero; number of iterations is 4
48 &gt;+ Add 1 to Cell #2
49 &gt;+ Add 1 to Cell #3
50 &gt;- Subtract 1 from Cell #4
51 &gt;&gt;+ Add 1 to Cell #6
52 [&lt;] Move back to the first zero cell you find; this will
53 be Cell #1 which was cleared by the previous loop
54 &lt;- Decrement the loop Counter in Cell #0
55 ] Loop till Cell #0 is zero; number of iterations is 8
56
57 The result of this is:
58 Cell No : 0 1 2 3 4 5 6
59 Contents: 0 0 72 104 88 32 8
60 Pointer : ^
61
62 &gt;&gt;. Cell #2 has value 72 which is 'H'
63 &gt;---. Subtract 3 from Cell #3 to get 101 which is 'e'
64 +++++++..+++. Likewise for 'llo' from Cell #3
65 &gt;&gt;. Cell #5 is 32 for the space
66 &lt;-. Subtract 1 from Cell #4 for 87 to give a 'W'
67 &lt;. Cell #3 was set to 'o' from the end of 'Hello'
68 +++.------.--------. Cell #3 for 'rl' and 'd'
69 &gt;&gt;+. Add 1 to Cell #5 gives us an exclamation point
70 &gt;++. And finally a newline from Cell #6
71 </textarea></form>
72
73 <script>
74 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
75 lineNumbers: true,
76 matchBrackets: true,
77 mode: "text/x-brainfuck"
78 });
79 </script>
80
81 <p>A mode for Brainfuck</p>
82
83 <p><strong>MIME types defined:</strong> <code>text/x-brainfuck</code></p>
84 </article>
99 mod(CodeMirror);
1010 })(function(CodeMirror) {
1111 "use strict";
12
13 function Context(indented, column, type, info, align, prev) {
14 this.indented = indented;
15 this.column = column;
16 this.type = type;
17 this.info = info;
18 this.align = align;
19 this.prev = prev;
20 }
21 function pushContext(state, col, type, info) {
22 var indent = state.indented;
23 if (state.context && state.context.type != "statement" && type != "statement")
24 indent = state.context.indented;
25 return state.context = new Context(indent, col, type, info, null, state.context);
26 }
27 function popContext(state) {
28 var t = state.context.type;
29 if (t == ")" || t == "]" || t == "}")
30 state.indented = state.context.indented;
31 return state.context = state.context.prev;
32 }
33
34 function typeBefore(stream, state, pos) {
35 if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
36 if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
37 if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
38 }
39
40 function isTopScope(context) {
41 for (;;) {
42 if (!context || context.type == "top") return true;
43 if (context.type == "}" && context.prev.info != "namespace") return false;
44 context = context.prev;
45 }
46 }
1247
1348 CodeMirror.defineMode("clike", function(config, parserConfig) {
1449 var indentUnit = config.indentUnit,
2459 multiLineStrings = parserConfig.multiLineStrings,
2560 indentStatements = parserConfig.indentStatements !== false,
2661 indentSwitch = parserConfig.indentSwitch !== false,
27 namespaceSeparator = parserConfig.namespaceSeparator;
28 var isOperatorChar = /[+\-*&%=<>!?|\/]/;
62 namespaceSeparator = parserConfig.namespaceSeparator,
63 isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/,
64 numberStart = parserConfig.numberStart || /[\d\.]/,
65 number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
66 isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
67 endStatement = parserConfig.endStatement || /^[;:,]$/;
2968
3069 var curPunc, isDefKeyword;
3170
3978 state.tokenize = tokenString(ch);
4079 return state.tokenize(stream, state);
4180 }
42 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
81 if (isPunctuationChar.test(ch)) {
4382 curPunc = ch;
4483 return null;
4584 }
46 if (/\d/.test(ch)) {
47 stream.eatWhile(/[\w\.]/);
48 return "number";
85 if (numberStart.test(ch)) {
86 stream.backUp(1)
87 if (stream.match(number)) return "number"
88 stream.next()
4989 }
5090 if (ch == "/") {
5191 if (stream.eat("*")) {
5898 }
5999 }
60100 if (isOperatorChar.test(ch)) {
61 stream.eatWhile(isOperatorChar);
101 while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {}
62102 return "operator";
63103 }
64104 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
66106 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
67107
68108 var cur = stream.current();
69 if (keywords.propertyIsEnumerable(cur)) {
70 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
71 if (defKeywords.propertyIsEnumerable(cur)) isDefKeyword = true;
109 if (contains(keywords, cur)) {
110 if (contains(blockKeywords, cur)) curPunc = "newstatement";
111 if (contains(defKeywords, cur)) isDefKeyword = true;
72112 return "keyword";
73113 }
74 if (types.propertyIsEnumerable(cur)) return "variable-3";
75 if (builtin.propertyIsEnumerable(cur)) {
76 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
114 if (contains(types, cur)) return "variable-3";
115 if (contains(builtin, cur)) {
116 if (contains(blockKeywords, cur)) curPunc = "newstatement";
77117 return "builtin";
78118 }
79 if (atoms.propertyIsEnumerable(cur)) return "atom";
119 if (contains(atoms, cur)) return "atom";
80120 return "variable";
81121 }
82122
105145 return "comment";
106146 }
107147
108 function Context(indented, column, type, align, prev) {
109 this.indented = indented;
110 this.column = column;
111 this.type = type;
112 this.align = align;
113 this.prev = prev;
114 }
115 function isStatement(type) {
116 return type == "statement" || type == "switchstatement" || type == "namespace";
117 }
118 function pushContext(state, col, type) {
119 var indent = state.indented;
120 if (state.context && isStatement(state.context.type) && !isStatement(type))
121 indent = state.context.indented;
122 return state.context = new Context(indent, col, type, null, state.context);
123 }
124 function popContext(state) {
125 var t = state.context.type;
126 if (t == ")" || t == "]" || t == "}")
127 state.indented = state.context.indented;
128 return state.context = state.context.prev;
129 }
130
131 function typeBefore(stream, state) {
132 if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
133 if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true;
134 }
135
136 function isTopScope(context) {
137 for (;;) {
138 if (!context || context.type == "top") return true;
139 if (context.type == "}" && context.prev.type != "namespace") return false;
140 context = context.prev;
141 }
148 function maybeEOL(stream, state) {
149 if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context))
150 state.typeAtEndOfLine = typeBefore(stream, state, stream.pos)
142151 }
143152
144153 // Interface
147156 startState: function(basecolumn) {
148157 return {
149158 tokenize: null,
150 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
159 context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false),
151160 indented: 0,
152161 startOfLine: true,
153162 prevToken: null
161170 state.indented = stream.indentation();
162171 state.startOfLine = true;
163172 }
164 if (stream.eatSpace()) return null;
173 if (stream.eatSpace()) { maybeEOL(stream, state); return null; }
165174 curPunc = isDefKeyword = null;
166175 var style = (state.tokenize || tokenBase)(stream, state);
167176 if (style == "comment" || style == "meta") return style;
168177 if (ctx.align == null) ctx.align = true;
169178
170 if ((curPunc == ";" || curPunc == ":" || curPunc == ","))
171 while (isStatement(state.context.type)) popContext(state);
179 if (endStatement.test(curPunc)) while (state.context.type == "statement") popContext(state);
172180 else if (curPunc == "{") pushContext(state, stream.column(), "}");
173181 else if (curPunc == "[") pushContext(state, stream.column(), "]");
174182 else if (curPunc == "(") pushContext(state, stream.column(), ")");
175183 else if (curPunc == "}") {
176 while (isStatement(ctx.type)) ctx = popContext(state);
184 while (ctx.type == "statement") ctx = popContext(state);
177185 if (ctx.type == "}") ctx = popContext(state);
178 while (isStatement(ctx.type)) ctx = popContext(state);
186 while (ctx.type == "statement") ctx = popContext(state);
179187 }
180188 else if (curPunc == ctx.type) popContext(state);
181189 else if (indentStatements &&
182190 (((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
183 (isStatement(ctx.type) && curPunc == "newstatement"))) {
184 var type = "statement";
185 if (curPunc == "newstatement" && indentSwitch && stream.current() == "switch")
186 type = "switchstatement";
187 else if (style == "keyword" && stream.current() == "namespace")
188 type = "namespace";
189 pushContext(state, stream.column(), type);
191 (ctx.type == "statement" && curPunc == "newstatement"))) {
192 pushContext(state, stream.column(), "statement", stream.current());
190193 }
191194
192195 if (style == "variable" &&
193196 ((state.prevToken == "def" ||
194 (parserConfig.typeFirstDefinitions && typeBefore(stream, state) &&
197 (parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) &&
195198 isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
196199 style = "def";
197200
204207
205208 state.startOfLine = false;
206209 state.prevToken = isDefKeyword ? "def" : style || curPunc;
210 maybeEOL(stream, state);
207211 return style;
208212 },
209213
210214 indent: function(state, textAfter) {
211 if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
215 if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
212216 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
213 if (isStatement(ctx.type) && firstChar == "}") ctx = ctx.prev;
217 if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
218 if (parserConfig.dontIndentStatements)
219 while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
220 ctx = ctx.prev
221 if (hooks.indent) {
222 var hook = hooks.indent(state, ctx, textAfter);
223 if (typeof hook == "number") return hook
224 }
214225 var closing = firstChar == ctx.type;
215 var switchBlock = ctx.prev && ctx.prev.type == "switchstatement";
216 if (isStatement(ctx.type))
226 var switchBlock = ctx.prev && ctx.prev.info == "switch";
227 if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
228 while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
229 return ctx.indented
230 }
231 if (ctx.type == "statement")
217232 return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
218233 if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
219234 return ctx.column + (closing ? 0 : 1);
237252 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
238253 return obj;
239254 }
255 function contains(words, word) {
256 if (typeof words === "function") {
257 return words(word);
258 } else {
259 return words.propertyIsEnumerable(word);
260 }
261 }
240262 var cKeywords = "auto if break case register continue return default do sizeof " +
241 "static else struct switch extern typedef float union for " +
242 "goto while enum const volatile";
263 "static else struct switch extern typedef union for goto while enum const volatile";
243264 var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t";
244265
245266 function cppHook(stream, state) {
246 if (!state.startOfLine) return false;
247 for (;;) {
248 if (stream.skipTo("\\")) {
249 stream.next();
250 if (stream.eol()) {
251 state.tokenize = cppHook;
252 break;
253 }
254 } else {
255 stream.skipToEnd();
256 state.tokenize = null;
257 break;
258 }
259 }
260 return "meta";
267 if (!state.startOfLine) return false
268 for (var ch, next = null; ch = stream.peek();) {
269 if (ch == "\\" && stream.match(/^.$/)) {
270 next = cppHook
271 break
272 } else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) {
273 break
274 }
275 stream.next()
276 }
277 state.tokenize = next
278 return "meta"
261279 }
262280
263281 function pointerHook(_stream, state) {
264282 if (state.prevToken == "variable-3") return "variable-3";
265283 return false;
284 }
285
286 function cpp14Literal(stream) {
287 stream.eatWhile(/[\w\.']/);
288 return "number";
266289 }
267290
268291 function cpp11StringHook(stream, state) {
365388 defKeywords: words("class namespace struct enum union"),
366389 typeFirstDefinitions: true,
367390 atoms: words("true false null"),
391 dontIndentStatements: /^template$/,
368392 hooks: {
369393 "#": cppHook,
370394 "*": pointerHook,
372396 "U": cpp11StringHook,
373397 "L": cpp11StringHook,
374398 "R": cpp11StringHook,
399 "0": cpp14Literal,
400 "1": cpp14Literal,
401 "2": cpp14Literal,
402 "3": cpp14Literal,
403 "4": cpp14Literal,
404 "5": cpp14Literal,
405 "6": cpp14Literal,
406 "7": cpp14Literal,
407 "8": cpp14Literal,
408 "9": cpp14Literal,
375409 token: function(stream, state, style) {
376410 if (style == "variable" && stream.peek() == "(" &&
377411 (state.prevToken == ";" || state.prevToken == null ||
397431 defKeywords: words("class interface package enum"),
398432 typeFirstDefinitions: true,
399433 atoms: words("true false null"),
434 endStatement: /^[;:]$/,
435 number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
400436 hooks: {
401437 "@": function(stream) {
402438 stream.eatWhile(/[\w\$_]/);
452488 keywords: words(
453489
454490 /* scala */
455 "abstract case catch class def do else extends false final finally for forSome if " +
491 "abstract case catch class def do else extends final finally for forSome if " +
456492 "implicit import lazy match new null object override package private protected return " +
457493 "sealed super this throw trait try type val var while with yield _ : = => <- <: " +
458494 "<% >: # @ " +
465501 ),
466502 types: words(
467503 "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
468 "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
504 "Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Integral Iterable " +
469505 "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
470506 "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
471507 "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +
495531 "'": function(stream) {
496532 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
497533 return "atom";
534 },
535 "=": function(stream, state) {
536 var cx = state.context
537 if (cx.type == "}" && cx.align && stream.eat(">")) {
538 state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev)
539 return "operator"
540 } else {
541 return false
542 }
543 }
544 },
545 modeProps: {closeBrackets: {triples: '"'}}
546 });
547
548 function tokenKotlinString(tripleString){
549 return function (stream, state) {
550 var escaped = false, next, end = false;
551 while (!stream.eol()) {
552 if (!tripleString && !escaped && stream.match('"') ) {end = true; break;}
553 if (tripleString && stream.match('"""')) {end = true; break;}
554 next = stream.next();
555 if(!escaped && next == "$" && stream.match('{'))
556 stream.skipTo("}");
557 escaped = !escaped && next == "\\" && !tripleString;
558 }
559 if (end || !tripleString)
560 state.tokenize = null;
561 return "string";
562 }
563 }
564
565 def("text/x-kotlin", {
566 name: "clike",
567 keywords: words(
568 /*keywords*/
569 "package as typealias class interface this super val " +
570 "var fun for is in This throw return " +
571 "break continue object if else while do try when !in !is as? " +
572
573 /*soft keywords*/
574 "file import where by get set abstract enum open inner override private public internal " +
575 "protected catch finally out final vararg reified dynamic companion constructor init " +
576 "sealed field property receiver param sparam lateinit data inline noinline tailrec " +
577 "external annotation crossinline const operator infix"
578 ),
579 types: words(
580 /* package java.lang */
581 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
582 "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
583 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
584 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
585 ),
586 intendSwitch: false,
587 indentStatements: false,
588 multiLineStrings: true,
589 blockKeywords: words("catch class do else finally for if where try while enum"),
590 defKeywords: words("class val var object package interface fun"),
591 atoms: words("true false null this"),
592 hooks: {
593 '"': function(stream, state) {
594 state.tokenize = tokenKotlinString(stream.match('""'));
595 return state.tokenize(stream, state);
498596 }
499597 },
500598 modeProps: {closeBrackets: {triples: '"'}}
573671
574672 def("text/x-objectivec", {
575673 name: "clike",
576 keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " +
674 keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in " +
577675 "inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),
578676 types: words(cTypes),
579677 atoms: words("YES NO NULL NILL ON OFF true false"),
582680 stream.eatWhile(/[\w\$]/);
583681 return "keyword";
584682 },
585 "#": cppHook
683 "#": cppHook,
684 indent: function(_state, ctx, textAfter) {
685 if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented
686 }
586687 },
587688 modeProps: {fold: "brace"}
588689 });
589690
691 def("text/x-squirrel", {
692 name: "clike",
693 keywords: words("base break clone continue const default delete enum extends function in class" +
694 " foreach local resume return this throw typeof yield constructor instanceof static"),
695 types: words(cTypes),
696 blockKeywords: words("case catch class else for foreach if switch try while"),
697 defKeywords: words("function local class"),
698 typeFirstDefinitions: true,
699 atoms: words("true false null"),
700 hooks: {"#": cppHook},
701 modeProps: {fold: ["brace", "include"]}
702 });
703
704 // Ceylon Strings need to deal with interpolation
705 var stringTokenizer = null;
706 function tokenCeylonString(type) {
707 return function(stream, state) {
708 var escaped = false, next, end = false;
709 while (!stream.eol()) {
710 if (!escaped && stream.match('"') &&
711 (type == "single" || stream.match('""'))) {
712 end = true;
713 break;
714 }
715 if (!escaped && stream.match('``')) {
716 stringTokenizer = tokenCeylonString(type);
717 end = true;
718 break;
719 }
720 next = stream.next();
721 escaped = type == "single" && !escaped && next == "\\";
722 }
723 if (end)
724 state.tokenize = null;
725 return "string";
726 }
727 }
728
729 def("text/x-ceylon", {
730 name: "clike",
731 keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" +
732 " exists extends finally for function given if import in interface is let module new" +
733 " nonempty object of out outer package return satisfies super switch then this throw" +
734 " try value void while"),
735 types: function(word) {
736 // In Ceylon all identifiers that start with an uppercase are types
737 var first = word.charAt(0);
738 return (first === first.toUpperCase() && first !== first.toLowerCase());
739 },
740 blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"),
741 defKeywords: words("class dynamic function interface module object package value"),
742 builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" +
743 " native optional sealed see serializable shared suppressWarnings tagged throws variable"),
744 isPunctuationChar: /[\[\]{}\(\),;\:\.`]/,
745 isOperatorChar: /[+\-*&%=<>!?|^~:\/]/,
746 numberStart: /[\d#$]/,
747 number: /^(?:#[\da-fA-F_]+|\$[01_]+|[\d_]+[kMGTPmunpf]?|[\d_]+\.[\d_]+(?:[eE][-+]?\d+|[kMGTPmunpf]|)|)/i,
748 multiLineStrings: true,
749 typeFirstDefinitions: true,
750 atoms: words("true false null larger smaller equal empty finished"),
751 indentSwitch: false,
752 styleDefs: false,
753 hooks: {
754 "@": function(stream) {
755 stream.eatWhile(/[\w\$_]/);
756 return "meta";
757 },
758 '"': function(stream, state) {
759 state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single");
760 return state.tokenize(stream, state);
761 },
762 '`': function(stream, state) {
763 if (!stringTokenizer || !stream.match('`')) return false;
764 state.tokenize = stringTokenizer;
765 stringTokenizer = null;
766 return state.tokenize(stream, state);
767 },
768 "'": function(stream) {
769 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
770 return "atom";
771 },
772 token: function(_stream, state, style) {
773 if ((style == "variable" || style == "variable-3") &&
774 state.prevToken == ".") {
775 return "variable-2";
776 }
777 }
778 },
779 modeProps: {
780 fold: ["brace", "import"],
781 closeBrackets: {triples: '"'}
782 }
783 });
784
590785 });
205205 }
206206 </textarea></div>
207207
208 <h2>Kotlin mode</h2>
209
210 <div><textarea id="kotlin-code">
211 package org.wasabi.http
212
213 import java.util.concurrent.Executors
214 import java.net.InetSocketAddress
215 import org.wasabi.app.AppConfiguration
216 import io.netty.bootstrap.ServerBootstrap
217 import io.netty.channel.nio.NioEventLoopGroup
218 import io.netty.channel.socket.nio.NioServerSocketChannel
219 import org.wasabi.app.AppServer
220
221 public class HttpServer(private val appServer: AppServer) {
222
223 val bootstrap: ServerBootstrap
224 val primaryGroup: NioEventLoopGroup
225 val workerGroup: NioEventLoopGroup
226
227 init {
228 // Define worker groups
229 primaryGroup = NioEventLoopGroup()
230 workerGroup = NioEventLoopGroup()
231
232 // Initialize bootstrap of server
233 bootstrap = ServerBootstrap()
234
235 bootstrap.group(primaryGroup, workerGroup)
236 bootstrap.channel(javaClass<NioServerSocketChannel>())
237 bootstrap.childHandler(NettyPipelineInitializer(appServer))
238 }
239
240 public fun start(wait: Boolean = true) {
241 val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel()
242
243 if (wait) {
244 channel?.closeFuture()?.sync()
245 }
246 }
247
248 public fun stop() {
249 // Shutdown all event loops
250 primaryGroup.shutdownGracefully()
251 workerGroup.shutdownGracefully()
252
253 // Wait till all threads are terminated
254 primaryGroup.terminationFuture().sync()
255 workerGroup.terminationFuture().sync()
256 }
257 }
258 </textarea></div>
259
260 <h2>Ceylon mode</h2>
261
262 <div><textarea id="ceylon-code">
263 "Produces the [[stream|Iterable]] that results from repeated
264 application of the given [[function|next]] to the given
265 [[first]] element of the stream, until the function first
266 returns [[finished]]. If the given function never returns
267 `finished`, the resulting stream is infinite.
268
269 For example:
270
271 loop(0)(2.plus).takeWhile(10.largerThan)
272
273 produces the stream `{ 0, 2, 4, 6, 8 }`."
274 tagged("Streams")
275 shared {Element+} loop&lt;Element&gt;(
276 "The first element of the resulting stream."
277 Element first)(
278 "The function that produces the next element of the
279 stream, given the current element. The function may
280 return [[finished]] to indicate the end of the
281 stream."
282 Element|Finished next(Element element))
283 =&gt; let (start = first)
284 object satisfies {Element+} {
285 first =&gt; start;
286 empty =&gt; false;
287 function nextElement(Element element)
288 =&gt; next(element);
289 iterator()
290 =&gt; object satisfies Iterator&lt;Element&gt; {
291 variable Element|Finished current = start;
292 shared actual Element|Finished next() {
293 if (!is Finished result = current) {
294 current = nextElement(result);
295 return result;
296 }
297 else {
298 return finished;
299 }
300 }
301 };
302 };
303 </textarea></div>
304
208305 <script>
209306 var cEditor = CodeMirror.fromTextArea(document.getElementById("c-code"), {
210307 lineNumbers: true,
230327 lineNumbers: true,
231328 matchBrackets: true,
232329 mode: "text/x-scala"
330 });
331 var kotlinEditor = CodeMirror.fromTextArea(document.getElementById("kotlin-code"), {
332 lineNumbers: true,
333 matchBrackets: true,
334 mode: "text/x-kotlin"
335 });
336 var ceylonEditor = CodeMirror.fromTextArea(document.getElementById("ceylon-code"), {
337 lineNumbers: true,
338 matchBrackets: true,
339 mode: "text/x-ceylon"
233340 });
234341 var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
235342 CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
246353 (Java), <code>text/x-csharp</code> (C#),
247354 <code>text/x-objectivec</code> (Objective-C),
248355 <code>text/x-scala</code> (Scala), <code>text/x-vertex</code>
249 and <code>x-shader/x-fragment</code> (shader programs).</p>
356 <code>x-shader/x-fragment</code> (shader programs),
357 <code>text/x-squirrel</code> (Squirrel) and
358 <code>text/x-ceylon</code> (Ceylon)</p>
250359 </article>
2424 "[keyword struct] [def bar]{}",
2525 "[variable-3 int] [variable-3 *][def baz]() {}");
2626
27 MT("def_new_line",
28 "::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
29 "[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
30
2731 MT("double_block",
2832 "[keyword for] (;;)",
2933 " [keyword for] (;;)",
3034 " [variable x][operator ++];",
3135 "[keyword return];");
36
37 MT("preprocessor",
38 "[meta #define FOO 3]",
39 "[variable-3 int] [variable foo];",
40 "[meta #define BAR\\]",
41 "[meta 4]",
42 "[variable-3 unsigned] [variable-3 int] [variable bar] [operator =] [number 8];",
43 "[meta #include <baz> ][comment // comment]")
44
45
46 var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
47 function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
48
49 MTCPP("cpp14_literal",
50 "[number 10'000];",
51 "[number 0b10'000];",
52 "[number 0x10'000];",
53 "[string '100000'];");
3254 })();
3030 var atoms = makeKeywords("true false nil");
3131
3232 var keywords = makeKeywords(
33 "defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars binding gen-class gen-and-load-class gen-and-save-class handler-case handle");
33 "defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest " +
34 "slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn " +
35 "do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync " +
36 "doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars " +
37 "binding gen-class gen-and-load-class gen-and-save-class handler-case handle");
3438
3539 var builtins = makeKeywords(
36 "* *' *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* *compile-path* *compiler-options* *data-readers* *e *err* *file* *flush-on-newline* *fn-loader* *in* *math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* *source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* + +' - -' -> ->> ->ArrayChunk ->Vec ->VecNode ->VecSeq -cache-protocol-fn -reset-methods .. / < <= = == > >= EMPTY-NODE accessor aclone add-classpath add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint biginteger binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* bound? butlast byte byte-array bytes case cast char char-array char-escape-string char-name-string char? chars chunk chunk-append chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement concat cond condp conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec dec' decimal? declare default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol defrecord defstruct deftype delay delay? deliver denominator deref derive descendants destructure disj disj! dissoc dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array doubles drop drop-last drop-while empty empty? ensure enumeration-seq error-handler error-mode eval even? every-pred every? ex-data ex-info extend extend-protocol extend-type extenders extends? false? ffirst file-seq filter filterv find find-keyword find-ns find-protocol-impl find-protocol-method find-var first flatten float float-array float? floats flush fn fn? fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future? gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator group-by hash hash-combine hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc inc' init-proxy instance? int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt keep keep-indexed key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy map map-indexed map? mapcat mapv max max-key memfn memoize merge merge-with meta method-sig methods min min-key mod munge name namespace namespace-munge neg? newline next nfirst nil? nnext not not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext nthrest num number? numerator object-array odd? or parents partial partition partition-all partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers primitives-classnames print print-ctor print-dup print-method print-simple print-str printf println println-str prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot rand rand-int rand-nth range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern re-seq read read-line read-string realized? reduce reduce-kv reductions ref ref-history-count ref-max-history ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! resolve rest restart-agent resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? seque sequence sequential? set set-error-handler! set-error-mode! set-validator! set? short short-array shorts shuffle shutdown-agents slurp some some-fn sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? special-symbol? spit split-at split-with str string? struct struct-map subs subseq subvec supers swap! symbol symbol? sync take take-last take-nth take-while test the-ns thread-bound? time to-array to-array-2d trampoline transient tree-seq true? type unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote unquote-splicing update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector-of vector? when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn xml-seq zero? zipmap *default-data-reader-fn* as-> cond-> cond->> reduced reduced? send-via set-agent-send-executor! set-agent-send-off-executor! some-> some->>");
40 "* *' *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* " +
41 "*compile-path* *compiler-options* *data-readers* *e *err* *file* *flush-on-newline* *fn-loader* *in* " +
42 "*math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* " +
43 "*source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* + +' - -' -> " +
44 "->> ->ArrayChunk ->Vec ->VecNode ->VecSeq -cache-protocol-fn -reset-methods .. / < <= = == > >= EMPTY-NODE accessor " +
45 "aclone add-classpath add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! " +
46 "alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double " +
47 "aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 " +
48 "bases bean bigdec bigint biginteger binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set " +
49 "bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* bound? butlast " +
50 "byte byte-array bytes case cat cast char char-array char-escape-string char-name-string char? chars chunk chunk-append " +
51 "chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors " +
52 "clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement completing concat cond condp " +
53 "conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec dec' decimal? " +
54 "declare dedupe default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol " +
55 "defrecord defstruct deftype delay delay? deliver denominator deref derive descendants destructure disj disj! dissoc " +
56 "dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array doubles drop drop-last " +
57 "drop-while eduction empty empty? ensure enumeration-seq error-handler error-mode eval even? every-pred every? ex-data ex-info " +
58 "extend extend-protocol extend-type extenders extends? false? ffirst file-seq filter filterv find find-keyword " +
59 "find-ns find-protocol-impl find-protocol-method find-var first flatten float float-array float? floats flush fn fn? " +
60 "fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future? " +
61 "gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator group-by hash " +
62 "hash-combine hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc inc' init-proxy instance? " +
63 "int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt keep " +
64 "keep-indexed key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file " +
65 "load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array " +
66 "make-hierarchy map map-indexed map? mapcat mapv max max-key memfn memoize merge merge-with meta method-sig methods " +
67 "min min-key mod munge name namespace namespace-munge neg? newline next nfirst nil? nnext not not-any? not-empty " +
68 "not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias " +
69 "ns-unmap nth nthnext nthrest num number? numerator object-array odd? or parents partial partition partition-all " +
70 "partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers " +
71 "primitives-classnames print print-ctor print-dup print-method print-simple print-str printf println println-str " +
72 "prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues " +
73 "quot rand rand-int rand-nth random-sample range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern " +
74 "re-seq read read-line read-string realized? reduce reduce-kv reductions ref ref-history-count ref-max-history " +
75 "ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods " +
76 "remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! resolve rest " +
77 "restart-agent resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? " +
78 "seque sequence sequential? set set-error-handler! set-error-mode! set-validator! set? short short-array shorts " +
79 "shuffle shutdown-agents slurp some some-fn sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? " +
80 "special-symbol? spit split-at split-with str string? struct struct-map subs subseq subvec supers swap! symbol " +
81 "symbol? sync take take-last take-nth take-while test the-ns thread-bound? time to-array to-array-2d trampoline transduce " +
82 "transient tree-seq true? type unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec " +
83 "unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int " +
84 "unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int "+
85 "unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote " +
86 "unquote-splicing update update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector-of " +
87 "vector? volatile! volatile? vreset! vswap! when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context " +
88 "with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn xml-seq zero? zipmap " +
89 "*default-data-reader-fn* as-> cond-> cond->> reduced reduced? send-via set-agent-send-executor! " +
90 "set-agent-send-off-executor! some-> some->>");
3791
3892 var indentKeys = makeKeywords(
3993 // Built-ins
40 "ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type try catch " +
94 "ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto " +
95 "locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type " +
96 "try catch " +
4197
4298 // Binding forms
4399 "let letfn binding loop for doseq dotimes when-let if-let " +
58114 sign: /[+-]/,
59115 exponent: /e/i,
60116 keyword_char: /[^\s\(\[\;\)\]]/,
61 symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/
117 symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/,
118 block_indent: /^(?:def|with)[^\/]+$|\/(?:def|with)/
62119 };
63120
64121 function stateStack(indent, type, prev) { // represents a state stack object
94151
95152 if ( '.' == stream.peek() ) {
96153 stream.eat('.');
154 stream.eatWhile(tests.digit);
155 } else if ('/' == stream.peek() ) {
156 stream.eat('/');
97157 stream.eatWhile(tests.digit);
98158 }
99159
138198 }
139199
140200 // skip spaces
141 if (stream.eatSpace()) {
201 if (state.mode != "string" && stream.eatSpace()) {
142202 return null;
143203 }
144204 var returnType = null;
186246 }
187247
188248 if (keyWord.length > 0 && (indentKeys.propertyIsEnumerable(keyWord) ||
189 /^(?:def|with)/.test(keyWord))) { // indent-word
249 tests.block_indent.test(keyWord))) { // indent-word
190250 pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
191251 } else { // non-indent word
192252 // we continue eating the spaces
239299 });
240300
241301 CodeMirror.defineMIME("text/x-clojure", "clojure");
302 CodeMirror.defineMIME("text/x-clojurescript", "clojure");
303 CodeMirror.defineMIME("application/edn", "clojure");
242304
243305 });
7777 \tab \return \backspace
7878 \u1000 \uAaAa \u9F9F)
7979
80 ;; Let's play with numbers
81 (+ 1 -1 1/2 -1/2 -0.5 0.5)
82
8083 </textarea></form>
8184 <script>
8285 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
2424 var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/;
2525 var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
2626 var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
27 var properties = /^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/;
27 var atProp = /^@[_A-Za-z$][_A-Za-z$0-9]*/;
2828
2929 var wordOperators = wordRegexp(["and", "or", "not",
3030 "is", "isnt", "in",
144144 }
145145 }
146146
147
148
147149 // Handle operators and delimiters
148150 if (stream.match(operators) || stream.match(wordOperators)) {
149151 return "operator";
156158 return "atom";
157159 }
158160
161 if (stream.match(atProp) || state.prop && stream.match(identifiers)) {
162 return "property";
163 }
164
159165 if (stream.match(keywords)) {
160166 return "keyword";
161167 }
162168
163169 if (stream.match(identifiers)) {
164170 return "variable";
165 }
166
167 if (stream.match(properties)) {
168 return "property";
169171 }
170172
171173 // Handle non-detected items
264266 var style = state.tokenize(stream, state);
265267 var current = stream.current();
266268
267 // Handle "." connected identifiers
268 if (current === ".") {
269 style = state.tokenize(stream, state);
270 current = stream.current();
271 if (/^\.[\w$]+$/.test(current)) {
272 return "variable";
273 } else {
274 return ERRORCLASS;
275 }
276 }
277
278269 // Handle scope changes.
279270 if (current === "return") {
280271 state.dedent = true;
281272 }
282 if (((current === "->" || current === "=>") &&
283 !state.lambda &&
284 !stream.peek())
273 if (((current === "->" || current === "=>") && stream.eol())
285274 || style === "indent") {
286275 indent(stream, state);
287276 }
323312 return {
324313 tokenize: tokenBase,
325314 scope: {offset:basecolumn || 0, type:"coffee", prev: null, align: false},
326 lastToken: null,
327 lambda: false,
315 prop: false,
328316 dedent: 0
329317 };
330318 },
334322 if (fillAlign && stream.sol()) fillAlign.align = false;
335323
336324 var style = tokenLexer(stream, state);
337 if (fillAlign && style && style != "comment") fillAlign.align = true;
338
339 state.lastToken = {style:style, content: stream.current()};
340
341 if (stream.eol() && stream.lambda) {
342 state.lambda = false;
325 if (style && style != "comment") {
326 if (fillAlign) fillAlign.align = true;
327 state.prop = style == "punctuation" && stream.current() == "."
343328 }
344329
345330 return style;
364349 });
365350
366351 CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
352 CodeMirror.defineMIME("text/coffeescript", "coffeescript");
367353
368354 });
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 CodeMirror.defineMode("crystal", function(config) {
14 function wordRegExp(words, end) {
15 return new RegExp((end ? "" : "^") + "(?:" + words.join("|") + ")" + (end ? "$" : "\\b"));
16 }
17
18 function chain(tokenize, stream, state) {
19 state.tokenize.push(tokenize);
20 return tokenize(stream, state);
21 }
22
23 var operators = /^(?:[-+/%|&^]|\*\*?|[<>]{2})/;
24 var conditionalOperators = /^(?:[=!]~|===|<=>|[<>=!]=?|[|&]{2}|~)/;
25 var indexingOperators = /^(?:\[\][?=]?)/;
26 var anotherOperators = /^(?:\.(?:\.{2})?|->|[?:])/;
27 var idents = /^[a-z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
28 var types = /^[A-Z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
29 var keywords = wordRegExp([
30 "abstract", "alias", "as", "asm", "begin", "break", "case", "class", "def", "do",
31 "else", "elsif", "end", "ensure", "enum", "extend", "for", "fun", "if", "ifdef",
32 "include", "instance_sizeof", "lib", "macro", "module", "next", "of", "out", "pointerof",
33 "private", "protected", "rescue", "return", "require", "sizeof", "struct",
34 "super", "then", "type", "typeof", "union", "unless", "until", "when", "while", "with",
35 "yield", "__DIR__", "__FILE__", "__LINE__"
36 ]);
37 var atomWords = wordRegExp(["true", "false", "nil", "self"]);
38 var indentKeywordsArray = [
39 "def", "fun", "macro",
40 "class", "module", "struct", "lib", "enum", "union",
41 "if", "unless", "case", "while", "until", "begin", "then",
42 "do",
43 "for", "ifdef"
44 ];
45 var indentKeywords = wordRegExp(indentKeywordsArray);
46 var dedentKeywordsArray = [
47 "end",
48 "else", "elsif",
49 "rescue", "ensure"
50 ];
51 var dedentKeywords = wordRegExp(dedentKeywordsArray);
52 var dedentPunctualsArray = ["\\)", "\\}", "\\]"];
53 var dedentPunctuals = new RegExp("^(?:" + dedentPunctualsArray.join("|") + ")$");
54 var nextTokenizer = {
55 "def": tokenFollowIdent, "fun": tokenFollowIdent, "macro": tokenMacroDef,
56 "class": tokenFollowType, "module": tokenFollowType, "struct": tokenFollowType,
57 "lib": tokenFollowType, "enum": tokenFollowType, "union": tokenFollowType
58 };
59 var matching = {"[": "]", "{": "}", "(": ")", "<": ">"};
60
61 function tokenBase(stream, state) {
62 if (stream.eatSpace()) {
63 return null;
64 }
65
66 // Macros
67 if (state.lastToken != "\\" && stream.match("{%", false)) {
68 return chain(tokenMacro("%", "%"), stream, state);
69 }
70
71 if (state.lastToken != "\\" && stream.match("{{", false)) {
72 return chain(tokenMacro("{", "}"), stream, state);
73 }
74
75 // Comments
76 if (stream.peek() == "#") {
77 stream.skipToEnd();
78 return "comment";
79 }
80
81 // Variables and keywords
82 var matched;
83 if (stream.match(idents)) {
84 stream.eat(/[?!]/);
85
86 matched = stream.current();
87 if (stream.eat(":")) {
88 return "atom";
89 } else if (state.lastToken == ".") {
90 return "property";
91 } else if (keywords.test(matched)) {
92 if (state.lastToken != "abstract" && indentKeywords.test(matched)) {
93 if (!(matched == "fun" && state.blocks.indexOf("lib") >= 0)) {
94 state.blocks.push(matched);
95 state.currentIndent += 1;
96 }
97 } else if (dedentKeywords.test(matched)) {
98 state.blocks.pop();
99 state.currentIndent -= 1;
100 }
101
102 if (nextTokenizer.hasOwnProperty(matched)) {
103 state.tokenize.push(nextTokenizer[matched]);
104 }
105
106 return "keyword";
107 } else if (atomWords.test(matched)) {
108 return "atom";
109 }
110
111 return "variable";
112 }
113
114 // Class variables and instance variables
115 // or attributes
116 if (stream.eat("@")) {
117 if (stream.peek() == "[") {
118 return chain(tokenNest("[", "]", "meta"), stream, state);
119 }
120
121 stream.eat("@");
122 stream.match(idents) || stream.match(types);
123 return "variable-2";
124 }
125
126 // Global variables
127 if (stream.eat("$")) {
128 stream.eat(/[0-9]+|\?/) || stream.match(idents) || stream.match(types);
129 return "variable-3";
130 }
131
132 // Constants and types
133 if (stream.match(types)) {
134 return "tag";
135 }
136
137 // Symbols or ':' operator
138 if (stream.eat(":")) {
139 if (stream.eat("\"")) {
140 return chain(tokenQuote("\"", "atom", false), stream, state);
141 } else if (stream.match(idents) || stream.match(types) ||
142 stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators)) {
143 return "atom";
144 }
145 stream.eat(":");
146 return "operator";
147 }
148
149 // Strings
150 if (stream.eat("\"")) {
151 return chain(tokenQuote("\"", "string", true), stream, state);
152 }
153
154 // Strings or regexps or macro variables or '%' operator
155 if (stream.peek() == "%") {
156 var style = "string";
157 var embed = true;
158 var delim;
159
160 if (stream.match("%r")) {
161 // Regexps
162 style = "string-2";
163 delim = stream.next();
164 } else if (stream.match("%w")) {
165 embed = false;
166 delim = stream.next();
167 } else {
168 if(delim = stream.match(/^%([^\w\s=])/)) {
169 delim = delim[1];
170 } else if (stream.match(/^%[a-zA-Z0-9_\u009F-\uFFFF]*/)) {
171 // Macro variables
172 return "meta";
173 } else {
174 // '%' operator
175 return "operator";
176 }
177 }
178
179 if (matching.hasOwnProperty(delim)) {
180 delim = matching[delim];
181 }
182 return chain(tokenQuote(delim, style, embed), stream, state);
183 }
184
185 // Characters
186 if (stream.eat("'")) {
187 stream.match(/^(?:[^']|\\(?:[befnrtv0'"]|[0-7]{3}|u(?:[0-9a-fA-F]{4}|\{[0-9a-fA-F]{1,6}\})))/);
188 stream.eat("'");
189 return "atom";
190 }
191
192 // Numbers
193 if (stream.eat("0")) {
194 if (stream.eat("x")) {
195 stream.match(/^[0-9a-fA-F]+/);
196 } else if (stream.eat("o")) {
197 stream.match(/^[0-7]+/);
198 } else if (stream.eat("b")) {
199 stream.match(/^[01]+/);
200 }
201 return "number";
202 }
203
204 if (stream.eat(/\d/)) {
205 stream.match(/^\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/);
206 return "number";
207 }
208
209 // Operators
210 if (stream.match(operators)) {
211 stream.eat("="); // Operators can follow assign symbol.
212 return "operator";
213 }
214
215 if (stream.match(conditionalOperators) || stream.match(anotherOperators)) {
216 return "operator";
217 }
218
219 // Parens and braces
220 if (matched = stream.match(/[({[]/, false)) {
221 matched = matched[0];
222 return chain(tokenNest(matched, matching[matched], null), stream, state);
223 }
224
225 // Escapes
226 if (stream.eat("\\")) {
227 stream.next();
228 return "meta";
229 }
230
231 stream.next();
232 return null;
233 }
234
235 function tokenNest(begin, end, style, started) {
236 return function (stream, state) {
237 if (!started && stream.match(begin)) {
238 state.tokenize[state.tokenize.length - 1] = tokenNest(begin, end, style, true);
239 state.currentIndent += 1;
240 return style;
241 }
242
243 var nextStyle = tokenBase(stream, state);
244 if (stream.current() === end) {
245 state.tokenize.pop();
246 state.currentIndent -= 1;
247 nextStyle = style;
248 }
249
250 return nextStyle;
251 };
252 }
253
254 function tokenMacro(begin, end, started) {
255 return function (stream, state) {
256 if (!started && stream.match("{" + begin)) {
257 state.currentIndent += 1;
258 state.tokenize[state.tokenize.length - 1] = tokenMacro(begin, end, true);
259 return "meta";
260 }
261
262 if (stream.match(end + "}")) {
263 state.currentIndent -= 1;
264 state.tokenize.pop();
265 return "meta";
266 }
267
268 return tokenBase(stream, state);
269 };
270 }
271
272 function tokenMacroDef(stream, state) {
273 if (stream.eatSpace()) {
274 return null;
275 }
276
277 var matched;
278 if (matched = stream.match(idents)) {
279 if (matched == "def") {
280 return "keyword";
281 }
282 stream.eat(/[?!]/);
283 }
284
285 state.tokenize.pop();
286 return "def";
287 }
288
289 function tokenFollowIdent(stream, state) {
290 if (stream.eatSpace()) {
291 return null;
292 }
293
294 if (stream.match(idents)) {
295 stream.eat(/[!?]/);
296 } else {
297 stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators);
298 }
299 state.tokenize.pop();
300 return "def";
301 }
302
303 function tokenFollowType(stream, state) {
304 if (stream.eatSpace()) {
305 return null;
306 }
307
308 stream.match(types);
309 state.tokenize.pop();
310 return "def";
311 }
312
313 function tokenQuote(end, style, embed) {
314 return function (stream, state) {
315 var escaped = false;
316
317 while (stream.peek()) {
318 if (!escaped) {
319 if (stream.match("{%", false)) {
320 state.tokenize.push(tokenMacro("%", "%"));
321 return style;
322 }
323
324 if (stream.match("{{", false)) {
325 state.tokenize.push(tokenMacro("{", "}"));
326 return style;
327 }
328
329 if (embed && stream.match("#{", false)) {
330 state.tokenize.push(tokenNest("#{", "}", "meta"));
331 return style;
332 }
333
334 var ch = stream.next();
335
336 if (ch == end) {
337 state.tokenize.pop();
338 return style;
339 }
340
341 escaped = ch == "\\";
342 } else {
343 stream.next();
344 escaped = false;
345 }
346 }
347
348 return style;
349 };
350 }
351
352 return {
353 startState: function () {
354 return {
355 tokenize: [tokenBase],
356 currentIndent: 0,
357 lastToken: null,
358 blocks: []
359 };
360 },
361
362 token: function (stream, state) {
363 var style = state.tokenize[state.tokenize.length - 1](stream, state);
364 var token = stream.current();
365
366 if (style && style != "comment") {
367 state.lastToken = token;
368 }
369
370 return style;
371 },
372
373 indent: function (state, textAfter) {
374 textAfter = textAfter.replace(/^\s*(?:\{%)?\s*|\s*(?:%\})?\s*$/g, "");
375
376 if (dedentKeywords.test(textAfter) || dedentPunctuals.test(textAfter)) {
377 return config.indentUnit * (state.currentIndent - 1);
378 }
379
380 return config.indentUnit * state.currentIndent;
381 },
382
383 fold: "indent",
384 electricInput: wordRegExp(dedentPunctualsArray.concat(dedentKeywordsArray), true),
385 lineComment: '#'
386 };
387 });
388
389 CodeMirror.defineMIME("text/x-crystal", "crystal");
390 });
0 <!doctype html>
1
2 <title>CodeMirror: Crystal mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="crystal.js"></script>
10 <style>
11 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
12 .cm-s-default span.cm-arrow { color: red; }
13 </style>
14
15 <div id=nav>
16 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
17
18 <ul>
19 <li><a href="../../index.html">Home</a>
20 <li><a href="../../doc/manual.html">Manual</a>
21 <li><a href="https://github.com/codemirror/codemirror">Code</a>
22 </ul>
23 <ul>
24 <li><a href="../index.html">Language modes</a>
25 <li><a class=active href="#">Crystal</a>
26 </ul>
27 </div>
28
29 <article>
30 <h2>Crystal mode</h2>
31 <form><textarea id="code" name="code">
32 # Features of Crystal
33 # - Ruby-inspired syntax.
34 # - Statically type-checked but without having to specify the type of variables or method arguments.
35 # - Be able to call C code by writing bindings to it in Crystal.
36 # - Have compile-time evaluation and generation of code, to avoid boilerplate code.
37 # - Compile to efficient native code.
38
39 # A very basic HTTP server
40 require "http/server"
41
42 server = HTTP::Server.new(8080) do |request|
43 HTTP::Response.ok "text/plain", "Hello world, got #{request.path}!"
44 end
45
46 puts "Listening on http://0.0.0.0:8080"
47 server.listen
48
49 module Foo
50 def initialize(@foo); end
51
52 abstract def abstract_method : String
53
54 @[AlwaysInline]
55 def with_foofoo
56 with Foo.new(self) yield
57 end
58
59 struct Foo
60 def initialize(@foo); end
61
62 def hello_world
63 @foo.abstract_method
64 end
65 end
66 end
67
68 class Bar
69 include Foo
70
71 @@foobar = 12345
72
73 def initialize(@bar)
74 super(@bar.not_nil! + 100)
75 end
76
77 macro alias_method(name, method)
78 def {{ name }}(*args)
79 {{ method }}(*args)
80 end
81 end
82
83 def a_method
84 "Hello, World"
85 end
86
87 alias_method abstract_method, a_method
88
89 macro def show_instance_vars : Nil
90 {% for var in @type.instance_vars %}
91 puts "@{{ var }} = #{ @{{ var }} }"
92 {% end %}
93 nil
94 end
95 end
96
97 class Baz &lt; Bar; end
98
99 lib LibC
100 fun c_puts = "puts"(str : Char*) : Int
101 end
102
103 $baz = Baz.new(100)
104 $baz.show_instance_vars
105 $baz.with_foofoo do
106 LibC.c_puts hello_world
107 end
108 </textarea></form>
109 <script>
110 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
111 mode: "text/x-crystal",
112 matchBrackets: true,
113 indentUnit: 2
114 });
115 </script>
116
117 <p><strong>MIME types defined:</strong> <code>text/x-crystal</code>.</p>
118 </article>
1111 "use strict";
1212
1313 CodeMirror.defineMode("css", function(config, parserConfig) {
14 var inline = parserConfig.inline
1415 if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
1516
1617 var indentUnit = config.indentUnit,
1819 documentTypes = parserConfig.documentTypes || {},
1920 mediaTypes = parserConfig.mediaTypes || {},
2021 mediaFeatures = parserConfig.mediaFeatures || {},
22 mediaValueKeywords = parserConfig.mediaValueKeywords || {},
2123 propertyKeywords = parserConfig.propertyKeywords || {},
2224 nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
2325 fontProperties = parserConfig.fontProperties || {},
2426 counterDescriptors = parserConfig.counterDescriptors || {},
2527 colorKeywords = parserConfig.colorKeywords || {},
2628 valueKeywords = parserConfig.valueKeywords || {},
27 allowNested = parserConfig.allowNested;
29 allowNested = parserConfig.allowNested,
30 supportsAtComponent = parserConfig.supportsAtComponent === true;
2831
2932 var type, override;
3033 function ret(style, tp) { type = tp; return style; }
118121 this.prev = prev;
119122 }
120123
121 function pushContext(state, stream, type) {
122 state.context = new Context(type, stream.indentation() + indentUnit, state.context);
124 function pushContext(state, stream, type, indent) {
125 state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
123126 return type;
124127 }
125128
126129 function popContext(state) {
127 state.context = state.context.prev;
130 if (state.context.prev)
131 state.context = state.context.prev;
128132 return state.context.type;
129133 }
130134
156160 return pushContext(state, stream, "block");
157161 } else if (type == "}" && state.context.prev) {
158162 return popContext(state);
159 } else if (/@(media|supports|(-moz-)?document)/.test(type)) {
163 } else if (supportsAtComponent && /@component/.test(type)) {
164 return pushContext(state, stream, "atComponentBlock");
165 } else if (/^@(-moz-)?document$/.test(type)) {
166 return pushContext(state, stream, "documentTypes");
167 } else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) {
160168 return pushContext(state, stream, "atBlock");
161 } else if (/@(font-face|counter-style)/.test(type)) {
169 } else if (/^@(font-face|counter-style)/.test(type)) {
162170 state.stateArg = type;
163171 return "restricted_atBlock_before";
164172 } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
218226 if (type == "}" || type == "{") return popAndPass(type, stream, state);
219227 if (type == "(") return pushContext(state, stream, "parens");
220228
221 if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
229 if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
222230 override += " error";
223231 } else if (type == "word") {
224232 wordAsValue(stream);
251259 return pass(type, stream, state);
252260 };
253261
262 states.documentTypes = function(type, stream, state) {
263 if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
264 override = "tag";
265 return state.context.type;
266 } else {
267 return states.atBlock(type, stream, state);
268 }
269 };
270
254271 states.atBlock = function(type, stream, state) {
255272 if (type == "(") return pushContext(state, stream, "atBlock_parens");
256 if (type == "}") return popAndPass(type, stream, state);
273 if (type == "}" || type == ";") return popAndPass(type, stream, state);
257274 if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
275
276 if (type == "interpolation") return pushContext(state, stream, "interpolation");
258277
259278 if (type == "word") {
260279 var word = stream.current().toLowerCase();
261280 if (word == "only" || word == "not" || word == "and" || word == "or")
262281 override = "keyword";
263 else if (documentTypes.hasOwnProperty(word))
264 override = "tag";
265282 else if (mediaTypes.hasOwnProperty(word))
266283 override = "attribute";
267284 else if (mediaFeatures.hasOwnProperty(word))
268285 override = "property";
286 else if (mediaValueKeywords.hasOwnProperty(word))
287 override = "keyword";
269288 else if (propertyKeywords.hasOwnProperty(word))
270289 override = "property";
271290 else if (nonStandardPropertyKeywords.hasOwnProperty(word))
272291 override = "string-2";
273292 else if (valueKeywords.hasOwnProperty(word))
274293 override = "atom";
294 else if (colorKeywords.hasOwnProperty(word))
295 override = "keyword";
275296 else
276297 override = "error";
277298 }
299 return state.context.type;
300 };
301
302 states.atComponentBlock = function(type, stream, state) {
303 if (type == "}")
304 return popAndPass(type, stream, state);
305 if (type == "{")
306 return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
307 if (type == "word")
308 override = "error";
278309 return state.context.type;
279310 };
280311
335366 return {
336367 startState: function(base) {
337368 return {tokenize: null,
338 state: "top",
369 state: inline ? "block" : "top",
339370 stateArg: null,
340 context: new Context("top", base || 0, null)};
371 context: new Context(inline ? "block" : "top", base || 0, null)};
341372 },
342373
343374 token: function(stream, state) {
356387 var cx = state.context, ch = textAfter && textAfter.charAt(0);
357388 var indent = cx.indent;
358389 if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
359 if (cx.prev &&
360 (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock") ||
361 ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
362 ch == "{" && (cx.type == "at" || cx.type == "atBlock"))) {
363 indent = cx.indent - indentUnit;
364 cx = cx.prev;
390 if (cx.prev) {
391 if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
392 cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
393 // Resume indentation from parent context.
394 cx = cx.prev;
395 indent = cx.indent;
396 } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
397 ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
398 // Dedent relative to current context.
399 indent = Math.max(0, cx.indent - indentUnit);
400 cx = cx.prev;
401 }
365402 }
366403 return indent;
367404 },
398435 "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
399436 "max-color", "color-index", "min-color-index", "max-color-index",
400437 "monochrome", "min-monochrome", "max-monochrome", "resolution",
401 "min-resolution", "max-resolution", "scan", "grid"
438 "min-resolution", "max-resolution", "scan", "grid", "orientation",
439 "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
440 "pointer", "any-pointer", "hover", "any-hover"
402441 ], mediaFeatures = keySet(mediaFeatures_);
442
443 var mediaValueKeywords_ = [
444 "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
445 "interlace", "progressive"
446 ], mediaValueKeywords = keySet(mediaValueKeywords_);
403447
404448 var propertyKeywords_ = [
405449 "align-content", "align-items", "align-self", "alignment-adjust",
407451 "animation-direction", "animation-duration", "animation-fill-mode",
408452 "animation-iteration-count", "animation-name", "animation-play-state",
409453 "animation-timing-function", "appearance", "azimuth", "backface-visibility",
410 "background", "background-attachment", "background-clip", "background-color",
411 "background-image", "background-origin", "background-position",
454 "background", "background-attachment", "background-blend-mode", "background-clip",
455 "background-color", "background-image", "background-origin", "background-position",
412456 "background-repeat", "background-size", "baseline-shift", "binding",
413457 "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
414458 "bookmark-target", "border", "border-bottom", "border-bottom-color",
439483 "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
440484 "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
441485 "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
442 "grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
443 "grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
444 "grid-template", "grid-template-areas", "grid-template-columns",
486 "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
487 "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
488 "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
445489 "grid-template-rows", "hanging-punctuation", "height", "hyphens",
446490 "icon", "image-orientation", "image-rendering", "image-resolution",
447491 "inline-box-align", "justify-content", "left", "letter-spacing",
552596 "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
553597 "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
554598 "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
555 "col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
599 "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
600 "compact", "condensed", "contain", "content",
556601 "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
557 "cross", "crosshair", "currentcolor", "cursive", "cyclic", "dashed", "decimal",
558 "decimal-leading-zero", "default", "default-button", "destination-atop",
559 "destination-in", "destination-out", "destination-over", "devanagari",
602 "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
603 "decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
604 "destination-in", "destination-out", "destination-over", "devanagari", "difference",
560605 "disc", "discard", "disclosure-closed", "disclosure-open", "document",
561606 "dot-dash", "dot-dot-dash",
562607 "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
567612 "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
568613 "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
569614 "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
570 "ethiopic-numeric", "ew-resize", "expanded", "extends", "extra-condensed",
571 "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "footnotes",
572 "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
573 "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
615 "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
616 "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
617 "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
618 "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
574619 "help", "hidden", "hide", "higher", "highlight", "highlighttext",
575 "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
620 "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
576621 "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
577622 "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
578 "inline-block", "inline-flex", "inline-table", "inset", "inside", "intrinsic", "invert",
623 "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
579624 "italic", "japanese-formal", "japanese-informal", "justify", "kannada",
580625 "katakana", "katakana-iroha", "keep-all", "khmer",
581626 "korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
582 "landscape", "lao", "large", "larger", "left", "level", "lighter",
627 "landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
583628 "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
584629 "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
585630 "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
586 "lower-roman", "lowercase", "ltr", "malayalam", "match", "matrix", "matrix3d",
631 "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
587632 "media-controls-background", "media-current-time-display",
588633 "media-fullscreen-button", "media-mute-button", "media-play-button",
589634 "media-return-to-realtime-button", "media-rewind-button",
592637 "media-volume-slider-container", "media-volume-sliderthumb", "medium",
593638 "menu", "menulist", "menulist-button", "menulist-text",
594639 "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
595 "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
640 "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
596641 "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
597642 "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
598643 "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
605650 "relative", "repeat", "repeating-linear-gradient",
606651 "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
607652 "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
608 "rotateZ", "round", "row-resize", "rtl", "run-in", "running",
609 "s-resize", "sans-serif", "scale", "scale3d", "scaleX", "scaleY", "scaleZ",
653 "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
654 "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
610655 "scroll", "scrollbar", "se-resize", "searchfield",
611656 "searchfield-cancel-button", "searchfield-decoration",
612657 "searchfield-results-button", "searchfield-results-decoration",
614659 "simp-chinese-formal", "simp-chinese-informal", "single",
615660 "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
616661 "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
617 "small", "small-caps", "small-caption", "smaller", "solid", "somali",
618 "source-atop", "source-in", "source-out", "source-over", "space", "spell-out", "square",
662 "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
663 "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "spell-out", "square",
619664 "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
620665 "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
621666 "table-caption", "table-cell", "table-column", "table-column-group",
632677 "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
633678 "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
634679 "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
635 "window", "windowframe", "windowtext", "words", "x-large", "x-small", "xor",
680 "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
636681 "xx-large", "xx-small"
637682 ], valueKeywords = keySet(valueKeywords_);
638683
639 var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(propertyKeywords_)
640 .concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
684 var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
685 .concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
686 .concat(valueKeywords_);
641687 CodeMirror.registerHelper("hintWords", "css", allWords);
642688
643689 function tokenCComment(stream, state) {
656702 documentTypes: documentTypes,
657703 mediaTypes: mediaTypes,
658704 mediaFeatures: mediaFeatures,
705 mediaValueKeywords: mediaValueKeywords,
659706 propertyKeywords: propertyKeywords,
660707 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
661708 fontProperties: fontProperties,
675722 CodeMirror.defineMIME("text/x-scss", {
676723 mediaTypes: mediaTypes,
677724 mediaFeatures: mediaFeatures,
725 mediaValueKeywords: mediaValueKeywords,
678726 propertyKeywords: propertyKeywords,
679727 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
680728 colorKeywords: colorKeywords,
716764 CodeMirror.defineMIME("text/x-less", {
717765 mediaTypes: mediaTypes,
718766 mediaFeatures: mediaFeatures,
767 mediaValueKeywords: mediaValueKeywords,
719768 propertyKeywords: propertyKeywords,
720769 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
721770 colorKeywords: colorKeywords,
750799 helperType: "less"
751800 });
752801
802 CodeMirror.defineMIME("text/x-gss", {
803 documentTypes: documentTypes,
804 mediaTypes: mediaTypes,
805 mediaFeatures: mediaFeatures,
806 propertyKeywords: propertyKeywords,
807 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
808 fontProperties: fontProperties,
809 counterDescriptors: counterDescriptors,
810 colorKeywords: colorKeywords,
811 valueKeywords: valueKeywords,
812 supportsAtComponent: true,
813 tokenHooks: {
814 "/": function(stream, state) {
815 if (!stream.eat("*")) return false;
816 state.tokenize = tokenCComment;
817 return tokenCComment(stream, state);
818 }
819 },
820 name: "css",
821 helperType: "gss"
822 });
823
753824 });
0 <!doctype html>
1
2 <title>CodeMirror: Closure Stylesheets (GSS) mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <link rel="stylesheet" href="../../addon/hint/show-hint.css">
8 <script src="../../lib/codemirror.js"></script>
9 <script src="css.js"></script>
10 <script src="../../addon/hint/show-hint.js"></script>
11 <script src="../../addon/hint/css-hint.js"></script>
12 <style>.CodeMirror {background: #f8f8f8;}</style>
13 <div id=nav>
14 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
15
16 <ul>
17 <li><a href="../../index.html">Home</a>
18 <li><a href="../../doc/manual.html">Manual</a>
19 <li><a href="https://github.com/codemirror/codemirror">Code</a>
20 </ul>
21 <ul>
22 <li><a href="../index.html">Language modes</a>
23 <li><a class=active href="#">Closure Stylesheets (GSS)</a>
24 </ul>
25 </div>
26
27 <article>
28 <h2>Closure Stylesheets (GSS) mode</h2>
29 <form><textarea id="code" name="code">
30 /* Some example Closure Stylesheets */
31
32 @provide 'some.styles';
33
34 @require 'other.styles';
35
36 @component {
37
38 @def FONT_FAMILY "Times New Roman", Georgia, Serif;
39 @def FONT_SIZE_NORMAL 15px;
40 @def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
41
42 @def BG_COLOR rgb(235, 239, 249);
43
44 @def DIALOG_BORDER_COLOR rgb(107, 144, 218);
45 @def DIALOG_BG_COLOR BG_COLOR;
46
47 @def LEFT_HAND_NAV_WIDTH 180px;
48 @def LEFT_HAND_NAV_PADDING 3px;
49
50 @defmixin size(WIDTH, HEIGHT) {
51 width: WIDTH;
52 height: HEIGHT;
53 }
54
55 body {
56 background-color: BG_COLOR;
57 margin: 0;
58 padding: 3em 6em;
59 font: FONT_NORMAL;
60 color: #000;
61 }
62
63 #navigation a {
64 font-weight: bold;
65 text-decoration: none !important;
66 }
67
68 .dialog {
69 background-color: DIALOG_BG_COLOR;
70 border: 1px solid DIALOG_BORDER_COLOR;
71 }
72
73 .content {
74 position: absolute;
75 margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
76 LEFT_HAND_NAV_WIDTH,
77 LEFT_HAND_NAV_PADDING); /* padding right */
78
79 }
80
81 .logo {
82 @mixin size(150px, 55px);
83 background-image: url('http://www.google.com/images/logo_sm.gif');
84 }
85
86 }
87 </textarea></form>
88 <script>
89 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
90 extraKeys: {"Ctrl-Space": "autocomplete"},
91 lineNumbers: true,
92 matchBrackets: "text/x-less",
93 mode: "text/x-gss"
94 });
95 </script>
96
97 <p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
98 <p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
99
100 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
101
102 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 "use strict";
5
6 var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss");
7 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); }
8
9 MT("atComponent",
10 "[def @component] {",
11 "[tag foo] {",
12 " [property color]: [keyword black];",
13 "}",
14 "}");
15
16 })();
2525
2626 MT("mixin",
2727 "[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
28 " [property color]: [variable darken]([variable-2 @color], [number 10%]);",
28 " [property color]: [atom darken]([variable-2 @color], [number 10%]);",
2929 "}",
3030 "[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
31 " [property color]: [variable lighten]([variable-2 @color], [number 10%]);",
31 " [property color]: [atom lighten]([variable-2 @color], [number 10%]);",
3232 "}",
3333 "[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
3434 " [property display]: [atom block];",
9494
9595 MT('indent_parentheses',
9696 "[tag foo] {",
97 " [property color]: [variable darken]([variable-2 $blue],",
97 " [property color]: [atom darken]([variable-2 $blue],",
9898 " [number 9%]);",
9999 "}");
100100
55 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
66
77 // Error, because "foobarhello" is neither a known type or property, but
8 // property was expected (after "and"), and it should be in parenthese.
8 // property was expected (after "and"), and it should be in parentheses.
99 MT("atMediaUnknownType",
1010 "[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
1111
1616 // Make sure nesting works with media queries
1717 MT("atMediaMaxWidthNested",
1818 "[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
19
20 MT("atMediaFeatureValueKeyword",
21 "[def @media] ([property orientation]: [keyword landscape]) { }");
22
23 MT("atMediaUnknownFeatureValueKeyword",
24 "[def @media] ([property orientation]: [error upsidedown]) { }");
1925
2026 MT("tagSelector",
2127 "[tag foo] { }");
4854 MT("tagColorHex3",
4955 "[tag foo] { [property background]: [atom #fff]; }");
5056
57 MT("tagColorHex4",
58 "[tag foo] { [property background]: [atom #ffff]; }");
59
5160 MT("tagColorHex6",
5261 "[tag foo] { [property background]: [atom #ffffff]; }");
5362
54 MT("tagColorHex4",
55 "[tag foo] { [property background]: [atom&error #ffff]; }");
63 MT("tagColorHex8",
64 "[tag foo] { [property background]: [atom #ffffffff]; }");
65
66 MT("tagColorHex5Invalid",
67 "[tag foo] { [property background]: [atom&error #fffff]; }");
5668
5769 MT("tagColorHexInvalid",
5870 "[tag foo] { [property background]: [atom&error #ffg]; }");
113125 "}");
114126
115127 MT("empty_url",
116 "[def @import] [tag url]() [tag screen];");
128 "[def @import] [atom url]() [attribute screen];");
117129
118130 MT("parens",
119131 "[qualifier .foo] {",
149161 " [tag foo] {",
150162 " [property font-family]: [variable Verdana], [atom sans-serif];",
151163 " }",
152 " }");
164 "}");
153165
154166 MT("document_url",
155167 "[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
5959 };
6060 var indentUnit = config.indentUnit;
6161 var curPunc;
62 var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "right", "round", "rtrim", "shortestPath", "sign", "sin", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "trim", "type", "upper"]);
63 var preds = wordRegexp(["all", "and", "any", "has", "in", "none", "not", "or", "single", "xor"]);
64 var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "distinct", "drop", "else", "end", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]);
62 var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
63 var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
64 var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]);
6565 var operatorChars = /[*+\-<>=&|~%^]/;
6666
6767 return {
1414 "implements get native operator set typedef with enum throw rethrow " +
1515 "assert break case continue default in return new deferred async await " +
1616 "try catch finally do else for if switch while import library export " +
17 "part of show hide is").split(" ");
17 "part of show hide is as").split(" ");
1818 var blockKeywords = "try catch finally do else for if switch while".split(" ");
1919 var atoms = "true false null".split(" ");
2020 var builtins = "void bool num int double dynamic var String".split(" ");
2525 return obj;
2626 }
2727
28 function pushInterpolationStack(state) {
29 (state.interpolationStack || (state.interpolationStack = [])).push(state.tokenize);
30 }
31
32 function popInterpolationStack(state) {
33 return (state.interpolationStack || (state.interpolationStack = [])).pop();
34 }
35
36 function sizeInterpolationStack(state) {
37 return state.interpolationStack ? state.interpolationStack.length : 0;
38 }
39
2840 CodeMirror.defineMIME("application/dart", {
2941 name: "clike",
3042 keywords: set(keywords),
31 multiLineStrings: true,
3243 blockKeywords: set(blockKeywords),
3344 builtin: set(builtins),
3445 atoms: set(atoms),
3546 hooks: {
3647 "@": function(stream) {
37 stream.eatWhile(/[\w\$_]/);
48 stream.eatWhile(/[\w\$_\.]/);
3849 return "meta";
50 },
51
52 // custom string handling to deal with triple-quoted strings and string interpolation
53 "'": function(stream, state) {
54 return tokenString("'", stream, state, false);
55 },
56 "\"": function(stream, state) {
57 return tokenString("\"", stream, state, false);
58 },
59 "r": function(stream, state) {
60 var peek = stream.peek();
61 if (peek == "'" || peek == "\"") {
62 return tokenString(stream.next(), stream, state, true);
63 }
64 return false;
65 },
66
67 "}": function(_stream, state) {
68 // "}" is end of interpolation, if interpolation stack is non-empty
69 if (sizeInterpolationStack(state) > 0) {
70 state.tokenize = popInterpolationStack(state);
71 return null;
72 }
73 return false;
74 },
75
76 "/": function(stream, state) {
77 if (!stream.eat("*")) return false
78 state.tokenize = tokenNestedComment(1)
79 return state.tokenize(stream, state)
3980 }
4081 }
4182 });
83
84 function tokenString(quote, stream, state, raw) {
85 var tripleQuoted = false;
86 if (stream.eat(quote)) {
87 if (stream.eat(quote)) tripleQuoted = true;
88 else return "string"; //empty string
89 }
90 function tokenStringHelper(stream, state) {
91 var escaped = false;
92 while (!stream.eol()) {
93 if (!raw && !escaped && stream.peek() == "$") {
94 pushInterpolationStack(state);
95 state.tokenize = tokenInterpolation;
96 return "string";
97 }
98 var next = stream.next();
99 if (next == quote && !escaped && (!tripleQuoted || stream.match(quote + quote))) {
100 state.tokenize = null;
101 break;
102 }
103 escaped = !raw && !escaped && next == "\\";
104 }
105 return "string";
106 }
107 state.tokenize = tokenStringHelper;
108 return tokenStringHelper(stream, state);
109 }
110
111 function tokenInterpolation(stream, state) {
112 stream.eat("$");
113 if (stream.eat("{")) {
114 // let clike handle the content of ${...},
115 // we take over again when "}" appears (see hooks).
116 state.tokenize = null;
117 } else {
118 state.tokenize = tokenInterpolationIdentifier;
119 }
120 return null;
121 }
122
123 function tokenInterpolationIdentifier(stream, state) {
124 stream.eatWhile(/[\w_]/);
125 state.tokenize = popInterpolationStack(state);
126 return "variable";
127 }
128
129 function tokenNestedComment(depth) {
130 return function (stream, state) {
131 var ch
132 while (ch = stream.next()) {
133 if (ch == "*" && stream.eat("/")) {
134 if (depth == 1) {
135 state.tokenize = null
136 break
137 } else {
138 state.tokenize = tokenNestedComment(depth - 1)
139 return state.tokenize(stream, state)
140 }
141 } else if (ch == "/" && stream.eat("*")) {
142 state.tokenize = tokenNestedComment(depth + 1)
143 return state.tokenize(stream, state)
144 }
145 }
146 return "comment"
147 }
148 }
42149
43150 CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
44151
1313 "use strict";
1414
1515 CodeMirror.defineMode("django:inner", function() {
16 var keywords = ["block", "endblock", "for", "endfor", "true", "false",
17 "loop", "none", "self", "super", "if", "endif", "as",
18 "else", "import", "with", "endwith", "without", "context", "ifequal", "endifequal",
19 "ifnotequal", "endifnotequal", "extends", "include", "load", "comment",
20 "endcomment", "empty", "url", "static", "trans", "blocktrans", "now", "regroup",
21 "lorem", "ifchanged", "endifchanged", "firstof", "debug", "cycle", "csrf_token",
22 "autoescape", "endautoescape", "spaceless", "ssi", "templatetag",
23 "verbatim", "endverbatim", "widthratio"],
16 var keywords = ["block", "endblock", "for", "endfor", "true", "false", "filter", "endfilter",
17 "loop", "none", "self", "super", "if", "elif", "endif", "as", "else", "import",
18 "with", "endwith", "without", "context", "ifequal", "endifequal", "ifnotequal",
19 "endifnotequal", "extends", "include", "load", "comment", "endcomment",
20 "empty", "url", "static", "trans", "blocktrans", "endblocktrans", "now",
21 "regroup", "lorem", "ifchanged", "endifchanged", "firstof", "debug", "cycle",
22 "csrf_token", "autoescape", "endautoescape", "spaceless", "endspaceless",
23 "ssi", "templatetag", "verbatim", "endverbatim", "widthratio"],
2424 filters = ["add", "addslashes", "capfirst", "center", "cut", "date",
2525 "default", "default_if_none", "dictsort",
2626 "dictsortreversed", "divisibleby", "escape", "escapejs",
3434 "truncatechars_html", "truncatewords", "truncatewords_html",
3535 "unordered_list", "upper", "urlencode", "urlize",
3636 "urlizetrunc", "wordcount", "wordwrap", "yesno"],
37 operators = ["==", "!=", "<", ">", "<=", ">=", "in", "not", "or", "and"];
37 operators = ["==", "!=", "<", ">", "<=", ">="],
38 wordOperators = ["in", "not", "or", "and"];
3839
3940 keywords = new RegExp("^\\b(" + keywords.join("|") + ")\\b");
4041 filters = new RegExp("^\\b(" + filters.join("|") + ")\\b");
4142 operators = new RegExp("^\\b(" + operators.join("|") + ")\\b");
43 wordOperators = new RegExp("^\\b(" + wordOperators.join("|") + ")\\b");
4244
4345 // We have to return "null" instead of null, in order to avoid string
4446 // styling as the default, when using Django templates inside HTML
5860
5961 // Ignore completely any stream series that do not match the
6062 // Django template opening tags.
61 while (stream.next() != null && !stream.match("{{", false) && !stream.match("{%", false)) {}
63 while (stream.next() != null && !stream.match(/\{[{%#]/, false)) {}
6264 return null;
6365 }
6466
6567 // A string can be included in either single or double quotes (this is
66 // the delimeter). Mark everything as a string until the start delimeter
68 // the delimiter). Mark everything as a string until the start delimiter
6769 // occurs again.
68 function inString (delimeter, previousTokenizer) {
70 function inString (delimiter, previousTokenizer) {
6971 return function (stream, state) {
70 if (!state.escapeNext && stream.eat(delimeter)) {
72 if (!state.escapeNext && stream.eat(delimiter)) {
7173 state.tokenize = previousTokenizer;
7274 } else {
7375 if (state.escapeNext) {
7779 var ch = stream.next();
7880
7981 // Take into account the backslash for escaping characters, such as
80 // the string delimeter.
82 // the string delimiter.
8183 if (ch == "\\") {
8284 state.escapeNext = true;
8385 }
9799 return "null";
98100 }
99101
100 // Dot folowed by a non-word character should be considered an error.
102 // Dot followed by a non-word character should be considered an error.
101103 if (stream.match(/\.\W+/)) {
102104 return "error";
103105 } else if (stream.eat(".")) {
116118 return "null";
117119 }
118120
119 // Pipe folowed by a non-word character should be considered an error.
121 // Pipe followed by a non-word character should be considered an error.
120122 if (stream.match(/\.\W+/)) {
121123 return "error";
122124 } else if (stream.eat("|")) {
196198 return "null";
197199 }
198200
199 // Dot folowed by a non-word character should be considered an error.
201 // Dot followed by a non-word character should be considered an error.
200202 if (stream.match(/\.\W+/)) {
201203 return "error";
202204 } else if (stream.eat(".")) {
215217 return "null";
216218 }
217219
218 // Pipe folowed by a non-word character should be considered an error.
220 // Pipe followed by a non-word character should be considered an error.
219221 if (stream.match(/\.\W+/)) {
220222 return "error";
221223 } else if (stream.eat("|")) {
267269 // Attempt to match an operator
268270 if (stream.match(operators)) {
269271 return "operator";
272 }
273
274 // Attempt to match a word operator
275 if (stream.match(wordOperators)) {
276 return "keyword";
270277 }
271278
272279 // Attempt to match a keyword
309316
310317 // Mark everything as comment inside the tag and the tag itself.
311318 function inComment (stream, state) {
312 if (stream.match("#}")) {
313 state.tokenize = tokenBase;
314 }
319 if (stream.match(/^.*?#\}/)) state.tokenize = tokenBase
320 else stream.skipToEnd()
315321 return "comment";
316322 }
317323
6868 token: null,
6969 next: "start"
7070 }
71 ]
71 ],
72 meta: {
73 lineComment: "#"
74 }
7275 });
7376
7477 CodeMirror.defineMIME("text/x-dockerfile", "dockerfile");
113113
114114 if( textAfter.match(/\]\s+|\]/) )n=n-1;
115115 else if(textAfter.substr(textAfter.length-1, textAfter.length) === ">"){
116 if(textAfter.substr(0,1) === "<")n;
117 else if( type == "doindent" && textAfter.length > 1 )n;
116 if(textAfter.substr(0,1) === "<") {}
117 else if( type == "doindent" && textAfter.length > 1 ) {}
118118 else if( type == "doindent")n--;
119 else if( type == ">" && textAfter.length > 1)n;
120 else if( type == "tag" && textAfter !== ">")n;
119 else if( type == ">" && textAfter.length > 1) {}
120 else if( type == "tag" && textAfter !== ">") {}
121121 else if( type == "tag" && state.stack[state.stack.length-1] == "rule")n--;
122122 else if( type == "tag")n++;
123123 else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule" && type === ">")n--;
124 else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule")n;
124 else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule") {}
125125 else if( textAfter.substr(0,1) !== "<" && textAfter.substr(0,1) === ">" )n=n-1;
126 else if( textAfter === ">")n;
126 else if( textAfter === ">") {}
127127 else n=n-1;
128128 //over rule them all
129129 if(type == null || type == "]")n--;
168168 } else if (stream.eat("/")) {
169169 stream.skipToEnd();
170170 return "comment";
171 } else {
172 stream.skipTo(" ");
173 return "operator";
174 }
171 }
172 stream.backUp(1);
175173 }
176174 // Decimal
177 else if (/\d/.test(ch)) {
178 stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
179 return "number";
175 else if (/[+\-\d\.]/.test(ch)) {
176 if (stream.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i) ||
177 stream.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i) ||
178 stream.match(/^[+-]?\d+/)) {
179 return "number";
180 }
180181 }
181182 // Hash
182183 else if (ch == "#") {
185186 ch = stream.peek();
186187 if (ch == '"') {
187188 stream.next();
188 return chain(stream, state, tokenString('"', "string-2"));
189 return chain(stream, state, tokenString('"', "string"));
189190 }
190191 // Binary number
191192 else if (ch == "b") {
205206 stream.eatWhile(/[0-7]/);
206207 return "number";
207208 }
209 // Token concatenation in macros
210 else if (ch == '#') {
211 stream.next();
212 return "punctuation";
213 }
214 // Sequence literals
215 else if ((ch == '[') || (ch == '(')) {
216 stream.next();
217 return "bracket";
208218 // Hash symbol
209 else {
219 } else if (stream.match(/f|t|all-keys|include|key|next|rest/i)) {
220 return "atom";
221 } else {
210222 stream.eatWhile(/[-a-zA-Z]/);
211 return "keyword";
212 }
223 return "error";
224 }
225 } else if (ch == "~") {
226 stream.next();
227 ch = stream.peek();
228 if (ch == "=") {
229 stream.next();
230 ch = stream.peek();
231 if (ch == "=") {
232 stream.next();
233 return "operator";
234 }
235 return "operator";
236 }
237 return "operator";
238 } else if (ch == ":") {
239 stream.next();
240 ch = stream.peek();
241 if (ch == "=") {
242 stream.next();
243 return "operator";
244 } else if (ch == ":") {
245 stream.next();
246 return "punctuation";
247 }
248 } else if ("[](){}".indexOf(ch) != -1) {
249 stream.next();
250 return "bracket";
251 } else if (".,".indexOf(ch) != -1) {
252 stream.next();
253 return "punctuation";
213254 } else if (stream.match("end")) {
214255 return "keyword";
215256 }
221262 })) || stream.match(pattern))
222263 return patternStyles[name];
223264 }
265 }
266 if (/[+\-*\/^=<>&|]/.test(ch)) {
267 stream.next();
268 return "operator";
224269 }
225270 if (stream.match("define")) {
226271 return "def";
239284 }
240285
241286 function tokenComment(stream, state) {
242 var maybeEnd = false,
243 ch;
287 var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
244288 while ((ch = stream.next())) {
245289 if (ch == "/" && maybeEnd) {
246 state.tokenize = tokenBase;
247 break;
290 if (nestedCount > 0) {
291 nestedCount--;
292 } else {
293 state.tokenize = tokenBase;
294 break;
295 }
296 } else if (ch == "*" && maybeNested) {
297 nestedCount++;
248298 }
249299 maybeEnd = (ch == "*");
300 maybeNested = (ch == "/");
250301 }
251302 return "comment";
252303 }
253304
254305 function tokenString(quote, style) {
255306 return function(stream, state) {
256 var next, end = false;
307 var escaped = false, next, end = false;
257308 while ((next = stream.next()) != null) {
258 if (next == quote) {
309 if (next == quote && !escaped) {
259310 end = true;
260311 break;
261312 }
262 }
263 if (end)
313 escaped = !escaped && next == "\\";
314 }
315 if (end || !escaped) {
264316 state.tokenize = tokenBase;
317 }
265318 return style;
266319 };
267320 }
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 var mode = CodeMirror.getMode({indentUnit: 2}, "dylan");
5 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
6
7 MT('comments',
8 '[comment // This is a line comment]',
9 '[comment /* This is a block comment */]',
10 '[comment /* This is a multi]',
11 '[comment line comment]',
12 '[comment */]',
13 '[comment /* And this is a /*]',
14 '[comment /* nested */ comment */]');
15
16 MT('unary_operators',
17 '[operator -][variable a]',
18 '[operator -] [variable a]',
19 '[operator ~][variable a]',
20 '[operator ~] [variable a]');
21
22 MT('binary_operators',
23 '[variable a] [operator +] [variable b]',
24 '[variable a] [operator -] [variable b]',
25 '[variable a] [operator *] [variable b]',
26 '[variable a] [operator /] [variable b]',
27 '[variable a] [operator ^] [variable b]',
28 '[variable a] [operator =] [variable b]',
29 '[variable a] [operator ==] [variable b]',
30 '[variable a] [operator ~=] [variable b]',
31 '[variable a] [operator ~==] [variable b]',
32 '[variable a] [operator <] [variable b]',
33 '[variable a] [operator <=] [variable b]',
34 '[variable a] [operator >] [variable b]',
35 '[variable a] [operator >=] [variable b]',
36 '[variable a] [operator &] [variable b]',
37 '[variable a] [operator |] [variable b]',
38 '[variable a] [operator :=] [variable b]');
39
40 MT('integers',
41 '[number 1]',
42 '[number 123]',
43 '[number -123]',
44 '[number +456]',
45 '[number #b010]',
46 '[number #o073]',
47 '[number #xabcDEF123]');
48
49 MT('floats',
50 '[number .3]',
51 '[number -1.]',
52 '[number -2.335]',
53 '[number +3.78d1]',
54 '[number 3.78s-1]',
55 '[number -3.32e+5]');
56
57 MT('characters_and_strings',
58 "[string 'a']",
59 "[string '\\\\'']",
60 '[string ""]',
61 '[string "a"]',
62 '[string "abc def"]',
63 '[string "More escaped characters: \\\\\\\\ \\\\a \\\\b \\\\e \\\\f \\\\n \\\\r \\\\t \\\\0 ..."]');
64
65 MT('brackets',
66 '[bracket #[[]]]',
67 '[bracket #()]',
68 '[bracket #(][number 1][bracket )]',
69 '[bracket [[][number 1][punctuation ,] [number 3][bracket ]]]',
70 '[bracket ()]',
71 '[bracket {}]',
72 '[keyword if] [bracket (][variable foo][bracket )]',
73 '[bracket (][number 1][bracket )]',
74 '[bracket [[][number 1][bracket ]]]');
75
76 MT('hash_words',
77 '[punctuation ##]',
78 '[atom #f]', '[atom #F]',
79 '[atom #t]', '[atom #T]',
80 '[atom #all-keys]',
81 '[atom #include]',
82 '[atom #key]',
83 '[atom #next]',
84 '[atom #rest]',
85 '[string #"foo"]',
86 '[error #invalid]');
87 })();
9393
9494 if (bracesMode !== null && (state.braced || peek === "{")) {
9595 if (state.localState === null)
96 state.localState = bracesMode.startState();
96 state.localState = CodeMirror.startState(bracesMode);
9797
9898 var token = bracesMode.token(stream, state.localState),
9999 text = stream.current();
201201 });
202202
203203 CodeMirror.defineMIME("text/x-elm", "elm");
204 })();
204 });
219219 }else{
220220 return rval(state,stream,"function");
221221 }
222 }else if (is_member(w,operatorAtomWords)) {
223 return rval(state,stream,"operator");
224222 }else if (lookahead(stream) == ":") {
225223 if (w == "erlang") {
226224 return rval(state,stream,"builtin");
227225 } else {
228226 return rval(state,stream,"function");
229227 }
230 }else if (is_member(w,["true","false"])) {
231 return rval(state,stream,"boolean");
232228 }else if (is_member(w,["true","false"])) {
233229 return rval(state,stream,"boolean");
234230 }else{
436432 }
437433
438434 function maybe_drop_post(s) {
435 if (!s.length) return s
439436 var last = s.length-1;
440437
441438 if (s[last].type === "dot") {
442439 return [];
443440 }
444 if (s[last].type === "fun" && s[last-1].token === "fun") {
441 if (last > 1 && s[last].type === "fun" && s[last-1].token === "fun") {
445442 return s.slice(0,last-1);
446443 }
447 switch (s[s.length-1].token) {
444 switch (s[last].token) {
448445 case "}": return d(s,{g:["{"]});
449446 case "]": return d(s,{i:["["]});
450447 case ")": return d(s,{i:["("]});
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 CodeMirror.defineMode("fcl", function(config) {
14 var indentUnit = config.indentUnit;
15
16 var keywords = {
17 "term": true,
18 "method": true, "accu": true,
19 "rule": true, "then": true, "is": true, "and": true, "or": true,
20 "if": true, "default": true
21 };
22
23 var start_blocks = {
24 "var_input": true,
25 "var_output": true,
26 "fuzzify": true,
27 "defuzzify": true,
28 "function_block": true,
29 "ruleblock": true
30 };
31
32 var end_blocks = {
33 "end_ruleblock": true,
34 "end_defuzzify": true,
35 "end_function_block": true,
36 "end_fuzzify": true,
37 "end_var": true
38 };
39
40 var atoms = {
41 "true": true, "false": true, "nan": true,
42 "real": true, "min": true, "max": true, "cog": true, "cogs": true
43 };
44
45 var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
46
47 function tokenBase(stream, state) {
48 var ch = stream.next();
49
50 if (/[\d\.]/.test(ch)) {
51 if (ch == ".") {
52 stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
53 } else if (ch == "0") {
54 stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
55 } else {
56 stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
57 }
58 return "number";
59 }
60
61 if (ch == "/" || ch == "(") {
62 if (stream.eat("*")) {
63 state.tokenize = tokenComment;
64 return tokenComment(stream, state);
65 }
66 if (stream.eat("/")) {
67 stream.skipToEnd();
68 return "comment";
69 }
70 }
71 if (isOperatorChar.test(ch)) {
72 stream.eatWhile(isOperatorChar);
73 return "operator";
74 }
75 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
76
77 var cur = stream.current().toLowerCase();
78 if (keywords.propertyIsEnumerable(cur) ||
79 start_blocks.propertyIsEnumerable(cur) ||
80 end_blocks.propertyIsEnumerable(cur)) {
81 return "keyword";
82 }
83 if (atoms.propertyIsEnumerable(cur)) return "atom";
84 return "variable";
85 }
86
87
88 function tokenComment(stream, state) {
89 var maybeEnd = false, ch;
90 while (ch = stream.next()) {
91 if ((ch == "/" || ch == ")") && maybeEnd) {
92 state.tokenize = tokenBase;
93 break;
94 }
95 maybeEnd = (ch == "*");
96 }
97 return "comment";
98 }
99
100 function Context(indented, column, type, align, prev) {
101 this.indented = indented;
102 this.column = column;
103 this.type = type;
104 this.align = align;
105 this.prev = prev;
106 }
107
108 function pushContext(state, col, type) {
109 return state.context = new Context(state.indented, col, type, null, state.context);
110 }
111
112 function popContext(state) {
113 if (!state.context.prev) return;
114 var t = state.context.type;
115 if (t == "end_block")
116 state.indented = state.context.indented;
117 return state.context = state.context.prev;
118 }
119
120 // Interface
121
122 return {
123 startState: function(basecolumn) {
124 return {
125 tokenize: null,
126 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
127 indented: 0,
128 startOfLine: true
129 };
130 },
131
132 token: function(stream, state) {
133 var ctx = state.context;
134 if (stream.sol()) {
135 if (ctx.align == null) ctx.align = false;
136 state.indented = stream.indentation();
137 state.startOfLine = true;
138 }
139 if (stream.eatSpace()) return null;
140
141 var style = (state.tokenize || tokenBase)(stream, state);
142 if (style == "comment") return style;
143 if (ctx.align == null) ctx.align = true;
144
145 var cur = stream.current().toLowerCase();
146
147 if (start_blocks.propertyIsEnumerable(cur)) pushContext(state, stream.column(), "end_block");
148 else if (end_blocks.propertyIsEnumerable(cur)) popContext(state);
149
150 state.startOfLine = false;
151 return style;
152 },
153
154 indent: function(state, textAfter) {
155 if (state.tokenize != tokenBase && state.tokenize != null) return 0;
156 var ctx = state.context;
157
158 var closing = end_blocks.propertyIsEnumerable(textAfter);
159 if (ctx.align) return ctx.column + (closing ? 0 : 1);
160 else return ctx.indented + (closing ? 0 : indentUnit);
161 },
162
163 electricChars: "ryk",
164 fold: "brace",
165 blockCommentStart: "(*",
166 blockCommentEnd: "*)",
167 lineComment: "//"
168 };
169 });
170
171 CodeMirror.defineMIME("text/x-fcl", "fcl");
172 });
0 <!doctype html>
1
2 <title>CodeMirror: FCL mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <link rel="stylesheet" href="../../theme/elegant.css">
8 <script src="../../lib/codemirror.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
10 <script src="fcl.js"></script>
11 <style>.CodeMirror {border:1px solid #999; background:#ffc}</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="#">FCL</a>
23 </ul>
24 </div>
25
26 <article>
27 <h2>FCL mode</h2>
28 <form><textarea id="code" name="code">
29 FUNCTION_BLOCK Fuzzy_FB
30 VAR_INPUT
31 TimeDay : REAL; (* RANGE(0 .. 23) *)
32 ApplicateHost: REAL;
33 TimeConfiguration: REAL;
34 TimeRequirements: REAL;
35 END_VAR
36
37 VAR_OUTPUT
38 ProbabilityDistribution: REAL;
39 ProbabilityAccess: REAL;
40 END_VAR
41
42 FUZZIFY TimeDay
43 TERM inside := (0, 0) (8, 1) (22,0);
44 TERM outside := (0, 1) (8, 0) (22, 1);
45 END_FUZZIFY
46
47 FUZZIFY ApplicateHost
48 TERM few := (0, 1) (100, 0) (200, 0);
49 TERM many := (0, 0) (100, 0) (200, 1);
50 END_FUZZIFY
51
52 FUZZIFY TimeConfiguration
53 TERM recently := (0, 1) (30, 1) (120, 0);
54 TERM long := (0, 0) (30, 0) (120, 1);
55 END_FUZZIFY
56
57 FUZZIFY TimeRequirements
58 TERM recently := (0, 1) (30, 1) (365, 0);
59 TERM long := (0, 0) (30, 0) (365, 1);
60 END_FUZZIFY
61
62 DEFUZZIFY ProbabilityAccess
63 TERM hight := 1;
64 TERM medium := 0.5;
65 TERM low := 0;
66 ACCU: MAX;
67 METHOD: COGS;
68 DEFAULT := 0;
69 END_DEFUZZIFY
70
71 DEFUZZIFY ProbabilityDistribution
72 TERM hight := 1;
73 TERM medium := 0.5;
74 TERM low := 0;
75 ACCU: MAX;
76 METHOD: COGS;
77 DEFAULT := 0;
78 END_DEFUZZIFY
79
80 RULEBLOCK No1
81 AND : MIN;
82 RULE 1 : IF TimeDay IS outside AND ApplicateHost IS few THEN ProbabilityAccess IS hight;
83 RULE 2 : IF ApplicateHost IS many THEN ProbabilityAccess IS hight;
84 RULE 3 : IF TimeDay IS inside AND ApplicateHost IS few THEN ProbabilityAccess IS low;
85 END_RULEBLOCK
86
87 RULEBLOCK No2
88 AND : MIN;
89 RULE 1 : IF ApplicateHost IS many THEN ProbabilityDistribution IS hight;
90 END_RULEBLOCK
91
92 END_FUNCTION_BLOCK
93 </textarea></form>
94
95 <script>
96 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
97 theme: "elegant",
98 matchBrackets: true,
99 indentUnit: 8,
100 tabSize: 8,
101 indentWithTabs: true,
102 mode: "text/x-fcl"
103 });
104 </script>
105
106 <p><strong>MIME type:</strong> <code>text/x-fcl</code></p>
107 </article>
7676 });
7777 </script>
7878
79 <p><strong>MIME types defined:</strong> <code>text/x-Fortran</code>.</p>
79 <p><strong>MIME types defined:</strong> <code>text/x-fortran</code>.</p>
8080 </article>
99 mod(CodeMirror);
1010 })(function(CodeMirror) {
1111 "use strict";
12
13 var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
1214
1315 CodeMirror.defineMode("gfm", function(config, modeConfig) {
1416 var codeDepth = 0;
3638
3739 // Hack to prevent formatting override inside code blocks (block and inline)
3840 if (state.codeBlock) {
39 if (stream.match(/^```/)) {
41 if (stream.match(/^```+/)) {
4042 state.codeBlock = false;
4143 return null;
4244 }
4648 if (stream.sol()) {
4749 state.code = false;
4850 }
49 if (stream.sol() && stream.match(/^```/)) {
51 if (stream.sol() && stream.match(/^```+/)) {
5052 stream.skipToEnd();
5153 state.codeBlock = true;
5254 return null;
7779 }
7880 if (stream.sol() || state.ateSpace) {
7981 state.ateSpace = false;
80 if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
81 // User/Project@SHA
82 // User@SHA
83 // SHA
84 state.combineTokens = true;
85 return "link";
86 } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
87 // User/Project#Num
88 // User#Num
89 // #Num
90 state.combineTokens = true;
91 return "link";
82 if (modeConfig.gitHubSpice !== false) {
83 if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
84 // User/Project@SHA
85 // User@SHA
86 // SHA
87 state.combineTokens = true;
88 return "link";
89 } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
90 // User/Project#Num
91 // User#Num
92 // #Num
93 state.combineTokens = true;
94 return "link";
95 }
9296 }
9397 }
94 if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i) &&
95 stream.string.slice(stream.start - 2, stream.start) != "](") {
98 if (stream.match(urlRE) &&
99 stream.string.slice(stream.start - 2, stream.start) != "](" &&
100 (stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
96101 // URLs
97102 // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
98103 // And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
104 // And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
99105 state.combineTokens = true;
100106 return "link";
101107 }
108114 var markdownConfig = {
109115 underscoresBreakWords: false,
110116 taskLists: true,
111 fencedCodeBlocks: true,
117 fencedCodeBlocks: '```',
112118 strikethrough: true
113119 };
114120 for (var attr in modeConfig) {
115121 markdownConfig[attr] = modeConfig[attr];
116122 }
117123 markdownConfig.name = "markdown";
118 CodeMirror.defineMIME("gfmBase", markdownConfig);
119 return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
124 return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
125
120126 }, "markdown");
121127
128 CodeMirror.defineMIME("text/x-gfm", "gfm");
122129 });
4646 GFM adds syntax to strikethrough text, which is missing from standard Markdown.
4747
4848 ~~Mistaken text.~~
49 ~~**works with other fomatting**~~
49 ~~**works with other formatting**~~
5050
5151 ~~spans across
5252 lines~~
4949 "",
5050 "[comment ```]",
5151 "bar");
52
53 MT("fencedCodeBlockModeSwitchingObjc",
54 "[comment ```objective-c]",
55 "[keyword @property] [variable NSString] [operator *] [variable foo];",
56 "[comment ```]",
57 "bar");
58
59 MT("fencedCodeBlocksNoTildes",
60 "~~~",
61 "foo",
62 "~~~");
5263
5364 MT("taskListAsterisk",
5465 "[variable-2 * []] foo]", // Invalid; must have space or x between []
132143 MT("vanillaLink",
133144 "foo [link http://www.example.com/] bar");
134145
146 MT("vanillaLinkNoScheme",
147 "foo [link www.example.com] bar");
148
149 MT("vanillaLinkHttps",
150 "foo [link https://www.example.com/] bar");
151
152 MT("vanillaLinkDataSchema",
153 "foo [link data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==] bar");
154
135155 MT("vanillaLinkPunctuation",
136156 "foo [link http://www.example.com/]. bar");
137157
140160
141161 MT("vanillaLinkEmphasis",
142162 "foo [em *][em&link http://www.example.com/index.html][em *] bar");
163
164 MT("notALink",
165 "foo asfd:asdf bar");
143166
144167 MT("notALink",
145168 "[comment ```css]",
151174
152175 MT("notALink",
153176 "[comment `foo]",
154 "[link http://www.example.com/]",
155 "[comment `foo]",
177 "[comment&link http://www.example.com/]",
178 "[comment `] foo",
156179 "",
157180 "[link http://www.example.com/]");
158181
2222 "bool":true, "byte":true, "complex64":true, "complex128":true,
2323 "float32":true, "float64":true, "int8":true, "int16":true, "int32":true,
2424 "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true,
25 "uint64":true, "int":true, "uint":true, "uintptr":true
25 "uint64":true, "int":true, "uint":true, "uintptr":true, "error": true
2626 };
2727
2828 var atoms = {
8585 var escaped = false, next, end = false;
8686 while ((next = stream.next()) != null) {
8787 if (next == quote && !escaped) {end = true; break;}
88 escaped = !escaped && next == "\\";
88 escaped = !escaped && quote != "`" && next == "\\";
8989 }
9090 if (end || !(escaped || quote == "`"))
9191 state.tokenize = tokenBase;
1010 })(function(CodeMirror) {
1111 "use strict";
1212
13 // full haml mode. This handled embeded ruby and html fragments too
13 // full haml mode. This handled embedded ruby and html fragments too
1414 CodeMirror.defineMode("haml", function(config) {
1515 var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"});
1616 var rubyMode = CodeMirror.getMode(config, "ruby");
8484 state.tokenize = rubyInQuote(")");
8585 return state.tokenize(stream, state);
8686 } else if (ch == "{") {
87 state.tokenize = rubyInQuote("}");
88 return state.tokenize(stream, state);
87 if (!stream.match(/^\{%.*/)) {
88 state.tokenize = rubyInQuote("}");
89 return state.tokenize(stream, state);
90 }
8991 }
9092 }
9193
9597 return {
9698 // default to html mode
9799 startState: function() {
98 var htmlState = htmlMode.startState();
99 var rubyState = rubyMode.startState();
100 var htmlState = CodeMirror.startState(htmlMode);
101 var rubyState = CodeMirror.startState(rubyMode);
100102 return {
101103 htmlState: htmlState,
102104 rubyState: rubyState,
22
33 (function(mod) {
44 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
5 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"), require("../../addon/mode/multiplex"));
66 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
7 define(["../../lib/codemirror", "../../addon/mode/simple", "../../addon/mode/multiplex"], mod);
88 else // Plain browser env
99 mod(CodeMirror);
1010 })(function(CodeMirror) {
1111 "use strict";
1212
13 CodeMirror.defineSimpleMode("handlebars", {
13 CodeMirror.defineSimpleMode("handlebars-tags", {
1414 start: [
1515 { regex: /\{\{!--/, push: "dash_comment", token: "comment" },
1616 { regex: /\{\{!/, push: "comment", token: "comment" },
2020 { regex: /\}\}/, pop: true, token: "tag" },
2121
2222 // Double and single quotes
23 { regex: /"(?:[^\\]|\\.)*?"/, token: "string" },
24 { regex: /'(?:[^\\]|\\.)*?'/, token: "string" },
23 { regex: /"(?:[^\\"]|\\.)*"?/, token: "string" },
24 { regex: /'(?:[^\\']|\\.)*'?/, token: "string" },
2525
2626 // Handlebars keywords
2727 { regex: />|[#\/]([A-Za-z_]\w*)/, token: "keyword" },
4848 ]
4949 });
5050
51 CodeMirror.defineMode("handlebars", function(config, parserConfig) {
52 var handlebars = CodeMirror.getMode(config, "handlebars-tags");
53 if (!parserConfig || !parserConfig.base) return handlebars;
54 return CodeMirror.multiplexingMode(
55 CodeMirror.getMode(config, parserConfig.base),
56 {open: "{{", close: "}}", mode: handlebars, parseDelimiters: true}
57 );
58 });
59
5160 CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");
5261 });
6060
6161 </textarea></form>
6262 <script>
63 CodeMirror.defineMode("htmlhandlebars", function(config) {
64 return CodeMirror.multiplexingMode(
65 CodeMirror.getMode(config, "text/html"),
66 {open: "{{", close: "}}",
67 mode: CodeMirror.getMode(config, "handlebars"),
68 parseDelimiters: true});
69 });
70
7163 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
7264 lineNumbers: true,
7365 matchBrackets: true,
74 mode: "htmlhandlebars"
66 mode: {name: "handlebars", base: "text/html"}
7567 });
7668 </script>
77 </script>
78
69
7970 <p>Handlebars syntax highlighting for CodeMirror.</p>
8071
8172 <p><strong>MIME types defined:</strong> <code>text/x-handlebars-template</code></p>
73
74 <p>Supported options: <code>base</code> to set the mode to
75 wrap. For example, use</p>
76 <pre>mode: {name: "handlebars", base: "text/html"}</pre>
77 <p>to highlight an HTML template.</p>
8278 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function (mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"), require("../haskell/haskell"))
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror", "../haskell/haskell"], mod)
8 else // Plain browser env
9 mod(CodeMirror)
10 })(function (CodeMirror) {
11 "use strict"
12
13 CodeMirror.defineMode("haskell-literate", function (config, parserConfig) {
14 var baseMode = CodeMirror.getMode(config, (parserConfig && parserConfig.base) || "haskell")
15
16 return {
17 startState: function () {
18 return {
19 inCode: false,
20 baseState: CodeMirror.startState(baseMode)
21 }
22 },
23 token: function (stream, state) {
24 if (stream.sol()) {
25 if (state.inCode = stream.eat(">"))
26 return "meta"
27 }
28 if (state.inCode) {
29 return baseMode.token(stream, state.baseState)
30 } else {
31 stream.skipToEnd()
32 return "comment"
33 }
34 },
35 innerMode: function (state) {
36 return state.inCode ? {state: state.baseState, mode: baseMode} : null
37 }
38 }
39 }, "haskell")
40
41 CodeMirror.defineMIME("text/x-literate-haskell", "haskell-literate")
42 });
0 <!doctype html>
1
2 <title>CodeMirror: Haskell-literate mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="haskell-literate.js"></script>
9 <script src="../haskell/haskell.js"></script>
10 <style>.CodeMirror {
11 border-top : 1px solid #DDDDDD;
12 border-bottom : 1px solid #DDDDDD;
13 }</style>
14 <div id=nav>
15 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo
16 src="../../doc/logo.png"></a>
17
18 <ul>
19 <li><a href="../../index.html">Home</a>
20 <li><a href="../../doc/manual.html">Manual</a>
21 <li><a href="https://github.com/codemirror/codemirror">Code</a>
22 </ul>
23 <ul>
24 <li><a href="../index.html">Language modes</a>
25 <li><a class=active href="#">Haskell-literate</a>
26 </ul>
27 </div>
28
29 <article>
30 <h2>Haskell literate mode</h2>
31 <form>
32 <textarea id="code" name="code">
33 > {-# LANGUAGE OverloadedStrings #-}
34 > {-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
35 > import Control.Applicative ((<$>), (<*>))
36 > import Data.Maybe (isJust)
37
38 > import Data.Text (Text)
39 > import Text.Blaze ((!))
40 > import qualified Data.Text as T
41 > import qualified Happstack.Server as Happstack
42 > import qualified Text.Blaze.Html5 as H
43 > import qualified Text.Blaze.Html5.Attributes as A
44
45 > import Text.Digestive
46 > import Text.Digestive.Blaze.Html5
47 > import Text.Digestive.Happstack
48 > import Text.Digestive.Util
49
50 Simple forms and validation
51 ---------------------------
52
53 Let's start by creating a very simple datatype to represent a user:
54
55 > data User = User
56 > { userName :: Text
57 > , userMail :: Text
58 > } deriving (Show)
59
60 And dive in immediately to create a `Form` for a user. The `Form v m a` type
61 has three parameters:
62
63 - `v`: the type for messages and errors (usually a `String`-like type, `Text` in
64 this case);
65 - `m`: the monad we are operating in, not specified here;
66 - `a`: the return type of the `Form`, in this case, this is obviously `User`.
67
68 > userForm :: Monad m => Form Text m User
69
70 We create forms by using the `Applicative` interface. A few form types are
71 provided in the `Text.Digestive.Form` module, such as `text`, `string`,
72 `bool`...
73
74 In the `digestive-functors` library, the developer is required to label each
75 field using the `.:` operator. This might look like a bit of a burden, but it
76 allows you to do some really useful stuff, like separating the `Form` from the
77 actual HTML layout.
78
79 > userForm = User
80 > <$> "name" .: text Nothing
81 > <*> "mail" .: check "Not a valid email address" checkEmail (text Nothing)
82
83 The `check` function enables you to validate the result of a form. For example,
84 we can validate the email address with a really naive `checkEmail` function.
85
86 > checkEmail :: Text -> Bool
87 > checkEmail = isJust . T.find (== '@')
88
89 More validation
90 ---------------
91
92 For our example, we also want descriptions of Haskell libraries, and in order to
93 do that, we need package versions...
94
95 > type Version = [Int]
96
97 We want to let the user input a version number such as `0.1.0.0`. This means we
98 need to validate if the input `Text` is of this form, and then we need to parse
99 it to a `Version` type. Fortunately, we can do this in a single function:
100 `validate` allows conversion between values, which can optionally fail.
101
102 `readMaybe :: Read a => String -> Maybe a` is a utility function imported from
103 `Text.Digestive.Util`.
104
105 > validateVersion :: Text -> Result Text Version
106 > validateVersion = maybe (Error "Cannot parse version") Success .
107 > mapM (readMaybe . T.unpack) . T.split (== '.')
108
109 A quick test in GHCi:
110
111 ghci> validateVersion (T.pack "0.3.2.1")
112 Success [0,3,2,1]
113 ghci> validateVersion (T.pack "0.oops")
114 Error "Cannot parse version"
115
116 It works! This means we can now easily add a `Package` type and a `Form` for it:
117
118 > data Category = Web | Text | Math
119 > deriving (Bounded, Enum, Eq, Show)
120
121 > data Package = Package Text Version Category
122 > deriving (Show)
123
124 > packageForm :: Monad m => Form Text m Package
125 > packageForm = Package
126 > <$> "name" .: text Nothing
127 > <*> "version" .: validate validateVersion (text (Just "0.0.0.1"))
128 > <*> "category" .: choice categories Nothing
129 > where
130 > categories = [(x, T.pack (show x)) | x <- [minBound .. maxBound]]
131
132 Composing forms
133 ---------------
134
135 A release has an author and a package. Let's use this to illustrate the
136 composability of the digestive-functors library: we can reuse the forms we have
137 written earlier on.
138
139 > data Release = Release User Package
140 > deriving (Show)
141
142 > releaseForm :: Monad m => Form Text m Release
143 > releaseForm = Release
144 > <$> "author" .: userForm
145 > <*> "package" .: packageForm
146
147 Views
148 -----
149
150 As mentioned before, one of the advantages of using digestive-functors is
151 separation of forms and their actual HTML layout. In order to do this, we have
152 another type, `View`.
153
154 We can get a `View` from a `Form` by supplying input. A `View` contains more
155 information than a `Form`, it has:
156
157 - the original form;
158 - the input given by the user;
159 - any errors that have occurred.
160
161 It is this view that we convert to HTML. For this tutorial, we use the
162 [blaze-html] library, and some helpers from the `digestive-functors-blaze`
163 library.
164
165 [blaze-html]: http://jaspervdj.be/blaze/
166
167 Let's write a view for the `User` form. As you can see, we here refer to the
168 different fields in the `userForm`. The `errorList` will generate a list of
169 errors for the `"mail"` field.
170
171 > userView :: View H.Html -> H.Html
172 > userView view = do
173 > label "name" view "Name: "
174 > inputText "name" view
175 > H.br
176 >
177 > errorList "mail" view
178 > label "mail" view "Email address: "
179 > inputText "mail" view
180 > H.br
181
182 Like forms, views are also composable: let's illustrate that by adding a view
183 for the `releaseForm`, in which we reuse `userView`. In order to do this, we
184 take only the parts relevant to the author from the view by using `subView`. We
185 can then pass the resulting view to our own `userView`.
186 We have no special view code for `Package`, so we can just add that to
187 `releaseView` as well. `childErrorList` will generate a list of errors for each
188 child of the specified form. In this case, this means a list of errors from
189 `"package.name"` and `"package.version"`. Note how we use `foo.bar` to refer to
190 nested forms.
191
192 > releaseView :: View H.Html -> H.Html
193 > releaseView view = do
194 > H.h2 "Author"
195 > userView $ subView "author" view
196 >
197 > H.h2 "Package"
198 > childErrorList "package" view
199 >
200 > label "package.name" view "Name: "
201 > inputText "package.name" view
202 > H.br
203 >
204 > label "package.version" view "Version: "
205 > inputText "package.version" view
206 > H.br
207 >
208 > label "package.category" view "Category: "
209 > inputSelect "package.category" view
210 > H.br
211
212 The attentive reader might have wondered what the type parameter for `View` is:
213 it is the `String`-like type used for e.g. error messages.
214 But wait! We have
215 releaseForm :: Monad m => Form Text m Release
216 releaseView :: View H.Html -> H.Html
217 ... doesn't this mean that we need a `View Text` rather than a `View Html`? The
218 answer is yes -- but having `View Html` allows us to write these views more
219 easily with the `digestive-functors-blaze` library. Fortunately, we will be able
220 to fix this using the `Functor` instance of `View`.
221 fmap :: Monad m => (v -> w) -> View v -> View w
222 A backend
223 ---------
224 To finish this tutorial, we need to be able to actually run this code. We need
225 an HTTP server for that, and we use [Happstack] for this tutorial. The
226 `digestive-functors-happstack` library gives about everything we need for this.
227 [Happstack]: http://happstack.com/
228
229 > site :: Happstack.ServerPart Happstack.Response
230 > site = do
231 > Happstack.decodeBody $ Happstack.defaultBodyPolicy "/tmp" 4096 4096 4096
232 > r <- runForm "test" releaseForm
233 > case r of
234 > (view, Nothing) -> do
235 > let view' = fmap H.toHtml view
236 > Happstack.ok $ Happstack.toResponse $
237 > template $
238 > form view' "/" $ do
239 > releaseView view'
240 > H.br
241 > inputSubmit "Submit"
242 > (_, Just release) -> Happstack.ok $ Happstack.toResponse $
243 > template $ do
244 > css
245 > H.h1 "Release received"
246 > H.p $ H.toHtml $ show release
247 >
248 > main :: IO ()
249 > main = Happstack.simpleHTTP Happstack.nullConf site
250
251 Utilities
252 ---------
253
254 > template :: H.Html -> H.Html
255 > template body = H.docTypeHtml $ do
256 > H.head $ do
257 > H.title "digestive-functors tutorial"
258 > css
259 > H.body body
260 > css :: H.Html
261 > css = H.style ! A.type_ "text/css" $ do
262 > "label {width: 130px; float: left; clear: both}"
263 > "ul.digestive-functors-error-list {"
264 > " color: red;"
265 > " list-style-type: none;"
266 > " padding-left: 0px;"
267 > "}"
268 </textarea>
269 </form>
270
271 <p><strong>MIME types
272 defined:</strong> <code>text/x-literate-haskell</code>.</p>
273
274 <p>Parser configuration parameters recognized: <code>base</code> to
275 set the base mode (defaults to <code>"haskell"</code>).</p>
276
277 <script>
278 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: "haskell-literate"});
279 </script>
280
281 </article>
1515
1616 // Tokenizer
1717
18 var keywords = function(){
19 function kw(type) {return {type: type, style: "keyword"};}
20 var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
21 var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
18 function kw(type) {return {type: type, style: "keyword"};}
19 var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
20 var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
2221 var type = kw("typedef");
23 return {
24 "if": A, "while": A, "else": B, "do": B, "try": B,
25 "return": C, "break": C, "continue": C, "new": C, "throw": C,
26 "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
22 var keywords = {
23 "if": A, "while": A, "else": B, "do": B, "try": B,
24 "return": C, "break": C, "continue": C, "new": C, "throw": C,
25 "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
2726 "public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"),
28 "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
29 "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
30 "in": operator, "never": kw("property_access"), "trace":kw("trace"),
27 "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
28 "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
29 "in": operator, "never": kw("property_access"), "trace":kw("trace"),
3130 "class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type,
32 "true": atom, "false": atom, "null": atom
33 };
34 }();
31 "true": atom, "false": atom, "null": atom
32 };
3533
3634 var isOperatorChar = /[+\-*&%=<>!?|]/;
3735
4038 return f(stream, state);
4139 }
4240
43 function nextUntilUnescaped(stream, end) {
41 function toUnescaped(stream, end) {
4442 var escaped = false, next;
4543 while ((next = stream.next()) != null) {
4644 if (next == end && !escaped)
47 return false;
45 return true;
4846 escaped = !escaped && next == "\\";
4947 }
50 return escaped;
5148 }
5249
5350 // Used as scratch variables to communicate multiple values without
6057
6158 function haxeTokenBase(stream, state) {
6259 var ch = stream.next();
63 if (ch == '"' || ch == "'")
60 if (ch == '"' || ch == "'") {
6461 return chain(stream, state, haxeTokenString(ch));
65 else if (/[\[\]{}\(\),;\:\.]/.test(ch))
62 } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
6663 return ret(ch);
67 else if (ch == "0" && stream.eat(/x/i)) {
64 } else if (ch == "0" && stream.eat(/x/i)) {
6865 stream.eatWhile(/[\da-f]/i);
6966 return ret("number", "number");
70 }
71 else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
72 stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
67 } else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
68 stream.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/);
7369 return ret("number", "number");
74 }
75 else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
76 nextUntilUnescaped(stream, "/");
70 } else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
71 toUnescaped(stream, "/");
7772 stream.eatWhile(/[gimsu]/);
7873 return ret("regexp", "string-2");
79 }
80 else if (ch == "/") {
74 } else if (ch == "/") {
8175 if (stream.eat("*")) {
8276 return chain(stream, state, haxeTokenComment);
83 }
84 else if (stream.eat("/")) {
77 } else if (stream.eat("/")) {
8578 stream.skipToEnd();
8679 return ret("comment", "comment");
87 }
88 else {
80 } else {
8981 stream.eatWhile(isOperatorChar);
9082 return ret("operator", null, stream.current());
9183 }
92 }
93 else if (ch == "#") {
84 } else if (ch == "#") {
9485 stream.skipToEnd();
9586 return ret("conditional", "meta");
96 }
97 else if (ch == "@") {
87 } else if (ch == "@") {
9888 stream.eat(/:/);
9989 stream.eatWhile(/[\w_]/);
10090 return ret ("metadata", "meta");
101 }
102 else if (isOperatorChar.test(ch)) {
91 } else if (isOperatorChar.test(ch)) {
10392 stream.eatWhile(isOperatorChar);
10493 return ret("operator", null, stream.current());
105 }
106 else {
107 var word;
108 if(/[A-Z]/.test(ch))
109 {
110 stream.eatWhile(/[\w_<>]/);
111 word = stream.current();
112 return ret("type", "variable-3", word);
113 }
114 else
115 {
94 } else {
95 var word;
96 if(/[A-Z]/.test(ch)) {
97 stream.eatWhile(/[\w_<>]/);
98 word = stream.current();
99 return ret("type", "variable-3", word);
100 } else {
116101 stream.eatWhile(/[\w_]/);
117102 var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
118103 return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
119104 ret("variable", "variable", word);
120 }
105 }
121106 }
122107 }
123108
124109 function haxeTokenString(quote) {
125110 return function(stream, state) {
126 if (!nextUntilUnescaped(stream, quote))
111 if (toUnescaped(stream, quote))
127112 state.tokenize = haxeTokenBase;
128113 return ret("string", "string");
129114 };
175160 cc.pop()();
176161 if (cx.marked) return cx.marked;
177162 if (type == "variable" && inScope(state, content)) return "variable-2";
178 if (type == "variable" && imported(state, content)) return "variable-3";
163 if (type == "variable" && imported(state, content)) return "variable-3";
179164 return style;
180165 }
181166 }
182167 }
183168
184 function imported(state, typename)
185 {
186 if (/[a-z]/.test(typename.charAt(0)))
187 return false;
188 var len = state.importedtypes.length;
189 for (var i = 0; i<len; i++)
190 if(state.importedtypes[i]==typename) return true;
191 }
192
169 function imported(state, typename) {
170 if (/[a-z]/.test(typename.charAt(0)))
171 return false;
172 var len = state.importedtypes.length;
173 for (var i = 0; i<len; i++)
174 if(state.importedtypes[i]==typename) return true;
175 }
193176
194177 function registerimport(importname) {
195 var state = cx.state;
196 for (var t = state.importedtypes; t; t = t.next)
197 if(t.name == importname) return;
198 state.importedtypes = { name: importname, next: state.importedtypes };
178 var state = cx.state;
179 for (var t = state.importedtypes; t; t = t.next)
180 if(t.name == importname) return;
181 state.importedtypes = { name: importname, next: state.importedtypes };
199182 }
200183 // Combinator utils
201184
206189 function cont() {
207190 pass.apply(null, arguments);
208191 return true;
192 }
193 function inList(name, list) {
194 for (var v = list; v; v = v.next)
195 if (v.name == name) return true;
196 return false;
209197 }
210198 function register(varname) {
211199 var state = cx.state;
212200 if (state.context) {
213201 cx.marked = "def";
214 for (var v = state.localVars; v; v = v.next)
215 if (v.name == varname) return;
202 if (inList(varname, state.localVars)) return;
216203 state.localVars = {name: varname, next: state.localVars};
204 } else if (state.globalVars) {
205 if (inList(varname, state.globalVars)) return;
206 state.globalVars = {name: varname, next: state.globalVars};
217207 }
218208 }
219209
228218 cx.state.localVars = cx.state.context.vars;
229219 cx.state.context = cx.state.context.prev;
230220 }
221 popcontext.lex = true;
231222 function pushlex(type, info) {
232223 var result = function() {
233224 var state = cx.state;
251242 if (type == wanted) return cont();
252243 else if (wanted == ";") return pass();
253244 else return cont(f);
254 };
245 }
255246 return f;
256247 }
257248
265256 if (type == "attribute") return cont(maybeattribute);
266257 if (type == "function") return cont(functiondef);
267258 if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
268 poplex, statement, poplex);
259 poplex, statement, poplex);
269260 if (type == "variable") return cont(pushlex("stat"), maybelabel);
270261 if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
271 block, poplex, poplex);
262 block, poplex, poplex);
272263 if (type == "case") return cont(expression, expect(":"));
273264 if (type == "default") return cont(expect(":"));
274265 if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
275 statement, poplex, popcontext);
266 statement, poplex, popcontext);
276267 if (type == "import") return cont(importdef, expect(";"));
277268 if (type == "typedef") return cont(typedef);
278269 return pass(pushlex("stat"), expression, expect(";"), poplex);
279270 }
280271 function expression(type) {
281272 if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
273 if (type == "type" ) return cont(maybeoperator);
282274 if (type == "function") return cont(functiondef);
283275 if (type == "keyword c") return cont(maybeexpression);
284276 if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
285277 if (type == "operator") return cont(expression);
286 if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
278 if (type == "[") return cont(pushlex("]"), commasep(maybeexpression, "]"), poplex, maybeoperator);
287279 if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
288280 return cont();
289281 }
317309 }
318310
319311 function importdef (type, value) {
320 if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
321 else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
312 if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
313 else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
322314 }
323315
324316 function typedef (type, value)
325317 {
326 if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
327 else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
318 if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
319 else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
328320 }
329321
330322 function maybelabel(type) {
362354 if (type == ",") return cont(vardef1);
363355 }
364356 function forspec1(type, value) {
365 if (type == "variable") {
366 register(value);
367 }
368 return cont(pushlex(")"), pushcontext, forin, expression, poplex, statement, popcontext);
357 if (type == "variable") {
358 register(value);
359 return cont(forin, expression)
360 } else {
361 return pass()
362 }
369363 }
370364 function forin(_type, value) {
371365 if (value == "in") return cont();
372366 }
373367 function functiondef(type, value) {
374 if (type == "variable") {register(value); return cont(functiondef);}
368 //function names starting with upper-case letters are recognised as types, so cludging them together here.
369 if (type == "variable" || type == "type") {register(value); return cont(functiondef);}
375370 if (value == "new") return cont(functiondef);
376371 if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, typeuse, statement, popcontext);
377372 }
391386 }
392387
393388 // Interface
394
395389 return {
396390 startState: function(basecolumn) {
397 var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
398 return {
391 var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
392 var state = {
399393 tokenize: haxeTokenBase,
400394 reAllowed: true,
401395 kwAllowed: true,
402396 cc: [],
403397 lexical: new HaxeLexical((basecolumn || 0) - indentUnit, 0, "block", false),
404398 localVars: parserConfig.localVars,
405 importedtypes: defaulttypes,
399 importedtypes: defaulttypes,
406400 context: parserConfig.localVars && {vars: parserConfig.localVars},
407401 indented: 0
408402 };
403 if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
404 state.globalVars = parserConfig.globalVars;
405 return state;
409406 },
410407
411408 token: function(stream, state) {
5050 });
5151 </script>
5252
53 <p>Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
54 JavaScript, CSS and XML.<br />Other dependancies include those of the scriping language chosen.</p>
53 <p>Mode for html embedded scripts like JSP and ASP.NET. Depends on multiplex and HtmlMixed which in turn depends on
54 JavaScript, CSS and XML.<br />Other dependencies include those of the scripting language chosen.</p>
5555
56 <p><strong>MIME types defined:</strong> <code>application/x-aspx</code> (ASP.NET),
57 <code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages)</p>
56 <p><strong>MIME types defined:</strong> <code>application/x-aspx</code> (ASP.NET),
57 <code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages)
58 and <code>application/x-erb</code></p>
5859 </article>
88 else // Plain browser env
99 mod(CodeMirror);
1010 })(function(CodeMirror) {
11 "use strict";
11 "use strict";
1212
13 CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
14 var htmlMode = CodeMirror.getMode(config, {name: "xml",
15 htmlMode: true,
16 multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
17 multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag});
18 var cssMode = CodeMirror.getMode(config, "css");
13 var defaultTags = {
14 script: [
15 ["lang", /(javascript|babel)/i, "javascript"],
16 ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, "javascript"],
17 ["type", /./, "text/plain"],
18 [null, null, "javascript"]
19 ],
20 style: [
21 ["lang", /^css$/i, "css"],
22 ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
23 ["type", /./, "text/plain"],
24 [null, null, "css"]
25 ]
26 };
1927
20 var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes;
21 scriptTypes.push({matches: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,
22 mode: CodeMirror.getMode(config, "javascript")});
23 if (scriptTypesConf) for (var i = 0; i < scriptTypesConf.length; ++i) {
24 var conf = scriptTypesConf[i];
25 scriptTypes.push({matches: conf.matches, mode: conf.mode && CodeMirror.getMode(config, conf.mode)});
26 }
27 scriptTypes.push({matches: /./,
28 mode: CodeMirror.getMode(config, "text/plain")});
29
30 function html(stream, state) {
31 var tagName = state.htmlState.tagName;
32 if (tagName) tagName = tagName.toLowerCase();
33 var style = htmlMode.token(stream, state.htmlState);
34 if (tagName == "script" && /\btag\b/.test(style) && stream.current() == ">") {
35 // Script block: mode to change to depends on type attribute
36 var scriptType = stream.string.slice(Math.max(0, stream.pos - 100), stream.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i);
37 scriptType = scriptType ? scriptType[1] : "";
38 if (scriptType && /[\"\']/.test(scriptType.charAt(0))) scriptType = scriptType.slice(1, scriptType.length - 1);
39 for (var i = 0; i < scriptTypes.length; ++i) {
40 var tp = scriptTypes[i];
41 if (typeof tp.matches == "string" ? scriptType == tp.matches : tp.matches.test(scriptType)) {
42 if (tp.mode) {
43 state.token = script;
44 state.localMode = tp.mode;
45 state.localState = tp.mode.startState && tp.mode.startState(htmlMode.indent(state.htmlState, ""));
46 }
47 break;
48 }
49 }
50 } else if (tagName == "style" && /\btag\b/.test(style) && stream.current() == ">") {
51 state.token = css;
52 state.localMode = cssMode;
53 state.localState = cssMode.startState(htmlMode.indent(state.htmlState, ""));
54 }
55 return style;
56 }
5728 function maybeBackup(stream, pat, style) {
58 var cur = stream.current();
59 var close = cur.search(pat);
60 if (close > -1) stream.backUp(cur.length - close);
61 else if (cur.match(/<\/?$/)) {
29 var cur = stream.current(), close = cur.search(pat);
30 if (close > -1) {
31 stream.backUp(cur.length - close);
32 } else if (cur.match(/<\/?$/)) {
6233 stream.backUp(cur.length);
6334 if (!stream.match(pat, false)) stream.match(cur);
6435 }
6536 return style;
6637 }
67 function script(stream, state) {
68 if (stream.match(/^<\/\s*script\s*>/i, false)) {
69 state.token = html;
70 state.localState = state.localMode = null;
71 return null;
72 }
73 return maybeBackup(stream, /<\/\s*script\s*>/,
74 state.localMode.token(stream, state.localState));
75 }
76 function css(stream, state) {
77 if (stream.match(/^<\/\s*style\s*>/i, false)) {
78 state.token = html;
79 state.localState = state.localMode = null;
80 return null;
81 }
82 return maybeBackup(stream, /<\/\s*style\s*>/,
83 cssMode.token(stream, state.localState));
38
39 var attrRegexpCache = {};
40 function getAttrRegexp(attr) {
41 var regexp = attrRegexpCache[attr];
42 if (regexp) return regexp;
43 return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
8444 }
8545
86 return {
87 startState: function() {
88 var state = htmlMode.startState();
89 return {token: html, localMode: null, localState: null, htmlState: state};
90 },
46 function getAttrValue(text, attr) {
47 var match = text.match(getAttrRegexp(attr))
48 return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
49 }
9150
92 copyState: function(state) {
93 if (state.localState)
94 var local = CodeMirror.copyState(state.localMode, state.localState);
95 return {token: state.token, localMode: state.localMode, localState: local,
96 htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
97 },
51 function getTagRegexp(tagName, anchored) {
52 return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
53 }
9854
99 token: function(stream, state) {
100 return state.token(stream, state);
101 },
55 function addTags(from, to) {
56 for (var tag in from) {
57 var dest = to[tag] || (to[tag] = []);
58 var source = from[tag];
59 for (var i = source.length - 1; i >= 0; i--)
60 dest.unshift(source[i])
61 }
62 }
10263
103 indent: function(state, textAfter) {
104 if (!state.localMode || /^\s*<\//.test(textAfter))
105 return htmlMode.indent(state.htmlState, textAfter);
106 else if (state.localMode.indent)
107 return state.localMode.indent(state.localState, textAfter);
108 else
109 return CodeMirror.Pass;
110 },
64 function findMatchingMode(tagInfo, tagText) {
65 for (var i = 0; i < tagInfo.length; i++) {
66 var spec = tagInfo[i];
67 if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
68 }
69 }
11170
112 innerMode: function(state) {
113 return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
114 }
115 };
116 }, "xml", "javascript", "css");
71 CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
72 var htmlMode = CodeMirror.getMode(config, {
73 name: "xml",
74 htmlMode: true,
75 multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
76 multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
77 });
11778
118 CodeMirror.defineMIME("text/html", "htmlmixed");
79 var tags = {};
80 var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
81 addTags(defaultTags, tags);
82 if (configTags) addTags(configTags, tags);
83 if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
84 tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
11985
86 function html(stream, state) {
87 var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName
88 if (tag && !/[<>\s\/]/.test(stream.current()) &&
89 (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) &&
90 tags.hasOwnProperty(tagName)) {
91 state.inTag = tagName + " "
92 } else if (state.inTag && tag && />$/.test(stream.current())) {
93 var inTag = /^([\S]+) (.*)/.exec(state.inTag)
94 state.inTag = null
95 var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])
96 var mode = CodeMirror.getMode(config, modeSpec)
97 var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
98 state.token = function (stream, state) {
99 if (stream.match(endTagA, false)) {
100 state.token = html;
101 state.localState = state.localMode = null;
102 return null;
103 }
104 return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
105 };
106 state.localMode = mode;
107 state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
108 } else if (state.inTag) {
109 state.inTag += stream.current()
110 if (stream.eol()) state.inTag += " "
111 }
112 return style;
113 };
114
115 return {
116 startState: function () {
117 var state = CodeMirror.startState(htmlMode);
118 return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
119 },
120
121 copyState: function (state) {
122 var local;
123 if (state.localState) {
124 local = CodeMirror.copyState(state.localMode, state.localState);
125 }
126 return {token: state.token, inTag: state.inTag,
127 localMode: state.localMode, localState: local,
128 htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
129 },
130
131 token: function (stream, state) {
132 return state.token(stream, state);
133 },
134
135 indent: function (state, textAfter) {
136 if (!state.localMode || /^\s*<\//.test(textAfter))
137 return htmlMode.indent(state.htmlState, textAfter);
138 else if (state.localMode.indent)
139 return state.localMode.indent(state.localState, textAfter);
140 else
141 return CodeMirror.Pass;
142 },
143
144 innerMode: function (state) {
145 return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
146 }
147 };
148 }, "xml", "javascript", "css");
149
150 CodeMirror.defineMIME("text/html", "htmlmixed");
120151 });
3232 <li><a href="apl/index.html">APL</a></li>
3333 <li><a href="asn.1/index.html">ASN.1</a></li>
3434 <li><a href="asterisk/index.html">Asterisk dialplan</a></li>
35 <li><a href="brainfuck/index.html">Brainfuck</a></li>
3536 <li><a href="clike/index.html">C, C++, C#</a></li>
37 <li><a href="clike/index.html">Ceylon</a></li>
3638 <li><a href="clojure/index.html">Clojure</a></li>
39 <li><a href="css/gss.html">Closure Stylesheets (GSS)</a></li>
3740 <li><a href="cmake/index.html">CMake</a></li>
3841 <li><a href="cobol/index.html">COBOL</a></li>
3942 <li><a href="coffeescript/index.html">CoffeeScript</a></li>
4043 <li><a href="commonlisp/index.html">Common Lisp</a></li>
44 <li><a href="crystal/index.html">Crystal</a></li>
4145 <li><a href="css/index.html">CSS</a></li>
4246 <li><a href="cypher/index.html">Cypher</a></li>
4347 <li><a href="python/index.html">Cython</a></li>
5458 <li><a href="elm/index.html">Elm</a></li>
5559 <li><a href="erlang/index.html">Erlang</a></li>
5660 <li><a href="factor/index.html">Factor</a></li>
61 <li><a href="fcl/index.html">FCL</a></li>
5762 <li><a href="forth/index.html">Forth</a></li>
5863 <li><a href="fortran/index.html">Fortran</a></li>
5964 <li><a href="mllike/index.html">F#</a></li>
6368 <li><a href="groovy/index.html">Groovy</a></li>
6469 <li><a href="haml/index.html">HAML</a></li>
6570 <li><a href="handlebars/index.html">Handlebars</a></li>
66 <li><a href="haskell/index.html">Haskell</a></li>
71 <li><a href="haskell/index.html">Haskell</a> (<a href="haskell-literate/index.html">Literate</a>)</li>
6772 <li><a href="haxe/index.html">Haxe</a></li>
6873 <li><a href="htmlembedded/index.html">HTML embedded</a> (JSP, ASP.NET)</li>
6974 <li><a href="htmlmixed/index.html">HTML mixed-mode</a></li>
7075 <li><a href="http/index.html">HTTP</a></li>
7176 <li><a href="idl/index.html">IDL</a></li>
7277 <li><a href="clike/index.html">Java</a></li>
73 <li><a href="jade/index.html">Jade</a></li>
74 <li><a href="javascript/index.html">JavaScript</a></li>
78 <li><a href="javascript/index.html">JavaScript</a> (<a href="jsx/index.html">JSX</a>)</li>
7579 <li><a href="jinja2/index.html">Jinja2</a></li>
7680 <li><a href="julia/index.html">Julia</a></li>
7781 <li><a href="kotlin/index.html">Kotlin</a></li>
8084 <li><a href="lua/index.html">Lua</a></li>
8185 <li><a href="markdown/index.html">Markdown</a> (<a href="gfm/index.html">GitHub-flavour</a>)</li>
8286 <li><a href="mathematica/index.html">Mathematica</a></li>
87 <li><a href="mbox/index.html">mbox</a></li>
8388 <li><a href="mirc/index.html">mIRC</a></li>
8489 <li><a href="modelica/index.html">Modelica</a></li>
90 <li><a href="mscgen/index.html">MscGen</a></li>
8591 <li><a href="mumps/index.html">MUMPS</a></li>
8692 <li><a href="nginx/index.html">Nginx</a></li>
93 <li><a href="nsis/index.html">NSIS</a></li>
8794 <li><a href="ntriples/index.html">NTriples</a></li>
8895 <li><a href="clike/index.html">Objective C</a></li>
8996 <li><a href="mllike/index.html">OCaml</a></li>
9097 <li><a href="octave/index.html">Octave</a> (MATLAB)</li>
98 <li><a href="oz/index.html">Oz</a></li>
9199 <li><a href="pascal/index.html">Pascal</a></li>
92100 <li><a href="pegjs/index.html">PEG.js</a></li>
93101 <li><a href="perl/index.html">Perl</a></li>
94102 <li><a href="asciiarmor/index.html">PGP (ASCII armor)</a></li>
95103 <li><a href="php/index.html">PHP</a></li>
96104 <li><a href="pig/index.html">Pig Latin</a></li>
105 <li><a href="powershell/index.html">PowerShell</a></li>
97106 <li><a href="properties/index.html">Properties files</a></li>
107 <li><a href="protobuf/index.html">ProtoBuf</a></li>
108 <li><a href="pug/index.html">Pug</a></li>
98109 <li><a href="puppet/index.html">Puppet</a></li>
99110 <li><a href="python/index.html">Python</a></li>
100111 <li><a href="q/index.html">Q</a></li>
103114 <li><a href="rst/index.html">reStructuredText</a></li>
104115 <li><a href="ruby/index.html">Ruby</a></li>
105116 <li><a href="rust/index.html">Rust</a></li>
117 <li><a href="sas/index.html">SAS</a></li>
106118 <li><a href="sass/index.html">Sass</a></li>
107119 <li><a href="spreadsheet/index.html">Spreadsheet</a></li>
108120 <li><a href="clike/scala.html">Scala</a></li>
118130 <li><a href="stylus/index.html">Stylus</a></li>
119131 <li><a href="sql/index.html">SQL</a> (several dialects)</li>
120132 <li><a href="sparql/index.html">SPARQL</a></li>
133 <li><a href="clike/index.html">Squirrel</a></li>
121134 <li><a href="swift/index.html">Swift</a></li>
122135 <li><a href="stex/index.html">sTeX, LaTeX</a></li>
123136 <li><a href="tcl/index.html">Tcl</a></li>
135148 <li><a href="vbscript/index.html">VBScript</a></li>
136149 <li><a href="velocity/index.html">Velocity</a></li>
137150 <li><a href="verilog/index.html">Verilog/SystemVerilog</a></li>
151 <li><a href="vhdl/index.html">VHDL</a></li>
152 <li><a href="vue/index.html">Vue.js app</a></li>
153 <li><a href="webidl/index.html">Web IDL</a></li>
138154 <li><a href="xml/index.html">XML/HTML</a></li>
139155 <li><a href="xquery/index.html">XQuery</a></li>
156 <li><a href="yacas/index.html">Yacas</a></li>
140157 <li><a href="yaml/index.html">YAML</a></li>
158 <li><a href="yaml-frontmatter/index.html">YAML frontmatter</a></li>
141159 <li><a href="z80/index.html">Z80</a></li>
142160 </ul>
143161 </div>
+0
-70
mode/jade/index.html less more
0 <!doctype html>
1
2 <title>CodeMirror: Jade Templating Mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../javascript/javascript.js"></script>
9 <script src="../css/css.js"></script>
10 <script src="../xml/xml.js"></script>
11 <script src="../htmlmixed/htmlmixed.js"></script>
12 <script src="jade.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="#">Jade Templating Mode</a>
25 </ul>
26 </div>
27
28 <article>
29 <h2>Jade Templating Mode</h2>
30 <form><textarea id="code" name="code">
31 doctype html
32 html
33 head
34 title= "Jade Templating CodeMirror Mode Example"
35 link(rel='stylesheet', href='/css/bootstrap.min.css')
36 link(rel='stylesheet', href='/css/index.css')
37 script(type='text/javascript', src='/js/jquery-1.9.1.min.js')
38 script(type='text/javascript', src='/js/bootstrap.min.js')
39 body
40 div.header
41 h1 Welcome to this Example
42 div.spots
43 if locals.spots
44 each spot in spots
45 div.spot.well
46 div
47 if spot.logo
48 img.img-rounded.logo(src=spot.logo)
49 else
50 img.img-rounded.logo(src="img/placeholder.png")
51 h3
52 a(href=spot.hash) ##{spot.hash}
53 if spot.title
54 span.title #{spot.title}
55 if spot.desc
56 div #{spot.desc}
57 else
58 h3 There are no spots currently available.
59 </textarea></form>
60 <script>
61 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
62 mode: {name: "jade", alignCDATA: true},
63 lineNumbers: true
64 });
65 </script>
66 <h3>The Jade Templating Mode</h3>
67 <p> Created by Forbes Lindesay. Managed as part of a Brackets extension at <a href="https://github.com/ForbesLindesay/jade-brackets">https://github.com/ForbesLindesay/jade-brackets</a>.</p>
68 <p><strong>MIME type defined:</strong> <code>text/x-jade</code>.</p>
69 </article>
+0
-590
mode/jade/jade.js less more
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"), require("../javascript/javascript"), require("../css/css"), require("../htmlmixed/htmlmixed"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror", "../javascript/javascript", "../css/css", "../htmlmixed/htmlmixed"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 CodeMirror.defineMode('jade', function (config) {
14 // token types
15 var KEYWORD = 'keyword';
16 var DOCTYPE = 'meta';
17 var ID = 'builtin';
18 var CLASS = 'qualifier';
19
20 var ATTRS_NEST = {
21 '{': '}',
22 '(': ')',
23 '[': ']'
24 };
25
26 var jsMode = CodeMirror.getMode(config, 'javascript');
27
28 function State() {
29 this.javaScriptLine = false;
30 this.javaScriptLineExcludesColon = false;
31
32 this.javaScriptArguments = false;
33 this.javaScriptArgumentsDepth = 0;
34
35 this.isInterpolating = false;
36 this.interpolationNesting = 0;
37
38 this.jsState = jsMode.startState();
39
40 this.restOfLine = '';
41
42 this.isIncludeFiltered = false;
43 this.isEach = false;
44
45 this.lastTag = '';
46 this.scriptType = '';
47
48 // Attributes Mode
49 this.isAttrs = false;
50 this.attrsNest = [];
51 this.inAttributeName = true;
52 this.attributeIsType = false;
53 this.attrValue = '';
54
55 // Indented Mode
56 this.indentOf = Infinity;
57 this.indentToken = '';
58
59 this.innerMode = null;
60 this.innerState = null;
61
62 this.innerModeForLine = false;
63 }
64 /**
65 * Safely copy a state
66 *
67 * @return {State}
68 */
69 State.prototype.copy = function () {
70 var res = new State();
71 res.javaScriptLine = this.javaScriptLine;
72 res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon;
73 res.javaScriptArguments = this.javaScriptArguments;
74 res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth;
75 res.isInterpolating = this.isInterpolating;
76 res.interpolationNesting = this.intpolationNesting;
77
78 res.jsState = CodeMirror.copyState(jsMode, this.jsState);
79
80 res.innerMode = this.innerMode;
81 if (this.innerMode && this.innerState) {
82 res.innerState = CodeMirror.copyState(this.innerMode, this.innerState);
83 }
84
85 res.restOfLine = this.restOfLine;
86
87 res.isIncludeFiltered = this.isIncludeFiltered;
88 res.isEach = this.isEach;
89 res.lastTag = this.lastTag;
90 res.scriptType = this.scriptType;
91 res.isAttrs = this.isAttrs;
92 res.attrsNest = this.attrsNest.slice();
93 res.inAttributeName = this.inAttributeName;
94 res.attributeIsType = this.attributeIsType;
95 res.attrValue = this.attrValue;
96 res.indentOf = this.indentOf;
97 res.indentToken = this.indentToken;
98
99 res.innerModeForLine = this.innerModeForLine;
100
101 return res;
102 };
103
104 function javaScript(stream, state) {
105 if (stream.sol()) {
106 // if javaScriptLine was set at end of line, ignore it
107 state.javaScriptLine = false;
108 state.javaScriptLineExcludesColon = false;
109 }
110 if (state.javaScriptLine) {
111 if (state.javaScriptLineExcludesColon && stream.peek() === ':') {
112 state.javaScriptLine = false;
113 state.javaScriptLineExcludesColon = false;
114 return;
115 }
116 var tok = jsMode.token(stream, state.jsState);
117 if (stream.eol()) state.javaScriptLine = false;
118 return tok || true;
119 }
120 }
121 function javaScriptArguments(stream, state) {
122 if (state.javaScriptArguments) {
123 if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== '(') {
124 state.javaScriptArguments = false;
125 return;
126 }
127 if (stream.peek() === '(') {
128 state.javaScriptArgumentsDepth++;
129 } else if (stream.peek() === ')') {
130 state.javaScriptArgumentsDepth--;
131 }
132 if (state.javaScriptArgumentsDepth === 0) {
133 state.javaScriptArguments = false;
134 return;
135 }
136
137 var tok = jsMode.token(stream, state.jsState);
138 return tok || true;
139 }
140 }
141
142 function yieldStatement(stream) {
143 if (stream.match(/^yield\b/)) {
144 return 'keyword';
145 }
146 }
147
148 function doctype(stream) {
149 if (stream.match(/^(?:doctype) *([^\n]+)?/)) {
150 return DOCTYPE;
151 }
152 }
153
154 function interpolation(stream, state) {
155 if (stream.match('#{')) {
156 state.isInterpolating = true;
157 state.interpolationNesting = 0;
158 return 'punctuation';
159 }
160 }
161
162 function interpolationContinued(stream, state) {
163 if (state.isInterpolating) {
164 if (stream.peek() === '}') {
165 state.interpolationNesting--;
166 if (state.interpolationNesting < 0) {
167 stream.next();
168 state.isInterpolating = false;
169 return 'puncutation';
170 }
171 } else if (stream.peek() === '{') {
172 state.interpolationNesting++;
173 }
174 return jsMode.token(stream, state.jsState) || true;
175 }
176 }
177
178 function caseStatement(stream, state) {
179 if (stream.match(/^case\b/)) {
180 state.javaScriptLine = true;
181 return KEYWORD;
182 }
183 }
184
185 function when(stream, state) {
186 if (stream.match(/^when\b/)) {
187 state.javaScriptLine = true;
188 state.javaScriptLineExcludesColon = true;
189 return KEYWORD;
190 }
191 }
192
193 function defaultStatement(stream) {
194 if (stream.match(/^default\b/)) {
195 return KEYWORD;
196 }
197 }
198
199 function extendsStatement(stream, state) {
200 if (stream.match(/^extends?\b/)) {
201 state.restOfLine = 'string';
202 return KEYWORD;
203 }
204 }
205
206 function append(stream, state) {
207 if (stream.match(/^append\b/)) {
208 state.restOfLine = 'variable';
209 return KEYWORD;
210 }
211 }
212 function prepend(stream, state) {
213 if (stream.match(/^prepend\b/)) {
214 state.restOfLine = 'variable';
215 return KEYWORD;
216 }
217 }
218 function block(stream, state) {
219 if (stream.match(/^block\b *(?:(prepend|append)\b)?/)) {
220 state.restOfLine = 'variable';
221 return KEYWORD;
222 }
223 }
224
225 function include(stream, state) {
226 if (stream.match(/^include\b/)) {
227 state.restOfLine = 'string';
228 return KEYWORD;
229 }
230 }
231
232 function includeFiltered(stream, state) {
233 if (stream.match(/^include:([a-zA-Z0-9\-]+)/, false) && stream.match('include')) {
234 state.isIncludeFiltered = true;
235 return KEYWORD;
236 }
237 }
238
239 function includeFilteredContinued(stream, state) {
240 if (state.isIncludeFiltered) {
241 var tok = filter(stream, state);
242 state.isIncludeFiltered = false;
243 state.restOfLine = 'string';
244 return tok;
245 }
246 }
247
248 function mixin(stream, state) {
249 if (stream.match(/^mixin\b/)) {
250 state.javaScriptLine = true;
251 return KEYWORD;
252 }
253 }
254
255 function call(stream, state) {
256 if (stream.match(/^\+([-\w]+)/)) {
257 if (!stream.match(/^\( *[-\w]+ *=/, false)) {
258 state.javaScriptArguments = true;
259 state.javaScriptArgumentsDepth = 0;
260 }
261 return 'variable';
262 }
263 if (stream.match(/^\+#{/, false)) {
264 stream.next();
265 state.mixinCallAfter = true;
266 return interpolation(stream, state);
267 }
268 }
269 function callArguments(stream, state) {
270 if (state.mixinCallAfter) {
271 state.mixinCallAfter = false;
272 if (!stream.match(/^\( *[-\w]+ *=/, false)) {
273 state.javaScriptArguments = true;
274 state.javaScriptArgumentsDepth = 0;
275 }
276 return true;
277 }
278 }
279
280 function conditional(stream, state) {
281 if (stream.match(/^(if|unless|else if|else)\b/)) {
282 state.javaScriptLine = true;
283 return KEYWORD;
284 }
285 }
286
287 function each(stream, state) {
288 if (stream.match(/^(- *)?(each|for)\b/)) {
289 state.isEach = true;
290 return KEYWORD;
291 }
292 }
293 function eachContinued(stream, state) {
294 if (state.isEach) {
295 if (stream.match(/^ in\b/)) {
296 state.javaScriptLine = true;
297 state.isEach = false;
298 return KEYWORD;
299 } else if (stream.sol() || stream.eol()) {
300 state.isEach = false;
301 } else if (stream.next()) {
302 while (!stream.match(/^ in\b/, false) && stream.next());
303 return 'variable';
304 }
305 }
306 }
307
308 function whileStatement(stream, state) {
309 if (stream.match(/^while\b/)) {
310 state.javaScriptLine = true;
311 return KEYWORD;
312 }
313 }
314
315 function tag(stream, state) {
316 var captures;
317 if (captures = stream.match(/^(\w(?:[-:\w]*\w)?)\/?/)) {
318 state.lastTag = captures[1].toLowerCase();
319 if (state.lastTag === 'script') {
320 state.scriptType = 'application/javascript';
321 }
322 return 'tag';
323 }
324 }
325
326 function filter(stream, state) {
327 if (stream.match(/^:([\w\-]+)/)) {
328 var innerMode;
329 if (config && config.innerModes) {
330 innerMode = config.innerModes(stream.current().substring(1));
331 }
332 if (!innerMode) {
333 innerMode = stream.current().substring(1);
334 }
335 if (typeof innerMode === 'string') {
336 innerMode = CodeMirror.getMode(config, innerMode);
337 }
338 setInnerMode(stream, state, innerMode);
339 return 'atom';
340 }
341 }
342
343 function code(stream, state) {
344 if (stream.match(/^(!?=|-)/)) {
345 state.javaScriptLine = true;
346 return 'punctuation';
347 }
348 }
349
350 function id(stream) {
351 if (stream.match(/^#([\w-]+)/)) {
352 return ID;
353 }
354 }
355
356 function className(stream) {
357 if (stream.match(/^\.([\w-]+)/)) {
358 return CLASS;
359 }
360 }
361
362 function attrs(stream, state) {
363 if (stream.peek() == '(') {
364 stream.next();
365 state.isAttrs = true;
366 state.attrsNest = [];
367 state.inAttributeName = true;
368 state.attrValue = '';
369 state.attributeIsType = false;
370 return 'punctuation';
371 }
372 }
373
374 function attrsContinued(stream, state) {
375 if (state.isAttrs) {
376 if (ATTRS_NEST[stream.peek()]) {
377 state.attrsNest.push(ATTRS_NEST[stream.peek()]);
378 }
379 if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) {
380 state.attrsNest.pop();
381 } else if (stream.eat(')')) {
382 state.isAttrs = false;
383 return 'punctuation';
384 }
385 if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) {
386 if (stream.peek() === '=' || stream.peek() === '!') {
387 state.inAttributeName = false;
388 state.jsState = jsMode.startState();
389 if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') {
390 state.attributeIsType = true;
391 } else {
392 state.attributeIsType = false;
393 }
394 }
395 return 'attribute';
396 }
397
398 var tok = jsMode.token(stream, state.jsState);
399 if (state.attributeIsType && tok === 'string') {
400 state.scriptType = stream.current().toString();
401 }
402 if (state.attrsNest.length === 0 && (tok === 'string' || tok === 'variable' || tok === 'keyword')) {
403 try {
404 Function('', 'var x ' + state.attrValue.replace(/,\s*$/, '').replace(/^!/, ''));
405 state.inAttributeName = true;
406 state.attrValue = '';
407 stream.backUp(stream.current().length);
408 return attrsContinued(stream, state);
409 } catch (ex) {
410 //not the end of an attribute
411 }
412 }
413 state.attrValue += stream.current();
414 return tok || true;
415 }
416 }
417
418 function attributesBlock(stream, state) {
419 if (stream.match(/^&attributes\b/)) {
420 state.javaScriptArguments = true;
421 state.javaScriptArgumentsDepth = 0;
422 return 'keyword';
423 }
424 }
425
426 function indent(stream) {
427 if (stream.sol() && stream.eatSpace()) {
428 return 'indent';
429 }
430 }
431
432 function comment(stream, state) {
433 if (stream.match(/^ *\/\/(-)?([^\n]*)/)) {
434 state.indentOf = stream.indentation();
435 state.indentToken = 'comment';
436 return 'comment';
437 }
438 }
439
440 function colon(stream) {
441 if (stream.match(/^: */)) {
442 return 'colon';
443 }
444 }
445
446 function text(stream, state) {
447 if (stream.match(/^(?:\| ?| )([^\n]+)/)) {
448 return 'string';
449 }
450 if (stream.match(/^(<[^\n]*)/, false)) {
451 // html string
452 setInnerMode(stream, state, 'htmlmixed');
453 state.innerModeForLine = true;
454 return innerMode(stream, state, true);
455 }
456 }
457
458 function dot(stream, state) {
459 if (stream.eat('.')) {
460 var innerMode = null;
461 if (state.lastTag === 'script' && state.scriptType.toLowerCase().indexOf('javascript') != -1) {
462 innerMode = state.scriptType.toLowerCase().replace(/"|'/g, '');
463 } else if (state.lastTag === 'style') {
464 innerMode = 'css';
465 }
466 setInnerMode(stream, state, innerMode);
467 return 'dot';
468 }
469 }
470
471 function fail(stream) {
472 stream.next();
473 return null;
474 }
475
476
477 function setInnerMode(stream, state, mode) {
478 mode = CodeMirror.mimeModes[mode] || mode;
479 mode = config.innerModes ? config.innerModes(mode) || mode : mode;
480 mode = CodeMirror.mimeModes[mode] || mode;
481 mode = CodeMirror.getMode(config, mode);
482 state.indentOf = stream.indentation();
483
484 if (mode && mode.name !== 'null') {
485 state.innerMode = mode;
486 } else {
487 state.indentToken = 'string';
488 }
489 }
490 function innerMode(stream, state, force) {
491 if (stream.indentation() > state.indentOf || (state.innerModeForLine && !stream.sol()) || force) {
492 if (state.innerMode) {
493 if (!state.innerState) {
494 state.innerState = state.innerMode.startState ? state.innerMode.startState(stream.indentation()) : {};
495 }
496 return stream.hideFirstChars(state.indentOf + 2, function () {
497 return state.innerMode.token(stream, state.innerState) || true;
498 });
499 } else {
500 stream.skipToEnd();
501 return state.indentToken;
502 }
503 } else if (stream.sol()) {
504 state.indentOf = Infinity;
505 state.indentToken = null;
506 state.innerMode = null;
507 state.innerState = null;
508 }
509 }
510 function restOfLine(stream, state) {
511 if (stream.sol()) {
512 // if restOfLine was set at end of line, ignore it
513 state.restOfLine = '';
514 }
515 if (state.restOfLine) {
516 stream.skipToEnd();
517 var tok = state.restOfLine;
518 state.restOfLine = '';
519 return tok;
520 }
521 }
522
523
524 function startState() {
525 return new State();
526 }
527 function copyState(state) {
528 return state.copy();
529 }
530 /**
531 * Get the next token in the stream
532 *
533 * @param {Stream} stream
534 * @param {State} state
535 */
536 function nextToken(stream, state) {
537 var tok = innerMode(stream, state)
538 || restOfLine(stream, state)
539 || interpolationContinued(stream, state)
540 || includeFilteredContinued(stream, state)
541 || eachContinued(stream, state)
542 || attrsContinued(stream, state)
543 || javaScript(stream, state)
544 || javaScriptArguments(stream, state)
545 || callArguments(stream, state)
546
547 || yieldStatement(stream, state)
548 || doctype(stream, state)
549 || interpolation(stream, state)
550 || caseStatement(stream, state)
551 || when(stream, state)
552 || defaultStatement(stream, state)
553 || extendsStatement(stream, state)
554 || append(stream, state)
555 || prepend(stream, state)
556 || block(stream, state)
557 || include(stream, state)
558 || includeFiltered(stream, state)
559 || mixin(stream, state)
560 || call(stream, state)
561 || conditional(stream, state)
562 || each(stream, state)
563 || whileStatement(stream, state)
564 || tag(stream, state)
565 || filter(stream, state)
566 || code(stream, state)
567 || id(stream, state)
568 || className(stream, state)
569 || attrs(stream, state)
570 || attributesBlock(stream, state)
571 || indent(stream, state)
572 || text(stream, state)
573 || comment(stream, state)
574 || colon(stream, state)
575 || dot(stream, state)
576 || fail(stream, state);
577
578 return tok === true ? null : tok;
579 }
580 return {
581 startState: startState,
582 copyState: copyState,
583 token: nextToken
584 };
585 });
586
587 CodeMirror.defineMIME('text/x-jade', 'jade');
588
589 });
00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
11 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 // TODO actually recognize syntax of TypeScript constructs
42
53 (function(mod) {
64 if (typeof exports == "object" && typeof module == "object") // CommonJS
1210 })(function(CodeMirror) {
1311 "use strict";
1412
13 function expressionAllowed(stream, state, backUp) {
14 return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
15 (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
16 }
17
1518 CodeMirror.defineMode("javascript", function(config, parserConfig) {
1619 var indentUnit = config.indentUnit;
1720 var statementIndent = parserConfig.statementIndent;
2932
3033 var jsKeywords = {
3134 "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
32 "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C,
35 "return": C, "break": C, "continue": C, "new": kw("new"), "delete": C, "throw": C, "debugger": C,
3336 "var": kw("var"), "const": kw("var"), "let": kw("var"),
3437 "function": kw("function"), "catch": kw("catch"),
3538 "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
3639 "in": operator, "typeof": operator, "instanceof": operator,
3740 "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
38 "this": kw("this"), "module": kw("module"), "class": kw("class"), "super": kw("atom"),
39 "yield": C, "export": kw("export"), "import": kw("import"), "extends": C
41 "this": kw("this"), "class": kw("class"), "super": kw("atom"),
42 "yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
43 "await": C, "async": kw("async")
4044 };
4145
4246 // Extend the 'normal' keywords with the TypeScript language extensions
4448 var type = {type: "variable", style: "variable-3"};
4549 var tsKeywords = {
4650 // object-like things
47 "interface": kw("interface"),
48 "extends": kw("extends"),
49 "constructor": kw("constructor"),
51 "interface": kw("class"),
52 "implements": C,
53 "namespace": C,
54 "module": kw("module"),
55 "enum": kw("module"),
56 "type": kw("type"),
5057
5158 // scope modifiers
52 "public": kw("public"),
53 "private": kw("private"),
54 "protected": kw("protected"),
55 "static": kw("static"),
59 "public": kw("modifier"),
60 "private": kw("modifier"),
61 "protected": kw("modifier"),
62 "abstract": kw("modifier"),
63
64 // operators
65 "as": operator,
5666
5767 // types
58 "string": type, "number": type, "bool": type, "any": type
68 "string": type, "number": type, "boolean": type, "any": type
5969 };
6070
6171 for (var attr in tsKeywords) {
104114 } else if (ch == "0" && stream.eat(/x/i)) {
105115 stream.eatWhile(/[\da-f]/i);
106116 return ret("number", "number");
117 } else if (ch == "0" && stream.eat(/o/i)) {
118 stream.eatWhile(/[0-7]/i);
119 return ret("number", "number");
120 } else if (ch == "0" && stream.eat(/b/i)) {
121 stream.eatWhile(/[01]/i);
122 return ret("number", "number");
107123 } else if (/\d/.test(ch)) {
108124 stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
109125 return ret("number", "number");
114130 } else if (stream.eat("/")) {
115131 stream.skipToEnd();
116132 return ret("comment", "comment");
117 } else if (state.lastType == "operator" || state.lastType == "keyword c" ||
118 state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
133 } else if (expressionAllowed(stream, state, 1)) {
119134 readRegexp(stream);
120135 stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
121136 return ret("regexp", "string-2");
199214 var bracket = brackets.indexOf(ch);
200215 if (bracket >= 0 && bracket < 3) {
201216 if (!depth) { ++pos; break; }
202 if (--depth == 0) break;
217 if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
203218 } else if (bracket >= 3 && bracket < 6) {
204219 ++depth;
205220 } else if (wordRE.test(ch)) {
274289 return false;
275290 }
276291 var state = cx.state;
292 cx.marked = "def";
277293 if (state.context) {
278 cx.marked = "def";
279294 if (inList(state.localVars)) return;
280295 state.localVars = {name: varname, next: state.localVars};
281296 } else {
328343
329344 function statement(type, value) {
330345 if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
331 if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
346 if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
332347 if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
333348 if (type == "{") return cont(pushlex("}"), block, poplex);
334349 if (type == ";") return cont();
335350 if (type == "if") {
336351 if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
337352 cx.state.cc.pop()();
338 return cont(pushlex("form"), expression, statement, poplex, maybeelse);
353 return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
339354 }
340355 if (type == "function") return cont(functiondef);
341356 if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
342357 if (type == "variable") return cont(pushlex("stat"), maybelabel);
343 if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
358 if (type == "switch") return cont(pushlex("form"), parenExpr, pushlex("}", "switch"), expect("{"),
344359 block, poplex, poplex);
345360 if (type == "case") return cont(expression, expect(":"));
346361 if (type == "default") return cont(expect(":"));
347362 if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
348363 statement, poplex, popcontext);
349 if (type == "module") return cont(pushlex("form"), pushcontext, afterModule, popcontext, poplex);
350364 if (type == "class") return cont(pushlex("form"), className, poplex);
351 if (type == "export") return cont(pushlex("form"), afterExport, poplex);
352 if (type == "import") return cont(pushlex("form"), afterImport, poplex);
365 if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
366 if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
367 if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
368 if (type == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
369 if (type == "async") return cont(statement)
353370 return pass(pushlex("stat"), expression, expect(";"), poplex);
354371 }
355372 function expression(type) {
357374 }
358375 function expressionNoComma(type) {
359376 return expressionInner(type, true);
377 }
378 function parenExpr(type) {
379 if (type != "(") return pass()
380 return cont(pushlex(")"), expression, expect(")"), poplex)
360381 }
361382 function expressionInner(type, noComma) {
362383 if (cx.state.fatArrowAt == cx.stream.start) {
368389 var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
369390 if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
370391 if (type == "function") return cont(functiondef, maybeop);
371 if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
372 if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
392 if (type == "keyword c" || type == "async") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
393 if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
373394 if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
374395 if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
375396 if (type == "{") return contCommasep(objprop, "}", null, maybeop);
376 if (type == "quasi") { return pass(quasi, maybeop); }
397 if (type == "quasi") return pass(quasi, maybeop);
398 if (type == "new") return cont(maybeTarget(noComma));
377399 return cont();
378400 }
379401 function maybeexpression(type) {
424446 findFatArrow(cx.stream, cx.state);
425447 return pass(type == "{" ? statement : expressionNoComma);
426448 }
449 function maybeTarget(noComma) {
450 return function(type) {
451 if (type == ".") return cont(noComma ? targetNoComma : target);
452 else return pass(noComma ? expressionNoComma : expression);
453 };
454 }
455 function target(_, value) {
456 if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
457 }
458 function targetNoComma(_, value) {
459 if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
460 }
427461 function maybelabel(type) {
428462 if (type == ":") return cont(poplex, statement);
429463 return pass(maybeoperatorComma, expect(";"), poplex);
432466 if (type == "variable") {cx.marked = "property"; return cont();}
433467 }
434468 function objprop(type, value) {
435 if (type == "variable" || cx.style == "keyword") {
469 if (type == "async") {
470 cx.marked = "property";
471 return cont(objprop);
472 } else if (type == "variable" || cx.style == "keyword") {
436473 cx.marked = "property";
437474 if (value == "get" || value == "set") return cont(getterSetter);
438475 return cont(afterprop);
441478 return cont(afterprop);
442479 } else if (type == "jsonld-keyword") {
443480 return cont(afterprop);
481 } else if (type == "modifier") {
482 return cont(objprop)
444483 } else if (type == "[") {
445484 return cont(expression, expect("]"), afterprop);
485 } else if (type == "spread") {
486 return cont(expression);
487 } else if (type == ":") {
488 return pass(afterprop)
446489 }
447490 }
448491 function getterSetter(type) {
455498 if (type == "(") return pass(functiondef);
456499 }
457500 function commasep(what, end) {
458 function proceed(type) {
501 function proceed(type, value) {
459502 if (type == ",") {
460503 var lex = cx.state.lexical;
461504 if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
462 return cont(what, proceed);
463 }
464 if (type == end) return cont();
505 return cont(function(type, value) {
506 if (type == end || value == end) return pass()
507 return pass(what)
508 }, proceed);
509 }
510 if (type == end || value == end) return cont();
465511 return cont(expect(end));
466512 }
467 return function(type) {
468 if (type == end) return cont();
513 return function(type, value) {
514 if (type == end || value == end) return cont();
469515 return pass(what, proceed);
470516 };
471517 }
478524 if (type == "}") return cont();
479525 return pass(statement, block);
480526 }
481 function maybetype(type) {
482 if (isTS && type == ":") return cont(typedef);
527 function maybetype(type, value) {
528 if (isTS) {
529 if (type == ":") return cont(typeexpr);
530 if (value == "?") return cont(maybetype);
531 }
483532 }
484533 function maybedefault(_, value) {
485534 if (value == "=") return cont(expressionNoComma);
486535 }
487 function typedef(type) {
488 if (type == "variable") {cx.marked = "variable-3"; return cont();}
536 function typeexpr(type) {
537 if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
538 if (type == "{") return cont(commasep(typeprop, "}"))
539 if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
540 }
541 function maybeReturnType(type) {
542 if (type == "=>") return cont(typeexpr)
543 }
544 function typeprop(type) {
545 if (type == "variable" || cx.style == "keyword") {
546 cx.marked = "property"
547 return cont(typeprop)
548 } else if (type == ":") {
549 return cont(typeexpr)
550 }
551 }
552 function typearg(type) {
553 if (type == "variable") return cont(typearg)
554 else if (type == ":") return cont(typeexpr)
555 }
556 function afterType(type, value) {
557 if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
558 if (type == "[") return cont(expect("]"), afterType)
489559 }
490560 function vardef() {
491561 return pass(pattern, maybetype, maybeAssign, vardefCont);
492562 }
493563 function pattern(type, value) {
564 if (type == "modifier") return cont(pattern)
494565 if (type == "variable") { register(value); return cont(); }
566 if (type == "spread") return cont(pattern);
495567 if (type == "[") return contCommasep(pattern, "]");
496568 if (type == "{") return contCommasep(proppattern, "}");
497569 }
501573 return cont(maybeAssign);
502574 }
503575 if (type == "variable") cx.marked = "property";
576 if (type == "spread") return cont(pattern);
577 if (type == "}") return pass();
504578 return cont(expect(":"), pattern, maybeAssign);
505579 }
506580 function maybeAssign(_type, value) {
536610 function functiondef(type, value) {
537611 if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
538612 if (type == "variable") {register(value); return cont(functiondef);}
539 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
613 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, maybetype, statement, popcontext);
540614 }
541615 function funarg(type) {
542616 if (type == "spread") return cont(funarg);
546620 if (type == "variable") {register(value); return cont(classNameAfter);}
547621 }
548622 function classNameAfter(type, value) {
549 if (value == "extends") return cont(expression, classNameAfter);
623 if (value == "extends") return cont(isTS ? typeexpr : expression, classNameAfter);
550624 if (type == "{") return cont(pushlex("}"), classBody, poplex);
551625 }
552626 function classBody(type, value) {
553627 if (type == "variable" || cx.style == "keyword") {
554 if (value == "static") {
628 if ((value == "static" || value == "get" || value == "set" ||
629 (isTS && (value == "public" || value == "private" || value == "protected"))) &&
630 cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
555631 cx.marked = "keyword";
556632 return cont(classBody);
557633 }
558634 cx.marked = "property";
559 if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
560 return cont(functiondef, classBody);
635 return cont(isTS ? classfield : functiondef, classBody);
561636 }
562637 if (value == "*") {
563638 cx.marked = "keyword";
566641 if (type == ";") return cont(classBody);
567642 if (type == "}") return cont();
568643 }
569 function classGetterSetter(type) {
570 if (type != "variable") return pass();
571 cx.marked = "property";
572 return cont();
573 }
574 function afterModule(type, value) {
575 if (type == "string") return cont(statement);
576 if (type == "variable") { register(value); return cont(maybeFrom); }
644 function classfield(type) {
645 if (type == ":") return cont(typeexpr)
646 return pass(functiondef)
577647 }
578648 function afterExport(_type, value) {
579649 if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
598668 }
599669 function arrayLiteral(type) {
600670 if (type == "]") return cont();
601 return pass(expressionNoComma, maybeArrayComprehension);
602 }
603 function maybeArrayComprehension(type) {
604 if (type == "for") return pass(comprehension, expect("]"));
605 if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
606671 return pass(commasep(expressionNoComma, "]"));
607 }
608 function comprehension(type) {
609 if (type == "for") return cont(forspec, comprehension);
610 if (type == "if") return cont(expression, comprehension);
611672 }
612673
613674 function isContinuedStatement(state, textAfter) {
627688 lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
628689 localVars: parserConfig.localVars,
629690 context: parserConfig.localVars && {vars: parserConfig.localVars},
630 indented: 0
691 indented: basecolumn || 0
631692 };
632693 if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
633694 state.globalVars = parserConfig.globalVars;
651712 indent: function(state, textAfter) {
652713 if (state.tokenize == tokenComment) return CodeMirror.Pass;
653714 if (state.tokenize != tokenBase) return 0;
654 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
715 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
655716 // Kludge to prevent 'maybelse' from blocking lexical scope pops
656717 if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
657718 var c = state.cc[i];
658719 if (c == poplex) lexical = lexical.prev;
659720 else if (c != maybeelse) break;
660721 }
661 if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
722 while ((lexical.type == "stat" || lexical.type == "form") &&
723 (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
724 (top == maybeoperatorComma || top == maybeoperatorNoComma) &&
725 !/^[,\.=+\-*:?[\(]/.test(textAfter))))
726 lexical = lexical.prev;
662727 if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
663728 lexical = lexical.prev;
664729 var type = lexical.type, closing = firstChar == type;
683748
684749 helperType: jsonMode ? "json" : "javascript",
685750 jsonldMode: jsonldMode,
686 jsonMode: jsonMode
751 jsonMode: jsonMode,
752
753 expressionAllowed: expressionAllowed,
754 skipExpression: function(state) {
755 var top = state.cc[state.cc.length - 1]
756 if (top == expression || top == expressionNoComma) state.cc.pop()
757 }
687758 };
688759 });
689760
55 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
66
77 MT("locals",
8 "[keyword function] [variable foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");
8 "[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]; }");
99
1010 MT("comma-and-binop",
1111 "[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");
1616 " [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
1717 "})();");
1818
19 MT("destructure_trailing_comma",
20 "[keyword let] {[def a], [def b],} [operator =] [variable foo];",
21 "[keyword let] [def c];"); // Parser still in good state?
22
1923 MT("class_body",
20 "[keyword class] [variable Foo] {",
24 "[keyword class] [def Foo] {",
2125 " [property constructor]() {}",
2226 " [property sayName]() {",
2327 " [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",
2529 "}");
2630
2731 MT("class",
28 "[keyword class] [variable Point] [keyword extends] [variable SuperThing] {",
29 " [property get] [property prop]() { [keyword return] [number 24]; }",
32 "[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
33 " [keyword get] [property prop]() { [keyword return] [number 24]; }",
3034 " [property constructor]([def x], [def y]) {",
3135 " [keyword super]([string 'something']);",
3236 " [keyword this].[property x] [operator =] [variable-2 x];",
3337 " }",
3438 "}");
3539
36 MT("module",
37 "[keyword module] [string 'foo'] {",
38 " [keyword export] [keyword let] [def x] [operator =] [number 42];",
39 " [keyword export] [keyword *] [keyword from] [string 'somewhere'];",
40 "}");
41
4240 MT("import",
43 "[keyword function] [variable foo]() {",
41 "[keyword function] [def foo]() {",
4442 " [keyword import] [def $] [keyword from] [string 'jquery'];",
45 " [keyword module] [def crypto] [keyword from] [string 'crypto'];",
4643 " [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
4744 "}");
4845
46 MT("import_trailing_comma",
47 "[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']")
48
4949 MT("const",
50 "[keyword function] [variable f]() {",
50 "[keyword function] [def f]() {",
5151 " [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
5252 "}");
5353
5454 MT("for/of",
55 "[keyword for]([keyword let] [variable of] [keyword of] [variable something]) {}");
55 "[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}");
5656
5757 MT("generator",
58 "[keyword function*] [variable repeat]([def n]) {",
58 "[keyword function*] [def repeat]([def n]) {",
5959 " [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
6060 " [keyword yield] [variable-2 i];",
6161 "}");
6262
6363 MT("quotedStringAddition",
64 "[keyword let] [variable f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");
64 "[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");
6565
6666 MT("quotedFatArrow",
67 "[keyword let] [variable f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");
67 "[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");
6868
6969 MT("fatArrow",
7070 "[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
7171 "[variable a];", // No longer in scope
72 "[keyword let] [variable f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
72 "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
7373 "[variable c];");
7474
7575 MT("spread",
76 "[keyword function] [variable f]([def a], [meta ...][def b]) {",
76 "[keyword function] [def f]([def a], [meta ...][def b]) {",
7777 " [variable something]([variable-2 a], [meta ...][variable-2 b]);",
78 "}");
79
80 MT("comprehension",
81 "[keyword function] [variable f]() {",
82 " [[([variable x] [operator +] [number 1]) [keyword for] ([keyword var] [def x] [keyword in] [variable y]) [keyword if] [variable pred]([variable-2 x]) ]];",
83 " ([variable u] [keyword for] ([keyword var] [def u] [keyword of] [variable generateValues]()) [keyword if] ([variable-2 u].[property color] [operator ===] [string 'blue']));",
8478 "}");
8579
8680 MT("quasi",
9084 "[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
9185
9286 MT("indent_statement",
93 "[keyword var] [variable x] [operator =] [number 10]",
87 "[keyword var] [def x] [operator =] [number 10]",
9488 "[variable x] [operator +=] [variable y] [operator +]",
9589 " [atom Infinity]",
9690 "[keyword debugger];");
111105 "}");
112106
113107 MT("indent_for",
114 "[keyword for] ([keyword var] [variable i] [operator =] [number 0];",
108 "[keyword for] ([keyword var] [def i] [operator =] [number 0];",
115109 " [variable i] [operator <] [number 100];",
116110 " [variable i][operator ++])",
117111 " [variable doSomething]([variable i]);",
118112 "[keyword debugger];");
119113
120114 MT("indent_c_style",
121 "[keyword function] [variable foo]()",
115 "[keyword function] [def foo]()",
122116 "{",
123117 " [keyword debugger];",
124118 "}");
145139 " [number 1];",
146140 "[number 2];");
147141
142 MT("indent_semicolonless_if",
143 "[keyword function] [def foo]() {",
144 " [keyword if] ([variable x])",
145 " [variable foo]()",
146 "}")
147
148 MT("indent_semicolonless_if_with_statement",
149 "[keyword function] [def foo]() {",
150 " [keyword if] ([variable x])",
151 " [variable foo]()",
152 " [variable bar]()",
153 "}")
154
148155 MT("multilinestring",
149 "[keyword var] [variable x] [operator =] [string 'foo\\]",
156 "[keyword var] [def x] [operator =] [string 'foo\\]",
150157 "[string bar'];");
151158
152159 MT("scary_regexp",
153160 "[string-2 /foo[[/]]bar/];");
154161
155162 MT("indent_strange_array",
156 "[keyword var] [variable x] [operator =] [[",
163 "[keyword var] [def x] [operator =] [[",
157164 " [number 1],,",
158165 " [number 2],",
159166 "]];",
160167 "[number 10];");
161168
162169 MT("param_default",
163 "[keyword function] [variable foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
170 "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {",
164171 " [keyword return] [variable-2 x];",
165172 "}");
173
174 MT("new_target",
175 "[keyword function] [def F]([def target]) {",
176 " [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {",
177 " [keyword return] [keyword new]",
178 " .[keyword target];",
179 " }",
180 "}");
181
182 var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
183 function TS(name) {
184 test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
185 }
186
187 TS("extend_type",
188 "[keyword class] [def Foo] [keyword extends] [variable-3 Some][operator <][variable-3 Type][operator >] {}")
189
190 TS("arrow_type",
191 "[keyword let] [def x]: ([variable arg]: [variable-3 Type]) [operator =>] [variable-3 ReturnType]")
192
193 TS("typescript_class",
194 "[keyword class] [def Foo] {",
195 " [keyword public] [keyword static] [property main]() {}",
196 " [keyword private] [property _foo]: [variable-3 string];",
197 "}")
166198
167199 var jsonld_mode = CodeMirror.getMode(
168200 {indentUnit: 2},
0 <!doctype html>
1
2 <title>CodeMirror: JSX mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../javascript/javascript.js"></script>
9 <script src="../xml/xml.js"></script>
10 <script src="jsx.js"></script>
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</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="#">JSX</a>
23 </ul>
24 </div>
25
26 <article>
27 <h2>JSX mode</h2>
28
29 <div><textarea id="code" name="code">// Code snippets from http://facebook.github.io/react/docs/jsx-in-depth.html
30
31 // Rendering HTML tags
32 var myDivElement = <div className="foo" />;
33 ReactDOM.render(myDivElement, document.getElementById('example'));
34
35 // Rendering React components
36 var MyComponent = React.createClass({/*...*/});
37 var myElement = <MyComponent someProperty={true} />;
38 ReactDOM.render(myElement, document.getElementById('example'));
39
40 // Namespaced components
41 var Form = MyFormComponent;
42
43 var App = (
44 <Form>
45 <Form.Row>
46 <Form.Label />
47 <Form.Input />
48 </Form.Row>
49 </Form>
50 );
51
52 // Attribute JavaScript expressions
53 var person = <Person name={window.isLoggedIn ? window.name : ''} />;
54
55 // Boolean attributes
56 <input type="button" disabled />;
57 <input type="button" disabled={true} />;
58
59 // Child JavaScript expressions
60 var content = <Container>{window.isLoggedIn ? <Nav /> : <Login />}</Container>;
61
62 // Comments
63 var content = (
64 <Nav>
65 {/* child comment, put {} around */}
66 <Person
67 /* multi
68 line
69 comment */
70 name={window.isLoggedIn ? window.name : ''} // end of line comment
71 />
72 </Nav>
73 );
74 </textarea></div>
75
76 <script>
77 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
78 lineNumbers: true,
79 mode: "jsx"
80 })
81 </script>
82
83 <p>JSX Mode for <a href="http://facebook.github.io/react">React</a>'s
84 JavaScript syntax extension.</p>
85
86 <p><strong>MIME types defined:</strong> <code>text/jsx</code>, <code>text/typescript-jsx</code>.</p>
87
88 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"))
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript"], mod)
8 else // Plain browser env
9 mod(CodeMirror)
10 })(function(CodeMirror) {
11 "use strict"
12
13 // Depth means the amount of open braces in JS context, in XML
14 // context 0 means not in tag, 1 means in tag, and 2 means in tag
15 // and js block comment.
16 function Context(state, mode, depth, prev) {
17 this.state = state; this.mode = mode; this.depth = depth; this.prev = prev
18 }
19
20 function copyContext(context) {
21 return new Context(CodeMirror.copyState(context.mode, context.state),
22 context.mode,
23 context.depth,
24 context.prev && copyContext(context.prev))
25 }
26
27 CodeMirror.defineMode("jsx", function(config, modeConfig) {
28 var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false})
29 var jsMode = CodeMirror.getMode(config, modeConfig && modeConfig.base || "javascript")
30
31 function flatXMLIndent(state) {
32 var tagName = state.tagName
33 state.tagName = null
34 var result = xmlMode.indent(state, "")
35 state.tagName = tagName
36 return result
37 }
38
39 function token(stream, state) {
40 if (state.context.mode == xmlMode)
41 return xmlToken(stream, state, state.context)
42 else
43 return jsToken(stream, state, state.context)
44 }
45
46 function xmlToken(stream, state, cx) {
47 if (cx.depth == 2) { // Inside a JS /* */ comment
48 if (stream.match(/^.*?\*\//)) cx.depth = 1
49 else stream.skipToEnd()
50 return "comment"
51 }
52
53 if (stream.peek() == "{") {
54 xmlMode.skipAttribute(cx.state)
55
56 var indent = flatXMLIndent(cx.state), xmlContext = cx.state.context
57 // If JS starts on same line as tag
58 if (xmlContext && stream.match(/^[^>]*>\s*$/, false)) {
59 while (xmlContext.prev && !xmlContext.startOfLine)
60 xmlContext = xmlContext.prev
61 // If tag starts the line, use XML indentation level
62 if (xmlContext.startOfLine) indent -= config.indentUnit
63 // Else use JS indentation level
64 else if (cx.prev.state.lexical) indent = cx.prev.state.lexical.indented
65 // Else if inside of tag
66 } else if (cx.depth == 1) {
67 indent += config.indentUnit
68 }
69
70 state.context = new Context(CodeMirror.startState(jsMode, indent),
71 jsMode, 0, state.context)
72 return null
73 }
74
75 if (cx.depth == 1) { // Inside of tag
76 if (stream.peek() == "<") { // Tag inside of tag
77 xmlMode.skipAttribute(cx.state)
78 state.context = new Context(CodeMirror.startState(xmlMode, flatXMLIndent(cx.state)),
79 xmlMode, 0, state.context)
80 return null
81 } else if (stream.match("//")) {
82 stream.skipToEnd()
83 return "comment"
84 } else if (stream.match("/*")) {
85 cx.depth = 2
86 return token(stream, state)
87 }
88 }
89
90 var style = xmlMode.token(stream, cx.state), cur = stream.current(), stop
91 if (/\btag\b/.test(style)) {
92 if (/>$/.test(cur)) {
93 if (cx.state.context) cx.depth = 0
94 else state.context = state.context.prev
95 } else if (/^</.test(cur)) {
96 cx.depth = 1
97 }
98 } else if (!style && (stop = cur.indexOf("{")) > -1) {
99 stream.backUp(cur.length - stop)
100 }
101 return style
102 }
103
104 function jsToken(stream, state, cx) {
105 if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) {
106 jsMode.skipExpression(cx.state)
107 state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")),
108 xmlMode, 0, state.context)
109 return null
110 }
111
112 var style = jsMode.token(stream, cx.state)
113 if (!style && cx.depth != null) {
114 var cur = stream.current()
115 if (cur == "{") {
116 cx.depth++
117 } else if (cur == "}") {
118 if (--cx.depth == 0) state.context = state.context.prev
119 }
120 }
121 return style
122 }
123
124 return {
125 startState: function() {
126 return {context: new Context(CodeMirror.startState(jsMode), jsMode)}
127 },
128
129 copyState: function(state) {
130 return {context: copyContext(state.context)}
131 },
132
133 token: token,
134
135 indent: function(state, textAfter, fullLine) {
136 return state.context.mode.indent(state.context.state, textAfter, fullLine)
137 },
138
139 innerMode: function(state) {
140 return state.context
141 }
142 }
143 }, "xml", "javascript")
144
145 CodeMirror.defineMIME("text/jsx", "jsx")
146 CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}})
147 });
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 var mode = CodeMirror.getMode({indentUnit: 2}, "jsx")
5 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)) }
6
7 MT("selfclose",
8 "[keyword var] [def x] [operator =] [bracket&tag <] [tag foo] [bracket&tag />] [operator +] [number 1];")
9
10 MT("openclose",
11 "([bracket&tag <][tag foo][bracket&tag >]hello [atom &amp;][bracket&tag </][tag foo][bracket&tag >][operator ++])")
12
13 MT("attr",
14 "([bracket&tag <][tag foo] [attribute abc]=[string 'value'][bracket&tag >]hello [atom &amp;][bracket&tag </][tag foo][bracket&tag >][operator ++])")
15
16 MT("braced_attr",
17 "([bracket&tag <][tag foo] [attribute abc]={[number 10]}[bracket&tag >]hello [atom &amp;][bracket&tag </][tag foo][bracket&tag >][operator ++])")
18
19 MT("braced_text",
20 "([bracket&tag <][tag foo][bracket&tag >]hello {[number 10]} [atom &amp;][bracket&tag </][tag foo][bracket&tag >][operator ++])")
21
22 MT("nested_tag",
23 "([bracket&tag <][tag foo][bracket&tag ><][tag bar][bracket&tag ></][tag bar][bracket&tag ></][tag foo][bracket&tag >][operator ++])")
24
25 MT("nested_jsx",
26 "[keyword return] (",
27 " [bracket&tag <][tag foo][bracket&tag >]",
28 " say {[number 1] [operator +] [bracket&tag <][tag bar] [attribute attr]={[number 10]}[bracket&tag />]}!",
29 " [bracket&tag </][tag foo][bracket&tag >][operator ++]",
30 ")")
31
32 MT("preserve_js_context",
33 "[variable x] [operator =] [string-2 `quasi${][bracket&tag <][tag foo][bracket&tag />][string-2 }quoted`]")
34
35 MT("line_comment",
36 "([bracket&tag <][tag foo] [comment // hello]",
37 " [bracket&tag ></][tag foo][bracket&tag >][operator ++])")
38
39 MT("line_comment_not_in_tag",
40 "([bracket&tag <][tag foo][bracket&tag >] // hello",
41 " [bracket&tag </][tag foo][bracket&tag >][operator ++])")
42
43 MT("block_comment",
44 "([bracket&tag <][tag foo] [comment /* hello]",
45 "[comment line 2]",
46 "[comment line 3 */] [bracket&tag ></][tag foo][bracket&tag >][operator ++])")
47
48 MT("block_comment_not_in_tag",
49 "([bracket&tag <][tag foo][bracket&tag >]/* hello",
50 " line 2",
51 " line 3 */ [bracket&tag </][tag foo][bracket&tag >][operator ++])")
52
53 MT("missing_attr",
54 "([bracket&tag <][tag foo] [attribute selected][bracket&tag />][operator ++])")
55
56 MT("indent_js",
57 "([bracket&tag <][tag foo][bracket&tag >]",
58 " [bracket&tag <][tag bar] [attribute baz]={[keyword function]() {",
59 " [keyword return] [number 10]",
60 " }}[bracket&tag />]",
61 " [bracket&tag </][tag foo][bracket&tag >])")
62
63 MT("spread",
64 "([bracket&tag <][tag foo] [attribute bar]={[meta ...][variable baz] [operator /][number 2]}[bracket&tag />])")
65
66 MT("tag_attribute",
67 "([bracket&tag <][tag foo] [attribute bar]=[bracket&tag <][tag foo][bracket&tag />/>][operator ++])")
68 })()
1313 CodeMirror.defineMode("julia", function(_conf, parserConf) {
1414 var ERRORCLASS = 'error';
1515
16 function wordRegexp(words) {
17 return new RegExp("^((" + words.join(")|(") + "))\\b");
18 }
19
20 var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b/;
16 function wordRegexp(words, end) {
17 if (typeof end === 'undefined') { end = "\\b"; }
18 return new RegExp("^((" + words.join(")|(") + "))" + end);
19 }
20
21 var octChar = "\\\\[0-7]{1,3}";
22 var hexChar = "\\\\x[A-Fa-f0-9]{1,2}";
23 var specialChar = "\\\\[abfnrtv0%?'\"\\\\]";
24 var singleChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])";
25 var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b(?!\()|[\u2208\u2209](?!\()/;
2126 var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
22 var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*!*/;
27 var identifiers = parserConf.identifiers || /^[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
28 var charsList = [octChar, hexChar, specialChar, singleChar];
2329 var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"];
2430 var blockClosers = ["end", "else", "elseif", "catch", "finally"];
25 var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype', 'ccall'];
26 var builtinList = ['true', 'false', 'enumerate', 'open', 'close', 'nothing', 'NaN', 'Inf', 'print', 'println', 'Int', 'Int8', 'Uint8', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Int64', 'Uint64', 'Int128', 'Uint128', 'Bool', 'Char', 'Float16', 'Float32', 'Float64', 'Array', 'Vector', 'Matrix', 'String', 'UTF8String', 'ASCIIString', 'error', 'warn', 'info', '@printf'];
31 var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype'];
32 var builtinList = ['true', 'false', 'nothing', 'NaN', 'Inf'];
2733
2834 //var stringPrefixes = new RegExp("^[br]?('|\")")
29 var stringPrefixes = /^(`|'|"{3}|([br]?"))/;
35 var stringPrefixes = /^(`|"{3}|([brv]?"))/;
36 var chars = wordRegexp(charsList, "'");
3037 var keywords = wordRegexp(keywordList);
3138 var builtins = wordRegexp(builtinList);
3239 var openers = wordRegexp(blockOpeners);
3340 var closers = wordRegexp(blockClosers);
34 var macro = /^@[_A-Za-z][_A-Za-z0-9]*/;
35 var symbol = /^:[_A-Za-z][_A-Za-z0-9]*/;
36
37 function in_array(state) {
38 var ch = cur_scope(state);
39 if(ch=="[" || ch=="{") {
41 var macro = /^@[_A-Za-z][\w]*/;
42 var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/;
43 var typeAnnotation = /^::[^,;"{()=$\s]+({[^}]*}+)*/;
44
45 function inArray(state) {
46 var ch = currentScope(state);
47 if (ch == '[') {
4048 return true;
4149 }
42 else {
43 return false;
44 }
45 }
46
47 function cur_scope(state) {
48 if(state.scopes.length==0) {
50 return false;
51 }
52
53 function currentScope(state) {
54 if (state.scopes.length == 0) {
4955 return null;
5056 }
5157 return state.scopes[state.scopes.length - 1];
5359
5460 // tokenizers
5561 function tokenBase(stream, state) {
62 // Handle multiline comments
63 if (stream.match(/^#=/, false)) {
64 state.tokenize = tokenComment;
65 return state.tokenize(stream, state);
66 }
67
5668 // Handle scope changes
57 var leaving_expr = state.leaving_expr;
58 if(stream.sol()) {
59 leaving_expr = false;
60 }
61 state.leaving_expr = false;
62 if(leaving_expr) {
63 if(stream.match(/^'+/)) {
69 var leavingExpr = state.leavingExpr;
70 if (stream.sol()) {
71 leavingExpr = false;
72 }
73 state.leavingExpr = false;
74 if (leavingExpr) {
75 if (stream.match(/^'+/)) {
6476 return 'operator';
6577 }
66
67 }
68
69 if(stream.match(/^\.{2,3}/)) {
78 }
79
80 if (stream.match(/^\.{2,3}/)) {
7081 return 'operator';
7182 }
7283
7586 }
7687
7788 var ch = stream.peek();
78 // Handle Comments
89
90 // Handle single line comments
7991 if (ch === '#') {
80 stream.skipToEnd();
81 return 'comment';
82 }
83 if(ch==='[') {
84 state.scopes.push("[");
85 }
86
87 if(ch==='{') {
88 state.scopes.push("{");
89 }
90
91 var scope=cur_scope(state);
92
93 if(scope==='[' && ch===']') {
92 stream.skipToEnd();
93 return 'comment';
94 }
95
96 if (ch === '[') {
97 state.scopes.push('[');
98 }
99
100 if (ch === '(') {
101 state.scopes.push('(');
102 }
103
104 var scope = currentScope(state);
105
106 if (scope == '[' && ch === ']') {
94107 state.scopes.pop();
95 state.leaving_expr=true;
96 }
97
98 if(scope==='{' && ch==='}') {
108 state.leavingExpr = true;
109 }
110
111 if (scope == '(' && ch === ')') {
99112 state.scopes.pop();
100 state.leaving_expr=true;
101 }
102
103 if(ch===')') {
104 state.leaving_expr = true;
113 state.leavingExpr = true;
105114 }
106115
107116 var match;
108 if(!in_array(state) && (match=stream.match(openers, false))) {
117 if (!inArray(state) && (match=stream.match(openers, false))) {
109118 state.scopes.push(match);
110119 }
111120
112 if(!in_array(state) && stream.match(closers, false)) {
121 if (!inArray(state) && stream.match(closers, false)) {
113122 state.scopes.pop();
114123 }
115124
116 if(in_array(state)) {
117 if(stream.match(/^end/)) {
125 if (inArray(state)) {
126 if (state.lastToken == 'end' && stream.match(/^:/)) {
127 return 'operator';
128 }
129 if (stream.match(/^end/)) {
118130 return 'number';
119131 }
120
121 }
122
123 if(stream.match(/^=>/)) {
132 }
133
134 if (stream.match(/^=>/)) {
124135 return 'operator';
125136 }
126
127137
128138 // Handle Number Literals
129139 if (stream.match(/^[0-9\.]/, false)) {
130140 var imMatcher = RegExp(/^im\b/);
131 var floatLiteral = false;
141 var numberLiteral = false;
132142 // Floats
133 if (stream.match(/^\d*\.(?!\.)\d+([ef][\+\-]?\d+)?/i)) { floatLiteral = true; }
134 if (stream.match(/^\d+\.(?!\.)\d*/)) { floatLiteral = true; }
135 if (stream.match(/^\.\d+/)) { floatLiteral = true; }
136 if (floatLiteral) {
137 // Float literals may be "imaginary"
138 stream.match(imMatcher);
139 state.leaving_expr = true;
140 return 'number';
141 }
143 if (stream.match(/^\d*\.(?!\.)\d*([Eef][\+\-]?\d+)?/i)) { numberLiteral = true; }
144 if (stream.match(/^\d+\.(?!\.)\d*/)) { numberLiteral = true; }
145 if (stream.match(/^\.\d+/)) { numberLiteral = true; }
146 if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { numberLiteral = true; }
142147 // Integers
143 var intLiteral = false;
144 // Hex
145 if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; }
146 // Binary
147 if (stream.match(/^0b[01]+/i)) { intLiteral = true; }
148 // Octal
149 if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; }
150 // Decimal
151 if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
152 intLiteral = true;
153 }
148 if (stream.match(/^0x[0-9a-f]+/i)) { numberLiteral = true; } // Hex
149 if (stream.match(/^0b[01]+/i)) { numberLiteral = true; } // Binary
150 if (stream.match(/^0o[0-7]+/i)) { numberLiteral = true; } // Octal
151 if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal
154152 // Zero by itself with no other piece of number.
155 if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
156 if (intLiteral) {
153 if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; }
154 if (numberLiteral) {
157155 // Integer literals may be "long"
158156 stream.match(imMatcher);
159 state.leaving_expr = true;
157 state.leavingExpr = true;
160158 return 'number';
161159 }
162160 }
163161
164 if(stream.match(/^(::)|(<:)/)) {
162 if (stream.match(/^<:/)) {
165163 return 'operator';
166164 }
167165
166 if (stream.match(typeAnnotation)) {
167 return 'builtin';
168 }
169
168170 // Handle symbols
169 if(!leaving_expr && stream.match(symbol)) {
170 return 'string';
171 if (!leavingExpr && stream.match(symbol) || stream.match(/:\./)) {
172 return 'builtin';
173 }
174
175 // Handle parametric types
176 if (stream.match(/^{[^}]*}(?=\()/)) {
177 return 'builtin';
171178 }
172179
173180 // Handle operators and Delimiters
175182 return 'operator';
176183 }
177184
185 // Handle Chars
186 if (stream.match(/^'/)) {
187 state.tokenize = tokenChar;
188 return state.tokenize(stream, state);
189 }
178190
179191 // Handle Strings
180192 if (stream.match(stringPrefixes)) {
186198 return 'meta';
187199 }
188200
189
190201 if (stream.match(delimiters)) {
191202 return null;
192203 }
199210 return 'builtin';
200211 }
201212
213 var isDefinition = state.isDefinition ||
214 state.lastToken == 'function' ||
215 state.lastToken == 'macro' ||
216 state.lastToken == 'type' ||
217 state.lastToken == 'immutable';
202218
203219 if (stream.match(identifiers)) {
204 state.leaving_expr=true;
220 if (isDefinition) {
221 if (stream.peek() === '.') {
222 state.isDefinition = true;
223 return 'variable';
224 }
225 state.isDefinition = false;
226 return 'def';
227 }
228 if (stream.match(/^({[^}]*})*\(/, false)) {
229 return callOrDef(stream, state);
230 }
231 state.leavingExpr = true;
205232 return 'variable';
206233 }
234
207235 // Handle non-detected items
208236 stream.next();
209237 return ERRORCLASS;
210238 }
211239
240 function callOrDef(stream, state) {
241 var match = stream.match(/^(\(\s*)/);
242 if (match) {
243 if (state.firstParenPos < 0)
244 state.firstParenPos = state.scopes.length;
245 state.scopes.push('(');
246 state.charsAdvanced += match[1].length;
247 }
248 if (currentScope(state) == '(' && stream.match(/^\)/)) {
249 state.scopes.pop();
250 state.charsAdvanced += 1;
251 if (state.scopes.length <= state.firstParenPos) {
252 var isDefinition = stream.match(/^\s*?=(?!=)/, false);
253 stream.backUp(state.charsAdvanced);
254 state.firstParenPos = -1;
255 state.charsAdvanced = 0;
256 if (isDefinition)
257 return 'def';
258 return 'builtin';
259 }
260 }
261 // Unfortunately javascript does not support multiline strings, so we have
262 // to undo anything done upto here if a function call or definition splits
263 // over two or more lines.
264 if (stream.match(/^$/g, false)) {
265 stream.backUp(state.charsAdvanced);
266 while (state.scopes.length > state.firstParenPos)
267 state.scopes.pop();
268 state.firstParenPos = -1;
269 state.charsAdvanced = 0;
270 return 'builtin';
271 }
272 state.charsAdvanced += stream.match(/^([^()]*)/)[1].length;
273 return callOrDef(stream, state);
274 }
275
276 function tokenComment(stream, state) {
277 if (stream.match(/^#=/)) {
278 state.weakScopes++;
279 }
280 if (!stream.match(/.*?(?=(#=|=#))/)) {
281 stream.skipToEnd();
282 }
283 if (stream.match(/^=#/)) {
284 state.weakScopes--;
285 if (state.weakScopes == 0)
286 state.tokenize = tokenBase;
287 }
288 return 'comment';
289 }
290
291 function tokenChar(stream, state) {
292 var isChar = false, match;
293 if (stream.match(chars)) {
294 isChar = true;
295 } else if (match = stream.match(/\\u([a-f0-9]{1,4})(?=')/i)) {
296 var value = parseInt(match[1], 16);
297 if (value <= 55295 || value >= 57344) { // (U+0,U+D7FF), (U+E000,U+FFFF)
298 isChar = true;
299 stream.next();
300 }
301 } else if (match = stream.match(/\\U([A-Fa-f0-9]{5,8})(?=')/)) {
302 var value = parseInt(match[1], 16);
303 if (value <= 1114111) { // U+10FFFF
304 isChar = true;
305 stream.next();
306 }
307 }
308 if (isChar) {
309 state.leavingExpr = true;
310 state.tokenize = tokenBase;
311 return 'string';
312 }
313 if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); }
314 if (stream.match(/^'/)) { state.tokenize = tokenBase; }
315 return ERRORCLASS;
316 }
317
212318 function tokenStringFactory(delimiter) {
213 while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
319 while ('bruv'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
214320 delimiter = delimiter.substr(1);
215321 }
216 var singleline = delimiter.length == 1;
217322 var OUTCLASS = 'string';
218323
219324 function tokenString(stream, state) {
220325 while (!stream.eol()) {
221 stream.eatWhile(/[^'"\\]/);
326 stream.eatWhile(/[^"\\]/);
222327 if (stream.eat('\\')) {
223328 stream.next();
224 if (singleline && stream.eol()) {
225 return OUTCLASS;
226 }
227329 } else if (stream.match(delimiter)) {
228330 state.tokenize = tokenBase;
331 state.leavingExpr = true;
229332 return OUTCLASS;
230333 } else {
231 stream.eat(/['"]/);
232 }
233 }
234 if (singleline) {
235 if (parserConf.singleLineStringErrors) {
236 return ERRORCLASS;
237 } else {
238 state.tokenize = tokenBase;
334 stream.eat(/["]/);
239335 }
240336 }
241337 return OUTCLASS;
242338 }
243339 tokenString.isString = true;
244340 return tokenString;
245 }
246
247 function tokenLexer(stream, state) {
248 var style = state.tokenize(stream, state);
249 var current = stream.current();
250
251 // Handle '.' connected identifiers
252 if (current === '.') {
253 style = stream.match(identifiers, false) ? null : ERRORCLASS;
254 if (style === null && state.lastStyle === 'meta') {
255 // Apply 'meta' style to '.' connected identifiers when
256 // appropriate.
257 style = 'meta';
258 }
259 return style;
260 }
261
262 return style;
263341 }
264342
265343 var external = {
267345 return {
268346 tokenize: tokenBase,
269347 scopes: [],
270 leaving_expr: false
348 weakScopes: 0,
349 lastToken: null,
350 leavingExpr: false,
351 isDefinition: false,
352 charsAdvanced: 0,
353 firstParenPos: -1
271354 };
272355 },
273356
274357 token: function(stream, state) {
275 var style = tokenLexer(stream, state);
276 state.lastStyle = style;
358 var style = state.tokenize(stream, state);
359 var current = stream.current();
360
361 if (current && style) {
362 state.lastToken = current;
363 }
364
365 // Handle '.' connected identifiers
366 if (current === '.') {
367 style = stream.match(identifiers, false) || stream.match(macro, false) ||
368 stream.match(/\(/, false) ? 'operator' : ERRORCLASS;
369 }
277370 return style;
278371 },
279372
280373 indent: function(state, textAfter) {
281374 var delta = 0;
282 if(textAfter=="end" || textAfter=="]" || textAfter=="}" || textAfter=="else" || textAfter=="elseif" || textAfter=="catch" || textAfter=="finally") {
375 if (textAfter == "]" || textAfter == ")" || textAfter == "end" || textAfter == "else" || textAfter == "elseif" || textAfter == "catch" || textAfter == "finally") {
283376 delta = -1;
284377 }
285 return (state.scopes.length + delta) * 4;
378 return (state.scopes.length + delta) * _conf.indentUnit;
286379 },
287380
381 electricInput: /(end|else(if)?|catch|finally)$/,
288382 lineComment: "#",
289 fold: "indent",
290 electricChars: "edlsifyh]}"
383 fold: "indent"
291384 };
292385 return external;
293386 });
+0
-89
mode/kotlin/index.html less more
0 <!doctype html>
1
2 <title>CodeMirror: Kotlin mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="kotlin.js"></script>
9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <div id=nav>
11 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
12
13 <ul>
14 <li><a href="../../index.html">Home</a>
15 <li><a href="../../doc/manual.html">Manual</a>
16 <li><a href="https://github.com/codemirror/codemirror">Code</a>
17 </ul>
18 <ul>
19 <li><a href="../index.html">Language modes</a>
20 <li><a class=active href="#">Kotlin</a>
21 </ul>
22 </div>
23
24 <article>
25 <h2>Kotlin mode</h2>
26
27
28 <div><textarea id="code" name="code">
29 package org.wasabi.http
30
31 import java.util.concurrent.Executors
32 import java.net.InetSocketAddress
33 import org.wasabi.app.AppConfiguration
34 import io.netty.bootstrap.ServerBootstrap
35 import io.netty.channel.nio.NioEventLoopGroup
36 import io.netty.channel.socket.nio.NioServerSocketChannel
37 import org.wasabi.app.AppServer
38
39 public class HttpServer(private val appServer: AppServer) {
40
41 val bootstrap: ServerBootstrap
42 val primaryGroup: NioEventLoopGroup
43 val workerGroup: NioEventLoopGroup
44
45 {
46 // Define worker groups
47 primaryGroup = NioEventLoopGroup()
48 workerGroup = NioEventLoopGroup()
49
50 // Initialize bootstrap of server
51 bootstrap = ServerBootstrap()
52
53 bootstrap.group(primaryGroup, workerGroup)
54 bootstrap.channel(javaClass<NioServerSocketChannel>())
55 bootstrap.childHandler(NettyPipelineInitializer(appServer))
56 }
57
58 public fun start(wait: Boolean = true) {
59 val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel()
60
61 if (wait) {
62 channel?.closeFuture()?.sync()
63 }
64 }
65
66 public fun stop() {
67 // Shutdown all event loops
68 primaryGroup.shutdownGracefully()
69 workerGroup.shutdownGracefully()
70
71 // Wait till all threads are terminated
72 primaryGroup.terminationFuture().sync()
73 workerGroup.terminationFuture().sync()
74 }
75 }
76 </textarea></div>
77
78 <script>
79 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
80 mode: {name: "kotlin"},
81 lineNumbers: true,
82 indentUnit: 4
83 });
84 </script>
85 <h3>Mode for Kotlin (http://kotlin.jetbrains.org/)</h3>
86 <p>Developed by Hadi Hariri (https://github.com/hhariri).</p>
87 <p><strong>MIME type defined:</strong> <code>text/x-kotlin</code>.</p>
88 </article>
+0
-284
mode/kotlin/kotlin.js less more
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 CodeMirror.defineMode("kotlin", function (config, parserConfig) {
14 function words(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 var multiLineStrings = parserConfig.multiLineStrings;
21
22 var keywords = words(
23 "package continue return object while break class data trait interface throw super" +
24 " when type this else This try val var fun for is in if do as true false null get set");
25 var softKeywords = words("import" +
26 " where by get set abstract enum open annotation override private public internal" +
27 " protected catch out vararg inline finally final ref");
28 var blockKeywords = words("catch class do else finally for if where try while enum");
29 var atoms = words("null true false this");
30
31 var curPunc;
32
33 function tokenBase(stream, state) {
34 var ch = stream.next();
35 if (ch == '"' || ch == "'") {
36 return startString(ch, stream, state);
37 }
38 // Wildcard import w/o trailing semicolon (import smth.*)
39 if (ch == "." && stream.eat("*")) {
40 return "word";
41 }
42 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
43 curPunc = ch;
44 return null;
45 }
46 if (/\d/.test(ch)) {
47 if (stream.eat(/eE/)) {
48 stream.eat(/\+\-/);
49 stream.eatWhile(/\d/);
50 }
51 return "number";
52 }
53 if (ch == "/") {
54 if (stream.eat("*")) {
55 state.tokenize.push(tokenComment);
56 return tokenComment(stream, state);
57 }
58 if (stream.eat("/")) {
59 stream.skipToEnd();
60 return "comment";
61 }
62 if (expectExpression(state.lastToken)) {
63 return startString(ch, stream, state);
64 }
65 }
66 // Commented
67 if (ch == "-" && stream.eat(">")) {
68 curPunc = "->";
69 return null;
70 }
71 if (/[\-+*&%=<>!?|\/~]/.test(ch)) {
72 stream.eatWhile(/[\-+*&%=<>|~]/);
73 return "operator";
74 }
75 stream.eatWhile(/[\w\$_]/);
76
77 var cur = stream.current();
78 if (atoms.propertyIsEnumerable(cur)) {
79 return "atom";
80 }
81 if (softKeywords.propertyIsEnumerable(cur)) {
82 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
83 return "softKeyword";
84 }
85
86 if (keywords.propertyIsEnumerable(cur)) {
87 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
88 return "keyword";
89 }
90 return "word";
91 }
92
93 tokenBase.isBase = true;
94
95 function startString(quote, stream, state) {
96 var tripleQuoted = false;
97 if (quote != "/" && stream.eat(quote)) {
98 if (stream.eat(quote)) tripleQuoted = true;
99 else return "string";
100 }
101 function t(stream, state) {
102 var escaped = false, next, end = !tripleQuoted;
103
104 while ((next = stream.next()) != null) {
105 if (next == quote && !escaped) {
106 if (!tripleQuoted) {
107 break;
108 }
109 if (stream.match(quote + quote)) {
110 end = true;
111 break;
112 }
113 }
114
115 if (quote == '"' && next == "$" && !escaped && stream.eat("{")) {
116 state.tokenize.push(tokenBaseUntilBrace());
117 return "string";
118 }
119
120 if (next == "$" && !escaped && !stream.eat(" ")) {
121 state.tokenize.push(tokenBaseUntilSpace());
122 return "string";
123 }
124 escaped = !escaped && next == "\\";
125 }
126 if (multiLineStrings)
127 state.tokenize.push(t);
128 if (end) state.tokenize.pop();
129 return "string";
130 }
131
132 state.tokenize.push(t);
133 return t(stream, state);
134 }
135
136 function tokenBaseUntilBrace() {
137 var depth = 1;
138
139 function t(stream, state) {
140 if (stream.peek() == "}") {
141 depth--;
142 if (depth == 0) {
143 state.tokenize.pop();
144 return state.tokenize[state.tokenize.length - 1](stream, state);
145 }
146 } else if (stream.peek() == "{") {
147 depth++;
148 }
149 return tokenBase(stream, state);
150 }
151
152 t.isBase = true;
153 return t;
154 }
155
156 function tokenBaseUntilSpace() {
157 function t(stream, state) {
158 if (stream.eat(/[\w]/)) {
159 var isWord = stream.eatWhile(/[\w]/);
160 if (isWord) {
161 state.tokenize.pop();
162 return "word";
163 }
164 }
165 state.tokenize.pop();
166 return "string";
167 }
168
169 t.isBase = true;
170 return t;
171 }
172
173 function tokenComment(stream, state) {
174 var maybeEnd = false, ch;
175 while (ch = stream.next()) {
176 if (ch == "/" && maybeEnd) {
177 state.tokenize.pop();
178 break;
179 }
180 maybeEnd = (ch == "*");
181 }
182 return "comment";
183 }
184
185 function expectExpression(last) {
186 return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
187 last == "newstatement" || last == "keyword" || last == "proplabel";
188 }
189
190 function Context(indented, column, type, align, prev) {
191 this.indented = indented;
192 this.column = column;
193 this.type = type;
194 this.align = align;
195 this.prev = prev;
196 }
197
198 function pushContext(state, col, type) {
199 return state.context = new Context(state.indented, col, type, null, state.context);
200 }
201
202 function popContext(state) {
203 var t = state.context.type;
204 if (t == ")" || t == "]" || t == "}")
205 state.indented = state.context.indented;
206 return state.context = state.context.prev;
207 }
208
209 // Interface
210
211 return {
212 startState: function (basecolumn) {
213 return {
214 tokenize: [tokenBase],
215 context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
216 indented: 0,
217 startOfLine: true,
218 lastToken: null
219 };
220 },
221
222 token: function (stream, state) {
223 var ctx = state.context;
224 if (stream.sol()) {
225 if (ctx.align == null) ctx.align = false;
226 state.indented = stream.indentation();
227 state.startOfLine = true;
228 // Automatic semicolon insertion
229 if (ctx.type == "statement" && !expectExpression(state.lastToken)) {
230 popContext(state);
231 ctx = state.context;
232 }
233 }
234 if (stream.eatSpace()) return null;
235 curPunc = null;
236 var style = state.tokenize[state.tokenize.length - 1](stream, state);
237 if (style == "comment") return style;
238 if (ctx.align == null) ctx.align = true;
239 if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
240 // Handle indentation for {x -> \n ... }
241 else if (curPunc == "->" && ctx.type == "statement" && ctx.prev.type == "}") {
242 popContext(state);
243 state.context.align = false;
244 }
245 else if (curPunc == "{") pushContext(state, stream.column(), "}");
246 else if (curPunc == "[") pushContext(state, stream.column(), "]");
247 else if (curPunc == "(") pushContext(state, stream.column(), ")");
248 else if (curPunc == "}") {
249 while (ctx.type == "statement") ctx = popContext(state);
250 if (ctx.type == "}") ctx = popContext(state);
251 while (ctx.type == "statement") ctx = popContext(state);
252 }
253 else if (curPunc == ctx.type) popContext(state);
254 else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
255 pushContext(state, stream.column(), "statement");
256 state.startOfLine = false;
257 state.lastToken = curPunc || style;
258 return style;
259 },
260
261 indent: function (state, textAfter) {
262 if (!state.tokenize[state.tokenize.length - 1].isBase) return 0;
263 var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
264 if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev;
265 var closing = firstChar == ctx.type;
266 if (ctx.type == "statement") {
267 return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
268 }
269 else if (ctx.align) return ctx.column + (closing ? 0 : 1);
270 else return ctx.indented + (closing ? 0 : config.indentUnit);
271 },
272
273 closeBrackets: {triples: "'\""},
274 electricChars: "{}",
275 blockCommentStart: "/*",
276 blockCommentEnd: "*/",
277 lineComment: "//"
278 };
279 });
280
281 CodeMirror.defineMIME("text/x-kotlin", "kotlin");
282
283 });
4949 startState: function(){
5050 return {
5151 next: 'start',
52 lastToken: null
52 lastToken: {style: null, indent: 0, content: ""}
5353 };
5454 },
5555 token: function(stream, state){
349349 });
350350 </script>
351351
352 <p>You might want to use the <a href="../gfm/index.html">Github-Flavored Markdown mode</a> instead, which adds support for fenced code blocks and a few other things.</p>
353
352354 <p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
353
355
354356 <p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
355357
356358 <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#markdown_*">normal</a>, <a href="../../test/index.html#verbose,markdown_*">verbose</a>.</p>
1212
1313 CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
1414
15 var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
16 var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
15 var htmlMode = CodeMirror.getMode(cmCfg, "text/html");
16 var htmlModeMissing = htmlMode.name == "null"
1717
1818 function getMode(name) {
1919 if (CodeMirror.findModeByName) {
3838 if (modeCfg.underscoresBreakWords === undefined)
3939 modeCfg.underscoresBreakWords = true;
4040
41 // Turn on fenced code blocks? ("```" to start/end)
42 if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
41 // Use `fencedCodeBlocks` to configure fenced code blocks. false to
42 // disable, string to specify a precise regexp that the fence should
43 // match, and true to allow three or more backticks or tildes (as
44 // per CommonMark).
4345
4446 // Turn on task lists? ("- [ ] " and "- [x] ")
4547 if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
4850 if (modeCfg.strikethrough === undefined)
4951 modeCfg.strikethrough = false;
5052
51 var codeDepth = 0;
52
53 var header = 'header'
54 , code = 'comment'
55 , quote = 'quote'
56 , list1 = 'variable-2'
57 , list2 = 'variable-3'
58 , list3 = 'keyword'
59 , hr = 'hr'
60 , image = 'tag'
61 , formatting = 'formatting'
62 , linkinline = 'link'
63 , linkemail = 'link'
64 , linktext = 'link'
65 , linkhref = 'string'
66 , em = 'em'
67 , strong = 'strong'
68 , strikethrough = 'strikethrough';
53 // Allow token types to be overridden by user-provided token types.
54 if (modeCfg.tokenTypeOverrides === undefined)
55 modeCfg.tokenTypeOverrides = {};
56
57 var tokenTypes = {
58 header: "header",
59 code: "comment",
60 quote: "quote",
61 list1: "variable-2",
62 list2: "variable-3",
63 list3: "keyword",
64 hr: "hr",
65 image: "image",
66 imageAltText: "image-alt-text",
67 imageMarker: "image-marker",
68 formatting: "formatting",
69 linkInline: "link",
70 linkEmail: "link",
71 linkText: "link",
72 linkHref: "string",
73 em: "em",
74 strong: "strong",
75 strikethrough: "strikethrough"
76 };
77
78 for (var tokenType in tokenTypes) {
79 if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) {
80 tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
81 }
82 }
6983
7084 var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
7185 , ulRE = /^[*\-+]\s+/
7286 , olRE = /^[0-9]+([.)])\s+/
7387 , taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
74 , atxHeaderRE = /^(#+)(?: |$)/
88 , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
7589 , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
76 , textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
90 , textRE = /^[^#!\[\]*_\\<>` "'(~]+/
91 , fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) +
92 ")[ \\t]*([\\w+#\-]*)");
7793
7894 function switchInline(stream, state, f) {
7995 state.f = state.inline = f;
85101 return f(stream, state);
86102 }
87103
104 function lineIsEmpty(line) {
105 return !line || !/\S/.test(line.string)
106 }
88107
89108 // Blocks
90109
101120 state.quote = 0;
102121 // Reset state.indentedCode
103122 state.indentedCode = false;
104 if (!htmlFound && state.f == htmlBlock) {
123 if (htmlModeMissing && state.f == htmlBlock) {
105124 state.f = inlineNormal;
106125 state.block = blockNormal;
107126 }
109128 state.trailingSpace = 0;
110129 state.trailingSpaceNewLine = false;
111130 // Mark this line as blank
112 state.thisLineHasContent = false;
131 state.prevLine = state.thisLine
132 state.thisLine = null
113133 return null;
114134 }
115135
130150 state.list = null;
131151 } else if (state.indentation > 0) {
132152 state.list = null;
133 state.listDepth = Math.floor(state.indentation / 4);
134153 } else { // No longer a list
135154 state.list = false;
136 state.listDepth = 0;
137155 }
138156 }
139157
140158 var match = null;
141159 if (state.indentationDiff >= 4) {
142160 stream.skipToEnd();
143 if (prevLineIsIndentedCode || !state.prevLineHasContent) {
161 if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) {
144162 state.indentation -= 4;
145163 state.indentedCode = true;
146 return code;
164 return tokenTypes.code;
147165 } else {
148166 return null;
149167 }
154172 if (modeCfg.highlightFormatting) state.formatting = "header";
155173 state.f = state.inline;
156174 return getType(state);
157 } else if (state.prevLineHasContent && !state.quote && !prevLineIsList && !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
175 } else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList &&
176 !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
158177 state.header = match[0].charAt(0) == '=' ? 1 : 2;
159178 if (modeCfg.highlightFormatting) state.formatting = "header";
160179 state.f = state.inline;
168187 return switchInline(stream, state, footnoteLink);
169188 } else if (stream.match(hrRE, true)) {
170189 state.hr = true;
171 return hr;
172 } else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
190 return tokenTypes.hr;
191 } else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
173192 var listType = null;
174193 if (stream.match(ulRE, true)) {
175194 listType = 'ul';
177196 stream.match(olRE, true);
178197 listType = 'ol';
179198 }
180 state.indentation += 4;
199 state.indentation = stream.column() + stream.current().length;
181200 state.list = true;
182 state.listDepth++;
201
202 // While this list item's marker's indentation
203 // is less than the deepest list item's content's indentation,
204 // pop the deepest list item indentation off the stack.
205 while (state.listStack && stream.column() < state.listStack[state.listStack.length - 1]) {
206 state.listStack.pop();
207 }
208
209 // Add this list item's content's indentation to the stack
210 state.listStack.push(state.indentation);
211
183212 if (modeCfg.taskLists && stream.match(taskListRE, false)) {
184213 state.taskList = true;
185214 }
186215 state.f = state.inline;
187216 if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
188217 return getType(state);
189 } else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) {
218 } else if (modeCfg.fencedCodeBlocks && (match = stream.match(fencedCodeRE, true))) {
219 state.fencedChars = match[1]
190220 // try switching mode
191 state.localMode = getMode(RegExp.$1);
192 if (state.localMode) state.localState = state.localMode.startState();
221 state.localMode = getMode(match[2]);
222 if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
193223 state.f = state.block = local;
194224 if (modeCfg.highlightFormatting) state.formatting = "code-block";
195 state.code = true;
225 state.code = -1
196226 return getType(state);
197227 }
198228
201231
202232 function htmlBlock(stream, state) {
203233 var style = htmlMode.token(stream, state.htmlState);
204 if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) ||
205 (state.md_inside && stream.current().indexOf(">") > -1)) {
206 state.f = inlineNormal;
207 state.block = blockNormal;
208 state.htmlState = null;
234 if (!htmlModeMissing) {
235 var inner = CodeMirror.innerMode(htmlMode, state.htmlState)
236 if ((inner.mode.name == "xml" && inner.state.tagStart === null &&
237 (!inner.state.context && inner.state.tokenize.isInText)) ||
238 (state.md_inside && stream.current().indexOf(">") > -1)) {
239 state.f = inlineNormal;
240 state.block = blockNormal;
241 state.htmlState = null;
242 }
209243 }
210244 return style;
211245 }
212246
213247 function local(stream, state) {
214 if (stream.sol() && stream.match("```", false)) {
248 if (state.fencedChars && stream.match(state.fencedChars, false)) {
215249 state.localMode = state.localState = null;
216250 state.f = state.block = leavingLocal;
217251 return null;
219253 return state.localMode.token(stream, state.localState);
220254 } else {
221255 stream.skipToEnd();
222 return code;
256 return tokenTypes.code;
223257 }
224258 }
225259
226260 function leavingLocal(stream, state) {
227 stream.match("```");
261 stream.match(state.fencedChars);
228262 state.block = blockNormal;
229263 state.f = inlineNormal;
264 state.fencedChars = null;
230265 if (modeCfg.highlightFormatting) state.formatting = "code-block";
231 state.code = true;
266 state.code = 1
232267 var returnType = getType(state);
233 state.code = false;
268 state.code = 0
234269 return returnType;
235270 }
236271
239274 var styles = [];
240275
241276 if (state.formatting) {
242 styles.push(formatting);
277 styles.push(tokenTypes.formatting);
243278
244279 if (typeof state.formatting === "string") state.formatting = [state.formatting];
245280
246281 for (var i = 0; i < state.formatting.length; i++) {
247 styles.push(formatting + "-" + state.formatting[i]);
282 styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
248283
249284 if (state.formatting[i] === "header") {
250 styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
285 styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
251286 }
252287
253288 // Add `formatting-quote` and `formatting-quote-#` for blockquotes
254289 // Add `error` instead if the maximum blockquote nesting depth is passed
255290 if (state.formatting[i] === "quote") {
256291 if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
257 styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote);
292 styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
258293 } else {
259294 styles.push("error");
260295 }
272307 }
273308
274309 if (state.linkHref) {
275 styles.push(linkhref, "url");
310 styles.push(tokenTypes.linkHref, "url");
276311 } else { // Only apply inline styles to non-url text
277 if (state.strong) { styles.push(strong); }
278 if (state.em) { styles.push(em); }
279 if (state.strikethrough) { styles.push(strikethrough); }
280
281 if (state.linkText) { styles.push(linktext); }
282
283 if (state.code) { styles.push(code); }
284 }
285
286 if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
312 if (state.strong) { styles.push(tokenTypes.strong); }
313 if (state.em) { styles.push(tokenTypes.em); }
314 if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
315 if (state.linkText) { styles.push(tokenTypes.linkText); }
316 if (state.code) { styles.push(tokenTypes.code); }
317 if (state.image) { styles.push(tokenTypes.image); }
318 if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
319 if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
320 }
321
322 if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
287323
288324 if (state.quote) {
289 styles.push(quote);
325 styles.push(tokenTypes.quote);
290326
291327 // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
292328 if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
293 styles.push(quote + "-" + state.quote);
329 styles.push(tokenTypes.quote + "-" + state.quote);
294330 } else {
295 styles.push(quote + "-" + modeCfg.maxBlockquoteDepth);
331 styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
296332 }
297333 }
298334
299335 if (state.list !== false) {
300 var listMod = (state.listDepth - 1) % 3;
336 var listMod = (state.listStack.length - 1) % 3;
301337 if (!listMod) {
302 styles.push(list1);
338 styles.push(tokenTypes.list1);
303339 } else if (listMod === 1) {
304 styles.push(list2);
340 styles.push(tokenTypes.list2);
305341 } else {
306 styles.push(list3);
342 styles.push(tokenTypes.list3);
307343 }
308344 }
309345
355391
356392 var ch = stream.next();
357393
358 if (ch === '\\') {
359 stream.next();
360 if (modeCfg.highlightFormatting) {
361 var type = getType(state);
362 return type ? type + " formatting-escape" : "formatting-escape";
363 }
364 }
365
366394 // Matches link titles present on next line
367395 if (state.linkTitle) {
368396 state.linkTitle = false;
373401 matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
374402 var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
375403 if (stream.match(new RegExp(regex), true)) {
376 return linkhref;
404 return tokenTypes.linkHref;
377405 }
378406 }
379407
381409 if (ch === '`') {
382410 var previousFormatting = state.formatting;
383411 if (modeCfg.highlightFormatting) state.formatting = "code";
384 var t = getType(state);
385 var before = stream.pos;
386412 stream.eatWhile('`');
387 var difference = 1 + stream.pos - before;
388 if (!state.code) {
389 codeDepth = difference;
390 state.code = true;
391 return getType(state);
413 var count = stream.current().length
414 if (state.code == 0) {
415 state.code = count
416 return getType(state)
417 } else if (count == state.code) { // Must be exact
418 var t = getType(state)
419 state.code = 0
420 return t
392421 } else {
393 if (difference === codeDepth) { // Must be exact
394 state.code = false;
395 return t;
396 }
397 state.formatting = previousFormatting;
398 return getType(state);
422 state.formatting = previousFormatting
423 return getType(state)
399424 }
400425 } else if (state.code) {
401426 return getType(state);
402427 }
403428
429 if (ch === '\\') {
430 stream.next();
431 if (modeCfg.highlightFormatting) {
432 var type = getType(state);
433 var formattingEscape = tokenTypes.formatting + "-escape";
434 return type ? type + " " + formattingEscape : formattingEscape;
435 }
436 }
437
404438 if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
405 stream.match(/\[[^\]]*\]/);
439 state.imageMarker = true;
440 state.image = true;
441 if (modeCfg.highlightFormatting) state.formatting = "image";
442 return getType(state);
443 }
444
445 if (ch === '[' && state.imageMarker) {
446 state.imageMarker = false;
447 state.imageAltText = true
448 if (modeCfg.highlightFormatting) state.formatting = "image";
449 return getType(state);
450 }
451
452 if (ch === ']' && state.imageAltText) {
453 if (modeCfg.highlightFormatting) state.formatting = "image";
454 var type = getType(state);
455 state.imageAltText = false;
456 state.image = false;
406457 state.inline = state.f = linkHref;
407 return image;
408 }
409
410 if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) {
458 return type;
459 }
460
461 if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && !state.image) {
411462 state.linkText = true;
412463 if (modeCfg.highlightFormatting) state.formatting = "link";
413464 return getType(state);
414465 }
415466
416 if (ch === ']' && state.linkText && stream.match(/\(.*\)| ?\[.*\]/, false)) {
467 if (ch === ']' && state.linkText && stream.match(/\(.*?\)| ?\[.*?\]/, false)) {
417468 if (modeCfg.highlightFormatting) state.formatting = "link";
418469 var type = getType(state);
419470 state.linkText = false;
430481 } else {
431482 type = "";
432483 }
433 return type + linkinline;
484 return type + tokenTypes.linkInline;
434485 }
435486
436487 if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
442493 } else {
443494 type = "";
444495 }
445 return type + linkemail;
446 }
447
448 if (ch === '<' && stream.match(/^\w/, false)) {
449 if (stream.string.indexOf(">") != -1) {
450 var atts = stream.string.substring(1,stream.string.indexOf(">"));
451 if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
452 state.md_inside = true;
453 }
496 return type + tokenTypes.linkEmail;
497 }
498
499 if (ch === '<' && stream.match(/^(!--|\w)/, false)) {
500 var end = stream.string.indexOf(">", stream.pos);
501 if (end != -1) {
502 var atts = stream.string.substring(stream.start, end);
503 if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true;
454504 }
455505 stream.backUp(1);
456506 state.htmlState = CodeMirror.startState(htmlMode);
552602 } else {
553603 type = "";
554604 }
555 return type + linkinline;
605 return type + tokenTypes.linkInline;
556606 }
557607
558608 stream.match(/^[^>]+/, true);
559609
560 return linkinline;
610 return tokenTypes.linkInline;
561611 }
562612
563613 function linkHref(stream, state) {
567617 }
568618 var ch = stream.next();
569619 if (ch === '(' || ch === '[') {
570 state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
620 state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]", 0);
571621 if (modeCfg.highlightFormatting) state.formatting = "link-string";
572622 state.linkHref = true;
573623 return getType(state);
574624 }
575625 return 'error';
626 }
627
628 var linkRE = {
629 ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,
630 "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\\]]|\\.)*\])*?(?=\])/
576631 }
577632
578633 function getLinkHrefInside(endChar) {
587642 return returnState;
588643 }
589644
590 if (stream.match(inlineRE(endChar), true)) {
591 stream.backUp(1);
592 }
593
645 stream.match(linkRE[endChar])
594646 state.linkHref = true;
595647 return getType(state);
596648 };
597649 }
598650
599651 function footnoteLink(stream, state) {
600 if (stream.match(/^[^\]]*\]:/, false)) {
652 if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
601653 state.f = footnoteLinkInside;
602654 stream.next(); // Consume [
603655 if (modeCfg.highlightFormatting) state.formatting = "link";
616668 return returnType;
617669 }
618670
619 stream.match(/^[^\]]+/, true);
620
621 return linktext;
671 stream.match(/^([^\]\\]|\\.)+/, true);
672
673 return tokenTypes.linkText;
622674 }
623675
624676 function footnoteUrl(stream, state) {
635687 stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
636688 }
637689 state.f = state.inline = inlineNormal;
638 return linkhref + " url";
639 }
640
641 var savedInlineRE = [];
642 function inlineRE(endChar) {
643 if (!savedInlineRE[endChar]) {
644 // Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741)
645 endChar = (endChar+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
646 // Match any non-endChar, escaped character, as well as the closing
647 // endChar.
648 savedInlineRE[endChar] = new RegExp('^(?:[^\\\\]|\\\\.)*?(' + endChar + ')');
649 }
650 return savedInlineRE[endChar];
690 return tokenTypes.linkHref + " url";
651691 }
652692
653693 var mode = {
655695 return {
656696 f: blockNormal,
657697
658 prevLineHasContent: false,
659 thisLineHasContent: false,
698 prevLine: null,
699 thisLine: null,
660700
661701 block: blockNormal,
662702 htmlState: null,
669709 linkText: false,
670710 linkHref: false,
671711 linkTitle: false,
712 code: 0,
672713 em: false,
673714 strong: false,
674715 header: 0,
675716 hr: false,
676717 taskList: false,
677718 list: false,
678 listDepth: 0,
719 listStack: [],
679720 quote: 0,
680721 trailingSpace: 0,
681722 trailingSpaceNewLine: false,
682 strikethrough: false
723 strikethrough: false,
724 fencedChars: null
683725 };
684726 },
685727
687729 return {
688730 f: s.f,
689731
690 prevLineHasContent: s.prevLineHasContent,
691 thisLineHasContent: s.thisLineHasContent,
732 prevLine: s.prevLine,
733 thisLine: s.thisLine,
692734
693735 block: s.block,
694736 htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
701743 text: s.text,
702744 formatting: false,
703745 linkTitle: s.linkTitle,
746 code: s.code,
704747 em: s.em,
705748 strong: s.strong,
706749 strikethrough: s.strikethrough,
708751 hr: s.hr,
709752 taskList: s.taskList,
710753 list: s.list,
711 listDepth: s.listDepth,
754 listStack: s.listStack.slice(0),
712755 quote: s.quote,
713756 indentedCode: s.indentedCode,
714757 trailingSpace: s.trailingSpace,
715758 trailingSpaceNewLine: s.trailingSpaceNewLine,
716 md_inside: s.md_inside
759 md_inside: s.md_inside,
760 fencedChars: s.fencedChars
717761 };
718762 },
719763
722766 // Reset state.formatting
723767 state.formatting = false;
724768
725 if (stream.sol()) {
726 var forceBlankLine = !!state.header || state.hr;
769 if (stream != state.thisLine) {
770 var forceBlankLine = state.header || state.hr;
727771
728772 // Reset state.header and state.hr
729773 state.header = 0;
730774 state.hr = false;
731775
732776 if (stream.match(/^\s*$/, true) || forceBlankLine) {
733 state.prevLineHasContent = false;
734777 blankLine(state);
735 return forceBlankLine ? this.token(stream, state) : null;
736 } else {
737 state.prevLineHasContent = state.thisLineHasContent;
738 state.thisLineHasContent = true;
778 if (!forceBlankLine) return null
779 state.prevLine = null
739780 }
781
782 state.prevLine = state.thisLine
783 state.thisLine = stream
740784
741785 // Reset state.taskList
742786 state.taskList = false;
743
744 // Reset state.code
745 state.code = false;
746787
747788 // Reset state.trailingSpace
748789 state.trailingSpace = 0;
750791
751792 state.f = state.block;
752793 var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
753 var difference = Math.floor((indentation - state.indentation) / 4) * 4;
754 if (difference > 4) difference = 4;
755 var adjustedIndentation = state.indentation + difference;
756 state.indentationDiff = adjustedIndentation - state.indentation;
757 state.indentation = adjustedIndentation;
794 state.indentationDiff = Math.min(indentation - state.indentation, 4);
795 state.indentation = state.indentation + state.indentationDiff;
758796 if (indentation > 0) return null;
759797 }
760798 return state.f(stream, state);
55 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
66 var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "markdown", highlightFormatting: true});
77 function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
8 var modeAtxNoSpace = CodeMirror.getMode({tabSize: 4}, {name: "markdown", allowAtxHeaderWithoutSpace: true});
9 function AtxNoSpaceTest(name) { test.mode(name, modeAtxNoSpace, Array.prototype.slice.call(arguments, 1)); }
10 var modeFenced = CodeMirror.getMode({tabSize: 4}, {name: "markdown", fencedCodeBlocks: true});
11 function FencedTest(name) { test.mode(name, modeFenced, Array.prototype.slice.call(arguments, 1)); }
12 var modeOverrideClasses = CodeMirror.getMode({tabsize: 4}, {
13 name: "markdown",
14 strikethrough: true,
15 tokenTypeOverrides: {
16 "header" : "override-header",
17 "code" : "override-code",
18 "quote" : "override-quote",
19 "list1" : "override-list1",
20 "list2" : "override-list2",
21 "list3" : "override-list3",
22 "hr" : "override-hr",
23 "image" : "override-image",
24 "imageAltText": "override-image-alt-text",
25 "imageMarker": "override-image-marker",
26 "linkInline" : "override-link-inline",
27 "linkEmail" : "override-link-email",
28 "linkText" : "override-link-text",
29 "linkHref" : "override-link-href",
30 "em" : "override-em",
31 "strong" : "override-strong",
32 "strikethrough" : "override-strikethrough"
33 }});
34 function TokenTypeOverrideTest(name) { test.mode(name, modeOverrideClasses, Array.prototype.slice.call(arguments, 1)); }
35 var modeFormattingOverride = CodeMirror.getMode({tabsize: 4}, {
36 name: "markdown",
37 highlightFormatting: true,
38 tokenTypeOverrides: {
39 "formatting" : "override-formatting"
40 }});
41 function FormatTokenTypeOverrideTest(name) { test.mode(name, modeFormattingOverride, Array.prototype.slice.call(arguments, 1)); }
42
843
944 FT("formatting_emAsterisk",
1045 "[em&formatting&formatting-em *][em foo][em&formatting&formatting-em *]");
5489
5590 FT("formatting_escape",
5691 "[formatting-escape \\*]");
92
93 FT("formatting_image",
94 "[formatting&formatting-image&image&image-marker !][formatting&formatting-image&image&image-alt-text&link [[][image&image-alt-text&link alt text][formatting&formatting-image&image&image-alt-text&link ]]][formatting&formatting-link-string&string&url (][url&string http://link.to/image.jpg][formatting&formatting-link-string&string&url )]");
5795
5896 MT("plainText",
5997 "foo");
109147 // Block code using single backtick (shouldn't work)
110148 MT("blockCodeSingleBacktick",
111149 "[comment `]",
112 "foo",
150 "[comment foo]",
113151 "[comment `]");
114152
115153 // Unclosed backticks
171209 // http://spec.commonmark.org/0.19/#example-25
172210 MT("noAtxH1WithoutSpace",
173211 "#5 bolt");
212
213 // CommonMark requires a space after # but most parsers don't
214 AtxNoSpaceTest("atxNoSpaceAllowed_H1NoSpace",
215 "[header&header-1 #foo]");
216
217 AtxNoSpaceTest("atxNoSpaceAllowed_H4NoSpace",
218 "[header&header-4 ####foo]");
219
220 AtxNoSpaceTest("atxNoSpaceAllowed_H1Space",
221 "[header&header-1 # foo]");
174222
175223 // Inline styles should be parsed inside headers
176224 MT("atxH1inline",
408456 "",
409457 "hello");
410458
459 MT("listCommonMarkIndentationCode",
460 "[variable-2 * Code blocks also affect]",
461 " [variable-3 * The next level starts where the contents start.]",
462 " [variable-3 * Anything less than that will keep the item on the same level.]",
463 " [variable-3 * Each list item can indent the first level further and further.]",
464 " [variable-3 * For the most part, this makes sense while writing a list.]",
465 " [keyword * This means two items with same indentation can be different levels.]",
466 " [keyword * Each level has an indent requirement that can change between items.]",
467 " [keyword * A list item that meets this will be part of the next level.]",
468 " [variable-3 * Otherwise, it will be part of the level where it does meet this.]",
469 " [variable-2 * World]");
470
411471 // Blockquote
412472 MT("blockquote",
413473 "[variable-2 * foo]",
497557 "",
498558 " [variable-3 * bar]",
499559 "",
500 " [variable-2 hello]"
560 " [variable-3 hello]"
501561 );
502562 MT("listNested",
503563 "[variable-2 * foo]",
504564 "",
505565 " [variable-3 * bar]",
506566 "",
507 " [variable-3 * foo]"
567 " [keyword * foo]"
508568 );
509569
510570 // Code followed by text
532592
533593 MT("hrDashLong",
534594 "[hr ---------------------------------------]");
595
596 //Images
597 MT("Images",
598 "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)]")
599
600 //Images with highlight alt text
601 MT("imageEm",
602 "[image&image-marker !][image&image-alt-text&link [[][image-alt-text&em&image&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
603
604 MT("imageStrong",
605 "[image&image-marker !][image&image-alt-text&link [[][image-alt-text&strong&image&link **alt text**][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
606
607 MT("imageEmStrong",
608 "[image&image-marker !][image&image-alt-text&link [[][image-alt-text&image&strong&link **][image&image-alt-text&em&strong&link *alt text**][image&image-alt-text&em&link *][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
535609
536610 // Inline link with title
537611 MT("linkTitle",
543617
544618 // Inline link with image
545619 MT("linkImage",
546 "[link [[][tag ![[foo]]][string&url (http://example.com/)][link ]]][string&url (http://example.com/)] bar");
620 "[link [[][link&image&image-marker !][link&image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)][link ]]][string&url (http://example.com/)] bar");
547621
548622 // Inline link with Em
549623 MT("linkEm",
559633
560634 // Image with title
561635 MT("imageTitle",
562 "[tag ![[foo]]][string&url (http://example.com/ \"bar\")] hello");
636 "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/ \"bar\")] hello");
563637
564638 // Image without title
565639 MT("imageNoTitle",
566 "[tag ![[foo]]][string&url (http://example.com/)] bar");
640 "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/)] bar");
567641
568642 // Image with asterisks
569643 MT("imageAsterisks",
570 "[tag ![[*foo*]]][string&url (http://example.com/)] bar");
644 "[image&image-marker !][image&image-alt-text&link [[ ][image&image-alt-text&em&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)] bar");
571645
572646 // Not a link. Should be normal text due to square brackets being used
573647 // regularly in text, especially in quoted material, and no space is allowed
591665 MT("linkReferenceEmStrong",
592666 "[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string&url [[bar]]] hello");
593667
594 // Reference-style links with optional space separator (per docuentation)
668 // Reference-style links with optional space separator (per documentation)
595669 // "You can optionally use a space to separate the sets of brackets"
596670 MT("linkReferenceSpace",
597671 "[link [[foo]]] [string&url [[bar]]] hello");
627701 MT("labelTitleSingleQuotes",
628702 "[link [[foo]]:] [string&url http://example.com/ 'bar']");
629703
630 MT("labelTitleParenthese",
704 MT("labelTitleParentheses",
631705 "[link [[foo]]:] [string&url http://example.com/ (bar)]");
632706
633707 MT("labelTitleInvalid",
644718 "[link [[foo]]:] [string&url http://example.com/]",
645719 "[string 'bar'] hello");
646720
647 MT("labelTitleNextParenthese",
721 MT("labelTitleNextParentheses",
648722 "[link [[foo]]:] [string&url http://example.com/]",
649723 "[string (bar)] hello");
650724
651725 MT("labelTitleNextMixed",
652726 "[link [[foo]]:] [string&url http://example.com/]",
653727 "(bar\" hello");
728
729 MT("labelEscape",
730 "[link [[foo \\]] ]]:] [string&url http://example.com/]");
731
732 MT("labelEscapeColon",
733 "[link [[foo \\]]: bar]]:] [string&url http://example.com/]");
734
735 MT("labelEscapeEnd",
736 "[[foo\\]]: http://example.com/");
654737
655738 MT("linkWeb",
656739 "[link <http://example.com/>] foo");
716799
717800 MT("emStrongMixed",
718801 "[em *foo][em&strong __bar_hello** world]");
802
803 MT("linkWithNestedParens",
804 "[link [[foo]]][string&url (bar(baz))]")
719805
720806 // These characters should be escaped:
721807 // \ backslash
759845 "\\",
760846 "[em *foo*]");
761847
848 // Class override tests
849 TokenTypeOverrideTest("overrideHeader1",
850 "[override-header&override-header-1 # Foo]");
851
852 TokenTypeOverrideTest("overrideHeader2",
853 "[override-header&override-header-2 ## Foo]");
854
855 TokenTypeOverrideTest("overrideHeader3",
856 "[override-header&override-header-3 ### Foo]");
857
858 TokenTypeOverrideTest("overrideHeader4",
859 "[override-header&override-header-4 #### Foo]");
860
861 TokenTypeOverrideTest("overrideHeader5",
862 "[override-header&override-header-5 ##### Foo]");
863
864 TokenTypeOverrideTest("overrideHeader6",
865 "[override-header&override-header-6 ###### Foo]");
866
867 TokenTypeOverrideTest("overrideCode",
868 "[override-code `foo`]");
869
870 TokenTypeOverrideTest("overrideCodeBlock",
871 "[override-code ```]",
872 "[override-code foo]",
873 "[override-code ```]");
874
875 TokenTypeOverrideTest("overrideQuote",
876 "[override-quote&override-quote-1 > foo]",
877 "[override-quote&override-quote-1 > bar]");
878
879 TokenTypeOverrideTest("overrideQuoteNested",
880 "[override-quote&override-quote-1 > foo]",
881 "[override-quote&override-quote-1 >][override-quote&override-quote-2 > bar]",
882 "[override-quote&override-quote-1 >][override-quote&override-quote-2 >][override-quote&override-quote-3 > baz]");
883
884 TokenTypeOverrideTest("overrideLists",
885 "[override-list1 - foo]",
886 "",
887 " [override-list2 + bar]",
888 "",
889 " [override-list3 * baz]",
890 "",
891 " [override-list1 1. qux]",
892 "",
893 " [override-list2 - quux]");
894
895 TokenTypeOverrideTest("overrideHr",
896 "[override-hr * * *]");
897
898 TokenTypeOverrideTest("overrideImage",
899 "[override-image&override-image-marker !][override-image&override-image-alt-text&link [[alt text]]][override-link-href&url (http://link.to/image.jpg)]");
900
901 TokenTypeOverrideTest("overrideLinkText",
902 "[override-link-text [[foo]]][override-link-href&url (http://example.com)]");
903
904 TokenTypeOverrideTest("overrideLinkEmailAndInline",
905 "[override-link-email <][override-link-inline foo@example.com>]");
906
907 TokenTypeOverrideTest("overrideEm",
908 "[override-em *foo*]");
909
910 TokenTypeOverrideTest("overrideStrong",
911 "[override-strong **foo**]");
912
913 TokenTypeOverrideTest("overrideStrikethrough",
914 "[override-strikethrough ~~foo~~]");
915
916 FormatTokenTypeOverrideTest("overrideFormatting",
917 "[override-formatting-escape \\*]");
762918
763919 // Tests to make sure GFM-specific things aren't getting through
764920
765921 MT("taskList",
766922 "[variable-2 * [ ]] bar]");
767923
768 MT("fencedCodeBlocks",
924 MT("noFencedCodeBlocks",
925 "~~~",
926 "foo",
927 "~~~");
928
929 FencedTest("fencedCodeBlocks",
769930 "[comment ```]",
770 "foo",
771 "[comment ```]");
931 "[comment foo]",
932 "[comment ```]",
933 "bar");
934
935 FencedTest("fencedCodeBlocksMultipleChars",
936 "[comment `````]",
937 "[comment foo]",
938 "[comment ```]",
939 "[comment foo]",
940 "[comment `````]",
941 "bar");
942
943 FencedTest("fencedCodeBlocksTildes",
944 "[comment ~~~]",
945 "[comment foo]",
946 "[comment ~~~]",
947 "bar");
948
949 FencedTest("fencedCodeBlocksTildesMultipleChars",
950 "[comment ~~~~~]",
951 "[comment ~~~]",
952 "[comment foo]",
953 "[comment ~~~~~]",
954 "bar");
955
956 FencedTest("fencedCodeBlocksMultipleChars",
957 "[comment `````]",
958 "[comment foo]",
959 "[comment ```]",
960 "[comment foo]",
961 "[comment `````]",
962 "bar");
963
964 FencedTest("fencedCodeBlocksMixed",
965 "[comment ~~~]",
966 "[comment ```]",
967 "[comment foo]",
968 "[comment ~~~]",
969 "bar");
772970
773971 // Tests that require XML mode
774972
125125 }
126126
127127 // everything else is an error
128 stream.next(); // advance the stream.
128129 return 'error';
129130 }
130131
0 <!doctype html>
1
2 <title>CodeMirror: mbox mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="mbox.js"></script>
9 <style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
10 <div id=nav>
11 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
12
13 <ul>
14 <li><a href="../../index.html">Home</a>
15 <li><a href="../../doc/manual.html">Manual</a>
16 <li><a href="https://github.com/codemirror/codemirror">Code</a>
17 </ul>
18 <ul>
19 <li><a href="../index.html">Language modes</a>
20 <li><a class=active href="#">mbox</a>
21 </ul>
22 </div>
23
24 <article>
25 <h2>mbox mode</h2>
26 <form><textarea id="code" name="code">
27 From timothygu99@gmail.com Sun Apr 17 01:40:43 2016
28 From: Timothy Gu &lt;timothygu99@gmail.com&gt;
29 Date: Sat, 16 Apr 2016 18:40:43 -0700
30 Subject: mbox mode
31 Message-ID: &lt;Z8d+bTT50U/az94FZnyPkDjZmW0=@gmail.com&gt;
32
33 mbox mode is working!
34
35 Timothy
36 </textarea></form>
37 <script>
38 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
39 </script>
40
41 <p><strong>MIME types defined:</strong> <code>application/mbox</code>.</p>
42
43 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 var rfc2822 = [
14 "From", "Sender", "Reply-To", "To", "Cc", "Bcc", "Message-ID",
15 "In-Reply-To", "References", "Resent-From", "Resent-Sender", "Resent-To",
16 "Resent-Cc", "Resent-Bcc", "Resent-Message-ID", "Return-Path", "Received"
17 ];
18 var rfc2822NoEmail = [
19 "Date", "Subject", "Comments", "Keywords", "Resent-Date"
20 ];
21
22 CodeMirror.registerHelper("hintWords", "mbox", rfc2822.concat(rfc2822NoEmail));
23
24 var whitespace = /^[ \t]/;
25 var separator = /^From /; // See RFC 4155
26 var rfc2822Header = new RegExp("^(" + rfc2822.join("|") + "): ");
27 var rfc2822HeaderNoEmail = new RegExp("^(" + rfc2822NoEmail.join("|") + "): ");
28 var header = /^[^:]+:/; // Optional fields defined in RFC 2822
29 var email = /^[^ ]+@[^ ]+/;
30 var untilEmail = /^.*?(?=[^ ]+?@[^ ]+)/;
31 var bracketedEmail = /^<.*?>/;
32 var untilBracketedEmail = /^.*?(?=<.*>)/;
33
34 function styleForHeader(header) {
35 if (header === "Subject") return "header";
36 return "string";
37 }
38
39 function readToken(stream, state) {
40 if (stream.sol()) {
41 // From last line
42 state.inSeparator = false;
43 if (state.inHeader && stream.match(whitespace)) {
44 // Header folding
45 return null;
46 } else {
47 state.inHeader = false;
48 state.header = null;
49 }
50
51 if (stream.match(separator)) {
52 state.inHeaders = true;
53 state.inSeparator = true;
54 return "atom";
55 }
56
57 var match;
58 var emailPermitted = false;
59 if ((match = stream.match(rfc2822HeaderNoEmail)) ||
60 (emailPermitted = true) && (match = stream.match(rfc2822Header))) {
61 state.inHeaders = true;
62 state.inHeader = true;
63 state.emailPermitted = emailPermitted;
64 state.header = match[1];
65 return "atom";
66 }
67
68 // Use vim's heuristics: recognize custom headers only if the line is in a
69 // block of legitimate headers.
70 if (state.inHeaders && (match = stream.match(header))) {
71 state.inHeader = true;
72 state.emailPermitted = true;
73 state.header = match[1];
74 return "atom";
75 }
76
77 state.inHeaders = false;
78 stream.skipToEnd();
79 return null;
80 }
81
82 if (state.inSeparator) {
83 if (stream.match(email)) return "link";
84 if (stream.match(untilEmail)) return "atom";
85 stream.skipToEnd();
86 return "atom";
87 }
88
89 if (state.inHeader) {
90 var style = styleForHeader(state.header);
91
92 if (state.emailPermitted) {
93 if (stream.match(bracketedEmail)) return style + " link";
94 if (stream.match(untilBracketedEmail)) return style;
95 }
96 stream.skipToEnd();
97 return style;
98 }
99
100 stream.skipToEnd();
101 return null;
102 };
103
104 CodeMirror.defineMode("mbox", function() {
105 return {
106 startState: function() {
107 return {
108 // Is in a mbox separator
109 inSeparator: false,
110 // Is in a mail header
111 inHeader: false,
112 // If bracketed email is permitted. Only applicable when inHeader
113 emailPermitted: false,
114 // Name of current header
115 header: null,
116 // Is in a region of mail headers
117 inHeaders: false
118 };
119 },
120 token: readToken,
121 blankLine: function(state) {
122 state.inHeaders = state.inSeparator = state.inHeader = false;
123 }
124 };
125 });
126
127 CodeMirror.defineMIME("application/mbox", "mbox");
128 });
1313 CodeMirror.modeInfo = [
1414 {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
1515 {name: "PGP", mimes: ["application/pgp", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["pgp"]},
16 {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn, asn1"]},
16 {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]},
1717 {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i},
18 {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
1819 {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]},
1920 {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
2021 {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
2122 {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
22 {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]},
23 {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
24 {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
25 {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
2326 {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
2427 {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
2528 {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
2629 {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
2730 {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
31 {name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
2832 {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
2933 {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
3034 {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
3640 {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
3741 {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
3842 {name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
43 {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
3944 {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
4045 {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
4146 {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
4247 {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
4348 {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
4449 {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
50 {name: "FCL", mime: "text/x-fcl", mode: "fcl"},
4551 {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
4652 {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
4753 {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
4955 {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
5056 {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
5157 {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
52 {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]},
58 {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
5359 {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
5460 {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
61 {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
5562 {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
5663 {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
5764 {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
5865 {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
5966 {name: "HTTP", mime: "message/http", mode: "http"},
6067 {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
61 {name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]},
68 {name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
6269 {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
6370 {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
6471 {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
6572 mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
6673 {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
6774 {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
75 {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
6876 {name: "Jinja2", mime: "null", mode: "jinja2"},
6977 {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
70 {name: "Kotlin", mime: "text/x-kotlin", mode: "kotlin", ext: ["kt"]},
78 {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
7179 {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
7280 {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
7381 {name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
7684 {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
7785 {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]},
7886 {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
79 {name: "MUMPS", mime: "text/x-mumps", mode: "mumps"},
87 {name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]},
8088 {name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
89 {name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]},
8190 {name: "MySQL", mime: "text/x-mysql", mode: "sql"},
8291 {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
92 {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
8393 {name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]},
84 {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"]},
94 {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"], alias: ["objective-c", "objc"]},
8595 {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
8696 {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
97 {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]},
8798 {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
8899 {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]},
89100 {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
91102 {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
92103 {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
93104 {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
105 {name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
94106 {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
95 {name: "Python", mime: "text/x-python", mode: "python", ext: ["py", "pyw"]},
107 {name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
108 {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/},
96109 {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
97110 {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
98111 {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"], alias: ["rscript"]},
101114 {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
102115 {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
103116 {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
117 {name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]},
104118 {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
105119 {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
106120 {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
107121 {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
108 {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"]},
122 {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/},
109123 {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]},
110124 {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]},
111125 {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
115129 {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
116130 {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]},
117131 {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
132 {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
118133 {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
119 {name: "MariaDB", mime: "text/x-mariadb", mode: "sql"},
120134 {name: "sTeX", mime: "text/x-stex", mode: "stex"},
121135 {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]},
122136 {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
126140 {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
127141 {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
128142 {name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
129 {name: "troff", mime: "troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]},
143 {name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]},
130144 {name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]},
131145 {name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]},
132146 {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
133147 {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
134148 {name: "Twig", mime: "text/x-twig", mode: "twig"},
149 {name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]},
135150 {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
136151 {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]},
137152 {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
138153 {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
154 {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]},
139155 {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]},
140156 {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
157 {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]},
141158 {name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]},
142 {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}
159 {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
160 {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
161 {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
162 {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
143163 ];
144164 // Ensure all modes have a mime property for backwards compatibility
145165 for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
0 <!doctype html>
1
2 <title>CodeMirror: MscGen mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="mscgen.js"></script>
9 <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <div id=nav>
11 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
12 <ul>
13 <li><a href="../../index.html">Home</a>
14 <li><a href="../../doc/manual.html">Manual</a>
15 <li><a href="https://github.com/codemirror/codemirror">Code</a>
16 </ul>
17 <ul>
18 <li><a href="../index.html">Language modes</a>
19 <li><a class=active href="#">MscGen</a>
20 </ul>
21 </div>
22
23 <article>
24 <h2>MscGen mode</h2>
25
26 <div><textarea id="mscgen-code">
27 # Sample mscgen program
28 # See http://www.mcternan.me.uk/mscgen or
29 # https://sverweij.github.io/mscgen_js for more samples
30 msc {
31 # options
32 hscale="1.2";
33
34 # entities/ lifelines
35 a [label="Entity A"],
36 b [label="Entity B", linecolor="red", arclinecolor="red", textbgcolor="pink"],
37 c [label="Entity C"];
38
39 # arcs/ messages
40 a => c [label="doSomething(args)"];
41 b => c [label="doSomething(args)"];
42 c >> * [label="everyone asked me", arcskip="1"];
43 c =>> c [label="doing something"];
44 c -x * [label="report back", arcskip="1"];
45 |||;
46 --- [label="shows's over, however ..."];
47 b => a [label="did you see c doing something?"];
48 a -> b [label="nope"];
49 b :> a [label="shall we ask again?"];
50 a => b [label="naah"];
51 ...;
52 }
53 </textarea></div>
54
55 <h2>Xù mode</h2>
56
57 <div><textarea id="xu-code">
58 # Xù - expansions to MscGen to support inline expressions
59 # https://github.com/sverweij/mscgen_js/blob/master/wikum/xu.md
60 # More samples: https://sverweij.github.io/mscgen_js
61 msc {
62 hscale="0.8",
63 width="700";
64
65 a,
66 b [label="change store"],
67 c,
68 d [label="necro queue"],
69 e [label="natalis queue"],
70 f;
71
72 a =>> b [label="get change list()"];
73 a alt f [label="changes found"] { /* alt is a xu specific keyword*/
74 b >> a [label="list of changes"];
75 a =>> c [label="cull old stuff (list of changes)"];
76 b loop e [label="for each change"] { // loop is xu specific as well...
77 /*
78 * Interesting stuff happens.
79 */
80 c =>> b [label="get change()"];
81 b >> c [label="change"];
82 c alt e [label="change too old"] {
83 c =>> d [label="queue(change)"];
84 --- [label="change newer than latest run"];
85 c =>> e [label="queue(change)"];
86 --- [label="all other cases"];
87 ||| [label="leave well alone"];
88 };
89 };
90
91 c >> a [label="done
92 processing"];
93
94 /* shucks! nothing found ...*/
95 --- [label="nothing found"];
96 b >> a [label="nothing"];
97 a note a [label="silent exit"];
98 };
99 }
100 </textarea></div>
101
102 <h2>MsGenny mode</h2>
103 <div><textarea id="msgenny-code">
104 # MsGenny - simplified version of MscGen / Xù
105 # https://github.com/sverweij/mscgen_js/blob/master/wikum/msgenny.md
106 # More samples: https://sverweij.github.io/mscgen_js
107 a -> b : a -> b (signal);
108 a => b : a => b (method);
109 b >> a : b >> a (return value);
110 a =>> b : a =>> b (callback);
111 a -x b : a -x b (lost);
112 a :> b : a :> b (emphasis);
113 a .. b : a .. b (dotted);
114 a -- b : "a -- b straight line";
115 a note a : a note a\n(note),
116 b box b : b box b\n(action);
117 a rbox a : a rbox a\n(reference),
118 b abox b : b abox b\n(state/ condition);
119 ||| : ||| (empty row);
120 ... : ... (omitted row);
121 --- : --- (comment);
122 </textarea></div>
123
124 <p>
125 Simple mode for highlighting MscGen and two derived sequence
126 chart languages.
127 </p>
128
129 <script>
130 var mscgenEditor = CodeMirror.fromTextArea(document.getElementById("mscgen-code"), {
131 lineNumbers: true,
132 mode: "text/x-mscgen",
133 });
134 var xuEditor = CodeMirror.fromTextArea(document.getElementById("xu-code"), {
135 lineNumbers: true,
136 mode: "text/x-xu",
137 });
138 var msgennyEditor = CodeMirror.fromTextArea(document.getElementById("msgenny-code"), {
139 lineNumbers: true,
140 mode: "text/x-msgenny",
141 });
142 </script>
143
144 <p><strong>MIME types defined:</strong>
145 <code>text/x-mscgen</code>
146 <code>text/x-xu</code>
147 <code>text/x-msgenny</code>
148 </p>
149
150 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 // mode(s) for the sequence chart dsl's mscgen, xù and msgenny
4 // For more information on mscgen, see the site of the original author:
5 // http://www.mcternan.me.uk/mscgen
6 //
7 // This mode for mscgen and the two derivative languages were
8 // originally made for use in the mscgen_js interpreter
9 // (https://sverweij.github.io/mscgen_js)
10
11 (function(mod) {
12 if ( typeof exports == "object" && typeof module == "object")// CommonJS
13 mod(require("../../lib/codemirror"));
14 else if ( typeof define == "function" && define.amd)// AMD
15 define(["../../lib/codemirror"], mod);
16 else// Plain browser env
17 mod(CodeMirror);
18 })(function(CodeMirror) {
19 "use strict";
20
21 var languages = {
22 mscgen: {
23 "keywords" : ["msc"],
24 "options" : ["hscale", "width", "arcgradient", "wordwraparcs"],
25 "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
26 "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
27 "arcsWords" : ["note", "abox", "rbox", "box"],
28 "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
29 "singlecomment" : ["//", "#"],
30 "operators" : ["="]
31 },
32 xu: {
33 "keywords" : ["msc"],
34 "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"],
35 "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
36 "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
37 "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
38 "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
39 "singlecomment" : ["//", "#"],
40 "operators" : ["="]
41 },
42 msgenny: {
43 "keywords" : null,
44 "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"],
45 "attributes" : null,
46 "brackets" : ["\\{", "\\}"],
47 "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
48 "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
49 "singlecomment" : ["//", "#"],
50 "operators" : ["="]
51 }
52 }
53
54 CodeMirror.defineMode("mscgen", function(_, modeConfig) {
55 var language = languages[modeConfig && modeConfig.language || "mscgen"]
56 return {
57 startState: startStateFn,
58 copyState: copyStateFn,
59 token: produceTokenFunction(language),
60 lineComment : "#",
61 blockCommentStart : "/*",
62 blockCommentEnd : "*/"
63 };
64 });
65
66 CodeMirror.defineMIME("text/x-mscgen", "mscgen");
67 CodeMirror.defineMIME("text/x-xu", {name: "mscgen", language: "xu"});
68 CodeMirror.defineMIME("text/x-msgenny", {name: "mscgen", language: "msgenny"});
69
70 function wordRegexpBoundary(pWords) {
71 return new RegExp("\\b(" + pWords.join("|") + ")\\b", "i");
72 }
73
74 function wordRegexp(pWords) {
75 return new RegExp("(" + pWords.join("|") + ")", "i");
76 }
77
78 function startStateFn() {
79 return {
80 inComment : false,
81 inString : false,
82 inAttributeList : false,
83 inScript : false
84 };
85 }
86
87 function copyStateFn(pState) {
88 return {
89 inComment : pState.inComment,
90 inString : pState.inString,
91 inAttributeList : pState.inAttributeList,
92 inScript : pState.inScript
93 };
94 }
95
96 function produceTokenFunction(pConfig) {
97
98 return function(pStream, pState) {
99 if (pStream.match(wordRegexp(pConfig.brackets), true, true)) {
100 return "bracket";
101 }
102 /* comments */
103 if (!pState.inComment) {
104 if (pStream.match(/\/\*[^\*\/]*/, true, true)) {
105 pState.inComment = true;
106 return "comment";
107 }
108 if (pStream.match(wordRegexp(pConfig.singlecomment), true, true)) {
109 pStream.skipToEnd();
110 return "comment";
111 }
112 }
113 if (pState.inComment) {
114 if (pStream.match(/[^\*\/]*\*\//, true, true))
115 pState.inComment = false;
116 else
117 pStream.skipToEnd();
118 return "comment";
119 }
120 /* strings */
121 if (!pState.inString && pStream.match(/\"(\\\"|[^\"])*/, true, true)) {
122 pState.inString = true;
123 return "string";
124 }
125 if (pState.inString) {
126 if (pStream.match(/[^\"]*\"/, true, true))
127 pState.inString = false;
128 else
129 pStream.skipToEnd();
130 return "string";
131 }
132 /* keywords & operators */
133 if (!!pConfig.keywords && pStream.match(wordRegexpBoundary(pConfig.keywords), true, true))
134 return "keyword";
135
136 if (pStream.match(wordRegexpBoundary(pConfig.options), true, true))
137 return "keyword";
138
139 if (pStream.match(wordRegexpBoundary(pConfig.arcsWords), true, true))
140 return "keyword";
141
142 if (pStream.match(wordRegexp(pConfig.arcsOthers), true, true))
143 return "keyword";
144
145 if (!!pConfig.operators && pStream.match(wordRegexp(pConfig.operators), true, true))
146 return "operator";
147
148 /* attribute lists */
149 if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) {
150 pConfig.inAttributeList = true;
151 return "bracket";
152 }
153 if (pConfig.inAttributeList) {
154 if (pConfig.attributes !== null && pStream.match(wordRegexpBoundary(pConfig.attributes), true, true)) {
155 return "attribute";
156 }
157 if (pStream.match(/]/, true, true)) {
158 pConfig.inAttributeList = false;
159 return "bracket";
160 }
161 }
162
163 pStream.next();
164 return "base";
165 };
166 }
167
168 });
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 var mode = CodeMirror.getMode({indentUnit: 2}, "mscgen");
5 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
6
7 MT("empty chart",
8 "[keyword msc][bracket {]",
9 "[base ]",
10 "[bracket }]"
11 );
12
13 MT("comments",
14 "[comment // a single line comment]",
15 "[comment # another single line comment /* and */ ignored here]",
16 "[comment /* A multi-line comment even though it contains]",
17 "[comment msc keywords and \"quoted text\"*/]");
18
19 MT("strings",
20 "[string \"// a string\"]",
21 "[string \"a string running over]",
22 "[string two lines\"]",
23 "[string \"with \\\"escaped quote\"]"
24 );
25
26 MT("xù/ msgenny keywords classify as 'base'",
27 "[base watermark]",
28 "[base alt loop opt ref else break par seq assert]"
29 );
30
31 MT("mscgen options classify as keyword",
32 "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
33 );
34
35 MT("mscgen arcs classify as keyword",
36 "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
37 "[keyword |||...---]", "[keyword ..--==::]",
38 "[keyword ->]", "[keyword <-]", "[keyword <->]",
39 "[keyword =>]", "[keyword <=]", "[keyword <=>]",
40 "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
41 "[keyword >>]", "[keyword <<]", "[keyword <<>>]",
42 "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
43 "[keyword :>]", "[keyword <:]", "[keyword <:>]"
44 );
45
46 MT("within an attribute list, attributes classify as attribute",
47 "[bracket [[][attribute label]",
48 "[attribute id]","[attribute url]","[attribute idurl]",
49 "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
50 "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
51 "[attribute arcskip][bracket ]]]"
52 );
53
54 MT("outside an attribute list, attributes classify as base",
55 "[base label]",
56 "[base id]","[base url]","[base idurl]",
57 "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
58 "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
59 "[base arcskip]"
60 );
61
62 MT("a typical program",
63 "[comment # typical mscgen program]",
64 "[keyword msc][base ][bracket {]",
65 "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]",
66 "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
67 "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
68 "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
69 "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
70 "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]",
71 "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
72 "[bracket }]"
73 );
74 })();
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-msgenny");
5 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "msgenny"); }
6
7 MT("comments",
8 "[comment // a single line comment]",
9 "[comment # another single line comment /* and */ ignored here]",
10 "[comment /* A multi-line comment even though it contains]",
11 "[comment msc keywords and \"quoted text\"*/]");
12
13 MT("strings",
14 "[string \"// a string\"]",
15 "[string \"a string running over]",
16 "[string two lines\"]",
17 "[string \"with \\\"escaped quote\"]"
18 );
19
20 MT("xù/ msgenny keywords classify as 'keyword'",
21 "[keyword watermark]",
22 "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
23 );
24
25 MT("mscgen options classify as keyword",
26 "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
27 );
28
29 MT("mscgen arcs classify as keyword",
30 "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
31 "[keyword |||...---]", "[keyword ..--==::]",
32 "[keyword ->]", "[keyword <-]", "[keyword <->]",
33 "[keyword =>]", "[keyword <=]", "[keyword <=>]",
34 "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
35 "[keyword >>]", "[keyword <<]", "[keyword <<>>]",
36 "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
37 "[keyword :>]", "[keyword <:]", "[keyword <:>]"
38 );
39
40 MT("within an attribute list, mscgen/ xù attributes classify as base",
41 "[base [[label]",
42 "[base idurl id url]",
43 "[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]",
44 "[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]",
45 "[base arcskip]]]"
46 );
47
48 MT("outside an attribute list, mscgen/ xù attributes classify as base",
49 "[base label]",
50 "[base idurl id url]",
51 "[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]",
52 "[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]",
53 "[base arcskip]"
54 );
55
56 MT("a typical program",
57 "[comment # typical msgenny program]",
58 "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]",
59 "[base a : ][string \"Entity A\"][base ,]",
60 "[base b : Entity B,]",
61 "[base c : Entity C;]",
62 "[base a ][keyword =>>][base b: ][string \"Hello entity B\"][base ;]",
63 "[base a ][keyword alt][base c][bracket {]",
64 "[base a ][keyword <<][base b: ][string \"Here's an answer dude!\"][base ;]",
65 "[keyword ---][base : ][string \"sorry, won't march - comm glitch\"]",
66 "[base a ][keyword x-][base b: ][string \"Here's an answer dude! (won't arrive...)\"][base ;]",
67 "[bracket }]",
68 "[base c ][keyword :>][base *: What about me?;]"
69 );
70 })();
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-xu");
5 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "xu"); }
6
7 MT("empty chart",
8 "[keyword msc][bracket {]",
9 "[base ]",
10 "[bracket }]"
11 );
12
13 MT("comments",
14 "[comment // a single line comment]",
15 "[comment # another single line comment /* and */ ignored here]",
16 "[comment /* A multi-line comment even though it contains]",
17 "[comment msc keywords and \"quoted text\"*/]");
18
19 MT("strings",
20 "[string \"// a string\"]",
21 "[string \"a string running over]",
22 "[string two lines\"]",
23 "[string \"with \\\"escaped quote\"]"
24 );
25
26 MT("xù/ msgenny keywords classify as 'keyword'",
27 "[keyword watermark]",
28 "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
29 );
30
31 MT("mscgen options classify as keyword",
32 "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
33 );
34
35 MT("mscgen arcs classify as keyword",
36 "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
37 "[keyword |||...---]", "[keyword ..--==::]",
38 "[keyword ->]", "[keyword <-]", "[keyword <->]",
39 "[keyword =>]", "[keyword <=]", "[keyword <=>]",
40 "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
41 "[keyword >>]", "[keyword <<]", "[keyword <<>>]",
42 "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
43 "[keyword :>]", "[keyword <:]", "[keyword <:>]"
44 );
45
46 MT("within an attribute list, attributes classify as attribute",
47 "[bracket [[][attribute label]",
48 "[attribute id]","[attribute url]","[attribute idurl]",
49 "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
50 "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
51 "[attribute arcskip][bracket ]]]"
52 );
53
54 MT("outside an attribute list, attributes classify as base",
55 "[base label]",
56 "[base id]","[base url]","[base idurl]",
57 "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
58 "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
59 "[base arcskip]"
60 );
61
62 MT("a typical program",
63 "[comment # typical mscgen program]",
64 "[keyword msc][base ][bracket {]",
65 "[keyword wordwraparcs][operator =][string \"true\"][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]",
66 "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
67 "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
68 "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
69 "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
70 "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]",
71 "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
72 "[bracket }]"
73 );
74 })();
0 <!doctype html>
0 <!doctype html>
11
22 <title>CodeMirror: MUMPS mode</title>
33 <meta charset="utf-8"/>
7272 IF '$LENGTH($PIECE(XUSER(1),U,2)) QUIT 21 ;p419, p434
7373 Q 0
7474 ;
75 </textarea>
75 </textarea></div>
7676 <script>
7777 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
7878 mode: "mumps",
0 <!doctype html>
1
0 <!doctype html>
1 <head>
22 <title>CodeMirror: NGINX mode</title>
33 <meta charset="utf-8"/>
44 <link rel=stylesheet href="../../doc/docs.css">
172172 };
173173 });
174174
175 CodeMirror.defineMIME("text/nginx", "text/x-nginx-conf");
175 CodeMirror.defineMIME("text/x-nginx-conf", "nginx");
176176
177177 });
0 <!doctype html>
1
2 <title>CodeMirror: NSIS mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel=stylesheet href=../../lib/codemirror.css>
7 <script src=../../lib/codemirror.js></script>
8 <script src="../../addon/mode/simple.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
10 <script src=nsis.js></script>
11 <style type=text/css>
12 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
13 </style>
14 <div id=nav>
15 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
16
17 <ul>
18 <li><a href="../../index.html">Home</a>
19 <li><a href="../../doc/manual.html">Manual</a>
20 <li><a href="https://github.com/codemirror/codemirror">Code</a>
21 </ul>
22 <ul>
23 <li><a href="../index.html">Language modes</a>
24 <li><a class=active href="#">NSIS</a>
25 </ul>
26 </div>
27
28 <article>
29 <h2>NSIS mode</h2>
30
31
32 <textarea id=code>
33 ; This is a comment
34 !ifdef ERROR
35 !error "Something went wrong"
36 !endif
37
38 OutFile "demo.exe"
39 RequestExecutionLevel user
40 SetDetailsPrint listonly
41
42 !include "LogicLib.nsh"
43 !include "WinVer.nsh"
44
45 Section -mandatory
46
47 Call logWinVer
48
49 ${If} 1 > 0
50 MessageBox MB_OK "Hello world"
51 ${EndIf}
52
53 SectionEnd
54
55 Function logWinVer
56
57 ${If} ${IsWin10}
58 DetailPrint "Windows 10!"
59 ${ElseIf} ${AtLeastWinVista}
60 DetailPrint "We're post-XP"
61 ${Else}
62 DetailPrint "Legacy system"
63 ${EndIf}
64
65 FunctionEnd
66 </textarea>
67
68 <script>
69 var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
70 mode: 'nsis',
71 indentWithTabs: true,
72 smartIndent: true,
73 lineNumbers: true,
74 matchBrackets: true
75 });
76 </script>
77
78 <p><strong>MIME types defined:</strong> <code>text/x-nsis</code>.</p>
79 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 // Author: Jan T. Sott (http://github.com/idleberg)
4
5 (function(mod) {
6 if (typeof exports == "object" && typeof module == "object") // CommonJS
7 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
8 else if (typeof define == "function" && define.amd) // AMD
9 define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
10 else // Plain browser env
11 mod(CodeMirror);
12 })(function(CodeMirror) {
13 "use strict";
14
15 CodeMirror.defineSimpleMode("nsis",{
16 start:[
17 // Numbers
18 {regex: /(?:[+-]?)(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\d+.?\d*)/, token: "number"},
19
20 // Strings
21 { regex: /"(?:[^\\"]|\\.)*"?/, token: "string" },
22 { regex: /'(?:[^\\']|\\.)*'?/, token: "string" },
23 { regex: /`(?:[^\\`]|\\.)*`?/, token: "string" },
24
25 // Compile Time Commands
26 {regex: /(?:\!(include|addincludedir|addplugindir|appendfile|cd|delfile|echo|error|execute|packhdr|finalize|getdllversion|system|tempfile|warning|verbose|define|undef|insertmacro|makensis|searchparse|searchreplace))\b/, token: "keyword"},
27
28 // Conditional Compilation
29 {regex: /(?:\!(if(?:n?def)?|ifmacron?def|macro))\b/, token: "keyword", indent: true},
30 {regex: /(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true},
31
32 // Runtime Commands
33 {regex: /\b(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|IntCmp|IntCmpU|IntFmt|IntOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetPluginUnload|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"},
34 {regex: /\b(?:Function|PageEx|Section(?:Group)?)\b/, token: "keyword", indent: true},
35 {regex: /\b(?:(Function|PageEx|Section(?:Group)?)End)\b/, token: "keyword", dedent: true},
36
37 // Command Options
38 {regex: /\b(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HIDDEN|HKCC|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDD_DIR|IDD_INST|IDD_INSTFILES|IDD_LICENSE|IDD_SELCOM|IDD_UNINST|IDD_VERIFY|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|MB_YESNOCANCEL|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SW_HIDE|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWNORMAL|SYSTEM|TEMPORARY)\b/, token: "atom"},
39 {regex: /\b(?:admin|all|auto|both|bottom|bzip2|components|current|custom|directory|force|hide|highest|ifdiff|ifnewer|instfiles|lastused|leave|left|license|listonly|lzma|nevershow|none|normal|notset|right|show|silent|silentlog|textonly|top|try|un\.components|un\.custom|un\.directory|un\.instfiles|un\.license|uninstConfirm|user|Win10|Win7|Win8|WinVista|zlib)\b/, token: "builtin"},
40
41 // LogicLib.nsh
42 {regex: /\$\{(?:And(?:If(?:Not)?|Unless)|Break|Case(?:Else)?|Continue|Default|Do(?:Until|While)?|Else(?:If(?:Not)?|Unless)?|End(?:If|Select|Switch)|Exit(?:Do|For|While)|For(?:Each)?|If(?:Cmd|Not(?:Then)?|Then)?|Loop(?:Until|While)?|Or(?:If(?:Not)?|Unless)|Select|Switch|Unless|While)\}/, token: "variable-2", indent: true},
43
44 // FileFunc.nsh
45 {regex: /\$\{(?:BannerTrimPath|DirState|DriveSpace|Get(BaseName|Drives|ExeName|ExePath|FileAttributes|FileExt|FileName|FileVersion|Options|OptionsS|Parameters|Parent|Root|Size|Time)|Locate|RefreshShellIcons)\}/, token: "variable-2", dedent: true},
46
47 // Memento.nsh
48 {regex: /\$\{(?:Memento(?:Section(?:Done|End|Restore|Save)?|UnselectedSection))\}/, token: "variable-2", dedent: true},
49
50 // TextFunc.nsh
51 {regex: /\$\{(?:Config(?:Read|ReadS|Write|WriteS)|File(?:Join|ReadFromEnd|Recode)|Line(?:Find|Read|Sum)|Text(?:Compare|CompareS)|TrimNewLines)\}/, token: "variable-2", dedent: true},
52
53 // WinVer.nsh
54 {regex: /\$\{(?:(?:At(?:Least|Most)|Is)(?:ServicePack|Win(?:7|8|10|95|98|200(?:0|3|8(?:R2)?)|ME|NT4|Vista|XP))|Is(?:NT|Server))\}/, token: "variable", dedent: true},
55
56 // WordFunc.nsh
57 {regex: /\$\{(?:StrFilterS?|Version(?:Compare|Convert)|Word(?:AddS?|Find(?:(?:2|3)X)?S?|InsertS?|ReplaceS?))\}/, token: "variable-2", dedent: true},
58
59 // x64.nsh
60 {regex: /\$\{(?:RunningX64)\}/, token: "variable", dedent: true},
61 {regex: /\$\{(?:Disable|Enable)X64FSRedirection\}/, token: "variable-2", dedent: true},
62
63 // Line Comment
64 {regex: /(#|;).*/, token: "comment"},
65
66 // Block Comment
67 {regex: /\/\*/, token: "comment", next: "comment"},
68
69 // Operator
70 {regex: /[-+\/*=<>!]+/, token: "operator"},
71
72 // Variable
73 {regex: /\$[\w]+/, token: "variable"},
74
75 // Constant
76 {regex: /\${[\w]+}/,token: "variable-2"},
77
78 // Language String
79 {regex: /\$\([\w]+\)/,token: "variable-3"}
80 ],
81 comment: [
82 {regex: /.*?\*\//, token: "comment", next: "start"},
83 {regex: /.*/, token: "comment"}
84 ],
85 meta: {
86 electricInput: /^\s*((Function|PageEx|Section|Section(Group)?)End|(\!(endif|macroend))|\$\{(End(If|Unless|While)|Loop(Until)|Next)\})$/,
87 blockCommentStart: "/*",
88 blockCommentEnd: "*/",
89 lineComment: ["#", ";"]
90 }
91 });
92
93 CodeMirror.defineMIME("text/x-nsis", "nsis");
94 });
6464
6565 %one line comment
6666 %{ multi
67 line commment %}
67 line comment %}
6868
6969 </textarea></div>
7070 <script>
0 <!doctype html>
1
2 <title>CodeMirror: Oz mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="oz.js"></script>
9 <script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
10 <style>
11 .CodeMirror {border: 1px solid #aaa;}
12 </style>
13 <div id=nav>
14 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
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="#">Oz</a>
23 </ul>
24 </div>
25
26 <article>
27 <h2>Oz mode</h2>
28 <textarea id="code" name="code">
29 declare
30 fun {Ints N Max}
31 if N == Max then nil
32 else
33 {Delay 1000}
34 N|{Ints N+1 Max}
35 end
36 end
37
38 fun {Sum S Stream}
39 case Stream of nil then S
40 [] H|T then S|{Sum H+S T} end
41 end
42
43 local X Y in
44 thread X = {Ints 0 1000} end
45 thread Y = {Sum 0 X} end
46 {Browse Y}
47 end
48 </textarea>
49 <p>MIME type defined: <code>text/x-oz</code>.</p>
50
51 <script type="text/javascript">
52 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
53 lineNumbers: true,
54 mode: "text/x-oz",
55 readOnly: false
56 });
57 </script>
58 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 CodeMirror.defineMode("oz", function (conf) {
14
15 function wordRegexp(words) {
16 return new RegExp("^((" + words.join(")|(") + "))\\b");
17 }
18
19 var singleOperators = /[\^@!\|<>#~\.\*\-\+\\/,=]/;
20 var doubleOperators = /(<-)|(:=)|(=<)|(>=)|(<=)|(<:)|(>:)|(=:)|(\\=)|(\\=:)|(!!)|(==)|(::)/;
21 var tripleOperators = /(:::)|(\.\.\.)|(=<:)|(>=:)/;
22
23 var middle = ["in", "then", "else", "of", "elseof", "elsecase", "elseif", "catch",
24 "finally", "with", "require", "prepare", "import", "export", "define", "do"];
25 var end = ["end"];
26
27 var atoms = wordRegexp(["true", "false", "nil", "unit"]);
28 var commonKeywords = wordRegexp(["andthen", "at", "attr", "declare", "feat", "from", "lex",
29 "mod", "mode", "orelse", "parser", "prod", "prop", "scanner", "self", "syn", "token"]);
30 var openingKeywords = wordRegexp(["local", "proc", "fun", "case", "class", "if", "cond", "or", "dis",
31 "choice", "not", "thread", "try", "raise", "lock", "for", "suchthat", "meth", "functor"]);
32 var middleKeywords = wordRegexp(middle);
33 var endKeywords = wordRegexp(end);
34
35 // Tokenizers
36 function tokenBase(stream, state) {
37 if (stream.eatSpace()) {
38 return null;
39 }
40
41 // Brackets
42 if(stream.match(/[{}]/)) {
43 return "bracket";
44 }
45
46 // Special [] keyword
47 if (stream.match(/(\[])/)) {
48 return "keyword"
49 }
50
51 // Operators
52 if (stream.match(tripleOperators) || stream.match(doubleOperators)) {
53 return "operator";
54 }
55
56 // Atoms
57 if(stream.match(atoms)) {
58 return 'atom';
59 }
60
61 // Opening keywords
62 var matched = stream.match(openingKeywords);
63 if (matched) {
64 if (!state.doInCurrentLine)
65 state.currentIndent++;
66 else
67 state.doInCurrentLine = false;
68
69 // Special matching for signatures
70 if(matched[0] == "proc" || matched[0] == "fun")
71 state.tokenize = tokenFunProc;
72 else if(matched[0] == "class")
73 state.tokenize = tokenClass;
74 else if(matched[0] == "meth")
75 state.tokenize = tokenMeth;
76
77 return 'keyword';
78 }
79
80 // Middle and other keywords
81 if (stream.match(middleKeywords) || stream.match(commonKeywords)) {
82 return "keyword"
83 }
84
85 // End keywords
86 if (stream.match(endKeywords)) {
87 state.currentIndent--;
88 return 'keyword';
89 }
90
91 // Eat the next char for next comparisons
92 var ch = stream.next();
93
94 // Strings
95 if (ch == '"' || ch == "'") {
96 state.tokenize = tokenString(ch);
97 return state.tokenize(stream, state);
98 }
99
100 // Numbers
101 if (/[~\d]/.test(ch)) {
102 if (ch == "~") {
103 if(! /^[0-9]/.test(stream.peek()))
104 return null;
105 else if (( stream.next() == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))
106 return "number";
107 }
108
109 if ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/))
110 return "number";
111
112 return null;
113 }
114
115 // Comments
116 if (ch == "%") {
117 stream.skipToEnd();
118 return 'comment';
119 }
120 else if (ch == "/") {
121 if (stream.eat("*")) {
122 state.tokenize = tokenComment;
123 return tokenComment(stream, state);
124 }
125 }
126
127 // Single operators
128 if(singleOperators.test(ch)) {
129 return "operator";
130 }
131
132 // If nothing match, we skip the entire alphanumerical block
133 stream.eatWhile(/\w/);
134
135 return "variable";
136 }
137
138 function tokenClass(stream, state) {
139 if (stream.eatSpace()) {
140 return null;
141 }
142 stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)/);
143 state.tokenize = tokenBase;
144 return "variable-3"
145 }
146
147 function tokenMeth(stream, state) {
148 if (stream.eatSpace()) {
149 return null;
150 }
151 stream.match(/([a-zA-Z][A-Za-z0-9_]*)|(`.+`)/);
152 state.tokenize = tokenBase;
153 return "def"
154 }
155
156 function tokenFunProc(stream, state) {
157 if (stream.eatSpace()) {
158 return null;
159 }
160
161 if(!state.hasPassedFirstStage && stream.eat("{")) {
162 state.hasPassedFirstStage = true;
163 return "bracket";
164 }
165 else if(state.hasPassedFirstStage) {
166 stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)|\$/);
167 state.hasPassedFirstStage = false;
168 state.tokenize = tokenBase;
169 return "def"
170 }
171 else {
172 state.tokenize = tokenBase;
173 return null;
174 }
175 }
176
177 function tokenComment(stream, state) {
178 var maybeEnd = false, ch;
179 while (ch = stream.next()) {
180 if (ch == "/" && maybeEnd) {
181 state.tokenize = tokenBase;
182 break;
183 }
184 maybeEnd = (ch == "*");
185 }
186 return "comment";
187 }
188
189 function tokenString(quote) {
190 return function (stream, state) {
191 var escaped = false, next, end = false;
192 while ((next = stream.next()) != null) {
193 if (next == quote && !escaped) {
194 end = true;
195 break;
196 }
197 escaped = !escaped && next == "\\";
198 }
199 if (end || !escaped)
200 state.tokenize = tokenBase;
201 return "string";
202 };
203 }
204
205 function buildElectricInputRegEx() {
206 // Reindentation should occur on [] or on a match of any of
207 // the block closing keywords, at the end of a line.
208 var allClosings = middle.concat(end);
209 return new RegExp("[\\[\\]]|(" + allClosings.join("|") + ")$");
210 }
211
212 return {
213
214 startState: function () {
215 return {
216 tokenize: tokenBase,
217 currentIndent: 0,
218 doInCurrentLine: false,
219 hasPassedFirstStage: false
220 };
221 },
222
223 token: function (stream, state) {
224 if (stream.sol())
225 state.doInCurrentLine = 0;
226
227 return state.tokenize(stream, state);
228 },
229
230 indent: function (state, textAfter) {
231 var trueText = textAfter.replace(/^\s+|\s+$/g, '');
232
233 if (trueText.match(endKeywords) || trueText.match(middleKeywords) || trueText.match(/(\[])/))
234 return conf.indentUnit * (state.currentIndent - 1);
235
236 if (state.currentIndent < 0)
237 return 0;
238
239 return state.currentIndent * conf.indentUnit;
240 },
241 fold: "indent",
242 electricInput: buildElectricInputRegEx(),
243 lineComment: "%",
244 blockCommentStart: "/*",
245 blockCommentEnd: "*/"
246 };
247 });
248
249 CodeMirror.defineMIME("text/x-oz", "oz");
250
251 });
2323 inString: false,
2424 stringType: null,
2525 inComment: false,
26 inChracterClass: false,
26 inCharacterClass: false,
2727 braced: 0,
2828 lhs: true,
2929 localState: null
6565 }
6666 }
6767 return "comment";
68 } else if (state.inChracterClass) {
69 while (state.inChracterClass && !stream.eol()) {
68 } else if (state.inCharacterClass) {
69 while (state.inCharacterClass && !stream.eol()) {
7070 if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) {
71 state.inChracterClass = false;
71 state.inCharacterClass = false;
7272 }
7373 }
7474 } else if (stream.peek() === '[') {
7575 stream.next();
76 state.inChracterClass = true;
76 state.inCharacterClass = true;
7777 return 'bracket';
7878 } else if (stream.match(/^\/\//)) {
7979 stream.skipToEnd();
8080 return "comment";
8181 } else if (state.braced || stream.peek() === '{') {
8282 if (state.localState === null) {
83 state.localState = jsMode.startState();
83 state.localState = CodeMirror.startState(jsMode);
8484 }
8585 var token = jsMode.token(stream, state.localState);
8686 var text = stream.current();
267267 chmod :1, // - changes the permissions on a list of files
268268 chomp :1, // - remove a trailing record separator from a string
269269 chop :1, // - remove the last character from a string
270 chown :1, // - change the owership on a list of files
270 chown :1, // - change the ownership on a list of files
271271 chr :1, // - get character this number represents
272272 chroot :1, // - make directory new root for path lookups
273273 close :1, // - close file (or pipe or socket) handle
8585 "die echo empty exit eval include include_once isset list require require_once return " +
8686 "print unset __halt_compiler self static parent yield insteadof finally";
8787 var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__";
88 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 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";
88 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";
8989 CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" "));
9090 CodeMirror.registerHelper("wordChars", "php", /[\w$]/);
9191
104104 return "variable-2";
105105 },
106106 "<": function(stream, state) {
107 if (stream.match(/<</)) {
108 var nowDoc = stream.eat("'");
107 var before;
108 if (before = stream.match(/<<\s*/)) {
109 var quoted = stream.eat(/['"]/);
109110 stream.eatWhile(/[\w\.]/);
110 var delim = stream.current().slice(3 + (nowDoc ? 1 : 0));
111 if (nowDoc) stream.eat("'");
111 var delim = stream.current().slice(before[0].length + (quoted ? 2 : 1));
112 if (quoted) stream.eat(quoted);
112113 if (delim) {
113114 (state.tokStack || (state.tokStack = [])).push(delim, 0);
114 state.tokenize = phpString(delim, nowDoc ? false : true);
115 state.tokenize = phpString(delim, quoted != "'");
115116 return "string";
116117 }
117118 }
158159 if (!isPHP) {
159160 if (stream.match(/^<\?\w*/)) {
160161 state.curMode = phpMode;
162 if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, ""))
161163 state.curState = state.php;
162164 return "meta";
163165 }
181183 } else if (isPHP && state.php.tokenize == null && stream.match("?>")) {
182184 state.curMode = htmlMode;
183185 state.curState = state.html;
186 if (!state.php.context.prev) state.php = null;
184187 return "meta";
185188 } else {
186189 return phpMode.token(stream, state.curState);
189192
190193 return {
191194 startState: function() {
192 var html = CodeMirror.startState(htmlMode), php = CodeMirror.startState(phpMode);
195 var html = CodeMirror.startState(htmlMode)
196 var php = parserConfig.startOpen ? CodeMirror.startState(phpMode) : null
193197 return {html: html,
194198 php: php,
195199 curMode: parserConfig.startOpen ? phpMode : htmlMode,
199203
200204 copyState: function(state) {
201205 var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
202 php = state.php, phpNew = CodeMirror.copyState(phpMode, php), cur;
206 php = state.php, phpNew = php && CodeMirror.copyState(phpMode, php), cur;
203207 if (state.curMode == htmlMode) cur = htmlNew;
204208 else cur = phpNew;
205209 return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
0 <!doctype html>
1
0 <!doctype html>
21 <title>CodeMirror: Pig Latin mode</title>
32 <meta charset="utf-8"/>
43 <link rel=stylesheet href="../../doc/docs.css">
5049
5150 <p><strong>MIME type defined:</strong> <code>text/x-pig</code>
5251 (PIG code)
53 </html>
5452 </article>
0 <!doctype html>
1 <html>
2 <head>
3 <meta charset="utf-8">
4 <title>CodeMirror: Powershell mode</title>
5 <link rel="stylesheet" href="../../doc/docs.css">
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="powershell.js"></script>
9 <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 </head>
11 <body>
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="#">JavaScript</a>
23 </ul>
24 </div>
25 <article>
26 <h2>PowerShell mode</h2>
27
28 <div><textarea id="code" name="code">
29 # Number Literals
30 0 12345
31 12kb 12mb 12gB 12Tb 12PB 12L 12D 12lkb 12dtb
32 1.234 1.234e56 1. 1.e2 .2 .2e34
33 1.2MB 1.kb .1dTb 1.e1gb
34 0x1 0xabcdef 0x3tb 0xelmb
35
36 # String Literals
37 'Literal escaping'''
38 'Literal $variable'
39 "Escaping 1`""
40 "Escaping 2"""
41 "Escaped `$variable"
42 "Text, $variable and more text"
43 "Text, ${variable with spaces} and more text."
44 "Text, $($expression + 3) and more text."
45 "Text, $("interpolation $("inception")") and more text."
46
47 @"
48 Multiline
49 string
50 "@
51 # --
52 @"
53 Multiline
54 string with quotes "'
55 "@
56 # --
57 @'
58 Multiline literal
59 string with quotes "'
60 '@
61
62 # Array and Hash literals
63 @( 'a','b','c' )
64 @{ 'key': 'value' }
65
66 # Variables
67 $Variable = 5
68 $global:variable = 5
69 ${Variable with spaces} = 5
70
71 # Operators
72 = += -= *= /= %=
73 ++ -- .. -f * / % + -
74 -not ! -bnot
75 -split -isplit -csplit
76 -join
77 -is -isnot -as
78 -eq -ieq -ceq -ne -ine -cne
79 -gt -igt -cgt -ge -ige -cge
80 -lt -ilt -clt -le -ile -cle
81 -like -ilike -clike -notlike -inotlike -cnotlike
82 -match -imatch -cmatch -notmatch -inotmatch -cnotmatch
83 -contains -icontains -ccontains -notcontains -inotcontains -cnotcontains
84 -replace -ireplace -creplace
85 -band -bor -bxor
86 -and -or -xor
87
88 # Punctuation
89 () [] {} , : ` = ; .
90
91 # Keywords
92 elseif begin function for foreach return else trap while do data dynamicparam
93 until end break if throw param continue finally in switch exit filter from try
94 process catch
95
96 # Built-in variables
97 $$ $? $^ $_
98 $args $ConfirmPreference $ConsoleFileName $DebugPreference $Error
99 $ErrorActionPreference $ErrorView $ExecutionContext $false $FormatEnumerationLimit
100 $HOME $Host $input $MaximumAliasCount $MaximumDriveCount $MaximumErrorCount
101 $MaximumFunctionCount $MaximumHistoryCount $MaximumVariableCount $MyInvocation
102 $NestedPromptLevel $null $OutputEncoding $PID $PROFILE $ProgressPreference
103 $PSBoundParameters $PSCommandPath $PSCulture $PSDefaultParameterValues
104 $PSEmailServer $PSHOME $PSScriptRoot $PSSessionApplicationName
105 $PSSessionConfigurationName $PSSessionOption $PSUICulture $PSVersionTable $PWD
106 $ShellId $StackTrace $true $VerbosePreference $WarningPreference $WhatIfPreference
107 $true $false $null
108
109 # Built-in functions
110 A:
111 Add-Computer Add-Content Add-History Add-Member Add-PSSnapin Add-Type
112 B:
113 C:
114 Checkpoint-Computer Clear-Content Clear-EventLog Clear-History Clear-Host Clear-Item
115 Clear-ItemProperty Clear-Variable Compare-Object Complete-Transaction Connect-PSSession
116 ConvertFrom-Csv ConvertFrom-Json ConvertFrom-SecureString ConvertFrom-StringData
117 Convert-Path ConvertTo-Csv ConvertTo-Html ConvertTo-Json ConvertTo-SecureString
118 ConvertTo-Xml Copy-Item Copy-ItemProperty
119 D:
120 Debug-Process Disable-ComputerRestore Disable-PSBreakpoint Disable-PSRemoting
121 Disable-PSSessionConfiguration Disconnect-PSSession
122 E:
123 Enable-ComputerRestore Enable-PSBreakpoint Enable-PSRemoting Enable-PSSessionConfiguration
124 Enter-PSSession Exit-PSSession Export-Alias Export-Clixml Export-Console Export-Counter
125 Export-Csv Export-FormatData Export-ModuleMember Export-PSSession
126 F:
127 ForEach-Object Format-Custom Format-List Format-Table Format-Wide
128 G:
129 Get-Acl Get-Alias Get-AuthenticodeSignature Get-ChildItem Get-Command Get-ComputerRestorePoint
130 Get-Content Get-ControlPanelItem Get-Counter Get-Credential Get-Culture Get-Date
131 Get-Event Get-EventLog Get-EventSubscriber Get-ExecutionPolicy Get-FormatData Get-Help
132 Get-History Get-Host Get-HotFix Get-Item Get-ItemProperty Get-Job Get-Location Get-Member
133 Get-Module Get-PfxCertificate Get-Process Get-PSBreakpoint Get-PSCallStack Get-PSDrive
134 Get-PSProvider Get-PSSession Get-PSSessionConfiguration Get-PSSnapin Get-Random Get-Service
135 Get-TraceSource Get-Transaction Get-TypeData Get-UICulture Get-Unique Get-Variable Get-Verb
136 Get-WinEvent Get-WmiObject Group-Object
137 H:
138 help
139 I:
140 Import-Alias Import-Clixml Import-Counter Import-Csv Import-LocalizedData Import-Module
141 Import-PSSession ImportSystemModules Invoke-Command Invoke-Expression Invoke-History
142 Invoke-Item Invoke-RestMethod Invoke-WebRequest Invoke-WmiMethod
143 J:
144 Join-Path
145 K:
146 L:
147 Limit-EventLog
148 M:
149 Measure-Command Measure-Object mkdir more Move-Item Move-ItemProperty
150 N:
151 New-Alias New-Event New-EventLog New-Item New-ItemProperty New-Module New-ModuleManifest
152 New-Object New-PSDrive New-PSSession New-PSSessionConfigurationFile New-PSSessionOption
153 New-PSTransportOption New-Service New-TimeSpan New-Variable New-WebServiceProxy
154 New-WinEvent
155 O:
156 oss Out-Default Out-File Out-GridView Out-Host Out-Null Out-Printer Out-String
157 P:
158 Pause Pop-Location prompt Push-Location
159 Q:
160 R:
161 Read-Host Receive-Job Receive-PSSession Register-EngineEvent Register-ObjectEvent
162 Register-PSSessionConfiguration Register-WmiEvent Remove-Computer Remove-Event
163 Remove-EventLog Remove-Item Remove-ItemProperty Remove-Job Remove-Module
164 Remove-PSBreakpoint Remove-PSDrive Remove-PSSession Remove-PSSnapin Remove-TypeData
165 Remove-Variable Remove-WmiObject Rename-Computer Rename-Item Rename-ItemProperty
166 Reset-ComputerMachinePassword Resolve-Path Restart-Computer Restart-Service
167 Restore-Computer Resume-Job Resume-Service
168 S:
169 Save-Help Select-Object Select-String Select-Xml Send-MailMessage Set-Acl Set-Alias
170 Set-AuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item
171 Set-ItemProperty Set-Location Set-PSBreakpoint Set-PSDebug
172 Set-PSSessionConfiguration Set-Service Set-StrictMode Set-TraceSource Set-Variable
173 Set-WmiInstance Show-Command Show-ControlPanelItem Show-EventLog Sort-Object
174 Split-Path Start-Job Start-Process Start-Service Start-Sleep Start-Transaction
175 Start-Transcript Stop-Computer Stop-Job Stop-Process Stop-Service Stop-Transcript
176 Suspend-Job Suspend-Service
177 T:
178 TabExpansion2 Tee-Object Test-ComputerSecureChannel Test-Connection
179 Test-ModuleManifest Test-Path Test-PSSessionConfigurationFile Trace-Command
180 U:
181 Unblock-File Undo-Transaction Unregister-Event Unregister-PSSessionConfiguration
182 Update-FormatData Update-Help Update-List Update-TypeData Use-Transaction
183 V:
184 W:
185 Wait-Event Wait-Job Wait-Process Where-Object Write-Debug Write-Error Write-EventLog
186 Write-Host Write-Output Write-Progress Write-Verbose Write-Warning
187 X:
188 Y:
189 Z:</textarea></div>
190 <script>
191 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
192 mode: "powershell",
193 lineNumbers: true,
194 indentUnit: 4,
195 tabMode: "shift",
196 matchBrackets: true
197 });
198 </script>
199
200 <p><strong>MIME types defined:</strong> <code>application/x-powershell</code>.</p>
201 </article>
202 </body>
203 </html>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 'use strict';
5 if (typeof exports == 'object' && typeof module == 'object') // CommonJS
6 mod(require('codemirror'));
7 else if (typeof define == 'function' && define.amd) // AMD
8 define(['codemirror'], mod);
9 else // Plain browser env
10 mod(window.CodeMirror);
11 })(function(CodeMirror) {
12 'use strict';
13
14 CodeMirror.defineMode('powershell', function() {
15 function buildRegexp(patterns, options) {
16 options = options || {};
17 var prefix = options.prefix !== undefined ? options.prefix : '^';
18 var suffix = options.suffix !== undefined ? options.suffix : '\\b';
19
20 for (var i = 0; i < patterns.length; i++) {
21 if (patterns[i] instanceof RegExp) {
22 patterns[i] = patterns[i].source;
23 }
24 else {
25 patterns[i] = patterns[i].replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
26 }
27 }
28
29 return new RegExp(prefix + '(' + patterns.join('|') + ')' + suffix, 'i');
30 }
31
32 var notCharacterOrDash = '(?=[^A-Za-z\\d\\-_]|$)';
33 var varNames = /[\w\-:]/
34 var keywords = buildRegexp([
35 /begin|break|catch|continue|data|default|do|dynamicparam/,
36 /else|elseif|end|exit|filter|finally|for|foreach|from|function|if|in/,
37 /param|process|return|switch|throw|trap|try|until|where|while/
38 ], { suffix: notCharacterOrDash });
39
40 var punctuation = /[\[\]{},;`\.]|@[({]/;
41 var wordOperators = buildRegexp([
42 'f',
43 /b?not/,
44 /[ic]?split/, 'join',
45 /is(not)?/, 'as',
46 /[ic]?(eq|ne|[gl][te])/,
47 /[ic]?(not)?(like|match|contains)/,
48 /[ic]?replace/,
49 /b?(and|or|xor)/
50 ], { prefix: '-' });
51 var symbolOperators = /[+\-*\/%]=|\+\+|--|\.\.|[+\-*&^%:=!|\/]|<(?!#)|(?!#)>/;
52 var operators = buildRegexp([wordOperators, symbolOperators], { suffix: '' });
53
54 var numbers = /^((0x[\da-f]+)|((\d+\.\d+|\d\.|\.\d+|\d+)(e[\+\-]?\d+)?))[ld]?([kmgtp]b)?/i;
55
56 var identifiers = /^[A-Za-z\_][A-Za-z\-\_\d]*\b/;
57
58 var symbolBuiltins = /[A-Z]:|%|\?/i;
59 var namedBuiltins = buildRegexp([
60 /Add-(Computer|Content|History|Member|PSSnapin|Type)/,
61 /Checkpoint-Computer/,
62 /Clear-(Content|EventLog|History|Host|Item(Property)?|Variable)/,
63 /Compare-Object/,
64 /Complete-Transaction/,
65 /Connect-PSSession/,
66 /ConvertFrom-(Csv|Json|SecureString|StringData)/,
67 /Convert-Path/,
68 /ConvertTo-(Csv|Html|Json|SecureString|Xml)/,
69 /Copy-Item(Property)?/,
70 /Debug-Process/,
71 /Disable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)/,
72 /Disconnect-PSSession/,
73 /Enable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)/,
74 /(Enter|Exit)-PSSession/,
75 /Export-(Alias|Clixml|Console|Counter|Csv|FormatData|ModuleMember|PSSession)/,
76 /ForEach-Object/,
77 /Format-(Custom|List|Table|Wide)/,
78 new RegExp('Get-(Acl|Alias|AuthenticodeSignature|ChildItem|Command|ComputerRestorePoint|Content|ControlPanelItem|Counter|Credential'
79 + '|Culture|Date|Event|EventLog|EventSubscriber|ExecutionPolicy|FormatData|Help|History|Host|HotFix|Item|ItemProperty|Job'
80 + '|Location|Member|Module|PfxCertificate|Process|PSBreakpoint|PSCallStack|PSDrive|PSProvider|PSSession|PSSessionConfiguration'
81 + '|PSSnapin|Random|Service|TraceSource|Transaction|TypeData|UICulture|Unique|Variable|Verb|WinEvent|WmiObject)'),
82 /Group-Object/,
83 /Import-(Alias|Clixml|Counter|Csv|LocalizedData|Module|PSSession)/,
84 /ImportSystemModules/,
85 /Invoke-(Command|Expression|History|Item|RestMethod|WebRequest|WmiMethod)/,
86 /Join-Path/,
87 /Limit-EventLog/,
88 /Measure-(Command|Object)/,
89 /Move-Item(Property)?/,
90 new RegExp('New-(Alias|Event|EventLog|Item(Property)?|Module|ModuleManifest|Object|PSDrive|PSSession|PSSessionConfigurationFile'
91 + '|PSSessionOption|PSTransportOption|Service|TimeSpan|Variable|WebServiceProxy|WinEvent)'),
92 /Out-(Default|File|GridView|Host|Null|Printer|String)/,
93 /Pause/,
94 /(Pop|Push)-Location/,
95 /Read-Host/,
96 /Receive-(Job|PSSession)/,
97 /Register-(EngineEvent|ObjectEvent|PSSessionConfiguration|WmiEvent)/,
98 /Remove-(Computer|Event|EventLog|Item(Property)?|Job|Module|PSBreakpoint|PSDrive|PSSession|PSSnapin|TypeData|Variable|WmiObject)/,
99 /Rename-(Computer|Item(Property)?)/,
100 /Reset-ComputerMachinePassword/,
101 /Resolve-Path/,
102 /Restart-(Computer|Service)/,
103 /Restore-Computer/,
104 /Resume-(Job|Service)/,
105 /Save-Help/,
106 /Select-(Object|String|Xml)/,
107 /Send-MailMessage/,
108 new RegExp('Set-(Acl|Alias|AuthenticodeSignature|Content|Date|ExecutionPolicy|Item(Property)?|Location|PSBreakpoint|PSDebug' +
109 '|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance)'),
110 /Show-(Command|ControlPanelItem|EventLog)/,
111 /Sort-Object/,
112 /Split-Path/,
113 /Start-(Job|Process|Service|Sleep|Transaction|Transcript)/,
114 /Stop-(Computer|Job|Process|Service|Transcript)/,
115 /Suspend-(Job|Service)/,
116 /TabExpansion2/,
117 /Tee-Object/,
118 /Test-(ComputerSecureChannel|Connection|ModuleManifest|Path|PSSessionConfigurationFile)/,
119 /Trace-Command/,
120 /Unblock-File/,
121 /Undo-Transaction/,
122 /Unregister-(Event|PSSessionConfiguration)/,
123 /Update-(FormatData|Help|List|TypeData)/,
124 /Use-Transaction/,
125 /Wait-(Event|Job|Process)/,
126 /Where-Object/,
127 /Write-(Debug|Error|EventLog|Host|Output|Progress|Verbose|Warning)/,
128 /cd|help|mkdir|more|oss|prompt/,
129 /ac|asnp|cat|cd|chdir|clc|clear|clhy|cli|clp|cls|clv|cnsn|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|dnsn|ebp/,
130 /echo|epal|epcsv|epsn|erase|etsn|exsn|fc|fl|foreach|ft|fw|gal|gbp|gc|gci|gcm|gcs|gdr|ghy|gi|gjb|gl|gm|gmo|gp|gps/,
131 /group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md/,
132 /measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri/,
133 /rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls/,
134 /sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|where|wjb|write/
135 ], { prefix: '', suffix: '' });
136 var variableBuiltins = buildRegexp([
137 /[$?^_]|Args|ConfirmPreference|ConsoleFileName|DebugPreference|Error|ErrorActionPreference|ErrorView|ExecutionContext/,
138 /FormatEnumerationLimit|Home|Host|Input|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount/,
139 /MaximumHistoryCount|MaximumVariableCount|MyInvocation|NestedPromptLevel|OutputEncoding|Pid|Profile|ProgressPreference/,
140 /PSBoundParameters|PSCommandPath|PSCulture|PSDefaultParameterValues|PSEmailServer|PSHome|PSScriptRoot|PSSessionApplicationName/,
141 /PSSessionConfigurationName|PSSessionOption|PSUICulture|PSVersionTable|Pwd|ShellId|StackTrace|VerbosePreference/,
142 /WarningPreference|WhatIfPreference/,
143
144 /Event|EventArgs|EventSubscriber|Sender/,
145 /Matches|Ofs|ForEach|LastExitCode|PSCmdlet|PSItem|PSSenderInfo|This/,
146 /true|false|null/
147 ], { prefix: '\\$', suffix: '' });
148
149 var builtins = buildRegexp([symbolBuiltins, namedBuiltins, variableBuiltins], { suffix: notCharacterOrDash });
150
151 var grammar = {
152 keyword: keywords,
153 number: numbers,
154 operator: operators,
155 builtin: builtins,
156 punctuation: punctuation,
157 identifier: identifiers
158 };
159
160 // tokenizers
161 function tokenBase(stream, state) {
162 // Handle Comments
163 //var ch = stream.peek();
164
165 var parent = state.returnStack[state.returnStack.length - 1];
166 if (parent && parent.shouldReturnFrom(state)) {
167 state.tokenize = parent.tokenize;
168 state.returnStack.pop();
169 return state.tokenize(stream, state);
170 }
171
172 if (stream.eatSpace()) {
173 return null;
174 }
175
176 if (stream.eat('(')) {
177 state.bracketNesting += 1;
178 return 'punctuation';
179 }
180
181 if (stream.eat(')')) {
182 state.bracketNesting -= 1;
183 return 'punctuation';
184 }
185
186 for (var key in grammar) {
187 if (stream.match(grammar[key])) {
188 return key;
189 }
190 }
191
192 var ch = stream.next();
193
194 // single-quote string
195 if (ch === "'") {
196 return tokenSingleQuoteString(stream, state);
197 }
198
199 if (ch === '$') {
200 return tokenVariable(stream, state);
201 }
202
203 // double-quote string
204 if (ch === '"') {
205 return tokenDoubleQuoteString(stream, state);
206 }
207
208 if (ch === '<' && stream.eat('#')) {
209 state.tokenize = tokenComment;
210 return tokenComment(stream, state);
211 }
212
213 if (ch === '#') {
214 stream.skipToEnd();
215 return 'comment';
216 }
217
218 if (ch === '@') {
219 var quoteMatch = stream.eat(/["']/);
220 if (quoteMatch && stream.eol()) {
221 state.tokenize = tokenMultiString;
222 state.startQuote = quoteMatch[0];
223 return tokenMultiString(stream, state);
224 } else if (stream.peek().match(/[({]/)) {
225 return 'punctuation';
226 } else if (stream.peek().match(varNames)) {
227 // splatted variable
228 return tokenVariable(stream, state);
229 }
230 }
231 return 'error';
232 }
233
234 function tokenSingleQuoteString(stream, state) {
235 var ch;
236 while ((ch = stream.peek()) != null) {
237 stream.next();
238
239 if (ch === "'" && !stream.eat("'")) {
240 state.tokenize = tokenBase;
241 return 'string';
242 }
243 }
244
245 return 'error';
246 }
247
248 function tokenDoubleQuoteString(stream, state) {
249 var ch;
250 while ((ch = stream.peek()) != null) {
251 if (ch === '$') {
252 state.tokenize = tokenStringInterpolation;
253 return 'string';
254 }
255
256 stream.next();
257 if (ch === '`') {
258 stream.next();
259 continue;
260 }
261
262 if (ch === '"' && !stream.eat('"')) {
263 state.tokenize = tokenBase;
264 return 'string';
265 }
266 }
267
268 return 'error';
269 }
270
271 function tokenStringInterpolation(stream, state) {
272 return tokenInterpolation(stream, state, tokenDoubleQuoteString);
273 }
274
275 function tokenMultiStringReturn(stream, state) {
276 state.tokenize = tokenMultiString;
277 state.startQuote = '"'
278 return tokenMultiString(stream, state);
279 }
280
281 function tokenHereStringInterpolation(stream, state) {
282 return tokenInterpolation(stream, state, tokenMultiStringReturn);
283 }
284
285 function tokenInterpolation(stream, state, parentTokenize) {
286 if (stream.match('$(')) {
287 var savedBracketNesting = state.bracketNesting;
288 state.returnStack.push({
289 /*jshint loopfunc:true */
290 shouldReturnFrom: function(state) {
291 return state.bracketNesting === savedBracketNesting;
292 },
293 tokenize: parentTokenize
294 });
295 state.tokenize = tokenBase;
296 state.bracketNesting += 1;
297 return 'punctuation';
298 } else {
299 stream.next();
300 state.returnStack.push({
301 shouldReturnFrom: function() { return true; },
302 tokenize: parentTokenize
303 });
304 state.tokenize = tokenVariable;
305 return state.tokenize(stream, state);
306 }
307 }
308
309 function tokenComment(stream, state) {
310 var maybeEnd = false, ch;
311 while ((ch = stream.next()) != null) {
312 if (maybeEnd && ch == '>') {
313 state.tokenize = tokenBase;
314 break;
315 }
316 maybeEnd = (ch === '#');
317 }
318 return 'comment';
319 }
320
321 function tokenVariable(stream, state) {
322 var ch = stream.peek();
323 if (stream.eat('{')) {
324 state.tokenize = tokenVariableWithBraces;
325 return tokenVariableWithBraces(stream, state);
326 } else if (ch != undefined && ch.match(varNames)) {
327 stream.eatWhile(varNames);
328 state.tokenize = tokenBase;
329 return 'variable-2';
330 } else {
331 state.tokenize = tokenBase;
332 return 'error';
333 }
334 }
335
336 function tokenVariableWithBraces(stream, state) {
337 var ch;
338 while ((ch = stream.next()) != null) {
339 if (ch === '}') {
340 state.tokenize = tokenBase;
341 break;
342 }
343 }
344 return 'variable-2';
345 }
346
347 function tokenMultiString(stream, state) {
348 var quote = state.startQuote;
349 if (stream.sol() && stream.match(new RegExp(quote + '@'))) {
350 state.tokenize = tokenBase;
351 }
352 else if (quote === '"') {
353 while (!stream.eol()) {
354 var ch = stream.peek();
355 if (ch === '$') {
356 state.tokenize = tokenHereStringInterpolation;
357 return 'string';
358 }
359
360 stream.next();
361 if (ch === '`') {
362 stream.next();
363 }
364 }
365 }
366 else {
367 stream.skipToEnd();
368 }
369
370 return 'string';
371 }
372
373 var external = {
374 startState: function() {
375 return {
376 returnStack: [],
377 bracketNesting: 0,
378 tokenize: tokenBase
379 };
380 },
381
382 token: function(stream, state) {
383 return state.tokenize(stream, state);
384 },
385
386 blockCommentStart: '<#',
387 blockCommentEnd: '#>',
388 lineComment: '#',
389 fold: 'brace'
390 };
391 return external;
392 });
393
394 CodeMirror.defineMIME('application/x-powershell', 'powershell');
395 });
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 var mode = CodeMirror.getMode({indentUnit: 2}, "powershell");
5 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
6
7 MT('comment', '[number 1][comment # A]');
8 MT('comment_multiline', '[number 1][comment <#]',
9 '[comment ABC]',
10 '[comment #>][number 2]');
11
12 [
13 '0', '1234',
14 '12kb', '12mb', '12Gb', '12Tb', '12PB', '12L', '12D', '12lkb', '12dtb',
15 '1.234', '1.234e56', '1.', '1.e2', '.2', '.2e34',
16 '1.2MB', '1.kb', '.1dTB', '1.e1gb', '.2', '.2e34',
17 '0x1', '0xabcdef', '0x3tb', '0xelmb'
18 ].forEach(function(number) {
19 MT("number_" + number, "[number " + number + "]");
20 });
21
22 MT('string_literal_escaping', "[string 'a''']");
23 MT('string_literal_variable', "[string 'a $x']");
24 MT('string_escaping_1', '[string "a `""]');
25 MT('string_escaping_2', '[string "a """]');
26 MT('string_variable_escaping', '[string "a `$x"]');
27 MT('string_variable', '[string "a ][variable-2 $x][string b"]');
28 MT('string_variable_spaces', '[string "a ][variable-2 ${x y}][string b"]');
29 MT('string_expression', '[string "a ][punctuation $(][variable-2 $x][operator +][number 3][punctuation )][string b"]');
30 MT('string_expression_nested', '[string "A][punctuation $(][string "a][punctuation $(][string "w"][punctuation )][string b"][punctuation )][string B"]');
31
32 MT('string_heredoc', '[string @"]',
33 '[string abc]',
34 '[string "@]');
35 MT('string_heredoc_quotes', '[string @"]',
36 '[string abc "\']',
37 '[string "@]');
38 MT('string_heredoc_variable', '[string @"]',
39 '[string a ][variable-2 $x][string b]',
40 '[string "@]');
41 MT('string_heredoc_nested_string', '[string @"]',
42 '[string a][punctuation $(][string "w"][punctuation )][string b]',
43 '[string "@]');
44 MT('string_heredoc_literal_quotes', "[string @']",
45 '[string abc "\']',
46 "[string '@]");
47
48 MT('array', "[punctuation @(][string 'a'][punctuation ,][string 'b'][punctuation )]");
49 MT('hash', "[punctuation @{][string 'key'][operator :][string 'value'][punctuation }]");
50
51 MT('variable', "[variable-2 $test]");
52 MT('variable_global', "[variable-2 $global:test]");
53 MT('variable_spaces', "[variable-2 ${test test}]");
54 MT('operator_splat', "[variable-2 @x]");
55 MT('variable_builtin', "[builtin $ErrorActionPreference]");
56 MT('variable_builtin_symbols', "[builtin $$]");
57
58 MT('operator', "[operator +]");
59 MT('operator_unary', "[operator +][number 3]");
60 MT('operator_long', "[operator -match]");
61
62 [
63 '(', ')', '[[', ']]', '{', '}', ',', '`', ';', '.'
64 ].forEach(function(punctuation) {
65 MT("punctuation_" + punctuation.replace(/^[\[\]]/,''), "[punctuation " + punctuation + "]");
66 });
67
68 MT('keyword', "[keyword if]");
69
70 MT('call_builtin', "[builtin Get-ChildItem]");
71 })();
3333 }
3434
3535 if (sol) {
36 while(stream.eatSpace());
36 while(stream.eatSpace()) {}
3737 }
3838
3939 var ch = stream.next();
0 <!doctype html>
1
2 <title>CodeMirror: ProtoBuf mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="protobuf.js"></script>
9 <style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
10 <div id=nav>
11 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
12
13 <ul>
14 <li><a href="../../index.html">Home</a>
15 <li><a href="../../doc/manual.html">Manual</a>
16 <li><a href="https://github.com/codemirror/codemirror">Code</a>
17 </ul>
18 <ul>
19 <li><a href="../index.html">Language modes</a>
20 <li><a class=active href="#">ProtoBuf</a>
21 </ul>
22 </div>
23
24 <article>
25 <h2>ProtoBuf mode</h2>
26 <form><textarea id="code" name="code">
27 package addressbook;
28
29 message Address {
30 required string street = 1;
31 required string postCode = 2;
32 }
33
34 message PhoneNumber {
35 required string number = 1;
36 }
37
38 message Person {
39 optional int32 id = 1;
40 required string name = 2;
41 required string surname = 3;
42 optional Address address = 4;
43 repeated PhoneNumber phoneNumbers = 5;
44 optional uint32 age = 6;
45 repeated uint32 favouriteNumbers = 7;
46 optional string license = 8;
47 enum Gender {
48 MALE = 0;
49 FEMALE = 1;
50 }
51 optional Gender gender = 9;
52 optional fixed64 lastUpdate = 10;
53 required bool deleted = 11 [default = false];
54 }
55
56 </textarea></form>
57 <script>
58 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
59 </script>
60
61 <p><strong>MIME types defined:</strong> <code>text/x-protobuf</code>.</p>
62
63 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 function wordRegexp(words) {
14 return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
15 };
16
17 var keywordArray = [
18 "package", "message", "import", "syntax",
19 "required", "optional", "repeated", "reserved", "default", "extensions", "packed",
20 "bool", "bytes", "double", "enum", "float", "string",
21 "int32", "int64", "uint32", "uint64", "sint32", "sint64", "fixed32", "fixed64", "sfixed32", "sfixed64"
22 ];
23 var keywords = wordRegexp(keywordArray);
24
25 CodeMirror.registerHelper("hintWords", "protobuf", keywordArray);
26
27 var identifiers = new RegExp("^[_A-Za-z\xa1-\uffff][_A-Za-z0-9\xa1-\uffff]*");
28
29 function tokenBase(stream) {
30 // whitespaces
31 if (stream.eatSpace()) return null;
32
33 // Handle one line Comments
34 if (stream.match("//")) {
35 stream.skipToEnd();
36 return "comment";
37 }
38
39 // Handle Number Literals
40 if (stream.match(/^[0-9\.+-]/, false)) {
41 if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
42 return "number";
43 if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
44 return "number";
45 if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
46 return "number";
47 }
48
49 // Handle Strings
50 if (stream.match(/^"([^"]|(""))*"/)) { return "string"; }
51 if (stream.match(/^'([^']|(''))*'/)) { return "string"; }
52
53 // Handle words
54 if (stream.match(keywords)) { return "keyword"; }
55 if (stream.match(identifiers)) { return "variable"; } ;
56
57 // Handle non-detected items
58 stream.next();
59 return null;
60 };
61
62 CodeMirror.defineMode("protobuf", function() {
63 return {token: tokenBase};
64 });
65
66 CodeMirror.defineMIME("text/x-protobuf", "protobuf");
67 });
0 <!doctype html>
1
2 <title>CodeMirror: Pug Templating Mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../javascript/javascript.js"></script>
9 <script src="../css/css.js"></script>
10 <script src="../xml/xml.js"></script>
11 <script src="../htmlmixed/htmlmixed.js"></script>
12 <script src="pug.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="#">Pug Templating Mode</a>
25 </ul>
26 </div>
27
28 <article>
29 <h2>Pug Templating Mode</h2>
30 <form><textarea id="code" name="code">
31 doctype html
32 html
33 head
34 title= "Pug Templating CodeMirror Mode Example"
35 link(rel='stylesheet', href='/css/bootstrap.min.css')
36 link(rel='stylesheet', href='/css/index.css')
37 script(type='text/javascript', src='/js/jquery-1.9.1.min.js')
38 script(type='text/javascript', src='/js/bootstrap.min.js')
39 body
40 div.header
41 h1 Welcome to this Example
42 div.spots
43 if locals.spots
44 each spot in spots
45 div.spot.well
46 div
47 if spot.logo
48 img.img-rounded.logo(src=spot.logo)
49 else
50 img.img-rounded.logo(src="img/placeholder.png")
51 h3
52 a(href=spot.hash) ##{spot.hash}
53 if spot.title
54 span.title #{spot.title}
55 if spot.desc
56 div #{spot.desc}
57 else
58 h3 There are no spots currently available.
59 </textarea></form>
60 <script>
61 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
62 mode: {name: "pug", alignCDATA: true},
63 lineNumbers: true
64 });
65 </script>
66 <h3>The Pug Templating Mode</h3>
67 <p> Created by Forbes Lindesay. Managed as part of a Brackets extension at <a href="https://github.com/ForbesLindesay/jade-brackets">https://github.com/ForbesLindesay/jade-brackets</a>.</p>
68 <p><strong>MIME type defined:</strong> <code>text/x-pug</code>, <code>text/x-jade</code>.</p>
69 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"), require("../javascript/javascript"), require("../css/css"), require("../htmlmixed/htmlmixed"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror", "../javascript/javascript", "../css/css", "../htmlmixed/htmlmixed"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 CodeMirror.defineMode("pug", function (config) {
14 // token types
15 var KEYWORD = 'keyword';
16 var DOCTYPE = 'meta';
17 var ID = 'builtin';
18 var CLASS = 'qualifier';
19
20 var ATTRS_NEST = {
21 '{': '}',
22 '(': ')',
23 '[': ']'
24 };
25
26 var jsMode = CodeMirror.getMode(config, 'javascript');
27
28 function State() {
29 this.javaScriptLine = false;
30 this.javaScriptLineExcludesColon = false;
31
32 this.javaScriptArguments = false;
33 this.javaScriptArgumentsDepth = 0;
34
35 this.isInterpolating = false;
36 this.interpolationNesting = 0;
37
38 this.jsState = CodeMirror.startState(jsMode);
39
40 this.restOfLine = '';
41
42 this.isIncludeFiltered = false;
43 this.isEach = false;
44
45 this.lastTag = '';
46 this.scriptType = '';
47
48 // Attributes Mode
49 this.isAttrs = false;
50 this.attrsNest = [];
51 this.inAttributeName = true;
52 this.attributeIsType = false;
53 this.attrValue = '';
54
55 // Indented Mode
56 this.indentOf = Infinity;
57 this.indentToken = '';
58
59 this.innerMode = null;
60 this.innerState = null;
61
62 this.innerModeForLine = false;
63 }
64 /**
65 * Safely copy a state
66 *
67 * @return {State}
68 */
69 State.prototype.copy = function () {
70 var res = new State();
71 res.javaScriptLine = this.javaScriptLine;
72 res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon;
73 res.javaScriptArguments = this.javaScriptArguments;
74 res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth;
75 res.isInterpolating = this.isInterpolating;
76 res.interpolationNesting = this.interpolationNesting;
77
78 res.jsState = CodeMirror.copyState(jsMode, this.jsState);
79
80 res.innerMode = this.innerMode;
81 if (this.innerMode && this.innerState) {
82 res.innerState = CodeMirror.copyState(this.innerMode, this.innerState);
83 }
84
85 res.restOfLine = this.restOfLine;
86
87 res.isIncludeFiltered = this.isIncludeFiltered;
88 res.isEach = this.isEach;
89 res.lastTag = this.lastTag;
90 res.scriptType = this.scriptType;
91 res.isAttrs = this.isAttrs;
92 res.attrsNest = this.attrsNest.slice();
93 res.inAttributeName = this.inAttributeName;
94 res.attributeIsType = this.attributeIsType;
95 res.attrValue = this.attrValue;
96 res.indentOf = this.indentOf;
97 res.indentToken = this.indentToken;
98
99 res.innerModeForLine = this.innerModeForLine;
100
101 return res;
102 };
103
104 function javaScript(stream, state) {
105 if (stream.sol()) {
106 // if javaScriptLine was set at end of line, ignore it
107 state.javaScriptLine = false;
108 state.javaScriptLineExcludesColon = false;
109 }
110 if (state.javaScriptLine) {
111 if (state.javaScriptLineExcludesColon && stream.peek() === ':') {
112 state.javaScriptLine = false;
113 state.javaScriptLineExcludesColon = false;
114 return;
115 }
116 var tok = jsMode.token(stream, state.jsState);
117 if (stream.eol()) state.javaScriptLine = false;
118 return tok || true;
119 }
120 }
121 function javaScriptArguments(stream, state) {
122 if (state.javaScriptArguments) {
123 if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== '(') {
124 state.javaScriptArguments = false;
125 return;
126 }
127 if (stream.peek() === '(') {
128 state.javaScriptArgumentsDepth++;
129 } else if (stream.peek() === ')') {
130 state.javaScriptArgumentsDepth--;
131 }
132 if (state.javaScriptArgumentsDepth === 0) {
133 state.javaScriptArguments = false;
134 return;
135 }
136
137 var tok = jsMode.token(stream, state.jsState);
138 return tok || true;
139 }
140 }
141
142 function yieldStatement(stream) {
143 if (stream.match(/^yield\b/)) {
144 return 'keyword';
145 }
146 }
147
148 function doctype(stream) {
149 if (stream.match(/^(?:doctype) *([^\n]+)?/)) {
150 return DOCTYPE;
151 }
152 }
153
154 function interpolation(stream, state) {
155 if (stream.match('#{')) {
156 state.isInterpolating = true;
157 state.interpolationNesting = 0;
158 return 'punctuation';
159 }
160 }
161
162 function interpolationContinued(stream, state) {
163 if (state.isInterpolating) {
164 if (stream.peek() === '}') {
165 state.interpolationNesting--;
166 if (state.interpolationNesting < 0) {
167 stream.next();
168 state.isInterpolating = false;
169 return 'punctuation';
170 }
171 } else if (stream.peek() === '{') {
172 state.interpolationNesting++;
173 }
174 return jsMode.token(stream, state.jsState) || true;
175 }
176 }
177
178 function caseStatement(stream, state) {
179 if (stream.match(/^case\b/)) {
180 state.javaScriptLine = true;
181 return KEYWORD;
182 }
183 }
184
185 function when(stream, state) {
186 if (stream.match(/^when\b/)) {
187 state.javaScriptLine = true;
188 state.javaScriptLineExcludesColon = true;
189 return KEYWORD;
190 }
191 }
192
193 function defaultStatement(stream) {
194 if (stream.match(/^default\b/)) {
195 return KEYWORD;
196 }
197 }
198
199 function extendsStatement(stream, state) {
200 if (stream.match(/^extends?\b/)) {
201 state.restOfLine = 'string';
202 return KEYWORD;
203 }
204 }
205
206 function append(stream, state) {
207 if (stream.match(/^append\b/)) {
208 state.restOfLine = 'variable';
209 return KEYWORD;
210 }
211 }
212 function prepend(stream, state) {
213 if (stream.match(/^prepend\b/)) {
214 state.restOfLine = 'variable';
215 return KEYWORD;
216 }
217 }
218 function block(stream, state) {
219 if (stream.match(/^block\b *(?:(prepend|append)\b)?/)) {
220 state.restOfLine = 'variable';
221 return KEYWORD;
222 }
223 }
224
225 function include(stream, state) {
226 if (stream.match(/^include\b/)) {
227 state.restOfLine = 'string';
228 return KEYWORD;
229 }
230 }
231
232 function includeFiltered(stream, state) {
233 if (stream.match(/^include:([a-zA-Z0-9\-]+)/, false) && stream.match('include')) {
234 state.isIncludeFiltered = true;
235 return KEYWORD;
236 }
237 }
238
239 function includeFilteredContinued(stream, state) {
240 if (state.isIncludeFiltered) {
241 var tok = filter(stream, state);
242 state.isIncludeFiltered = false;
243 state.restOfLine = 'string';
244 return tok;
245 }
246 }
247
248 function mixin(stream, state) {
249 if (stream.match(/^mixin\b/)) {
250 state.javaScriptLine = true;
251 return KEYWORD;
252 }
253 }
254
255 function call(stream, state) {
256 if (stream.match(/^\+([-\w]+)/)) {
257 if (!stream.match(/^\( *[-\w]+ *=/, false)) {
258 state.javaScriptArguments = true;
259 state.javaScriptArgumentsDepth = 0;
260 }
261 return 'variable';
262 }
263 if (stream.match(/^\+#{/, false)) {
264 stream.next();
265 state.mixinCallAfter = true;
266 return interpolation(stream, state);
267 }
268 }
269 function callArguments(stream, state) {
270 if (state.mixinCallAfter) {
271 state.mixinCallAfter = false;
272 if (!stream.match(/^\( *[-\w]+ *=/, false)) {
273 state.javaScriptArguments = true;
274 state.javaScriptArgumentsDepth = 0;
275 }
276 return true;
277 }
278 }
279
280 function conditional(stream, state) {
281 if (stream.match(/^(if|unless|else if|else)\b/)) {
282 state.javaScriptLine = true;
283 return KEYWORD;
284 }
285 }
286
287 function each(stream, state) {
288 if (stream.match(/^(- *)?(each|for)\b/)) {
289 state.isEach = true;
290 return KEYWORD;
291 }
292 }
293 function eachContinued(stream, state) {
294 if (state.isEach) {
295 if (stream.match(/^ in\b/)) {
296 state.javaScriptLine = true;
297 state.isEach = false;
298 return KEYWORD;
299 } else if (stream.sol() || stream.eol()) {
300 state.isEach = false;
301 } else if (stream.next()) {
302 while (!stream.match(/^ in\b/, false) && stream.next());
303 return 'variable';
304 }
305 }
306 }
307
308 function whileStatement(stream, state) {
309 if (stream.match(/^while\b/)) {
310 state.javaScriptLine = true;
311 return KEYWORD;
312 }
313 }
314
315 function tag(stream, state) {
316 var captures;
317 if (captures = stream.match(/^(\w(?:[-:\w]*\w)?)\/?/)) {
318 state.lastTag = captures[1].toLowerCase();
319 if (state.lastTag === 'script') {
320 state.scriptType = 'application/javascript';
321 }
322 return 'tag';
323 }
324 }
325
326 function filter(stream, state) {
327 if (stream.match(/^:([\w\-]+)/)) {
328 var innerMode;
329 if (config && config.innerModes) {
330 innerMode = config.innerModes(stream.current().substring(1));
331 }
332 if (!innerMode) {
333 innerMode = stream.current().substring(1);
334 }
335 if (typeof innerMode === 'string') {
336 innerMode = CodeMirror.getMode(config, innerMode);
337 }
338 setInnerMode(stream, state, innerMode);
339 return 'atom';
340 }
341 }
342
343 function code(stream, state) {
344 if (stream.match(/^(!?=|-)/)) {
345 state.javaScriptLine = true;
346 return 'punctuation';
347 }
348 }
349
350 function id(stream) {
351 if (stream.match(/^#([\w-]+)/)) {
352 return ID;
353 }
354 }
355
356 function className(stream) {
357 if (stream.match(/^\.([\w-]+)/)) {
358 return CLASS;
359 }
360 }
361
362 function attrs(stream, state) {
363 if (stream.peek() == '(') {
364 stream.next();
365 state.isAttrs = true;
366 state.attrsNest = [];
367 state.inAttributeName = true;
368 state.attrValue = '';
369 state.attributeIsType = false;
370 return 'punctuation';
371 }
372 }
373
374 function attrsContinued(stream, state) {
375 if (state.isAttrs) {
376 if (ATTRS_NEST[stream.peek()]) {
377 state.attrsNest.push(ATTRS_NEST[stream.peek()]);
378 }
379 if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) {
380 state.attrsNest.pop();
381 } else if (stream.eat(')')) {
382 state.isAttrs = false;
383 return 'punctuation';
384 }
385 if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) {
386 if (stream.peek() === '=' || stream.peek() === '!') {
387 state.inAttributeName = false;
388 state.jsState = CodeMirror.startState(jsMode);
389 if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') {
390 state.attributeIsType = true;
391 } else {
392 state.attributeIsType = false;
393 }
394 }
395 return 'attribute';
396 }
397
398 var tok = jsMode.token(stream, state.jsState);
399 if (state.attributeIsType && tok === 'string') {
400 state.scriptType = stream.current().toString();
401 }
402 if (state.attrsNest.length === 0 && (tok === 'string' || tok === 'variable' || tok === 'keyword')) {
403 try {
404 Function('', 'var x ' + state.attrValue.replace(/,\s*$/, '').replace(/^!/, ''));
405 state.inAttributeName = true;
406 state.attrValue = '';
407 stream.backUp(stream.current().length);
408 return attrsContinued(stream, state);
409 } catch (ex) {
410 //not the end of an attribute
411 }
412 }
413 state.attrValue += stream.current();
414 return tok || true;
415 }
416 }
417
418 function attributesBlock(stream, state) {
419 if (stream.match(/^&attributes\b/)) {
420 state.javaScriptArguments = true;
421 state.javaScriptArgumentsDepth = 0;
422 return 'keyword';
423 }
424 }
425
426 function indent(stream) {
427 if (stream.sol() && stream.eatSpace()) {
428 return 'indent';
429 }
430 }
431
432 function comment(stream, state) {
433 if (stream.match(/^ *\/\/(-)?([^\n]*)/)) {
434 state.indentOf = stream.indentation();
435 state.indentToken = 'comment';
436 return 'comment';
437 }
438 }
439
440 function colon(stream) {
441 if (stream.match(/^: */)) {
442 return 'colon';
443 }
444 }
445
446 function text(stream, state) {
447 if (stream.match(/^(?:\| ?| )([^\n]+)/)) {
448 return 'string';
449 }
450 if (stream.match(/^(<[^\n]*)/, false)) {
451 // html string
452 setInnerMode(stream, state, 'htmlmixed');
453 state.innerModeForLine = true;
454 return innerMode(stream, state, true);
455 }
456 }
457
458 function dot(stream, state) {
459 if (stream.eat('.')) {
460 var innerMode = null;
461 if (state.lastTag === 'script' && state.scriptType.toLowerCase().indexOf('javascript') != -1) {
462 innerMode = state.scriptType.toLowerCase().replace(/"|'/g, '');
463 } else if (state.lastTag === 'style') {
464 innerMode = 'css';
465 }
466 setInnerMode(stream, state, innerMode);
467 return 'dot';
468 }
469 }
470
471 function fail(stream) {
472 stream.next();
473 return null;
474 }
475
476
477 function setInnerMode(stream, state, mode) {
478 mode = CodeMirror.mimeModes[mode] || mode;
479 mode = config.innerModes ? config.innerModes(mode) || mode : mode;
480 mode = CodeMirror.mimeModes[mode] || mode;
481 mode = CodeMirror.getMode(config, mode);
482 state.indentOf = stream.indentation();
483
484 if (mode && mode.name !== 'null') {
485 state.innerMode = mode;
486 } else {
487 state.indentToken = 'string';
488 }
489 }
490 function innerMode(stream, state, force) {
491 if (stream.indentation() > state.indentOf || (state.innerModeForLine && !stream.sol()) || force) {
492 if (state.innerMode) {
493 if (!state.innerState) {
494 state.innerState = state.innerMode.startState ? CodeMirror.startState(state.innerMode, stream.indentation()) : {};
495 }
496 return stream.hideFirstChars(state.indentOf + 2, function () {
497 return state.innerMode.token(stream, state.innerState) || true;
498 });
499 } else {
500 stream.skipToEnd();
501 return state.indentToken;
502 }
503 } else if (stream.sol()) {
504 state.indentOf = Infinity;
505 state.indentToken = null;
506 state.innerMode = null;
507 state.innerState = null;
508 }
509 }
510 function restOfLine(stream, state) {
511 if (stream.sol()) {
512 // if restOfLine was set at end of line, ignore it
513 state.restOfLine = '';
514 }
515 if (state.restOfLine) {
516 stream.skipToEnd();
517 var tok = state.restOfLine;
518 state.restOfLine = '';
519 return tok;
520 }
521 }
522
523
524 function startState() {
525 return new State();
526 }
527 function copyState(state) {
528 return state.copy();
529 }
530 /**
531 * Get the next token in the stream
532 *
533 * @param {Stream} stream
534 * @param {State} state
535 */
536 function nextToken(stream, state) {
537 var tok = innerMode(stream, state)
538 || restOfLine(stream, state)
539 || interpolationContinued(stream, state)
540 || includeFilteredContinued(stream, state)
541 || eachContinued(stream, state)
542 || attrsContinued(stream, state)
543 || javaScript(stream, state)
544 || javaScriptArguments(stream, state)
545 || callArguments(stream, state)
546
547 || yieldStatement(stream, state)
548 || doctype(stream, state)
549 || interpolation(stream, state)
550 || caseStatement(stream, state)
551 || when(stream, state)
552 || defaultStatement(stream, state)
553 || extendsStatement(stream, state)
554 || append(stream, state)
555 || prepend(stream, state)
556 || block(stream, state)
557 || include(stream, state)
558 || includeFiltered(stream, state)
559 || mixin(stream, state)
560 || call(stream, state)
561 || conditional(stream, state)
562 || each(stream, state)
563 || whileStatement(stream, state)
564 || tag(stream, state)
565 || filter(stream, state)
566 || code(stream, state)
567 || id(stream, state)
568 || className(stream, state)
569 || attrs(stream, state)
570 || attributesBlock(stream, state)
571 || indent(stream, state)
572 || text(stream, state)
573 || comment(stream, state)
574 || colon(stream, state)
575 || dot(stream, state)
576 || fail(stream, state);
577
578 return tok === true ? null : tok;
579 }
580 return {
581 startState: startState,
582 copyState: copyState,
583 token: nextToken
584 };
585 }, 'javascript', 'css', 'htmlmixed');
586
587 CodeMirror.defineMIME('text/x-pug', 'pug');
588 CodeMirror.defineMIME('text/x-jade', 'pug');
589
590 });
125125 if (word && words.hasOwnProperty(word)) {
126126 // Negates the initial next()
127127 stream.backUp(1);
128 // Acutally move the stream
128 // rs move the stream
129129 stream.match(/[\w]+/);
130130 // We want to process these words differently
131131 // do to the importance they have in Puppet
175175 </script>
176176 <h2>Configuration Options for Python mode:</h2>
177177 <ul>
178 <li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
178 <li>version - 2/3 - The version of Python to recognize. Default is 3.</li>
179179 <li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
180180 <li>hangingIndent - int - If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.</li>
181181 </ul>
185185 <li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre> including <pre>@</pre> on Python 3</li>
186186 <li>singleDelimiters - RegEx - Regular Expression for single delimiter matching, default : <pre>^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]</pre></li>
187187 <li>doubleOperators - RegEx - Regular Expression for double operators matching, default : <pre>^((==)|(!=)|(&lt;=)|(&gt;=)|(&lt;&gt;)|(&lt;&lt;)|(&gt;&gt;)|(//)|(\\*\\*))</pre></li>
188 <li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
188 <li>doubleDelimiters - RegEx - Regular Expression for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
189189 <li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(&gt;&gt;=)|(&lt;&lt;=)|(\\*\\*=))</pre></li>
190190 <li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre> on Python 2 and <pre>^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*</pre> on Python 3.</li>
191191 <li>extra_keywords - list of string - List of extra words ton consider as keywords</li>
3131 "sorted", "staticmethod", "str", "sum", "super", "tuple",
3232 "type", "vars", "zip", "__import__", "NotImplemented",
3333 "Ellipsis", "__debug__"];
34 var py2 = {builtins: ["apply", "basestring", "buffer", "cmp", "coerce", "execfile",
35 "file", "intern", "long", "raw_input", "reduce", "reload",
36 "unichr", "unicode", "xrange", "False", "True", "None"],
37 keywords: ["exec", "print"]};
38 var py3 = {builtins: ["ascii", "bytes", "exec", "print"],
39 keywords: ["nonlocal", "False", "True", "None", "async", "await"]};
40
4134 CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins));
4235
4336 function top(state) {
4740 CodeMirror.defineMode("python", function(conf, parserConf) {
4841 var ERRORCLASS = "error";
4942
50 var singleDelimiters = parserConf.singleDelimiters || new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]");
51 var doubleOperators = parserConf.doubleOperators || new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
52 var doubleDelimiters = parserConf.doubleDelimiters || new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
53 var tripleDelimiters = parserConf.tripleDelimiters || new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
54
55 if (parserConf.version && parseInt(parserConf.version, 10) == 3){
56 // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
57 var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!@]");
58 var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
43 var singleDelimiters = parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.]/;
44 var doubleOperators = parserConf.doubleOperators || /^([!<>]==|<>|<<|>>|\/\/|\*\*)/;
45 var doubleDelimiters = parserConf.doubleDelimiters || /^(\+=|\-=|\*=|%=|\/=|&=|\|=|\^=)/;
46 var tripleDelimiters = parserConf.tripleDelimiters || /^(\/\/=|>>=|<<=|\*\*=)/;
47
48 var hangingIndent = parserConf.hangingIndent || conf.indentUnit;
49
50 var myKeywords = commonKeywords, myBuiltins = commonBuiltins;
51 if (parserConf.extra_keywords != undefined)
52 myKeywords = myKeywords.concat(parserConf.extra_keywords);
53
54 if (parserConf.extra_builtins != undefined)
55 myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
56
57 var py3 = !(parserConf.version && Number(parserConf.version) < 3)
58 if (py3) {
59 // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
60 var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/;
61 var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;
62 myKeywords = myKeywords.concat(["nonlocal", "False", "True", "None", "async", "await"]);
63 myBuiltins = myBuiltins.concat(["ascii", "bytes", "exec", "print"]);
64 var stringPrefixes = new RegExp("^(([rbuf]|(br))?('{3}|\"{3}|['\"]))", "i");
5965 } else {
60 var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
61 var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
62 }
63
64 var hangingIndent = parserConf.hangingIndent || conf.indentUnit;
65
66 var myKeywords = commonKeywords, myBuiltins = commonBuiltins;
67 if(parserConf.extra_keywords != undefined){
68 myKeywords = myKeywords.concat(parserConf.extra_keywords);
69 }
70 if(parserConf.extra_builtins != undefined){
71 myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
72 }
73 if (parserConf.version && parseInt(parserConf.version, 10) == 3) {
74 myKeywords = myKeywords.concat(py3.keywords);
75 myBuiltins = myBuiltins.concat(py3.builtins);
76 var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
77 } else {
78 myKeywords = myKeywords.concat(py2.keywords);
79 myBuiltins = myBuiltins.concat(py2.builtins);
66 var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!]/;
67 var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*/;
68 myKeywords = myKeywords.concat(["exec", "print"]);
69 myBuiltins = myBuiltins.concat(["apply", "basestring", "buffer", "cmp", "coerce", "execfile",
70 "file", "intern", "long", "raw_input", "reduce", "reload",
71 "unichr", "unicode", "xrange", "False", "True", "None"]);
8072 var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
8173 }
8274 var keywords = wordRegexp(myKeywords);
8476
8577 // tokenizers
8678 function tokenBase(stream, state) {
79 if (stream.sol()) state.indent = stream.indentation()
8780 // Handle scope changes
8881 if (stream.sol() && top(state).type == "py") {
8982 var scopeOffset = top(state).offset;
9083 if (stream.eatSpace()) {
9184 var lineOffset = stream.indentation();
9285 if (lineOffset > scopeOffset)
93 pushScope(stream, state, "py");
86 pushPyScope(state);
9487 else if (lineOffset < scopeOffset && dedent(stream, state))
9588 state.errorToken = true;
9689 return null;
159152
160153 // Handle operators and Delimiters
161154 if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters))
162 return null;
155 return "punctuation";
163156
164157 if (stream.match(doubleOperators) || stream.match(singleOperators))
165158 return "operator";
166159
167160 if (stream.match(singleDelimiters))
168 return null;
161 return "punctuation";
162
163 if (state.lastToken == "." && stream.match(identifiers))
164 return "property";
169165
170166 if (stream.match(keywords) || stream.match(wordOperators))
171167 return "keyword";
188184 }
189185
190186 function tokenStringFactory(delimiter) {
191 while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
187 while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
192188 delimiter = delimiter.substr(1);
193189
194190 var singleline = delimiter.length == 1;
220216 return tokenString;
221217 }
222218
223 function pushScope(stream, state, type) {
224 var offset = 0, align = null;
225 if (type == "py") {
226 while (top(state).type != "py")
227 state.scopes.pop();
228 }
229 offset = top(state).offset + (type == "py" ? conf.indentUnit : hangingIndent);
230 if (type != "py" && !stream.match(/^(\s|#.*)*$/, false))
231 align = stream.column() + 1;
232 state.scopes.push({offset: offset, type: type, align: align});
219 function pushPyScope(state) {
220 while (top(state).type != "py") state.scopes.pop()
221 state.scopes.push({offset: top(state).offset + conf.indentUnit,
222 type: "py",
223 align: null})
224 }
225
226 function pushBracketScope(stream, state, type) {
227 var align = stream.match(/^([\s\[\{\(]|#.*)*$/, false) ? null : stream.column() + 1
228 state.scopes.push({offset: state.indent + hangingIndent,
229 type: type,
230 align: align})
233231 }
234232
235233 function dedent(stream, state) {
236234 var indented = stream.indentation();
237 while (top(state).offset > indented) {
235 while (state.scopes.length > 1 && top(state).offset > indented) {
238236 if (top(state).type != "py") return true;
239237 state.scopes.pop();
240238 }
242240 }
243241
244242 function tokenLexer(stream, state) {
243 if (stream.sol()) state.beginningOfLine = true;
244
245245 var style = state.tokenize(stream, state);
246246 var current = stream.current();
247247
248 // Handle '.' connected identifiers
249 if (current == ".") {
250 style = stream.match(identifiers, false) ? null : ERRORCLASS;
251 if (style == null && state.lastStyle == "meta") {
252 // Apply 'meta' style to '.' connected identifiers when
253 // appropriate.
254 style = "meta";
255 }
256 return style;
257 }
258
259248 // Handle decorators
260 if (current == "@"){
261 if(parserConf.version && parseInt(parserConf.version, 10) == 3){
262 return stream.match(identifiers, false) ? "meta" : "operator";
263 } else {
264 return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
265 }
266 }
249 if (state.beginningOfLine && current == "@")
250 return stream.match(identifiers, false) ? "meta" : py3 ? "operator" : ERRORCLASS;
251
252 if (/\S/.test(current)) state.beginningOfLine = false;
267253
268254 if ((style == "variable" || style == "builtin")
269 && state.lastStyle == "meta")
255 && state.lastToken == "meta")
270256 style = "meta";
271257
272258 // Handle scope changes.
275261
276262 if (current == "lambda") state.lambda = true;
277263 if (current == ":" && !state.lambda && top(state).type == "py")
278 pushScope(stream, state, "py");
264 pushPyScope(state);
279265
280266 var delimiter_index = current.length == 1 ? "[({".indexOf(current) : -1;
281267 if (delimiter_index != -1)
282 pushScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
268 pushBracketScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
283269
284270 delimiter_index = "])}".indexOf(current);
285271 if (delimiter_index != -1) {
286 if (top(state).type == current) state.scopes.pop();
272 if (top(state).type == current) state.indent = state.scopes.pop().offset - hangingIndent
287273 else return ERRORCLASS;
288274 }
289275 if (state.dedent > 0 && stream.eol() && top(state).type == "py") {
299285 return {
300286 tokenize: tokenBase,
301287 scopes: [{offset: basecolumn || 0, type: "py", align: null}],
302 lastStyle: null,
288 indent: basecolumn || 0,
303289 lastToken: null,
304290 lambda: false,
305291 dedent: 0
311297 if (addErr) state.errorToken = false;
312298 var style = tokenLexer(stream, state);
313299
314 state.lastStyle = style;
315
316 var current = stream.current();
317 if (current && style)
318 state.lastToken = current;
300 if (style && style != "comment")
301 state.lastToken = (style == "keyword" || style == "punctuation") ? stream.current() : style;
302 if (style == "punctuation") style = null;
319303
320304 if (stream.eol() && state.lambda)
321305 state.lambda = false;
326310 if (state.tokenize != tokenBase)
327311 return state.tokenize.isString ? CodeMirror.Pass : 0;
328312
329 var scope = top(state);
330 var closing = textAfter && textAfter.charAt(0) == scope.type;
313 var scope = top(state), closing = scope.type == textAfter.charAt(0)
331314 if (scope.align != null)
332 return scope.align - (closing ? 1 : 0);
333 else if (closing && state.scopes.length > 1)
334 return state.scopes[state.scopes.length - 2].offset;
315 return scope.align - (closing ? 1 : 0)
335316 else
336 return scope.offset;
317 return scope.offset - (closing ? hangingIndent : 0)
337318 },
338319
320 electricInput: /^\s*[\}\]\)]$/,
339321 closeBrackets: {triples: "'\""},
340322 lineComment: "#",
341323 fold: "indent"
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 var mode = CodeMirror.getMode({indentUnit: 4},
5 {name: "python",
6 version: 3,
7 singleLineStringErrors: false});
8 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
9
10 // Error, because "foobarhello" is neither a known type or property, but
11 // property was expected (after "and"), and it should be in parentheses.
12 MT("decoratorStartOfLine",
13 "[meta @dec]",
14 "[keyword def] [def function]():",
15 " [keyword pass]");
16
17 MT("decoratorIndented",
18 "[keyword class] [def Foo]:",
19 " [meta @dec]",
20 " [keyword def] [def function]():",
21 " [keyword pass]");
22
23 MT("matmulWithSpace:", "[variable a] [operator @] [variable b]");
24 MT("matmulWithoutSpace:", "[variable a][operator @][variable b]");
25 MT("matmulSpaceBefore:", "[variable a] [operator @][variable b]");
26
27 MT("fValidStringPrefix", "[string f'this is a {formatted} string']");
28 MT("uValidStringPrefix", "[string u'this is an unicode string']");
29 })();
99 mod(CodeMirror);
1010 })(function(CodeMirror) {
1111 "use strict";
12
13 CodeMirror.registerHelper("wordChars", "r", /[\w.]/);
1214
1315 CodeMirror.defineMode("r", function(config) {
1416 function wordObj(str) {
3333 // Quick and dirty spec file highlighting
3434
3535 CodeMirror.defineMode("rpm-spec", function() {
36 var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
36 var arch = /^(i386|i586|i686|x86_64|ppc64le|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
3737
38 var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|AutoReqProv|Provides|Requires(\(\w+\))?|Obsoletes|Conflicts|Recommends|Source\d*|Patch\d*|ExclusiveArch|NoSource|Supplements):/;
39 var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pre|post|triggerin|triggerun|pretrans|posttrans|verifyscript|check|triggerpostun|triggerprein|trigger)/;
38 var preamble = /^[a-zA-Z0-9()]+:/;
39 var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pretrans|posttrans|pre|post|triggerin|triggerun|verifyscript|check|triggerpostun|triggerprein|trigger)/;
4040 var control_flow_complex = /^%(ifnarch|ifarch|if)/; // rpm control flow macros
4141 var control_flow_simple = /^%(else|endif)/; // rpm control flow macros
4242 var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/; // operators in control flow macros
5454 if (ch == "#") { stream.skipToEnd(); return "comment"; }
5555
5656 if (stream.sol()) {
57 if (stream.match(preamble)) { return "preamble"; }
58 if (stream.match(section)) { return "section"; }
57 if (stream.match(preamble)) { return "header"; }
58 if (stream.match(section)) { return "atom"; }
5959 }
6060
6161 if (stream.match(/^\$\w+/)) { return "def"; } // Variables like '$RPM_BUILD_ROOT'
7272 if (stream.eol()) { state.controlFlow = false; }
7373 }
7474
75 if (stream.match(arch)) { return "number"; }
75 if (stream.match(arch)) {
76 if (stream.eol()) { state.controlFlow = false; }
77 return "number";
78 }
7679
7780 // Macros like '%make_install' or '%attr(0775,root,root)'
7881 if (stream.match(/^%[\w]+/)) {
7982 if (stream.match(/^\(/)) { state.macroParameters = true; }
80 return "macro";
83 return "keyword";
8184 }
8285 if (state.macroParameters) {
8386 if (stream.match(/^\d+/)) { return "number";}
8487 if (stream.match(/^\)/)) {
8588 state.macroParameters = false;
86 return "macro";
89 return "keyword";
8790 }
8891 }
89 if (stream.match(/^%\{\??[\w \-]+\}/)) { return "macro"; } // Macros like '%{defined fedora}'
92
93 // Macros like '%{defined fedora}'
94 if (stream.match(/^%\{\??[\w \-\:\!]+\}/)) {
95 if (stream.eol()) { state.controlFlow = false; }
96 return "def";
97 }
9098
9199 //TODO: Include bash script sub-parser (CodeMirror supports that)
92100 stream.next();
2424 "caller", "lambda", "proc", "public", "protected", "private", "require", "load",
2525 "require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__"
2626 ]);
27 var indentWords = wordObj(["def", "class", "case", "for", "while", "module", "then",
27 var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then",
2828 "catch", "loop", "proc", "begin"]);
2929 var dedentWords = wordObj(["end", "until"]);
3030 var matching = {"[": "]", "{": "}", "(": ")"};
3636 }
3737
3838 function tokenBase(stream, state) {
39 curPunc = null;
4039 if (stream.sol() && stream.match("=begin") && stream.eol()) {
4140 state.tokenize.push(readBlockComment);
4241 return "comment";
231230 },
232231
233232 token: function(stream, state) {
233 curPunc = null;
234234 if (stream.sol()) state.indented = stream.indentation();
235235 var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype;
236236 var thisTok = curPunc;
274274 (state.continuedLine ? config.indentUnit : 0);
275275 },
276276
277 electricChars: "}de", // enD and rescuE
277 electricInput: /^\s*(?:end|rescue|\})$/,
278278 lineComment: "#"
279279 };
280280 });
55
66 <link rel="stylesheet" href="../../lib/codemirror.css">
77 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/mode/simple.js"></script>
89 <script src="rust.js"></script>
910 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
1011 <div id=nav>
3637
3738 fn check_crate(x: int) {
3839 let v = 10;
39 alt foo {
40 1 to 3 {
41 print_foo();
42 if x {
43 blah() + 10;
40 match foo {
41 1 ... 3 {
42 print_foo();
43 if x {
44 blah().to_string();
45 }
4446 }
45 }
46 (x, y) { "bye" }
47 _ { "hi" }
47 (x, y) { "bye" }
48 _ { "hi" }
4849 }
4950 }
5051 </textarea></div>
5152
5253 <script>
5354 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
54 lineNumbers: true
55 lineNumbers: true,
56 lineWrapping: true,
57 indentUnit: 4,
58 mode: "rust"
5559 });
5660 </script>
5761
22
33 (function(mod) {
44 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
5 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
66 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
7 define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
88 else // Plain browser env
99 mod(CodeMirror);
1010 })(function(CodeMirror) {
1111 "use strict";
1212
13 CodeMirror.defineMode("rust", function() {
14 var indentUnit = 4, altIndentUnit = 2;
15 var valKeywords = {
16 "if": "if-style", "while": "if-style", "loop": "else-style", "else": "else-style",
17 "do": "else-style", "ret": "else-style", "fail": "else-style",
18 "break": "atom", "cont": "atom", "const": "let", "resource": "fn",
19 "let": "let", "fn": "fn", "for": "for", "alt": "alt", "iface": "iface",
20 "impl": "impl", "type": "type", "enum": "enum", "mod": "mod",
21 "as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op",
22 "claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style",
23 "export": "else-style", "copy": "op", "log": "op", "log_err": "op",
24 "use": "op", "bind": "op", "self": "atom", "struct": "enum"
25 };
26 var typeKeywords = function() {
27 var keywords = {"fn": "fn", "block": "fn", "obj": "obj"};
28 var atoms = "bool uint int i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 str char".split(" ");
29 for (var i = 0, e = atoms.length; i < e; ++i) keywords[atoms[i]] = "atom";
30 return keywords;
31 }();
32 var operatorChar = /[+\-*&%=<>!?|\.@]/;
13 CodeMirror.defineSimpleMode("rust",{
14 start: [
15 // string and byte string
16 {regex: /b?"/, token: "string", next: "string"},
17 // raw string and raw byte string
18 {regex: /b?r"/, token: "string", next: "string_raw"},
19 {regex: /b?r#+"/, token: "string", next: "string_raw_hash"},
20 // character
21 {regex: /'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/, token: "string-2"},
22 // byte
23 {regex: /b'(?:[^']|\\(?:['\\nrt0]|x[\da-fA-F]{2}))'/, token: "string-2"},
3324
34 // Tokenizer
35
36 // Used as scratch variable to communicate multiple values without
37 // consing up tons of objects.
38 var tcat, content;
39 function r(tc, style) {
40 tcat = tc;
41 return style;
42 }
43
44 function tokenBase(stream, state) {
45 var ch = stream.next();
46 if (ch == '"') {
47 state.tokenize = tokenString;
48 return state.tokenize(stream, state);
49 }
50 if (ch == "'") {
51 tcat = "atom";
52 if (stream.eat("\\")) {
53 if (stream.skipTo("'")) { stream.next(); return "string"; }
54 else { return "error"; }
55 } else {
56 stream.next();
57 return stream.eat("'") ? "string" : "error";
58 }
59 }
60 if (ch == "/") {
61 if (stream.eat("/")) { stream.skipToEnd(); return "comment"; }
62 if (stream.eat("*")) {
63 state.tokenize = tokenComment(1);
64 return state.tokenize(stream, state);
65 }
66 }
67 if (ch == "#") {
68 if (stream.eat("[")) { tcat = "open-attr"; return null; }
69 stream.eatWhile(/\w/);
70 return r("macro", "meta");
71 }
72 if (ch == ":" && stream.match(":<")) {
73 return r("op", null);
74 }
75 if (ch.match(/\d/) || (ch == "." && stream.eat(/\d/))) {
76 var flp = false;
77 if (!stream.match(/^x[\da-f]+/i) && !stream.match(/^b[01]+/)) {
78 stream.eatWhile(/\d/);
79 if (stream.eat(".")) { flp = true; stream.eatWhile(/\d/); }
80 if (stream.match(/^e[+\-]?\d+/i)) { flp = true; }
81 }
82 if (flp) stream.match(/^f(?:32|64)/);
83 else stream.match(/^[ui](?:8|16|32|64)/);
84 return r("atom", "number");
85 }
86 if (ch.match(/[()\[\]{}:;,]/)) return r(ch, null);
87 if (ch == "-" && stream.eat(">")) return r("->", null);
88 if (ch.match(operatorChar)) {
89 stream.eatWhile(operatorChar);
90 return r("op", null);
91 }
92 stream.eatWhile(/\w/);
93 content = stream.current();
94 if (stream.match(/^::\w/)) {
95 stream.backUp(1);
96 return r("prefix", "variable-2");
97 }
98 if (state.keywords.propertyIsEnumerable(content))
99 return r(state.keywords[content], content.match(/true|false/) ? "atom" : "keyword");
100 return r("name", "variable");
101 }
102
103 function tokenString(stream, state) {
104 var ch, escaped = false;
105 while (ch = stream.next()) {
106 if (ch == '"' && !escaped) {
107 state.tokenize = tokenBase;
108 return r("atom", "string");
109 }
110 escaped = !escaped && ch == "\\";
111 }
112 // Hack to not confuse the parser when a string is split in
113 // pieces.
114 return r("op", "string");
115 }
116
117 function tokenComment(depth) {
118 return function(stream, state) {
119 var lastCh = null, ch;
120 while (ch = stream.next()) {
121 if (ch == "/" && lastCh == "*") {
122 if (depth == 1) {
123 state.tokenize = tokenBase;
124 break;
125 } else {
126 state.tokenize = tokenComment(depth - 1);
127 return state.tokenize(stream, state);
128 }
129 }
130 if (ch == "*" && lastCh == "/") {
131 state.tokenize = tokenComment(depth + 1);
132 return state.tokenize(stream, state);
133 }
134 lastCh = ch;
135 }
136 return "comment";
137 };
138 }
139
140 // Parser
141
142 var cx = {state: null, stream: null, marked: null, cc: null};
143 function pass() {
144 for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
145 }
146 function cont() {
147 pass.apply(null, arguments);
148 return true;
149 }
150
151 function pushlex(type, info) {
152 var result = function() {
153 var state = cx.state;
154 state.lexical = {indented: state.indented, column: cx.stream.column(),
155 type: type, prev: state.lexical, info: info};
156 };
157 result.lex = true;
158 return result;
159 }
160 function poplex() {
161 var state = cx.state;
162 if (state.lexical.prev) {
163 if (state.lexical.type == ")")
164 state.indented = state.lexical.indented;
165 state.lexical = state.lexical.prev;
166 }
167 }
168 function typecx() { cx.state.keywords = typeKeywords; }
169 function valcx() { cx.state.keywords = valKeywords; }
170 poplex.lex = typecx.lex = valcx.lex = true;
171
172 function commasep(comb, end) {
173 function more(type) {
174 if (type == ",") return cont(comb, more);
175 if (type == end) return cont();
176 return cont(more);
177 }
178 return function(type) {
179 if (type == end) return cont();
180 return pass(comb, more);
181 };
182 }
183
184 function stat_of(comb, tag) {
185 return cont(pushlex("stat", tag), comb, poplex, block);
186 }
187 function block(type) {
188 if (type == "}") return cont();
189 if (type == "let") return stat_of(letdef1, "let");
190 if (type == "fn") return stat_of(fndef);
191 if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block);
192 if (type == "enum") return stat_of(enumdef);
193 if (type == "mod") return stat_of(mod);
194 if (type == "iface") return stat_of(iface);
195 if (type == "impl") return stat_of(impl);
196 if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex);
197 if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block);
198 return pass(pushlex("stat"), expression, poplex, endstatement, block);
199 }
200 function endstatement(type) {
201 if (type == ";") return cont();
202 return pass();
203 }
204 function expression(type) {
205 if (type == "atom" || type == "name") return cont(maybeop);
206 if (type == "{") return cont(pushlex("}"), exprbrace, poplex);
207 if (type.match(/[\[\(]/)) return matchBrackets(type, expression);
208 if (type.match(/[\]\)\};,]/)) return pass();
209 if (type == "if-style") return cont(expression, expression);
210 if (type == "else-style" || type == "op") return cont(expression);
211 if (type == "for") return cont(pattern, maybetype, inop, expression, expression);
212 if (type == "alt") return cont(expression, altbody);
213 if (type == "fn") return cont(fndef);
214 if (type == "macro") return cont(macro);
215 return cont();
216 }
217 function maybeop(type) {
218 if (content == ".") return cont(maybeprop);
219 if (content == "::<"){return cont(typarams, maybeop);}
220 if (type == "op" || content == ":") return cont(expression);
221 if (type == "(" || type == "[") return matchBrackets(type, expression);
222 return pass();
223 }
224 function maybeprop() {
225 if (content.match(/^\w+$/)) {cx.marked = "variable"; return cont(maybeop);}
226 return pass(expression);
227 }
228 function exprbrace(type) {
229 if (type == "op") {
230 if (content == "|") return cont(blockvars, poplex, pushlex("}", "block"), block);
231 if (content == "||") return cont(poplex, pushlex("}", "block"), block);
232 }
233 if (content == "mutable" || (content.match(/^\w+$/) && cx.stream.peek() == ":"
234 && !cx.stream.match("::", false)))
235 return pass(record_of(expression));
236 return pass(block);
237 }
238 function record_of(comb) {
239 function ro(type) {
240 if (content == "mutable" || content == "with") {cx.marked = "keyword"; return cont(ro);}
241 if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);}
242 if (type == ":") return cont(comb, ro);
243 if (type == "}") return cont();
244 return cont(ro);
245 }
246 return ro;
247 }
248 function blockvars(type) {
249 if (type == "name") {cx.marked = "def"; return cont(blockvars);}
250 if (type == "op" && content == "|") return cont();
251 return cont(blockvars);
252 }
253
254 function letdef1(type) {
255 if (type.match(/[\]\)\};]/)) return cont();
256 if (content == "=") return cont(expression, letdef2);
257 if (type == ",") return cont(letdef1);
258 return pass(pattern, maybetype, letdef1);
259 }
260 function letdef2(type) {
261 if (type.match(/[\]\)\};,]/)) return pass(letdef1);
262 else return pass(expression, letdef2);
263 }
264 function maybetype(type) {
265 if (type == ":") return cont(typecx, rtype, valcx);
266 return pass();
267 }
268 function inop(type) {
269 if (type == "name" && content == "in") {cx.marked = "keyword"; return cont();}
270 return pass();
271 }
272 function fndef(type) {
273 if (content == "@" || content == "~") {cx.marked = "keyword"; return cont(fndef);}
274 if (type == "name") {cx.marked = "def"; return cont(fndef);}
275 if (content == "<") return cont(typarams, fndef);
276 if (type == "{") return pass(expression);
277 if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef);
278 if (type == "->") return cont(typecx, rtype, valcx, fndef);
279 if (type == ";") return cont();
280 return cont(fndef);
281 }
282 function tydef(type) {
283 if (type == "name") {cx.marked = "def"; return cont(tydef);}
284 if (content == "<") return cont(typarams, tydef);
285 if (content == "=") return cont(typecx, rtype, valcx);
286 return cont(tydef);
287 }
288 function enumdef(type) {
289 if (type == "name") {cx.marked = "def"; return cont(enumdef);}
290 if (content == "<") return cont(typarams, enumdef);
291 if (content == "=") return cont(typecx, rtype, valcx, endstatement);
292 if (type == "{") return cont(pushlex("}"), typecx, enumblock, valcx, poplex);
293 return cont(enumdef);
294 }
295 function enumblock(type) {
296 if (type == "}") return cont();
297 if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, enumblock);
298 if (content.match(/^\w+$/)) cx.marked = "def";
299 return cont(enumblock);
300 }
301 function mod(type) {
302 if (type == "name") {cx.marked = "def"; return cont(mod);}
303 if (type == "{") return cont(pushlex("}"), block, poplex);
304 return pass();
305 }
306 function iface(type) {
307 if (type == "name") {cx.marked = "def"; return cont(iface);}
308 if (content == "<") return cont(typarams, iface);
309 if (type == "{") return cont(pushlex("}"), block, poplex);
310 return pass();
311 }
312 function impl(type) {
313 if (content == "<") return cont(typarams, impl);
314 if (content == "of" || content == "for") {cx.marked = "keyword"; return cont(rtype, impl);}
315 if (type == "name") {cx.marked = "def"; return cont(impl);}
316 if (type == "{") return cont(pushlex("}"), block, poplex);
317 return pass();
318 }
319 function typarams() {
320 if (content == ">") return cont();
321 if (content == ",") return cont(typarams);
322 if (content == ":") return cont(rtype, typarams);
323 return pass(rtype, typarams);
324 }
325 function argdef(type) {
326 if (type == "name") {cx.marked = "def"; return cont(argdef);}
327 if (type == ":") return cont(typecx, rtype, valcx);
328 return pass();
329 }
330 function rtype(type) {
331 if (type == "name") {cx.marked = "variable-3"; return cont(rtypemaybeparam); }
332 if (content == "mutable") {cx.marked = "keyword"; return cont(rtype);}
333 if (type == "atom") return cont(rtypemaybeparam);
334 if (type == "op" || type == "obj") return cont(rtype);
335 if (type == "fn") return cont(fntype);
336 if (type == "{") return cont(pushlex("{"), record_of(rtype), poplex);
337 return matchBrackets(type, rtype);
338 }
339 function rtypemaybeparam() {
340 if (content == "<") return cont(typarams);
341 return pass();
342 }
343 function fntype(type) {
344 if (type == "(") return cont(pushlex("("), commasep(rtype, ")"), poplex, fntype);
345 if (type == "->") return cont(rtype);
346 return pass();
347 }
348 function pattern(type) {
349 if (type == "name") {cx.marked = "def"; return cont(patternmaybeop);}
350 if (type == "atom") return cont(patternmaybeop);
351 if (type == "op") return cont(pattern);
352 if (type.match(/[\]\)\};,]/)) return pass();
353 return matchBrackets(type, pattern);
354 }
355 function patternmaybeop(type) {
356 if (type == "op" && content == ".") return cont();
357 if (content == "to") {cx.marked = "keyword"; return cont(pattern);}
358 else return pass();
359 }
360 function altbody(type) {
361 if (type == "{") return cont(pushlex("}", "alt"), altblock1, poplex);
362 return pass();
363 }
364 function altblock1(type) {
365 if (type == "}") return cont();
366 if (type == "|") return cont(altblock1);
367 if (content == "when") {cx.marked = "keyword"; return cont(expression, altblock2);}
368 if (type.match(/[\]\);,]/)) return cont(altblock1);
369 return pass(pattern, altblock2);
370 }
371 function altblock2(type) {
372 if (type == "{") return cont(pushlex("}", "alt"), block, poplex, altblock1);
373 else return pass(altblock1);
374 }
375
376 function macro(type) {
377 if (type.match(/[\[\(\{]/)) return matchBrackets(type, expression);
378 return pass();
379 }
380 function matchBrackets(type, comb) {
381 if (type == "[") return cont(pushlex("]"), commasep(comb, "]"), poplex);
382 if (type == "(") return cont(pushlex(")"), commasep(comb, ")"), poplex);
383 if (type == "{") return cont(pushlex("}"), commasep(comb, "}"), poplex);
384 return cont();
385 }
386
387 function parse(state, stream, style) {
388 var cc = state.cc;
389 // Communicate our context to the combinators.
390 // (Less wasteful than consing up a hundred closures on every call.)
391 cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
392
393 while (true) {
394 var combinator = cc.length ? cc.pop() : block;
395 if (combinator(tcat)) {
396 while(cc.length && cc[cc.length - 1].lex)
397 cc.pop()();
398 return cx.marked || style;
399 }
400 }
401 }
402
403 return {
404 startState: function() {
405 return {
406 tokenize: tokenBase,
407 cc: [],
408 lexical: {indented: -indentUnit, column: 0, type: "top", align: false},
409 keywords: valKeywords,
410 indented: 0
411 };
412 },
413
414 token: function(stream, state) {
415 if (stream.sol()) {
416 if (!state.lexical.hasOwnProperty("align"))
417 state.lexical.align = false;
418 state.indented = stream.indentation();
419 }
420 if (stream.eatSpace()) return null;
421 tcat = content = null;
422 var style = state.tokenize(stream, state);
423 if (style == "comment") return style;
424 if (!state.lexical.hasOwnProperty("align"))
425 state.lexical.align = true;
426 if (tcat == "prefix") return style;
427 if (!content) content = stream.current();
428 return parse(state, stream, style);
429 },
430
431 indent: function(state, textAfter) {
432 if (state.tokenize != tokenBase) return 0;
433 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical,
434 type = lexical.type, closing = firstChar == type;
435 if (type == "stat") return lexical.indented + indentUnit;
436 if (lexical.align) return lexical.column + (closing ? 0 : 1);
437 return lexical.indented + (closing ? 0 : (lexical.info == "alt" ? altIndentUnit : indentUnit));
438 },
439
440 electricChars: "{}",
25 {regex: /(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/,
26 token: "number"},
27 {regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]},
28 {regex: /(?:abstract|alignof|as|box|break|continue|const|crate|do|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"},
29 {regex: /\b(?:Self|isize|usize|char|bool|u8|u16|u32|u64|f16|f32|f64|i8|i16|i32|i64|str|Option)\b/, token: "atom"},
30 {regex: /\b(?:true|false|Some|None|Ok|Err)\b/, token: "builtin"},
31 {regex: /\b(fn)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/,
32 token: ["keyword", null ,"def"]},
33 {regex: /#!?\[.*\]/, token: "meta"},
34 {regex: /\/\/.*/, token: "comment"},
35 {regex: /\/\*/, token: "comment", next: "comment"},
36 {regex: /[-+\/*=<>!]+/, token: "operator"},
37 {regex: /[a-zA-Z_]\w*!/,token: "variable-3"},
38 {regex: /[a-zA-Z_]\w*/, token: "variable"},
39 {regex: /[\{\[\(]/, indent: true},
40 {regex: /[\}\]\)]/, dedent: true}
41 ],
42 string: [
43 {regex: /"/, token: "string", next: "start"},
44 {regex: /(?:[^\\"]|\\(?:.|$))*/, token: "string"}
45 ],
46 string_raw: [
47 {regex: /"/, token: "string", next: "start"},
48 {regex: /[^"]*/, token: "string"}
49 ],
50 string_raw_hash: [
51 {regex: /"#+/, token: "string", next: "start"},
52 {regex: /(?:[^"]|"(?!#))*/, token: "string"}
53 ],
54 comment: [
55 {regex: /.*?\*\//, token: "comment", next: "start"},
56 {regex: /.*/, token: "comment"}
57 ],
58 meta: {
59 dontIndentStates: ["comment"],
60 electricInput: /^\s*\}$/,
44161 blockCommentStart: "/*",
44262 blockCommentEnd: "*/",
44363 lineComment: "//",
44464 fold: "brace"
445 };
65 }
44666 });
44767
68
44869 CodeMirror.defineMIME("text/x-rustsrc", "rust");
449
45070 });
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function() {
4 var mode = CodeMirror.getMode({indentUnit: 4}, "rust");
5 function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));}
6
7 MT('integer_test',
8 '[number 123i32]',
9 '[number 123u32]',
10 '[number 123_u32]',
11 '[number 0xff_u8]',
12 '[number 0o70_i16]',
13 '[number 0b1111_1111_1001_0000_i32]',
14 '[number 0usize]');
15
16 MT('float_test',
17 '[number 123.0f64]',
18 '[number 0.1f64]',
19 '[number 0.1f32]',
20 '[number 12E+99_f64]');
21
22 MT('string-literals-test',
23 '[string "foo"]',
24 '[string r"foo"]',
25 '[string "\\"foo\\""]',
26 '[string r#""foo""#]',
27 '[string "foo #\\"# bar"]',
28
29 '[string b"foo"]',
30 '[string br"foo"]',
31 '[string b"\\"foo\\""]',
32 '[string br#""foo""#]',
33 '[string br##"foo #" bar"##]',
34
35 "[string-2 'h']",
36 "[string-2 b'h']");
37
38 })();
0 <!doctype html>
1
2 <title>CodeMirror: SAS mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../xml/xml.js"></script>
9 <script src="sas.js"></script>
10 <style type="text/css">
11 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
12 .cm-s-default .cm-trailing-space-a:before,
13 .cm-s-default .cm-trailing-space-b:before {position: absolute; content: "\00B7"; color: #777;}
14 .cm-s-default .cm-trailing-space-new-line:before {position: absolute; content: "\21B5"; color: #777;}
15 </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="#">SAS</a>
27 </ul>
28 </div>
29
30 <article>
31 <h2>SAS mode</h2>
32 <form><textarea id="code" name="code">
33 libname foo "/tmp/foobar";
34 %let count=1;
35
36 /* Multi line
37 Comment
38 */
39 data _null_;
40 x=ranuni();
41 * single comment;
42 x2=x**2;
43 sx=sqrt(x);
44 if x=x2 then put "x must be 1";
45 else do;
46 put x=;
47 end;
48 run;
49
50 /* embedded comment
51 * comment;
52 */
53
54 proc glm data=sashelp.class;
55 class sex;
56 model weight = height sex;
57 run;
58
59 proc sql;
60 select count(*)
61 from sashelp.class;
62
63 create table foo as
64 select * from sashelp.class;
65
66 select *
67 from foo;
68 quit;
69 </textarea></form>
70
71 <script>
72 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
73 mode: 'sas',
74 lineNumbers: true
75 });
76 </script>
77
78 <p><strong>MIME types defined:</strong> <code>text/x-sas</code>.</p>
79
80 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3
4 // SAS mode copyright (c) 2016 Jared Dean, SAS Institute
5 // Created by Jared Dean
6
7 // TODO
8 // indent and de-indent
9 // identify macro variables
10
11
12 //Definitions
13 // comment -- text withing * ; or /* */
14 // keyword -- SAS language variable
15 // variable -- macro variables starts with '&' or variable formats
16 // variable-2 -- DATA Step, proc, or macro names
17 // string -- text within ' ' or " "
18 // operator -- numeric operator + / - * ** le eq ge ... and so on
19 // builtin -- proc %macro data run mend
20 // atom
21 // def
22
23 (function(mod) {
24 if (typeof exports == "object" && typeof module == "object") // CommonJS
25 mod(require("../../lib/codemirror"));
26 else if (typeof define == "function" && define.amd) // AMD
27 define(["../../lib/codemirror"], mod);
28 else // Plain browser env
29 mod(CodeMirror);
30 })(function(CodeMirror) {
31 "use strict";
32
33 CodeMirror.defineMode("sas", function () {
34 var words = {};
35 var isDoubleOperatorSym = {
36 eq: 'operator',
37 lt: 'operator',
38 le: 'operator',
39 gt: 'operator',
40 ge: 'operator',
41 "in": 'operator',
42 ne: 'operator',
43 or: 'operator'
44 };
45 var isDoubleOperatorChar = /(<=|>=|!=|<>)/;
46 var isSingleOperatorChar = /[=\(:\),{}.*<>+\-\/^\[\]]/;
47
48 // Takes a string of words separated by spaces and adds them as
49 // keys with the value of the first argument 'style'
50 function define(style, string, context) {
51 if (context) {
52 var split = string.split(' ');
53 for (var i = 0; i < split.length; i++) {
54 words[split[i]] = {style: style, state: context};
55 }
56 }
57 }
58 //datastep
59 define('def', 'stack pgm view source debug nesting nolist', ['inDataStep']);
60 define('def', 'if while until for do do; end end; then else cancel', ['inDataStep']);
61 define('def', 'label format _n_ _error_', ['inDataStep']);
62 define('def', 'ALTER BUFNO BUFSIZE CNTLLEV COMPRESS DLDMGACTION ENCRYPT ENCRYPTKEY EXTENDOBSCOUNTER GENMAX GENNUM INDEX LABEL OBSBUF OUTREP PW PWREQ READ REPEMPTY REPLACE REUSE ROLE SORTEDBY SPILL TOBSNO TYPE WRITE FILECLOSE FIRSTOBS IN OBS POINTOBS WHERE WHEREUP IDXNAME IDXWHERE DROP KEEP RENAME', ['inDataStep']);
63 define('def', 'filevar finfo finv fipname fipnamel fipstate first firstobs floor', ['inDataStep']);
64 define('def', 'varfmt varinfmt varlabel varlen varname varnum varray varrayx vartype verify vformat vformatd vformatdx vformatn vformatnx vformatw vformatwx vformatx vinarray vinarrayx vinformat vinformatd vinformatdx vinformatn vinformatnx vinformatw vinformatwx vinformatx vlabel vlabelx vlength vlengthx vname vnamex vnferr vtype vtypex weekday', ['inDataStep']);
65 define('def', 'zipfips zipname zipnamel zipstate', ['inDataStep']);
66 define('def', 'put putc putn', ['inDataStep']);
67 define('builtin', 'data run', ['inDataStep']);
68
69
70 //proc
71 define('def', 'data', ['inProc']);
72
73 // flow control for macros
74 define('def', '%if %end %end; %else %else; %do %do; %then', ['inMacro']);
75
76 //everywhere
77 define('builtin', 'proc run; quit; libname filename %macro %mend option options', ['ALL']);
78
79 define('def', 'footnote title libname ods', ['ALL']);
80 define('def', '%let %put %global %sysfunc %eval ', ['ALL']);
81 // automatic macro variables http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a003167023.htm
82 define('variable', '&sysbuffr &syscc &syscharwidth &syscmd &sysdate &sysdate9 &sysday &sysdevic &sysdmg &sysdsn &sysencoding &sysenv &syserr &syserrortext &sysfilrc &syshostname &sysindex &sysinfo &sysjobid &syslast &syslckrc &syslibrc &syslogapplname &sysmacroname &sysmenv &sysmsg &sysncpu &sysodspath &sysparm &syspbuff &sysprocessid &sysprocessname &sysprocname &sysrc &sysscp &sysscpl &sysscpl &syssite &sysstartid &sysstartname &systcpiphostname &systime &sysuserid &sysver &sysvlong &sysvlong4 &syswarningtext', ['ALL']);
83
84 //footnote[1-9]? title[1-9]?
85
86 //options statement
87 define('def', 'source2 nosource2 page pageno pagesize', ['ALL']);
88
89 //proc and datastep
90 define('def', '_all_ _character_ _cmd_ _freq_ _i_ _infile_ _last_ _msg_ _null_ _numeric_ _temporary_ _type_ abort abs addr adjrsq airy alpha alter altlog altprint and arcos array arsin as atan attrc attrib attrn authserver autoexec awscontrol awsdef awsmenu awsmenumerge awstitle backward band base betainv between blocksize blshift bnot bor brshift bufno bufsize bxor by byerr byline byte calculated call cards cards4 catcache cbufno cdf ceil center cexist change chisq cinv class cleanup close cnonct cntllev coalesce codegen col collate collin column comamid comaux1 comaux2 comdef compbl compound compress config continue convert cos cosh cpuid create cross crosstab css curobs cv daccdb daccdbsl daccsl daccsyd dacctab dairy datalines datalines4 datejul datepart datetime day dbcslang dbcstype dclose ddm delete delimiter depdb depdbsl depsl depsyd deptab dequote descending descript design= device dflang dhms dif digamma dim dinfo display distinct dkricond dkrocond dlm dnum do dopen doptname doptnum dread drop dropnote dsname dsnferr echo else emaildlg emailid emailpw emailserver emailsys encrypt end endsas engine eof eov erf erfc error errorcheck errors exist exp fappend fclose fcol fdelete feedback fetch fetchobs fexist fget file fileclose fileexist filefmt filename fileref fmterr fmtsearch fnonct fnote font fontalias fopen foptname foptnum force formatted formchar formdelim formdlim forward fpoint fpos fput fread frewind frlen from fsep fuzz fwrite gaminv gamma getoption getvarc getvarn go goto group gwindow hbar hbound helpenv helploc hms honorappearance hosthelp hostprint hour hpct html hvar ibessel ibr id if index indexc indexw initcmd initstmt inner input inputc inputn inr insert int intck intnx into intrr invaliddata irr is jbessel join juldate keep kentb kurtosis label lag last lbound leave left length levels lgamma lib library libref line linesize link list log log10 log2 logpdf logpmf logsdf lostcard lowcase lrecl ls macro macrogen maps mautosource max maxdec maxr mdy mean measures median memtype merge merror min minute missing missover mlogic mod mode model modify month mopen mort mprint mrecall msglevel msymtabmax mvarsize myy n nest netpv new news nmiss no nobatch nobs nocaps nocardimage nocenter nocharcode nocmdmac nocol nocum nodate nodbcs nodetails nodmr nodms nodmsbatch nodup nodupkey noduplicates noechoauto noequals noerrorabend noexitwindows nofullstimer noicon noimplmac noint nolist noloadlist nomiss nomlogic nomprint nomrecall nomsgcase nomstored nomultenvappl nonotes nonumber noobs noovp nopad nopercent noprint noprintinit normal norow norsasuser nosetinit nosplash nosymbolgen note notes notitle notitles notsorted noverbose noxsync noxwait npv null number numkeys nummousekeys nway obs on open order ordinal otherwise out outer outp= output over ovp p(1 5 10 25 50 75 90 95 99) pad pad2 paired parm parmcards path pathdll pathname pdf peek peekc pfkey pmf point poisson poke position printer probbeta probbnml probchi probf probgam probhypr probit probnegb probnorm probsig probt procleave prt ps pw pwreq qtr quote r ranbin rancau ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni read recfm register regr remote remove rename repeat replace resolve retain return reuse reverse rewind right round rsquare rtf rtrace rtraceloc s s2 samploc sasautos sascontrol sasfrscr sasmsg sasmstore sasscript sasuser saving scan sdf second select selection separated seq serror set setcomm setot sign simple sin sinh siteinfo skewness skip sle sls sortedby sortpgm sortseq sortsize soundex spedis splashlocation split spool sqrt start std stderr stdin stfips stimer stname stnamel stop stopover subgroup subpopn substr sum sumwgt symbol symbolgen symget symput sysget sysin sysleave sysmsg sysparm sysprint sysprintfont sysprod sysrc system t table tables tan tanh tapeclose tbufsize terminal test then timepart tinv tnonct to today tol tooldef totper transformout translate trantab tranwrd trigamma trim trimn trunc truncover type unformatted uniform union until upcase update user usericon uss validate value var weight when where while wincharset window work workinit workterm write wsum xsync xwait yearcutoff yes yyq min max', ['inDataStep', 'inProc']);
91 define('operator', 'and not ', ['inDataStep', 'inProc']);
92
93 // Main function
94 function tokenize(stream, state) {
95 // Finally advance the stream
96 var ch = stream.next();
97
98 // BLOCKCOMMENT
99 if (ch === '/' && stream.eat('*')) {
100 state.continueComment = true;
101 return "comment";
102 } else if (state.continueComment === true) { // in comment block
103 //comment ends at the beginning of the line
104 if (ch === '*' && stream.peek() === '/') {
105 stream.next();
106 state.continueComment = false;
107 } else if (stream.skipTo('*')) { //comment is potentially later in line
108 stream.skipTo('*');
109 stream.next();
110 if (stream.eat('/'))
111 state.continueComment = false;
112 } else {
113 stream.skipToEnd();
114 }
115 return "comment";
116 }
117
118 // DoubleOperator match
119 var doubleOperator = ch + stream.peek();
120
121 // Match all line comments.
122 var myString = stream.string;
123 var myRegexp = /(?:^\s*|[;]\s*)(\*.*?);/ig;
124 var match = myRegexp.exec(myString);
125 if (match !== null) {
126 if (match.index === 0 && (stream.column() !== (match.index + match[0].length - 1))) {
127 stream.backUp(stream.column());
128 stream.skipTo(';');
129 stream.next();
130 return 'comment';
131 } else if (match.index + 1 < stream.column() && stream.column() < match.index + match[0].length - 1) {
132 // the ';' triggers the match so move one past it to start
133 // the comment block that is why match.index+1
134 stream.backUp(stream.column() - match.index - 1);
135 stream.skipTo(';');
136 stream.next();
137 return 'comment';
138 }
139 } else if ((ch === '"' || ch === "'") && !state.continueString) {
140 state.continueString = ch
141 return "string"
142 } else if (state.continueString) {
143 if (state.continueString == ch) {
144 state.continueString = null;
145 } else if (stream.skipTo(state.continueString)) {
146 // quote found on this line
147 stream.next();
148 state.continueString = null;
149 } else {
150 stream.skipToEnd();
151 }
152 return "string";
153 } else if (state.continueString !== null && stream.eol()) {
154 stream.skipTo(state.continueString) || stream.skipToEnd();
155 return "string";
156 } else if (/[\d\.]/.test(ch)) { //find numbers
157 if (ch === ".")
158 stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
159 else if (ch === "0")
160 stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
161 else
162 stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
163 return "number";
164 } else if (isDoubleOperatorChar.test(ch + stream.peek())) { // TWO SYMBOL TOKENS
165 stream.next();
166 return "operator";
167 } else if (isDoubleOperatorSym.hasOwnProperty(doubleOperator)) {
168 stream.next();
169 if (stream.peek() === ' ')
170 return isDoubleOperatorSym[doubleOperator.toLowerCase()];
171 } else if (isSingleOperatorChar.test(ch)) { // SINGLE SYMBOL TOKENS
172 return "operator";
173 }
174
175 // Matches one whole word -- even if the word is a character
176 var word;
177 if (stream.match(/[%&;\w]+/, false) != null) {
178 word = ch + stream.match(/[%&;\w]+/, true);
179 if (/&/.test(word)) return 'variable'
180 } else {
181 word = ch;
182 }
183 // the word after DATA PROC or MACRO
184 if (state.nextword) {
185 stream.match(/[\w]+/);
186 // match memname.libname
187 if (stream.peek() === '.') stream.skipTo(' ');
188 state.nextword = false;
189 return 'variable-2';
190 }
191
192 word = word.toLowerCase()
193 // Are we in a DATA Step?
194 if (state.inDataStep) {
195 if (word === 'run;' || stream.match(/run\s;/)) {
196 state.inDataStep = false;
197 return 'builtin';
198 }
199 // variable formats
200 if ((word) && stream.next() === '.') {
201 //either a format or libname.memname
202 if (/\w/.test(stream.peek())) return 'variable-2';
203 else return 'variable';
204 }
205 // do we have a DATA Step keyword
206 if (word && words.hasOwnProperty(word) &&
207 (words[word].state.indexOf("inDataStep") !== -1 ||
208 words[word].state.indexOf("ALL") !== -1)) {
209 //backup to the start of the word
210 if (stream.start < stream.pos)
211 stream.backUp(stream.pos - stream.start);
212 //advance the length of the word and return
213 for (var i = 0; i < word.length; ++i) stream.next();
214 return words[word].style;
215 }
216 }
217 // Are we in an Proc statement?
218 if (state.inProc) {
219 if (word === 'run;' || word === 'quit;') {
220 state.inProc = false;
221 return 'builtin';
222 }
223 // do we have a proc keyword
224 if (word && words.hasOwnProperty(word) &&
225 (words[word].state.indexOf("inProc") !== -1 ||
226 words[word].state.indexOf("ALL") !== -1)) {
227 stream.match(/[\w]+/);
228 return words[word].style;
229 }
230 }
231 // Are we in a Macro statement?
232 if (state.inMacro) {
233 if (word === '%mend') {
234 if (stream.peek() === ';') stream.next();
235 state.inMacro = false;
236 return 'builtin';
237 }
238 if (word && words.hasOwnProperty(word) &&
239 (words[word].state.indexOf("inMacro") !== -1 ||
240 words[word].state.indexOf("ALL") !== -1)) {
241 stream.match(/[\w]+/);
242 return words[word].style;
243 }
244
245 return 'atom';
246 }
247 // Do we have Keywords specific words?
248 if (word && words.hasOwnProperty(word)) {
249 // Negates the initial next()
250 stream.backUp(1);
251 // Actually move the stream
252 stream.match(/[\w]+/);
253 if (word === 'data' && /=/.test(stream.peek()) === false) {
254 state.inDataStep = true;
255 state.nextword = true;
256 return 'builtin';
257 }
258 if (word === 'proc') {
259 state.inProc = true;
260 state.nextword = true;
261 return 'builtin';
262 }
263 if (word === '%macro') {
264 state.inMacro = true;
265 state.nextword = true;
266 return 'builtin';
267 }
268 if (/title[1-9]/.test(word)) return 'def';
269
270 if (word === 'footnote') {
271 stream.eat(/[1-9]/);
272 return 'def';
273 }
274
275 // Returns their value as state in the prior define methods
276 if (state.inDataStep === true && words[word].state.indexOf("inDataStep") !== -1)
277 return words[word].style;
278 if (state.inProc === true && words[word].state.indexOf("inProc") !== -1)
279 return words[word].style;
280 if (state.inMacro === true && words[word].state.indexOf("inMacro") !== -1)
281 return words[word].style;
282 if (words[word].state.indexOf("ALL") !== -1)
283 return words[word].style;
284 return null;
285 }
286 // Unrecognized syntax
287 return null;
288 }
289
290 return {
291 startState: function () {
292 return {
293 inDataStep: false,
294 inProc: false,
295 inMacro: false,
296 nextword: false,
297 continueString: null,
298 continueComment: false
299 };
300 },
301 token: function (stream, state) {
302 // Strip the spaces, but regex will account for them either way
303 if (stream.eatSpace()) return null;
304 // Go through the main process
305 return tokenize(stream, state);
306 },
307
308 blockCommentStart: "/*",
309 blockCommentEnd: "*/"
310 };
311
312 });
313
314 CodeMirror.defineMIME("text/x-sas", "sas");
315 });
164164 };
165165 return function(stream, state) {
166166 rubyState = state.rubyState;
167 state.rubyState = rubyMode.startState();
167 state.rubyState = CodeMirror.startState(rubyMode);
168168 state.tokenize = runSplat;
169169 return ruby(stream, state);
170170 };
316316
317317 function startSubMode(mode, state) {
318318 var subMode = getMode(mode);
319 var subState = subMode.startState && subMode.startState();
319 var subState = CodeMirror.startState(subMode);
320320
321321 state.subMode = subMode;
322322 state.subState = subState;
506506 var mode = {
507507 // default to html mode
508508 startState: function() {
509 var htmlState = htmlMode.startState();
510 var rubyState = rubyMode.startState();
509 var htmlState = CodeMirror.startState(htmlMode);
510 var rubyState = CodeMirror.startState(rubyMode);
511511 return {
512512 htmlState: htmlState,
513513 rubyState: rubyState,
120120 return tokenUntil(stream, state, /\{\/literal}/);
121121
122122 case "string":
123 if (stream.match(/^.*?"/)) {
123 var match = stream.match(/^.*?("|\\[\s\S])/);
124 if (!match) {
125 stream.skipToEnd();
126 } else if (match[1] == "\"") {
124127 state.soyState.pop();
125 } else {
126 stream.skipToEnd();
127128 }
128129 return "string";
129130 }
2424 "strbefore", "strafter", "year", "month", "day", "hours", "minutes", "seconds",
2525 "timezone", "tz", "now", "uuid", "struuid", "md5", "sha1", "sha256", "sha384",
2626 "sha512", "coalesce", "if", "strlang", "strdt", "isnumeric", "regex", "exists",
27 "isblank", "isliteral", "a"]);
27 "isblank", "isliteral", "a", "bind"]);
2828 var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
2929 "ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
3030 "graph", "by", "asc", "desc", "as", "having", "undef", "values", "group",
134134 else if (curPunc == "{") pushContext(state, "}", stream.column());
135135 else if (/[\]\}\)]/.test(curPunc)) {
136136 while (state.context && state.context.type == "pattern") popContext(state);
137 if (state.context && curPunc == state.context.type) popContext(state);
137 if (state.context && curPunc == state.context.type) {
138 popContext(state);
139 if (curPunc == "}" && state.context && state.context.type == "pattern")
140 popContext(state);
141 }
138142 }
139143 else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state);
140144 else if (/atom|string|variable/.test(style) && state.context) {
164168 return context.col + (closing ? 0 : 1);
165169 else
166170 return context.indent + (closing ? 0 : indentUnit);
167 }
171 },
172
173 lineComment: "#"
168174 };
169175 });
170176
6969 return "operator";
7070 case "\\":
7171 if (stream.match(/\\[a-z]+/)) return "string-2";
72 else return null;
72 else {
73 stream.next();
74 return "atom";
75 }
7376 case ".":
7477 case ",":
7578 case ";":
5555 <code><a href="?mime=text/x-cassandra">text/x-cassandra</a></code>,
5656 <code><a href="?mime=text/x-plsql">text/x-plsql</a></code>,
5757 <code><a href="?mime=text/x-mssql">text/x-mssql</a></code>,
58 <code><a href="?mime=text/x-hive">text/x-hive</a></code>.
58 <code><a href="?mime=text/x-hive">text/x-hive</a></code>,
59 <code><a href="?mime=text/x-pgsql">text/x-pgsql</a></code>,
60 <code><a href="?mime=text/x-gql">text/x-gql</a></code>.
5961 </p>
6062 <script>
6163 window.onload = function() {
6464 // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
6565 return "keyword";
6666 } else if (/^[\(\),\;\[\]]/.test(ch)) {
67 // no highlightning
67 // no highlighting
6868 return null;
6969 } else if (support.commentSlashSlash && ch == "/" && stream.eat("/")) {
7070 // 1-line comment
256256 }
257257
258258 // these keywords are used by all SQL dialects (however, a mode can still overwrite it)
259 var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where ";
259 var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where limit ";
260260
261261 // turn a space-separated list into an array
262262 function set(str) {
340340 name: "sql",
341341 client: set("appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define describe echo editfile embedded escape exec execute feedback flagger flush heading headsep instance linesize lno loboffset logsource long longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar release repfooter repheader serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout time timing trimout trimspool ttitle underline verify version wrap"),
342342 keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"),
343 builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bigserial bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least lenght lenghtb ln lower lpad ltrim lub make_ref max min mlslabel mod months_between natural naturaln nchar nclob new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null number numeric nvarchar2 nvl others power rawtohex real reftohex round rowcount rowidtochar rowtype rpad rtrim serial sign signtype sin sinh smallint soundex sqlcode sqlerrm sqrt stddev string substr substrb sum sysdate tan tanh to_char text to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid unlogged upper user userenv varchar varchar2 variance varying vsize xml"),
343 builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bigserial bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least length lengthb ln lower lpad ltrim lub make_ref max min mlslabel mod months_between natural naturaln nchar nclob new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null number numeric nvarchar2 nvl others power rawtohex real reftohex round rowcount rowidtochar rowtype rpad rtrim serial sign signtype sin sinh smallint soundex sqlcode sqlerrm sqrt stddev string substr substrb sum sysdate tan tanh to_char text to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid unlogged upper user userenv varchar varchar2 variance varying vsize xml"),
344344 operatorChars: /^[*+\-%<>!=~]/,
345345 dateSQL: set("date time timestamp"),
346346 support: set("doubleQuote nCharCast zerolessFloat binaryNumber hexNumber")
355355 operatorChars: /^[*+\-%<>!=]/,
356356 dateSQL: set("date timestamp"),
357357 support: set("ODBCdotTable doubleQuote binaryNumber hexNumber")
358 });
359
360 CodeMirror.defineMIME("text/x-pgsql", {
361 name: "sql",
362 client: set("source"),
363 // http://www.postgresql.org/docs/9.5/static/sql-keywords-appendix.html
364 keywords: set(sqlKeywords + "a abort abs absent absolute access according action ada add admin after aggregate all allocate also always analyse analyze any are array array_agg array_max_cardinality asensitive assertion assignment asymmetric at atomic attribute attributes authorization avg backward base64 before begin begin_frame begin_partition bernoulli binary bit_length blob blocked bom both breadth c cache call called cardinality cascade cascaded case cast catalog catalog_name ceil ceiling chain characteristics characters character_length character_set_catalog character_set_name character_set_schema char_length check checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema collect column columns column_name command_function command_function_code comment comments commit committed concurrently condition condition_number configuration conflict connect connection connection_name constraint constraints constraint_catalog constraint_name constraint_schema constructor contains content continue control conversion convert copy corr corresponding cost covar_pop covar_samp cross csv cube cume_dist current current_catalog current_date current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cursor_name cycle data database datalink datetime_interval_code datetime_interval_precision day db deallocate dec declare default defaults deferrable deferred defined definer degree delimiter delimiters dense_rank depth deref derived describe descriptor deterministic diagnostics dictionary disable discard disconnect dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue do document domain dynamic dynamic_function dynamic_function_code each element else empty enable encoding encrypted end end-exec end_frame end_partition enforced enum equals escape event every except exception exclude excluding exclusive exec execute exists exp explain expression extension external extract false family fetch file filter final first first_value flag float floor following for force foreign fortran forward found frame_row free freeze fs full function functions fusion g general generated get global go goto grant granted greatest grouping groups handler header hex hierarchy hold hour id identity if ignore ilike immediate immediately immutable implementation implicit import including increment indent index indexes indicator inherit inherits initially inline inner inout input insensitive instance instantiable instead integrity intersect intersection invoker isnull isolation k key key_member key_type label lag language large last last_value lateral lead leading leakproof least left length level library like_regex link listen ln load local localtime localtimestamp location locator lock locked logged lower m map mapping match matched materialized max maxvalue max_cardinality member merge message_length message_octet_length message_text method min minute minvalue mod mode modifies module month more move multiset mumps name names namespace national natural nchar nclob nesting new next nfc nfd nfkc nfkd nil no none normalize normalized nothing notify notnull nowait nth_value ntile null nullable nullif nulls number object occurrences_regex octets octet_length of off offset oids old only open operator option options ordering ordinality others out outer output over overlaps overlay overriding owned owner p pad parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partial partition pascal passing passthrough password percent percentile_cont percentile_disc percent_rank period permission placing plans pli policy portion position position_regex power precedes preceding prepare prepared preserve primary prior privileges procedural procedure program public quote range rank read reads reassign recheck recovery recursive ref references referencing refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release rename repeatable replace replica requiring reset respect restart restore restrict result return returned_cardinality returned_length returned_octet_length returned_sqlstate returning returns revoke right role rollback rollup routine routine_catalog routine_name routine_schema row rows row_count row_number rule savepoint scale schema schema_name scope scope_catalog scope_name scope_schema scroll search second section security selective self sensitive sequence sequences serializable server server_name session session_user setof sets share show similar simple size skip snapshot some source space specific specifictype specific_name sql sqlcode sqlerror sqlexception sqlstate sqlwarning sqrt stable standalone start state statement static statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset substring substring_regex succeeds sum symmetric sysid system system_time system_user t tables tablesample tablespace table_name temp template temporary then ties timezone_hour timezone_minute to token top_level_count trailing transaction transactions_committed transactions_rolled_back transaction_active transform transforms translate translate_regex translation treat trigger trigger_catalog trigger_name trigger_schema trim trim_array true truncate trusted type types uescape unbounded uncommitted under unencrypted unique unknown unlink unlisten unlogged unnamed unnest until untyped upper uri usage user user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema using vacuum valid validate validator value value_of varbinary variadic var_pop var_samp verbose version versioning view views volatile when whenever whitespace width_bucket window within work wrapper write xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate year yes loop repeat"),
365 // http://www.postgresql.org/docs/9.5/static/datatype.html
366 builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"),
367 atoms: set("false true null unknown"),
368 operatorChars: /^[*+\-%<>!=&|^\/#@?~]/,
369 dateSQL: set("date time timestamp"),
370 support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast")
371 });
372
373 // Google's SQL-like query language, GQL
374 CodeMirror.defineMIME("text/x-gql", {
375 name: "sql",
376 keywords: set("ancestor and asc by contains desc descendant distinct from group has in is limit offset on order select superset where"),
377 atoms: set("false true"),
378 builtin: set("blob datetime first key __key__ string integer double boolean null"),
379 operatorChars: /^[*+\-%<>!=]/
358380 });
359381 }());
360382
125125 if (stream.match(/^&{1}\s*$/)) {
126126 return ["variable-3", "reference"];
127127 }
128 // Variable
129 if (ch == "$" && stream.match(/^\$[\w-]+/i)) {
130 return ["variable-2", "variable-name"];
131 }
132128 // Word operator
133129 if (stream.match(wordOperatorKeywordsRegexp)) {
134130 return ["operator", "operator"];
135131 }
136132 // Word
137 if (stream.match(/^[-_]*[a-z0-9]+[\w-]*/i)) {
133 if (stream.match(/^\$?[-_]*[a-z0-9]+[\w-]*/i)) {
134 // Variable
138135 if (stream.match(/^(\.|\[)[\w-\'\"\]]+/i, false)) {
139136 if (!wordIsTag(stream.current())) {
140 stream.match(/[\w-]+/);
137 stream.match(/\./);
141138 return ["variable-2", "variable-name"];
142139 }
143140 }
322319 return pushContext(state, stream, "block", 0);
323320 }
324321 if (type == "variable-name") {
325 if ((stream.indentation() == 0 && startOfLine(stream)) || wordIsBlock(firstWordOfLine(stream))) {
322 if (stream.string.match(/^\s?\$[\w-\.\[\]\'\"]+$/) || wordIsBlock(firstWordOfLine(stream))) {
326323 return pushContext(state, stream, "variableName");
327324 }
328325 else {
428425 return pushContext(state, stream, "block");
429426 }
430427 if (word == "return") return pushContext(state, stream, "block", 0);
428
429 // Placeholder selector
430 if (override == "variable-2" && stream.string.match(/^\s?\$[\w-\.\[\]\'\"]+$/)) {
431 return pushContext(state, stream, "block");
432 }
431433 }
432434 return state.context.type;
433435 };
638640 states.variableName = function(type, stream, state) {
639641 if (type == "string" || type == "[" || type == "]" || stream.current().match(/^(\.|\$)/)) {
640642 if (stream.current().match(/^\.[\w-]+/i)) override = "variable-2";
641 if (endOfLine(stream)) return popContext(state);
642643 return "variableName";
643644 }
644645 return popAndPass(type, stream, state);
734735 var nonStandardPropertyKeywords_ = ["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"];
735736 var fontProperties_ = ["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"];
736737 var colorKeywords_ = ["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"];
737 var valueKeywords_ = ["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","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","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-resize","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","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","x-large","x-small","xor","xx-large","xx-small","bicubic","optimizespeed","grayscale"];
738 var valueKeywords_ = ["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","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","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-resize","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","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","x-large","x-small","xor","xx-large","xx-small","bicubic","optimizespeed","grayscale","row","row-reverse","wrap","wrap-reverse","column-reverse","flex-start","flex-end","space-between","space-around"];
738739
739740 var wordOperatorKeywords_ = ["in","and","or","not","is not","is a","is","isnt","defined","if unless"],
740741 blockKeywords_ = ["for","if","else","unless", "from", "to"],
3434 // Created by Main Account on 12/18/14.
3535 // Copyright (c) 2014 Razeware LLC. All rights reserved.
3636 //
37
37
3838 import Foundation
39
39
4040 class TipCalculatorModel {
41
41
4242 var total: Double
4343 var taxPct: Double
4444 var subtotal: Double {
4646 return total / (taxPct + 1)
4747 }
4848 }
49
49
5050 init(total: Double, taxPct: Double) {
5151 self.total = total
5252 self.taxPct = taxPct
5353 }
54
54
5555 func calcTipWithTipPct(tipPct: Double) -> Double {
5656 return subtotal * tipPct
5757 }
58
58
5959 func returnPossibleTips() -> [Int: Double] {
60
60
6161 let possibleTipsInferred = [0.15, 0.18, 0.20]
6262 let possibleTipsExplicit:[Double] = [0.15, 0.18, 0.20]
63
63
6464 var retval = [Int: Double]()
6565 for possibleTip in possibleTipsInferred {
6666 let intPct = Int(possibleTip*100)
6767 retval[intPct] = calcTipWithTipPct(possibleTip)
6868 }
6969 return retval
70
70
7171 }
72
72
7373 }
7474 </textarea></form>
7575
1212 })(function(CodeMirror) {
1313 "use strict"
1414
15 function trim(str) { return /^\s*(.*?)\s*$/.exec(str)[1] }
16
17 var separators = [" ","\\\+","\\\-","\\\(","\\\)","\\\*","/",":","\\\?","\\\<","\\\>"," ","\\\."]
18 var tokens = new RegExp(separators.join("|"),"g")
19
20 function getWord(string, pos) {
21 var index = -1, count = 1
22 var words = string.split(tokens)
23 for (var i = 0; i < words.length; i++) {
24 for(var j = 1; j <= words[i].length; j++) {
25 if (count==pos) index = i
26 count++
27 }
28 count++
29 }
30 var ret = ["", ""]
31 if (pos == 0) {
32 ret[1] = words[0]
33 ret[0] = null
34 } else {
35 ret[1] = words[index]
36 ret[0] = words[index-1]
37 }
38 return ret
39 }
40
41 CodeMirror.defineMode("swift", function() {
42 var keywords=["var","let","class","deinit","enum","extension","func","import","init","let","protocol","static","struct","subscript","typealias","var","as","dynamicType","is","new","super","self","Self","Type","__COLUMN__","__FILE__","__FUNCTION__","__LINE__","break","case","continue","default","do","else","fallthrough","if","in","for","return","switch","where","while","associativity","didSet","get","infix","inout","left","mutating","none","nonmutating","operator","override","postfix","precedence","prefix","right","set","unowned","unowned(safe)","unowned(unsafe)","weak","willSet"]
43 var commonConstants=["Infinity","NaN","undefined","null","true","false","on","off","yes","no","nil","null","this","super"]
44 var types=["String","bool","int","string","double","Double","Int","Float","float","public","private","extension"]
45 var numbers=["0","1","2","3","4","5","6","7","8","9"]
46 var operators=["+","-","/","*","%","=","|","&","<",">"]
47 var punc=[";",",",".","(",")","{","}","[","]"]
48 var delimiters=/^(?:[()\[\]{},:`=;]|\.\.?\.?)/
49 var identifiers=/^[_A-Za-z$][_A-Za-z$0-9]*/
50 var properties=/^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/
51 var regexPrefixes=/^(\/{3}|\/)/
52
15 function wordSet(words) {
16 var set = {}
17 for (var i = 0; i < words.length; i++) set[words[i]] = true
18 return set
19 }
20
21 var keywords = wordSet(["var","let","class","deinit","enum","extension","func","import","init","protocol",
22 "static","struct","subscript","typealias","as","dynamicType","is","new","super",
23 "self","Self","Type","__COLUMN__","__FILE__","__FUNCTION__","__LINE__","break","case",
24 "continue","default","do","else","fallthrough","if","in","for","return","switch",
25 "where","while","associativity","didSet","get","infix","inout","left","mutating",
26 "none","nonmutating","operator","override","postfix","precedence","prefix","right",
27 "set","unowned","weak","willSet"])
28 var definingKeywords = wordSet(["var","let","class","enum","extension","func","import","protocol","struct",
29 "typealias","dynamicType","for"])
30 var atoms = wordSet(["Infinity","NaN","undefined","null","true","false","on","off","yes","no","nil","null",
31 "this","super"])
32 var types = wordSet(["String","bool","int","string","double","Double","Int","Float","float","public",
33 "private","extension"])
34 var operators = "+-/*%=|&<>#"
35 var punc = ";,.(){}[]"
36 var number = /^-?(?:(?:[\d_]+\.[_\d]*|\.[_\d]+|0o[0-7_\.]+|0b[01_\.]+)(?:e-?[\d_]+)?|0x[\d_a-f\.]+(?:p-?[\d_]+)?)/i
37 var identifier = /^[_A-Za-z$][_A-Za-z$0-9]*/
38 var property = /^[@\.][_A-Za-z$][_A-Za-z$0-9]*/
39 var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\//
40
41 function tokenBase(stream, state, prev) {
42 if (stream.sol()) state.indented = stream.indentation()
43 if (stream.eatSpace()) return null
44
45 var ch = stream.peek()
46 if (ch == "/") {
47 if (stream.match("//")) {
48 stream.skipToEnd()
49 return "comment"
50 }
51 if (stream.match("/*")) {
52 state.tokenize.push(tokenComment)
53 return tokenComment(stream, state)
54 }
55 if (stream.match(regexp)) return "string-2"
56 }
57 if (operators.indexOf(ch) > -1) {
58 stream.next()
59 return "operator"
60 }
61 if (punc.indexOf(ch) > -1) {
62 stream.next()
63 stream.match("..")
64 return "punctuation"
65 }
66 if (ch == '"' || ch == "'") {
67 stream.next()
68 var tokenize = tokenString(ch)
69 state.tokenize.push(tokenize)
70 return tokenize(stream, state)
71 }
72
73 if (stream.match(number)) return "number"
74 if (stream.match(property)) return "property"
75
76 if (stream.match(identifier)) {
77 var ident = stream.current()
78 if (keywords.hasOwnProperty(ident)) {
79 if (definingKeywords.hasOwnProperty(ident))
80 state.prev = "define"
81 return "keyword"
82 }
83 if (types.hasOwnProperty(ident)) return "variable-2"
84 if (atoms.hasOwnProperty(ident)) return "atom"
85 if (prev == "define") return "def"
86 return "variable"
87 }
88
89 stream.next()
90 return null
91 }
92
93 function tokenUntilClosingParen() {
94 var depth = 0
95 return function(stream, state, prev) {
96 var inner = tokenBase(stream, state, prev)
97 if (inner == "punctuation") {
98 if (stream.current() == "(") ++depth
99 else if (stream.current() == ")") {
100 if (depth == 0) {
101 stream.backUp(1)
102 state.tokenize.pop()
103 return state.tokenize[state.tokenize.length - 1](stream, state)
104 }
105 else --depth
106 }
107 }
108 return inner
109 }
110 }
111
112 function tokenString(quote) {
113 return function(stream, state) {
114 var ch, escaped = false
115 while (ch = stream.next()) {
116 if (escaped) {
117 if (ch == "(") {
118 state.tokenize.push(tokenUntilClosingParen())
119 return "string"
120 }
121 escaped = false
122 } else if (ch == quote) {
123 break
124 } else {
125 escaped = ch == "\\"
126 }
127 }
128 state.tokenize.pop()
129 return "string"
130 }
131 }
132
133 function tokenComment(stream, state) {
134 stream.match(/^(?:[^*]|\*(?!\/))*/)
135 if (stream.match("*/")) state.tokenize.pop()
136 return "comment"
137 }
138
139 function Context(prev, align, indented) {
140 this.prev = prev
141 this.align = align
142 this.indented = indented
143 }
144
145 function pushContext(state, stream) {
146 var align = stream.match(/^\s*($|\/[\/\*])/, false) ? null : stream.column() + 1
147 state.context = new Context(state.context, align, state.indented)
148 }
149
150 function popContext(state) {
151 if (state.context) {
152 state.indented = state.context.indented
153 state.context = state.context.prev
154 }
155 }
156
157 CodeMirror.defineMode("swift", function(config) {
53158 return {
54159 startState: function() {
55160 return {
56 prev: false,
57 string: false,
58 escape: false,
59 inner: false,
60 comment: false,
61 num_left: 0,
62 num_right: 0,
63 doubleString: false,
64 singleString: false
161 prev: null,
162 context: null,
163 indented: 0,
164 tokenize: []
65165 }
66166 },
167
67168 token: function(stream, state) {
68 if (stream.eatSpace()) return null
69
70 var ch = stream.next()
71 if (state.string) {
72 if (state.escape) {
73 state.escape = false
74 return "string"
75 } else {
76 if ((ch == "\"" && (state.doubleString && !state.singleString) ||
77 (ch == "'" && (!state.doubleString && state.singleString))) &&
78 !state.escape) {
79 state.string = false
80 state.doubleString = false
81 state.singleString = false
82 return "string"
83 } else if (ch == "\\" && stream.peek() == "(") {
84 state.inner = true
85 state.string = false
86 return "keyword"
87 } else if (ch == "\\" && stream.peek() != "(") {
88 state.escape = true
89 state.string = true
90 return "string"
91 } else {
92 return "string"
93 }
94 }
95 } else if (state.comment) {
96 if (ch == "*" && stream.peek() == "/") {
97 state.prev = "*"
98 return "comment"
99 } else if (ch == "/" && state.prev == "*") {
100 state.prev = false
101 state.comment = false
102 return "comment"
103 }
104 return "comment"
105 } else {
106 if (ch == "/") {
107 if (stream.peek() == "/") {
108 stream.skipToEnd()
109 return "comment"
110 }
111 if (stream.peek() == "*") {
112 state.comment = true
113 return "comment"
114 }
115 }
116 if (ch == "(" && state.inner) {
117 state.num_left++
118 return null
119 }
120 if (ch == ")" && state.inner) {
121 state.num_right++
122 if (state.num_left == state.num_right) {
123 state.inner=false
124 state.string=true
125 }
126 return null
127 }
128
129 var ret = getWord(stream.string, stream.pos)
130 var the_word = ret[1]
131 var prev_word = ret[0]
132
133 if (operators.indexOf(ch + "") > -1) return "operator"
134 if (punc.indexOf(ch) > -1) return "punctuation"
135
136 if (typeof the_word != "undefined") {
137 the_word = trim(the_word)
138 if (typeof prev_word != "undefined") prev_word = trim(prev_word)
139 if (the_word.charAt(0) == "#") return null
140
141 if (types.indexOf(the_word) > -1) return "def"
142 if (commonConstants.indexOf(the_word) > -1) return "atom"
143 if (numbers.indexOf(the_word) > -1) return "number"
144
145 if ((numbers.indexOf(the_word.charAt(0) + "") > -1 ||
146 operators.indexOf(the_word.charAt(0) + "") > -1) &&
147 numbers.indexOf(ch) > -1) {
148 return "number"
149 }
150
151 if (keywords.indexOf(the_word) > -1 ||
152 keywords.indexOf(the_word.split(tokens)[0]) > -1)
153 return "keyword"
154 if (keywords.indexOf(prev_word) > -1) return "def"
155 }
156 if (ch == '"' && !state.doubleString) {
157 state.string = true
158 state.doubleString = true
159 return "string"
160 }
161 if (ch == "'" && !state.singleString) {
162 state.string = true
163 state.singleString = true
164 return "string"
165 }
166 if (ch == "(" && state.inner)
167 state.num_left++
168 if (ch == ")" && state.inner) {
169 state.num_right++
170 if (state.num_left == state.num_right) {
171 state.inner = false
172 state.string = true
173 }
174 return null
175 }
176 if (stream.match(/^-?[0-9\.]/, false)) {
177 if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i) ||
178 stream.match(/^-?\d+\.\d*/) ||
179 stream.match(/^-?\.\d+/)) {
180 if (stream.peek() == ".") stream.backUp(1)
181 return "number"
182 }
183 if (stream.match(/^-?0x[0-9a-f]+/i) ||
184 stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/) ||
185 stream.match(/^-?0(?![\dx])/i))
186 return "number"
187 }
188 if (stream.match(regexPrefixes)) {
189 if (stream.current()!="/" || stream.match(/^.*\//,false)) return "string"
190 else stream.backUp(1)
191 }
192 if (stream.match(delimiters)) return "punctuation"
193 if (stream.match(identifiers)) return "variable"
194 if (stream.match(properties)) return "property"
195 return "variable"
196 }
197 }
169 var prev = state.prev
170 state.prev = null
171 var tokenize = state.tokenize[state.tokenize.length - 1] || tokenBase
172 var style = tokenize(stream, state, prev)
173 if (!style || style == "comment") state.prev = prev
174 else if (!state.prev) state.prev = style
175
176 if (style == "punctuation") {
177 var bracket = /[\(\[\{]|([\]\)\}])/.exec(stream.current())
178 if (bracket) (bracket[1] ? popContext : pushContext)(state, stream)
179 }
180
181 return style
182 },
183
184 indent: function(state, textAfter) {
185 var cx = state.context
186 if (!cx) return 0
187 var closing = /^[\]\}\)]/.test(textAfter)
188 if (cx.align != null) return cx.align - (closing ? 1 : 0)
189 return cx.indented + (closing ? 0 : config.indentUnit)
190 },
191
192 electricInput: /^\s*[\)\}\]]$/,
193
194 lineComment: "//",
195 blockCommentStart: "/*",
196 blockCommentEnd: "*/"
198197 }
199198 })
200199
201200 CodeMirror.defineMIME("text/x-swift","swift")
202 })
201 });
4141 var beforeParams = state.beforeParams;
4242 state.beforeParams = false;
4343 var ch = stream.next();
44 if ((ch == '"' || ch == "'") && state.inParams)
44 if ((ch == '"' || ch == "'") && state.inParams) {
4545 return chain(stream, state, tokenString(ch));
46 else if (/[\[\]{}\(\),;\.]/.test(ch)) {
46 } else if (/[\[\]{}\(\),;\.]/.test(ch)) {
4747 if (ch == "(" && beforeParams) state.inParams = true;
4848 else if (ch == ")") state.inParams = false;
4949 return null;
50 }
51 else if (/\d/.test(ch)) {
50 } else if (/\d/.test(ch)) {
5251 stream.eatWhile(/[\w\.]/);
5352 return "number";
54 }
55 else if (ch == "#" && stream.eat("*")) {
56 return chain(stream, state, tokenComment);
57 }
58 else if (ch == "#" && stream.match(/ *\[ *\[/)) {
59 return chain(stream, state, tokenUnparsed);
60 }
61 else if (ch == "#" && stream.eat("#")) {
53 } else if (ch == "#") {
54 if (stream.eat("*"))
55 return chain(stream, state, tokenComment);
56 if (ch == "#" && stream.match(/ *\[ *\[/))
57 return chain(stream, state, tokenUnparsed);
6258 stream.skipToEnd();
6359 return "comment";
64 }
65 else if (ch == '"') {
60 } else if (ch == '"') {
6661 stream.skipTo(/"/);
6762 return "comment";
68 }
69 else if (ch == "$") {
63 } else if (ch == "$") {
7064 stream.eatWhile(/[$_a-z0-9A-Z\.{:]/);
7165 stream.eatWhile(/}/);
7266 state.beforeParams = true;
7367 return "builtin";
74 }
75 else if (isOperatorChar.test(ch)) {
68 } else if (isOperatorChar.test(ch)) {
7669 stream.eatWhile(isOperatorChar);
7770 return "comment";
78 }
79 else {
71 } else {
8072 stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);
8173 var word = stream.current().toLowerCase();
8274 if (keywords && keywords.propertyIsEnumerable(word))
1515 ! Info
1616 CoreVersion parameter is needed for TiddlyWiki only!
1717 ***/
18 //{{{
1918
2019 (function(mod) {
2120 if (typeof exports == "object" && typeof module == "object") // CommonJS
3130 // Tokenizer
3231 var textwords = {};
3332
34 var keywords = function () {
35 function kw(type) {
36 return { type: type, style: "macro"};
37 }
38 return {
39 "allTags": kw('allTags'), "closeAll": kw('closeAll'), "list": kw('list'),
40 "newJournal": kw('newJournal'), "newTiddler": kw('newTiddler'),
41 "permaview": kw('permaview'), "saveChanges": kw('saveChanges'),
42 "search": kw('search'), "slider": kw('slider'), "tabs": kw('tabs'),
43 "tag": kw('tag'), "tagging": kw('tagging'), "tags": kw('tags'),
44 "tiddler": kw('tiddler'), "timeline": kw('timeline'),
45 "today": kw('today'), "version": kw('version'), "option": kw('option'),
46
47 "with": kw('with'),
48 "filter": kw('filter')
49 };
50 }();
33 var keywords = {
34 "allTags": true, "closeAll": true, "list": true,
35 "newJournal": true, "newTiddler": true,
36 "permaview": true, "saveChanges": true,
37 "search": true, "slider": true, "tabs": true,
38 "tag": true, "tagging": true, "tags": true,
39 "tiddler": true, "timeline": true,
40 "today": true, "version": true, "option": true,
41 "with": true, "filter": true
42 };
5143
5244 var isSpaceName = /[\w_\-]/i,
53 reHR = /^\-\-\-\-+$/, // <hr>
54 reWikiCommentStart = /^\/\*\*\*$/, // /***
55 reWikiCommentStop = /^\*\*\*\/$/, // ***/
56 reBlockQuote = /^<<<$/,
57
58 reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ js block start
59 reJsCodeStop = /^\/\/\}\}\}$/, // //}}} js stop
60 reXmlCodeStart = /^<!--\{\{\{-->$/, // xml block start
61 reXmlCodeStop = /^<!--\}\}\}-->$/, // xml stop
62
63 reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start
64 reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop
65
66 reUntilCodeStop = /.*?\}\}\}/;
45 reHR = /^\-\-\-\-+$/, // <hr>
46 reWikiCommentStart = /^\/\*\*\*$/, // /***
47 reWikiCommentStop = /^\*\*\*\/$/, // ***/
48 reBlockQuote = /^<<<$/,
49
50 reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ js block start
51 reJsCodeStop = /^\/\/\}\}\}$/, // //}}} js stop
52 reXmlCodeStart = /^<!--\{\{\{-->$/, // xml block start
53 reXmlCodeStop = /^<!--\}\}\}-->$/, // xml stop
54
55 reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start
56 reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop
57
58 reUntilCodeStop = /.*?\}\}\}/;
6759
6860 function chain(stream, state, f) {
6961 state.tokenize = f;
7062 return f(stream, state);
7163 }
7264
73 function jsTokenBase(stream, state) {
74 var sol = stream.sol(), ch;
65 function tokenBase(stream, state) {
66 var sol = stream.sol(), ch = stream.peek();
7567
7668 state.block = false; // indicates the start of a code block.
77
78 ch = stream.peek(); // don't eat, to make matching simpler
7969
8070 // check start of blocks
8171 if (sol && /[<\/\*{}\-]/.test(ch)) {
8373 state.block = true;
8474 return chain(stream, state, twTokenCode);
8575 }
86 if (stream.match(reBlockQuote)) {
76 if (stream.match(reBlockQuote))
8777 return 'quote';
88 }
89 if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop)) {
78 if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop))
9079 return 'comment';
91 }
92 if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop)) {
80 if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop))
9381 return 'comment';
94 }
95 if (stream.match(reHR)) {
82 if (stream.match(reHR))
9683 return 'hr';
97 }
98 } // sol
99 ch = stream.next();
100
84 }
85
86 stream.next();
10187 if (sol && /[\/\*!#;:>|]/.test(ch)) {
10288 if (ch == "!") { // tw header
10389 stream.skipToEnd();
123109 stream.eatWhile(">");
124110 return "quote";
125111 }
126 if (ch == '|') {
112 if (ch == '|')
127113 return 'header';
128 }
129 }
130
131 if (ch == '{' && stream.match(/\{\{/)) {
114 }
115
116 if (ch == '{' && stream.match(/\{\{/))
132117 return chain(stream, state, twTokenCode);
133 }
134118
135119 // rudimentary html:// file:// link matching. TW knows much more ...
136 if (/[hf]/i.test(ch)) {
137 if (/[ti]/i.test(stream.peek()) && stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i)) {
138 return "link";
139 }
140 }
120 if (/[hf]/i.test(ch) &&
121 /[ti]/i.test(stream.peek()) &&
122 stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i))
123 return "link";
124
141125 // just a little string indicator, don't want to have the whole string covered
142 if (ch == '"') {
126 if (ch == '"')
143127 return 'string';
144 }
145 if (ch == '~') { // _no_ CamelCase indicator should be bold
128
129 if (ch == '~') // _no_ CamelCase indicator should be bold
146130 return 'brace';
147 }
148 if (/[\[\]]/.test(ch)) { // check for [[..]]
149 if (stream.peek() == ch) {
150 stream.next();
151 return 'brace';
152 }
153 }
131
132 if (/[\[\]]/.test(ch) && stream.match(ch)) // check for [[..]]
133 return 'brace';
134
154135 if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
155136 stream.eatWhile(isSpaceName);
156137 return "link";
157138 }
139
158140 if (/\d/.test(ch)) { // numbers
159141 stream.eatWhile(/\d/);
160142 return "number";
161143 }
144
162145 if (ch == "/") { // tw invisible comment
163146 if (stream.eat("%")) {
164147 return chain(stream, state, twTokenComment);
165 }
166 else if (stream.eat("/")) { //
148 } else if (stream.eat("/")) { //
167149 return chain(stream, state, twTokenEm);
168150 }
169151 }
170 if (ch == "_") { // tw underline
171 if (stream.eat("_")) {
152
153 if (ch == "_" && stream.eat("_")) // tw underline
172154 return chain(stream, state, twTokenUnderline);
173 }
174 }
155
175156 // strikethrough and mdash handling
176 if (ch == "-") {
177 if (stream.eat("-")) {
178 // if strikethrough looks ugly, change CSS.
179 if (stream.peek() != ' ')
180 return chain(stream, state, twTokenStrike);
181 // mdash
182 if (stream.peek() == ' ')
183 return 'brace';
184 }
185 }
186 if (ch == "'") { // tw bold
187 if (stream.eat("'")) {
188 return chain(stream, state, twTokenStrong);
189 }
190 }
191 if (ch == "<") { // tw macro
192 if (stream.eat("<")) {
193 return chain(stream, state, twTokenMacro);
194 }
195 }
196 else {
197 return null;
198 }
157 if (ch == "-" && stream.eat("-")) {
158 // if strikethrough looks ugly, change CSS.
159 if (stream.peek() != ' ')
160 return chain(stream, state, twTokenStrike);
161 // mdash
162 if (stream.peek() == ' ')
163 return 'brace';
164 }
165
166 if (ch == "'" && stream.eat("'")) // tw bold
167 return chain(stream, state, twTokenStrong);
168
169 if (ch == "<" && stream.eat("<")) // tw macro
170 return chain(stream, state, twTokenMacro);
199171
200172 // core macro handling
201173 stream.eatWhile(/[\w\$_]/);
202 var word = stream.current(),
203 known = textwords.propertyIsEnumerable(word) && textwords[word];
204
205 return known ? known.style : null;
206 } // jsTokenBase()
174 return textwords.propertyIsEnumerable(stream.current()) ? "keyword" : null
175 }
207176
208177 // tw invisible comment
209178 function twTokenComment(stream, state) {
210 var maybeEnd = false,
211 ch;
179 var maybeEnd = false, ch;
212180 while (ch = stream.next()) {
213181 if (ch == "/" && maybeEnd) {
214 state.tokenize = jsTokenBase;
182 state.tokenize = tokenBase;
215183 break;
216184 }
217185 maybeEnd = (ch == "%");
225193 ch;
226194 while (ch = stream.next()) {
227195 if (ch == "'" && maybeEnd) {
228 state.tokenize = jsTokenBase;
196 state.tokenize = tokenBase;
229197 break;
230198 }
231199 maybeEnd = (ch == "'");
242210 }
243211
244212 if (!sb && stream.match(reUntilCodeStop)) {
245 state.tokenize = jsTokenBase;
213 state.tokenize = tokenBase;
246214 return "comment";
247215 }
248216
249217 if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
250 state.tokenize = jsTokenBase;
218 state.tokenize = tokenBase;
251219 return "comment";
252220 }
253221
261229 ch;
262230 while (ch = stream.next()) {
263231 if (ch == "/" && maybeEnd) {
264 state.tokenize = jsTokenBase;
232 state.tokenize = tokenBase;
265233 break;
266234 }
267235 maybeEnd = (ch == "/");
275243 ch;
276244 while (ch = stream.next()) {
277245 if (ch == "_" && maybeEnd) {
278 state.tokenize = jsTokenBase;
246 state.tokenize = tokenBase;
279247 break;
280248 }
281249 maybeEnd = (ch == "_");
290258
291259 while (ch = stream.next()) {
292260 if (ch == "-" && maybeEnd) {
293 state.tokenize = jsTokenBase;
261 state.tokenize = tokenBase;
294262 break;
295263 }
296264 maybeEnd = (ch == "-");
300268
301269 // macro
302270 function twTokenMacro(stream, state) {
303 var ch, word, known;
304
305271 if (stream.current() == '<<') {
306272 return 'macro';
307273 }
308274
309 ch = stream.next();
275 var ch = stream.next();
310276 if (!ch) {
311 state.tokenize = jsTokenBase;
277 state.tokenize = tokenBase;
312278 return null;
313279 }
314280 if (ch == ">") {
315281 if (stream.peek() == '>') {
316282 stream.next();
317 state.tokenize = jsTokenBase;
283 state.tokenize = tokenBase;
318284 return "macro";
319285 }
320286 }
321287
322288 stream.eatWhile(/[\w\$_]/);
323 word = stream.current();
324 known = keywords.propertyIsEnumerable(word) && keywords[word];
325
326 if (known) {
327 return known.style, word;
328 }
329 else {
330 return null, word;
331 }
289 return keywords.propertyIsEnumerable(stream.current()) ? "keyword" : null
332290 }
333291
334292 // Interface
335293 return {
336294 startState: function () {
337 return {
338 tokenize: jsTokenBase,
339 indented: 0,
340 level: 0
341 };
295 return {tokenize: tokenBase};
342296 },
343297
344298 token: function (stream, state) {
345299 if (stream.eatSpace()) return null;
346300 var style = state.tokenize(stream, state);
347301 return style;
348 },
349
350 electricChars: ""
302 }
351303 };
352304 });
353305
354306 CodeMirror.defineMIME("text/x-tiddlywiki", "tiddlywiki");
355307 });
356
357 //}}}
1414 }
1515
1616 .cm-tw-box {
17 border-top-width: 0px ! important;
17 border-top-width: 0px !important;
1818 border-style: solid;
1919 border-width: 1px;
2020 border-color: inherit;
7676 };
7777 });
7878
79 CodeMirror.defineMIME('troff', 'troff');
79 CodeMirror.defineMIME('text/troff', 'troff');
80 CodeMirror.defineMIME('text/x-troff', 'troff');
81 CodeMirror.defineMIME('application/x-troff', 'troff');
8082
8183 });
22
33 (function(mod) {
44 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
5 mod(require("../../lib/codemirror"), require("../../addon/mode/multiplex"));
66 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
7 define(["../../lib/codemirror", "../../addon/mode/multiplex"], mod);
88 else // Plain browser env
99 mod(CodeMirror);
1010 })(function(CodeMirror) {
1111 "use strict";
1212
13 CodeMirror.defineMode("twig", function() {
13 CodeMirror.defineMode("twig:inner", function() {
1414 var keywords = ["and", "as", "autoescape", "endautoescape", "block", "do", "endblock", "else", "elseif", "extends", "for", "endfor", "embed", "endembed", "filter", "endfilter", "flush", "from", "if", "endif", "in", "is", "include", "import", "not", "or", "set", "spaceless", "endspaceless", "with", "endwith", "trans", "endtrans", "blocktrans", "endblocktrans", "macro", "endmacro", "use", "verbatim", "endverbatim"],
1515 operator = /^[+\-*&%=<>!?|~^]/,
1616 sign = /^[:\[\(\{]/,
127127 };
128128 });
129129
130 CodeMirror.defineMode("twig", function(config, parserConfig) {
131 var twigInner = CodeMirror.getMode(config, "twig:inner");
132 if (!parserConfig || !parserConfig.base) return twigInner;
133 return CodeMirror.multiplexingMode(
134 CodeMirror.getMode(config, parserConfig.base), {
135 open: /\{[{#%]/, close: /[}#%]\}/, mode: twigInner, parseDelimiters: true
136 }
137 );
138 });
130139 CodeMirror.defineMIME("text/x-twig", "twig");
131140 });
7676
7777 $someObject("This plus $something in the middle").method(7567).property
7878
79 #set($something = "Parseable string with '$quotes'!")
80
7981 #macro( tablerows $color $somelist )
8082 #foreach( $something in $somelist )
8183 <tr><td bgcolor=$color>$something</td></tr>
3333 state.beforeParams = false;
3434 var ch = stream.next();
3535 // start of unparsed string?
36 if ((ch == "'") && state.inParams) {
36 if ((ch == "'") && !state.inString && state.inParams) {
3737 state.lastTokenWasBuiltin = false;
3838 return chain(stream, state, tokenString(ch));
3939 }
111111 Syntax highlighting and indentation for the Verilog and SystemVerilog languages (IEEE 1800).
112112 <h2>Configuration options:</h2>
113113 <ul>
114 <li><strong>noIndentKeywords</strong> - List of keywords which should not cause identation to increase. E.g. ["package", "module"]. Default: None</li>
114 <li><strong>noIndentKeywords</strong> - List of keywords which should not cause indentation to increase. E.g. ["package", "module"]. Default: None</li>
115115 </ul>
116116 </p>
117117
262262 ""
263263 );
264264
265 MT("covergoup_with_function_indents_properly",
265 MT("covergroup_with_function_indents_properly",
266266 "[keyword covergroup] [variable cg] [keyword with] [keyword function] [variable sample][bracket (][keyword bit] [variable b][bracket )];",
267267 " [variable c] : [keyword coverpoint] [variable c];",
268268 "[keyword endgroup]: [variable cg]",
249249 if (text == contextClosing) {
250250 return true;
251251 } else {
252 // contextClosing may be mulitple keywords separated by ;
252 // contextClosing may be multiple keywords separated by ;
253253 var closingKeywords = contextClosing.split(";");
254254 for (var i in closingKeywords) {
255255 if (text == closingKeywords[i]) {
0 <!doctype html>
1
2 <title>CodeMirror: VHDL mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="vhdl.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="#">VHDL</a>
22 </ul>
23 </div>
24
25 <article>
26 <h2>VHDL mode</h2>
27
28 <div><textarea id="code" name="code">
29 LIBRARY ieee;
30 USE ieee.std_logic_1164.ALL;
31 USE ieee.numeric_std.ALL;
32
33 ENTITY tb IS
34 END tb;
35
36 ARCHITECTURE behavior OF tb IS
37 --Inputs
38 signal a : unsigned(2 downto 0) := (others => '0');
39 signal b : unsigned(2 downto 0) := (others => '0');
40 --Outputs
41 signal a_eq_b : std_logic;
42 signal a_le_b : std_logic;
43 signal a_gt_b : std_logic;
44
45 signal i,j : integer;
46
47 BEGIN
48
49 -- Instantiate the Unit Under Test (UUT)
50 uut: entity work.comparator PORT MAP (
51 a => a,
52 b => b,
53 a_eq_b => a_eq_b,
54 a_le_b => a_le_b,
55 a_gt_b => a_gt_b
56 );
57
58 -- Stimulus process
59 stim_proc: process
60 begin
61 for i in 0 to 8 loop
62 for j in 0 to 8 loop
63 a <= to_unsigned(i,3); --integer to unsigned type conversion
64 b <= to_unsigned(j,3);
65 wait for 10 ns;
66 end loop;
67 end loop;
68 end process;
69
70 END;
71 </textarea></div>
72
73 <script>
74 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
75 lineNumbers: true,
76 matchBrackets: true,
77 mode: {
78 name: "vhdl",
79 }
80 });
81 </script>
82
83 <p>
84 Syntax highlighting and indentation for the VHDL language.
85 <h2>Configuration options:</h2>
86 <ul>
87 <li><strong>atoms</strong> - List of atom words. Default: "null"</li>
88 <li><strong>hooks</strong> - List of meta hooks. Default: ["`", "$"]</li>
89 <li><strong>multiLineStrings</strong> - Whether multi-line strings are accepted. Default: false</li>
90 </ul>
91 </p>
92
93 <p><strong>MIME types defined:</strong> <code>text/x-vhdl</code>.</p>
94 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 // Originally written by Alf Nielsen, re-written by Michael Zhou
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 words(str) {
15 var obj = {}, words = str.split(",");
16 for (var i = 0; i < words.length; ++i) {
17 var allCaps = words[i].toUpperCase();
18 var firstCap = words[i].charAt(0).toUpperCase() + words[i].slice(1);
19 obj[words[i]] = true;
20 obj[allCaps] = true;
21 obj[firstCap] = true;
22 }
23 return obj;
24 }
25
26 function metaHook(stream) {
27 stream.eatWhile(/[\w\$_]/);
28 return "meta";
29 }
30
31 CodeMirror.defineMode("vhdl", function(config, parserConfig) {
32 var indentUnit = config.indentUnit,
33 atoms = parserConfig.atoms || words("null"),
34 hooks = parserConfig.hooks || {"`": metaHook, "$": metaHook},
35 multiLineStrings = parserConfig.multiLineStrings;
36
37 var keywords = words("abs,access,after,alias,all,and,architecture,array,assert,attribute,begin,block," +
38 "body,buffer,bus,case,component,configuration,constant,disconnect,downto,else,elsif,end,end block,end case," +
39 "end component,end for,end generate,end if,end loop,end process,end record,end units,entity,exit,file,for," +
40 "function,generate,generic,generic map,group,guarded,if,impure,in,inertial,inout,is,label,library,linkage," +
41 "literal,loop,map,mod,nand,new,next,nor,null,of,on,open,or,others,out,package,package body,port,port map," +
42 "postponed,procedure,process,pure,range,record,register,reject,rem,report,return,rol,ror,select,severity,signal," +
43 "sla,sll,sra,srl,subtype,then,to,transport,type,unaffected,units,until,use,variable,wait,when,while,with,xnor,xor");
44
45 var blockKeywords = words("architecture,entity,begin,case,port,else,elsif,end,for,function,if");
46
47 var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
48 var curPunc;
49
50 function tokenBase(stream, state) {
51 var ch = stream.next();
52 if (hooks[ch]) {
53 var result = hooks[ch](stream, state);
54 if (result !== false) return result;
55 }
56 if (ch == '"') {
57 state.tokenize = tokenString2(ch);
58 return state.tokenize(stream, state);
59 }
60 if (ch == "'") {
61 state.tokenize = tokenString(ch);
62 return state.tokenize(stream, state);
63 }
64 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
65 curPunc = ch;
66 return null;
67 }
68 if (/[\d']/.test(ch)) {
69 stream.eatWhile(/[\w\.']/);
70 return "number";
71 }
72 if (ch == "-") {
73 if (stream.eat("-")) {
74 stream.skipToEnd();
75 return "comment";
76 }
77 }
78 if (isOperatorChar.test(ch)) {
79 stream.eatWhile(isOperatorChar);
80 return "operator";
81 }
82 stream.eatWhile(/[\w\$_]/);
83 var cur = stream.current();
84 if (keywords.propertyIsEnumerable(cur.toLowerCase())) {
85 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
86 return "keyword";
87 }
88 if (atoms.propertyIsEnumerable(cur)) return "atom";
89 return "variable";
90 }
91
92 function tokenString(quote) {
93 return function(stream, state) {
94 var escaped = false, next, end = false;
95 while ((next = stream.next()) != null) {
96 if (next == quote && !escaped) {end = true; break;}
97 escaped = !escaped && next == "--";
98 }
99 if (end || !(escaped || multiLineStrings))
100 state.tokenize = tokenBase;
101 return "string";
102 };
103 }
104 function tokenString2(quote) {
105 return function(stream, state) {
106 var escaped = false, next, end = false;
107 while ((next = stream.next()) != null) {
108 if (next == quote && !escaped) {end = true; break;}
109 escaped = !escaped && next == "--";
110 }
111 if (end || !(escaped || multiLineStrings))
112 state.tokenize = tokenBase;
113 return "string-2";
114 };
115 }
116
117 function Context(indented, column, type, align, prev) {
118 this.indented = indented;
119 this.column = column;
120 this.type = type;
121 this.align = align;
122 this.prev = prev;
123 }
124 function pushContext(state, col, type) {
125 return state.context = new Context(state.indented, col, type, null, state.context);
126 }
127 function popContext(state) {
128 var t = state.context.type;
129 if (t == ")" || t == "]" || t == "}")
130 state.indented = state.context.indented;
131 return state.context = state.context.prev;
132 }
133
134 // Interface
135 return {
136 startState: function(basecolumn) {
137 return {
138 tokenize: null,
139 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
140 indented: 0,
141 startOfLine: true
142 };
143 },
144
145 token: function(stream, state) {
146 var ctx = state.context;
147 if (stream.sol()) {
148 if (ctx.align == null) ctx.align = false;
149 state.indented = stream.indentation();
150 state.startOfLine = true;
151 }
152 if (stream.eatSpace()) return null;
153 curPunc = null;
154 var style = (state.tokenize || tokenBase)(stream, state);
155 if (style == "comment" || style == "meta") return style;
156 if (ctx.align == null) ctx.align = true;
157
158 if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
159 else if (curPunc == "{") pushContext(state, stream.column(), "}");
160 else if (curPunc == "[") pushContext(state, stream.column(), "]");
161 else if (curPunc == "(") pushContext(state, stream.column(), ")");
162 else if (curPunc == "}") {
163 while (ctx.type == "statement") ctx = popContext(state);
164 if (ctx.type == "}") ctx = popContext(state);
165 while (ctx.type == "statement") ctx = popContext(state);
166 }
167 else if (curPunc == ctx.type) popContext(state);
168 else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
169 pushContext(state, stream.column(), "statement");
170 state.startOfLine = false;
171 return style;
172 },
173
174 indent: function(state, textAfter) {
175 if (state.tokenize != tokenBase && state.tokenize != null) return 0;
176 var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
177 if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
178 else if (ctx.align) return ctx.column + (closing ? 0 : 1);
179 else return ctx.indented + (closing ? 0 : indentUnit);
180 },
181
182 electricChars: "{}"
183 };
184 });
185
186 CodeMirror.defineMIME("text/x-vhdl", "vhdl");
187
188 });
0 <!doctype html>
1
2 <title>CodeMirror: Vue.js mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/mode/overlay.js"></script>
9 <script src="../../addon/mode/simple.js"></script>
10 <script src="../../addon/selection/selection-pointer.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="../coffeescript/coffeescript.js"></script>
15 <script src="../sass/sass.js"></script>
16 <script src="../pug/pug.js"></script>
17
18 <script src="../handlebars/handlebars.js"></script>
19 <script src="../htmlmixed/htmlmixed.js"></script>
20 <script src="vue.js"></script>
21 <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
22 <div id=nav>
23 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
24
25 <ul>
26 <li><a href="../../index.html">Home</a>
27 <li><a href="../../doc/manual.html">Manual</a>
28 <li><a href="https://github.com/codemirror/codemirror">Code</a>
29 </ul>
30 <ul>
31 <li><a href="../index.html">Language modes</a>
32 <li><a class=active href="#">Vue.js mode</a>
33 </ul>
34 </div>
35
36 <article>
37 <h2>Vue.js mode</h2>
38 <form><textarea id="code" name="code">
39 <template>
40 <div class="sass">Im am a {{mustache-like}} template</div>
41 </template>
42
43 <script lang="coffee">
44 module.exports =
45 props: ['one', 'two', 'three']
46 </script>
47
48 <style lang="sass">
49 .sass
50 font-size: 18px
51 </style>
52
53 </textarea></form>
54 <script>
55 // Define an extended mixed-mode that understands vbscript and
56 // leaves mustache/handlebars embedded templates in html mode
57 var mixedMode = {
58 name: "vue"
59 };
60 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
61 mode: mixedMode,
62 selectionPointer: true
63 });
64 </script>
65
66 <p><strong>MIME types defined:</strong> <code>text/x-vue</code></p>
67
68 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function (mod) {
4 "use strict";
5 if (typeof exports === "object" && typeof module === "object") {// CommonJS
6 mod(require("../../lib/codemirror"),
7 require("../../addon/mode/overlay"),
8 require("../xml/xml"),
9 require("../javascript/javascript"),
10 require("../coffeescript/coffeescript"),
11 require("../css/css"),
12 require("../sass/sass"),
13 require("../stylus/stylus"),
14 require("../pug/pug"),
15 require("../handlebars/handlebars"));
16 } else if (typeof define === "function" && define.amd) { // AMD
17 define(["../../lib/codemirror",
18 "../../addon/mode/overlay",
19 "../xml/xml",
20 "../javascript/javascript",
21 "../coffeescript/coffeescript",
22 "../css/css",
23 "../sass/sass",
24 "../stylus/stylus",
25 "../pug/pug",
26 "../handlebars/handlebars"], mod);
27 } else { // Plain browser env
28 mod(CodeMirror);
29 }
30 })(function (CodeMirror) {
31 var tagLanguages = {
32 script: [
33 ["lang", /coffee(script)?/, "coffeescript"],
34 ["type", /^(?:text|application)\/(?:x-)?coffee(?:script)?$/, "coffeescript"]
35 ],
36 style: [
37 ["lang", /^stylus$/i, "stylus"],
38 ["lang", /^sass$/i, "sass"],
39 ["type", /^(text\/)?(x-)?styl(us)?$/i, "stylus"],
40 ["type", /^text\/sass/i, "sass"]
41 ],
42 template: [
43 ["lang", /^vue-template$/i, "vue"],
44 ["lang", /^pug$/i, "pug"],
45 ["lang", /^handlebars$/i, "handlebars"],
46 ["type", /^(text\/)?(x-)?pug$/i, "pug"],
47 ["type", /^text\/x-handlebars-template$/i, "handlebars"],
48 [null, null, "vue-template"]
49 ]
50 };
51
52 CodeMirror.defineMode("vue-template", function (config, parserConfig) {
53 var mustacheOverlay = {
54 token: function (stream) {
55 if (stream.match(/^\{\{.*?\}\}/)) return "meta mustache";
56 while (stream.next() && !stream.match("{{", false)) {}
57 return null;
58 }
59 };
60 return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), mustacheOverlay);
61 });
62
63 CodeMirror.defineMode("vue", function (config) {
64 return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages});
65 }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "pug", "handlebars");
66
67 CodeMirror.defineMIME("script/x-vue", "vue");
68 });
0 <!doctype html>
1
2 <title>CodeMirror: Web IDL mode</title>
3 <meta charset="utf-8">
4 <link rel="stylesheet" href="../../doc/docs.css">
5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <script src="../../lib/codemirror.js"></script>
7 <script src="../../addon/edit/matchbrackets.js"></script>
8 <script src="webidl.js"></script>
9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10
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="#">Web IDL</a>
22 </ul>
23 </div>
24
25 <article>
26 <h2>Web IDL mode</h2>
27
28 <div>
29 <textarea id="code" name="code">
30 [NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
31 interface HTMLImageElement : HTMLElement {
32 attribute DOMString alt;
33 attribute DOMString src;
34 attribute DOMString srcset;
35 attribute DOMString sizes;
36 attribute DOMString? crossOrigin;
37 attribute DOMString useMap;
38 attribute boolean isMap;
39 attribute unsigned long width;
40 attribute unsigned long height;
41 readonly attribute unsigned long naturalWidth;
42 readonly attribute unsigned long naturalHeight;
43 readonly attribute boolean complete;
44 readonly attribute DOMString currentSrc;
45
46 // also has obsolete members
47 };
48
49 partial interface HTMLImageElement {
50 attribute DOMString name;
51 attribute DOMString lowsrc;
52 attribute DOMString align;
53 attribute unsigned long hspace;
54 attribute unsigned long vspace;
55 attribute DOMString longDesc;
56
57 [TreatNullAs=EmptyString] attribute DOMString border;
58 };
59 </textarea>
60 </div>
61
62 <script>
63 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
64 lineNumbers: true,
65 matchBrackets: true
66 });
67 </script>
68
69 <p><strong>MIME type defined:</strong> <code>text/x-webidl</code>.</p>
70 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function(mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"));
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror"], mod);
8 else // Plain browser env
9 mod(CodeMirror);
10 })(function(CodeMirror) {
11 "use strict";
12
13 function wordRegexp(words) {
14 return new RegExp("^((" + words.join(")|(") + "))\\b");
15 };
16
17 var builtinArray = [
18 "Clamp",
19 "Constructor",
20 "EnforceRange",
21 "Exposed",
22 "ImplicitThis",
23 "Global", "PrimaryGlobal",
24 "LegacyArrayClass",
25 "LegacyUnenumerableNamedProperties",
26 "LenientThis",
27 "NamedConstructor",
28 "NewObject",
29 "NoInterfaceObject",
30 "OverrideBuiltins",
31 "PutForwards",
32 "Replaceable",
33 "SameObject",
34 "TreatNonObjectAsNull",
35 "TreatNullAs",
36 "EmptyString",
37 "Unforgeable",
38 "Unscopeable"
39 ];
40 var builtins = wordRegexp(builtinArray);
41
42 var typeArray = [
43 "unsigned", "short", "long", // UnsignedIntegerType
44 "unrestricted", "float", "double", // UnrestrictedFloatType
45 "boolean", "byte", "octet", // Rest of PrimitiveType
46 "Promise", // PromiseType
47 "ArrayBuffer", "DataView", "Int8Array", "Int16Array", "Int32Array",
48 "Uint8Array", "Uint16Array", "Uint32Array", "Uint8ClampedArray",
49 "Float32Array", "Float64Array", // BufferRelatedType
50 "ByteString", "DOMString", "USVString", "sequence", "object", "RegExp",
51 "Error", "DOMException", "FrozenArray", // Rest of NonAnyType
52 "any", // Rest of SingleType
53 "void" // Rest of ReturnType
54 ];
55 var types = wordRegexp(typeArray);
56
57 var keywordArray = [
58 "attribute", "callback", "const", "deleter", "dictionary", "enum", "getter",
59 "implements", "inherit", "interface", "iterable", "legacycaller", "maplike",
60 "partial", "required", "serializer", "setlike", "setter", "static",
61 "stringifier", "typedef", // ArgumentNameKeyword except
62 // "unrestricted"
63 "optional", "readonly", "or"
64 ];
65 var keywords = wordRegexp(keywordArray);
66
67 var atomArray = [
68 "true", "false", // BooleanLiteral
69 "Infinity", "NaN", // FloatLiteral
70 "null" // Rest of ConstValue
71 ];
72 var atoms = wordRegexp(atomArray);
73
74 CodeMirror.registerHelper("hintWords", "webidl",
75 builtinArray.concat(typeArray).concat(keywordArray).concat(atomArray));
76
77 var startDefArray = ["callback", "dictionary", "enum", "interface"];
78 var startDefs = wordRegexp(startDefArray);
79
80 var endDefArray = ["typedef"];
81 var endDefs = wordRegexp(endDefArray);
82
83 var singleOperators = /^[:<=>?]/;
84 var integers = /^-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)/;
85 var floats = /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/;
86 var identifiers = /^_?[A-Za-z][0-9A-Z_a-z-]*/;
87 var identifiersEnd = /^_?[A-Za-z][0-9A-Z_a-z-]*(?=\s*;)/;
88 var strings = /^"[^"]*"/;
89 var multilineComments = /^\/\*.*?\*\//;
90 var multilineCommentsStart = /^\/\*.*/;
91 var multilineCommentsEnd = /^.*?\*\//;
92
93 function readToken(stream, state) {
94 // whitespace
95 if (stream.eatSpace()) return null;
96
97 // comment
98 if (state.inComment) {
99 if (stream.match(multilineCommentsEnd)) {
100 state.inComment = false;
101 return "comment";
102 }
103 stream.skipToEnd();
104 return "comment";
105 }
106 if (stream.match("//")) {
107 stream.skipToEnd();
108 return "comment";
109 }
110 if (stream.match(multilineComments)) return "comment";
111 if (stream.match(multilineCommentsStart)) {
112 state.inComment = true;
113 return "comment";
114 }
115
116 // integer and float
117 if (stream.match(/^-?[0-9\.]/, false)) {
118 if (stream.match(integers) || stream.match(floats)) return "number";
119 }
120
121 // string
122 if (stream.match(strings)) return "string";
123
124 // identifier
125 if (state.startDef && stream.match(identifiers)) return "def";
126
127 if (state.endDef && stream.match(identifiersEnd)) {
128 state.endDef = false;
129 return "def";
130 }
131
132 if (stream.match(keywords)) return "keyword";
133
134 if (stream.match(types)) {
135 var lastToken = state.lastToken;
136 var nextToken = (stream.match(/^\s*(.+?)\b/, false) || [])[1];
137
138 if (lastToken === ":" || lastToken === "implements" ||
139 nextToken === "implements" || nextToken === "=") {
140 // Used as identifier
141 return "builtin";
142 } else {
143 // Used as type
144 return "variable-3";
145 }
146 }
147
148 if (stream.match(builtins)) return "builtin";
149 if (stream.match(atoms)) return "atom";
150 if (stream.match(identifiers)) return "variable";
151
152 // other
153 if (stream.match(singleOperators)) return "operator";
154
155 // unrecognized
156 stream.next();
157 return null;
158 };
159
160 CodeMirror.defineMode("webidl", function() {
161 return {
162 startState: function() {
163 return {
164 // Is in multiline comment
165 inComment: false,
166 // Last non-whitespace, matched token
167 lastToken: "",
168 // Next token is a definition
169 startDef: false,
170 // Last token of the statement is a definition
171 endDef: false
172 };
173 },
174 token: function(stream, state) {
175 var style = readToken(stream, state);
176
177 if (style) {
178 var cur = stream.current();
179 state.lastToken = cur;
180 if (style === "keyword") {
181 state.startDef = startDefs.test(cur);
182 state.endDef = state.endDef || endDefs.test(cur);
183 } else {
184 state.startDef = false;
185 }
186 }
187
188 return style;
189 }
190 };
191 });
192
193 CodeMirror.defineMIME("text/x-webidl", "webidl");
194 });
4141 lineNumbers: true
4242 });
4343 </script>
44 <p>The XML mode supports two configuration parameters:</p>
44 <p>The XML mode supports these configuration parameters:</p>
4545 <dl>
4646 <dt><code>htmlMode (boolean)</code></dt>
4747 <dd>This switches the mode to parse HTML instead of XML. This
4848 means attributes do not have to be quoted, and some elements
4949 (such as <code>br</code>) do not require a closing tag.</dd>
50 <dt><code>matchClosing (boolean)</code></dt>
51 <dd>Controls whether the mode checks that close tags match the
52 corresponding opening tag, and highlights mismatches as errors.
53 Defaults to true.</dd>
5054 <dt><code>alignCDATA (boolean)</code></dt>
5155 <dd>Setting this to true will force the opening tag of CDATA
5256 blocks to not be indented.</dd>
1010 })(function(CodeMirror) {
1111 "use strict";
1212
13 CodeMirror.defineMode("xml", function(config, parserConfig) {
14 var indentUnit = config.indentUnit;
15 var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
16 var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
17 if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
18
19 var Kludges = parserConfig.htmlMode ? {
20 autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
21 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
22 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
23 'track': true, 'wbr': true, 'menuitem': true},
24 implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
25 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
26 'th': true, 'tr': true},
27 contextGrabbers: {
28 'dd': {'dd': true, 'dt': true},
29 'dt': {'dd': true, 'dt': true},
30 'li': {'li': true},
31 'option': {'option': true, 'optgroup': true},
32 'optgroup': {'optgroup': true},
33 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
34 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
35 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
36 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
37 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
38 'rp': {'rp': true, 'rt': true},
39 'rt': {'rp': true, 'rt': true},
40 'tbody': {'tbody': true, 'tfoot': true},
41 'td': {'td': true, 'th': true},
42 'tfoot': {'tbody': true},
43 'th': {'td': true, 'th': true},
44 'thead': {'tbody': true, 'tfoot': true},
45 'tr': {'tr': true}
46 },
47 doNotIndent: {"pre": true},
48 allowUnquoted: true,
49 allowMissing: true,
50 caseFold: true
51 } : {
52 autoSelfClosers: {},
53 implicitlyClosed: {},
54 contextGrabbers: {},
55 doNotIndent: {},
56 allowUnquoted: false,
57 allowMissing: false,
58 caseFold: false
59 };
60 var alignCDATA = parserConfig.alignCDATA;
13 var htmlConfig = {
14 autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
15 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
16 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
17 'track': true, 'wbr': true, 'menuitem': true},
18 implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
19 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
20 'th': true, 'tr': true},
21 contextGrabbers: {
22 'dd': {'dd': true, 'dt': true},
23 'dt': {'dd': true, 'dt': true},
24 'li': {'li': true},
25 'option': {'option': true, 'optgroup': true},
26 'optgroup': {'optgroup': true},
27 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
28 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
29 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
30 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
31 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
32 'rp': {'rp': true, 'rt': true},
33 'rt': {'rp': true, 'rt': true},
34 'tbody': {'tbody': true, 'tfoot': true},
35 'td': {'td': true, 'th': true},
36 'tfoot': {'tbody': true},
37 'th': {'td': true, 'th': true},
38 'thead': {'tbody': true, 'tfoot': true},
39 'tr': {'tr': true}
40 },
41 doNotIndent: {"pre": true},
42 allowUnquoted: true,
43 allowMissing: true,
44 caseFold: true
45 }
46
47 var xmlConfig = {
48 autoSelfClosers: {},
49 implicitlyClosed: {},
50 contextGrabbers: {},
51 doNotIndent: {},
52 allowUnquoted: false,
53 allowMissing: false,
54 caseFold: false
55 }
56
57 CodeMirror.defineMode("xml", function(editorConf, config_) {
58 var indentUnit = editorConf.indentUnit
59 var config = {}
60 var defaults = config_.htmlMode ? htmlConfig : xmlConfig
61 for (var prop in defaults) config[prop] = defaults[prop]
62 for (var prop in config_) config[prop] = config_[prop]
6163
6264 // Return variables for tokenizers
6365 var type, setStyle;
108110 return null;
109111 }
110112 }
113 inText.isInText = true;
111114
112115 function inTag(stream, state) {
113116 var ch = stream.next();
186189 this.tagName = tagName;
187190 this.indent = state.indented;
188191 this.startOfLine = startOfLine;
189 if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
192 if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
190193 this.noIndent = true;
191194 }
192195 function popContext(state) {
199202 return;
200203 }
201204 parentTagName = state.context.tagName;
202 if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
203 !Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
205 if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
206 !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
204207 return;
205208 }
206209 popContext(state);
231234 if (type == "word") {
232235 var tagName = stream.current();
233236 if (state.context && state.context.tagName != tagName &&
234 Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
237 config.implicitlyClosed.hasOwnProperty(state.context.tagName))
235238 popContext(state);
236 if (state.context && state.context.tagName == tagName) {
239 if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
237240 setStyle = "tag";
238241 return closeState;
239242 } else {
267270 var tagName = state.tagName, tagStart = state.tagStart;
268271 state.tagName = state.tagStart = null;
269272 if (type == "selfcloseTag" ||
270 Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
273 config.autoSelfClosers.hasOwnProperty(tagName)) {
271274 maybePopContext(state, tagName);
272275 } else {
273276 maybePopContext(state, tagName);
280283 }
281284 function attrEqState(type, stream, state) {
282285 if (type == "equals") return attrValueState;
283 if (!Kludges.allowMissing) setStyle = "error";
286 if (!config.allowMissing) setStyle = "error";
284287 return attrState(type, stream, state);
285288 }
286289 function attrValueState(type, stream, state) {
287290 if (type == "string") return attrContinuedState;
288 if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;}
291 if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
289292 setStyle = "error";
290293 return attrState(type, stream, state);
291294 }
295298 }
296299
297300 return {
298 startState: function() {
299 return {tokenize: inText,
300 state: baseState,
301 indented: 0,
302 tagName: null, tagStart: null,
303 context: null};
301 startState: function(baseIndent) {
302 var state = {tokenize: inText,
303 state: baseState,
304 indented: baseIndent || 0,
305 tagName: null, tagStart: null,
306 context: null}
307 if (baseIndent != null) state.baseIndent = baseIndent
308 return state
304309 },
305310
306311 token: function(stream, state) {
333338 return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
334339 // Indent the starts of attribute names.
335340 if (state.tagName) {
336 if (multilineTagIndentPastTag)
341 if (config.multilineTagIndentPastTag !== false)
337342 return state.tagStart + state.tagName.length + 2;
338343 else
339 return state.tagStart + indentUnit * multilineTagIndentFactor;
340 }
341 if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
344 return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
345 }
346 if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
342347 var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
343348 if (tagAfter && tagAfter[1]) { // Closing tag spotted
344349 while (context) {
345350 if (context.tagName == tagAfter[2]) {
346351 context = context.prev;
347352 break;
348 } else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
353 } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
349354 context = context.prev;
350355 } else {
351356 break;
353358 }
354359 } else if (tagAfter) { // Opening tag spotted
355360 while (context) {
356 var grabbers = Kludges.contextGrabbers[context.tagName];
361 var grabbers = config.contextGrabbers[context.tagName];
357362 if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
358363 context = context.prev;
359364 else
360365 break;
361366 }
362367 }
363 while (context && !context.startOfLine)
368 while (context && context.prev && !context.startOfLine)
364369 context = context.prev;
365370 if (context) return context.indent + indentUnit;
366 else return 0;
371 else return state.baseIndent || 0;
367372 },
368373
369374 electricInput: /<\/[\s\w:]+>$/,
370375 blockCommentStart: "<!--",
371376 blockCommentEnd: "-->",
372377
373 configuration: parserConfig.htmlMode ? "html" : "xml",
374 helperType: parserConfig.htmlMode ? "html" : "xml"
378 configuration: config.htmlMode ? "html" : "xml",
379 helperType: config.htmlMode ? "html" : "xml",
380
381 skipAttribute: function(state) {
382 if (state.state == attrValueState)
383 state.state = attrState
384 }
375385 };
376386 });
377387
1616 // function. Each keyword is a property of the keywords object whose
1717 // value is {type: atype, style: astyle}
1818 var keywords = function(){
19 // conveinence functions used to build keywords object
19 // convenience functions used to build keywords object
2020 function kw(type) {return {type: type, style: "keyword"};}
2121 var A = kw("keyword a")
2222 , B = kw("keyword b")
0 <!doctype html>
1
2 <title>CodeMirror: yacas mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel=stylesheet href=../../lib/codemirror.css>
7 <script src=../../lib/codemirror.js></script>
8 <script src=../../addon/edit/matchbrackets.js></script>
9 <script src=yacas.js></script>
10 <style type=text/css>
11 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
12 </style>
13 <div id=nav>
14 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
15
16 <ul>
17 <li><a href="../../index.html">Home</a>
18 <li><a href="../../doc/manual.html">Manual</a>
19 <li><a href="https://github.com/codemirror/codemirror">Code</a>
20 </ul>
21 <ul>
22 <li><a href="../index.html">Language modes</a>
23 <li><a class=active href="#">yacas</a>
24 </ul>
25 </div>
26
27 <article>
28 <h2>yacas mode</h2>
29
30
31 <textarea id="yacasCode">
32 // example yacas code
33 Graph(edges_IsList) <-- [
34 Local(v, e, f, t);
35
36 vertices := {};
37
38 ForEach (e, edges) [
39 If (IsList(e), e := Head(e));
40 {f, t} := Tail(Listify(e));
41
42 DestructiveAppend(vertices, f);
43 DestructiveAppend(vertices, t);
44 ];
45
46 Graph(RemoveDuplicates(vertices), edges);
47 ];
48
49 10 # IsGraph(Graph(vertices_IsList, edges_IsList)) <-- True;
50 20 # IsGraph(_x) <-- False;
51
52 Edges(Graph(vertices_IsList, edges_IsList)) <-- edges;
53 Vertices(Graph(vertices_IsList, edges_IsList)) <-- vertices;
54
55 AdjacencyList(g_IsGraph) <-- [
56 Local(l, vertices, edges, e, op, f, t);
57
58 l := Association'Create();
59
60 vertices := Vertices(g);
61 ForEach (v, vertices)
62 Association'Set(l, v, {});
63
64 edges := Edges(g);
65
66 ForEach(e, edges) [
67 If (IsList(e), e := Head(e));
68 {op, f, t} := Listify(e);
69 DestructiveAppend(Association'Get(l, f), t);
70 If (String(op) = "<->", DestructiveAppend(Association'Get(l, t), f));
71 ];
72
73 l;
74 ];
75 </textarea>
76
77 <script>
78 var yacasEditor = CodeMirror.fromTextArea(document.getElementById('yacasCode'), {
79 mode: 'text/x-yacas',
80 lineNumbers: true,
81 matchBrackets: true
82 });
83 </script>
84
85 <p><strong>MIME types defined:</strong> <code>text/x-yacas</code> (yacas).</p>
86 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 // Yacas mode copyright (c) 2015 by Grzegorz Mazur
4 // Loosely based on mathematica mode by Calin Barbat
5
6 (function(mod) {
7 if (typeof exports == "object" && typeof module == "object") // CommonJS
8 mod(require("../../lib/codemirror"));
9 else if (typeof define == "function" && define.amd) // AMD
10 define(["../../lib/codemirror"], mod);
11 else // Plain browser env
12 mod(CodeMirror);
13 })(function(CodeMirror) {
14 "use strict";
15
16 CodeMirror.defineMode('yacas', function(_config, _parserConfig) {
17
18 function words(str) {
19 var obj = {}, words = str.split(" ");
20 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
21 return obj;
22 }
23
24 var bodiedOps = words("Assert BackQuote D Defun Deriv For ForEach FromFile " +
25 "FromString Function Integrate InverseTaylor Limit " +
26 "LocalSymbols Macro MacroRule MacroRulePattern " +
27 "NIntegrate Rule RulePattern Subst TD TExplicitSum " +
28 "TSum Taylor Taylor1 Taylor2 Taylor3 ToFile " +
29 "ToStdout ToString TraceRule Until While");
30
31 // patterns
32 var pFloatForm = "(?:(?:\\.\\d+|\\d+\\.\\d*|\\d+)(?:[eE][+-]?\\d+)?)";
33 var pIdentifier = "(?:[a-zA-Z\\$'][a-zA-Z0-9\\$']*)";
34
35 // regular expressions
36 var reFloatForm = new RegExp(pFloatForm);
37 var reIdentifier = new RegExp(pIdentifier);
38 var rePattern = new RegExp(pIdentifier + "?_" + pIdentifier);
39 var reFunctionLike = new RegExp(pIdentifier + "\\s*\\(");
40
41 function tokenBase(stream, state) {
42 var ch;
43
44 // get next character
45 ch = stream.next();
46
47 // string
48 if (ch === '"') {
49 state.tokenize = tokenString;
50 return state.tokenize(stream, state);
51 }
52
53 // comment
54 if (ch === '/') {
55 if (stream.eat('*')) {
56 state.tokenize = tokenComment;
57 return state.tokenize(stream, state);
58 }
59 if (stream.eat("/")) {
60 stream.skipToEnd();
61 return "comment";
62 }
63 }
64
65 // go back one character
66 stream.backUp(1);
67
68 // update scope info
69 var m = stream.match(/^(\w+)\s*\(/, false);
70 if (m !== null && bodiedOps.hasOwnProperty(m[1]))
71 state.scopes.push('bodied');
72
73 var scope = currentScope(state);
74
75 if (scope === 'bodied' && ch === '[')
76 state.scopes.pop();
77
78 if (ch === '[' || ch === '{' || ch === '(')
79 state.scopes.push(ch);
80
81 scope = currentScope(state);
82
83 if (scope === '[' && ch === ']' ||
84 scope === '{' && ch === '}' ||
85 scope === '(' && ch === ')')
86 state.scopes.pop();
87
88 if (ch === ';') {
89 while (scope === 'bodied') {
90 state.scopes.pop();
91 scope = currentScope(state);
92 }
93 }
94
95 // look for ordered rules
96 if (stream.match(/\d+ *#/, true, false)) {
97 return 'qualifier';
98 }
99
100 // look for numbers
101 if (stream.match(reFloatForm, true, false)) {
102 return 'number';
103 }
104
105 // look for placeholders
106 if (stream.match(rePattern, true, false)) {
107 return 'variable-3';
108 }
109
110 // match all braces separately
111 if (stream.match(/(?:\[|\]|{|}|\(|\))/, true, false)) {
112 return 'bracket';
113 }
114
115 // literals looking like function calls
116 if (stream.match(reFunctionLike, true, false)) {
117 stream.backUp(1);
118 return 'variable';
119 }
120
121 // all other identifiers
122 if (stream.match(reIdentifier, true, false)) {
123 return 'variable-2';
124 }
125
126 // operators; note that operators like @@ or /; are matched separately for each symbol.
127 if (stream.match(/(?:\\|\+|\-|\*|\/|,|;|\.|:|@|~|=|>|<|&|\||_|`|'|\^|\?|!|%)/, true, false)) {
128 return 'operator';
129 }
130
131 // everything else is an error
132 return 'error';
133 }
134
135 function tokenString(stream, state) {
136 var next, end = false, escaped = false;
137 while ((next = stream.next()) != null) {
138 if (next === '"' && !escaped) {
139 end = true;
140 break;
141 }
142 escaped = !escaped && next === '\\';
143 }
144 if (end && !escaped) {
145 state.tokenize = tokenBase;
146 }
147 return 'string';
148 };
149
150 function tokenComment(stream, state) {
151 var prev, next;
152 while((next = stream.next()) != null) {
153 if (prev === '*' && next === '/') {
154 state.tokenize = tokenBase;
155 break;
156 }
157 prev = next;
158 }
159 return 'comment';
160 }
161
162 function currentScope(state) {
163 var scope = null;
164 if (state.scopes.length > 0)
165 scope = state.scopes[state.scopes.length - 1];
166 return scope;
167 }
168
169 return {
170 startState: function() {
171 return {
172 tokenize: tokenBase,
173 scopes: []
174 };
175 },
176 token: function(stream, state) {
177 if (stream.eatSpace()) return null;
178 return state.tokenize(stream, state);
179 },
180 indent: function(state, textAfter) {
181 if (state.tokenize !== tokenBase && state.tokenize !== null)
182 return CodeMirror.Pass;
183
184 var delta = 0;
185 if (textAfter === ']' || textAfter === '];' ||
186 textAfter === '}' || textAfter === '};' ||
187 textAfter === ');')
188 delta = -1;
189
190 return (state.scopes.length + delta) * _config.indentUnit;
191 },
192 electricChars: "{}[]();",
193 blockCommentStart: "/*",
194 blockCommentEnd: "*/",
195 lineComment: "//"
196 };
197 });
198
199 CodeMirror.defineMIME('text/x-yacas', {
200 name: 'yacas'
201 });
202
203 });
0 <!doctype html>
1
2 <title>CodeMirror: YAML front matter mode</title>
3 <meta charset="utf-8"/>
4 <link rel=stylesheet href="../../doc/docs.css">
5
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/mode/overlay.js"></script>
9 <script src="../markdown/markdown.js"></script>
10 <script src="../gfm/gfm.js"></script>
11 <script src="../yaml/yaml.js"></script>
12 <script src="yaml-frontmatter.js"></script>
13 <style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</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="#">YAML-Frontmatter</a>
25 </ul>
26 </div>
27
28 <article>
29 <h2>YAML front matter mode</h2>
30 <form><textarea id="code" name="code">
31 ---
32 receipt: Oz-Ware Purchase Invoice
33 date: 2007-08-06
34 customer:
35 given: Dorothy
36 family: Gale
37
38 items:
39 - part_no: A4786
40 descrip: Water Bucket (Filled)
41 price: 1.47
42 quantity: 4
43
44 - part_no: E1628
45 descrip: High Heeled "Ruby" Slippers
46 size: 8
47 price: 100.27
48 quantity: 1
49
50 bill-to: &id001
51 street: |
52 123 Tornado Alley
53 Suite 16
54 city: East Centerville
55 state: KS
56
57 ship-to: *id001
58
59 specialDelivery: >
60 Follow the Yellow Brick
61 Road to the Emerald City.
62 Pay no attention to the
63 man behind the curtain.
64 ---
65
66 GitHub Flavored Markdown
67 ========================
68
69 Everything from markdown plus GFM features:
70
71 ## URL autolinking
72
73 Underscores_are_allowed_between_words.
74
75 ## Strikethrough text
76
77 GFM adds syntax to strikethrough text, which is missing from standard Markdown.
78
79 ~~Mistaken text.~~
80 ~~**works with other formatting**~~
81
82 ~~spans across
83 lines~~
84
85 ## Fenced code blocks (and syntax highlighting)
86
87 ```javascript
88 for (var i = 0; i &lt; items.length; i++) {
89 console.log(items[i], i); // log them
90 }
91 ```
92
93 ## Task Lists
94
95 - [ ] Incomplete task list item
96 - [x] **Completed** task list item
97
98 ## A bit of GitHub spice
99
100 * SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
101 * User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
102 * User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
103 * \#Num: #1
104 * User/#Num: mojombo#1
105 * User/Project#Num: mojombo/god#1
106
107 See http://github.github.com/github-flavored-markdown/.
108 </textarea></form>
109
110 <p>Defines a mode that parses
111 a <a href="http://jekyllrb.com/docs/frontmatter/">YAML frontmatter</a>
112 at the start of a file, switching to a base mode at the end of that.
113 Takes a mode configuration option <code>base</code> to configure the
114 base mode, which defaults to <code>"gfm"</code>.</p>
115
116 <script>
117 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: "yaml-frontmatter"});
118 </script>
119
120 </article>
0 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // Distributed under an MIT license: http://codemirror.net/LICENSE
2
3 (function (mod) {
4 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 mod(require("../../lib/codemirror"), require("../yaml/yaml"))
6 else if (typeof define == "function" && define.amd) // AMD
7 define(["../../lib/codemirror", "../yaml/yaml"], mod)
8 else // Plain browser env
9 mod(CodeMirror)
10 })(function (CodeMirror) {
11
12 var START = 0, FRONTMATTER = 1, BODY = 2
13
14 // a mixed mode for Markdown text with an optional YAML front matter
15 CodeMirror.defineMode("yaml-frontmatter", function (config, parserConfig) {
16 var yamlMode = CodeMirror.getMode(config, "yaml")
17 var innerMode = CodeMirror.getMode(config, parserConfig && parserConfig.base || "gfm")
18
19 function curMode(state) {
20 return state.state == BODY ? innerMode : yamlMode
21 }
22
23 return {
24 startState: function () {
25 return {
26 state: START,
27 inner: CodeMirror.startState(yamlMode)
28 }
29 },
30 copyState: function (state) {
31 return {
32 state: state.state,
33 inner: CodeMirror.copyState(curMode(state), state.inner)
34 }
35 },
36 token: function (stream, state) {
37 if (state.state == START) {
38 if (stream.match(/---/, false)) {
39 state.state = FRONTMATTER
40 return yamlMode.token(stream, state.inner)
41 } else {
42 state.state = BODY
43 state.inner = CodeMirror.startState(innerMode)
44 return innerMode.token(stream, state.inner)
45 }
46 } else if (state.state == FRONTMATTER) {
47 var end = stream.sol() && stream.match(/---/, false)
48 var style = yamlMode.token(stream, state.inner)
49 if (end) {
50 state.state = BODY
51 state.inner = CodeMirror.startState(innerMode)
52 }
53 return style
54 } else {
55 return innerMode.token(stream, state.inner)
56 }
57 },
58 innerMode: function (state) {
59 return {mode: curMode(state), state: state.inner}
60 },
61 blankLine: function (state) {
62 var mode = curMode(state)
63 if (mode.blankLine) return mode.blankLine(state.inner)
64 }
65 }
66 })
67 });
00 {
1 "name": "codemirror",
2 "version":"5.4.0",
3 "main": "lib/codemirror.js",
4 "description": "In-browser code editing made bearable",
5 "license": "MIT",
6 "directories": {"lib": "./lib"},
7 "scripts": {"test": "node ./test/run.js"},
8 "devDependencies": {"node-static": "0.6.0",
9 "phantomjs": "1.9.2-5",
10 "blint": ">=0.1.1"},
11 "bugs": "http://github.com/codemirror/CodeMirror/issues",
12 "keywords": ["JavaScript", "CodeMirror", "Editor"],
13 "homepage": "http://codemirror.net",
14 "maintainers":[{"name": "Marijn Haverbeke",
15 "email": "marijnh@gmail.com",
16 "web": "http://marijnhaverbeke.nl"}],
17 "repository": {"type": "git",
18 "url": "https://github.com/codemirror/CodeMirror.git"}
1 "name": "codemirror",
2 "version": "5.19.0",
3 "main": "lib/codemirror.js",
4 "description": "Full-featured in-browser code editor",
5 "license": "MIT",
6 "directories": {
7 "lib": "./lib"
8 },
9 "scripts": {
10 "test": "node ./test/run.js",
11 "lint": "bin/lint"
12 },
13 "devDependencies": {
14 "node-static": "0.6.0",
15 "phantomjs-prebuilt": "^2.1.12",
16 "blint": ">=0.1.1"
17 },
18 "bugs": "http://github.com/codemirror/CodeMirror/issues",
19 "keywords": [
20 "JavaScript",
21 "CodeMirror",
22 "Editor"
23 ],
24 "homepage": "http://codemirror.net",
25 "maintainers": [
26 {
27 "name": "Marijn Haverbeke",
28 "email": "marijnh@gmail.com",
29 "web": "http://marijnhaverbeke.nl"
30 }
31 ],
32 "repository": {
33 "type": "git",
34 "url": "https://github.com/codemirror/CodeMirror.git"
35 },
36 "jspm": {
37 "directories": {},
38 "dependencies": {},
39 "devDependencies": {}
40 }
1941 }
7878
7979 test("indented", "javascript", function(cm) {
8080 cm.lineComment(Pos(1, 0), Pos(2), {indent: true});
81 }, simpleProg, "function foo() {\n // return bar;\n // }");
81 }, simpleProg, "function foo() {\n// return bar;\n// }");
8282
8383 test("singleEmptyLine", "javascript", function(cm) {
8484 cm.setCursor(1);
9696 test("dontMessWithStrings3", "javascript", function(cm) {
9797 cm.execCommand("toggleComment");
9898 }, "// console.log(\"// string\");", "console.log(\"// string\");");
99
100 test("includeLastLine", "javascript", function(cm) {
101 cm.execCommand("selectAll")
102 cm.execCommand("toggleComment")
103 }, "// foo\n// bar\nbaz", "// // foo\n// // bar\n// baz")
104
105 test("uncommentWithTrailingBlockEnd", "xml", function(cm) {
106 cm.execCommand("toggleComment")
107 }, "<!-- foo --> -->", "foo -->")
108
109 test("dontCommentInComment", "xml", function(cm) {
110 cm.setCursor(1, 0)
111 cm.execCommand("toggleComment")
112 }, "<!-- foo\nbar -->", "<!-- foo\nbar -->")
99113 })();
7575 }
7676 }
7777 if (!threw) {
78 if (expFail) callback("fail", test.name, message || "expected failure, but succeeded");
78 if (expFail) callback("fail", test.name, message || "expected failure, but passed");
7979 else callback("ok", test.name, message);
8080 }
8181 if (!quit) { // Run next test
1818 var code;
1919 for (var c in CodeMirror.keyNames)
2020 if (CodeMirror.keyNames[c] == key) { code = c; break; }
21 if (c == null) throw new Error("Unknown key: " + key);
21 if (code == null) throw new Error("Unknown key: " + key);
2222
2323 return eventCache[keyName] = {
2424 type: "keydown", keyCode: code, ctrlKey: ctrl, shiftKey: shift, altKey: alt,
137137 cm.triggerOnKeyDown(fakeEvent("Ctrl-S"));
138138 is(saved, "hi");
139139 }, {value: "hi", keyMap: "emacs"});
140
141 testCM("gotoInvalidLineFloat", function(cm) {
142 cm.openDialog = function(_, cb) { cb("2.2"); };
143 cm.triggerOnKeyDown(fakeEvent("Alt-G"));
144 cm.triggerOnKeyDown(fakeEvent("G"));
145 }, {value: "1\n2\n3\n4", keyMap: "emacs"});
140146 })();
77 <link rel="stylesheet" href="mode_test.css">
88 <script src="../doc/activebookmark.js"></script>
99 <script src="../lib/codemirror.js"></script>
10 <script src="../mode/meta.js"></script>
1011 <script src="../addon/mode/overlay.js"></script>
1112 <script src="../addon/mode/multiplex.js"></script>
1213 <script src="../addon/search/searchcursor.js"></script>
1415 <script src="../addon/edit/matchbrackets.js"></script>
1516 <script src="../addon/hint/sql-hint.js"></script>
1617 <script src="../addon/comment/comment.js"></script>
18 <script src="../addon/mode/simple.js"></script>
1719 <script src="../mode/css/css.js"></script>
1820 <script src="../mode/clike/clike.js"></script>
1921 <!-- clike must be after css or vim and sublime tests will fail -->
2123 <script src="../mode/haml/haml.js"></script>
2224 <script src="../mode/htmlmixed/htmlmixed.js"></script>
2325 <script src="../mode/javascript/javascript.js"></script>
26 <script src="../mode/jsx/jsx.js"></script>
2427 <script src="../mode/markdown/markdown.js"></script>
2528 <script src="../mode/php/php.js"></script>
29 <script src="../mode/python/python.js"></script>
30 <script src="../mode/powershell/powershell.js"></script>
2631 <script src="../mode/ruby/ruby.js"></script>
2732 <script src="../mode/shell/shell.js"></script>
2833 <script src="../mode/slim/slim.js"></script>
3540 <script src="../keymap/emacs.js"></script>
3641 <script src="../keymap/sublime.js"></script>
3742 <script src="../keymap/vim.js"></script>
43 <script src="../mode/rust/rust.js"></script>
44 <script src="../mode/mscgen/mscgen.js"></script>
45 <script src="../mode/dylan/dylan.js"></script>
3846
3947 <style type="text/css">
4048 .ok {color: #090;}
97105
98106 <script src="../mode/clike/test.js"></script>
99107 <script src="../mode/css/test.js"></script>
108 <script src="../mode/css/gss_test.js"></script>
100109 <script src="../mode/css/scss_test.js"></script>
101110 <script src="../mode/css/less_test.js"></script>
102111 <script src="../mode/gfm/test.js"></script>
103112 <script src="../mode/haml/test.js"></script>
104113 <script src="../mode/javascript/test.js"></script>
114 <script src="../mode/jsx/test.js"></script>
105115 <script src="../mode/markdown/test.js"></script>
106116 <script src="../mode/php/test.js"></script>
117 <script src="../mode/powershell/test.js"></script>
107118 <script src="../mode/ruby/test.js"></script>
108119 <script src="../mode/shell/test.js"></script>
109120 <script src="../mode/slim/test.js"></script>
112123 <script src="../mode/verilog/test.js"></script>
113124 <script src="../mode/xml/test.js"></script>
114125 <script src="../mode/xquery/test.js"></script>
126 <script src="../mode/python/test.js"></script>
127 <script src="../mode/rust/test.js"></script>
128 <script src="../mode/mscgen/mscgen_test.js"></script>
129 <script src="../mode/mscgen/xu_test.js"></script>
130 <script src="../mode/mscgen/msgenny_test.js"></script>
131 <script src="../mode/dylan/test.js"></script>
115132 <script src="../addon/mode/multiplex_test.js"></script>
116133 <script src="emacs_test.js"></script>
117134 <script src="sql-hint-test.js"></script>
199216 progress.style.width = (count * (progress.parentNode.clientWidth - 2) / totalTests) + "px";
200217 progressRan.nodeValue = count;
201218 if (type == "ok") {
202 message = "Test '" + name + "' succeeded";
219 message = "Test '" + name + "' passed";
203220 if (!verbose) customMessage = false;
204221 } else if (type == "skipped") {
205222 message = "Test '" + name + "' skipped";
169169 for (var i = 0; i < output.length; ++i) {
170170 var style = output[i].style, val = output[i].text;
171171 s +=
172 '<td class="mt-token"' + (i == diffAt * 2 ? " style='background: pink'" : "") + '>' +
172 '<td class="mt-token"' + (i == diffAt ? " style='background: pink'" : "") + '>' +
173173 '<span class="cm-' + esc(String(style)) + '">' +
174174 esc(val.replace(/ /g,'\xb7')) + // · MIDDLE DOT
175175 '</span>' +
1616 throw err;
1717 }).listen(3000, function () {
1818 var childProcess = require('child_process');
19 var phantomjs = require("phantomjs");
19 var phantomjs = require("phantomjs-prebuilt");
2020 var childArgs = [
2121 require("path").join(__dirname, 'phantom_driver.js')
2222 ];
1818 function barV(cm) { return byClassName(cm.getWrapperElement(), "CodeMirror-vscrollbar")[0]; }
1919
2020 function displayBottom(cm, scrollbar) {
21 if (scrollbar)
21 if (scrollbar && cm.display.scroller.offsetHeight > cm.display.scroller.clientHeight)
2222 return barH(cm).getBoundingClientRect().top;
2323 else
2424 return cm.getWrapperElement().getBoundingClientRect().bottom - 1;
2525 }
2626
2727 function displayRight(cm, scrollbar) {
28 if (scrollbar)
28 if (scrollbar && cm.display.scroller.offsetWidth > cm.display.scroller.clientWidth)
2929 return barV(cm).getBoundingClientRect().left;
3030 else
3131 return cm.getWrapperElement().getBoundingClientRect().right - 1;
101101 cm.replaceSelection("\n");
102102 is(cm.cursorCoords(null, "window").bottom < displayBottom(cm, false));
103103 }, {lineWrapping: true});
104
105 testCM("height_auto_with_gutter_expect_no_scroll_after_line_delete", function(cm) {
106 cm.setSize(null, "auto");
107 cm.setValue("x\n");
108 cm.execCommand("goDocEnd");
109 cm.execCommand("delCharBefore");
110 eq(cm.getScrollInfo().top, 0);
111 cm.scrollTo(null, 10);
112 is(cm.getScrollInfo().top < 5);
113 }, {lineNumbers: true});
104114 })();
273273 "clearBookmarks",
274274 Pos(0, 0), "selectBookmarks", at(0, 0));
275275
276 stTest("smartBackspace", " foo\n bar",
277 setSel(0, 2, 0, 2, 1, 4, 1, 4, 1, 6, 1, 6), "smartBackspace",
278 val("foo\n br"))
279
276280 stTest("upAndDowncaseAtCursor", "abc\ndef x\nghI",
277281 setSel(0, 1, 0, 3,
278282 1, 1, 1, 1,
508508 eq(cm.findMarksAt(Pos(1, 1)).length, 0);
509509 });
510510
511 testCM("findMarksMiddle", function(cm) {
512 var mark = cm.markText(Pos(1, 1), Pos(3, 1));
513 var found = cm.findMarks(Pos(2, 1), Pos(2, 2));
514 eq(found.length, 1);
515 eq(found[0], mark);
516 }, {value: "line 0\nline 1\nline 2\nline 3"});
517
511518 testCM("deleteSpanCollapsedInclusiveLeft", function(cm) {
512519 var from = Pos(1, 0), to = Pos(1, 1);
513520 var m = cm.markText(from, to, {collapsed: true, inclusiveLeft: true});
10801087 }, null, ie_lt8);
10811088
10821089 testCM("measureEndOfLine", function(cm) {
1090 if (phantom) return;
10831091 cm.setSize(null, "auto");
10841092 var inner = byClassName(cm.getWrapperElement(), "CodeMirror-lines")[0].firstChild;
10851093 var lh = inner.offsetHeight;
13271335 }, {value: "a very long line that wraps around somehow so that we can test cursor movement\nshortone\nk",
13281336 lineWrapping: true});
13291337
1338 testCM("verticalMovementCommandsSingleLine", function(cm) {
1339 cm.display.wrapper.style.height = "auto";
1340 cm.refresh();
1341 cm.execCommand("goLineUp");
1342 eqPos(cm.getCursor(), Pos(0, 0));
1343 cm.execCommand("goLineDown");
1344 eqPos(cm.getCursor(), Pos(0, 11));
1345 cm.setCursor(Pos(0, 5));
1346 cm.execCommand("goLineDown");
1347 eqPos(cm.getCursor(), Pos(0, 11));
1348 cm.execCommand("goLineDown");
1349 eqPos(cm.getCursor(), Pos(0, 11));
1350 cm.execCommand("goLineUp");
1351 eqPos(cm.getCursor(), Pos(0, 0));
1352 cm.execCommand("goLineUp");
1353 eqPos(cm.getCursor(), Pos(0, 0));
1354 cm.execCommand("goPageDown");
1355 eqPos(cm.getCursor(), Pos(0, 11));
1356 cm.execCommand("goPageDown"); cm.execCommand("goLineDown");
1357 eqPos(cm.getCursor(), Pos(0, 11));
1358 cm.execCommand("goPageUp");
1359 eqPos(cm.getCursor(), Pos(0, 0));
1360 cm.setCursor(Pos(0, 5));
1361 cm.execCommand("goPageUp");
1362 eqPos(cm.getCursor(), Pos(0, 0));
1363 cm.setCursor(Pos(0, 5));
1364 cm.execCommand("goPageDown");
1365 eqPos(cm.getCursor(), Pos(0, 11));
1366 }, {value: "single line"});
1367
1368
13301369 testCM("rtlMovement", function(cm) {
13311370 if (cm.getOption("inputStyle") != "textarea") return;
13321371 forEach(["خحج", "خحabcخحج", "abخحخحجcd", "abخde", "abخح2342خ1حج", "خ1ح2خح3حxج",
14781517 // Good:
14791518 // | ------------- display width ------------- |
14801519 // | ------- widget-width when measured ------ |
1481 // | | -- under-half -- | | -- under-half -- | |
1520 // | | -- under-half -- | | -- under-half -- | |
14821521 // | | --- over-half --- | |
14831522 // | | --- over-half --- | |
14841523 // Height: measured as 3 lines, same as it will be when actually displayed
14951534 // Bad (too wide):
14961535 // | ------------- display width ------------- |
14971536 // | -------- widget-width when measured ------- | < -- uh oh
1498 // | | -- under-half -- | | -- under-half -- | |
1537 // | | -- under-half -- | | -- under-half -- | |
14991538 // | | --- over-half --- | | --- over-half --- | | < -- when measured, combined on one line
15001539 // Height: measured as 2 lines, less than expected. Will be displayed as 3 lines!
15011540
15821621 eq(byClassName(lines, "foo").length, 2);
15831622 eq(byClassName(lines, "bar").length, 1);
15841623 eq(byClassName(lines, "baz").length, 1);
1585 eq(byClassName(lines, "gutter-class").length, 1);
1624 eq(byClassName(lines, "gutter-class").length, 2); // Gutter classes are reflected in 2 nodes
15861625 cm.removeLineClass(0, "text", "foo");
15871626 cls(0, "bar", null, null, null);
15881627 cm.removeLineClass(0, "text", "foo");
16561695 testCM("selectionBias", function(cm) {
16571696 cm.markText(Pos(0, 1), Pos(0, 3), {atomic: true});
16581697 cm.setCursor(Pos(0, 2));
1698 eqPos(cm.getCursor(), Pos(0, 1));
1699 cm.setCursor(Pos(0, 2));
16591700 eqPos(cm.getCursor(), Pos(0, 3));
16601701 cm.setCursor(Pos(0, 2));
16611702 eqPos(cm.getCursor(), Pos(0, 1));
21242165 CodeMirror.addClass(node, "b");
21252166 eq(node.className, "a b");
21262167 });
2168
2169 testCM("lineSeparator", function(cm) {
2170 eq(cm.lineCount(), 3);
2171 eq(cm.getLine(1), "bar\r");
2172 eq(cm.getLine(2), "baz\rquux");
2173 cm.setOption("lineSeparator", "\r");
2174 eq(cm.lineCount(), 5);
2175 eq(cm.getLine(4), "quux");
2176 eq(cm.getValue(), "foo\rbar\r\rbaz\rquux");
2177 eq(cm.getValue("\n"), "foo\nbar\n\nbaz\nquux");
2178 cm.setOption("lineSeparator", null);
2179 cm.setValue("foo\nbar\r\nbaz\rquux");
2180 eq(cm.lineCount(), 4);
2181 }, {value: "foo\nbar\r\nbaz\rquux",
2182 lineSeparator: "\n"});
126126 arguments = args;
127127 }
128128 for (var i = 0; i < arguments.length; i++) {
129 CodeMirror.Vim.handleKey(cm, arguments[i]);
129 var result = CodeMirror.Vim.handleKey(cm, arguments[i]);
130 if (!result && cm.state.vim.insertMode) {
131 cm.replaceSelections(fillArray(arguments[i], cm.listSelections().length));
132 }
130133 }
131134 }
132135 }
144147 for (var i = 0; i < arguments.length; i++) {
145148 var key = arguments[i];
146149 // Find key in keymap and handle.
147 var handled = CodeMirror.lookupKey(key, 'vim-insert', executeHandler);
150 var handled = CodeMirror.lookupKey(key, cm.getOption('keyMap'), executeHandler, cm);
148151 // Record for insert mode.
149152 if (handled == "handled" && cm.state.vim.insertMode && arguments[i] != 'Esc') {
150153 var lastChange = CodeMirror.Vim.getVimGlobalState_().macroModeState.lastInsertModeChanges;
151 if (lastChange) {
154 if (lastChange && (key.indexOf('Delete') != -1 || key.indexOf('Backspace') != -1)) {
152155 lastChange.changes.push(new CodeMirror.Vim.InsertModeKey(key));
153156 }
154157 }
272275 testJumplist('jumplist_repeated_motion', ['3', '*', '<C-o>'], [2,3], [2,3]);
273276 testJumplist('jumplist_/', ['/', '<C-o>'], [2,3], [2,3], 'dialog');
274277 testJumplist('jumplist_?', ['?', '<C-o>'], [2,3], [2,3], 'dialog');
275 testJumplist('jumplist_skip_delted_mark<c-o>',
278 testJumplist('jumplist_skip_deleted_mark<c-o>',
276279 ['*', 'n', 'n', 'k', 'd', 'k', '<C-o>', '<C-o>', '<C-o>'],
277280 [0,2], [0,2]);
278 testJumplist('jumplist_skip_delted_mark<c-i>',
281 testJumplist('jumplist_skip_deleted_mark<c-i>',
279282 ['*', 'n', 'n', 'k', 'd', 'k', '<C-o>', '<C-i>', '<C-i>'],
280283 [1,0], [0,2]);
281284
389392 helpers.doKeys(['%']);
390393 helpers.assertCursorAt(0,0);
391394 }, {value:'(")")'});
392 (')')
393395 testVim('%_skip_comment', function(cm, vim, helpers) {
394396 cm.setCursor(0,0);
395397 helpers.doKeys(['%']);
482484 var topLeftCharCoords = cm.charCoords(makeCursor(0, 0));
483485 var endingCharCoords = cm.charCoords(endingPos);
484486 is(topLeftCharCoords.left == endingCharCoords.left, 'gj should end up on column 0');
485 },{ lineNumbers: false, lineWrapping:true, value: 'Thislineisintentiallylongtotestmovementofgjandgkoverwrappedlines.' });
487 },{ lineNumbers: false, lineWrapping:true, value: 'Thislineisintentionallylongtotestmovementofgjandgkoverwrappedlines.' });
486488 testVim('}', function(cm, vim, helpers) {
487489 cm.setCursor(0, 0);
488490 helpers.doKeys('}');
634636 var curStart = makeCursor(0, 3);
635637 cm.setCursor(curStart);
636638 helpers.doKeys('d', 'j');
637 eq(' word1 ', cm.getValue());
639 eq('', cm.getValue());
638640 var register = helpers.getRegisterController().getRegister();
639 eq('', register.toString());
640 is(!register.linewise);
641 helpers.assertCursorAt(0, 3);
641 eq(' word1 \n', register.toString());
642 is(register.linewise);
643 helpers.assertCursorAt(0, 0);
642644 }, { value: ' word1 ' });
643645 testVim('dk', function(cm, vim, helpers) {
644646 var curStart = makeCursor(1, 3);
654656 var curStart = makeCursor(0, 3);
655657 cm.setCursor(curStart);
656658 helpers.doKeys('d', 'k');
657 eq(' word1 ', cm.getValue());
659 eq('', cm.getValue());
658660 var register = helpers.getRegisterController().getRegister();
659 eq('', register.toString());
660 is(!register.linewise);
661 helpers.assertCursorAt(0, 3);
661 eq(' word1 \n', register.toString());
662 is(register.linewise);
663 helpers.assertCursorAt(0, 0);
662664 }, { value: ' word1 ' });
663665 testVim('dw_space', function(cm, vim, helpers) {
664666 var curStart = makeCursor(0, 0);
10441046 helpers.doKeys('<C-v>', '2', 'j', 'l', 'D');
10451047 eq('1\n5\na', cm.getValue());
10461048 }, {value: '1234\n5678\nabcdefg'});
1049
1050 testVim('s_visual_block', function(cm, vim, helpers) {
1051 cm.setCursor(0, 1);
1052 helpers.doKeys('<C-v>', '2', 'j', 'l', 'l', 'l', 's');
1053 var replacement = fillArray('hello{', 3);
1054 cm.replaceSelections(replacement);
1055 eq('1hello{\n5hello{\nahello{fg\n', cm.getValue());
1056 helpers.doKeys('<Esc>');
1057 cm.setCursor(2, 3);
1058 helpers.doKeys('<C-v>', '1', 'k', 'h', 'S');
1059 replacement = fillArray('world', 1);
1060 cm.replaceSelections(replacement);
1061 eq('1hello{\n world\n', cm.getValue());
1062 }, {value: '1234\n5678\nabcdefg\n'});
10471063
10481064 // Swapcase commands edit in place and do not modify registers.
10491065 testVim('g~w_repeat', function(cm, vim, helpers) {
14051421 eq('abe', cm.getValue());
14061422 helpers.assertCursorAt(0, 1);
14071423 }, { value: 'abcde' });
1424 testVim('insert', function(cm, vim, helpers) {
1425 helpers.doKeys('i');
1426 eq('vim-insert', cm.getOption('keyMap'));
1427 eq(false, cm.state.overwrite);
1428 helpers.doKeys('<Ins>');
1429 eq('vim-replace', cm.getOption('keyMap'));
1430 eq(true, cm.state.overwrite);
1431 helpers.doKeys('<Ins>');
1432 eq('vim-insert', cm.getOption('keyMap'));
1433 eq(false, cm.state.overwrite);
1434 });
1435 testVim('i_backspace', function(cm, vim, helpers) {
1436 cm.setCursor(0, 10);
1437 helpers.doKeys('i');
1438 helpers.doInsertModeKeys('Backspace');
1439 helpers.assertCursorAt(0, 9);
1440 eq('012345678', cm.getValue());
1441 }, { value: '0123456789'});
1442 testVim('i_overwrite_backspace', function(cm, vim, helpers) {
1443 cm.setCursor(0, 10);
1444 helpers.doKeys('i');
1445 helpers.doKeys('<Ins>');
1446 helpers.doInsertModeKeys('Backspace');
1447 helpers.assertCursorAt(0, 9);
1448 eq('0123456789', cm.getValue());
1449 }, { value: '0123456789'});
14081450 testVim('A', function(cm, vim, helpers) {
14091451 helpers.doKeys('A');
14101452 helpers.assertCursorAt(0, lines[0].length);
19401982 cm.setCursor(1, 1);
19411983 // blockwise to characterwise visual
19421984 helpers.doKeys('<C-v>', 'j', 'l', 'v');
1943 selections = cm.getSelections();
1985 var selections = cm.getSelections();
19441986 eq('7891\nabc', selections.join(''));
19451987 // characterwise to blockwise
19461988 helpers.doKeys('<C-v>');
21482190 cm.setCursor(0, 1);
21492191 helpers.doKeys('j', 'S');
21502192 helpers.doKeys('<Esc>');
2151 helpers.assertCursorAt(1, 0);
2152 eq('aa\n\ncc', cm.getValue());
2153 }, { value: 'aa\nbb\ncc'});
2193 helpers.assertCursorAt(1, 1);
2194 eq('aa{\n \ncc', cm.getValue());
2195 helpers.doKeys('j', 'S');
2196 eq('aa{\n \n ', cm.getValue());
2197 helpers.assertCursorAt(2, 2);
2198 helpers.doKeys('<Esc>');
2199 helpers.doKeys('d', 'd', 'd', 'd');
2200 helpers.assertCursorAt(0, 0);
2201 helpers.doKeys('S');
2202 is(vim.insertMode);
2203 eq('', cm.getValue());
2204 }, { value: 'aa{\nbb\ncc'});
21542205 testVim('blockwise_paste', function(cm, vim, helpers) {
21552206 cm.setCursor(0, 0);
21562207 helpers.doKeys('<C-v>', '3', 'j', 'l', 'y');
27922843 helpers.doKeys('.');
27932844 eq('testestt', cm.getValue());
27942845 helpers.assertCursorAt(0, 6);
2846 helpers.doKeys('O');
2847 cm.replaceRange('xyz', cm.getCursor());
2848 helpers.doInsertModeKeys('Backspace');
2849 helpers.doInsertModeKeys('Down');
2850 helpers.doKeys('<Esc>');
2851 helpers.doKeys('.');
2852 eq('xy\nxy\ntestestt', cm.getValue());
2853 helpers.assertCursorAt(1, 1);
27952854 }, { value: ''});
27962855 testVim('._insert_repeat', function(cm, vim, helpers) {
27972856 helpers.doKeys('i');
31103169 return new Array(500).join('\n');
31113170 })()});
31123171 });
3172 testVim('zb_to_bottom', function(cm, vim, helpers){
3173 var lineNum = 250;
3174 cm.setSize(600, 35*cm.defaultTextHeight());
3175 cm.setCursor(lineNum, 0);
3176 helpers.doKeys('z', 'b');
3177 var scrollInfo = cm.getScrollInfo();
3178 eq(scrollInfo.top + scrollInfo.clientHeight, cm.charCoords(Pos(lineNum, 0), 'local').bottom);
3179 }, { value: (function(){
3180 return new Array(500).join('\n');
3181 })()});
3182 testVim('zt_to_top', function(cm, vim, helpers){
3183 var lineNum = 250;
3184 cm.setSize(600, 35*cm.defaultTextHeight());
3185 cm.setCursor(lineNum, 0);
3186 helpers.doKeys('z', 't');
3187 eq(cm.getScrollInfo().top, cm.charCoords(Pos(lineNum, 0), 'local').top);
3188 }, { value: (function(){
3189 return new Array(500).join('\n');
3190 })()});
31133191 testVim('zb<zz', function(cm, vim, helpers){
31143192 eq(zVals[0]<zVals[1], true);
31153193 });
31273205 });
31283206
31293207 var moveTillCharacterSandbox =
3130 'The quick brown fox \n'
3131 'jumped over the lazy dog.'
3208 'The quick brown fox \n';
31323209 testVim('moveTillCharacter', function(cm, vim, helpers){
31333210 cm.setCursor(0, 0);
31343211 // Search for the 'q'.
31753252
31763253
31773254 var scrollMotionSandbox =
3178 '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
3179 '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
3180 '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
31813255 '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';
31823256 testVim('scrollMotion', function(cm, vim, helpers){
31833257 var prevCursor, prevScrollInfo;
33963470 helpers.doEx('sort! d');
33973471 eq('a3\nb2\nc1\nz\ny', cm.getValue());
33983472 }, { value: 'a3\nz\nc1\ny\nb2'});
3473 testVim('ex_sort_patterns_not_supported', function(cm, vim, helpers) {
3474 var notified = false;
3475 cm.openNotification = helpers.fakeOpenNotification(function(text) {
3476 notified = /patterns not supported/.test(text);
3477 });
3478 helpers.doEx('sort /abc/');
3479 is(notified, 'No notification.');
3480 });
33993481 // test for :global command
34003482 testVim('ex_global', function(cm, vim, helpers) {
34013483 cm.setCursor(0, 0);
36363718 } catch(e) {
36373719 throw e
36383720 } finally {
3639 // Restore overriden functions.
3721 // Restore overridden functions.
36403722 CodeMirror.keyName = savedKeyName;
36413723 cm.openDialog = savedOpenDialog;
36423724 }
36793761 helpers.doKeys('n');
36803762 helpers.assertCursorAt(0, 11,'can\'t resume search after clearing highlighting');
36813763 }, { value: 'match nope match \n nope Match' });
3764 testVim('ex_yank', function (cm, vim, helpers) {
3765 var curStart = makeCursor(3, 0);
3766 cm.setCursor(curStart);
3767 helpers.doEx('y');
3768 var register = helpers.getRegisterController().getRegister();
3769 var line = cm.getLine(3);
3770 eq(line + '\n', register.toString());
3771 });
36823772 testVim('set_boolean', function(cm, vim, helpers) {
36833773 CodeMirror.Vim.defineOption('testoption', true, 'boolean');
36843774 // Test default value is set.
36873777 // Test fail to set to non-boolean
36883778 CodeMirror.Vim.setOption('testoption', '5');
36893779 fail();
3690 } catch (expected) {};
3780 } catch (expected) {}
36913781 // Test setOption
36923782 CodeMirror.Vim.setOption('testoption', false);
36933783 is(!CodeMirror.Vim.getOption('testoption'));
37003790 // Test fail to set to non-boolean
37013791 helpers.doEx('set testoption=22');
37023792 fail();
3703 } catch (expected) {};
3793 } catch (expected) {}
37043794 // Test setOption
37053795 helpers.doEx('set notestoption');
37063796 is(!CodeMirror.Vim.getOption('testoption'));
37133803 // Test fail to set non-string.
37143804 CodeMirror.Vim.setOption('testoption', true);
37153805 fail();
3716 } catch (expected) {};
3806 } catch (expected) {}
37173807 try {
37183808 // Test fail to set 'notestoption'
37193809 CodeMirror.Vim.setOption('notestoption', 'b');
37203810 fail();
3721 } catch (expected) {};
3811 } catch (expected) {}
37223812 // Test setOption
37233813 CodeMirror.Vim.setOption('testoption', 'c');
37243814 eq('c', CodeMirror.Vim.getOption('testoption'));
37313821 // Test fail to set 'notestopt'
37323822 helpers.doEx('set notestopt=b');
37333823 fail();
3734 } catch (expected) {};
3824 } catch (expected) {}
37353825 // Test setOption
37363826 helpers.doEx('set testopt=c')
37373827 eq('c', CodeMirror.Vim.getOption('testopt'));
37813871 // Test fail to set 'notestopt'
37823872 helpers.doEx('set notestopt=b');
37833873 fail();
3784 } catch (expected) {};
3874 } catch (expected) {}
37853875 // Test setOption (Identical to the string tests, but via callback instead)
37863876 helpers.doEx('set testopt=c')
37873877 eq('c', CodeMirror.Vim.getOption('testopt', cm)); //local || global
39184008 is(vim.insertMode);
39194009 helpers.doKeys('j', 'k');
39204010 is(!vim.insertMode);
3921 })
4011 cm.setCursor(0, 1);
4012 CodeMirror.Vim.map('jj', '<Esc>', 'insert');
4013 helpers.doKeys('<C-v>', '2', 'j', 'l', 'c');
4014 var replacement = fillArray('fo', 3);
4015 cm.replaceSelections(replacement);
4016 eq('1fo4\n5fo8\nafodefg', cm.getValue());
4017 helpers.doKeys('j', 'j');
4018 cm.setCursor(0, 0);
4019 helpers.doKeys('.');
4020 eq('foo4\nfoo8\nfoodefg', cm.getValue());
4021 }, { value: '1234\n5678\nabcdefg' });
4022 testVim('ex_unmap_api', function(cm, vim, helpers) {
4023 CodeMirror.Vim.map('<Alt-X>', 'gg', 'normal');
4024 is(CodeMirror.Vim.handleKey(cm, "<Alt-X>", "normal"), "Alt-X key is mapped");
4025 CodeMirror.Vim.unmap("<Alt-X>", "normal");
4026 is(!CodeMirror.Vim.handleKey(cm, "<Alt-X>", "normal"), "Alt-X key is unmapped");
4027 });
39224028
39234029 // Testing registration of functions as ex-commands and mapping to <Key>-keys
39244030 testVim('ex_api_test', function(cm, vim, helpers) {
77
88 */
99
10 .cm-s-3024-day.CodeMirror {background: #f7f7f7; color: #3a3432;}
11 .cm-s-3024-day div.CodeMirror-selected {background: #d6d5d4 !important;}
12 .cm-s-3024-day.CodeMirror ::selection { background: #d6d5d4; }
13 .cm-s-3024-day.CodeMirror ::-moz-selection { background: #d9d9d9; }
10 .cm-s-3024-day.CodeMirror { background: #f7f7f7; color: #3a3432; }
11 .cm-s-3024-day div.CodeMirror-selected { background: #d6d5d4; }
1412
15 .cm-s-3024-day .CodeMirror-gutters {background: #f7f7f7; border-right: 0px;}
13 .cm-s-3024-day .CodeMirror-line::selection, .cm-s-3024-day .CodeMirror-line > span::selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d6d5d4; }
14 .cm-s-3024-day .CodeMirror-line::-moz-selection, .cm-s-3024-day .CodeMirror-line > span::-moz-selection, .cm-s-3024-day .CodeMirror-line > span > span::selection { background: #d9d9d9; }
15
16 .cm-s-3024-day .CodeMirror-gutters { background: #f7f7f7; border-right: 0px; }
1617 .cm-s-3024-day .CodeMirror-guttermarker { color: #db2d20; }
1718 .cm-s-3024-day .CodeMirror-guttermarker-subtle { color: #807d7c; }
18 .cm-s-3024-day .CodeMirror-linenumber {color: #807d7c;}
19 .cm-s-3024-day .CodeMirror-linenumber { color: #807d7c; }
1920
20 .cm-s-3024-day .CodeMirror-cursor {border-left: 1px solid #5c5855 !important;}
21 .cm-s-3024-day .CodeMirror-cursor { border-left: 1px solid #5c5855; }
2122
22 .cm-s-3024-day span.cm-comment {color: #cdab53;}
23 .cm-s-3024-day span.cm-atom {color: #a16a94;}
24 .cm-s-3024-day span.cm-number {color: #a16a94;}
23 .cm-s-3024-day span.cm-comment { color: #cdab53; }
24 .cm-s-3024-day span.cm-atom { color: #a16a94; }
25 .cm-s-3024-day span.cm-number { color: #a16a94; }
2526
26 .cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute {color: #01a252;}
27 .cm-s-3024-day span.cm-keyword {color: #db2d20;}
28 .cm-s-3024-day span.cm-string {color: #fded02;}
27 .cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute { color: #01a252; }
28 .cm-s-3024-day span.cm-keyword { color: #db2d20; }
29 .cm-s-3024-day span.cm-string { color: #fded02; }
2930
30 .cm-s-3024-day span.cm-variable {color: #01a252;}
31 .cm-s-3024-day span.cm-variable-2 {color: #01a0e4;}
32 .cm-s-3024-day span.cm-def {color: #e8bbd0;}
33 .cm-s-3024-day span.cm-bracket {color: #3a3432;}
34 .cm-s-3024-day span.cm-tag {color: #db2d20;}
35 .cm-s-3024-day span.cm-link {color: #a16a94;}
36 .cm-s-3024-day span.cm-error {background: #db2d20; color: #5c5855;}
31 .cm-s-3024-day span.cm-variable { color: #01a252; }
32 .cm-s-3024-day span.cm-variable-2 { color: #01a0e4; }
33 .cm-s-3024-day span.cm-def { color: #e8bbd0; }
34 .cm-s-3024-day span.cm-bracket { color: #3a3432; }
35 .cm-s-3024-day span.cm-tag { color: #db2d20; }
36 .cm-s-3024-day span.cm-link { color: #a16a94; }
37 .cm-s-3024-day span.cm-error { background: #db2d20; color: #5c5855; }
3738
38 .cm-s-3024-day .CodeMirror-activeline-background {background: #e8f2ff !important;}
39 .cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: #a16a94 !important;}
39 .cm-s-3024-day .CodeMirror-activeline-background { background: #e8f2ff; }
40 .cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: #a16a94 !important; }
77
88 */
99
10 .cm-s-3024-night.CodeMirror {background: #090300; color: #d6d5d4;}
11 .cm-s-3024-night div.CodeMirror-selected {background: #3a3432 !important;}
12 .cm-s-3024-night.CodeMirror ::selection { background: rgba(58, 52, 50, .99); }
13 .cm-s-3024-night.CodeMirror ::-moz-selection { background: rgba(58, 52, 50, .99); }
14 .cm-s-3024-night .CodeMirror-gutters {background: #090300; border-right: 0px;}
10 .cm-s-3024-night.CodeMirror { background: #090300; color: #d6d5d4; }
11 .cm-s-3024-night div.CodeMirror-selected { background: #3a3432; }
12 .cm-s-3024-night .CodeMirror-line::selection, .cm-s-3024-night .CodeMirror-line > span::selection, .cm-s-3024-night .CodeMirror-line > span > span::selection { background: rgba(58, 52, 50, .99); }
13 .cm-s-3024-night .CodeMirror-line::-moz-selection, .cm-s-3024-night .CodeMirror-line > span::-moz-selection, .cm-s-3024-night .CodeMirror-line > span > span::-moz-selection { background: rgba(58, 52, 50, .99); }
14 .cm-s-3024-night .CodeMirror-gutters { background: #090300; border-right: 0px; }
1515 .cm-s-3024-night .CodeMirror-guttermarker { color: #db2d20; }
1616 .cm-s-3024-night .CodeMirror-guttermarker-subtle { color: #5c5855; }
17 .cm-s-3024-night .CodeMirror-linenumber {color: #5c5855;}
17 .cm-s-3024-night .CodeMirror-linenumber { color: #5c5855; }
1818
19 .cm-s-3024-night .CodeMirror-cursor {border-left: 1px solid #807d7c !important;}
19 .cm-s-3024-night .CodeMirror-cursor { border-left: 1px solid #807d7c; }
2020
21 .cm-s-3024-night span.cm-comment {color: #cdab53;}
22 .cm-s-3024-night span.cm-atom {color: #a16a94;}
23 .cm-s-3024-night span.cm-number {color: #a16a94;}
21 .cm-s-3024-night span.cm-comment { color: #cdab53; }
22 .cm-s-3024-night span.cm-atom { color: #a16a94; }
23 .cm-s-3024-night span.cm-number { color: #a16a94; }
2424
25 .cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute {color: #01a252;}
26 .cm-s-3024-night span.cm-keyword {color: #db2d20;}
27 .cm-s-3024-night span.cm-string {color: #fded02;}
25 .cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute { color: #01a252; }
26 .cm-s-3024-night span.cm-keyword { color: #db2d20; }
27 .cm-s-3024-night span.cm-string { color: #fded02; }
2828
29 .cm-s-3024-night span.cm-variable {color: #01a252;}
30 .cm-s-3024-night span.cm-variable-2 {color: #01a0e4;}
31 .cm-s-3024-night span.cm-def {color: #e8bbd0;}
32 .cm-s-3024-night span.cm-bracket {color: #d6d5d4;}
33 .cm-s-3024-night span.cm-tag {color: #db2d20;}
34 .cm-s-3024-night span.cm-link {color: #a16a94;}
35 .cm-s-3024-night span.cm-error {background: #db2d20; color: #807d7c;}
29 .cm-s-3024-night span.cm-variable { color: #01a252; }
30 .cm-s-3024-night span.cm-variable-2 { color: #01a0e4; }
31 .cm-s-3024-night span.cm-def { color: #e8bbd0; }
32 .cm-s-3024-night span.cm-bracket { color: #d6d5d4; }
33 .cm-s-3024-night span.cm-tag { color: #db2d20; }
34 .cm-s-3024-night span.cm-link { color: #a16a94; }
35 .cm-s-3024-night span.cm-error { background: #db2d20; color: #807d7c; }
3636
37 .cm-s-3024-night .CodeMirror-activeline-background {background: #2F2F2F !important;}
38 .cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
37 .cm-s-3024-night .CodeMirror-activeline-background { background: #2F2F2F; }
38 .cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
0 .cm-s-abcdef.CodeMirror { background: #0f0f0f; color: #defdef; }
1 .cm-s-abcdef div.CodeMirror-selected { background: #515151; }
2 .cm-s-abcdef .CodeMirror-line::selection, .cm-s-abcdef .CodeMirror-line > span::selection, .cm-s-abcdef .CodeMirror-line > span > span::selection { background: rgba(56, 56, 56, 0.99); }
3 .cm-s-abcdef .CodeMirror-line::-moz-selection, .cm-s-abcdef .CodeMirror-line > span::-moz-selection, .cm-s-abcdef .CodeMirror-line > span > span::-moz-selection { background: rgba(56, 56, 56, 0.99); }
4 .cm-s-abcdef .CodeMirror-gutters { background: #555; border-right: 2px solid #314151; }
5 .cm-s-abcdef .CodeMirror-guttermarker { color: #222; }
6 .cm-s-abcdef .CodeMirror-guttermarker-subtle { color: azure; }
7 .cm-s-abcdef .CodeMirror-linenumber { color: #FFFFFF; }
8 .cm-s-abcdef .CodeMirror-cursor { border-left: 1px solid #00FF00; }
9
10 .cm-s-abcdef span.cm-keyword { color: darkgoldenrod; font-weight: bold; }
11 .cm-s-abcdef span.cm-atom { color: #77F; }
12 .cm-s-abcdef span.cm-number { color: violet; }
13 .cm-s-abcdef span.cm-def { color: #fffabc; }
14 .cm-s-abcdef span.cm-variable { color: #abcdef; }
15 .cm-s-abcdef span.cm-variable-2 { color: #cacbcc; }
16 .cm-s-abcdef span.cm-variable-3 { color: #def; }
17 .cm-s-abcdef span.cm-property { color: #fedcba; }
18 .cm-s-abcdef span.cm-operator { color: #ff0; }
19 .cm-s-abcdef span.cm-comment { color: #7a7b7c; font-style: italic;}
20 .cm-s-abcdef span.cm-string { color: #2b4; }
21 .cm-s-abcdef span.cm-meta { color: #C9F; }
22 .cm-s-abcdef span.cm-qualifier { color: #FFF700; }
23 .cm-s-abcdef span.cm-builtin { color: #30aabc; }
24 .cm-s-abcdef span.cm-bracket { color: #8a8a8a; }
25 .cm-s-abcdef span.cm-tag { color: #FFDD44; }
26 .cm-s-abcdef span.cm-attribute { color: #DDFF00; }
27 .cm-s-abcdef span.cm-error { color: #FF0000; }
28 .cm-s-abcdef span.cm-header { color: aquamarine; font-weight: bold; }
29 .cm-s-abcdef span.cm-link { color: blueviolet; }
30
31 .cm-s-abcdef .CodeMirror-activeline-background { background: #314151; }
11
22 /* Color scheme */
33
4 .cm-s-ambiance .cm-header {color: blue;}
4 .cm-s-ambiance .cm-header { color: blue; }
55 .cm-s-ambiance .cm-quote { color: #24C2C7; }
66
77 .cm-s-ambiance .cm-keyword { color: #cda869; }
1212 .cm-s-ambiance .cm-variable-2 { color: #eed1b3; }
1313 .cm-s-ambiance .cm-variable-3 { color: #faded3; }
1414 .cm-s-ambiance .cm-property { color: #eed1b3; }
15 .cm-s-ambiance .cm-operator {color: #fa8d6a;}
15 .cm-s-ambiance .cm-operator { color: #fa8d6a; }
1616 .cm-s-ambiance .cm-comment { color: #555; font-style:italic; }
1717 .cm-s-ambiance .cm-string { color: #8f9d6a; }
1818 .cm-s-ambiance .cm-string-2 { color: #9d937c; }
2020 .cm-s-ambiance .cm-qualifier { color: yellow; }
2121 .cm-s-ambiance .cm-builtin { color: #9999cc; }
2222 .cm-s-ambiance .cm-bracket { color: #24C2C7; }
23 .cm-s-ambiance .cm-tag { color: #fee4ff }
24 .cm-s-ambiance .cm-attribute { color: #9B859D; }
23 .cm-s-ambiance .cm-tag { color: #fee4ff; }
24 .cm-s-ambiance .cm-attribute { color: #9B859D; }
2525 .cm-s-ambiance .cm-hr { color: pink; }
2626 .cm-s-ambiance .cm-link { color: #F4C20B; }
2727 .cm-s-ambiance .cm-special { color: #FF9D00; }
3030 .cm-s-ambiance .CodeMirror-matchingbracket { color: #0f0; }
3131 .cm-s-ambiance .CodeMirror-nonmatchingbracket { color: #f22; }
3232
33 .cm-s-ambiance .CodeMirror-selected { background: rgba(255, 255, 255, 0.15); }
34 .cm-s-ambiance.CodeMirror-focused .CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
35 .cm-s-ambiance.CodeMirror ::selection { background: rgba(255, 255, 255, 0.10); }
36 .cm-s-ambiance.CodeMirror ::-moz-selection { background: rgba(255, 255, 255, 0.10); }
33 .cm-s-ambiance div.CodeMirror-selected { background: rgba(255, 255, 255, 0.15); }
34 .cm-s-ambiance.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
35 .cm-s-ambiance .CodeMirror-line::selection, .cm-s-ambiance .CodeMirror-line > span::selection, .cm-s-ambiance .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
36 .cm-s-ambiance .CodeMirror-line::-moz-selection, .cm-s-ambiance .CodeMirror-line > span::-moz-selection, .cm-s-ambiance .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
3737
3838 /* Editor styling */
3939
6161 .cm-s-ambiance .CodeMirror-guttermarker { color: #aaa; }
6262 .cm-s-ambiance .CodeMirror-guttermarker-subtle { color: #111; }
6363
64 .cm-s-ambiance .CodeMirror-lines .CodeMirror-cursor {
65 border-left: 1px solid #7991E8;
66 }
64 .cm-s-ambiance .CodeMirror-cursor { border-left: 1px solid #7991E8; }
6765
6866 .cm-s-ambiance .CodeMirror-activeline-background {
6967 background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.031);
22 Name: Base16 Default Dark
33 Author: Chris Kempson (http://chriskempson.com)
44
5 CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
5 CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
66 Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
77
88 */
99
10 .cm-s-base16-dark.CodeMirror {background: #151515; color: #e0e0e0;}
11 .cm-s-base16-dark div.CodeMirror-selected {background: #303030 !important;}
12 .cm-s-base16-dark.CodeMirror ::selection { background: rgba(48, 48, 48, .99); }
13 .cm-s-base16-dark.CodeMirror ::-moz-selection { background: rgba(48, 48, 48, .99); }
14 .cm-s-base16-dark .CodeMirror-gutters {background: #151515; border-right: 0px;}
10 .cm-s-base16-dark.CodeMirror { background: #151515; color: #e0e0e0; }
11 .cm-s-base16-dark div.CodeMirror-selected { background: #303030; }
12 .cm-s-base16-dark .CodeMirror-line::selection, .cm-s-base16-dark .CodeMirror-line > span::selection, .cm-s-base16-dark .CodeMirror-line > span > span::selection { background: rgba(48, 48, 48, .99); }
13 .cm-s-base16-dark .CodeMirror-line::-moz-selection, .cm-s-base16-dark .CodeMirror-line > span::-moz-selection, .cm-s-base16-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(48, 48, 48, .99); }
14 .cm-s-base16-dark .CodeMirror-gutters { background: #151515; border-right: 0px; }
1515 .cm-s-base16-dark .CodeMirror-guttermarker { color: #ac4142; }
1616 .cm-s-base16-dark .CodeMirror-guttermarker-subtle { color: #505050; }
17 .cm-s-base16-dark .CodeMirror-linenumber {color: #505050;}
18 .cm-s-base16-dark .CodeMirror-cursor {border-left: 1px solid #b0b0b0 !important;}
17 .cm-s-base16-dark .CodeMirror-linenumber { color: #505050; }
18 .cm-s-base16-dark .CodeMirror-cursor { border-left: 1px solid #b0b0b0; }
1919
20 .cm-s-base16-dark span.cm-comment {color: #8f5536;}
21 .cm-s-base16-dark span.cm-atom {color: #aa759f;}
22 .cm-s-base16-dark span.cm-number {color: #aa759f;}
20 .cm-s-base16-dark span.cm-comment { color: #8f5536; }
21 .cm-s-base16-dark span.cm-atom { color: #aa759f; }
22 .cm-s-base16-dark span.cm-number { color: #aa759f; }
2323
24 .cm-s-base16-dark span.cm-property, .cm-s-base16-dark span.cm-attribute {color: #90a959;}
25 .cm-s-base16-dark span.cm-keyword {color: #ac4142;}
26 .cm-s-base16-dark span.cm-string {color: #f4bf75;}
24 .cm-s-base16-dark span.cm-property, .cm-s-base16-dark span.cm-attribute { color: #90a959; }
25 .cm-s-base16-dark span.cm-keyword { color: #ac4142; }
26 .cm-s-base16-dark span.cm-string { color: #f4bf75; }
2727
28 .cm-s-base16-dark span.cm-variable {color: #90a959;}
29 .cm-s-base16-dark span.cm-variable-2 {color: #6a9fb5;}
30 .cm-s-base16-dark span.cm-def {color: #d28445;}
31 .cm-s-base16-dark span.cm-bracket {color: #e0e0e0;}
32 .cm-s-base16-dark span.cm-tag {color: #ac4142;}
33 .cm-s-base16-dark span.cm-link {color: #aa759f;}
34 .cm-s-base16-dark span.cm-error {background: #ac4142; color: #b0b0b0;}
28 .cm-s-base16-dark span.cm-variable { color: #90a959; }
29 .cm-s-base16-dark span.cm-variable-2 { color: #6a9fb5; }
30 .cm-s-base16-dark span.cm-def { color: #d28445; }
31 .cm-s-base16-dark span.cm-bracket { color: #e0e0e0; }
32 .cm-s-base16-dark span.cm-tag { color: #ac4142; }
33 .cm-s-base16-dark span.cm-link { color: #aa759f; }
34 .cm-s-base16-dark span.cm-error { background: #ac4142; color: #b0b0b0; }
3535
36 .cm-s-base16-dark .CodeMirror-activeline-background {background: #202020 !important;}
37 .cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
36 .cm-s-base16-dark .CodeMirror-activeline-background { background: #202020; }
37 .cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
22 Name: Base16 Default Light
33 Author: Chris Kempson (http://chriskempson.com)
44
5 CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
5 CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
66 Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
77
88 */
99
10 .cm-s-base16-light.CodeMirror {background: #f5f5f5; color: #202020;}
11 .cm-s-base16-light div.CodeMirror-selected {background: #e0e0e0 !important;}
12 .cm-s-base16-light.CodeMirror ::selection { background: #e0e0e0; }
13 .cm-s-base16-light.CodeMirror ::-moz-selection { background: #e0e0e0; }
14 .cm-s-base16-light .CodeMirror-gutters {background: #f5f5f5; border-right: 0px;}
10 .cm-s-base16-light.CodeMirror { background: #f5f5f5; color: #202020; }
11 .cm-s-base16-light div.CodeMirror-selected { background: #e0e0e0; }
12 .cm-s-base16-light .CodeMirror-line::selection, .cm-s-base16-light .CodeMirror-line > span::selection, .cm-s-base16-light .CodeMirror-line > span > span::selection { background: #e0e0e0; }
13 .cm-s-base16-light .CodeMirror-line::-moz-selection, .cm-s-base16-light .CodeMirror-line > span::-moz-selection, .cm-s-base16-light .CodeMirror-line > span > span::-moz-selection { background: #e0e0e0; }
14 .cm-s-base16-light .CodeMirror-gutters { background: #f5f5f5; border-right: 0px; }
1515 .cm-s-base16-light .CodeMirror-guttermarker { color: #ac4142; }
1616 .cm-s-base16-light .CodeMirror-guttermarker-subtle { color: #b0b0b0; }
17 .cm-s-base16-light .CodeMirror-linenumber {color: #b0b0b0;}
18 .cm-s-base16-light .CodeMirror-cursor {border-left: 1px solid #505050 !important;}
17 .cm-s-base16-light .CodeMirror-linenumber { color: #b0b0b0; }
18 .cm-s-base16-light .CodeMirror-cursor { border-left: 1px solid #505050; }
1919
20 .cm-s-base16-light span.cm-comment {color: #8f5536;}
21 .cm-s-base16-light span.cm-atom {color: #aa759f;}
22 .cm-s-base16-light span.cm-number {color: #aa759f;}
20 .cm-s-base16-light span.cm-comment { color: #8f5536; }
21 .cm-s-base16-light span.cm-atom { color: #aa759f; }
22 .cm-s-base16-light span.cm-number { color: #aa759f; }
2323
24 .cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute {color: #90a959;}
25 .cm-s-base16-light span.cm-keyword {color: #ac4142;}
26 .cm-s-base16-light span.cm-string {color: #f4bf75;}
24 .cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute { color: #90a959; }
25 .cm-s-base16-light span.cm-keyword { color: #ac4142; }
26 .cm-s-base16-light span.cm-string { color: #f4bf75; }
2727
28 .cm-s-base16-light span.cm-variable {color: #90a959;}
29 .cm-s-base16-light span.cm-variable-2 {color: #6a9fb5;}
30 .cm-s-base16-light span.cm-def {color: #d28445;}
31 .cm-s-base16-light span.cm-bracket {color: #202020;}
32 .cm-s-base16-light span.cm-tag {color: #ac4142;}
33 .cm-s-base16-light span.cm-link {color: #aa759f;}
34 .cm-s-base16-light span.cm-error {background: #ac4142; color: #505050;}
28 .cm-s-base16-light span.cm-variable { color: #90a959; }
29 .cm-s-base16-light span.cm-variable-2 { color: #6a9fb5; }
30 .cm-s-base16-light span.cm-def { color: #d28445; }
31 .cm-s-base16-light span.cm-bracket { color: #202020; }
32 .cm-s-base16-light span.cm-tag { color: #ac4142; }
33 .cm-s-base16-light span.cm-link { color: #aa759f; }
34 .cm-s-base16-light span.cm-error { background: #ac4142; color: #505050; }
3535
36 .cm-s-base16-light .CodeMirror-activeline-background {background: #DDDCDC !important;}
37 .cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
36 .cm-s-base16-light .CodeMirror-activeline-background { background: #DDDCDC; }
37 .cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
0 /*
1
2 Name: Bespin
3 Author: Mozilla / Jan T. Sott
4
5 CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
6 Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
7
8 */
9
10 .cm-s-bespin.CodeMirror {background: #28211c; color: #9d9b97;}
11 .cm-s-bespin div.CodeMirror-selected {background: #36312e !important;}
12 .cm-s-bespin .CodeMirror-gutters {background: #28211c; border-right: 0px;}
13 .cm-s-bespin .CodeMirror-linenumber {color: #666666;}
14 .cm-s-bespin .CodeMirror-cursor {border-left: 1px solid #797977 !important;}
15
16 .cm-s-bespin span.cm-comment {color: #937121;}
17 .cm-s-bespin span.cm-atom {color: #9b859d;}
18 .cm-s-bespin span.cm-number {color: #9b859d;}
19
20 .cm-s-bespin span.cm-property, .cm-s-bespin span.cm-attribute {color: #54be0d;}
21 .cm-s-bespin span.cm-keyword {color: #cf6a4c;}
22 .cm-s-bespin span.cm-string {color: #f9ee98;}
23
24 .cm-s-bespin span.cm-variable {color: #54be0d;}
25 .cm-s-bespin span.cm-variable-2 {color: #5ea6ea;}
26 .cm-s-bespin span.cm-def {color: #cf7d34;}
27 .cm-s-bespin span.cm-error {background: #cf6a4c; color: #797977;}
28 .cm-s-bespin span.cm-bracket {color: #9d9b97;}
29 .cm-s-bespin span.cm-tag {color: #cf6a4c;}
30 .cm-s-bespin span.cm-link {color: #9b859d;}
31
32 .cm-s-bespin .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
33 .cm-s-bespin .CodeMirror-activeline-background { background: #404040; }
00 /* Port of TextMate's Blackboard theme */
11
22 .cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8; }
3 .cm-s-blackboard .CodeMirror-selected { background: #253B76 !important; }
4 .cm-s-blackboard.CodeMirror ::selection { background: rgba(37, 59, 118, .99); }
5 .cm-s-blackboard.CodeMirror ::-moz-selection { background: rgba(37, 59, 118, .99); }
3 .cm-s-blackboard div.CodeMirror-selected { background: #253B76; }
4 .cm-s-blackboard .CodeMirror-line::selection, .cm-s-blackboard .CodeMirror-line > span::selection, .cm-s-blackboard .CodeMirror-line > span > span::selection { background: rgba(37, 59, 118, .99); }
5 .cm-s-blackboard .CodeMirror-line::-moz-selection, .cm-s-blackboard .CodeMirror-line > span::-moz-selection, .cm-s-blackboard .CodeMirror-line > span > span::-moz-selection { background: rgba(37, 59, 118, .99); }
66 .cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; }
77 .cm-s-blackboard .CodeMirror-guttermarker { color: #FBDE2D; }
88 .cm-s-blackboard .CodeMirror-guttermarker-subtle { color: #888; }
99 .cm-s-blackboard .CodeMirror-linenumber { color: #888; }
10 .cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
10 .cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7; }
1111
1212 .cm-s-blackboard .cm-keyword { color: #FBDE2D; }
1313 .cm-s-blackboard .cm-atom { color: #D8FA3C; }
1414 .cm-s-blackboard .cm-number { color: #D8FA3C; }
1515 .cm-s-blackboard .cm-def { color: #8DA6CE; }
1616 .cm-s-blackboard .cm-variable { color: #FF6400; }
17 .cm-s-blackboard .cm-operator { color: #FBDE2D;}
17 .cm-s-blackboard .cm-operator { color: #FBDE2D; }
1818 .cm-s-blackboard .cm-comment { color: #AEAEAE; }
1919 .cm-s-blackboard .cm-string { color: #61CE3C; }
2020 .cm-s-blackboard .cm-string-2 { color: #61CE3C; }
2727 .cm-s-blackboard .cm-link { color: #8DA6CE; }
2828 .cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }
2929
30 .cm-s-blackboard .CodeMirror-activeline-background {background: #3C3636 !important;}
31 .cm-s-blackboard .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
30 .cm-s-blackboard .CodeMirror-activeline-background { background: #3C3636; }
31 .cm-s-blackboard .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
00 .cm-s-cobalt.CodeMirror { background: #002240; color: white; }
1 .cm-s-cobalt div.CodeMirror-selected { background: #b36539 !important; }
2 .cm-s-cobalt.CodeMirror ::selection { background: rgba(179, 101, 57, .99); }
3 .cm-s-cobalt.CodeMirror ::-moz-selection { background: rgba(179, 101, 57, .99); }
1 .cm-s-cobalt div.CodeMirror-selected { background: #b36539; }
2 .cm-s-cobalt .CodeMirror-line::selection, .cm-s-cobalt .CodeMirror-line > span::selection, .cm-s-cobalt .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); }
3 .cm-s-cobalt .CodeMirror-line::-moz-selection, .cm-s-cobalt .CodeMirror-line > span::-moz-selection, .cm-s-cobalt .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); }
44 .cm-s-cobalt .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
55 .cm-s-cobalt .CodeMirror-guttermarker { color: #ffee80; }
66 .cm-s-cobalt .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
77 .cm-s-cobalt .CodeMirror-linenumber { color: #d0d0d0; }
8 .cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white !important; }
8 .cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white; }
99
1010 .cm-s-cobalt span.cm-comment { color: #08f; }
1111 .cm-s-cobalt span.cm-atom { color: #845dc4; }
2020 .cm-s-cobalt span.cm-link { color: #845dc4; }
2121 .cm-s-cobalt span.cm-error { color: #9d1e15; }
2222
23 .cm-s-cobalt .CodeMirror-activeline-background {background: #002D57 !important;}
24 .cm-s-cobalt .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
23 .cm-s-cobalt .CodeMirror-activeline-background { background: #002D57; }
24 .cm-s-cobalt .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
22 .cm-s-colorforth .CodeMirror-guttermarker { color: #FFBD40; }
33 .cm-s-colorforth .CodeMirror-guttermarker-subtle { color: #78846f; }
44 .cm-s-colorforth .CodeMirror-linenumber { color: #bababa; }
5 .cm-s-colorforth .CodeMirror-cursor { border-left: 1px solid white !important; }
5 .cm-s-colorforth .CodeMirror-cursor { border-left: 1px solid white; }
66
77 .cm-s-colorforth span.cm-comment { color: #ededed; }
88 .cm-s-colorforth span.cm-def { color: #ff1c1c; font-weight:bold; }
2525 .cm-s-colorforth span.cm-attribute { color: #FFF700; }
2626 .cm-s-colorforth span.cm-error { color: #f00; }
2727
28 .cm-s-colorforth .CodeMirror-selected { background: #333d53 !important; }
28 .cm-s-colorforth div.CodeMirror-selected { background: #333d53; }
2929
3030 .cm-s-colorforth span.cm-compilation { background: rgba(255, 255, 255, 0.12); }
3131
32 .cm-s-colorforth .CodeMirror-activeline-background {background: #253540 !important;}
32 .cm-s-colorforth .CodeMirror-activeline-background { background: #253540; }
0 /*
1
2 Name: dracula
3 Author: Michael Kaminsky (http://github.com/mkaminsky11)
4
5 Original dracula color scheme by Zeno Rocha (https://github.com/zenorocha/dracula-theme)
6
7 */
8
9
10 .cm-s-dracula.CodeMirror, .cm-s-dracula .CodeMirror-gutters {
11 background-color: #282a36 !important;
12 color: #f8f8f2 !important;
13 border: none;
14 }
15 .cm-s-dracula .CodeMirror-gutters { color: #282a36; }
16 .cm-s-dracula .CodeMirror-cursor { border-left: solid thin #f8f8f0; }
17 .cm-s-dracula .CodeMirror-linenumber { color: #6D8A88; }
18 .cm-s-dracula.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
19 .cm-s-dracula .CodeMirror-line::selection, .cm-s-dracula .CodeMirror-line > span::selection, .cm-s-dracula .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
20 .cm-s-dracula .CodeMirror-line::-moz-selection, .cm-s-dracula .CodeMirror-line > span::-moz-selection, .cm-s-dracula .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
21 .cm-s-dracula span.cm-comment { color: #6272a4; }
22 .cm-s-dracula span.cm-string, .cm-s-dracula span.cm-string-2 { color: #f1fa8c; }
23 .cm-s-dracula span.cm-number { color: #bd93f9; }
24 .cm-s-dracula span.cm-variable { color: #50fa7b; }
25 .cm-s-dracula span.cm-variable-2 { color: white; }
26 .cm-s-dracula span.cm-def { color: #ffb86c; }
27 .cm-s-dracula span.cm-keyword { color: #ff79c6; }
28 .cm-s-dracula span.cm-operator { color: #ff79c6; }
29 .cm-s-dracula span.cm-keyword { color: #ff79c6; }
30 .cm-s-dracula span.cm-atom { color: #bd93f9; }
31 .cm-s-dracula span.cm-meta { color: #f8f8f2; }
32 .cm-s-dracula span.cm-tag { color: #ff79c6; }
33 .cm-s-dracula span.cm-attribute { color: #50fa7b; }
34 .cm-s-dracula span.cm-qualifier { color: #50fa7b; }
35 .cm-s-dracula span.cm-property { color: #66d9ef; }
36 .cm-s-dracula span.cm-builtin { color: #50fa7b; }
37 .cm-s-dracula span.cm-variable-3 { color: #50fa7b; }
38
39 .cm-s-dracula .CodeMirror-activeline-background { background: rgba(255,255,255,0.1); }
40 .cm-s-dracula .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
0 .cm-s-eclipse span.cm-meta {color: #FF1717;}
0 .cm-s-eclipse span.cm-meta { color: #FF1717; }
11 .cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
2 .cm-s-eclipse span.cm-atom {color: #219;}
3 .cm-s-eclipse span.cm-number {color: #164;}
4 .cm-s-eclipse span.cm-def {color: #00f;}
5 .cm-s-eclipse span.cm-variable {color: black;}
6 .cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
7 .cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
8 .cm-s-eclipse span.cm-property {color: black;}
9 .cm-s-eclipse span.cm-operator {color: black;}
10 .cm-s-eclipse span.cm-comment {color: #3F7F5F;}
11 .cm-s-eclipse span.cm-string {color: #2A00FF;}
12 .cm-s-eclipse span.cm-string-2 {color: #f50;}
13 .cm-s-eclipse span.cm-qualifier {color: #555;}
14 .cm-s-eclipse span.cm-builtin {color: #30a;}
15 .cm-s-eclipse span.cm-bracket {color: #cc7;}
16 .cm-s-eclipse span.cm-tag {color: #170;}
17 .cm-s-eclipse span.cm-attribute {color: #00c;}
18 .cm-s-eclipse span.cm-link {color: #219;}
19 .cm-s-eclipse span.cm-error {color: #f00;}
2 .cm-s-eclipse span.cm-atom { color: #219; }
3 .cm-s-eclipse span.cm-number { color: #164; }
4 .cm-s-eclipse span.cm-def { color: #00f; }
5 .cm-s-eclipse span.cm-variable { color: black; }
6 .cm-s-eclipse span.cm-variable-2 { color: #0000C0; }
7 .cm-s-eclipse span.cm-variable-3 { color: #0000C0; }
8 .cm-s-eclipse span.cm-property { color: black; }
9 .cm-s-eclipse span.cm-operator { color: black; }
10 .cm-s-eclipse span.cm-comment { color: #3F7F5F; }
11 .cm-s-eclipse span.cm-string { color: #2A00FF; }
12 .cm-s-eclipse span.cm-string-2 { color: #f50; }
13 .cm-s-eclipse span.cm-qualifier { color: #555; }
14 .cm-s-eclipse span.cm-builtin { color: #30a; }
15 .cm-s-eclipse span.cm-bracket { color: #cc7; }
16 .cm-s-eclipse span.cm-tag { color: #170; }
17 .cm-s-eclipse span.cm-attribute { color: #00c; }
18 .cm-s-eclipse span.cm-link { color: #219; }
19 .cm-s-eclipse span.cm-error { color: #f00; }
2020
21 .cm-s-eclipse .CodeMirror-activeline-background {background: #e8f2ff !important;}
22 .cm-s-eclipse .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
21 .cm-s-eclipse .CodeMirror-activeline-background { background: #e8f2ff; }
22 .cm-s-eclipse .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
0 .cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
1 .cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
2 .cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
3 .cm-s-elegant span.cm-variable {color: black;}
4 .cm-s-elegant span.cm-variable-2 {color: #b11;}
5 .cm-s-elegant span.cm-qualifier {color: #555;}
6 .cm-s-elegant span.cm-keyword {color: #730;}
7 .cm-s-elegant span.cm-builtin {color: #30a;}
8 .cm-s-elegant span.cm-link {color: #762;}
9 .cm-s-elegant span.cm-error {background-color: #fdd;}
0 .cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom { color: #762; }
1 .cm-s-elegant span.cm-comment { color: #262; font-style: italic; line-height: 1em; }
2 .cm-s-elegant span.cm-meta { color: #555; font-style: italic; line-height: 1em; }
3 .cm-s-elegant span.cm-variable { color: black; }
4 .cm-s-elegant span.cm-variable-2 { color: #b11; }
5 .cm-s-elegant span.cm-qualifier { color: #555; }
6 .cm-s-elegant span.cm-keyword { color: #730; }
7 .cm-s-elegant span.cm-builtin { color: #30a; }
8 .cm-s-elegant span.cm-link { color: #762; }
9 .cm-s-elegant span.cm-error { background-color: #fdd; }
1010
11 .cm-s-elegant .CodeMirror-activeline-background {background: #e8f2ff !important;}
12 .cm-s-elegant .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
11 .cm-s-elegant .CodeMirror-activeline-background { background: #e8f2ff; }
12 .cm-s-elegant .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
00 .cm-s-erlang-dark.CodeMirror { background: #002240; color: white; }
1 .cm-s-erlang-dark div.CodeMirror-selected { background: #b36539 !important; }
2 .cm-s-erlang-dark.CodeMirror ::selection { background: rgba(179, 101, 57, .99); }
3 .cm-s-erlang-dark.CodeMirror ::-moz-selection { background: rgba(179, 101, 57, .99); }
1 .cm-s-erlang-dark div.CodeMirror-selected { background: #b36539; }
2 .cm-s-erlang-dark .CodeMirror-line::selection, .cm-s-erlang-dark .CodeMirror-line > span::selection, .cm-s-erlang-dark .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); }
3 .cm-s-erlang-dark .CodeMirror-line::-moz-selection, .cm-s-erlang-dark .CodeMirror-line > span::-moz-selection, .cm-s-erlang-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); }
44 .cm-s-erlang-dark .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
55 .cm-s-erlang-dark .CodeMirror-guttermarker { color: white; }
66 .cm-s-erlang-dark .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
77 .cm-s-erlang-dark .CodeMirror-linenumber { color: #d0d0d0; }
8 .cm-s-erlang-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
8 .cm-s-erlang-dark .CodeMirror-cursor { border-left: 1px solid white; }
99
1010 .cm-s-erlang-dark span.cm-quote { color: #ccc; }
1111 .cm-s-erlang-dark span.cm-atom { color: #f133f1; }
2929 .cm-s-erlang-dark span.cm-variable-3 { color: #ccc; }
3030 .cm-s-erlang-dark span.cm-error { color: #9d1e15; }
3131
32 .cm-s-erlang-dark .CodeMirror-activeline-background {background: #013461 !important;}
33 .cm-s-erlang-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
32 .cm-s-erlang-dark .CodeMirror-activeline-background { background: #013461; }
33 .cm-s-erlang-dark .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
0 /*
1
2 Name: Hopscotch
3 Author: Jan T. Sott
4
5 CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
6 Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
7
8 */
9
10 .cm-s-hopscotch.CodeMirror {background: #322931; color: #d5d3d5;}
11 .cm-s-hopscotch div.CodeMirror-selected {background: #433b42 !important;}
12 .cm-s-hopscotch .CodeMirror-gutters {background: #322931; border-right: 0px;}
13 .cm-s-hopscotch .CodeMirror-linenumber {color: #797379;}
14 .cm-s-hopscotch .CodeMirror-cursor {border-left: 1px solid #989498 !important;}
15
16 .cm-s-hopscotch span.cm-comment {color: #b33508;}
17 .cm-s-hopscotch span.cm-atom {color: #c85e7c;}
18 .cm-s-hopscotch span.cm-number {color: #c85e7c;}
19
20 .cm-s-hopscotch span.cm-property, .cm-s-hopscotch span.cm-attribute {color: #8fc13e;}
21 .cm-s-hopscotch span.cm-keyword {color: #dd464c;}
22 .cm-s-hopscotch span.cm-string {color: #fdcc59;}
23
24 .cm-s-hopscotch span.cm-variable {color: #8fc13e;}
25 .cm-s-hopscotch span.cm-variable-2 {color: #1290bf;}
26 .cm-s-hopscotch span.cm-def {color: #fd8b19;}
27 .cm-s-hopscotch span.cm-error {background: #dd464c; color: #989498;}
28 .cm-s-hopscotch span.cm-bracket {color: #d5d3d5;}
29 .cm-s-hopscotch span.cm-tag {color: #dd464c;}
30 .cm-s-hopscotch span.cm-link {color: #c85e7c;}
31
32 .cm-s-hopscotch .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
33 .cm-s-hopscotch .CodeMirror-activeline-background { background: #302020; }
0 /*
1 ICEcoder default theme by Matt Pass, used in code editor available at https://icecoder.net
2 */
3
4 .cm-s-icecoder { color: #666; background: #1d1d1b; }
5
6 .cm-s-icecoder span.cm-keyword { color: #eee; font-weight:bold; } /* off-white 1 */
7 .cm-s-icecoder span.cm-atom { color: #e1c76e; } /* yellow */
8 .cm-s-icecoder span.cm-number { color: #6cb5d9; } /* blue */
9 .cm-s-icecoder span.cm-def { color: #b9ca4a; } /* green */
10
11 .cm-s-icecoder span.cm-variable { color: #6cb5d9; } /* blue */
12 .cm-s-icecoder span.cm-variable-2 { color: #cc1e5c; } /* pink */
13 .cm-s-icecoder span.cm-variable-3 { color: #f9602c; } /* orange */
14
15 .cm-s-icecoder span.cm-property { color: #eee; } /* off-white 1 */
16 .cm-s-icecoder span.cm-operator { color: #9179bb; } /* purple */
17 .cm-s-icecoder span.cm-comment { color: #97a3aa; } /* grey-blue */
18
19 .cm-s-icecoder span.cm-string { color: #b9ca4a; } /* green */
20 .cm-s-icecoder span.cm-string-2 { color: #6cb5d9; } /* blue */
21
22 .cm-s-icecoder span.cm-meta { color: #555; } /* grey */
23
24 .cm-s-icecoder span.cm-qualifier { color: #555; } /* grey */
25 .cm-s-icecoder span.cm-builtin { color: #214e7b; } /* bright blue */
26 .cm-s-icecoder span.cm-bracket { color: #cc7; } /* grey-yellow */
27
28 .cm-s-icecoder span.cm-tag { color: #e8e8e8; } /* off-white 2 */
29 .cm-s-icecoder span.cm-attribute { color: #099; } /* teal */
30
31 .cm-s-icecoder span.cm-header { color: #6a0d6a; } /* purple-pink */
32 .cm-s-icecoder span.cm-quote { color: #186718; } /* dark green */
33 .cm-s-icecoder span.cm-hr { color: #888; } /* mid-grey */
34 .cm-s-icecoder span.cm-link { color: #e1c76e; } /* yellow */
35 .cm-s-icecoder span.cm-error { color: #d00; } /* red */
36
37 .cm-s-icecoder .CodeMirror-cursor { border-left: 1px solid white; }
38 .cm-s-icecoder div.CodeMirror-selected { color: #fff; background: #037; }
39 .cm-s-icecoder .CodeMirror-gutters { background: #1d1d1b; min-width: 41px; border-right: 0; }
40 .cm-s-icecoder .CodeMirror-linenumber { color: #555; cursor: default; }
41 .cm-s-icecoder .CodeMirror-matchingbracket { color: #fff !important; background: #555 !important; }
42 .cm-s-icecoder .CodeMirror-activeline-background { background: #000; }
0 /*
1
2 Name: Isotope
3 Author: David Desandro / Jan T. Sott
4
5 CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
6 Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
7
8 */
9
10 .cm-s-isotope.CodeMirror {background: #000000; color: #e0e0e0;}
11 .cm-s-isotope div.CodeMirror-selected {background: #404040 !important;}
12 .cm-s-isotope .CodeMirror-gutters {background: #000000; border-right: 0px;}
13 .cm-s-isotope .CodeMirror-linenumber {color: #808080;}
14 .cm-s-isotope .CodeMirror-cursor {border-left: 1px solid #c0c0c0 !important;}
15
16 .cm-s-isotope span.cm-comment {color: #3300ff;}
17 .cm-s-isotope span.cm-atom {color: #cc00ff;}
18 .cm-s-isotope span.cm-number {color: #cc00ff;}
19
20 .cm-s-isotope span.cm-property, .cm-s-isotope span.cm-attribute {color: #33ff00;}
21 .cm-s-isotope span.cm-keyword {color: #ff0000;}
22 .cm-s-isotope span.cm-string {color: #ff0099;}
23
24 .cm-s-isotope span.cm-variable {color: #33ff00;}
25 .cm-s-isotope span.cm-variable-2 {color: #0066ff;}
26 .cm-s-isotope span.cm-def {color: #ff9900;}
27 .cm-s-isotope span.cm-error {background: #ff0000; color: #c0c0c0;}
28 .cm-s-isotope span.cm-bracket {color: #e0e0e0;}
29 .cm-s-isotope span.cm-tag {color: #ff0000;}
30 .cm-s-isotope span.cm-link {color: #cc00ff;}
31
32 .cm-s-isotope .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
33 .cm-s-isotope .CodeMirror-activeline-background { background: #202020; }
55 line-height: 1.3em;
66 }
77 .cm-s-lesser-dark.CodeMirror { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; }
8 .cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/
9 .cm-s-lesser-dark.CodeMirror ::selection { background: rgba(69, 68, 59, .99); }
10 .cm-s-lesser-dark.CodeMirror ::-moz-selection { background: rgba(69, 68, 59, .99); }
11 .cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
8 .cm-s-lesser-dark div.CodeMirror-selected { background: #45443B; } /* 33322B*/
9 .cm-s-lesser-dark .CodeMirror-line::selection, .cm-s-lesser-dark .CodeMirror-line > span::selection, .cm-s-lesser-dark .CodeMirror-line > span > span::selection { background: rgba(69, 68, 59, .99); }
10 .cm-s-lesser-dark .CodeMirror-line::-moz-selection, .cm-s-lesser-dark .CodeMirror-line > span::-moz-selection, .cm-s-lesser-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(69, 68, 59, .99); }
11 .cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white; }
1212 .cm-s-lesser-dark pre { padding: 0 8px; }/*editable code holder*/
1313
1414 .cm-s-lesser-dark.CodeMirror span.CodeMirror-matchingbracket { color: #7EFC7E; }/*65FC65*/
1818 .cm-s-lesser-dark .CodeMirror-guttermarker-subtle { color: #777; }
1919 .cm-s-lesser-dark .CodeMirror-linenumber { color: #777; }
2020
21 .cm-s-lesser-dark span.cm-header {color: #a0a;}
22 .cm-s-lesser-dark span.cm-quote {color: #090;}
21 .cm-s-lesser-dark span.cm-header { color: #a0a; }
22 .cm-s-lesser-dark span.cm-quote { color: #090; }
2323 .cm-s-lesser-dark span.cm-keyword { color: #599eff; }
2424 .cm-s-lesser-dark span.cm-atom { color: #C2B470; }
2525 .cm-s-lesser-dark span.cm-number { color: #B35E4D; }
26 .cm-s-lesser-dark span.cm-def {color: white;}
26 .cm-s-lesser-dark span.cm-def { color: white; }
2727 .cm-s-lesser-dark span.cm-variable { color:#D9BF8C; }
2828 .cm-s-lesser-dark span.cm-variable-2 { color: #669199; }
2929 .cm-s-lesser-dark span.cm-variable-3 { color: white; }
30 .cm-s-lesser-dark span.cm-property {color: #92A75C;}
31 .cm-s-lesser-dark span.cm-operator {color: #92A75C;}
30 .cm-s-lesser-dark span.cm-property { color: #92A75C; }
31 .cm-s-lesser-dark span.cm-operator { color: #92A75C; }
3232 .cm-s-lesser-dark span.cm-comment { color: #666; }
3333 .cm-s-lesser-dark span.cm-string { color: #BCD279; }
34 .cm-s-lesser-dark span.cm-string-2 {color: #f50;}
34 .cm-s-lesser-dark span.cm-string-2 { color: #f50; }
3535 .cm-s-lesser-dark span.cm-meta { color: #738C73; }
36 .cm-s-lesser-dark span.cm-qualifier {color: #555;}
36 .cm-s-lesser-dark span.cm-qualifier { color: #555; }
3737 .cm-s-lesser-dark span.cm-builtin { color: #ff9e59; }
3838 .cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; }
3939 .cm-s-lesser-dark span.cm-tag { color: #669199; }
40 .cm-s-lesser-dark span.cm-attribute {color: #00c;}
41 .cm-s-lesser-dark span.cm-hr {color: #999;}
42 .cm-s-lesser-dark span.cm-link {color: #00c;}
40 .cm-s-lesser-dark span.cm-attribute { color: #00c; }
41 .cm-s-lesser-dark span.cm-hr { color: #999; }
42 .cm-s-lesser-dark span.cm-link { color: #00c; }
4343 .cm-s-lesser-dark span.cm-error { color: #9d1e15; }
4444
45 .cm-s-lesser-dark .CodeMirror-activeline-background {background: #3C3A3A !important;}
46 .cm-s-lesser-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
45 .cm-s-lesser-dark .CodeMirror-activeline-background { background: #3C3A3A; }
46 .cm-s-lesser-dark .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
33 line-height: 1.2em;
44 font-size: 1em;
55 }
6 .CodeMirror-focused .cm-matchhighlight {
6 .cm-s-liquibyte .CodeMirror-focused .cm-matchhighlight {
77 text-decoration: underline;
88 text-decoration-color: #0f0;
99 text-decoration-style: wavy;
1010 }
11 .cm-trailingspace {
11 .cm-s-liquibyte .cm-trailingspace {
1212 text-decoration: line-through;
1313 text-decoration-color: #f00;
1414 text-decoration-style: dotted;
1515 }
16 .cm-tab {
16 .cm-s-liquibyte .cm-tab {
1717 text-decoration: line-through;
1818 text-decoration-color: #404040;
1919 text-decoration-style: dotted;
2020 }
2121 .cm-s-liquibyte .CodeMirror-gutters { background-color: #262626; border-right: 1px solid #505050; padding-right: 0.8em; }
22 .cm-s-liquibyte .CodeMirror-gutter-elt div{ font-size: 1.2em; }
22 .cm-s-liquibyte .CodeMirror-gutter-elt div { font-size: 1.2em; }
2323 .cm-s-liquibyte .CodeMirror-guttermarker { }
2424 .cm-s-liquibyte .CodeMirror-guttermarker-subtle { }
25 .cm-s-liquibyte .CodeMirror-linenumber { color: #606060; padding-left: 0;}
26 .cm-s-liquibyte .CodeMirror-cursor { border-left: 1px solid #eee !important; }
25 .cm-s-liquibyte .CodeMirror-linenumber { color: #606060; padding-left: 0; }
26 .cm-s-liquibyte .CodeMirror-cursor { border-left: 1px solid #eee; }
2727
2828 .cm-s-liquibyte span.cm-comment { color: #008000; }
2929 .cm-s-liquibyte span.cm-def { color: #ffaf40; font-weight: bold; }
4646 .cm-s-liquibyte span.cm-attribute { color: #c080ff; font-weight: bold; }
4747 .cm-s-liquibyte span.cm-error { color: #f00; }
4848
49 .cm-s-liquibyte .CodeMirror-selected { background-color: rgba(255, 0, 0, 0.25) !important; }
49 .cm-s-liquibyte div.CodeMirror-selected { background-color: rgba(255, 0, 0, 0.25); }
5050
5151 .cm-s-liquibyte span.cm-compilation { background-color: rgba(255, 255, 255, 0.12); }
5252
53 .cm-s-liquibyte .CodeMirror-activeline-background {background-color: rgba(0, 255, 0, 0.15) !important;}
53 .cm-s-liquibyte .CodeMirror-activeline-background { background-color: rgba(0, 255, 0, 0.15); }
5454
5555 /* Default styles for common addons */
56 div.CodeMirror span.CodeMirror-matchingbracket { color: #0f0; font-weight: bold; }
57 div.CodeMirror span.CodeMirror-nonmatchingbracket { color: #f00; font-weight: bold; }
56 .cm-s-liquibyte .CodeMirror span.CodeMirror-matchingbracket { color: #0f0; font-weight: bold; }
57 .cm-s-liquibyte .CodeMirror span.CodeMirror-nonmatchingbracket { color: #f00; font-weight: bold; }
5858 .CodeMirror-matchingtag { background-color: rgba(150, 255, 0, .3); }
5959 /* Scrollbars */
6060 /* Simple */
61 div.CodeMirror-simplescroll-horizontal div:hover, div.CodeMirror-simplescroll-vertical div:hover {
61 .cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div:hover, div.CodeMirror-simplescroll-vertical div:hover {
6262 background-color: rgba(80, 80, 80, .7);
6363 }
64 div.CodeMirror-simplescroll-horizontal div, div.CodeMirror-simplescroll-vertical div {
64 .cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div, div.CodeMirror-simplescroll-vertical div {
6565 background-color: rgba(80, 80, 80, .3);
6666 border: 1px solid #404040;
6767 border-radius: 5px;
6868 }
69 div.CodeMirror-simplescroll-vertical div {
69 .cm-s-liquibyte div.CodeMirror-simplescroll-vertical div {
7070 border-top: 1px solid #404040;
7171 border-bottom: 1px solid #404040;
7272 }
73 div.CodeMirror-simplescroll-horizontal div {
73 .cm-s-liquibyte div.CodeMirror-simplescroll-horizontal div {
7474 border-left: 1px solid #404040;
7575 border-right: 1px solid #404040;
7676 }
77 div.CodeMirror-simplescroll-vertical {
77 .cm-s-liquibyte div.CodeMirror-simplescroll-vertical {
7878 background-color: #262626;
7979 }
80 div.CodeMirror-simplescroll-horizontal {
80 .cm-s-liquibyte div.CodeMirror-simplescroll-horizontal {
8181 background-color: #262626;
8282 border-top: 1px solid #404040;
8383 }
8484 /* Overlay */
85 div.CodeMirror-overlayscroll-horizontal div, div.CodeMirror-overlayscroll-vertical div {
85 .cm-s-liquibyte div.CodeMirror-overlayscroll-horizontal div, div.CodeMirror-overlayscroll-vertical div {
8686 background-color: #404040;
8787 border-radius: 5px;
8888 }
89 div.CodeMirror-overlayscroll-vertical div {
89 .cm-s-liquibyte div.CodeMirror-overlayscroll-vertical div {
9090 border: 1px solid #404040;
9191 }
92 div.CodeMirror-overlayscroll-horizontal div {
92 .cm-s-liquibyte div.CodeMirror-overlayscroll-horizontal div {
9393 border: 1px solid #404040;
9494 }
0 /*
1
2 Name: material
3 Author: Michael Kaminsky (http://github.com/mkaminsky11)
4
5 Original material color scheme by Mattia Astorino (https://github.com/equinusocio/material-theme)
6
7 */
8
9 .cm-s-material {
10 background-color: #263238;
11 color: rgba(233, 237, 237, 1);
12 }
13 .cm-s-material .CodeMirror-gutters {
14 background: #263238;
15 color: rgb(83,127,126);
16 border: none;
17 }
18 .cm-s-material .CodeMirror-guttermarker, .cm-s-material .CodeMirror-guttermarker-subtle, .cm-s-material .CodeMirror-linenumber { color: rgb(83,127,126); }
19 .cm-s-material .CodeMirror-cursor { border-left: 1px solid #f8f8f0; }
20 .cm-s-material div.CodeMirror-selected { background: rgba(255, 255, 255, 0.15); }
21 .cm-s-material.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
22 .cm-s-material .CodeMirror-line::selection, .cm-s-material .CodeMirror-line > span::selection, .cm-s-material .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
23 .cm-s-material .CodeMirror-line::-moz-selection, .cm-s-material .CodeMirror-line > span::-moz-selection, .cm-s-material .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
24
25 .cm-s-material .CodeMirror-activeline-background { background: rgba(0, 0, 0, 0); }
26 .cm-s-material .cm-keyword { color: rgba(199, 146, 234, 1); }
27 .cm-s-material .cm-operator { color: rgba(233, 237, 237, 1); }
28 .cm-s-material .cm-variable-2 { color: #80CBC4; }
29 .cm-s-material .cm-variable-3 { color: #82B1FF; }
30 .cm-s-material .cm-builtin { color: #DECB6B; }
31 .cm-s-material .cm-atom { color: #F77669; }
32 .cm-s-material .cm-number { color: #F77669; }
33 .cm-s-material .cm-def { color: rgba(233, 237, 237, 1); }
34 .cm-s-material .cm-string { color: #C3E88D; }
35 .cm-s-material .cm-string-2 { color: #80CBC4; }
36 .cm-s-material .cm-comment { color: #546E7A; }
37 .cm-s-material .cm-variable { color: #82B1FF; }
38 .cm-s-material .cm-tag { color: #80CBC4; }
39 .cm-s-material .cm-meta { color: #80CBC4; }
40 .cm-s-material .cm-attribute { color: #FFCB6B; }
41 .cm-s-material .cm-property { color: #80CBAE; }
42 .cm-s-material .cm-qualifier { color: #DECB6B; }
43 .cm-s-material .cm-variable-3 { color: #DECB6B; }
44 .cm-s-material .cm-tag { color: rgba(255, 83, 112, 1); }
45 .cm-s-material .cm-error {
46 color: rgba(255, 255, 255, 1.0);
47 background-color: #EC5F67;
48 }
49 .cm-s-material .CodeMirror-matchingbracket {
50 text-decoration: underline;
51 color: white !important;
52 }
33 /* Create your own: http://tmtheme-editor.herokuapp.com */
44 /****************************************************************/
55
6 .cm-s-mbo.CodeMirror {background: #2c2c2c; color: #ffffec;}
7 .cm-s-mbo div.CodeMirror-selected {background: #716C62 !important;}
8 .cm-s-mbo.CodeMirror ::selection { background: rgba(113, 108, 98, .99); }
9 .cm-s-mbo.CodeMirror ::-moz-selection { background: rgba(113, 108, 98, .99); }
10 .cm-s-mbo .CodeMirror-gutters {background: #4e4e4e; border-right: 0px;}
6 .cm-s-mbo.CodeMirror { background: #2c2c2c; color: #ffffec; }
7 .cm-s-mbo div.CodeMirror-selected { background: #716C62; }
8 .cm-s-mbo .CodeMirror-line::selection, .cm-s-mbo .CodeMirror-line > span::selection, .cm-s-mbo .CodeMirror-line > span > span::selection { background: rgba(113, 108, 98, .99); }
9 .cm-s-mbo .CodeMirror-line::-moz-selection, .cm-s-mbo .CodeMirror-line > span::-moz-selection, .cm-s-mbo .CodeMirror-line > span > span::-moz-selection { background: rgba(113, 108, 98, .99); }
10 .cm-s-mbo .CodeMirror-gutters { background: #4e4e4e; border-right: 0px; }
1111 .cm-s-mbo .CodeMirror-guttermarker { color: white; }
1212 .cm-s-mbo .CodeMirror-guttermarker-subtle { color: grey; }
13 .cm-s-mbo .CodeMirror-linenumber {color: #dadada;}
14 .cm-s-mbo .CodeMirror-cursor {border-left: 1px solid #ffffec !important;}
13 .cm-s-mbo .CodeMirror-linenumber { color: #dadada; }
14 .cm-s-mbo .CodeMirror-cursor { border-left: 1px solid #ffffec; }
1515
16 .cm-s-mbo span.cm-comment {color: #95958a;}
17 .cm-s-mbo span.cm-atom {color: #00a8c6;}
18 .cm-s-mbo span.cm-number {color: #00a8c6;}
16 .cm-s-mbo span.cm-comment { color: #95958a; }
17 .cm-s-mbo span.cm-atom { color: #00a8c6; }
18 .cm-s-mbo span.cm-number { color: #00a8c6; }
1919
20 .cm-s-mbo span.cm-property, .cm-s-mbo span.cm-attribute {color: #9ddfe9;}
21 .cm-s-mbo span.cm-keyword {color: #ffb928;}
22 .cm-s-mbo span.cm-string {color: #ffcf6c;}
23 .cm-s-mbo span.cm-string.cm-property {color: #ffffec;}
20 .cm-s-mbo span.cm-property, .cm-s-mbo span.cm-attribute { color: #9ddfe9; }
21 .cm-s-mbo span.cm-keyword { color: #ffb928; }
22 .cm-s-mbo span.cm-string { color: #ffcf6c; }
23 .cm-s-mbo span.cm-string.cm-property { color: #ffffec; }
2424
25 .cm-s-mbo span.cm-variable {color: #ffffec;}
26 .cm-s-mbo span.cm-variable-2 {color: #00a8c6;}
27 .cm-s-mbo span.cm-def {color: #ffffec;}
28 .cm-s-mbo span.cm-bracket {color: #fffffc; font-weight: bold;}
29 .cm-s-mbo span.cm-tag {color: #9ddfe9;}
30 .cm-s-mbo span.cm-link {color: #f54b07;}
31 .cm-s-mbo span.cm-error {border-bottom: #636363; color: #ffffec;}
32 .cm-s-mbo span.cm-qualifier {color: #ffffec;}
25 .cm-s-mbo span.cm-variable { color: #ffffec; }
26 .cm-s-mbo span.cm-variable-2 { color: #00a8c6; }
27 .cm-s-mbo span.cm-def { color: #ffffec; }
28 .cm-s-mbo span.cm-bracket { color: #fffffc; font-weight: bold; }
29 .cm-s-mbo span.cm-tag { color: #9ddfe9; }
30 .cm-s-mbo span.cm-link { color: #f54b07; }
31 .cm-s-mbo span.cm-error { border-bottom: #636363; color: #ffffec; }
32 .cm-s-mbo span.cm-qualifier { color: #ffffec; }
3333
34 .cm-s-mbo .CodeMirror-activeline-background {background: #494b41 !important;}
35 .cm-s-mbo .CodeMirror-matchingbracket {color: #222 !important;}
36 .cm-s-mbo .CodeMirror-matchingtag {background: rgba(255, 255, 255, .37);}
34 .cm-s-mbo .CodeMirror-activeline-background { background: #494b41; }
35 .cm-s-mbo .CodeMirror-matchingbracket { color: #ffb928 !important; }
36 .cm-s-mbo .CodeMirror-matchingtag { background: rgba(255, 255, 255, .37); }
77
88 */
99 .cm-s-mdn-like.CodeMirror { color: #999; background-color: #fff; }
10 .cm-s-mdn-like .CodeMirror-selected { background: #cfc !important; }
11 .cm-s-mdn-like.CodeMirror ::selection { background: #cfc; }
12 .cm-s-mdn-like.CodeMirror ::-moz-selection { background: #cfc; }
10 .cm-s-mdn-like div.CodeMirror-selected { background: #cfc; }
11 .cm-s-mdn-like .CodeMirror-line::selection, .cm-s-mdn-like .CodeMirror-line > span::selection, .cm-s-mdn-like .CodeMirror-line > span > span::selection { background: #cfc; }
12 .cm-s-mdn-like .CodeMirror-line::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span::-moz-selection, .cm-s-mdn-like .CodeMirror-line > span > span::-moz-selection { background: #cfc; }
1313
1414 .cm-s-mdn-like .CodeMirror-gutters { background: #f8f8f8; border-left: 6px solid rgba(0,83,159,0.65); color: #333; }
1515 .cm-s-mdn-like .CodeMirror-linenumber { color: #aaa; padding-left: 8px; }
16 div.cm-s-mdn-like .CodeMirror-cursor { border-left: 2px solid #222; }
16 .cm-s-mdn-like .CodeMirror-cursor { border-left: 2px solid #222; }
1717
18 .cm-s-mdn-like .cm-keyword { color: #6262FF; }
18 .cm-s-mdn-like .cm-keyword { color: #6262FF; }
1919 .cm-s-mdn-like .cm-atom { color: #F90; }
2020 .cm-s-mdn-like .cm-number { color: #ca7841; }
2121 .cm-s-mdn-like .cm-def { color: #8DA6CE; }
3636 .cm-s-mdn-like .cm-attribute { color: #d6bb6d; } /*?*/
3737 .cm-s-mdn-like .cm-header { color: #FF6400; }
3838 .cm-s-mdn-like .cm-hr { color: #AEAEAE; }
39 .cm-s-mdn-like .cm-link { color:#ad9361; font-style:italic; text-decoration:none; }
39 .cm-s-mdn-like .cm-link { color:#ad9361; font-style:italic; text-decoration:none; }
4040 .cm-s-mdn-like .cm-error { border-bottom: 1px solid red; }
4141
42 div.cm-s-mdn-like .CodeMirror-activeline-background {background: #efefff;}
43 div.cm-s-mdn-like span.CodeMirror-matchingbracket {outline:1px solid grey; color: inherit;}
42 div.cm-s-mdn-like .CodeMirror-activeline-background { background: #efefff; }
43 div.cm-s-mdn-like span.CodeMirror-matchingbracket { outline:1px solid grey; color: inherit; }
4444
4545 .cm-s-mdn-like.CodeMirror { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFcAAAAyCAYAAAAp8UeFAAAHvklEQVR42s2b63bcNgyEQZCSHCdt2vd/0tWF7I+Q6XgMXiTtuvU5Pl57ZQKkKHzEAOtF5KeIJBGJ8uvL599FRFREZhFx8DeXv8trn68RuGaC8TRfo3SNp9dlDDHedyLyTUTeRWStXKPZrjtpZxaRw5hPqozRs1N8/enzIiQRWcCgy4MUA0f+XWliDhyL8Lfyvx7ei/Ae3iQFHyw7U/59pQVIMEEPEz0G7XiwdRjzSfC3UTtz9vchIntxvry5iMgfIhJoEflOz2CQr3F5h/HfeFe+GTdLaKcu9L8LTeQb/R/7GgbsfKedyNdoHsN31uRPWrfZ5wsj/NzzRQHuToIdU3ahwnsKPxXCjJITuOsi7XLc7SG/v5GdALs7wf8JjTFiB5+QvTEfRyGOfX3Lrx8wxyQi3sNq46O7QahQiCsRFgqddjBouVEHOKDgXAQHD9gJCr5sMKkEdjwsarG/ww3BMHBU7OBjXnzdyY7SfCxf5/z6ATccrwlKuwC/jhznnPF4CgVzhhVf4xp2EixcBActO75iZ8/fM9zAs2OMzKdslgXWJ9XG8PQoOAMA5fGcsvORgv0doBXyHrCwfLJAOwo71QLNkb8n2Pl6EWiR7OCibtkPaz4Kc/0NNAze2gju3zOwekALDaCFPI5vjPFmgGY5AZqyGEvH1x7QfIb8YtxMnA/b+QQ0aQDAwc6JMFg8CbQZ4qoYEEHbRwNojuK3EHwd7VALSgq+MNDKzfT58T8qdpADrgW0GmgcAS1lhzztJmkAzcPNOQbsWEALBDSlMKUG0Eq4CLAQWvEVQ9WU57gZJwZtgPO3r9oBTQ9WO8TjqXINx8R0EYpiZEUWOF3FxkbJkgU9B2f41YBrIj5ZfsQa0M5kTgiAAqM3ShXLgu8XMqcrQBvJ0CL5pnTsfMB13oB8athpAq2XOQmcGmoACCLydx7nToa23ATaSIY2ichfOdPTGxlasXMLaL0MLZAOwAKIM+y8CmicobGdCcbbK9DzN+yYGVoNNI5iUKTMyYOjPse4A8SM1MmcXgU0toOq1yO/v8FOxlASyc7TgeYaAMBJHcY1CcCwGI/TK4AmDbDyKYBBtFUkRwto8gygiQEaByFgJ00BH2M8JWwQS1nafDXQCidWyOI8AcjDCSjCLk8ngObuAm3JAHAdubAmOaK06V8MNEsKPJOhobSprwQa6gD7DclRQdqcwL4zxqgBrQcabUiBLclRDKAlWp+etPkBaNMA0AKlrHwTdEByZAA4GM+SNluSY6wAzcMNewxmgig5Ks0nkrSpBvSaQHMdKTBAnLojOdYyGpQ254602ZILPdTD1hdlggdIm74jbTp8vDwF5ZYUeLWGJpWsh6XNyXgcYwVoJQTEhhTYkxzZjiU5npU2TaB979TQehlaAVq4kaGpiPwwwLkYUuBbQwocyQTv1tA0+1UFWoJF3iv1oq+qoSk8EQdJmwHkziIF7oOZk14EGitibAdjLYYK78H5vZOhtWpoI0ATGHs0Q8OMb4Ey+2bU2UYztCtA0wFAs7TplGLRVQCcqaFdGSPCeTI1QNIC52iWNzof6Uib7xjEp07mNNoUYmVosVItHrHzRlLgBn9LFyRHaQCtVUMbtTNhoXWiTOO9k/V8BdAc1Oq0ArSQs6/5SU0hckNy9NnXqQY0PGYo5dWJ7nINaN6o958FWin27aBaWRka1r5myvLOAm0j30eBJqCxHLReVclxhxOEN2JfDWjxBtAC7MIH1fVaGdoOp4qJYDgKtKPSFNID2gSnGldrCqkFZ+5UeQXQBIRrSwocbdZYQT/2LwRahBPBXoHrB8nxaGROST62DKUbQOMMzZIC9abkuELfQzQALWTnDNAm8KHWFOJgJ5+SHIvTPcmx1xQyZRhNL5Qci689aXMEaN/uNIWkEwDAvFpOZmgsBaaGnbs1NPa1Jm32gBZAIh1pCtG7TSH4aE0y1uVY4uqoFPisGlpP2rSA5qTecWn5agK6BzSpgAyD+wFaqhnYoSZ1Vwr8CmlTQbrcO3ZaX0NAEyMbYaAlyquFoLKK3SPby9CeVUPThrSJmkCAE0CrKUQadi4DrdSlWhmah0YL9z9vClH59YGbHx1J8VZTyAjQepJjmXwAKTDQI3omc3p1U4gDUf6RfcdYfrUp5ClAi2J3Ba6UOXGo+K+bQrjjssitG2SJzshaLwMtXgRagUNpYYoVkMSBLM+9GGiJZMvduG6DRZ4qc04DMPtQQxOjEtACmhO7K1AbNbQDEggZyJwscFpAGwENhoBeUwh3bWolhe8BTYVKxQEWrSUn/uhcM5KhvUu/+eQu0Lzhi+VrK0PrZZNDQKs9cpYUuFYgMVpD4/NxenJTiMCNqdUEUf1qZWjppLT5qSkkUZbCwkbZMSuVnu80hfSkzRbQeqCZSAh6huR4VtoM2gHAlLf72smuWgE+VV7XpE25Ab2WFDgyhnSuKbs4GuGzCjR+tIoUuMFg3kgcWKLTwRqanJQ2W00hAsenfaApRC42hbCvK1SlE0HtE9BGgneJO+ELamitD1YjjOYnNYVcraGhtKkW0EqVVeDx733I2NH581k1NNxNLG0i0IJ8/NjVaOZ0tYZ2Vtr0Xv7tPV3hkWp9EFkgS/J0vosngTaSoaG06WHi+xObQkaAdlbanP8B2+2l0f90LmUAAAAASUVORK5CYII=); }
44 .cm-s-midnight.CodeMirror-focused span.CodeMirror-matchhighlight { background: #314D67 !important; }
55
66 /*<!--activeline-->*/
7 .cm-s-midnight .CodeMirror-activeline-background {background: #253540 !important;}
7 .cm-s-midnight .CodeMirror-activeline-background { background: #253540; }
88
99 .cm-s-midnight.CodeMirror {
1010 background: #0F192A;
1111 color: #D1EDFF;
1212 }
1313
14 .cm-s-midnight.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
14 .cm-s-midnight.CodeMirror { border-top: 1px solid black; border-bottom: 1px solid black; }
1515
16 .cm-s-midnight div.CodeMirror-selected {background: #314D67 !important;}
17 .cm-s-midnight.CodeMirror ::selection { background: rgba(49, 77, 103, .99); }
18 .cm-s-midnight.CodeMirror ::-moz-selection { background: rgba(49, 77, 103, .99); }
19 .cm-s-midnight .CodeMirror-gutters {background: #0F192A; border-right: 1px solid;}
16 .cm-s-midnight div.CodeMirror-selected { background: #314D67; }
17 .cm-s-midnight .CodeMirror-line::selection, .cm-s-midnight .CodeMirror-line > span::selection, .cm-s-midnight .CodeMirror-line > span > span::selection { background: rgba(49, 77, 103, .99); }
18 .cm-s-midnight .CodeMirror-line::-moz-selection, .cm-s-midnight .CodeMirror-line > span::-moz-selection, .cm-s-midnight .CodeMirror-line > span > span::-moz-selection { background: rgba(49, 77, 103, .99); }
19 .cm-s-midnight .CodeMirror-gutters { background: #0F192A; border-right: 1px solid; }
2020 .cm-s-midnight .CodeMirror-guttermarker { color: white; }
2121 .cm-s-midnight .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
22 .cm-s-midnight .CodeMirror-linenumber {color: #D0D0D0;}
23 .cm-s-midnight .CodeMirror-cursor {
24 border-left: 1px solid #F8F8F0 !important;
25 }
22 .cm-s-midnight .CodeMirror-linenumber { color: #D0D0D0; }
23 .cm-s-midnight .CodeMirror-cursor { border-left: 1px solid #F8F8F0; }
2624
27 .cm-s-midnight span.cm-comment {color: #428BDD;}
28 .cm-s-midnight span.cm-atom {color: #AE81FF;}
29 .cm-s-midnight span.cm-number {color: #D1EDFF;}
25 .cm-s-midnight span.cm-comment { color: #428BDD; }
26 .cm-s-midnight span.cm-atom { color: #AE81FF; }
27 .cm-s-midnight span.cm-number { color: #D1EDFF; }
3028
31 .cm-s-midnight span.cm-property, .cm-s-midnight span.cm-attribute {color: #A6E22E;}
32 .cm-s-midnight span.cm-keyword {color: #E83737;}
33 .cm-s-midnight span.cm-string {color: #1DC116;}
29 .cm-s-midnight span.cm-property, .cm-s-midnight span.cm-attribute { color: #A6E22E; }
30 .cm-s-midnight span.cm-keyword { color: #E83737; }
31 .cm-s-midnight span.cm-string { color: #1DC116; }
3432
35 .cm-s-midnight span.cm-variable {color: #FFAA3E;}
36 .cm-s-midnight span.cm-variable-2 {color: #FFAA3E;}
37 .cm-s-midnight span.cm-def {color: #4DD;}
38 .cm-s-midnight span.cm-bracket {color: #D1EDFF;}
39 .cm-s-midnight span.cm-tag {color: #449;}
40 .cm-s-midnight span.cm-link {color: #AE81FF;}
41 .cm-s-midnight span.cm-error {background: #F92672; color: #F8F8F0;}
33 .cm-s-midnight span.cm-variable { color: #FFAA3E; }
34 .cm-s-midnight span.cm-variable-2 { color: #FFAA3E; }
35 .cm-s-midnight span.cm-def { color: #4DD; }
36 .cm-s-midnight span.cm-bracket { color: #D1EDFF; }
37 .cm-s-midnight span.cm-tag { color: #449; }
38 .cm-s-midnight span.cm-link { color: #AE81FF; }
39 .cm-s-midnight span.cm-error { background: #F92672; color: #F8F8F0; }
4240
4341 .cm-s-midnight .CodeMirror-matchingbracket {
4442 text-decoration: underline;
00 /* Based on Sublime Text's Monokai theme */
11
2 .cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2;}
3 .cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
4 .cm-s-monokai.CodeMirror ::selection { background: rgba(73, 72, 62, .99); }
5 .cm-s-monokai.CodeMirror ::-moz-selection { background: rgba(73, 72, 62, .99); }
6 .cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;}
2 .cm-s-monokai.CodeMirror { background: #272822; color: #f8f8f2; }
3 .cm-s-monokai div.CodeMirror-selected { background: #49483E; }
4 .cm-s-monokai .CodeMirror-line::selection, .cm-s-monokai .CodeMirror-line > span::selection, .cm-s-monokai .CodeMirror-line > span > span::selection { background: rgba(73, 72, 62, .99); }
5 .cm-s-monokai .CodeMirror-line::-moz-selection, .cm-s-monokai .CodeMirror-line > span::-moz-selection, .cm-s-monokai .CodeMirror-line > span > span::-moz-selection { background: rgba(73, 72, 62, .99); }
6 .cm-s-monokai .CodeMirror-gutters { background: #272822; border-right: 0px; }
77 .cm-s-monokai .CodeMirror-guttermarker { color: white; }
88 .cm-s-monokai .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
9 .cm-s-monokai .CodeMirror-linenumber {color: #d0d0d0;}
10 .cm-s-monokai .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;}
9 .cm-s-monokai .CodeMirror-linenumber { color: #d0d0d0; }
10 .cm-s-monokai .CodeMirror-cursor { border-left: 1px solid #f8f8f0; }
1111
12 .cm-s-monokai span.cm-comment {color: #75715e;}
13 .cm-s-monokai span.cm-atom {color: #ae81ff;}
14 .cm-s-monokai span.cm-number {color: #ae81ff;}
12 .cm-s-monokai span.cm-comment { color: #75715e; }
13 .cm-s-monokai span.cm-atom { color: #ae81ff; }
14 .cm-s-monokai span.cm-number { color: #ae81ff; }
1515
16 .cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute {color: #a6e22e;}
17 .cm-s-monokai span.cm-keyword {color: #f92672;}
18 .cm-s-monokai span.cm-string {color: #e6db74;}
16 .cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute { color: #a6e22e; }
17 .cm-s-monokai span.cm-keyword { color: #f92672; }
18 .cm-s-monokai span.cm-builtin { color: #66d9ef; }
19 .cm-s-monokai span.cm-string { color: #e6db74; }
1920
20 .cm-s-monokai span.cm-variable {color: #f8f8f2;}
21 .cm-s-monokai span.cm-variable-2 {color: #9effff;}
22 .cm-s-monokai span.cm-variable-3 {color: #66d9ef;}
23 .cm-s-monokai span.cm-def {color: #fd971f;}
24 .cm-s-monokai span.cm-bracket {color: #f8f8f2;}
25 .cm-s-monokai span.cm-tag {color: #f92672;}
26 .cm-s-monokai span.cm-header {color: #ae81ff;}
27 .cm-s-monokai span.cm-link {color: #ae81ff;}
28 .cm-s-monokai span.cm-error {background: #f92672; color: #f8f8f0;}
21 .cm-s-monokai span.cm-variable { color: #f8f8f2; }
22 .cm-s-monokai span.cm-variable-2 { color: #9effff; }
23 .cm-s-monokai span.cm-variable-3 { color: #66d9ef; }
24 .cm-s-monokai span.cm-def { color: #fd971f; }
25 .cm-s-monokai span.cm-bracket { color: #f8f8f2; }
26 .cm-s-monokai span.cm-tag { color: #f92672; }
27 .cm-s-monokai span.cm-header { color: #ae81ff; }
28 .cm-s-monokai span.cm-link { color: #ae81ff; }
29 .cm-s-monokai span.cm-error { background: #f92672; color: #f8f8f0; }
2930
30 .cm-s-monokai .CodeMirror-activeline-background {background: #373831 !important;}
31 .cm-s-monokai .CodeMirror-activeline-background { background: #373831; }
3132 .cm-s-monokai .CodeMirror-matchingbracket {
3233 text-decoration: underline;
3334 color: white !important;
44 .cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
55 .cm-s-neat span.cm-variable { color: black; }
66 .cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
7 .cm-s-neat span.cm-meta {color: #555;}
7 .cm-s-neat span.cm-meta { color: #555; }
88 .cm-s-neat span.cm-link { color: #3a3; }
99
10 .cm-s-neat .CodeMirror-activeline-background {background: #e8f2ff !important;}
11 .cm-s-neat .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
10 .cm-s-neat .CodeMirror-activeline-background { background: #e8f2ff; }
11 .cm-s-neat .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
66 color:#2e383c;
77 line-height:1.4375;
88 }
9 .cm-s-neo .cm-comment {color:#75787b}
10 .cm-s-neo .cm-keyword, .cm-s-neo .cm-property {color:#1d75b3}
11 .cm-s-neo .cm-atom,.cm-s-neo .cm-number {color:#75438a}
12 .cm-s-neo .cm-node,.cm-s-neo .cm-tag {color:#9c3328}
13 .cm-s-neo .cm-string {color:#b35e14}
14 .cm-s-neo .cm-variable,.cm-s-neo .cm-qualifier {color:#047d65}
9 .cm-s-neo .cm-comment { color:#75787b; }
10 .cm-s-neo .cm-keyword, .cm-s-neo .cm-property { color:#1d75b3; }
11 .cm-s-neo .cm-atom,.cm-s-neo .cm-number { color:#75438a; }
12 .cm-s-neo .cm-node,.cm-s-neo .cm-tag { color:#9c3328; }
13 .cm-s-neo .cm-string { color:#b35e14; }
14 .cm-s-neo .cm-variable,.cm-s-neo .cm-qualifier { color:#047d65; }
1515
1616
1717 /* Editor styling */
3434 .cm-s-neo .CodeMirror-guttermarker { color: #1d75b3; }
3535 .cm-s-neo .CodeMirror-guttermarker-subtle { color: #e0e2e5; }
3636
37 .cm-s-neo div.CodeMirror-cursor {
37 .cm-s-neo .CodeMirror-cursor {
3838 width: auto;
3939 border: 0;
4040 background: rgba(155,157,162,0.37);
00 /* Loosely based on the Midnight Textmate theme */
11
22 .cm-s-night.CodeMirror { background: #0a001f; color: #f8f8f8; }
3 .cm-s-night div.CodeMirror-selected { background: #447 !important; }
4 .cm-s-night.CodeMirror ::selection { background: rgba(68, 68, 119, .99); }
5 .cm-s-night.CodeMirror ::-moz-selection { background: rgba(68, 68, 119, .99); }
3 .cm-s-night div.CodeMirror-selected { background: #447; }
4 .cm-s-night .CodeMirror-line::selection, .cm-s-night .CodeMirror-line > span::selection, .cm-s-night .CodeMirror-line > span > span::selection { background: rgba(68, 68, 119, .99); }
5 .cm-s-night .CodeMirror-line::-moz-selection, .cm-s-night .CodeMirror-line > span::-moz-selection, .cm-s-night .CodeMirror-line > span > span::-moz-selection { background: rgba(68, 68, 119, .99); }
66 .cm-s-night .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; }
77 .cm-s-night .CodeMirror-guttermarker { color: white; }
88 .cm-s-night .CodeMirror-guttermarker-subtle { color: #bbb; }
99 .cm-s-night .CodeMirror-linenumber { color: #f8f8f8; }
10 .cm-s-night .CodeMirror-cursor { border-left: 1px solid white !important; }
10 .cm-s-night .CodeMirror-cursor { border-left: 1px solid white; }
1111
12 .cm-s-night span.cm-comment { color: #6900a1; }
12 .cm-s-night span.cm-comment { color: #8900d1; }
1313 .cm-s-night span.cm-atom { color: #845dc4; }
1414 .cm-s-night span.cm-number, .cm-s-night span.cm-attribute { color: #ffd500; }
1515 .cm-s-night span.cm-keyword { color: #599eff; }
1818 .cm-s-night span.cm-variable-2, .cm-s-night span.cm-tag { color: #99b2ff; }
1919 .cm-s-night span.cm-variable-3, .cm-s-night span.cm-def { color: white; }
2020 .cm-s-night span.cm-bracket { color: #8da6ce; }
21 .cm-s-night span.cm-comment { color: #6900a1; }
2221 .cm-s-night span.cm-builtin, .cm-s-night span.cm-special { color: #ff9e59; }
2322 .cm-s-night span.cm-link { color: #845dc4; }
2423 .cm-s-night span.cm-error { color: #9d1e15; }
2524
26 .cm-s-night .CodeMirror-activeline-background {background: #1C005A !important;}
27 .cm-s-night .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
25 .cm-s-night .CodeMirror-activeline-background { background: #1C005A; }
26 .cm-s-night .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
0 /*
1 Name: Panda Syntax
2 Author: Siamak Mokhtari (http://github.com/siamak/)
3 CodeMirror template by Siamak Mokhtari (https://github.com/siamak/atom-panda-syntax)
4 */
5 .cm-s-panda-syntax {
6 background: #292A2B;
7 color: #E6E6E6;
8 line-height: 1.5;
9 font-family: 'Operator Mono', 'Source Sans Pro', Menlo, Monaco, Consolas, Courier New, monospace;
10 }
11 .cm-s-panda-syntax .CodeMirror-cursor { border-color: #ff2c6d; }
12 .cm-s-panda-syntax .CodeMirror-activeline-background {
13 background: rgba(99, 123, 156, 0.1);
14 }
15 .cm-s-panda-syntax .CodeMirror-selected {
16 background: #FFF;
17 }
18 .cm-s-panda-syntax .cm-comment {
19 font-style: italic;
20 color: #676B79;
21 }
22 .cm-s-panda-syntax .cm-operator {
23 color: #f3f3f3;
24 }
25 .cm-s-panda-syntax .cm-string {
26 color: #19F9D8;
27 }
28 .cm-s-panda-syntax .cm-string-2 {
29 color: #FFB86C;
30 }
31
32 .cm-s-panda-syntax .cm-tag {
33 color: #ff2c6d;
34 }
35 .cm-s-panda-syntax .cm-meta {
36 color: #b084eb;
37 }
38
39 .cm-s-panda-syntax .cm-number {
40 color: #FFB86C;
41 }
42 .cm-s-panda-syntax .cm-atom {
43 color: #ff2c6d;
44 }
45 .cm-s-panda-syntax .cm-keyword {
46 color: #FF75B5;
47 }
48 .cm-s-panda-syntax .cm-variable {
49 color: #ffb86c;
50 }
51 .cm-s-panda-syntax .cm-variable-2 {
52 color: #ff9ac1;
53 }
54 .cm-s-panda-syntax .cm-variable-3 {
55 color: #ff9ac1;
56 }
57
58 .cm-s-panda-syntax .cm-def {
59 color: #e6e6e6;
60 }
61 .cm-s-panda-syntax .cm-property {
62 color: #f3f3f3;
63 }
64 .cm-s-panda-syntax .cm-unit {
65 color: #ffb86c;
66 }
67
68 .cm-s-panda-syntax .cm-attribute {
69 color: #ffb86c;
70 }
71
72 .cm-s-panda-syntax .CodeMirror-matchingbracket {
73 border-bottom: 1px dotted #19F9D8;
74 padding-bottom: 2px;
75 color: #e6e6e6;
76 }
77 .CodeMirror-gutters {
78 background: #292a2b;
79 border-right-color: rgba(255, 255, 255, 0.1);
80 }
81 .CodeMirror-linenumber {
82 color: #e6e6e6;
83 opacity: 0.6;
84 }
77
88 */
99
10 .cm-s-paraiso-dark.CodeMirror {background: #2f1e2e; color: #b9b6b0;}
11 .cm-s-paraiso-dark div.CodeMirror-selected {background: #41323f !important;}
12 .cm-s-paraiso-dark.CodeMirror ::selection { background: rgba(65, 50, 63, .99); }
13 .cm-s-paraiso-dark.CodeMirror ::-moz-selection { background: rgba(65, 50, 63, .99); }
14 .cm-s-paraiso-dark .CodeMirror-gutters {background: #2f1e2e; border-right: 0px;}
10 .cm-s-paraiso-dark.CodeMirror { background: #2f1e2e; color: #b9b6b0; }
11 .cm-s-paraiso-dark div.CodeMirror-selected { background: #41323f; }
12 .cm-s-paraiso-dark .CodeMirror-line::selection, .cm-s-paraiso-dark .CodeMirror-line > span::selection, .cm-s-paraiso-dark .CodeMirror-line > span > span::selection { background: rgba(65, 50, 63, .99); }
13 .cm-s-paraiso-dark .CodeMirror-line::-moz-selection, .cm-s-paraiso-dark .CodeMirror-line > span::-moz-selection, .cm-s-paraiso-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(65, 50, 63, .99); }
14 .cm-s-paraiso-dark .CodeMirror-gutters { background: #2f1e2e; border-right: 0px; }
1515 .cm-s-paraiso-dark .CodeMirror-guttermarker { color: #ef6155; }
1616 .cm-s-paraiso-dark .CodeMirror-guttermarker-subtle { color: #776e71; }
17 .cm-s-paraiso-dark .CodeMirror-linenumber {color: #776e71;}
18 .cm-s-paraiso-dark .CodeMirror-cursor {border-left: 1px solid #8d8687 !important;}
17 .cm-s-paraiso-dark .CodeMirror-linenumber { color: #776e71; }
18 .cm-s-paraiso-dark .CodeMirror-cursor { border-left: 1px solid #8d8687; }
1919
20 .cm-s-paraiso-dark span.cm-comment {color: #e96ba8;}
21 .cm-s-paraiso-dark span.cm-atom {color: #815ba4;}
22 .cm-s-paraiso-dark span.cm-number {color: #815ba4;}
20 .cm-s-paraiso-dark span.cm-comment { color: #e96ba8; }
21 .cm-s-paraiso-dark span.cm-atom { color: #815ba4; }
22 .cm-s-paraiso-dark span.cm-number { color: #815ba4; }
2323
24 .cm-s-paraiso-dark span.cm-property, .cm-s-paraiso-dark span.cm-attribute {color: #48b685;}
25 .cm-s-paraiso-dark span.cm-keyword {color: #ef6155;}
26 .cm-s-paraiso-dark span.cm-string {color: #fec418;}
24 .cm-s-paraiso-dark span.cm-property, .cm-s-paraiso-dark span.cm-attribute { color: #48b685; }
25 .cm-s-paraiso-dark span.cm-keyword { color: #ef6155; }
26 .cm-s-paraiso-dark span.cm-string { color: #fec418; }
2727
28 .cm-s-paraiso-dark span.cm-variable {color: #48b685;}
29 .cm-s-paraiso-dark span.cm-variable-2 {color: #06b6ef;}
30 .cm-s-paraiso-dark span.cm-def {color: #f99b15;}
31 .cm-s-paraiso-dark span.cm-bracket {color: #b9b6b0;}
32 .cm-s-paraiso-dark span.cm-tag {color: #ef6155;}
33 .cm-s-paraiso-dark span.cm-link {color: #815ba4;}
34 .cm-s-paraiso-dark span.cm-error {background: #ef6155; color: #8d8687;}
28 .cm-s-paraiso-dark span.cm-variable { color: #48b685; }
29 .cm-s-paraiso-dark span.cm-variable-2 { color: #06b6ef; }
30 .cm-s-paraiso-dark span.cm-def { color: #f99b15; }
31 .cm-s-paraiso-dark span.cm-bracket { color: #b9b6b0; }
32 .cm-s-paraiso-dark span.cm-tag { color: #ef6155; }
33 .cm-s-paraiso-dark span.cm-link { color: #815ba4; }
34 .cm-s-paraiso-dark span.cm-error { background: #ef6155; color: #8d8687; }
3535
36 .cm-s-paraiso-dark .CodeMirror-activeline-background {background: #4D344A !important;}
37 .cm-s-paraiso-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
36 .cm-s-paraiso-dark .CodeMirror-activeline-background { background: #4D344A; }
37 .cm-s-paraiso-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
77
88 */
99
10 .cm-s-paraiso-light.CodeMirror {background: #e7e9db; color: #41323f;}
11 .cm-s-paraiso-light div.CodeMirror-selected {background: #b9b6b0 !important;}
12 .cm-s-paraiso-light.CodeMirror ::selection { background: #b9b6b0; }
13 .cm-s-paraiso-light.CodeMirror ::-moz-selection { background: #b9b6b0; }
14 .cm-s-paraiso-light .CodeMirror-gutters {background: #e7e9db; border-right: 0px;}
10 .cm-s-paraiso-light.CodeMirror { background: #e7e9db; color: #41323f; }
11 .cm-s-paraiso-light div.CodeMirror-selected { background: #b9b6b0; }
12 .cm-s-paraiso-light .CodeMirror-line::selection, .cm-s-paraiso-light .CodeMirror-line > span::selection, .cm-s-paraiso-light .CodeMirror-line > span > span::selection { background: #b9b6b0; }
13 .cm-s-paraiso-light .CodeMirror-line::-moz-selection, .cm-s-paraiso-light .CodeMirror-line > span::-moz-selection, .cm-s-paraiso-light .CodeMirror-line > span > span::-moz-selection { background: #b9b6b0; }
14 .cm-s-paraiso-light .CodeMirror-gutters { background: #e7e9db; border-right: 0px; }
1515 .cm-s-paraiso-light .CodeMirror-guttermarker { color: black; }
1616 .cm-s-paraiso-light .CodeMirror-guttermarker-subtle { color: #8d8687; }
17 .cm-s-paraiso-light .CodeMirror-linenumber {color: #8d8687;}
18 .cm-s-paraiso-light .CodeMirror-cursor {border-left: 1px solid #776e71 !important;}
17 .cm-s-paraiso-light .CodeMirror-linenumber { color: #8d8687; }
18 .cm-s-paraiso-light .CodeMirror-cursor { border-left: 1px solid #776e71; }
1919
20 .cm-s-paraiso-light span.cm-comment {color: #e96ba8;}
21 .cm-s-paraiso-light span.cm-atom {color: #815ba4;}
22 .cm-s-paraiso-light span.cm-number {color: #815ba4;}
20 .cm-s-paraiso-light span.cm-comment { color: #e96ba8; }
21 .cm-s-paraiso-light span.cm-atom { color: #815ba4; }
22 .cm-s-paraiso-light span.cm-number { color: #815ba4; }
2323
24 .cm-s-paraiso-light span.cm-property, .cm-s-paraiso-light span.cm-attribute {color: #48b685;}
25 .cm-s-paraiso-light span.cm-keyword {color: #ef6155;}
26 .cm-s-paraiso-light span.cm-string {color: #fec418;}
24 .cm-s-paraiso-light span.cm-property, .cm-s-paraiso-light span.cm-attribute { color: #48b685; }
25 .cm-s-paraiso-light span.cm-keyword { color: #ef6155; }
26 .cm-s-paraiso-light span.cm-string { color: #fec418; }
2727
28 .cm-s-paraiso-light span.cm-variable {color: #48b685;}
29 .cm-s-paraiso-light span.cm-variable-2 {color: #06b6ef;}
30 .cm-s-paraiso-light span.cm-def {color: #f99b15;}
31 .cm-s-paraiso-light span.cm-bracket {color: #41323f;}
32 .cm-s-paraiso-light span.cm-tag {color: #ef6155;}
33 .cm-s-paraiso-light span.cm-link {color: #815ba4;}
34 .cm-s-paraiso-light span.cm-error {background: #ef6155; color: #776e71;}
28 .cm-s-paraiso-light span.cm-variable { color: #48b685; }
29 .cm-s-paraiso-light span.cm-variable-2 { color: #06b6ef; }
30 .cm-s-paraiso-light span.cm-def { color: #f99b15; }
31 .cm-s-paraiso-light span.cm-bracket { color: #41323f; }
32 .cm-s-paraiso-light span.cm-tag { color: #ef6155; }
33 .cm-s-paraiso-light span.cm-link { color: #815ba4; }
34 .cm-s-paraiso-light span.cm-error { background: #ef6155; color: #776e71; }
3535
36 .cm-s-paraiso-light .CodeMirror-activeline-background {background: #CFD1C4 !important;}
37 .cm-s-paraiso-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
36 .cm-s-paraiso-light .CodeMirror-activeline-background { background: #CFD1C4; }
37 .cm-s-paraiso-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
1010 background: #2c2827;
1111 color: #8F938F;
1212 line-height: 1.5;
13 font-size: 14px;
1413 }
15 .cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2) !important; }
16 .cm-s-pastel-on-dark.CodeMirror ::selection { background: rgba(221,240,255,0.2); }
17 .cm-s-pastel-on-dark.CodeMirror ::-moz-selection { background: rgba(221,240,255,0.2); }
14 .cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2); }
15 .cm-s-pastel-on-dark .CodeMirror-line::selection, .cm-s-pastel-on-dark .CodeMirror-line > span::selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::selection { background: rgba(221,240,255,0.2); }
16 .cm-s-pastel-on-dark .CodeMirror-line::-moz-selection, .cm-s-pastel-on-dark .CodeMirror-line > span::-moz-selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(221,240,255,0.2); }
1817
1918 .cm-s-pastel-on-dark .CodeMirror-gutters {
2019 background: #34302f;
2423 .cm-s-pastel-on-dark .CodeMirror-guttermarker { color: white; }
2524 .cm-s-pastel-on-dark .CodeMirror-guttermarker-subtle { color: #8F938F; }
2625 .cm-s-pastel-on-dark .CodeMirror-linenumber { color: #8F938F; }
27 .cm-s-pastel-on-dark .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
26 .cm-s-pastel-on-dark .CodeMirror-cursor { border-left: 1px solid #A7A7A7; }
2827 .cm-s-pastel-on-dark span.cm-comment { color: #A6C6FF; }
2928 .cm-s-pastel-on-dark span.cm-atom { color: #DE8E30; }
3029 .cm-s-pastel-on-dark span.cm-number { color: #CCCCCC; }
4443 background: #757aD8;
4544 color: #f8f8f0;
4645 }
47 .cm-s-pastel-on-dark .CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.031) !important; }
46 .cm-s-pastel-on-dark .CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.031); }
4847 .cm-s-pastel-on-dark .CodeMirror-matchingbracket {
4948 border: 1px solid rgba(255,255,255,0.25);
5049 color: #8F938F !important;
0 /*
1
2 Name: Railscasts
3 Author: Ryan Bates (http://railscasts.com)
4
5 CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
6 Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
7
8 */
9
10 .cm-s-railscasts.CodeMirror {background: #2b2b2b; color: #f4f1ed;}
11 .cm-s-railscasts div.CodeMirror-selected {background: #272935 !important;}
12 .cm-s-railscasts .CodeMirror-gutters {background: #2b2b2b; border-right: 0px;}
13 .cm-s-railscasts .CodeMirror-linenumber {color: #5a647e;}
14 .cm-s-railscasts .CodeMirror-cursor {border-left: 1px solid #d4cfc9 !important;}
15
16 .cm-s-railscasts span.cm-comment {color: #bc9458;}
17 .cm-s-railscasts span.cm-atom {color: #b6b3eb;}
18 .cm-s-railscasts span.cm-number {color: #b6b3eb;}
19
20 .cm-s-railscasts span.cm-property, .cm-s-railscasts span.cm-attribute {color: #a5c261;}
21 .cm-s-railscasts span.cm-keyword {color: #da4939;}
22 .cm-s-railscasts span.cm-string {color: #ffc66d;}
23
24 .cm-s-railscasts span.cm-variable {color: #a5c261;}
25 .cm-s-railscasts span.cm-variable-2 {color: #6d9cbe;}
26 .cm-s-railscasts span.cm-def {color: #cc7833;}
27 .cm-s-railscasts span.cm-error {background: #da4939; color: #d4cfc9;}
28 .cm-s-railscasts span.cm-bracket {color: #f4f1ed;}
29 .cm-s-railscasts span.cm-tag {color: #da4939;}
30 .cm-s-railscasts span.cm-link {color: #b6b3eb;}
31
32 .cm-s-railscasts .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
33 .cm-s-railscasts .CodeMirror-activeline-background { background: #303040; }
00 .cm-s-rubyblue.CodeMirror { background: #112435; color: white; }
1 .cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; }
2 .cm-s-rubyblue.CodeMirror ::selection { background: rgba(56, 86, 111, 0.99); }
3 .cm-s-rubyblue.CodeMirror ::-moz-selection { background: rgba(56, 86, 111, 0.99); }
1 .cm-s-rubyblue div.CodeMirror-selected { background: #38566F; }
2 .cm-s-rubyblue .CodeMirror-line::selection, .cm-s-rubyblue .CodeMirror-line > span::selection, .cm-s-rubyblue .CodeMirror-line > span > span::selection { background: rgba(56, 86, 111, 0.99); }
3 .cm-s-rubyblue .CodeMirror-line::-moz-selection, .cm-s-rubyblue .CodeMirror-line > span::-moz-selection, .cm-s-rubyblue .CodeMirror-line > span > span::-moz-selection { background: rgba(56, 86, 111, 0.99); }
44 .cm-s-rubyblue .CodeMirror-gutters { background: #1F4661; border-right: 7px solid #3E7087; }
55 .cm-s-rubyblue .CodeMirror-guttermarker { color: white; }
66 .cm-s-rubyblue .CodeMirror-guttermarker-subtle { color: #3E7087; }
77 .cm-s-rubyblue .CodeMirror-linenumber { color: white; }
8 .cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
8 .cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white; }
99
1010 .cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
1111 .cm-s-rubyblue span.cm-atom { color: #F4C20B; }
2121 .cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }
2222 .cm-s-rubyblue span.cm-error { color: #AF2018; }
2323
24 .cm-s-rubyblue .CodeMirror-activeline-background {background: #173047 !important;}
24 .cm-s-rubyblue .CodeMirror-activeline-background { background: #173047; }
0 /*
1
2 Name: seti
3 Author: Michael Kaminsky (http://github.com/mkaminsky11)
4
5 Original seti color scheme by Jesse Weed (https://github.com/jesseweed/seti-syntax)
6
7 */
8
9
10 .cm-s-seti.CodeMirror {
11 background-color: #151718 !important;
12 color: #CFD2D1 !important;
13 border: none;
14 }
15 .cm-s-seti .CodeMirror-gutters {
16 color: #404b53;
17 background-color: #0E1112;
18 border: none;
19 }
20 .cm-s-seti .CodeMirror-cursor { border-left: solid thin #f8f8f0; }
21 .cm-s-seti .CodeMirror-linenumber { color: #6D8A88; }
22 .cm-s-seti.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
23 .cm-s-seti .CodeMirror-line::selection, .cm-s-seti .CodeMirror-line > span::selection, .cm-s-seti .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
24 .cm-s-seti .CodeMirror-line::-moz-selection, .cm-s-seti .CodeMirror-line > span::-moz-selection, .cm-s-seti .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
25 .cm-s-seti span.cm-comment { color: #41535b; }
26 .cm-s-seti span.cm-string, .cm-s-seti span.cm-string-2 { color: #55b5db; }
27 .cm-s-seti span.cm-number { color: #cd3f45; }
28 .cm-s-seti span.cm-variable { color: #55b5db; }
29 .cm-s-seti span.cm-variable-2 { color: #a074c4; }
30 .cm-s-seti span.cm-def { color: #55b5db; }
31 .cm-s-seti span.cm-keyword { color: #ff79c6; }
32 .cm-s-seti span.cm-operator { color: #9fca56; }
33 .cm-s-seti span.cm-keyword { color: #e6cd69; }
34 .cm-s-seti span.cm-atom { color: #cd3f45; }
35 .cm-s-seti span.cm-meta { color: #55b5db; }
36 .cm-s-seti span.cm-tag { color: #55b5db; }
37 .cm-s-seti span.cm-attribute { color: #9fca56; }
38 .cm-s-seti span.cm-qualifier { color: #9fca56; }
39 .cm-s-seti span.cm-property { color: #a074c4; }
40 .cm-s-seti span.cm-variable-3 { color: #9fca56; }
41 .cm-s-seti span.cm-builtin { color: #9fca56; }
42 .cm-s-seti .CodeMirror-activeline-background { background: #101213; }
43 .cm-s-seti .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
33 */
44
55 /*
6 Solarized color pallet
6 Solarized color palette
77 http://ethanschoonover.com/solarized/img/solarized-palette.png
88 */
99
3333 }
3434 .cm-s-solarized.cm-s-dark {
3535 color: #839496;
36 background-color: #002b36;
36 background-color: #002b36;
3737 text-shadow: #002b36 0 1px;
3838 }
3939 .cm-s-solarized.cm-s-light {
4949 .cm-s-solarized .cm-header { color: #586e75; }
5050 .cm-s-solarized .cm-quote { color: #93a1a1; }
5151
52 .cm-s-solarized .cm-keyword { color: #cb4b16 }
52 .cm-s-solarized .cm-keyword { color: #cb4b16; }
5353 .cm-s-solarized .cm-atom { color: #d33682; }
5454 .cm-s-solarized .cm-number { color: #d33682; }
5555 .cm-s-solarized .cm-def { color: #2aa198; }
5959 .cm-s-solarized .cm-variable-3 { color: #6c71c4; }
6060
6161 .cm-s-solarized .cm-property { color: #2aa198; }
62 .cm-s-solarized .cm-operator {color: #6c71c4;}
62 .cm-s-solarized .cm-operator { color: #6c71c4; }
6363
6464 .cm-s-solarized .cm-comment { color: #586e75; font-style:italic; }
6565
7272 .cm-s-solarized .cm-bracket { color: #cb4b16; }
7373 .cm-s-solarized .CodeMirror-matchingbracket { color: #859900; }
7474 .cm-s-solarized .CodeMirror-nonmatchingbracket { color: #dc322f; }
75 .cm-s-solarized .cm-tag { color: #93a1a1 }
76 .cm-s-solarized .cm-attribute { color: #2aa198; }
75 .cm-s-solarized .cm-tag { color: #93a1a1; }
76 .cm-s-solarized .cm-attribute { color: #2aa198; }
7777 .cm-s-solarized .cm-hr {
7878 color: transparent;
7979 border-top: 1px solid #586e75;
9393 border-bottom: 1px dotted #dc322f;
9494 }
9595
96 .cm-s-solarized.cm-s-dark .CodeMirror-selected { background: #073642; }
96 .cm-s-solarized.cm-s-dark div.CodeMirror-selected { background: #073642; }
9797 .cm-s-solarized.cm-s-dark.CodeMirror ::selection { background: rgba(7, 54, 66, 0.99); }
98 .cm-s-solarized.cm-s-dark.CodeMirror ::-moz-selection { background: rgba(7, 54, 66, 0.99); }
98 .cm-s-solarized.cm-s-dark .CodeMirror-line::-moz-selection, .cm-s-dark .CodeMirror-line > span::-moz-selection, .cm-s-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(7, 54, 66, 0.99); }
9999
100 .cm-s-solarized.cm-s-light .CodeMirror-selected { background: #eee8d5; }
101 .cm-s-solarized.cm-s-light.CodeMirror ::selection { background: #eee8d5; }
102 .cm-s-solarized.cm-s-lightCodeMirror ::-moz-selection { background: #eee8d5; }
100 .cm-s-solarized.cm-s-light div.CodeMirror-selected { background: #eee8d5; }
101 .cm-s-solarized.cm-s-light .CodeMirror-line::selection, .cm-s-light .CodeMirror-line > span::selection, .cm-s-light .CodeMirror-line > span > span::selection { background: #eee8d5; }
102 .cm-s-solarized.cm-s-light .CodeMirror-line::-moz-selection, .cm-s-ligh .CodeMirror-line > span::-moz-selection, .cm-s-ligh .CodeMirror-line > span > span::-moz-selection { background: #eee8d5; }
103103
104104 /* Editor styling */
105105
112112 box-shadow: inset 7px 0 12px -6px #000;
113113 }
114114
115 /* Gutter border and some shadow from it */
115 /* Remove gutter border */
116116 .cm-s-solarized .CodeMirror-gutters {
117 border-right: 1px solid;
117 border-right: 0;
118118 }
119119
120120 /* Gutter colors and line number styling based of color scheme (dark / light) */
121121
122122 /* Dark */
123123 .cm-s-solarized.cm-s-dark .CodeMirror-gutters {
124 background-color: #002b36;
125 border-color: #00232c;
124 background-color: #073642;
126125 }
127126
128127 .cm-s-solarized.cm-s-dark .CodeMirror-linenumber {
128 color: #586e75;
129129 text-shadow: #021014 0 -1px;
130130 }
131131
132132 /* Light */
133133 .cm-s-solarized.cm-s-light .CodeMirror-gutters {
134 background-color: #fdf6e3;
135 border-color: #eee8d5;
134 background-color: #eee8d5;
135 }
136
137 .cm-s-solarized.cm-s-light .CodeMirror-linenumber {
138 color: #839496;
136139 }
137140
138141 /* Common */
139142 .cm-s-solarized .CodeMirror-linenumber {
140 color: #586e75;
141143 padding: 0 5px;
142144 }
143145 .cm-s-solarized .CodeMirror-guttermarker-subtle { color: #586e75; }
148150 color: #586e75;
149151 }
150152
151 .cm-s-solarized .CodeMirror-lines .CodeMirror-cursor {
152 border-left: 1px solid #819090;
153 }
153 /* Cursor */
154 .cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; }
154155
155 /*
156 Active line. Negative margin compensates left padding of the text in the
157 view-port
158 */
156 /* Fat cursor */
157 .cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #77ee77; }
158 .cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #77ee77; }
159 .cm-s-solarized.cm-s-dark.cm-fat-cursor .CodeMirror-cursor { background: #586e75; }
160 .cm-s-solarized.cm-s-dark .cm-animate-fat-cursor { background-color: #586e75; }
161
162 /* Active line */
159163 .cm-s-solarized.cm-s-dark .CodeMirror-activeline-background {
160 background: rgba(255, 255, 255, 0.10);
164 background: rgba(255, 255, 255, 0.06);
161165 }
162166 .cm-s-solarized.cm-s-light .CodeMirror-activeline-background {
163 background: rgba(0, 0, 0, 0.10);
167 background: rgba(0, 0, 0, 0.06);
164168 }
00 .cm-s-the-matrix.CodeMirror { background: #000000; color: #00FF00; }
1 .cm-s-the-matrix div.CodeMirror-selected { background: #2D2D2D !important; }
2 .cm-s-the-matrix.CodeMirror ::selection { background: rgba(45, 45, 45, 0.99); }
3 .cm-s-the-matrix.CodeMirror ::-moz-selection { background: rgba(45, 45, 45, 0.99); }
1 .cm-s-the-matrix div.CodeMirror-selected { background: #2D2D2D; }
2 .cm-s-the-matrix .CodeMirror-line::selection, .cm-s-the-matrix .CodeMirror-line > span::selection, .cm-s-the-matrix .CodeMirror-line > span > span::selection { background: rgba(45, 45, 45, 0.99); }
3 .cm-s-the-matrix .CodeMirror-line::-moz-selection, .cm-s-the-matrix .CodeMirror-line > span::-moz-selection, .cm-s-the-matrix .CodeMirror-line > span > span::-moz-selection { background: rgba(45, 45, 45, 0.99); }
44 .cm-s-the-matrix .CodeMirror-gutters { background: #060; border-right: 2px solid #00FF00; }
55 .cm-s-the-matrix .CodeMirror-guttermarker { color: #0f0; }
66 .cm-s-the-matrix .CodeMirror-guttermarker-subtle { color: white; }
77 .cm-s-the-matrix .CodeMirror-linenumber { color: #FFFFFF; }
8 .cm-s-the-matrix .CodeMirror-cursor { border-left: 1px solid #00FF00 !important; }
8 .cm-s-the-matrix .CodeMirror-cursor { border-left: 1px solid #00FF00; }
99
10 .cm-s-the-matrix span.cm-keyword {color: #008803; font-weight: bold;}
11 .cm-s-the-matrix span.cm-atom {color: #3FF;}
12 .cm-s-the-matrix span.cm-number {color: #FFB94F;}
13 .cm-s-the-matrix span.cm-def {color: #99C;}
14 .cm-s-the-matrix span.cm-variable {color: #F6C;}
15 .cm-s-the-matrix span.cm-variable-2 {color: #C6F;}
16 .cm-s-the-matrix span.cm-variable-3 {color: #96F;}
17 .cm-s-the-matrix span.cm-property {color: #62FFA0;}
18 .cm-s-the-matrix span.cm-operator {color: #999}
19 .cm-s-the-matrix span.cm-comment {color: #CCCCCC;}
20 .cm-s-the-matrix span.cm-string {color: #39C;}
21 .cm-s-the-matrix span.cm-meta {color: #C9F;}
22 .cm-s-the-matrix span.cm-qualifier {color: #FFF700;}
23 .cm-s-the-matrix span.cm-builtin {color: #30a;}
24 .cm-s-the-matrix span.cm-bracket {color: #cc7;}
25 .cm-s-the-matrix span.cm-tag {color: #FFBD40;}
26 .cm-s-the-matrix span.cm-attribute {color: #FFF700;}
27 .cm-s-the-matrix span.cm-error {color: #FF0000;}
10 .cm-s-the-matrix span.cm-keyword { color: #008803; font-weight: bold; }
11 .cm-s-the-matrix span.cm-atom { color: #3FF; }
12 .cm-s-the-matrix span.cm-number { color: #FFB94F; }
13 .cm-s-the-matrix span.cm-def { color: #99C; }
14 .cm-s-the-matrix span.cm-variable { color: #F6C; }
15 .cm-s-the-matrix span.cm-variable-2 { color: #C6F; }
16 .cm-s-the-matrix span.cm-variable-3 { color: #96F; }
17 .cm-s-the-matrix span.cm-property { color: #62FFA0; }
18 .cm-s-the-matrix span.cm-operator { color: #999; }
19 .cm-s-the-matrix span.cm-comment { color: #CCCCCC; }
20 .cm-s-the-matrix span.cm-string { color: #39C; }
21 .cm-s-the-matrix span.cm-meta { color: #C9F; }
22 .cm-s-the-matrix span.cm-qualifier { color: #FFF700; }
23 .cm-s-the-matrix span.cm-builtin { color: #30a; }
24 .cm-s-the-matrix span.cm-bracket { color: #cc7; }
25 .cm-s-the-matrix span.cm-tag { color: #FFBD40; }
26 .cm-s-the-matrix span.cm-attribute { color: #FFF700; }
27 .cm-s-the-matrix span.cm-error { color: #FF0000; }
2828
29 .cm-s-the-matrix .CodeMirror-activeline-background {background: #040;}
29 .cm-s-the-matrix .CodeMirror-activeline-background { background: #040; }
66
77 */
88
9 .cm-s-tomorrow-night-bright.CodeMirror {background: #000000; color: #eaeaea;}
10 .cm-s-tomorrow-night-bright div.CodeMirror-selected {background: #424242 !important;}
11 .cm-s-tomorrow-night-bright .CodeMirror-gutters {background: #000000; border-right: 0px;}
9 .cm-s-tomorrow-night-bright.CodeMirror { background: #000000; color: #eaeaea; }
10 .cm-s-tomorrow-night-bright div.CodeMirror-selected { background: #424242; }
11 .cm-s-tomorrow-night-bright .CodeMirror-gutters { background: #000000; border-right: 0px; }
1212 .cm-s-tomorrow-night-bright .CodeMirror-guttermarker { color: #e78c45; }
1313 .cm-s-tomorrow-night-bright .CodeMirror-guttermarker-subtle { color: #777; }
14 .cm-s-tomorrow-night-bright .CodeMirror-linenumber {color: #424242;}
15 .cm-s-tomorrow-night-bright .CodeMirror-cursor {border-left: 1px solid #6A6A6A !important;}
14 .cm-s-tomorrow-night-bright .CodeMirror-linenumber { color: #424242; }
15 .cm-s-tomorrow-night-bright .CodeMirror-cursor { border-left: 1px solid #6A6A6A; }
1616
17 .cm-s-tomorrow-night-bright span.cm-comment {color: #d27b53;}
18 .cm-s-tomorrow-night-bright span.cm-atom {color: #a16a94;}
19 .cm-s-tomorrow-night-bright span.cm-number {color: #a16a94;}
17 .cm-s-tomorrow-night-bright span.cm-comment { color: #d27b53; }
18 .cm-s-tomorrow-night-bright span.cm-atom { color: #a16a94; }
19 .cm-s-tomorrow-night-bright span.cm-number { color: #a16a94; }
2020
21 .cm-s-tomorrow-night-bright span.cm-property, .cm-s-tomorrow-night-bright span.cm-attribute {color: #99cc99;}
22 .cm-s-tomorrow-night-bright span.cm-keyword {color: #d54e53;}
23 .cm-s-tomorrow-night-bright span.cm-string {color: #e7c547;}
21 .cm-s-tomorrow-night-bright span.cm-property, .cm-s-tomorrow-night-bright span.cm-attribute { color: #99cc99; }
22 .cm-s-tomorrow-night-bright span.cm-keyword { color: #d54e53; }
23 .cm-s-tomorrow-night-bright span.cm-string { color: #e7c547; }
2424
25 .cm-s-tomorrow-night-bright span.cm-variable {color: #b9ca4a;}
26 .cm-s-tomorrow-night-bright span.cm-variable-2 {color: #7aa6da;}
27 .cm-s-tomorrow-night-bright span.cm-def {color: #e78c45;}
28 .cm-s-tomorrow-night-bright span.cm-bracket {color: #eaeaea;}
29 .cm-s-tomorrow-night-bright span.cm-tag {color: #d54e53;}
30 .cm-s-tomorrow-night-bright span.cm-link {color: #a16a94;}
31 .cm-s-tomorrow-night-bright span.cm-error {background: #d54e53; color: #6A6A6A;}
25 .cm-s-tomorrow-night-bright span.cm-variable { color: #b9ca4a; }
26 .cm-s-tomorrow-night-bright span.cm-variable-2 { color: #7aa6da; }
27 .cm-s-tomorrow-night-bright span.cm-def { color: #e78c45; }
28 .cm-s-tomorrow-night-bright span.cm-bracket { color: #eaeaea; }
29 .cm-s-tomorrow-night-bright span.cm-tag { color: #d54e53; }
30 .cm-s-tomorrow-night-bright span.cm-link { color: #a16a94; }
31 .cm-s-tomorrow-night-bright span.cm-error { background: #d54e53; color: #6A6A6A; }
3232
33 .cm-s-tomorrow-night-bright .CodeMirror-activeline-background {background: #2a2a2a !important;}
34 .cm-s-tomorrow-night-bright .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
33 .cm-s-tomorrow-night-bright .CodeMirror-activeline-background { background: #2a2a2a; }
34 .cm-s-tomorrow-night-bright .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
77
88 */
99
10 .cm-s-tomorrow-night-eighties.CodeMirror {background: #000000; color: #CCCCCC;}
11 .cm-s-tomorrow-night-eighties div.CodeMirror-selected {background: #2D2D2D !important;}
12 .cm-s-tomorrow-night-eighties.CodeMirror ::selection { background: rgba(45, 45, 45, 0.99); }
13 .cm-s-tomorrow-night-eighties.CodeMirror ::-moz-selection { background: rgba(45, 45, 45, 0.99); }
14 .cm-s-tomorrow-night-eighties .CodeMirror-gutters {background: #000000; border-right: 0px;}
10 .cm-s-tomorrow-night-eighties.CodeMirror { background: #000000; color: #CCCCCC; }
11 .cm-s-tomorrow-night-eighties div.CodeMirror-selected { background: #2D2D2D; }
12 .cm-s-tomorrow-night-eighties .CodeMirror-line::selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span::selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span > span::selection { background: rgba(45, 45, 45, 0.99); }
13 .cm-s-tomorrow-night-eighties .CodeMirror-line::-moz-selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span::-moz-selection, .cm-s-tomorrow-night-eighties .CodeMirror-line > span > span::-moz-selection { background: rgba(45, 45, 45, 0.99); }
14 .cm-s-tomorrow-night-eighties .CodeMirror-gutters { background: #000000; border-right: 0px; }
1515 .cm-s-tomorrow-night-eighties .CodeMirror-guttermarker { color: #f2777a; }
1616 .cm-s-tomorrow-night-eighties .CodeMirror-guttermarker-subtle { color: #777; }
17 .cm-s-tomorrow-night-eighties .CodeMirror-linenumber {color: #515151;}
18 .cm-s-tomorrow-night-eighties .CodeMirror-cursor {border-left: 1px solid #6A6A6A !important;}
17 .cm-s-tomorrow-night-eighties .CodeMirror-linenumber { color: #515151; }
18 .cm-s-tomorrow-night-eighties .CodeMirror-cursor { border-left: 1px solid #6A6A6A; }
1919
20 .cm-s-tomorrow-night-eighties span.cm-comment {color: #d27b53;}
21 .cm-s-tomorrow-night-eighties span.cm-atom {color: #a16a94;}
22 .cm-s-tomorrow-night-eighties span.cm-number {color: #a16a94;}
20 .cm-s-tomorrow-night-eighties span.cm-comment { color: #d27b53; }
21 .cm-s-tomorrow-night-eighties span.cm-atom { color: #a16a94; }
22 .cm-s-tomorrow-night-eighties span.cm-number { color: #a16a94; }
2323
24 .cm-s-tomorrow-night-eighties span.cm-property, .cm-s-tomorrow-night-eighties span.cm-attribute {color: #99cc99;}
25 .cm-s-tomorrow-night-eighties span.cm-keyword {color: #f2777a;}
26 .cm-s-tomorrow-night-eighties span.cm-string {color: #ffcc66;}
24 .cm-s-tomorrow-night-eighties span.cm-property, .cm-s-tomorrow-night-eighties span.cm-attribute { color: #99cc99; }
25 .cm-s-tomorrow-night-eighties span.cm-keyword { color: #f2777a; }
26 .cm-s-tomorrow-night-eighties span.cm-string { color: #ffcc66; }
2727
28 .cm-s-tomorrow-night-eighties span.cm-variable {color: #99cc99;}
29 .cm-s-tomorrow-night-eighties span.cm-variable-2 {color: #6699cc;}
30 .cm-s-tomorrow-night-eighties span.cm-def {color: #f99157;}
31 .cm-s-tomorrow-night-eighties span.cm-bracket {color: #CCCCCC;}
32 .cm-s-tomorrow-night-eighties span.cm-tag {color: #f2777a;}
33 .cm-s-tomorrow-night-eighties span.cm-link {color: #a16a94;}
34 .cm-s-tomorrow-night-eighties span.cm-error {background: #f2777a; color: #6A6A6A;}
28 .cm-s-tomorrow-night-eighties span.cm-variable { color: #99cc99; }
29 .cm-s-tomorrow-night-eighties span.cm-variable-2 { color: #6699cc; }
30 .cm-s-tomorrow-night-eighties span.cm-def { color: #f99157; }
31 .cm-s-tomorrow-night-eighties span.cm-bracket { color: #CCCCCC; }
32 .cm-s-tomorrow-night-eighties span.cm-tag { color: #f2777a; }
33 .cm-s-tomorrow-night-eighties span.cm-link { color: #a16a94; }
34 .cm-s-tomorrow-night-eighties span.cm-error { background: #f2777a; color: #6A6A6A; }
3535
36 .cm-s-tomorrow-night-eighties .CodeMirror-activeline-background {background: #343600 !important;}
37 .cm-s-tomorrow-night-eighties .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
36 .cm-s-tomorrow-night-eighties .CodeMirror-activeline-background { background: #343600; }
37 .cm-s-tomorrow-night-eighties .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
0 .cm-quote {color: #090;}
1 .cm-negative {color: #d44;}
2 .cm-positive {color: #292;}
3 .cm-header, .cm-strong {font-weight: bold;}
4 .cm-em {font-style: italic;}
5 .cm-link {text-decoration: underline;}
6 .cm-strikethrough {text-decoration: line-through;}
7 .cm-header {color: #00f; font-weight: bold;}
0 .cm-s-ttcn .cm-quote { color: #090; }
1 .cm-s-ttcn .cm-negative { color: #d44; }
2 .cm-s-ttcn .cm-positive { color: #292; }
3 .cm-s-ttcn .cm-header, .cm-strong { font-weight: bold; }
4 .cm-s-ttcn .cm-em { font-style: italic; }
5 .cm-s-ttcn .cm-link { text-decoration: underline; }
6 .cm-s-ttcn .cm-strikethrough { text-decoration: line-through; }
7 .cm-s-ttcn .cm-header { color: #00f; font-weight: bold; }
88
9 .cm-atom {color: #219;}
10 .cm-attribute {color: #00c;}
11 .cm-bracket {color: #997;}
12 .cm-comment {color: #333333;}
13 .cm-def {color: #00f;}
14 .cm-em {font-style: italic;}
15 .cm-error {color: #f00;}
16 .cm-hr {color: #999;}
17 .cm-invalidchar {color: #f00;}
18 .cm-keyword {font-weight:bold}
19 .cm-link {color: #00c; text-decoration: underline;}
20 .cm-meta {color: #555;}
21 .cm-negative {color: #d44;}
22 .cm-positive {color: #292;}
23 .cm-qualifier {color: #555;}
24 .cm-strikethrough {text-decoration: line-through;}
25 .cm-string {color: #006400;}
26 .cm-string-2 {color: #f50;}
27 .cm-strong {font-weight: bold;}
28 .cm-tag {color: #170;}
29 .cm-variable {color: #8B2252;}
30 .cm-variable-2 {color: #05a;}
31 .cm-variable-3 {color: #085;}
9 .cm-s-ttcn .cm-atom { color: #219; }
10 .cm-s-ttcn .cm-attribute { color: #00c; }
11 .cm-s-ttcn .cm-bracket { color: #997; }
12 .cm-s-ttcn .cm-comment { color: #333333; }
13 .cm-s-ttcn .cm-def { color: #00f; }
14 .cm-s-ttcn .cm-em { font-style: italic; }
15 .cm-s-ttcn .cm-error { color: #f00; }
16 .cm-s-ttcn .cm-hr { color: #999; }
17 .cm-s-ttcn .cm-invalidchar { color: #f00; }
18 .cm-s-ttcn .cm-keyword { font-weight:bold; }
19 .cm-s-ttcn .cm-link { color: #00c; text-decoration: underline; }
20 .cm-s-ttcn .cm-meta { color: #555; }
21 .cm-s-ttcn .cm-negative { color: #d44; }
22 .cm-s-ttcn .cm-positive { color: #292; }
23 .cm-s-ttcn .cm-qualifier { color: #555; }
24 .cm-s-ttcn .cm-strikethrough { text-decoration: line-through; }
25 .cm-s-ttcn .cm-string { color: #006400; }
26 .cm-s-ttcn .cm-string-2 { color: #f50; }
27 .cm-s-ttcn .cm-strong { font-weight: bold; }
28 .cm-s-ttcn .cm-tag { color: #170; }
29 .cm-s-ttcn .cm-variable { color: #8B2252; }
30 .cm-s-ttcn .cm-variable-2 { color: #05a; }
31 .cm-s-ttcn .cm-variable-3 { color: #085; }
3232
33 .cm-s-default .cm-error {color: #f00;}
34 .cm-invalidchar {color: #f00;}
33 .cm-s-ttcn .cm-invalidchar { color: #f00; }
3534
3635 /* ASN */
3736 .cm-s-ttcn .cm-accessTypes,
38 .cm-s-ttcn .cm-compareTypes {color: #27408B}
39 .cm-s-ttcn .cm-cmipVerbs {color: #8B2252}
40 .cm-s-ttcn .cm-modifier {color:#D2691E}
41 .cm-s-ttcn .cm-status {color:#8B4545}
42 .cm-s-ttcn .cm-storage {color:#A020F0}
43 .cm-s-ttcn .cm-tags {color:#006400}
37 .cm-s-ttcn .cm-compareTypes { color: #27408B; }
38 .cm-s-ttcn .cm-cmipVerbs { color: #8B2252; }
39 .cm-s-ttcn .cm-modifier { color:#D2691E; }
40 .cm-s-ttcn .cm-status { color:#8B4545; }
41 .cm-s-ttcn .cm-storage { color:#A020F0; }
42 .cm-s-ttcn .cm-tags { color:#006400; }
4443
4544 /* CFG */
46 .cm-s-ttcn .cm-externalCommands {color: #8B4545; font-weight:bold}
45 .cm-s-ttcn .cm-externalCommands { color: #8B4545; font-weight:bold; }
4746 .cm-s-ttcn .cm-fileNCtrlMaskOptions,
48 .cm-s-ttcn .cm-sectionTitle {color: #2E8B57; font-weight:bold}
47 .cm-s-ttcn .cm-sectionTitle { color: #2E8B57; font-weight:bold; }
4948
5049 /* TTCN */
5150 .cm-s-ttcn .cm-booleanConsts,
5251 .cm-s-ttcn .cm-otherConsts,
53 .cm-s-ttcn .cm-verdictConsts {color: #006400}
52 .cm-s-ttcn .cm-verdictConsts { color: #006400; }
5453 .cm-s-ttcn .cm-configOps,
5554 .cm-s-ttcn .cm-functionOps,
5655 .cm-s-ttcn .cm-portOps,
5756 .cm-s-ttcn .cm-sutOps,
5857 .cm-s-ttcn .cm-timerOps,
59 .cm-s-ttcn .cm-verdictOps {color: #0000FF}
58 .cm-s-ttcn .cm-verdictOps { color: #0000FF; }
6059 .cm-s-ttcn .cm-preprocessor,
6160 .cm-s-ttcn .cm-templateMatch,
62 .cm-s-ttcn .cm-ttcn3Macros {color: #27408B}
63 .cm-s-ttcn .cm-types {color: #A52A2A; font-weight:bold}
64 .cm-s-ttcn .cm-visibilityModifiers {font-weight:bold}
61 .cm-s-ttcn .cm-ttcn3Macros { color: #27408B; }
62 .cm-s-ttcn .cm-types { color: #A52A2A; font-weight:bold; }
63 .cm-s-ttcn .cm-visibilityModifiers { font-weight:bold; }
00 .cm-s-twilight.CodeMirror { background: #141414; color: #f7f7f7; } /**/
1 .cm-s-twilight .CodeMirror-selected { background: #323232 !important; } /**/
2 .cm-s-twilight.CodeMirror ::selection { background: rgba(50, 50, 50, 0.99); }
3 .cm-s-twilight.CodeMirror ::-moz-selection { background: rgba(50, 50, 50, 0.99); }
1 .cm-s-twilight div.CodeMirror-selected { background: #323232; } /**/
2 .cm-s-twilight .CodeMirror-line::selection, .cm-s-twilight .CodeMirror-line > span::selection, .cm-s-twilight .CodeMirror-line > span > span::selection { background: rgba(50, 50, 50, 0.99); }
3 .cm-s-twilight .CodeMirror-line::-moz-selection, .cm-s-twilight .CodeMirror-line > span::-moz-selection, .cm-s-twilight .CodeMirror-line > span > span::-moz-selection { background: rgba(50, 50, 50, 0.99); }
44
55 .cm-s-twilight .CodeMirror-gutters { background: #222; border-right: 1px solid #aaa; }
66 .cm-s-twilight .CodeMirror-guttermarker { color: white; }
77 .cm-s-twilight .CodeMirror-guttermarker-subtle { color: #aaa; }
88 .cm-s-twilight .CodeMirror-linenumber { color: #aaa; }
9 .cm-s-twilight .CodeMirror-cursor { border-left: 1px solid white !important; }
9 .cm-s-twilight .CodeMirror-cursor { border-left: 1px solid white; }
1010
11 .cm-s-twilight .cm-keyword { color: #f9ee98; } /**/
11 .cm-s-twilight .cm-keyword { color: #f9ee98; } /**/
1212 .cm-s-twilight .cm-atom { color: #FC0; }
1313 .cm-s-twilight .cm-number { color: #ca7841; } /**/
1414 .cm-s-twilight .cm-def { color: #8DA6CE; }
1717 .cm-s-twilight .cm-operator { color: #cda869; } /**/
1818 .cm-s-twilight .cm-comment { color:#777; font-style:italic; font-weight:normal; } /**/
1919 .cm-s-twilight .cm-string { color:#8f9d6a; font-style:italic; } /**/
20 .cm-s-twilight .cm-string-2 { color:#bd6b18 } /*?*/
20 .cm-s-twilight .cm-string-2 { color:#bd6b18; } /*?*/
2121 .cm-s-twilight .cm-meta { background-color:#141414; color:#f7f7f7; } /*?*/
2222 .cm-s-twilight .cm-builtin { color: #cda869; } /*?*/
2323 .cm-s-twilight .cm-tag { color: #997643; } /**/
2424 .cm-s-twilight .cm-attribute { color: #d6bb6d; } /*?*/
2525 .cm-s-twilight .cm-header { color: #FF6400; }
2626 .cm-s-twilight .cm-hr { color: #AEAEAE; }
27 .cm-s-twilight .cm-link { color:#ad9361; font-style:italic; text-decoration:none; } /**/
27 .cm-s-twilight .cm-link { color:#ad9361; font-style:italic; text-decoration:none; } /**/
2828 .cm-s-twilight .cm-error { border-bottom: 1px solid red; }
2929
30 .cm-s-twilight .CodeMirror-activeline-background {background: #27282E !important;}
31 .cm-s-twilight .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
30 .cm-s-twilight .CodeMirror-activeline-background { background: #27282E; }
31 .cm-s-twilight .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
00 /* Taken from the popular Visual Studio Vibrant Ink Schema */
11
22 .cm-s-vibrant-ink.CodeMirror { background: black; color: white; }
3 .cm-s-vibrant-ink .CodeMirror-selected { background: #35493c !important; }
4 .cm-s-vibrant-ink.CodeMirror ::selection { background: rgba(53, 73, 60, 0.99); }
5 .cm-s-vibrant-ink.CodeMirror ::-moz-selection { background: rgba(53, 73, 60, 0.99); }
3 .cm-s-vibrant-ink div.CodeMirror-selected { background: #35493c; }
4 .cm-s-vibrant-ink .CodeMirror-line::selection, .cm-s-vibrant-ink .CodeMirror-line > span::selection, .cm-s-vibrant-ink .CodeMirror-line > span > span::selection { background: rgba(53, 73, 60, 0.99); }
5 .cm-s-vibrant-ink .CodeMirror-line::-moz-selection, .cm-s-vibrant-ink .CodeMirror-line > span::-moz-selection, .cm-s-vibrant-ink .CodeMirror-line > span > span::-moz-selection { background: rgba(53, 73, 60, 0.99); }
66
77 .cm-s-vibrant-ink .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
88 .cm-s-vibrant-ink .CodeMirror-guttermarker { color: white; }
99 .cm-s-vibrant-ink .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
1010 .cm-s-vibrant-ink .CodeMirror-linenumber { color: #d0d0d0; }
11 .cm-s-vibrant-ink .CodeMirror-cursor { border-left: 1px solid white !important; }
11 .cm-s-vibrant-ink .CodeMirror-cursor { border-left: 1px solid white; }
1212
13 .cm-s-vibrant-ink .cm-keyword { color: #CC7832; }
13 .cm-s-vibrant-ink .cm-keyword { color: #CC7832; }
1414 .cm-s-vibrant-ink .cm-atom { color: #FC0; }
1515 .cm-s-vibrant-ink .cm-number { color: #FFEE98; }
1616 .cm-s-vibrant-ink .cm-def { color: #8DA6CE; }
17 .cm-s-vibrant-ink span.cm-variable-2, .cm-s-vibrant span.cm-tag { color: #FFC66D }
18 .cm-s-vibrant-ink span.cm-variable-3, .cm-s-vibrant span.cm-def { color: #FFC66D }
17 .cm-s-vibrant-ink span.cm-variable-2, .cm-s-vibrant span.cm-tag { color: #FFC66D; }
18 .cm-s-vibrant-ink span.cm-variable-3, .cm-s-vibrant span.cm-def { color: #FFC66D; }
1919 .cm-s-vibrant-ink .cm-operator { color: #888; }
2020 .cm-s-vibrant-ink .cm-comment { color: gray; font-weight: bold; }
21 .cm-s-vibrant-ink .cm-string { color: #A5C25C }
22 .cm-s-vibrant-ink .cm-string-2 { color: red }
21 .cm-s-vibrant-ink .cm-string { color: #A5C25C; }
22 .cm-s-vibrant-ink .cm-string-2 { color: red; }
2323 .cm-s-vibrant-ink .cm-meta { color: #D8FA3C; }
2424 .cm-s-vibrant-ink .cm-builtin { color: #8DA6CE; }
2525 .cm-s-vibrant-ink .cm-tag { color: #8DA6CE; }
2929 .cm-s-vibrant-ink .cm-link { color: blue; }
3030 .cm-s-vibrant-ink .cm-error { border-bottom: 1px solid red; }
3131
32 .cm-s-vibrant-ink .CodeMirror-activeline-background {background: #27282E !important;}
33 .cm-s-vibrant-ink .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
32 .cm-s-vibrant-ink .CodeMirror-activeline-background { background: #27282E; }
33 .cm-s-vibrant-ink .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
2020 THE SOFTWARE.
2121 */
2222 .cm-s-xq-dark.CodeMirror { background: #0a001f; color: #f8f8f8; }
23 .cm-s-xq-dark .CodeMirror-selected { background: #27007A !important; }
24 .cm-s-xq-dark.CodeMirror ::selection { background: rgba(39, 0, 122, 0.99); }
25 .cm-s-xq-dark.CodeMirror ::-moz-selection { background: rgba(39, 0, 122, 0.99); }
23 .cm-s-xq-dark div.CodeMirror-selected { background: #27007A; }
24 .cm-s-xq-dark .CodeMirror-line::selection, .cm-s-xq-dark .CodeMirror-line > span::selection, .cm-s-xq-dark .CodeMirror-line > span > span::selection { background: rgba(39, 0, 122, 0.99); }
25 .cm-s-xq-dark .CodeMirror-line::-moz-selection, .cm-s-xq-dark .CodeMirror-line > span::-moz-selection, .cm-s-xq-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(39, 0, 122, 0.99); }
2626 .cm-s-xq-dark .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; }
2727 .cm-s-xq-dark .CodeMirror-guttermarker { color: #FFBD40; }
2828 .cm-s-xq-dark .CodeMirror-guttermarker-subtle { color: #f8f8f8; }
2929 .cm-s-xq-dark .CodeMirror-linenumber { color: #f8f8f8; }
30 .cm-s-xq-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
30 .cm-s-xq-dark .CodeMirror-cursor { border-left: 1px solid white; }
3131
32 .cm-s-xq-dark span.cm-keyword {color: #FFBD40;}
33 .cm-s-xq-dark span.cm-atom {color: #6C8CD5;}
34 .cm-s-xq-dark span.cm-number {color: #164;}
35 .cm-s-xq-dark span.cm-def {color: #FFF; text-decoration:underline;}
36 .cm-s-xq-dark span.cm-variable {color: #FFF;}
37 .cm-s-xq-dark span.cm-variable-2 {color: #EEE;}
38 .cm-s-xq-dark span.cm-variable-3 {color: #DDD;}
32 .cm-s-xq-dark span.cm-keyword { color: #FFBD40; }
33 .cm-s-xq-dark span.cm-atom { color: #6C8CD5; }
34 .cm-s-xq-dark span.cm-number { color: #164; }
35 .cm-s-xq-dark span.cm-def { color: #FFF; text-decoration:underline; }
36 .cm-s-xq-dark span.cm-variable { color: #FFF; }
37 .cm-s-xq-dark span.cm-variable-2 { color: #EEE; }
38 .cm-s-xq-dark span.cm-variable-3 { color: #DDD; }
3939 .cm-s-xq-dark span.cm-property {}
4040 .cm-s-xq-dark span.cm-operator {}
41 .cm-s-xq-dark span.cm-comment {color: gray;}
42 .cm-s-xq-dark span.cm-string {color: #9FEE00;}
43 .cm-s-xq-dark span.cm-meta {color: yellow;}
44 .cm-s-xq-dark span.cm-qualifier {color: #FFF700;}
45 .cm-s-xq-dark span.cm-builtin {color: #30a;}
46 .cm-s-xq-dark span.cm-bracket {color: #cc7;}
47 .cm-s-xq-dark span.cm-tag {color: #FFBD40;}
48 .cm-s-xq-dark span.cm-attribute {color: #FFF700;}
49 .cm-s-xq-dark span.cm-error {color: #f00;}
41 .cm-s-xq-dark span.cm-comment { color: gray; }
42 .cm-s-xq-dark span.cm-string { color: #9FEE00; }
43 .cm-s-xq-dark span.cm-meta { color: yellow; }
44 .cm-s-xq-dark span.cm-qualifier { color: #FFF700; }
45 .cm-s-xq-dark span.cm-builtin { color: #30a; }
46 .cm-s-xq-dark span.cm-bracket { color: #cc7; }
47 .cm-s-xq-dark span.cm-tag { color: #FFBD40; }
48 .cm-s-xq-dark span.cm-attribute { color: #FFF700; }
49 .cm-s-xq-dark span.cm-error { color: #f00; }
5050
51 .cm-s-xq-dark .CodeMirror-activeline-background {background: #27282E !important;}
52 .cm-s-xq-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
51 .cm-s-xq-dark .CodeMirror-activeline-background { background: #27282E; }
52 .cm-s-xq-dark .CodeMirror-matchingbracket { outline:1px solid grey; color:white !important; }
1919 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020 THE SOFTWARE.
2121 */
22 .cm-s-xq-light span.cm-keyword {line-height: 1em; font-weight: bold; color: #5A5CAD; }
23 .cm-s-xq-light span.cm-atom {color: #6C8CD5;}
24 .cm-s-xq-light span.cm-number {color: #164;}
25 .cm-s-xq-light span.cm-def {text-decoration:underline;}
26 .cm-s-xq-light span.cm-variable {color: black; }
27 .cm-s-xq-light span.cm-variable-2 {color:black;}
28 .cm-s-xq-light span.cm-variable-3 {color: black; }
22 .cm-s-xq-light span.cm-keyword { line-height: 1em; font-weight: bold; color: #5A5CAD; }
23 .cm-s-xq-light span.cm-atom { color: #6C8CD5; }
24 .cm-s-xq-light span.cm-number { color: #164; }
25 .cm-s-xq-light span.cm-def { text-decoration:underline; }
26 .cm-s-xq-light span.cm-variable { color: black; }
27 .cm-s-xq-light span.cm-variable-2 { color:black; }
28 .cm-s-xq-light span.cm-variable-3 { color: black; }
2929 .cm-s-xq-light span.cm-property {}
3030 .cm-s-xq-light span.cm-operator {}
31 .cm-s-xq-light span.cm-comment {color: #0080FF; font-style: italic;}
32 .cm-s-xq-light span.cm-string {color: red;}
33 .cm-s-xq-light span.cm-meta {color: yellow;}
34 .cm-s-xq-light span.cm-qualifier {color: grey}
35 .cm-s-xq-light span.cm-builtin {color: #7EA656;}
36 .cm-s-xq-light span.cm-bracket {color: #cc7;}
37 .cm-s-xq-light span.cm-tag {color: #3F7F7F;}
38 .cm-s-xq-light span.cm-attribute {color: #7F007F;}
39 .cm-s-xq-light span.cm-error {color: #f00;}
31 .cm-s-xq-light span.cm-comment { color: #0080FF; font-style: italic; }
32 .cm-s-xq-light span.cm-string { color: red; }
33 .cm-s-xq-light span.cm-meta { color: yellow; }
34 .cm-s-xq-light span.cm-qualifier { color: grey; }
35 .cm-s-xq-light span.cm-builtin { color: #7EA656; }
36 .cm-s-xq-light span.cm-bracket { color: #cc7; }
37 .cm-s-xq-light span.cm-tag { color: #3F7F7F; }
38 .cm-s-xq-light span.cm-attribute { color: #7F007F; }
39 .cm-s-xq-light span.cm-error { color: #f00; }
4040
41 .cm-s-xq-light .CodeMirror-activeline-background {background: #e8f2ff !important;}
42 .cm-s-xq-light .CodeMirror-matchingbracket {outline:1px solid grey;color:black !important;background:yellow;}
41 .cm-s-xq-light .CodeMirror-activeline-background { background: #e8f2ff; }
42 .cm-s-xq-light .CodeMirror-matchingbracket { outline:1px solid grey;color:black !important;background:yellow; }
0 /*
1
2 Name: yeti
3 Author: Michael Kaminsky (http://github.com/mkaminsky11)
4
5 Original yeti color scheme by Jesse Weed (https://github.com/jesseweed/yeti-syntax)
6
7 */
8
9
10 .cm-s-yeti.CodeMirror {
11 background-color: #ECEAE8 !important;
12 color: #d1c9c0 !important;
13 border: none;
14 }
15
16 .cm-s-yeti .CodeMirror-gutters {
17 color: #adaba6;
18 background-color: #E5E1DB;
19 border: none;
20 }
21 .cm-s-yeti .CodeMirror-cursor { border-left: solid thin #d1c9c0; }
22 .cm-s-yeti .CodeMirror-linenumber { color: #adaba6; }
23 .cm-s-yeti.CodeMirror-focused div.CodeMirror-selected { background: #DCD8D2; }
24 .cm-s-yeti .CodeMirror-line::selection, .cm-s-yeti .CodeMirror-line > span::selection, .cm-s-yeti .CodeMirror-line > span > span::selection { background: #DCD8D2; }
25 .cm-s-yeti .CodeMirror-line::-moz-selection, .cm-s-yeti .CodeMirror-line > span::-moz-selection, .cm-s-yeti .CodeMirror-line > span > span::-moz-selection { background: #DCD8D2; }
26 .cm-s-yeti span.cm-comment { color: #d4c8be; }
27 .cm-s-yeti span.cm-string, .cm-s-yeti span.cm-string-2 { color: #96c0d8; }
28 .cm-s-yeti span.cm-number { color: #a074c4; }
29 .cm-s-yeti span.cm-variable { color: #55b5db; }
30 .cm-s-yeti span.cm-variable-2 { color: #a074c4; }
31 .cm-s-yeti span.cm-def { color: #55b5db; }
32 .cm-s-yeti span.cm-operator { color: #9fb96e; }
33 .cm-s-yeti span.cm-keyword { color: #9fb96e; }
34 .cm-s-yeti span.cm-atom { color: #a074c4; }
35 .cm-s-yeti span.cm-meta { color: #96c0d8; }
36 .cm-s-yeti span.cm-tag { color: #96c0d8; }
37 .cm-s-yeti span.cm-attribute { color: #9fb96e; }
38 .cm-s-yeti span.cm-qualifier { color: #96c0d8; }
39 .cm-s-yeti span.cm-property { color: #a074c4; }
40 .cm-s-yeti span.cm-builtin { color: #a074c4; }
41 .cm-s-yeti span.cm-variable-3 { color: #96c0d8; }
42 .cm-s-yeti .CodeMirror-activeline-background { background: #E7E4E0; }
43 .cm-s-yeti .CodeMirror-matchingbracket { text-decoration: underline; }
99
1010 .cm-s-zenburn .CodeMirror-gutters { background: #3f3f3f !important; }
1111 .cm-s-zenburn .CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded { color: #999; }
12 .cm-s-zenburn .CodeMirror-cursor { border-left: 1px solid white !important; }
12 .cm-s-zenburn .CodeMirror-cursor { border-left: 1px solid white; }
1313 .cm-s-zenburn { background-color: #3f3f3f; color: #dcdccc; }
1414 .cm-s-zenburn span.cm-builtin { color: #dcdccc; font-weight: bold; }
1515 .cm-s-zenburn span.cm-comment { color: #7f9f7f; }
3232 .cm-s-zenburn span.CodeMirror-nonmatchingbracket { border-bottom: 1px solid; background: none; }
3333 .cm-s-zenburn .CodeMirror-activeline { background: #000000; }
3434 .cm-s-zenburn .CodeMirror-activeline-background { background: #000000; }
35 .cm-s-zenburn .CodeMirror-selected { background: #545454; }
36 .cm-s-zenburn .CodeMirror-focused .CodeMirror-selected { background: #4f4f4f; }
35 .cm-s-zenburn div.CodeMirror-selected { background: #545454; }
36 .cm-s-zenburn .CodeMirror-focused div.CodeMirror-selected { background: #4f4f4f; }