Merge branch 'master' into dev10
This commit is contained in:
commit
09f355f57e
@ -22,8 +22,11 @@
|
|||||||
- Chargement paresseux des images.
|
- Chargement paresseux des images.
|
||||||
|
|
||||||
## version 9.2.22
|
## version 9.2.22
|
||||||
- Modification :
|
- Modifications :
|
||||||
- Aperçu de la police dans les sélecteurs.
|
- Aperçu de la police dans les sélecteurs.
|
||||||
|
- Gestion du canal de mise à jour selon la version installée
|
||||||
|
- Mises à jour :
|
||||||
|
- Configurations Code Mirror pour TinyMCE et standalone
|
||||||
|
|
||||||
## version 9.2.21
|
## version 9.2.21
|
||||||
- Correction :
|
- Correction :
|
||||||
|
@ -2243,8 +2243,8 @@ class layout extends common {
|
|||||||
if( $this->getData(['config','autoUpdate']) &&
|
if( $this->getData(['config','autoUpdate']) &&
|
||||||
$lastAutoUpdate > $this->getData(['core','lastAutoUpdate']) + 86400 ) {
|
$lastAutoUpdate > $this->getData(['core','lastAutoUpdate']) + 86400 ) {
|
||||||
$this->setData(['core','lastAutoUpdate',$lastAutoUpdate]);
|
$this->setData(['core','lastAutoUpdate',$lastAutoUpdate]);
|
||||||
if ( helper::checkNewVersion() ) {
|
if ( helper::checkNewVersion(common::ZWII_UPDATE_CHANNEL) ) {
|
||||||
$rightItems .= '<li><a id="barUpdate" href="' . helper::baseUrl() . 'install/update" data-tippy-content="Mettre à jour Zwii '. common::ZWII_VERSION .' vers '. helper::getOnlineVersion() .'">' . template::ico('update colorRed') . '</a></li>';
|
$rightItems .= '<li><a id="barUpdate" href="' . helper::baseUrl() . 'install/update" data-tippy-content="Mettre à jour Zwii '. common::ZWII_VERSION .' vers '. helper::getOnlineVersion(common::ZWII_UPDATE_CHANNEL) .'">' . template::ico('update colorRed') . '</a></li>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ class install extends common {
|
|||||||
// Téléchargement
|
// Téléchargement
|
||||||
case 2:
|
case 2:
|
||||||
// Téléchargement depuis le serveur de Zwii
|
// Téléchargement depuis le serveur de Zwii
|
||||||
$success = (file_put_contents(self::TEMP_DIR.'update.tar.gz', file_get_contents('https://zwiicms.com/update/update.tar.gz')) !== false);
|
$success = (file_put_contents(self::TEMP_DIR.'update.tar.gz', file_get_contents('https://zwiicms.com/update/' . common::ZWII_UPDATE_CHANNEL . '/update.tar.gz')) !== false);
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'display' => self::DISPLAY_JSON,
|
'display' => self::DISPLAY_JSON,
|
||||||
@ -224,7 +224,7 @@ class install extends common {
|
|||||||
*/
|
*/
|
||||||
public function update() {
|
public function update() {
|
||||||
// Nouvelle version
|
// Nouvelle version
|
||||||
self::$newVersion = file_get_contents('http://zwiicms.com/update/version');
|
self::$newVersion = file_get_contents('http://zwiicms.com/update/' . common::ZWII_UPDATE_CHANNEL . '/version');
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'display' => self::DISPLAY_LAYOUT_LIGHT,
|
'display' => self::DISPLAY_LAYOUT_LIGHT,
|
||||||
|
9
core/vendor/codemirror/inc.json
vendored
9
core/vendor/codemirror/inc.json
vendored
@ -1,9 +1,10 @@
|
|||||||
[
|
[
|
||||||
"codemirror.css",
|
|
||||||
"codemirror.js",
|
"codemirror.js",
|
||||||
"mode/css.js",
|
"codemirror.css",
|
||||||
"mode/javascript.js",
|
"mode/css/css.js",
|
||||||
"mode/xml.js",
|
"mode/javascript/javascript.js",
|
||||||
|
"mode/xml/xml.js",
|
||||||
|
"modes.js",
|
||||||
"init.js",
|
"init.js",
|
||||||
"init.css"
|
"init.css"
|
||||||
]
|
]
|
@ -446,7 +446,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function maybeoperatorComma(type, value) {
|
function maybeoperatorComma(type, value) {
|
||||||
if (type == ",") return cont(expression);
|
if (type == ",") return cont(maybeexpression);
|
||||||
return maybeoperatorNoComma(type, value, false);
|
return maybeoperatorNoComma(type, value, false);
|
||||||
}
|
}
|
||||||
function maybeoperatorNoComma(type, value, noComma) {
|
function maybeoperatorNoComma(type, value, noComma) {
|
6
core/vendor/tinymce/init.js
vendored
6
core/vendor/tinymce/init.js
vendored
@ -26,15 +26,15 @@ tinymce.init({
|
|||||||
indentOnInit: true, // Whether or not to indent code on init.
|
indentOnInit: true, // Whether or not to indent code on init.
|
||||||
fullscreen: false, // Default setting is false
|
fullscreen: false, // Default setting is false
|
||||||
path: 'codemirror', // Path to CodeMirror distribution
|
path: 'codemirror', // Path to CodeMirror distribution
|
||||||
|
saveCursorPosition: true, // Insert caret marker
|
||||||
config: { // CodeMirror config object
|
config: { // CodeMirror config object
|
||||||
mode: 'application/x-httpd-php',
|
mode: 'application/x-httpd-php',
|
||||||
lineNumbers: true
|
lineNumbers: true
|
||||||
},
|
},
|
||||||
width: 800, // Default value is 800
|
width: 800, // Default value is 800
|
||||||
height: 500, // Default value is 550
|
height: 500, // Default value is 550
|
||||||
files: [ // Additional JS files to load
|
cssFiles: [
|
||||||
baseUrl + 'core/vendor/tinymce/mode/clike/clike.js',
|
'theme/neat.css'
|
||||||
baseUrl + 'core/vendor/tinymce/mode/php/php.js'
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// Cibles de la target
|
// Cibles de la target
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- 0.8
|
|
@ -1,406 +0,0 @@
|
|||||||
List of CodeMirror contributors. Updated before every release.
|
|
||||||
|
|
||||||
4r2r
|
|
||||||
Aaron Brooks
|
|
||||||
Abdelouahab
|
|
||||||
Abe Fettig
|
|
||||||
Adam Ahmed
|
|
||||||
Adam King
|
|
||||||
adanlobato
|
|
||||||
Adán Lobato
|
|
||||||
Adrian Aichner
|
|
||||||
aeroson
|
|
||||||
Ahmad Amireh
|
|
||||||
Ahmad M. Zawawi
|
|
||||||
ahoward
|
|
||||||
Akeksandr Motsjonov
|
|
||||||
Alberto González Palomo
|
|
||||||
Alberto Pose
|
|
||||||
Albert Xing
|
|
||||||
Alexander Pavlov
|
|
||||||
Alexander Schepanovski
|
|
||||||
Alexander Shvets
|
|
||||||
Alexander Solovyov
|
|
||||||
Alexandre Bique
|
|
||||||
alexey-k
|
|
||||||
Alex Piggott
|
|
||||||
Amsul
|
|
||||||
amuntean
|
|
||||||
Amy
|
|
||||||
Ananya Sen
|
|
||||||
anaran
|
|
||||||
AndersMad
|
|
||||||
Anders Nawroth
|
|
||||||
Anderson Mesquita
|
|
||||||
Andrea G
|
|
||||||
Andreas Reischuck
|
|
||||||
Andre von Houck
|
|
||||||
Andrey Fedorov
|
|
||||||
Andrey Klyuchnikov
|
|
||||||
Andrey Lushnikov
|
|
||||||
Andy Joslin
|
|
||||||
Andy Kimball
|
|
||||||
Andy Li
|
|
||||||
angelozerr
|
|
||||||
angelo.zerr@gmail.com
|
|
||||||
Ankit Ahuja
|
|
||||||
Ansel Santosa
|
|
||||||
Anthony Grimes
|
|
||||||
Anton Kovalyov
|
|
||||||
areos
|
|
||||||
as3boyan
|
|
||||||
AtomicPages LLC
|
|
||||||
Atul Bhouraskar
|
|
||||||
Aurelian Oancea
|
|
||||||
Bastian Müller
|
|
||||||
Bem Jones-Bey
|
|
||||||
benbro
|
|
||||||
Beni Cherniavsky-Paskin
|
|
||||||
Benjamin DeCoste
|
|
||||||
Ben Keen
|
|
||||||
Bernhard Sirlinger
|
|
||||||
Bert Chang
|
|
||||||
Billy Moon
|
|
||||||
binny
|
|
||||||
B Krishna Chaitanya
|
|
||||||
Blaine G
|
|
||||||
blukat29
|
|
||||||
boomyjee
|
|
||||||
borawjm
|
|
||||||
Brandon Frohs
|
|
||||||
Brandon Wamboldt
|
|
||||||
Brett Zamir
|
|
||||||
Brian Grinstead
|
|
||||||
Brian Sletten
|
|
||||||
Bruce Mitchener
|
|
||||||
Chandra Sekhar Pydi
|
|
||||||
Charles Skelton
|
|
||||||
Cheah Chu Yeow
|
|
||||||
Chris Coyier
|
|
||||||
Chris Granger
|
|
||||||
Chris Houseknecht
|
|
||||||
Chris Morgan
|
|
||||||
Christian Oyarzun
|
|
||||||
Christopher Brown
|
|
||||||
ciaranj
|
|
||||||
CodeAnimal
|
|
||||||
ComFreek
|
|
||||||
Curtis Gagliardi
|
|
||||||
dagsta
|
|
||||||
daines
|
|
||||||
Dale Jung
|
|
||||||
Dan Heberden
|
|
||||||
Daniel, Dao Quang Minh
|
|
||||||
Daniele Di Sarli
|
|
||||||
Daniel Faust
|
|
||||||
Daniel Huigens
|
|
||||||
Daniel KJ
|
|
||||||
Daniel Neel
|
|
||||||
Daniel Parnell
|
|
||||||
Danny Yoo
|
|
||||||
Darius Roberts
|
|
||||||
Dave Myers
|
|
||||||
David Mignot
|
|
||||||
David Pathakjee
|
|
||||||
deebugger
|
|
||||||
Deep Thought
|
|
||||||
dignifiedquire
|
|
||||||
Dimage Sapelkin
|
|
||||||
domagoj412
|
|
||||||
Dominator008
|
|
||||||
Domizio Demichelis
|
|
||||||
Doug Wikle
|
|
||||||
Drew Bratcher
|
|
||||||
Drew Hintz
|
|
||||||
Drew Khoury
|
|
||||||
Dror BG
|
|
||||||
duralog
|
|
||||||
eborden
|
|
||||||
edsharp
|
|
||||||
ekhaled
|
|
||||||
Enam Mijbah Noor
|
|
||||||
Eric Allam
|
|
||||||
eustas
|
|
||||||
Fabien O'Carroll
|
|
||||||
Fabio Zendhi Nagao
|
|
||||||
Faiza Alsaied
|
|
||||||
Fauntleroy
|
|
||||||
fbuchinger
|
|
||||||
feizhang365
|
|
||||||
Felipe Lalanne
|
|
||||||
Felix Raab
|
|
||||||
Filip Noetzel
|
|
||||||
flack
|
|
||||||
ForbesLindesay
|
|
||||||
Forbes Lindesay
|
|
||||||
Ford_Lawnmower
|
|
||||||
Frank Wiegand
|
|
||||||
Gabriel Horner
|
|
||||||
Gabriel Nahmias
|
|
||||||
galambalazs
|
|
||||||
Gautam Mehta
|
|
||||||
gekkoe
|
|
||||||
Gergely Hegykozi
|
|
||||||
Glenn Jorde
|
|
||||||
Glenn Ruehle
|
|
||||||
Golevka
|
|
||||||
Gordon Smith
|
|
||||||
Grant Skinner
|
|
||||||
greengiant
|
|
||||||
Gregory Koberger
|
|
||||||
Guillaume Massé
|
|
||||||
Guillaume Massé
|
|
||||||
Gustavo Rodrigues
|
|
||||||
Hakan Tunc
|
|
||||||
Hans Engel
|
|
||||||
Hardest
|
|
||||||
Hasan Karahan
|
|
||||||
Herculano Campos
|
|
||||||
Hiroyuki Makino
|
|
||||||
hitsthings
|
|
||||||
Hocdoc
|
|
||||||
Ian Beck
|
|
||||||
Ian Dickinson
|
|
||||||
Ian Wehrman
|
|
||||||
Ian Wetherbee
|
|
||||||
Ice White
|
|
||||||
ICHIKAWA, Yuji
|
|
||||||
ilvalle
|
|
||||||
Ingo Richter
|
|
||||||
Irakli Gozalishvili
|
|
||||||
Ivan Kurnosov
|
|
||||||
Jacob Lee
|
|
||||||
Jakob Miland
|
|
||||||
Jakub Vrana
|
|
||||||
James Campos
|
|
||||||
James Thorne
|
|
||||||
Jamie Hill
|
|
||||||
Jan Jongboom
|
|
||||||
jankeromnes
|
|
||||||
Jan Keromnes
|
|
||||||
Jan Odvarko
|
|
||||||
Jan T. Sott
|
|
||||||
Jared Forsyth
|
|
||||||
Jason
|
|
||||||
Jason Grout
|
|
||||||
Jason Johnston
|
|
||||||
Jason San Jose
|
|
||||||
Jason Siefken
|
|
||||||
Jaydeep Solanki
|
|
||||||
Jean Boussier
|
|
||||||
jeffkenton
|
|
||||||
Jeff Pickhardt
|
|
||||||
jem (graphite)
|
|
||||||
Jeremy Parmenter
|
|
||||||
Jochen Berger
|
|
||||||
Johan Ask
|
|
||||||
John Connor
|
|
||||||
John Lees-Miller
|
|
||||||
John Snelson
|
|
||||||
John Van Der Loo
|
|
||||||
Jonathan Malmaud
|
|
||||||
jongalloway
|
|
||||||
Jon Malmaud
|
|
||||||
Jon Sangster
|
|
||||||
Joost-Wim Boekesteijn
|
|
||||||
Joseph Pecoraro
|
|
||||||
Joshua Newman
|
|
||||||
Josh Watzman
|
|
||||||
jots
|
|
||||||
jsoojeon
|
|
||||||
Juan Benavides Romero
|
|
||||||
Jucovschi Constantin
|
|
||||||
Juho Vuori
|
|
||||||
Justin Hileman
|
|
||||||
jwallers@gmail.com
|
|
||||||
kaniga
|
|
||||||
Ken Newman
|
|
||||||
Ken Rockot
|
|
||||||
Kevin Sawicki
|
|
||||||
Klaus Silveira
|
|
||||||
Koh Zi Han, Cliff
|
|
||||||
komakino
|
|
||||||
Konstantin Lopuhin
|
|
||||||
koops
|
|
||||||
ks-ifware
|
|
||||||
kubelsmieci
|
|
||||||
Lanny
|
|
||||||
Laszlo Vidacs
|
|
||||||
leaf corcoran
|
|
||||||
Leonid Khachaturov
|
|
||||||
Leon Sorokin
|
|
||||||
Leonya Khachaturov
|
|
||||||
Liam Newman
|
|
||||||
LM
|
|
||||||
lochel
|
|
||||||
Lorenzo Stoakes
|
|
||||||
Luciano Longo
|
|
||||||
Luke Stagner
|
|
||||||
lynschinzer
|
|
||||||
Maksim Lin
|
|
||||||
Maksym Taran
|
|
||||||
Malay Majithia
|
|
||||||
Manuel Rego Casasnovas
|
|
||||||
Marat Dreizin
|
|
||||||
Marcel Gerber
|
|
||||||
Marco Aurélio
|
|
||||||
Marco Munizaga
|
|
||||||
Marcus Bointon
|
|
||||||
Marijn Haverbeke
|
|
||||||
Mário Gonçalves
|
|
||||||
Mario Pietsch
|
|
||||||
Mark Lentczner
|
|
||||||
Marko Bonaci
|
|
||||||
Martin Balek
|
|
||||||
Martín Gaitán
|
|
||||||
Martin Hasoň
|
|
||||||
Mason Malone
|
|
||||||
Mateusz Paprocki
|
|
||||||
Mathias Bynens
|
|
||||||
mats cronqvist
|
|
||||||
Matthew Beale
|
|
||||||
Matthias Bussonnier
|
|
||||||
Matthias BUSSONNIER
|
|
||||||
Matt McDonald
|
|
||||||
Matt Pass
|
|
||||||
Matt Sacks
|
|
||||||
mauricio
|
|
||||||
Maximilian Hils
|
|
||||||
Maxim Kraev
|
|
||||||
Max Kirsch
|
|
||||||
Max Xiantu
|
|
||||||
mbarkhau
|
|
||||||
Metatheos
|
|
||||||
Micah Dubinko
|
|
||||||
Michael Lehenbauer
|
|
||||||
Michael Zhou
|
|
||||||
Mighty Guava
|
|
||||||
Miguel Castillo
|
|
||||||
Mike
|
|
||||||
Mike Brevoort
|
|
||||||
Mike Diaz
|
|
||||||
Mike Ivanov
|
|
||||||
Mike Kadin
|
|
||||||
MinRK
|
|
||||||
Miraculix87
|
|
||||||
misfo
|
|
||||||
mloginov
|
|
||||||
mps
|
|
||||||
mtaran-google
|
|
||||||
Narciso Jaramillo
|
|
||||||
Nathan Williams
|
|
||||||
ndr
|
|
||||||
nerbert
|
|
||||||
nextrevision
|
|
||||||
nguillaumin
|
|
||||||
Ng Zhi An
|
|
||||||
Nicholas Bollweg
|
|
||||||
Nicholas Bollweg (Nick)
|
|
||||||
Nick Small
|
|
||||||
Niels van Groningen
|
|
||||||
nightwing
|
|
||||||
Nikita Beloglazov
|
|
||||||
Nikita Vasilyev
|
|
||||||
Nikolay Kostov
|
|
||||||
nilp0inter
|
|
||||||
Nisarg Jhaveri
|
|
||||||
nlwillia
|
|
||||||
Norman Rzepka
|
|
||||||
pablo
|
|
||||||
Page
|
|
||||||
Panupong Pasupat
|
|
||||||
paris
|
|
||||||
Patil Arpith
|
|
||||||
Patrick Strawderman
|
|
||||||
Paul Garvin
|
|
||||||
Paul Ivanov
|
|
||||||
Pavel Feldman
|
|
||||||
Pavel Strashkin
|
|
||||||
Paweł Bartkiewicz
|
|
||||||
peteguhl
|
|
||||||
Peter Flynn
|
|
||||||
peterkroon
|
|
||||||
Peter Kroon
|
|
||||||
prasanthj
|
|
||||||
Prasanth J
|
|
||||||
Radek Piórkowski
|
|
||||||
Rahul
|
|
||||||
Randy Burden
|
|
||||||
Randy Edmunds
|
|
||||||
Rasmus Erik Voel Jensen
|
|
||||||
Richard van der Meer
|
|
||||||
Richard Z.H. Wang
|
|
||||||
Roberto Abdelkader Martínez Pérez
|
|
||||||
robertop23
|
|
||||||
Robert Plummer
|
|
||||||
Ruslan Osmanov
|
|
||||||
Ryan Prior
|
|
||||||
sabaca
|
|
||||||
Samuel Ainsworth
|
|
||||||
sandeepshetty
|
|
||||||
Sander AKA Redsandro
|
|
||||||
santec
|
|
||||||
Sascha Peilicke
|
|
||||||
satchmorun
|
|
||||||
sathyamoorthi
|
|
||||||
SCLINIC\jdecker
|
|
||||||
Scott Aikin
|
|
||||||
Scott Goodhew
|
|
||||||
Sebastian Zaha
|
|
||||||
shaund
|
|
||||||
shaun gilchrist
|
|
||||||
Shawn A
|
|
||||||
sheopory
|
|
||||||
Shiv Deepak
|
|
||||||
Shmuel Englard
|
|
||||||
Shubham Jain
|
|
||||||
snasa
|
|
||||||
soliton4
|
|
||||||
sonson
|
|
||||||
spastorelli
|
|
||||||
srajanpaliwal
|
|
||||||
Stanislav Oaserele
|
|
||||||
Stas Kobzar
|
|
||||||
Stefan Borsje
|
|
||||||
Steffen Beyer
|
|
||||||
Steve O'Hara
|
|
||||||
stoskov
|
|
||||||
Taha Jahangir
|
|
||||||
Takuji Shimokawa
|
|
||||||
Tarmil
|
|
||||||
tfjgeorge
|
|
||||||
Thaddee Tyl
|
|
||||||
TheHowl
|
|
||||||
think
|
|
||||||
Thomas Dvornik
|
|
||||||
Thomas Schmid
|
|
||||||
Tim Alby
|
|
||||||
Tim Baumann
|
|
||||||
Timothy Farrell
|
|
||||||
Timothy Hatcher
|
|
||||||
TobiasBg
|
|
||||||
Tomas-A
|
|
||||||
Tomas Varaneckas
|
|
||||||
Tom Erik Støwer
|
|
||||||
Tom MacWright
|
|
||||||
Tony Jian
|
|
||||||
Travis Heppe
|
|
||||||
Triangle717
|
|
||||||
twifkak
|
|
||||||
Vestimir Markov
|
|
||||||
vf
|
|
||||||
Vincent Woo
|
|
||||||
Volker Mische
|
|
||||||
wenli
|
|
||||||
Wesley Wiser
|
|
||||||
William Jamieson
|
|
||||||
William Stein
|
|
||||||
Willy
|
|
||||||
Wojtek Ptak
|
|
||||||
Xavier Mendez
|
|
||||||
YNH Webdev
|
|
||||||
Yunchi Luo
|
|
||||||
Yuvi Panda
|
|
||||||
Zachary Dremann
|
|
||||||
zziuni
|
|
||||||
魏鹏刚
|
|
@ -1,76 +0,0 @@
|
|||||||
# How to contribute
|
|
||||||
|
|
||||||
- [Getting help](#getting-help-)
|
|
||||||
- [Submitting bug reports](#submitting-bug-reports-)
|
|
||||||
- [Contributing code](#contributing-code-)
|
|
||||||
|
|
||||||
## Getting help
|
|
||||||
|
|
||||||
Community discussion, questions, and informal bug reporting is done on the
|
|
||||||
[discuss.CodeMirror forum](http://discuss.codemirror.net).
|
|
||||||
|
|
||||||
## Submitting bug reports
|
|
||||||
|
|
||||||
The preferred way to report bugs is to use the
|
|
||||||
[GitHub issue tracker](http://github.com/codemirror/CodeMirror/issues). Before
|
|
||||||
reporting a bug, read these pointers.
|
|
||||||
|
|
||||||
**Note:** The issue tracker is for *bugs*, not requests for help. Questions
|
|
||||||
should be asked on the
|
|
||||||
[discuss.CodeMirror forum](http://discuss.codemirror.net) instead.
|
|
||||||
|
|
||||||
### Reporting bugs effectively
|
|
||||||
|
|
||||||
- CodeMirror is maintained by volunteers. They don't owe you anything, so be
|
|
||||||
polite. Reports with an indignant or belligerent tone tend to be moved to the
|
|
||||||
bottom of the pile.
|
|
||||||
|
|
||||||
- Include information about **the browser in which the problem occurred**. Even
|
|
||||||
if you tested several browsers, and the problem occurred in all of them,
|
|
||||||
mention this fact in the bug report. Also include browser version numbers and
|
|
||||||
the operating system that you're on.
|
|
||||||
|
|
||||||
- Mention which release of CodeMirror you're using. Preferably, try also with
|
|
||||||
the current development snapshot, to ensure the problem has not already been
|
|
||||||
fixed.
|
|
||||||
|
|
||||||
- Mention very precisely what went wrong. "X is broken" is not a good bug
|
|
||||||
report. What did you expect to happen? What happened instead? Describe the
|
|
||||||
exact steps a maintainer has to take to make the problem occur. We can not
|
|
||||||
fix something that we can not observe.
|
|
||||||
|
|
||||||
- If the problem can not be reproduced in any of the demos included in the
|
|
||||||
CodeMirror distribution, please provide an HTML document that demonstrates
|
|
||||||
the problem. The best way to do this is to go to
|
|
||||||
[jsbin.com](http://jsbin.com/ihunin/edit), enter it there, press save, and
|
|
||||||
include the resulting link in your bug report.
|
|
||||||
|
|
||||||
## Contributing code
|
|
||||||
|
|
||||||
- Make sure you have a [GitHub Account](https://github.com/signup/free)
|
|
||||||
- Fork [CodeMirror](https://github.com/codemirror/CodeMirror/)
|
|
||||||
([how to fork a repo](https://help.github.com/articles/fork-a-repo))
|
|
||||||
- Make your changes
|
|
||||||
- If your changes are easy to test or likely to regress, add tests.
|
|
||||||
Tests for the core go into `test/test.js`, some modes have their own
|
|
||||||
test suite under `mode/XXX/test.js`. Feel free to add new test
|
|
||||||
suites to modes that don't have one yet (be sure to link the new
|
|
||||||
tests into `test/index.html`).
|
|
||||||
- Follow the general code style of the rest of the project (see
|
|
||||||
below). Run `bin/lint` to verify that the linter is happy.
|
|
||||||
- Make sure all tests pass. Visit `test/index.html` in your browser to
|
|
||||||
run them.
|
|
||||||
- Submit a pull request
|
|
||||||
([how to create a pull request](https://help.github.com/articles/fork-a-repo))
|
|
||||||
|
|
||||||
### Coding standards
|
|
||||||
|
|
||||||
- 2 spaces per indentation level, no tabs.
|
|
||||||
- Include semicolons after statements.
|
|
||||||
- Note that the linter (`bin/lint`) which is run after each commit
|
|
||||||
complains about unused variables and functions. Prefix their names
|
|
||||||
with an underscore to muffle it.
|
|
||||||
|
|
||||||
- CodeMirror does *not* follow JSHint or JSLint prescribed style.
|
|
||||||
Patches that try to 'fix' code to pass one of these linters will be
|
|
||||||
unceremoniously discarded.
|
|
@ -1,19 +0,0 @@
|
|||||||
Copyright (C) 2014 by Marijn Haverbeke <marijnh@gmail.com> and others
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
@ -1,11 +0,0 @@
|
|||||||
# CodeMirror
|
|
||||||
[![Build Status](https://travis-ci.org/codemirror/CodeMirror.svg)](https://travis-ci.org/codemirror/CodeMirror)
|
|
||||||
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
|
|
||||||
|
|
||||||
CodeMirror is a JavaScript component that provides a code editor in
|
|
||||||
the browser. When a mode is available for the language you are coding
|
|
||||||
in, it will color your code, and optionally help with indentation.
|
|
||||||
|
|
||||||
The project page is http://codemirror.net
|
|
||||||
The manual is at http://codemirror.net/doc/manual.html
|
|
||||||
The contributing guidelines are in [CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
|
|
@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "codemirror",
|
|
||||||
"version":"4.8.0",
|
|
||||||
"main": ["lib/codemirror.js", "lib/codemirror.css"],
|
|
||||||
"ignore": [
|
|
||||||
"**/.*",
|
|
||||||
"node_modules",
|
|
||||||
"components",
|
|
||||||
"bin",
|
|
||||||
"demo",
|
|
||||||
"doc",
|
|
||||||
"test",
|
|
||||||
"index.html",
|
|
||||||
"package.json"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,199 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
|
|
||||||
<link rel=stylesheet href="lib/codemirror.css">
|
|
||||||
<link rel=stylesheet href="doc/docs.css">
|
|
||||||
<script src="lib/codemirror.js"></script>
|
|
||||||
<script src="mode/xml/xml.js"></script>
|
|
||||||
<script src="mode/javascript/javascript.js"></script>
|
|
||||||
<script src="mode/css/css.js"></script>
|
|
||||||
<script src="mode/htmlmixed/htmlmixed.js"></script>
|
|
||||||
<script src="addon/edit/matchbrackets.js"></script>
|
|
||||||
|
|
||||||
<script src="doc/activebookmark.js"></script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.CodeMirror { height: auto; border: 1px solid #ddd; }
|
|
||||||
.CodeMirror-scroll { max-height: 200px; }
|
|
||||||
.CodeMirror pre { padding-left: 7px; line-height: 1.25; }
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div id=nav>
|
|
||||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a class=active data-default="true" href="#description">Home</a>
|
|
||||||
<li><a href="doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#features">Features</a>
|
|
||||||
<li><a href="#community">Community</a>
|
|
||||||
<li><a href="#browsersupport">Browser support</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
|
|
||||||
<section id=description class=first>
|
|
||||||
<p><strong>CodeMirror</strong> is a versatile text editor
|
|
||||||
implemented in JavaScript for the browser. It is specialized for
|
|
||||||
editing code, and comes with a number of <a href="mode/index.html">language modes</a> and <a href="doc/manual.html#addons">addons</a>
|
|
||||||
that implement more advanced editing functionality.</p>
|
|
||||||
|
|
||||||
<p>A rich <a href="doc/manual.html#api">programming API</a> and a
|
|
||||||
CSS <a href="doc/manual.html#styling">theming</a> system are
|
|
||||||
available for customizing CodeMirror to fit your application, and
|
|
||||||
extending it with new functionality.</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id=demo>
|
|
||||||
<h2>This is CodeMirror</h2>
|
|
||||||
<form style="position: relative; margin-top: .5em;"><textarea id=demotext>
|
|
||||||
<!-- Create a simple CodeMirror instance -->
|
|
||||||
<link rel="stylesheet" href="lib/codemirror.css">
|
|
||||||
<script src="lib/codemirror.js"></script>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(myTextarea, {
|
|
||||||
lineNumbers: true
|
|
||||||
});
|
|
||||||
</script></textarea>
|
|
||||||
<select id="demolist" onchange="document.location = this.options[this.selectedIndex].value;">
|
|
||||||
<option value="#">Other demos...</option>
|
|
||||||
<option value="demo/complete.html">Autocompletion</option>
|
|
||||||
<option value="demo/folding.html">Code folding</option>
|
|
||||||
<option value="demo/theme.html">Themes</option>
|
|
||||||
<option value="mode/htmlmixed/index.html">Mixed language modes</option>
|
|
||||||
<option value="demo/bidi.html">Bi-directional text</option>
|
|
||||||
<option value="demo/variableheight.html">Variable font sizes</option>
|
|
||||||
<option value="demo/search.html">Search interface</option>
|
|
||||||
<option value="demo/vim.html">Vim bindings</option>
|
|
||||||
<option value="demo/emacs.html">Emacs bindings</option>
|
|
||||||
<option value="demo/sublime.html">Sublime Text bindings</option>
|
|
||||||
<option value="demo/tern.html">Tern integration</option>
|
|
||||||
<option value="demo/merge.html">Merge/diff interface</option>
|
|
||||||
<option value="demo/fullscreen.html">Full-screen editor</option>
|
|
||||||
</select></form>
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("demotext"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
mode: "text/html",
|
|
||||||
matchBrackets: true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<div style="position: relative; margin: 1em 0;">
|
|
||||||
<a class="bigbutton left" href="http://codemirror.net/codemirror.zip">DOWNLOAD LATEST RELEASE</a>
|
|
||||||
<div><strong>version 4.8</strong> (<a href="doc/releases.html">Release notes</a>)</div>
|
|
||||||
<div>or use the <a href="doc/compress.html">minification helper</a></div>
|
|
||||||
<div style="position: absolute; top: 0; right: 0; text-align: right">
|
|
||||||
<span class="bigbutton right" onclick="document.getElementById('paypal').submit();">DONATE WITH PAYPAL</span>
|
|
||||||
<div style="position: relative">
|
|
||||||
or <span onclick="document.getElementById('bankinfo').style.display = 'block';" class=quasilink>Bank</span>,
|
|
||||||
<span onclick="document.getElementById('bcinfo').style.display = 'block';" class=quasilink>Bitcoin</span>,
|
|
||||||
<a href="https://www.gittip.com/marijnh">Gittip</a>,
|
|
||||||
<a href="https://flattr.com/profile/marijnh">Flattr</a><br>
|
|
||||||
<div id=bankinfo class=bankinfo>
|
|
||||||
<span class=bankinfo_close onclick="document.getElementById('bankinfo').style.display = '';">×</span>
|
|
||||||
Bank: <i>Rabobank</i><br/>
|
|
||||||
Country: <i>Netherlands</i><br/>
|
|
||||||
SWIFT: <i>RABONL2U</i><br/>
|
|
||||||
Account: <i>147850770</i><br/>
|
|
||||||
Name: <i>Marijn Haverbeke</i><br/>
|
|
||||||
IBAN: <i>NL26 RABO 0147 8507 70</i>
|
|
||||||
</div>
|
|
||||||
<div id=bcinfo class=bankinfo>
|
|
||||||
<span class=bankinfo_close onclick="document.getElementById('bcinfo').style.display = '';">×</span>
|
|
||||||
Bitcoin address: 1HVnnU8E9yLPeFyNgNtUPB5deXBvUmZ6Nx
|
|
||||||
</div>
|
|
||||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="paypal">
|
|
||||||
<input type="hidden" name="cmd" value="_s-xclick"/>
|
|
||||||
<input type="hidden" name="hosted_button_id" value="3FVHS5FGUY7CC"/>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
Purchase <a href="http://codemirror.com">commercial support</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id=features>
|
|
||||||
<h2>Features</h2>
|
|
||||||
<ul>
|
|
||||||
<li>Support for <a href="mode/index.html">over 60 languages</a> out of the box
|
|
||||||
<li>A powerful, <a href="mode/htmlmixed/index.html">composable</a> language mode <a href="doc/manual.html#modeapi">system</a>
|
|
||||||
<li><a href="doc/manual.html#addon_show-hint">Autocompletion</a> (<a href="demo/xmlcomplete.html">XML</a>)
|
|
||||||
<li><a href="doc/manual.html#addon_foldcode">Code folding</a>
|
|
||||||
<li><a href="doc/manual.html#option_extraKeys">Configurable</a> keybindings
|
|
||||||
<li><a href="demo/vim.html">Vim</a>, <a href="demo/emacs.html">Emacs</a>, and <a href="demo/sublime.html">Sublime Text</a> bindings
|
|
||||||
<li><a href="doc/manual.html#addon_search">Search and replace</a> interface
|
|
||||||
<li><a href="doc/manual.html#addon_matchbrackets">Bracket</a> and <a href="doc/manual.html#addon_matchtags">tag</a> matching
|
|
||||||
<li>Support for <a href="demo/buffers.html">split views</a>
|
|
||||||
<li><a href="doc/manual.html#addon_lint">Linter integration</a>
|
|
||||||
<li><a href="demo/variableheight.html">Mixing font sizes and styles</a>
|
|
||||||
<li><a href="demo/theme.html">Various themes</a>
|
|
||||||
<li>Able to <a href="demo/resize.html">resize to fit content</a>
|
|
||||||
<li><a href="doc/manual.html#mark_replacedWith">Inline</a> and <a href="doc/manual.html#addLineWidget">block</a> widgets
|
|
||||||
<li>Programmable <a href="demo/marker.html">gutters</a>
|
|
||||||
<li>Making ranges of text <a href="doc/manual.html#markText">styled, read-only, or atomic</a>
|
|
||||||
<li><a href="demo/bidi.html">Bi-directional text</a> support
|
|
||||||
<li>Many other <a href="doc/manual.html#api">methods</a> and <a href="doc/manual.html#addons">addons</a>...
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id=community>
|
|
||||||
<h2>Community</h2>
|
|
||||||
|
|
||||||
<p>CodeMirror is an open-source project shared under
|
|
||||||
an <a href="LICENSE">MIT license</a>. It is the editor used in the
|
|
||||||
dev tools for
|
|
||||||
both <a href="https://hacks.mozilla.org/2013/11/firefox-developer-tools-episode-27-edit-as-html-codemirror-more/">Firefox</a>
|
|
||||||
and <a href="https://developers.google.com/chrome-developer-tools/">Chrome</a>, <a href="http://www.lighttable.com/">Light
|
|
||||||
Table</a>, <a href="http://brackets.io/">Adobe
|
|
||||||
Brackets</a>, <a href="http://blog.bitbucket.org/2013/05/14/edit-your-code-in-the-cloud-with-bitbucket/">Bitbucket</a>,
|
|
||||||
and <a href="doc/realworld.html">many other projects</a>.</p>
|
|
||||||
|
|
||||||
<p>Development and bug tracking happens
|
|
||||||
on <a href="https://github.com/codemirror/CodeMirror/">github</a>
|
|
||||||
(<a href="http://marijnhaverbeke.nl/git/codemirror">alternate git
|
|
||||||
repository</a>).
|
|
||||||
Please <a href="http://codemirror.net/doc/reporting.html">read these
|
|
||||||
pointers</a> before submitting a bug. Use pull requests to submit
|
|
||||||
patches. All contributions must be released under the same MIT
|
|
||||||
license that CodeMirror uses.</p>
|
|
||||||
|
|
||||||
<p>Discussion around the project is done on
|
|
||||||
a <a href="http://discuss.codemirror.net">discussion forum</a>.
|
|
||||||
There is also
|
|
||||||
the <a href="http://groups.google.com/group/codemirror-announce">codemirror-announce</a>
|
|
||||||
list, which is only used for major announcements (such as new
|
|
||||||
versions). If needed, you can
|
|
||||||
contact <a href="mailto:marijnh@gmail.com">the maintainer</a>
|
|
||||||
directly.</p>
|
|
||||||
|
|
||||||
<p>A list of CodeMirror-related software that is not part of the
|
|
||||||
main distribution is maintained
|
|
||||||
on <a href="https://github.com/codemirror/CodeMirror/wiki/CodeMirror-addons">our
|
|
||||||
wiki</a>. Feel free to add your project.</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id=browsersupport>
|
|
||||||
<h2>Browser support</h2>
|
|
||||||
<p>The <em>desktop</em> versions of the following browsers,
|
|
||||||
in <em>standards mode</em> (HTML5 <code><!doctype html></code>
|
|
||||||
recommended) are supported:</p>
|
|
||||||
<table style="margin-bottom: 1em">
|
|
||||||
<tr><th>Firefox</th><td>version 4 and up</td></tr>
|
|
||||||
<tr><th>Chrome</th><td>any version</td></tr>
|
|
||||||
<tr><th>Safari</th><td>version 5.2 and up</td></tr>
|
|
||||||
<tr><th style="padding-right: 1em;">Internet Explorer</th><td>version 8 and up</td></tr>
|
|
||||||
<tr><th>Opera</th><td>version 9 and up</td></tr>
|
|
||||||
</table>
|
|
||||||
<p>Modern mobile browsers tend to partly work. Bug reports and
|
|
||||||
patches for mobile support are welcome, but the maintainer does not
|
|
||||||
have the time or budget to actually work on it himself.</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</article>
|
|
@ -1,884 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function(mod) {
|
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
||||||
mod(require("../../lib/codemirror"));
|
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
|
||||||
define(["../../lib/codemirror"], mod);
|
|
||||||
else // Plain browser env
|
|
||||||
mod(CodeMirror);
|
|
||||||
})(function(CodeMirror) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Context(indented, column, type, info, align, prev) {
|
|
||||||
this.indented = indented;
|
|
||||||
this.column = column;
|
|
||||||
this.type = type;
|
|
||||||
this.info = info;
|
|
||||||
this.align = align;
|
|
||||||
this.prev = prev;
|
|
||||||
}
|
|
||||||
function pushContext(state, col, type, info) {
|
|
||||||
var indent = state.indented;
|
|
||||||
if (state.context && state.context.type == "statement" && type != "statement")
|
|
||||||
indent = state.context.indented;
|
|
||||||
return state.context = new Context(indent, col, type, info, null, state.context);
|
|
||||||
}
|
|
||||||
function popContext(state) {
|
|
||||||
var t = state.context.type;
|
|
||||||
if (t == ")" || t == "]" || t == "}")
|
|
||||||
state.indented = state.context.indented;
|
|
||||||
return state.context = state.context.prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeBefore(stream, state, pos) {
|
|
||||||
if (state.prevToken == "variable" || state.prevToken == "type") return true;
|
|
||||||
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
|
|
||||||
if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isTopScope(context) {
|
|
||||||
for (;;) {
|
|
||||||
if (!context || context.type == "top") return true;
|
|
||||||
if (context.type == "}" && context.prev.info != "namespace") return false;
|
|
||||||
context = context.prev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
||||||
var indentUnit = config.indentUnit,
|
|
||||||
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
|
||||||
dontAlignCalls = parserConfig.dontAlignCalls,
|
|
||||||
keywords = parserConfig.keywords || {},
|
|
||||||
types = parserConfig.types || {},
|
|
||||||
builtin = parserConfig.builtin || {},
|
|
||||||
blockKeywords = parserConfig.blockKeywords || {},
|
|
||||||
defKeywords = parserConfig.defKeywords || {},
|
|
||||||
atoms = parserConfig.atoms || {},
|
|
||||||
hooks = parserConfig.hooks || {},
|
|
||||||
multiLineStrings = parserConfig.multiLineStrings,
|
|
||||||
indentStatements = parserConfig.indentStatements !== false,
|
|
||||||
indentSwitch = parserConfig.indentSwitch !== false,
|
|
||||||
namespaceSeparator = parserConfig.namespaceSeparator,
|
|
||||||
isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/,
|
|
||||||
numberStart = parserConfig.numberStart || /[\d\.]/,
|
|
||||||
number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
|
|
||||||
isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
|
|
||||||
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/,
|
|
||||||
// An optional function that takes a {string} token and returns true if it
|
|
||||||
// should be treated as a builtin.
|
|
||||||
isReservedIdentifier = parserConfig.isReservedIdentifier || false;
|
|
||||||
|
|
||||||
var curPunc, isDefKeyword;
|
|
||||||
|
|
||||||
function tokenBase(stream, state) {
|
|
||||||
var ch = stream.next();
|
|
||||||
if (hooks[ch]) {
|
|
||||||
var result = hooks[ch](stream, state);
|
|
||||||
if (result !== false) return result;
|
|
||||||
}
|
|
||||||
if (ch == '"' || ch == "'") {
|
|
||||||
state.tokenize = tokenString(ch);
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
}
|
|
||||||
if (isPunctuationChar.test(ch)) {
|
|
||||||
curPunc = ch;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (numberStart.test(ch)) {
|
|
||||||
stream.backUp(1)
|
|
||||||
if (stream.match(number)) return "number"
|
|
||||||
stream.next()
|
|
||||||
}
|
|
||||||
if (ch == "/") {
|
|
||||||
if (stream.eat("*")) {
|
|
||||||
state.tokenize = tokenComment;
|
|
||||||
return tokenComment(stream, state);
|
|
||||||
}
|
|
||||||
if (stream.eat("/")) {
|
|
||||||
stream.skipToEnd();
|
|
||||||
return "comment";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isOperatorChar.test(ch)) {
|
|
||||||
while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {}
|
|
||||||
return "operator";
|
|
||||||
}
|
|
||||||
stream.eatWhile(isIdentifierChar);
|
|
||||||
if (namespaceSeparator) while (stream.match(namespaceSeparator))
|
|
||||||
stream.eatWhile(isIdentifierChar);
|
|
||||||
|
|
||||||
var cur = stream.current();
|
|
||||||
if (contains(keywords, cur)) {
|
|
||||||
if (contains(blockKeywords, cur)) curPunc = "newstatement";
|
|
||||||
if (contains(defKeywords, cur)) isDefKeyword = true;
|
|
||||||
return "keyword";
|
|
||||||
}
|
|
||||||
if (contains(types, cur)) return "type";
|
|
||||||
if (contains(builtin, cur)
|
|
||||||
|| (isReservedIdentifier && isReservedIdentifier(cur))) {
|
|
||||||
if (contains(blockKeywords, cur)) curPunc = "newstatement";
|
|
||||||
return "builtin";
|
|
||||||
}
|
|
||||||
if (contains(atoms, cur)) return "atom";
|
|
||||||
return "variable";
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenString(quote) {
|
|
||||||
return function(stream, state) {
|
|
||||||
var escaped = false, next, end = false;
|
|
||||||
while ((next = stream.next()) != null) {
|
|
||||||
if (next == quote && !escaped) {end = true; break;}
|
|
||||||
escaped = !escaped && next == "\\";
|
|
||||||
}
|
|
||||||
if (end || !(escaped || multiLineStrings))
|
|
||||||
state.tokenize = null;
|
|
||||||
return "string";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenComment(stream, state) {
|
|
||||||
var maybeEnd = false, ch;
|
|
||||||
while (ch = stream.next()) {
|
|
||||||
if (ch == "/" && maybeEnd) {
|
|
||||||
state.tokenize = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
maybeEnd = (ch == "*");
|
|
||||||
}
|
|
||||||
return "comment";
|
|
||||||
}
|
|
||||||
|
|
||||||
function maybeEOL(stream, state) {
|
|
||||||
if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context))
|
|
||||||
state.typeAtEndOfLine = typeBefore(stream, state, stream.pos)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interface
|
|
||||||
|
|
||||||
return {
|
|
||||||
startState: function(basecolumn) {
|
|
||||||
return {
|
|
||||||
tokenize: null,
|
|
||||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false),
|
|
||||||
indented: 0,
|
|
||||||
startOfLine: true,
|
|
||||||
prevToken: null
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
token: function(stream, state) {
|
|
||||||
var ctx = state.context;
|
|
||||||
if (stream.sol()) {
|
|
||||||
if (ctx.align == null) ctx.align = false;
|
|
||||||
state.indented = stream.indentation();
|
|
||||||
state.startOfLine = true;
|
|
||||||
}
|
|
||||||
if (stream.eatSpace()) { maybeEOL(stream, state); return null; }
|
|
||||||
curPunc = isDefKeyword = null;
|
|
||||||
var style = (state.tokenize || tokenBase)(stream, state);
|
|
||||||
if (style == "comment" || style == "meta") return style;
|
|
||||||
if (ctx.align == null) ctx.align = true;
|
|
||||||
|
|
||||||
if (curPunc == ";" || curPunc == ":" || (curPunc == "," && stream.match(/^\s*(?:\/\/.*)?$/, false)))
|
|
||||||
while (state.context.type == "statement") popContext(state);
|
|
||||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
|
||||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
|
||||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
|
||||||
else if (curPunc == "}") {
|
|
||||||
while (ctx.type == "statement") ctx = popContext(state);
|
|
||||||
if (ctx.type == "}") ctx = popContext(state);
|
|
||||||
while (ctx.type == "statement") ctx = popContext(state);
|
|
||||||
}
|
|
||||||
else if (curPunc == ctx.type) popContext(state);
|
|
||||||
else if (indentStatements &&
|
|
||||||
(((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
|
|
||||||
(ctx.type == "statement" && curPunc == "newstatement"))) {
|
|
||||||
pushContext(state, stream.column(), "statement", stream.current());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style == "variable" &&
|
|
||||||
((state.prevToken == "def" ||
|
|
||||||
(parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) &&
|
|
||||||
isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
|
|
||||||
style = "def";
|
|
||||||
|
|
||||||
if (hooks.token) {
|
|
||||||
var result = hooks.token(stream, state, style);
|
|
||||||
if (result !== undefined) style = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style == "def" && parserConfig.styleDefs === false) style = "variable";
|
|
||||||
|
|
||||||
state.startOfLine = false;
|
|
||||||
state.prevToken = isDefKeyword ? "def" : style || curPunc;
|
|
||||||
maybeEOL(stream, state);
|
|
||||||
return style;
|
|
||||||
},
|
|
||||||
|
|
||||||
indent: function(state, textAfter) {
|
|
||||||
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
|
|
||||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
|
||||||
var closing = firstChar == ctx.type;
|
|
||||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
|
||||||
if (parserConfig.dontIndentStatements)
|
|
||||||
while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
|
|
||||||
ctx = ctx.prev
|
|
||||||
if (hooks.indent) {
|
|
||||||
var hook = hooks.indent(state, ctx, textAfter, indentUnit);
|
|
||||||
if (typeof hook == "number") return hook
|
|
||||||
}
|
|
||||||
var switchBlock = ctx.prev && ctx.prev.info == "switch";
|
|
||||||
if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
|
|
||||||
while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
|
|
||||||
return ctx.indented
|
|
||||||
}
|
|
||||||
if (ctx.type == "statement")
|
|
||||||
return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
|
||||||
if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
|
|
||||||
return ctx.column + (closing ? 0 : 1);
|
|
||||||
if (ctx.type == ")" && !closing)
|
|
||||||
return ctx.indented + statementIndentUnit;
|
|
||||||
|
|
||||||
return ctx.indented + (closing ? 0 : indentUnit) +
|
|
||||||
(!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? indentUnit : 0);
|
|
||||||
},
|
|
||||||
|
|
||||||
electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/,
|
|
||||||
blockCommentStart: "/*",
|
|
||||||
blockCommentEnd: "*/",
|
|
||||||
blockCommentContinue: " * ",
|
|
||||||
lineComment: "//",
|
|
||||||
fold: "brace"
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
function words(str) {
|
|
||||||
var obj = {}, words = str.split(" ");
|
|
||||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
function contains(words, word) {
|
|
||||||
if (typeof words === "function") {
|
|
||||||
return words(word);
|
|
||||||
} else {
|
|
||||||
return words.propertyIsEnumerable(word);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var cKeywords = "auto if break case register continue return default do sizeof " +
|
|
||||||
"static else struct switch extern typedef union for goto while enum const " +
|
|
||||||
"volatile inline restrict asm fortran";
|
|
||||||
|
|
||||||
// Do not use this. Use the cTypes function below. This is global just to avoid
|
|
||||||
// excessive calls when cTypes is being called multiple times during a parse.
|
|
||||||
var basicCTypes = words("int long char short double float unsigned signed " +
|
|
||||||
"void bool");
|
|
||||||
|
|
||||||
// Do not use this. Use the objCTypes function below. This is global just to avoid
|
|
||||||
// excessive calls when objCTypes is being called multiple times during a parse.
|
|
||||||
var basicObjCTypes = words("SEL instancetype id Class Protocol BOOL");
|
|
||||||
|
|
||||||
// Returns true if identifier is a "C" type.
|
|
||||||
// C type is defined as those that are reserved by the compiler (basicTypes),
|
|
||||||
// and those that end in _t (Reserved by POSIX for types)
|
|
||||||
// http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
|
|
||||||
function cTypes(identifier) {
|
|
||||||
return contains(basicCTypes, identifier) || /.+_t/.test(identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if identifier is a "Objective C" type.
|
|
||||||
function objCTypes(identifier) {
|
|
||||||
return cTypes(identifier) || contains(basicObjCTypes, identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
var cBlockKeywords = "case do else for if switch while struct enum union";
|
|
||||||
var cDefKeywords = "struct enum union";
|
|
||||||
|
|
||||||
function cppHook(stream, state) {
|
|
||||||
if (!state.startOfLine) return false
|
|
||||||
for (var ch, next = null; ch = stream.peek();) {
|
|
||||||
if (ch == "\\" && stream.match(/^.$/)) {
|
|
||||||
next = cppHook
|
|
||||||
break
|
|
||||||
} else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
stream.next()
|
|
||||||
}
|
|
||||||
state.tokenize = next
|
|
||||||
return "meta"
|
|
||||||
}
|
|
||||||
|
|
||||||
function pointerHook(_stream, state) {
|
|
||||||
if (state.prevToken == "type") return "type";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For C and C++ (and ObjC): identifiers starting with __
|
|
||||||
// or _ followed by a capital letter are reserved for the compiler.
|
|
||||||
function cIsReservedIdentifier(token) {
|
|
||||||
if (!token || token.length < 2) return false;
|
|
||||||
if (token[0] != '_') return false;
|
|
||||||
return (token[1] == '_') || (token[1] !== token[1].toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
function cpp14Literal(stream) {
|
|
||||||
stream.eatWhile(/[\w\.']/);
|
|
||||||
return "number";
|
|
||||||
}
|
|
||||||
|
|
||||||
function cpp11StringHook(stream, state) {
|
|
||||||
stream.backUp(1);
|
|
||||||
// Raw strings.
|
|
||||||
if (stream.match(/(R|u8R|uR|UR|LR)/)) {
|
|
||||||
var match = stream.match(/"([^\s\\()]{0,16})\(/);
|
|
||||||
if (!match) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
state.cpp11RawStringDelim = match[1];
|
|
||||||
state.tokenize = tokenRawString;
|
|
||||||
return tokenRawString(stream, state);
|
|
||||||
}
|
|
||||||
// Unicode strings/chars.
|
|
||||||
if (stream.match(/(u8|u|U|L)/)) {
|
|
||||||
if (stream.match(/["']/, /* eat */ false)) {
|
|
||||||
return "string";
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Ignore this hook.
|
|
||||||
stream.next();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function cppLooksLikeConstructor(word) {
|
|
||||||
var lastTwo = /(\w+)::~?(\w+)$/.exec(word);
|
|
||||||
return lastTwo && lastTwo[1] == lastTwo[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
// C#-style strings where "" escapes a quote.
|
|
||||||
function tokenAtString(stream, state) {
|
|
||||||
var next;
|
|
||||||
while ((next = stream.next()) != null) {
|
|
||||||
if (next == '"' && !stream.eat('"')) {
|
|
||||||
state.tokenize = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "string";
|
|
||||||
}
|
|
||||||
|
|
||||||
// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
|
|
||||||
// <delim> can be a string up to 16 characters long.
|
|
||||||
function tokenRawString(stream, state) {
|
|
||||||
// Escape characters that have special regex meanings.
|
|
||||||
var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
|
|
||||||
var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
|
|
||||||
if (match)
|
|
||||||
state.tokenize = null;
|
|
||||||
else
|
|
||||||
stream.skipToEnd();
|
|
||||||
return "string";
|
|
||||||
}
|
|
||||||
|
|
||||||
function def(mimes, mode) {
|
|
||||||
if (typeof mimes == "string") mimes = [mimes];
|
|
||||||
var words = [];
|
|
||||||
function add(obj) {
|
|
||||||
if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
|
|
||||||
words.push(prop);
|
|
||||||
}
|
|
||||||
add(mode.keywords);
|
|
||||||
add(mode.types);
|
|
||||||
add(mode.builtin);
|
|
||||||
add(mode.atoms);
|
|
||||||
if (words.length) {
|
|
||||||
mode.helperType = mimes[0];
|
|
||||||
CodeMirror.registerHelper("hintWords", mimes[0], words);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < mimes.length; ++i)
|
|
||||||
CodeMirror.defineMIME(mimes[i], mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words(cKeywords),
|
|
||||||
types: cTypes,
|
|
||||||
blockKeywords: words(cBlockKeywords),
|
|
||||||
defKeywords: words(cDefKeywords),
|
|
||||||
typeFirstDefinitions: true,
|
|
||||||
atoms: words("NULL true false"),
|
|
||||||
isReservedIdentifier: cIsReservedIdentifier,
|
|
||||||
hooks: {
|
|
||||||
"#": cppHook,
|
|
||||||
"*": pointerHook,
|
|
||||||
},
|
|
||||||
modeProps: {fold: ["brace", "include"]}
|
|
||||||
});
|
|
||||||
|
|
||||||
def(["text/x-c++src", "text/x-c++hdr"], {
|
|
||||||
name: "clike",
|
|
||||||
// Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
|
|
||||||
keywords: words(cKeywords + "alignas alignof and and_eq audit axiom bitand bitor catch " +
|
|
||||||
"class compl concept constexpr const_cast decltype delete dynamic_cast " +
|
|
||||||
"explicit export final friend import module mutable namespace new noexcept " +
|
|
||||||
"not not_eq operator or or_eq override private protected public " +
|
|
||||||
"reinterpret_cast requires static_assert static_cast template this " +
|
|
||||||
"thread_local throw try typeid typename using virtual xor xor_eq"),
|
|
||||||
types: cTypes,
|
|
||||||
blockKeywords: words(cBlockKeywords + " class try catch"),
|
|
||||||
defKeywords: words(cDefKeywords + " class namespace"),
|
|
||||||
typeFirstDefinitions: true,
|
|
||||||
atoms: words("true false NULL nullptr"),
|
|
||||||
dontIndentStatements: /^template$/,
|
|
||||||
isIdentifierChar: /[\w\$_~\xa1-\uffff]/,
|
|
||||||
isReservedIdentifier: cIsReservedIdentifier,
|
|
||||||
hooks: {
|
|
||||||
"#": cppHook,
|
|
||||||
"*": pointerHook,
|
|
||||||
"u": cpp11StringHook,
|
|
||||||
"U": cpp11StringHook,
|
|
||||||
"L": cpp11StringHook,
|
|
||||||
"R": cpp11StringHook,
|
|
||||||
"0": cpp14Literal,
|
|
||||||
"1": cpp14Literal,
|
|
||||||
"2": cpp14Literal,
|
|
||||||
"3": cpp14Literal,
|
|
||||||
"4": cpp14Literal,
|
|
||||||
"5": cpp14Literal,
|
|
||||||
"6": cpp14Literal,
|
|
||||||
"7": cpp14Literal,
|
|
||||||
"8": cpp14Literal,
|
|
||||||
"9": cpp14Literal,
|
|
||||||
token: function(stream, state, style) {
|
|
||||||
if (style == "variable" && stream.peek() == "(" &&
|
|
||||||
(state.prevToken == ";" || state.prevToken == null ||
|
|
||||||
state.prevToken == "}") &&
|
|
||||||
cppLooksLikeConstructor(stream.current()))
|
|
||||||
return "def";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
namespaceSeparator: "::",
|
|
||||||
modeProps: {fold: ["brace", "include"]}
|
|
||||||
});
|
|
||||||
|
|
||||||
def("text/x-java", {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words("abstract assert break case catch class const continue default " +
|
|
||||||
"do else enum extends final finally float for goto if implements import " +
|
|
||||||
"instanceof interface native new package private protected public " +
|
|
||||||
"return static strictfp super switch synchronized this throw throws transient " +
|
|
||||||
"try volatile while @interface"),
|
|
||||||
types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " +
|
|
||||||
"Integer Long Number Object Short String StringBuffer StringBuilder Void"),
|
|
||||||
blockKeywords: words("catch class do else finally for if switch try while"),
|
|
||||||
defKeywords: words("class interface enum @interface"),
|
|
||||||
typeFirstDefinitions: true,
|
|
||||||
atoms: words("true false null"),
|
|
||||||
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
|
|
||||||
hooks: {
|
|
||||||
"@": function(stream) {
|
|
||||||
// Don't match the @interface keyword.
|
|
||||||
if (stream.match('interface', false)) return false;
|
|
||||||
|
|
||||||
stream.eatWhile(/[\w\$_]/);
|
|
||||||
return "meta";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modeProps: {fold: ["brace", "import"]}
|
|
||||||
});
|
|
||||||
|
|
||||||
def("text/x-csharp", {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words("abstract as async await base break case catch checked class const continue" +
|
|
||||||
" default delegate do else enum event explicit extern finally fixed for" +
|
|
||||||
" foreach goto if implicit in interface internal is lock namespace new" +
|
|
||||||
" operator out override params private protected public readonly ref return sealed" +
|
|
||||||
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
|
||||||
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
|
||||||
" global group into join let orderby partial remove select set value var yield"),
|
|
||||||
types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" +
|
|
||||||
" Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" +
|
|
||||||
" UInt64 bool byte char decimal double short int long object" +
|
|
||||||
" sbyte float string ushort uint ulong"),
|
|
||||||
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
|
||||||
defKeywords: words("class interface namespace struct var"),
|
|
||||||
typeFirstDefinitions: true,
|
|
||||||
atoms: words("true false null"),
|
|
||||||
hooks: {
|
|
||||||
"@": function(stream, state) {
|
|
||||||
if (stream.eat('"')) {
|
|
||||||
state.tokenize = tokenAtString;
|
|
||||||
return tokenAtString(stream, state);
|
|
||||||
}
|
|
||||||
stream.eatWhile(/[\w\$_]/);
|
|
||||||
return "meta";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function tokenTripleString(stream, state) {
|
|
||||||
var escaped = false;
|
|
||||||
while (!stream.eol()) {
|
|
||||||
if (!escaped && stream.match('"""')) {
|
|
||||||
state.tokenize = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
escaped = stream.next() == "\\" && !escaped;
|
|
||||||
}
|
|
||||||
return "string";
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenNestedComment(depth) {
|
|
||||||
return function (stream, state) {
|
|
||||||
var ch
|
|
||||||
while (ch = stream.next()) {
|
|
||||||
if (ch == "*" && stream.eat("/")) {
|
|
||||||
if (depth == 1) {
|
|
||||||
state.tokenize = null
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
state.tokenize = tokenNestedComment(depth - 1)
|
|
||||||
return state.tokenize(stream, state)
|
|
||||||
}
|
|
||||||
} else if (ch == "/" && stream.eat("*")) {
|
|
||||||
state.tokenize = tokenNestedComment(depth + 1)
|
|
||||||
return state.tokenize(stream, state)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "comment"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def("text/x-scala", {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words(
|
|
||||||
/* scala */
|
|
||||||
"abstract case catch class def do else extends final finally for forSome if " +
|
|
||||||
"implicit import lazy match new null object override package private protected return " +
|
|
||||||
"sealed super this throw trait try type val var while with yield _ " +
|
|
||||||
|
|
||||||
/* package scala */
|
|
||||||
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
|
||||||
"readChar readInt readLong readFloat readDouble"
|
|
||||||
),
|
|
||||||
types: words(
|
|
||||||
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
|
||||||
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Integral Iterable " +
|
|
||||||
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
|
||||||
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
|
||||||
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +
|
|
||||||
|
|
||||||
/* package java.lang */
|
|
||||||
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
|
||||||
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
|
||||||
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
|
||||||
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
|
||||||
),
|
|
||||||
multiLineStrings: true,
|
|
||||||
blockKeywords: words("catch class enum do else finally for forSome if match switch try while"),
|
|
||||||
defKeywords: words("class enum def object package trait type val var"),
|
|
||||||
atoms: words("true false null"),
|
|
||||||
indentStatements: false,
|
|
||||||
indentSwitch: false,
|
|
||||||
isOperatorChar: /[+\-*&%=<>!?|\/#:@]/,
|
|
||||||
hooks: {
|
|
||||||
"@": function(stream) {
|
|
||||||
stream.eatWhile(/[\w\$_]/);
|
|
||||||
return "meta";
|
|
||||||
},
|
|
||||||
'"': function(stream, state) {
|
|
||||||
if (!stream.match('""')) return false;
|
|
||||||
state.tokenize = tokenTripleString;
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
},
|
|
||||||
"'": function(stream) {
|
|
||||||
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
|
||||||
return "atom";
|
|
||||||
},
|
|
||||||
"=": function(stream, state) {
|
|
||||||
var cx = state.context
|
|
||||||
if (cx.type == "}" && cx.align && stream.eat(">")) {
|
|
||||||
state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev)
|
|
||||||
return "operator"
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"/": function(stream, state) {
|
|
||||||
if (!stream.eat("*")) return false
|
|
||||||
state.tokenize = tokenNestedComment(1)
|
|
||||||
return state.tokenize(stream, state)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modeProps: {closeBrackets: {pairs: '()[]{}""', triples: '"'}}
|
|
||||||
});
|
|
||||||
|
|
||||||
function tokenKotlinString(tripleString){
|
|
||||||
return function (stream, state) {
|
|
||||||
var escaped = false, next, end = false;
|
|
||||||
while (!stream.eol()) {
|
|
||||||
if (!tripleString && !escaped && stream.match('"') ) {end = true; break;}
|
|
||||||
if (tripleString && stream.match('"""')) {end = true; break;}
|
|
||||||
next = stream.next();
|
|
||||||
if(!escaped && next == "$" && stream.match('{'))
|
|
||||||
stream.skipTo("}");
|
|
||||||
escaped = !escaped && next == "\\" && !tripleString;
|
|
||||||
}
|
|
||||||
if (end || !tripleString)
|
|
||||||
state.tokenize = null;
|
|
||||||
return "string";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def("text/x-kotlin", {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words(
|
|
||||||
/*keywords*/
|
|
||||||
"package as typealias class interface this super val operator " +
|
|
||||||
"var fun for is in This throw return annotation " +
|
|
||||||
"break continue object if else while do try when !in !is as? " +
|
|
||||||
|
|
||||||
/*soft keywords*/
|
|
||||||
"file import where by get set abstract enum open inner override private public internal " +
|
|
||||||
"protected catch finally out final vararg reified dynamic companion constructor init " +
|
|
||||||
"sealed field property receiver param sparam lateinit data inline noinline tailrec " +
|
|
||||||
"external annotation crossinline const operator infix suspend actual expect setparam"
|
|
||||||
),
|
|
||||||
types: words(
|
|
||||||
/* package java.lang */
|
|
||||||
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
|
||||||
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
|
||||||
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
|
||||||
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void Annotation Any BooleanArray " +
|
|
||||||
"ByteArray Char CharArray DeprecationLevel DoubleArray Enum FloatArray Function Int IntArray Lazy " +
|
|
||||||
"LazyThreadSafetyMode LongArray Nothing ShortArray Unit"
|
|
||||||
),
|
|
||||||
intendSwitch: false,
|
|
||||||
indentStatements: false,
|
|
||||||
multiLineStrings: true,
|
|
||||||
number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+(\.\d+)?|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
|
|
||||||
blockKeywords: words("catch class do else finally for if where try while enum"),
|
|
||||||
defKeywords: words("class val var object interface fun"),
|
|
||||||
atoms: words("true false null this"),
|
|
||||||
hooks: {
|
|
||||||
"@": function(stream) {
|
|
||||||
stream.eatWhile(/[\w\$_]/);
|
|
||||||
return "meta";
|
|
||||||
},
|
|
||||||
'*': function(_stream, state) {
|
|
||||||
return state.prevToken == '.' ? 'variable' : 'operator';
|
|
||||||
},
|
|
||||||
'"': function(stream, state) {
|
|
||||||
state.tokenize = tokenKotlinString(stream.match('""'));
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
},
|
|
||||||
indent: function(state, ctx, textAfter, indentUnit) {
|
|
||||||
var firstChar = textAfter && textAfter.charAt(0);
|
|
||||||
if ((state.prevToken == "}" || state.prevToken == ")") && textAfter == "")
|
|
||||||
return state.indented;
|
|
||||||
if (state.prevToken == "operator" && textAfter != "}" ||
|
|
||||||
state.prevToken == "variable" && firstChar == "." ||
|
|
||||||
(state.prevToken == "}" || state.prevToken == ")") && firstChar == ".")
|
|
||||||
return indentUnit * 2 + ctx.indented;
|
|
||||||
if (ctx.align && ctx.type == "}")
|
|
||||||
return ctx.indented + (state.context.type == (textAfter || "").charAt(0) ? 0 : indentUnit);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modeProps: {closeBrackets: {triples: '"'}}
|
|
||||||
});
|
|
||||||
|
|
||||||
def(["x-shader/x-vertex", "x-shader/x-fragment"], {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words("sampler1D sampler2D sampler3D samplerCube " +
|
|
||||||
"sampler1DShadow sampler2DShadow " +
|
|
||||||
"const attribute uniform varying " +
|
|
||||||
"break continue discard return " +
|
|
||||||
"for while do if else struct " +
|
|
||||||
"in out inout"),
|
|
||||||
types: words("float int bool void " +
|
|
||||||
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
|
||||||
"mat2 mat3 mat4"),
|
|
||||||
blockKeywords: words("for while do if else struct"),
|
|
||||||
builtin: words("radians degrees sin cos tan asin acos atan " +
|
|
||||||
"pow exp log exp2 sqrt inversesqrt " +
|
|
||||||
"abs sign floor ceil fract mod min max clamp mix step smoothstep " +
|
|
||||||
"length distance dot cross normalize ftransform faceforward " +
|
|
||||||
"reflect refract matrixCompMult " +
|
|
||||||
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
|
||||||
"equal notEqual any all not " +
|
|
||||||
"texture1D texture1DProj texture1DLod texture1DProjLod " +
|
|
||||||
"texture2D texture2DProj texture2DLod texture2DProjLod " +
|
|
||||||
"texture3D texture3DProj texture3DLod texture3DProjLod " +
|
|
||||||
"textureCube textureCubeLod " +
|
|
||||||
"shadow1D shadow2D shadow1DProj shadow2DProj " +
|
|
||||||
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
|
|
||||||
"dFdx dFdy fwidth " +
|
|
||||||
"noise1 noise2 noise3 noise4"),
|
|
||||||
atoms: words("true false " +
|
|
||||||
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
|
|
||||||
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
|
|
||||||
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
|
|
||||||
"gl_FogCoord gl_PointCoord " +
|
|
||||||
"gl_Position gl_PointSize gl_ClipVertex " +
|
|
||||||
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
|
|
||||||
"gl_TexCoord gl_FogFragCoord " +
|
|
||||||
"gl_FragCoord gl_FrontFacing " +
|
|
||||||
"gl_FragData gl_FragDepth " +
|
|
||||||
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
|
|
||||||
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
|
|
||||||
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
|
|
||||||
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
|
|
||||||
"gl_ProjectionMatrixInverseTranspose " +
|
|
||||||
"gl_ModelViewProjectionMatrixInverseTranspose " +
|
|
||||||
"gl_TextureMatrixInverseTranspose " +
|
|
||||||
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
|
|
||||||
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
|
|
||||||
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
|
|
||||||
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
|
|
||||||
"gl_FogParameters " +
|
|
||||||
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
|
|
||||||
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
|
|
||||||
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
|
|
||||||
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
|
|
||||||
"gl_MaxDrawBuffers"),
|
|
||||||
indentSwitch: false,
|
|
||||||
hooks: {"#": cppHook},
|
|
||||||
modeProps: {fold: ["brace", "include"]}
|
|
||||||
});
|
|
||||||
|
|
||||||
def("text/x-nesc", {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words(cKeywords + " as atomic async call command component components configuration event generic " +
|
|
||||||
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
|
||||||
"signal task uses abstract extends"),
|
|
||||||
types: cTypes,
|
|
||||||
blockKeywords: words(cBlockKeywords),
|
|
||||||
atoms: words("null true false"),
|
|
||||||
hooks: {"#": cppHook},
|
|
||||||
modeProps: {fold: ["brace", "include"]}
|
|
||||||
});
|
|
||||||
|
|
||||||
def("text/x-objectivec", {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words(cKeywords + " bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
|
|
||||||
"readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
|
|
||||||
"@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
|
|
||||||
"@public @package @private @protected @required @optional @try @catch @finally @import " +
|
|
||||||
"@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available"),
|
|
||||||
types: objCTypes,
|
|
||||||
builtin: words("FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION NS_RETURNS_RETAINED " +
|
|
||||||
"NS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER NS_DESIGNATED_INITIALIZER " +
|
|
||||||
"NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION NS_ASSUME_NONNULL_BEGIN " +
|
|
||||||
"NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"),
|
|
||||||
blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized"),
|
|
||||||
defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class"),
|
|
||||||
dontIndentStatements: /^@.*$/,
|
|
||||||
typeFirstDefinitions: true,
|
|
||||||
atoms: words("YES NO NULL Nil nil true false nullptr"),
|
|
||||||
isReservedIdentifier: cIsReservedIdentifier,
|
|
||||||
hooks: {
|
|
||||||
"#": cppHook,
|
|
||||||
"*": pointerHook,
|
|
||||||
},
|
|
||||||
modeProps: {fold: ["brace", "include"]}
|
|
||||||
});
|
|
||||||
|
|
||||||
def("text/x-squirrel", {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words("base break clone continue const default delete enum extends function in class" +
|
|
||||||
" foreach local resume return this throw typeof yield constructor instanceof static"),
|
|
||||||
types: cTypes,
|
|
||||||
blockKeywords: words("case catch class else for foreach if switch try while"),
|
|
||||||
defKeywords: words("function local class"),
|
|
||||||
typeFirstDefinitions: true,
|
|
||||||
atoms: words("true false null"),
|
|
||||||
hooks: {"#": cppHook},
|
|
||||||
modeProps: {fold: ["brace", "include"]}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ceylon Strings need to deal with interpolation
|
|
||||||
var stringTokenizer = null;
|
|
||||||
function tokenCeylonString(type) {
|
|
||||||
return function(stream, state) {
|
|
||||||
var escaped = false, next, end = false;
|
|
||||||
while (!stream.eol()) {
|
|
||||||
if (!escaped && stream.match('"') &&
|
|
||||||
(type == "single" || stream.match('""'))) {
|
|
||||||
end = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!escaped && stream.match('``')) {
|
|
||||||
stringTokenizer = tokenCeylonString(type);
|
|
||||||
end = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
next = stream.next();
|
|
||||||
escaped = type == "single" && !escaped && next == "\\";
|
|
||||||
}
|
|
||||||
if (end)
|
|
||||||
state.tokenize = null;
|
|
||||||
return "string";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def("text/x-ceylon", {
|
|
||||||
name: "clike",
|
|
||||||
keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" +
|
|
||||||
" exists extends finally for function given if import in interface is let module new" +
|
|
||||||
" nonempty object of out outer package return satisfies super switch then this throw" +
|
|
||||||
" try value void while"),
|
|
||||||
types: function(word) {
|
|
||||||
// In Ceylon all identifiers that start with an uppercase are types
|
|
||||||
var first = word.charAt(0);
|
|
||||||
return (first === first.toUpperCase() && first !== first.toLowerCase());
|
|
||||||
},
|
|
||||||
blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"),
|
|
||||||
defKeywords: words("class dynamic function interface module object package value"),
|
|
||||||
builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" +
|
|
||||||
" native optional sealed see serializable shared suppressWarnings tagged throws variable"),
|
|
||||||
isPunctuationChar: /[\[\]{}\(\),;\:\.`]/,
|
|
||||||
isOperatorChar: /[+\-*&%=<>!?|^~:\/]/,
|
|
||||||
numberStart: /[\d#$]/,
|
|
||||||
number: /^(?:#[\da-fA-F_]+|\$[01_]+|[\d_]+[kMGTPmunpf]?|[\d_]+\.[\d_]+(?:[eE][-+]?\d+|[kMGTPmunpf]|)|)/i,
|
|
||||||
multiLineStrings: true,
|
|
||||||
typeFirstDefinitions: true,
|
|
||||||
atoms: words("true false null larger smaller equal empty finished"),
|
|
||||||
indentSwitch: false,
|
|
||||||
styleDefs: false,
|
|
||||||
hooks: {
|
|
||||||
"@": function(stream) {
|
|
||||||
stream.eatWhile(/[\w\$_]/);
|
|
||||||
return "meta";
|
|
||||||
},
|
|
||||||
'"': function(stream, state) {
|
|
||||||
state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single");
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
},
|
|
||||||
'`': function(stream, state) {
|
|
||||||
if (!stringTokenizer || !stream.match('`')) return false;
|
|
||||||
state.tokenize = stringTokenizer;
|
|
||||||
stringTokenizer = null;
|
|
||||||
return state.tokenize(stream, state);
|
|
||||||
},
|
|
||||||
"'": function(stream) {
|
|
||||||
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
|
||||||
return "atom";
|
|
||||||
},
|
|
||||||
token: function(_stream, state, style) {
|
|
||||||
if ((style == "variable" || style == "type") &&
|
|
||||||
state.prevToken == ".") {
|
|
||||||
return "variable-2";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modeProps: {
|
|
||||||
fold: ["brace", "import"],
|
|
||||||
closeBrackets: {triples: '"'}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@ -1,380 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: C-like mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
|
||||||
<script src="../../addon/hint/show-hint.js"></script>
|
|
||||||
<script src="clike.js"></script>
|
|
||||||
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">C-like</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>C-like mode</h2>
|
|
||||||
|
|
||||||
<div><textarea id="c-code">
|
|
||||||
/* C demo code */
|
|
||||||
|
|
||||||
#include <zmq.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <semaphore.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void* arg_socket;
|
|
||||||
zmq_msg_t* arg_msg;
|
|
||||||
char* arg_string;
|
|
||||||
unsigned long arg_len;
|
|
||||||
int arg_int, arg_command;
|
|
||||||
|
|
||||||
int signal_fd;
|
|
||||||
int pad;
|
|
||||||
void* context;
|
|
||||||
sem_t sem;
|
|
||||||
} acl_zmq_context;
|
|
||||||
|
|
||||||
#define p(X) (context->arg_##X)
|
|
||||||
|
|
||||||
void* zmq_thread(void* context_pointer) {
|
|
||||||
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
|
||||||
char ok = 'K', err = 'X';
|
|
||||||
int res;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
while ((res = sem_wait(&context->sem)) == EINTR);
|
|
||||||
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
|
||||||
switch(p(command)) {
|
|
||||||
case 0: goto cleanup;
|
|
||||||
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
|
||||||
case 2: p(int) = zmq_close(p(socket)); break;
|
|
||||||
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
|
||||||
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
|
||||||
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
|
||||||
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
|
||||||
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
|
||||||
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
|
||||||
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
|
||||||
}
|
|
||||||
p(command) = errno;
|
|
||||||
write(context->signal_fd, &ok, 1);
|
|
||||||
}
|
|
||||||
cleanup:
|
|
||||||
close(context->signal_fd);
|
|
||||||
free(context_pointer);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
|
||||||
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
|
||||||
pthread_t thread;
|
|
||||||
|
|
||||||
context->context = zmq_context;
|
|
||||||
context->signal_fd = signal_fd;
|
|
||||||
sem_init(&context->sem, 1, 0);
|
|
||||||
pthread_create(&thread, 0, &zmq_thread, context);
|
|
||||||
pthread_detach(thread);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<h2>C++ example</h2>
|
|
||||||
|
|
||||||
<div><textarea id="cpp-code">
|
|
||||||
#include <iostream>
|
|
||||||
#include "mystuff/util.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
enum Enum {
|
|
||||||
VAL1, VAL2, VAL3
|
|
||||||
};
|
|
||||||
|
|
||||||
char32_t unicode_string = U"\U0010FFFF";
|
|
||||||
string raw_string = R"delim(anything
|
|
||||||
you
|
|
||||||
want)delim";
|
|
||||||
|
|
||||||
int Helper(const MyType& param) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
class ForwardDec;
|
|
||||||
|
|
||||||
template <class T, class V>
|
|
||||||
class Class : public BaseClass {
|
|
||||||
const MyType<T, V> member_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
const MyType<T, V>& Method() const {
|
|
||||||
return member_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Method2(MyType<T, V>* value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class V>
|
|
||||||
void Class::Method2(MyType<T, V>* value) {
|
|
||||||
std::out << 1 >> method();
|
|
||||||
value->Method3(member_);
|
|
||||||
member_ = value;
|
|
||||||
}
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<h2>Objective-C example</h2>
|
|
||||||
|
|
||||||
<div><textarea id="objectivec-code">
|
|
||||||
/*
|
|
||||||
This is a longer comment
|
|
||||||
That spans two lines
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import "MyClass.h"
|
|
||||||
#import <AFramework/AFrameork.h>
|
|
||||||
@import BFrameworkModule;
|
|
||||||
|
|
||||||
NS_ENUM(SomeValues) {
|
|
||||||
aValue = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A Class Extension with some properties
|
|
||||||
@interface MyClass ()<AProtocol>
|
|
||||||
@property(atomic, readwrite, assign) NSInteger anInt;
|
|
||||||
@property(nonatomic, strong, nullable) NSString *aString;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation YourAppDelegate
|
|
||||||
|
|
||||||
- (instancetype)initWithString:(NSString *)aStringVar {
|
|
||||||
if ((self = [super init])) {
|
|
||||||
aString = aStringVar;
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)doSomething:(float)progress {
|
|
||||||
NSString *myString = @"This is a ObjC string %f ";
|
|
||||||
myString = [[NSString stringWithFormat:myString, progress] stringByAppendingString:self.aString];
|
|
||||||
return myString.length > 100 ? NO : YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<h2>Java example</h2>
|
|
||||||
|
|
||||||
<div><textarea id="java-code">
|
|
||||||
import com.demo.util.MyType;
|
|
||||||
import com.demo.util.MyInterface;
|
|
||||||
|
|
||||||
public enum Enum {
|
|
||||||
VAL1, VAL2, VAL3
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Class<T, V> implements MyInterface {
|
|
||||||
public static final MyType<T, V> member;
|
|
||||||
|
|
||||||
private class InnerClass {
|
|
||||||
public int zero() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MyType method() {
|
|
||||||
return member;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void method2(MyType<T, V> value) {
|
|
||||||
method();
|
|
||||||
value.method3();
|
|
||||||
member = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<h2>Scala example</h2>
|
|
||||||
|
|
||||||
<div><textarea id="scala-code">
|
|
||||||
object FilterTest extends App {
|
|
||||||
def filter(xs: List[Int], threshold: Int) = {
|
|
||||||
def process(ys: List[Int]): List[Int] =
|
|
||||||
if (ys.isEmpty) ys
|
|
||||||
else if (ys.head < threshold) ys.head :: process(ys.tail)
|
|
||||||
else process(ys.tail)
|
|
||||||
process(xs)
|
|
||||||
}
|
|
||||||
println(filter(List(1, 9, 2, 8, 3, 7, 4), 5))
|
|
||||||
}
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<h2>Kotlin mode</h2>
|
|
||||||
|
|
||||||
<div><textarea id="kotlin-code">
|
|
||||||
package org.wasabi.http
|
|
||||||
|
|
||||||
import java.util.concurrent.Executors
|
|
||||||
import java.net.InetSocketAddress
|
|
||||||
import org.wasabi.app.AppConfiguration
|
|
||||||
import io.netty.bootstrap.ServerBootstrap
|
|
||||||
import io.netty.channel.nio.NioEventLoopGroup
|
|
||||||
import io.netty.channel.socket.nio.NioServerSocketChannel
|
|
||||||
import org.wasabi.app.AppServer
|
|
||||||
|
|
||||||
public class HttpServer(private val appServer: AppServer) {
|
|
||||||
|
|
||||||
val bootstrap: ServerBootstrap
|
|
||||||
val primaryGroup: NioEventLoopGroup
|
|
||||||
val workerGroup: NioEventLoopGroup
|
|
||||||
|
|
||||||
init {
|
|
||||||
// Define worker groups
|
|
||||||
primaryGroup = NioEventLoopGroup()
|
|
||||||
workerGroup = NioEventLoopGroup()
|
|
||||||
|
|
||||||
// Initialize bootstrap of server
|
|
||||||
bootstrap = ServerBootstrap()
|
|
||||||
|
|
||||||
bootstrap.group(primaryGroup, workerGroup)
|
|
||||||
bootstrap.channel(javaClass<NioServerSocketChannel>())
|
|
||||||
bootstrap.childHandler(NettyPipelineInitializer(appServer))
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun start(wait: Boolean = true) {
|
|
||||||
val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel()
|
|
||||||
|
|
||||||
if (wait) {
|
|
||||||
channel?.closeFuture()?.sync()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun stop() {
|
|
||||||
// Shutdown all event loops
|
|
||||||
primaryGroup.shutdownGracefully()
|
|
||||||
workerGroup.shutdownGracefully()
|
|
||||||
|
|
||||||
// Wait till all threads are terminated
|
|
||||||
primaryGroup.terminationFuture().sync()
|
|
||||||
workerGroup.terminationFuture().sync()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<h2>Ceylon mode</h2>
|
|
||||||
|
|
||||||
<div><textarea id="ceylon-code">
|
|
||||||
"Produces the [[stream|Iterable]] that results from repeated
|
|
||||||
application of the given [[function|next]] to the given
|
|
||||||
[[first]] element of the stream, until the function first
|
|
||||||
returns [[finished]]. If the given function never returns
|
|
||||||
`finished`, the resulting stream is infinite.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
loop(0)(2.plus).takeWhile(10.largerThan)
|
|
||||||
|
|
||||||
produces the stream `{ 0, 2, 4, 6, 8 }`."
|
|
||||||
tagged("Streams")
|
|
||||||
shared {Element+} loop<Element>(
|
|
||||||
"The first element of the resulting stream."
|
|
||||||
Element first)(
|
|
||||||
"The function that produces the next element of the
|
|
||||||
stream, given the current element. The function may
|
|
||||||
return [[finished]] to indicate the end of the
|
|
||||||
stream."
|
|
||||||
Element|Finished next(Element element))
|
|
||||||
=> let (start = first)
|
|
||||||
object satisfies {Element+} {
|
|
||||||
first => start;
|
|
||||||
empty => false;
|
|
||||||
function nextElement(Element element)
|
|
||||||
=> next(element);
|
|
||||||
iterator()
|
|
||||||
=> object satisfies Iterator<Element> {
|
|
||||||
variable Element|Finished current = start;
|
|
||||||
shared actual Element|Finished next() {
|
|
||||||
if (!is Finished result = current) {
|
|
||||||
current = nextElement(result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return finished;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
</textarea></div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var cEditor = CodeMirror.fromTextArea(document.getElementById("c-code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-csrc"
|
|
||||||
});
|
|
||||||
var cppEditor = CodeMirror.fromTextArea(document.getElementById("cpp-code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-c++src"
|
|
||||||
});
|
|
||||||
var javaEditor = CodeMirror.fromTextArea(document.getElementById("java-code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-java"
|
|
||||||
});
|
|
||||||
var objectivecEditor = CodeMirror.fromTextArea(document.getElementById("objectivec-code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-objectivec"
|
|
||||||
});
|
|
||||||
var scalaEditor = CodeMirror.fromTextArea(document.getElementById("scala-code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-scala"
|
|
||||||
});
|
|
||||||
var kotlinEditor = CodeMirror.fromTextArea(document.getElementById("kotlin-code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-kotlin"
|
|
||||||
});
|
|
||||||
var ceylonEditor = CodeMirror.fromTextArea(document.getElementById("ceylon-code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "text/x-ceylon"
|
|
||||||
});
|
|
||||||
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
|
|
||||||
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>Simple mode that tries to handle C-like languages as well as it
|
|
||||||
can. Takes two configuration parameters: <code>keywords</code>, an
|
|
||||||
object whose property names are the keywords in the language,
|
|
||||||
and <code>useCPP</code>, which determines whether C preprocessor
|
|
||||||
directives are recognized.</p>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
|
||||||
(C), <code>text/x-c++src</code> (C++), <code>text/x-java</code>
|
|
||||||
(Java), <code>text/x-csharp</code> (C#),
|
|
||||||
<code>text/x-objectivec</code> (Objective-C),
|
|
||||||
<code>text/x-scala</code> (Scala), <code>text/x-vertex</code>
|
|
||||||
<code>x-shader/x-fragment</code> (shader programs),
|
|
||||||
<code>text/x-squirrel</code> (Squirrel) and
|
|
||||||
<code>text/x-ceylon</code> (Ceylon)</p>
|
|
||||||
</article>
|
|
@ -1,767 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: Scala mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<link rel="stylesheet" href="../../theme/ambiance.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="clike.js"></script>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">Scala</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>Scala mode</h2>
|
|
||||||
<form>
|
|
||||||
<textarea id="code" name="code">
|
|
||||||
|
|
||||||
/* __ *\
|
|
||||||
** ________ ___ / / ___ Scala API **
|
|
||||||
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
|
|
||||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
|
||||||
** |/ **
|
|
||||||
\* */
|
|
||||||
|
|
||||||
package scala.collection
|
|
||||||
|
|
||||||
import generic._
|
|
||||||
import mutable.{ Builder, ListBuffer }
|
|
||||||
import annotation.{tailrec, migration, bridge}
|
|
||||||
import annotation.unchecked.{ uncheckedVariance => uV }
|
|
||||||
import parallel.ParIterable
|
|
||||||
|
|
||||||
/** A template trait for traversable collections of type `Traversable[A]`.
|
|
||||||
*
|
|
||||||
* $traversableInfo
|
|
||||||
* @define mutability
|
|
||||||
* @define traversableInfo
|
|
||||||
* This is a base trait of all kinds of $mutability Scala collections. It
|
|
||||||
* implements the behavior common to all collections, in terms of a method
|
|
||||||
* `foreach` with signature:
|
|
||||||
* {{{
|
|
||||||
* def foreach[U](f: Elem => U): Unit
|
|
||||||
* }}}
|
|
||||||
* Collection classes mixing in this trait provide a concrete
|
|
||||||
* `foreach` method which traverses all the
|
|
||||||
* elements contained in the collection, applying a given function to each.
|
|
||||||
* They also need to provide a method `newBuilder`
|
|
||||||
* which creates a builder for collections of the same kind.
|
|
||||||
*
|
|
||||||
* A traversable class might or might not have two properties: strictness
|
|
||||||
* and orderedness. Neither is represented as a type.
|
|
||||||
*
|
|
||||||
* The instances of a strict collection class have all their elements
|
|
||||||
* computed before they can be used as values. By contrast, instances of
|
|
||||||
* a non-strict collection class may defer computation of some of their
|
|
||||||
* elements until after the instance is available as a value.
|
|
||||||
* A typical example of a non-strict collection class is a
|
|
||||||
* <a href="../immutable/Stream.html" target="ContentFrame">
|
|
||||||
* `scala.collection.immutable.Stream`</a>.
|
|
||||||
* A more general class of examples are `TraversableViews`.
|
|
||||||
*
|
|
||||||
* If a collection is an instance of an ordered collection class, traversing
|
|
||||||
* its elements with `foreach` will always visit elements in the
|
|
||||||
* same order, even for different runs of the program. If the class is not
|
|
||||||
* ordered, `foreach` can visit elements in different orders for
|
|
||||||
* different runs (but it will keep the same order in the same run).'
|
|
||||||
*
|
|
||||||
* A typical example of a collection class which is not ordered is a
|
|
||||||
* `HashMap` of objects. The traversal order for hash maps will
|
|
||||||
* depend on the hash codes of its elements, and these hash codes might
|
|
||||||
* differ from one run to the next. By contrast, a `LinkedHashMap`
|
|
||||||
* is ordered because it's `foreach` method visits elements in the
|
|
||||||
* order they were inserted into the `HashMap`.
|
|
||||||
*
|
|
||||||
* @author Martin Odersky
|
|
||||||
* @version 2.8
|
|
||||||
* @since 2.8
|
|
||||||
* @tparam A the element type of the collection
|
|
||||||
* @tparam Repr the type of the actual collection containing the elements.
|
|
||||||
*
|
|
||||||
* @define Coll Traversable
|
|
||||||
* @define coll traversable collection
|
|
||||||
*/
|
|
||||||
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
|
|
||||||
with FilterMonadic[A, Repr]
|
|
||||||
with TraversableOnce[A]
|
|
||||||
with GenTraversableLike[A, Repr]
|
|
||||||
with Parallelizable[A, ParIterable[A]]
|
|
||||||
{
|
|
||||||
self =>
|
|
||||||
|
|
||||||
import Traversable.breaks._
|
|
||||||
|
|
||||||
/** The type implementing this traversable */
|
|
||||||
protected type Self = Repr
|
|
||||||
|
|
||||||
/** The collection of type $coll underlying this `TraversableLike` object.
|
|
||||||
* By default this is implemented as the `TraversableLike` object itself,
|
|
||||||
* but this can be overridden.
|
|
||||||
*/
|
|
||||||
def repr: Repr = this.asInstanceOf[Repr]
|
|
||||||
|
|
||||||
/** The underlying collection seen as an instance of `$Coll`.
|
|
||||||
* By default this is implemented as the current collection object itself,
|
|
||||||
* but this can be overridden.
|
|
||||||
*/
|
|
||||||
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
|
|
||||||
|
|
||||||
/** A conversion from collections of type `Repr` to `$Coll` objects.
|
|
||||||
* By default this is implemented as just a cast, but this can be overridden.
|
|
||||||
*/
|
|
||||||
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
|
|
||||||
|
|
||||||
/** Creates a new builder for this collection type.
|
|
||||||
*/
|
|
||||||
protected[this] def newBuilder: Builder[A, Repr]
|
|
||||||
|
|
||||||
protected[this] def parCombiner = ParIterable.newCombiner[A]
|
|
||||||
|
|
||||||
/** Applies a function `f` to all elements of this $coll.
|
|
||||||
*
|
|
||||||
* Note: this method underlies the implementation of most other bulk operations.
|
|
||||||
* It's important to implement this method in an efficient way.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param f the function that is applied for its side-effect to every element.
|
|
||||||
* The result of function `f` is discarded.
|
|
||||||
*
|
|
||||||
* @tparam U the type parameter describing the result of function `f`.
|
|
||||||
* This result will always be ignored. Typically `U` is `Unit`,
|
|
||||||
* but this is not necessary.
|
|
||||||
*
|
|
||||||
* @usecase def foreach(f: A => Unit): Unit
|
|
||||||
*/
|
|
||||||
def foreach[U](f: A => U): Unit
|
|
||||||
|
|
||||||
/** Tests whether this $coll is empty.
|
|
||||||
*
|
|
||||||
* @return `true` if the $coll contain no elements, `false` otherwise.
|
|
||||||
*/
|
|
||||||
def isEmpty: Boolean = {
|
|
||||||
var result = true
|
|
||||||
breakable {
|
|
||||||
for (x <- this) {
|
|
||||||
result = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tests whether this $coll is known to have a finite size.
|
|
||||||
* All strict collections are known to have finite size. For a non-strict collection
|
|
||||||
* such as `Stream`, the predicate returns `true` if all elements have been computed.
|
|
||||||
* It returns `false` if the stream is not yet evaluated to the end.
|
|
||||||
*
|
|
||||||
* Note: many collection methods will not work on collections of infinite sizes.
|
|
||||||
*
|
|
||||||
* @return `true` if this collection is known to have finite size, `false` otherwise.
|
|
||||||
*/
|
|
||||||
def hasDefiniteSize = true
|
|
||||||
|
|
||||||
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
|
|
||||||
b ++= thisCollection
|
|
||||||
b ++= that.seq
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
@bridge
|
|
||||||
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
|
||||||
++(that: GenTraversableOnce[B])(bf)
|
|
||||||
|
|
||||||
/** Concatenates this $coll with the elements of a traversable collection.
|
|
||||||
* It differs from ++ in that the right operand determines the type of the
|
|
||||||
* resulting collection rather than the left one.
|
|
||||||
*
|
|
||||||
* @param that the traversable to append.
|
|
||||||
* @tparam B the element type of the returned collection.
|
|
||||||
* @tparam That $thatinfo
|
|
||||||
* @param bf $bfinfo
|
|
||||||
* @return a new collection of type `That` which contains all elements
|
|
||||||
* of this $coll followed by all elements of `that`.
|
|
||||||
*
|
|
||||||
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
|
|
||||||
*
|
|
||||||
* @return a new $coll which contains all elements of this $coll
|
|
||||||
* followed by all elements of `that`.
|
|
||||||
*/
|
|
||||||
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
|
|
||||||
b ++= that
|
|
||||||
b ++= thisCollection
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This overload exists because: for the implementation of ++: we should reuse
|
|
||||||
* that of ++ because many collections override it with more efficient versions.
|
|
||||||
* Since TraversableOnce has no '++' method, we have to implement that directly,
|
|
||||||
* but Traversable and down can use the overload.
|
|
||||||
*/
|
|
||||||
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
|
||||||
(that ++ seq)(breakOut)
|
|
||||||
|
|
||||||
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
b.sizeHint(this)
|
|
||||||
for (x <- this) b += f(x)
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
for (x <- this) b ++= f(x).seq
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Selects all elements of this $coll which satisfy a predicate.
|
|
||||||
*
|
|
||||||
* @param p the predicate used to test elements.
|
|
||||||
* @return a new $coll consisting of all elements of this $coll that satisfy the given
|
|
||||||
* predicate `p`. The order of the elements is preserved.
|
|
||||||
*/
|
|
||||||
def filter(p: A => Boolean): Repr = {
|
|
||||||
val b = newBuilder
|
|
||||||
for (x <- this)
|
|
||||||
if (p(x)) b += x
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Selects all elements of this $coll which do not satisfy a predicate.
|
|
||||||
*
|
|
||||||
* @param p the predicate used to test elements.
|
|
||||||
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
|
|
||||||
* predicate `p`. The order of the elements is preserved.
|
|
||||||
*/
|
|
||||||
def filterNot(p: A => Boolean): Repr = filter(!p(_))
|
|
||||||
|
|
||||||
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Builds a new collection by applying an option-valued function to all
|
|
||||||
* elements of this $coll on which the function is defined.
|
|
||||||
*
|
|
||||||
* @param f the option-valued function which filters and maps the $coll.
|
|
||||||
* @tparam B the element type of the returned collection.
|
|
||||||
* @tparam That $thatinfo
|
|
||||||
* @param bf $bfinfo
|
|
||||||
* @return a new collection of type `That` resulting from applying the option-valued function
|
|
||||||
* `f` to each element and collecting all defined results.
|
|
||||||
* The order of the elements is preserved.
|
|
||||||
*
|
|
||||||
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
|
|
||||||
*
|
|
||||||
* @param pf the partial function which filters and maps the $coll.
|
|
||||||
* @return a new $coll resulting from applying the given option-valued function
|
|
||||||
* `f` to each element and collecting all defined results.
|
|
||||||
* The order of the elements is preserved.
|
|
||||||
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
for (x <- this)
|
|
||||||
f(x) match {
|
|
||||||
case Some(y) => b += y
|
|
||||||
case _ =>
|
|
||||||
}
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Partitions this $coll in two ${coll}s according to a predicate.
|
|
||||||
*
|
|
||||||
* @param p the predicate on which to partition.
|
|
||||||
* @return a pair of ${coll}s: the first $coll consists of all elements that
|
|
||||||
* satisfy the predicate `p` and the second $coll consists of all elements
|
|
||||||
* that don't. The relative order of the elements in the resulting ${coll}s
|
|
||||||
* is the same as in the original $coll.
|
|
||||||
*/
|
|
||||||
def partition(p: A => Boolean): (Repr, Repr) = {
|
|
||||||
val l, r = newBuilder
|
|
||||||
for (x <- this) (if (p(x)) l else r) += x
|
|
||||||
(l.result, r.result)
|
|
||||||
}
|
|
||||||
|
|
||||||
def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
|
|
||||||
val m = mutable.Map.empty[K, Builder[A, Repr]]
|
|
||||||
for (elem <- this) {
|
|
||||||
val key = f(elem)
|
|
||||||
val bldr = m.getOrElseUpdate(key, newBuilder)
|
|
||||||
bldr += elem
|
|
||||||
}
|
|
||||||
val b = immutable.Map.newBuilder[K, Repr]
|
|
||||||
for ((k, v) <- m)
|
|
||||||
b += ((k, v.result))
|
|
||||||
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tests whether a predicate holds for all elements of this $coll.
|
|
||||||
*
|
|
||||||
* $mayNotTerminateInf
|
|
||||||
*
|
|
||||||
* @param p the predicate used to test elements.
|
|
||||||
* @return `true` if the given predicate `p` holds for all elements
|
|
||||||
* of this $coll, otherwise `false`.
|
|
||||||
*/
|
|
||||||
def forall(p: A => Boolean): Boolean = {
|
|
||||||
var result = true
|
|
||||||
breakable {
|
|
||||||
for (x <- this)
|
|
||||||
if (!p(x)) { result = false; break }
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tests whether a predicate holds for some of the elements of this $coll.
|
|
||||||
*
|
|
||||||
* $mayNotTerminateInf
|
|
||||||
*
|
|
||||||
* @param p the predicate used to test elements.
|
|
||||||
* @return `true` if the given predicate `p` holds for some of the
|
|
||||||
* elements of this $coll, otherwise `false`.
|
|
||||||
*/
|
|
||||||
def exists(p: A => Boolean): Boolean = {
|
|
||||||
var result = false
|
|
||||||
breakable {
|
|
||||||
for (x <- this)
|
|
||||||
if (p(x)) { result = true; break }
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Finds the first element of the $coll satisfying a predicate, if any.
|
|
||||||
*
|
|
||||||
* $mayNotTerminateInf
|
|
||||||
* $orderDependent
|
|
||||||
*
|
|
||||||
* @param p the predicate used to test elements.
|
|
||||||
* @return an option value containing the first element in the $coll
|
|
||||||
* that satisfies `p`, or `None` if none exists.
|
|
||||||
*/
|
|
||||||
def find(p: A => Boolean): Option[A] = {
|
|
||||||
var result: Option[A] = None
|
|
||||||
breakable {
|
|
||||||
for (x <- this)
|
|
||||||
if (p(x)) { result = Some(x); break }
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
|
|
||||||
|
|
||||||
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
b.sizeHint(this, 1)
|
|
||||||
var acc = z
|
|
||||||
b += acc
|
|
||||||
for (x <- this) { acc = op(acc, x); b += acc }
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
@migration(2, 9,
|
|
||||||
"This scanRight definition has changed in 2.9.\n" +
|
|
||||||
"The previous behavior can be reproduced with scanRight.reverse."
|
|
||||||
)
|
|
||||||
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
var scanned = List(z)
|
|
||||||
var acc = z
|
|
||||||
for (x <- reversed) {
|
|
||||||
acc = op(x, acc)
|
|
||||||
scanned ::= acc
|
|
||||||
}
|
|
||||||
val b = bf(repr)
|
|
||||||
for (elem <- scanned) b += elem
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Selects the first element of this $coll.
|
|
||||||
* $orderDependent
|
|
||||||
* @return the first element of this $coll.
|
|
||||||
* @throws `NoSuchElementException` if the $coll is empty.
|
|
||||||
*/
|
|
||||||
def head: A = {
|
|
||||||
var result: () => A = () => throw new NoSuchElementException
|
|
||||||
breakable {
|
|
||||||
for (x <- this) {
|
|
||||||
result = () => x
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Optionally selects the first element.
|
|
||||||
* $orderDependent
|
|
||||||
* @return the first element of this $coll if it is nonempty, `None` if it is empty.
|
|
||||||
*/
|
|
||||||
def headOption: Option[A] = if (isEmpty) None else Some(head)
|
|
||||||
|
|
||||||
/** Selects all elements except the first.
|
|
||||||
* $orderDependent
|
|
||||||
* @return a $coll consisting of all elements of this $coll
|
|
||||||
* except the first one.
|
|
||||||
* @throws `UnsupportedOperationException` if the $coll is empty.
|
|
||||||
*/
|
|
||||||
override def tail: Repr = {
|
|
||||||
if (isEmpty) throw new UnsupportedOperationException("empty.tail")
|
|
||||||
drop(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Selects the last element.
|
|
||||||
* $orderDependent
|
|
||||||
* @return The last element of this $coll.
|
|
||||||
* @throws NoSuchElementException If the $coll is empty.
|
|
||||||
*/
|
|
||||||
def last: A = {
|
|
||||||
var lst = head
|
|
||||||
for (x <- this)
|
|
||||||
lst = x
|
|
||||||
lst
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Optionally selects the last element.
|
|
||||||
* $orderDependent
|
|
||||||
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
|
|
||||||
*/
|
|
||||||
def lastOption: Option[A] = if (isEmpty) None else Some(last)
|
|
||||||
|
|
||||||
/** Selects all elements except the last.
|
|
||||||
* $orderDependent
|
|
||||||
* @return a $coll consisting of all elements of this $coll
|
|
||||||
* except the last one.
|
|
||||||
* @throws `UnsupportedOperationException` if the $coll is empty.
|
|
||||||
*/
|
|
||||||
def init: Repr = {
|
|
||||||
if (isEmpty) throw new UnsupportedOperationException("empty.init")
|
|
||||||
var lst = head
|
|
||||||
var follow = false
|
|
||||||
val b = newBuilder
|
|
||||||
b.sizeHint(this, -1)
|
|
||||||
for (x <- this.seq) {
|
|
||||||
if (follow) b += lst
|
|
||||||
else follow = true
|
|
||||||
lst = x
|
|
||||||
}
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
def take(n: Int): Repr = slice(0, n)
|
|
||||||
|
|
||||||
def drop(n: Int): Repr =
|
|
||||||
if (n <= 0) {
|
|
||||||
val b = newBuilder
|
|
||||||
b.sizeHint(this)
|
|
||||||
b ++= thisCollection result
|
|
||||||
}
|
|
||||||
else sliceWithKnownDelta(n, Int.MaxValue, -n)
|
|
||||||
|
|
||||||
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
|
|
||||||
|
|
||||||
// Precondition: from >= 0, until > 0, builder already configured for building.
|
|
||||||
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
|
|
||||||
var i = 0
|
|
||||||
breakable {
|
|
||||||
for (x <- this.seq) {
|
|
||||||
if (i >= from) b += x
|
|
||||||
i += 1
|
|
||||||
if (i >= until) break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
// Precondition: from >= 0
|
|
||||||
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
|
|
||||||
val b = newBuilder
|
|
||||||
if (until <= from) b.result
|
|
||||||
else {
|
|
||||||
b.sizeHint(this, delta)
|
|
||||||
sliceInternal(from, until, b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Precondition: from >= 0
|
|
||||||
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
|
|
||||||
val b = newBuilder
|
|
||||||
if (until <= from) b.result
|
|
||||||
else {
|
|
||||||
b.sizeHintBounded(until - from, this)
|
|
||||||
sliceInternal(from, until, b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def takeWhile(p: A => Boolean): Repr = {
|
|
||||||
val b = newBuilder
|
|
||||||
breakable {
|
|
||||||
for (x <- this) {
|
|
||||||
if (!p(x)) break
|
|
||||||
b += x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
def dropWhile(p: A => Boolean): Repr = {
|
|
||||||
val b = newBuilder
|
|
||||||
var go = false
|
|
||||||
for (x <- this) {
|
|
||||||
if (!p(x)) go = true
|
|
||||||
if (go) b += x
|
|
||||||
}
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
def span(p: A => Boolean): (Repr, Repr) = {
|
|
||||||
val l, r = newBuilder
|
|
||||||
var toLeft = true
|
|
||||||
for (x <- this) {
|
|
||||||
toLeft = toLeft && p(x)
|
|
||||||
(if (toLeft) l else r) += x
|
|
||||||
}
|
|
||||||
(l.result, r.result)
|
|
||||||
}
|
|
||||||
|
|
||||||
def splitAt(n: Int): (Repr, Repr) = {
|
|
||||||
val l, r = newBuilder
|
|
||||||
l.sizeHintBounded(n, this)
|
|
||||||
if (n >= 0) r.sizeHint(this, -n)
|
|
||||||
var i = 0
|
|
||||||
for (x <- this) {
|
|
||||||
(if (i < n) l else r) += x
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
(l.result, r.result)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Iterates over the tails of this $coll. The first value will be this
|
|
||||||
* $coll and the final one will be an empty $coll, with the intervening
|
|
||||||
* values the results of successive applications of `tail`.
|
|
||||||
*
|
|
||||||
* @return an iterator over all the tails of this $coll
|
|
||||||
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
|
|
||||||
*/
|
|
||||||
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
|
|
||||||
|
|
||||||
/** Iterates over the inits of this $coll. The first value will be this
|
|
||||||
* $coll and the final one will be an empty $coll, with the intervening
|
|
||||||
* values the results of successive applications of `init`.
|
|
||||||
*
|
|
||||||
* @return an iterator over all the inits of this $coll
|
|
||||||
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
|
|
||||||
*/
|
|
||||||
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
|
|
||||||
|
|
||||||
/** Copies elements of this $coll to an array.
|
|
||||||
* Fills the given array `xs` with at most `len` elements of
|
|
||||||
* this $coll, starting at position `start`.
|
|
||||||
* Copying will stop once either the end of the current $coll is reached,
|
|
||||||
* or the end of the array is reached, or `len` elements have been copied.
|
|
||||||
*
|
|
||||||
* $willNotTerminateInf
|
|
||||||
*
|
|
||||||
* @param xs the array to fill.
|
|
||||||
* @param start the starting index.
|
|
||||||
* @param len the maximal number of elements to copy.
|
|
||||||
* @tparam B the type of the elements of the array.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
|
|
||||||
*/
|
|
||||||
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
|
|
||||||
var i = start
|
|
||||||
val end = (start + len) min xs.length
|
|
||||||
breakable {
|
|
||||||
for (x <- this) {
|
|
||||||
if (i >= end) break
|
|
||||||
xs(i) = x
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def toTraversable: Traversable[A] = thisCollection
|
|
||||||
def toIterator: Iterator[A] = toStream.iterator
|
|
||||||
def toStream: Stream[A] = toBuffer.toStream
|
|
||||||
|
|
||||||
/** Converts this $coll to a string.
|
|
||||||
*
|
|
||||||
* @return a string representation of this collection. By default this
|
|
||||||
* string consists of the `stringPrefix` of this $coll,
|
|
||||||
* followed by all elements separated by commas and enclosed in parentheses.
|
|
||||||
*/
|
|
||||||
override def toString = mkString(stringPrefix + "(", ", ", ")")
|
|
||||||
|
|
||||||
/** Defines the prefix of this object's `toString` representation.
|
|
||||||
*
|
|
||||||
* @return a string representation which starts the result of `toString`
|
|
||||||
* applied to this $coll. By default the string prefix is the
|
|
||||||
* simple name of the collection class $coll.
|
|
||||||
*/
|
|
||||||
def stringPrefix : String = {
|
|
||||||
var string = repr.asInstanceOf[AnyRef].getClass.getName
|
|
||||||
val idx1 = string.lastIndexOf('.' : Int)
|
|
||||||
if (idx1 != -1) string = string.substring(idx1 + 1)
|
|
||||||
val idx2 = string.indexOf('$')
|
|
||||||
if (idx2 != -1) string = string.substring(0, idx2)
|
|
||||||
string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a non-strict view of this $coll.
|
|
||||||
*
|
|
||||||
* @return a non-strict view of this $coll.
|
|
||||||
*/
|
|
||||||
def view = new TraversableView[A, Repr] {
|
|
||||||
protected lazy val underlying = self.repr
|
|
||||||
override def foreach[U](f: A => U) = self foreach f
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a non-strict view of a slice of this $coll.
|
|
||||||
*
|
|
||||||
* Note: the difference between `view` and `slice` is that `view` produces
|
|
||||||
* a view of the current $coll, whereas `slice` produces a new $coll.
|
|
||||||
*
|
|
||||||
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
|
|
||||||
* $orderDependent
|
|
||||||
*
|
|
||||||
* @param from the index of the first element of the view
|
|
||||||
* @param until the index of the element following the view
|
|
||||||
* @return a non-strict view of a slice of this $coll, starting at index `from`
|
|
||||||
* and extending up to (but not including) index `until`.
|
|
||||||
*/
|
|
||||||
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
|
|
||||||
|
|
||||||
/** Creates a non-strict filter of this $coll.
|
|
||||||
*
|
|
||||||
* Note: the difference between `c filter p` and `c withFilter p` is that
|
|
||||||
* the former creates a new collection, whereas the latter only
|
|
||||||
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
|
|
||||||
* and `withFilter` operations.
|
|
||||||
* $orderDependent
|
|
||||||
*
|
|
||||||
* @param p the predicate used to test elements.
|
|
||||||
* @return an object of class `WithFilter`, which supports
|
|
||||||
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
|
||||||
* All these operations apply to those elements of this $coll which
|
|
||||||
* satisfy the predicate `p`.
|
|
||||||
*/
|
|
||||||
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
|
|
||||||
|
|
||||||
/** A class supporting filtered operations. Instances of this class are
|
|
||||||
* returned by method `withFilter`.
|
|
||||||
*/
|
|
||||||
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
|
|
||||||
|
|
||||||
/** Builds a new collection by applying a function to all elements of the
|
|
||||||
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
|
|
||||||
*
|
|
||||||
* @param f the function to apply to each element.
|
|
||||||
* @tparam B the element type of the returned collection.
|
|
||||||
* @tparam That $thatinfo
|
|
||||||
* @param bf $bfinfo
|
|
||||||
* @return a new collection of type `That` resulting from applying
|
|
||||||
* the given function `f` to each element of the outer $coll
|
|
||||||
* that satisfies predicate `p` and collecting the results.
|
|
||||||
*
|
|
||||||
* @usecase def map[B](f: A => B): $Coll[B]
|
|
||||||
*
|
|
||||||
* @return a new $coll resulting from applying the given function
|
|
||||||
* `f` to each element of the outer $coll that satisfies
|
|
||||||
* predicate `p` and collecting the results.
|
|
||||||
*/
|
|
||||||
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
for (x <- self)
|
|
||||||
if (p(x)) b += f(x)
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Builds a new collection by applying a function to all elements of the
|
|
||||||
* outer $coll containing this `WithFilter` instance that satisfy
|
|
||||||
* predicate `p` and concatenating the results.
|
|
||||||
*
|
|
||||||
* @param f the function to apply to each element.
|
|
||||||
* @tparam B the element type of the returned collection.
|
|
||||||
* @tparam That $thatinfo
|
|
||||||
* @param bf $bfinfo
|
|
||||||
* @return a new collection of type `That` resulting from applying
|
|
||||||
* the given collection-valued function `f` to each element
|
|
||||||
* of the outer $coll that satisfies predicate `p` and
|
|
||||||
* concatenating the results.
|
|
||||||
*
|
|
||||||
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
|
|
||||||
*
|
|
||||||
* @return a new $coll resulting from applying the given collection-valued function
|
|
||||||
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
|
|
||||||
*/
|
|
||||||
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
|
||||||
val b = bf(repr)
|
|
||||||
for (x <- self)
|
|
||||||
if (p(x)) b ++= f(x).seq
|
|
||||||
b.result
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Applies a function `f` to all elements of the outer $coll containing
|
|
||||||
* this `WithFilter` instance that satisfy predicate `p`.
|
|
||||||
*
|
|
||||||
* @param f the function that is applied for its side-effect to every element.
|
|
||||||
* The result of function `f` is discarded.
|
|
||||||
*
|
|
||||||
* @tparam U the type parameter describing the result of function `f`.
|
|
||||||
* This result will always be ignored. Typically `U` is `Unit`,
|
|
||||||
* but this is not necessary.
|
|
||||||
*
|
|
||||||
* @usecase def foreach(f: A => Unit): Unit
|
|
||||||
*/
|
|
||||||
def foreach[U](f: A => U): Unit =
|
|
||||||
for (x <- self)
|
|
||||||
if (p(x)) f(x)
|
|
||||||
|
|
||||||
/** Further refines the filter for this $coll.
|
|
||||||
*
|
|
||||||
* @param q the predicate used to test elements.
|
|
||||||
* @return an object of class `WithFilter`, which supports
|
|
||||||
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
|
||||||
* All these operations apply to those elements of this $coll which
|
|
||||||
* satisfy the predicate `q` in addition to the predicate `p`.
|
|
||||||
*/
|
|
||||||
def withFilter(q: A => Boolean): WithFilter =
|
|
||||||
new WithFilter(x => p(x) && q(x))
|
|
||||||
}
|
|
||||||
|
|
||||||
// A helper for tails and inits.
|
|
||||||
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
|
|
||||||
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
|
|
||||||
it ++ Iterator(Nil) map (newBuilder ++= _ result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</textarea>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
theme: "ambiance",
|
|
||||||
mode: "text/x-scala"
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</article>
|
|
@ -1,139 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
|
|
||||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
|
||||||
|
|
||||||
MT("indent",
|
|
||||||
"[type void] [def foo]([type void*] [variable a], [type int] [variable b]) {",
|
|
||||||
" [type int] [variable c] [operator =] [variable b] [operator +]",
|
|
||||||
" [number 1];",
|
|
||||||
" [keyword return] [operator *][variable a];",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("indent_switch",
|
|
||||||
"[keyword switch] ([variable x]) {",
|
|
||||||
" [keyword case] [number 10]:",
|
|
||||||
" [keyword return] [number 20];",
|
|
||||||
" [keyword default]:",
|
|
||||||
" [variable printf]([string \"foo %c\"], [variable x]);",
|
|
||||||
"}");
|
|
||||||
|
|
||||||
MT("def",
|
|
||||||
"[type void] [def foo]() {}",
|
|
||||||
"[keyword struct] [def bar]{}",
|
|
||||||
"[keyword enum] [def zot]{}",
|
|
||||||
"[keyword union] [def ugh]{}",
|
|
||||||
"[type int] [type *][def baz]() {}");
|
|
||||||
|
|
||||||
MT("def_new_line",
|
|
||||||
"::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
|
|
||||||
"[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
|
|
||||||
|
|
||||||
MT("double_block",
|
|
||||||
"[keyword for] (;;)",
|
|
||||||
" [keyword for] (;;)",
|
|
||||||
" [variable x][operator ++];",
|
|
||||||
"[keyword return];");
|
|
||||||
|
|
||||||
MT("preprocessor",
|
|
||||||
"[meta #define FOO 3]",
|
|
||||||
"[type int] [variable foo];",
|
|
||||||
"[meta #define BAR\\]",
|
|
||||||
"[meta 4]",
|
|
||||||
"[type unsigned] [type int] [variable bar] [operator =] [number 8];",
|
|
||||||
"[meta #include <baz> ][comment // comment]")
|
|
||||||
|
|
||||||
MT("c_underscores",
|
|
||||||
"[builtin __FOO];",
|
|
||||||
"[builtin _Complex];",
|
|
||||||
"[builtin __aName];",
|
|
||||||
"[variable _aName];");
|
|
||||||
|
|
||||||
MT("c_types",
|
|
||||||
"[type int];",
|
|
||||||
"[type long];",
|
|
||||||
"[type char];",
|
|
||||||
"[type short];",
|
|
||||||
"[type double];",
|
|
||||||
"[type float];",
|
|
||||||
"[type unsigned];",
|
|
||||||
"[type signed];",
|
|
||||||
"[type void];",
|
|
||||||
"[type bool];",
|
|
||||||
"[type foo_t];",
|
|
||||||
"[variable foo_T];",
|
|
||||||
"[variable _t];");
|
|
||||||
|
|
||||||
var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
|
|
||||||
function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
|
|
||||||
|
|
||||||
MTCPP("cpp14_literal",
|
|
||||||
"[number 10'000];",
|
|
||||||
"[number 0b10'000];",
|
|
||||||
"[number 0x10'000];",
|
|
||||||
"[string '100000'];");
|
|
||||||
|
|
||||||
MTCPP("ctor_dtor",
|
|
||||||
"[def Foo::Foo]() {}",
|
|
||||||
"[def Foo::~Foo]() {}");
|
|
||||||
|
|
||||||
MTCPP("cpp_underscores",
|
|
||||||
"[builtin __FOO];",
|
|
||||||
"[builtin _Complex];",
|
|
||||||
"[builtin __aName];",
|
|
||||||
"[variable _aName];");
|
|
||||||
|
|
||||||
var mode_objc = CodeMirror.getMode({indentUnit: 2}, "text/x-objectivec");
|
|
||||||
function MTOBJC(name) { test.mode(name, mode_objc, Array.prototype.slice.call(arguments, 1)); }
|
|
||||||
|
|
||||||
MTOBJC("objc_underscores",
|
|
||||||
"[builtin __FOO];",
|
|
||||||
"[builtin _Complex];",
|
|
||||||
"[builtin __aName];",
|
|
||||||
"[variable _aName];");
|
|
||||||
|
|
||||||
MTOBJC("objc_interface",
|
|
||||||
"[keyword @interface] [def foo] {",
|
|
||||||
" [type int] [variable bar];",
|
|
||||||
"}",
|
|
||||||
"[keyword @property] ([keyword atomic], [keyword nullable]) [variable NSString][operator *] [variable a];",
|
|
||||||
"[keyword @property] ([keyword nonatomic], [keyword assign]) [type int] [variable b];",
|
|
||||||
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] " +
|
|
||||||
"[builtin NS_DESIGNATED_INITIALIZER];",
|
|
||||||
"[keyword @end]");
|
|
||||||
|
|
||||||
MTOBJC("objc_implementation",
|
|
||||||
"[keyword @implementation] [def foo] {",
|
|
||||||
" [type int] [variable bar];",
|
|
||||||
"}",
|
|
||||||
"[keyword @property] ([keyword readwrite]) [type SEL] [variable a];",
|
|
||||||
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] {",
|
|
||||||
" [keyword if](([keyword self] [operator =] [[[keyword super] [variable init] ]])) {}",
|
|
||||||
" [keyword return] [keyword self];",
|
|
||||||
"}",
|
|
||||||
"[keyword @end]");
|
|
||||||
|
|
||||||
MTOBJC("objc_types",
|
|
||||||
"[type int];",
|
|
||||||
"[type foo_t];",
|
|
||||||
"[variable foo_T];",
|
|
||||||
"[type id];",
|
|
||||||
"[type SEL];",
|
|
||||||
"[type instancetype];",
|
|
||||||
"[type Class];",
|
|
||||||
"[type Protocol];",
|
|
||||||
"[type BOOL];"
|
|
||||||
);
|
|
||||||
|
|
||||||
var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala");
|
|
||||||
function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); }
|
|
||||||
MTSCALA("nested_comments",
|
|
||||||
"[comment /*]",
|
|
||||||
"[comment But wait /* this is a nested comment */ for real]",
|
|
||||||
"[comment /**** let * me * show * you ****/]",
|
|
||||||
"[comment ///// let / me / show / you /////]",
|
|
||||||
"[comment */]");
|
|
||||||
|
|
||||||
})();
|
|
717
core/vendor/tinymce/plugins/codemirror/codemirror/mode/css/css.js
vendored
Normal file
717
core/vendor/tinymce/plugins/codemirror/codemirror/mode/css/css.js
vendored
Normal file
@ -0,0 +1,717 @@
|
|||||||
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
|
(function(mod) {
|
||||||
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
|
mod(require("../../lib/codemirror"));
|
||||||
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
|
define(["../../lib/codemirror"], mod);
|
||||||
|
else // Plain browser env
|
||||||
|
mod(CodeMirror);
|
||||||
|
})(function(CodeMirror) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||||
|
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
|
||||||
|
|
||||||
|
var indentUnit = config.indentUnit,
|
||||||
|
tokenHooks = parserConfig.tokenHooks,
|
||||||
|
mediaTypes = parserConfig.mediaTypes || {},
|
||||||
|
mediaFeatures = parserConfig.mediaFeatures || {},
|
||||||
|
propertyKeywords = parserConfig.propertyKeywords || {},
|
||||||
|
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
||||||
|
colorKeywords = parserConfig.colorKeywords || {},
|
||||||
|
valueKeywords = parserConfig.valueKeywords || {},
|
||||||
|
fontProperties = parserConfig.fontProperties || {},
|
||||||
|
allowNested = parserConfig.allowNested;
|
||||||
|
|
||||||
|
var type, override;
|
||||||
|
function ret(style, tp) { type = tp; return style; }
|
||||||
|
|
||||||
|
// Tokenizers
|
||||||
|
|
||||||
|
function tokenBase(stream, state) {
|
||||||
|
var ch = stream.next();
|
||||||
|
if (tokenHooks[ch]) {
|
||||||
|
var result = tokenHooks[ch](stream, state);
|
||||||
|
if (result !== false) return result;
|
||||||
|
}
|
||||||
|
if (ch == "@") {
|
||||||
|
stream.eatWhile(/[\w\\\-]/);
|
||||||
|
return ret("def", stream.current());
|
||||||
|
} else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
|
||||||
|
return ret(null, "compare");
|
||||||
|
} else if (ch == "\"" || ch == "'") {
|
||||||
|
state.tokenize = tokenString(ch);
|
||||||
|
return state.tokenize(stream, state);
|
||||||
|
} else if (ch == "#") {
|
||||||
|
stream.eatWhile(/[\w\\\-]/);
|
||||||
|
return ret("atom", "hash");
|
||||||
|
} else if (ch == "!") {
|
||||||
|
stream.match(/^\s*\w*/);
|
||||||
|
return ret("keyword", "important");
|
||||||
|
} else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
|
||||||
|
stream.eatWhile(/[\w.%]/);
|
||||||
|
return ret("number", "unit");
|
||||||
|
} else if (ch === "-") {
|
||||||
|
if (/[\d.]/.test(stream.peek())) {
|
||||||
|
stream.eatWhile(/[\w.%]/);
|
||||||
|
return ret("number", "unit");
|
||||||
|
} else if (stream.match(/^\w+-/)) {
|
||||||
|
return ret("meta", "meta");
|
||||||
|
}
|
||||||
|
} else if (/[,+>*\/]/.test(ch)) {
|
||||||
|
return ret(null, "select-op");
|
||||||
|
} else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
|
||||||
|
return ret("qualifier", "qualifier");
|
||||||
|
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
|
||||||
|
return ret(null, ch);
|
||||||
|
} else if (ch == "u" && stream.match("rl(")) {
|
||||||
|
stream.backUp(1);
|
||||||
|
state.tokenize = tokenParenthesized;
|
||||||
|
return ret("property", "word");
|
||||||
|
} else if (/[\w\\\-]/.test(ch)) {
|
||||||
|
stream.eatWhile(/[\w\\\-]/);
|
||||||
|
return ret("property", "word");
|
||||||
|
} else {
|
||||||
|
return ret(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tokenString(quote) {
|
||||||
|
return function(stream, state) {
|
||||||
|
var escaped = false, ch;
|
||||||
|
while ((ch = stream.next()) != null) {
|
||||||
|
if (ch == quote && !escaped) {
|
||||||
|
if (quote == ")") stream.backUp(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
escaped = !escaped && ch == "\\";
|
||||||
|
}
|
||||||
|
if (ch == quote || !escaped && quote != ")") state.tokenize = null;
|
||||||
|
return ret("string", "string");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function tokenParenthesized(stream, state) {
|
||||||
|
stream.next(); // Must be '('
|
||||||
|
if (!stream.match(/\s*[\"\')]/, false))
|
||||||
|
state.tokenize = tokenString(")");
|
||||||
|
else
|
||||||
|
state.tokenize = null;
|
||||||
|
return ret(null, "(");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Context management
|
||||||
|
|
||||||
|
function Context(type, indent, prev) {
|
||||||
|
this.type = type;
|
||||||
|
this.indent = indent;
|
||||||
|
this.prev = prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushContext(state, stream, type) {
|
||||||
|
state.context = new Context(type, stream.indentation() + indentUnit, state.context);
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
function popContext(state) {
|
||||||
|
state.context = state.context.prev;
|
||||||
|
return state.context.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pass(type, stream, state) {
|
||||||
|
return states[state.context.type](type, stream, state);
|
||||||
|
}
|
||||||
|
function popAndPass(type, stream, state, n) {
|
||||||
|
for (var i = n || 1; i > 0; i--)
|
||||||
|
state.context = state.context.prev;
|
||||||
|
return pass(type, stream, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parser
|
||||||
|
|
||||||
|
function wordAsValue(stream) {
|
||||||
|
var word = stream.current().toLowerCase();
|
||||||
|
if (valueKeywords.hasOwnProperty(word))
|
||||||
|
override = "atom";
|
||||||
|
else if (colorKeywords.hasOwnProperty(word))
|
||||||
|
override = "keyword";
|
||||||
|
else
|
||||||
|
override = "variable";
|
||||||
|
}
|
||||||
|
|
||||||
|
var states = {};
|
||||||
|
|
||||||
|
states.top = function(type, stream, state) {
|
||||||
|
if (type == "{") {
|
||||||
|
return pushContext(state, stream, "block");
|
||||||
|
} else if (type == "}" && state.context.prev) {
|
||||||
|
return popContext(state);
|
||||||
|
} else if (type == "@media") {
|
||||||
|
return pushContext(state, stream, "media");
|
||||||
|
} else if (type == "@font-face") {
|
||||||
|
return "font_face_before";
|
||||||
|
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
||||||
|
return "keyframes";
|
||||||
|
} else if (type && type.charAt(0) == "@") {
|
||||||
|
return pushContext(state, stream, "at");
|
||||||
|
} else if (type == "hash") {
|
||||||
|
override = "builtin";
|
||||||
|
} else if (type == "word") {
|
||||||
|
override = "tag";
|
||||||
|
} else if (type == "variable-definition") {
|
||||||
|
return "maybeprop";
|
||||||
|
} else if (type == "interpolation") {
|
||||||
|
return pushContext(state, stream, "interpolation");
|
||||||
|
} else if (type == ":") {
|
||||||
|
return "pseudo";
|
||||||
|
} else if (allowNested && type == "(") {
|
||||||
|
return pushContext(state, stream, "parens");
|
||||||
|
}
|
||||||
|
return state.context.type;
|
||||||
|
};
|
||||||
|
|
||||||
|
states.block = function(type, stream, state) {
|
||||||
|
if (type == "word") {
|
||||||
|
var word = stream.current().toLowerCase();
|
||||||
|
if (propertyKeywords.hasOwnProperty(word)) {
|
||||||
|
override = "property";
|
||||||
|
return "maybeprop";
|
||||||
|
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
|
||||||
|
override = "string-2";
|
||||||
|
return "maybeprop";
|
||||||
|
} else if (allowNested) {
|
||||||
|
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
|
||||||
|
return "block";
|
||||||
|
} else {
|
||||||
|
override += " error";
|
||||||
|
return "maybeprop";
|
||||||
|
}
|
||||||
|
} else if (type == "meta") {
|
||||||
|
return "block";
|
||||||
|
} else if (!allowNested && (type == "hash" || type == "qualifier")) {
|
||||||
|
override = "error";
|
||||||
|
return "block";
|
||||||
|
} else {
|
||||||
|
return states.top(type, stream, state);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
states.maybeprop = function(type, stream, state) {
|
||||||
|
if (type == ":") return pushContext(state, stream, "prop");
|
||||||
|
return pass(type, stream, state);
|
||||||
|
};
|
||||||
|
|
||||||
|
states.prop = function(type, stream, state) {
|
||||||
|
if (type == ";") return popContext(state);
|
||||||
|
if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
|
||||||
|
if (type == "}" || type == "{") return popAndPass(type, stream, state);
|
||||||
|
if (type == "(") return pushContext(state, stream, "parens");
|
||||||
|
|
||||||
|
if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
|
||||||
|
override += " error";
|
||||||
|
} else if (type == "word") {
|
||||||
|
wordAsValue(stream);
|
||||||
|
} else if (type == "interpolation") {
|
||||||
|
return pushContext(state, stream, "interpolation");
|
||||||
|
}
|
||||||
|
return "prop";
|
||||||
|
};
|
||||||
|
|
||||||
|
states.propBlock = function(type, _stream, state) {
|
||||||
|
if (type == "}") return popContext(state);
|
||||||
|
if (type == "word") { override = "property"; return "maybeprop"; }
|
||||||
|
return state.context.type;
|
||||||
|
};
|
||||||
|
|
||||||
|
states.parens = function(type, stream, state) {
|
||||||
|
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
||||||
|
if (type == ")") return popContext(state);
|
||||||
|
if (type == "(") return pushContext(state, stream, "parens");
|
||||||
|
if (type == "word") wordAsValue(stream);
|
||||||
|
return "parens";
|
||||||
|
};
|
||||||
|
|
||||||
|
states.pseudo = function(type, stream, state) {
|
||||||
|
if (type == "word") {
|
||||||
|
override = "variable-3";
|
||||||
|
return state.context.type;
|
||||||
|
}
|
||||||
|
return pass(type, stream, state);
|
||||||
|
};
|
||||||
|
|
||||||
|
states.media = function(type, stream, state) {
|
||||||
|
if (type == "(") return pushContext(state, stream, "media_parens");
|
||||||
|
if (type == "}") return popAndPass(type, stream, state);
|
||||||
|
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
||||||
|
|
||||||
|
if (type == "word") {
|
||||||
|
var word = stream.current().toLowerCase();
|
||||||
|
if (word == "only" || word == "not" || word == "and")
|
||||||
|
override = "keyword";
|
||||||
|
else if (mediaTypes.hasOwnProperty(word))
|
||||||
|
override = "attribute";
|
||||||
|
else if (mediaFeatures.hasOwnProperty(word))
|
||||||
|
override = "property";
|
||||||
|
else
|
||||||
|
override = "error";
|
||||||
|
}
|
||||||
|
return state.context.type;
|
||||||
|
};
|
||||||
|
|
||||||
|
states.media_parens = function(type, stream, state) {
|
||||||
|
if (type == ")") return popContext(state);
|
||||||
|
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
||||||
|
return states.media(type, stream, state);
|
||||||
|
};
|
||||||
|
|
||||||
|
states.font_face_before = function(type, stream, state) {
|
||||||
|
if (type == "{")
|
||||||
|
return pushContext(state, stream, "font_face");
|
||||||
|
return pass(type, stream, state);
|
||||||
|
};
|
||||||
|
|
||||||
|
states.font_face = function(type, stream, state) {
|
||||||
|
if (type == "}") return popContext(state);
|
||||||
|
if (type == "word") {
|
||||||
|
if (!fontProperties.hasOwnProperty(stream.current().toLowerCase()))
|
||||||
|
override = "error";
|
||||||
|
else
|
||||||
|
override = "property";
|
||||||
|
return "maybeprop";
|
||||||
|
}
|
||||||
|
return "font_face";
|
||||||
|
};
|
||||||
|
|
||||||
|
states.keyframes = function(type, stream, state) {
|
||||||
|
if (type == "word") { override = "variable"; return "keyframes"; }
|
||||||
|
if (type == "{") return pushContext(state, stream, "top");
|
||||||
|
return pass(type, stream, state);
|
||||||
|
};
|
||||||
|
|
||||||
|
states.at = function(type, stream, state) {
|
||||||
|
if (type == ";") return popContext(state);
|
||||||
|
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
||||||
|
if (type == "word") override = "tag";
|
||||||
|
else if (type == "hash") override = "builtin";
|
||||||
|
return "at";
|
||||||
|
};
|
||||||
|
|
||||||
|
states.interpolation = function(type, stream, state) {
|
||||||
|
if (type == "}") return popContext(state);
|
||||||
|
if (type == "{" || type == ";") return popAndPass(type, stream, state);
|
||||||
|
if (type != "variable") override = "error";
|
||||||
|
return "interpolation";
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
startState: function(base) {
|
||||||
|
return {tokenize: null,
|
||||||
|
state: "top",
|
||||||
|
context: new Context("top", base || 0, null)};
|
||||||
|
},
|
||||||
|
|
||||||
|
token: function(stream, state) {
|
||||||
|
if (!state.tokenize && stream.eatSpace()) return null;
|
||||||
|
var style = (state.tokenize || tokenBase)(stream, state);
|
||||||
|
if (style && typeof style == "object") {
|
||||||
|
type = style[1];
|
||||||
|
style = style[0];
|
||||||
|
}
|
||||||
|
override = style;
|
||||||
|
state.state = states[state.state](type, stream, state);
|
||||||
|
return override;
|
||||||
|
},
|
||||||
|
|
||||||
|
indent: function(state, textAfter) {
|
||||||
|
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
||||||
|
var indent = cx.indent;
|
||||||
|
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
||||||
|
if (cx.prev &&
|
||||||
|
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") ||
|
||||||
|
ch == ")" && (cx.type == "parens" || cx.type == "media_parens") ||
|
||||||
|
ch == "{" && (cx.type == "at" || cx.type == "media"))) {
|
||||||
|
indent = cx.indent - indentUnit;
|
||||||
|
cx = cx.prev;
|
||||||
|
}
|
||||||
|
return indent;
|
||||||
|
},
|
||||||
|
|
||||||
|
electricChars: "}",
|
||||||
|
blockCommentStart: "/*",
|
||||||
|
blockCommentEnd: "*/",
|
||||||
|
fold: "brace"
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function keySet(array) {
|
||||||
|
var keys = {};
|
||||||
|
for (var i = 0; i < array.length; ++i) {
|
||||||
|
keys[array[i]] = true;
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
var mediaTypes_ = [
|
||||||
|
"all", "aural", "braille", "handheld", "print", "projection", "screen",
|
||||||
|
"tty", "tv", "embossed"
|
||||||
|
], mediaTypes = keySet(mediaTypes_);
|
||||||
|
|
||||||
|
var mediaFeatures_ = [
|
||||||
|
"width", "min-width", "max-width", "height", "min-height", "max-height",
|
||||||
|
"device-width", "min-device-width", "max-device-width", "device-height",
|
||||||
|
"min-device-height", "max-device-height", "aspect-ratio",
|
||||||
|
"min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
|
||||||
|
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
|
||||||
|
"max-color", "color-index", "min-color-index", "max-color-index",
|
||||||
|
"monochrome", "min-monochrome", "max-monochrome", "resolution",
|
||||||
|
"min-resolution", "max-resolution", "scan", "grid"
|
||||||
|
], mediaFeatures = keySet(mediaFeatures_);
|
||||||
|
|
||||||
|
var propertyKeywords_ = [
|
||||||
|
"align-content", "align-items", "align-self", "alignment-adjust",
|
||||||
|
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
||||||
|
"animation-direction", "animation-duration", "animation-fill-mode",
|
||||||
|
"animation-iteration-count", "animation-name", "animation-play-state",
|
||||||
|
"animation-timing-function", "appearance", "azimuth", "backface-visibility",
|
||||||
|
"background", "background-attachment", "background-clip", "background-color",
|
||||||
|
"background-image", "background-origin", "background-position",
|
||||||
|
"background-repeat", "background-size", "baseline-shift", "binding",
|
||||||
|
"bleed", "bookmark-label", "bookmark-level", "bookmark-state",
|
||||||
|
"bookmark-target", "border", "border-bottom", "border-bottom-color",
|
||||||
|
"border-bottom-left-radius", "border-bottom-right-radius",
|
||||||
|
"border-bottom-style", "border-bottom-width", "border-collapse",
|
||||||
|
"border-color", "border-image", "border-image-outset",
|
||||||
|
"border-image-repeat", "border-image-slice", "border-image-source",
|
||||||
|
"border-image-width", "border-left", "border-left-color",
|
||||||
|
"border-left-style", "border-left-width", "border-radius", "border-right",
|
||||||
|
"border-right-color", "border-right-style", "border-right-width",
|
||||||
|
"border-spacing", "border-style", "border-top", "border-top-color",
|
||||||
|
"border-top-left-radius", "border-top-right-radius", "border-top-style",
|
||||||
|
"border-top-width", "border-width", "bottom", "box-decoration-break",
|
||||||
|
"box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
|
||||||
|
"caption-side", "clear", "clip", "color", "color-profile", "column-count",
|
||||||
|
"column-fill", "column-gap", "column-rule", "column-rule-color",
|
||||||
|
"column-rule-style", "column-rule-width", "column-span", "column-width",
|
||||||
|
"columns", "content", "counter-increment", "counter-reset", "crop", "cue",
|
||||||
|
"cue-after", "cue-before", "cursor", "direction", "display",
|
||||||
|
"dominant-baseline", "drop-initial-after-adjust",
|
||||||
|
"drop-initial-after-align", "drop-initial-before-adjust",
|
||||||
|
"drop-initial-before-align", "drop-initial-size", "drop-initial-value",
|
||||||
|
"elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
|
||||||
|
"flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
|
||||||
|
"float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
|
||||||
|
"font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
|
||||||
|
"font-stretch", "font-style", "font-synthesis", "font-variant",
|
||||||
|
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
|
||||||
|
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
|
||||||
|
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
|
||||||
|
"grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
|
||||||
|
"grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
|
||||||
|
"grid-template", "grid-template-areas", "grid-template-columns",
|
||||||
|
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
|
||||||
|
"icon", "image-orientation", "image-rendering", "image-resolution",
|
||||||
|
"inline-box-align", "justify-content", "left", "letter-spacing",
|
||||||
|
"line-break", "line-height", "line-stacking", "line-stacking-ruby",
|
||||||
|
"line-stacking-shift", "line-stacking-strategy", "list-style",
|
||||||
|
"list-style-image", "list-style-position", "list-style-type", "margin",
|
||||||
|
"margin-bottom", "margin-left", "margin-right", "margin-top",
|
||||||
|
"marker-offset", "marks", "marquee-direction", "marquee-loop",
|
||||||
|
"marquee-play-count", "marquee-speed", "marquee-style", "max-height",
|
||||||
|
"max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
|
||||||
|
"nav-left", "nav-right", "nav-up", "object-fit", "object-position",
|
||||||
|
"opacity", "order", "orphans", "outline",
|
||||||
|
"outline-color", "outline-offset", "outline-style", "outline-width",
|
||||||
|
"overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
|
||||||
|
"padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
|
||||||
|
"page", "page-break-after", "page-break-before", "page-break-inside",
|
||||||
|
"page-policy", "pause", "pause-after", "pause-before", "perspective",
|
||||||
|
"perspective-origin", "pitch", "pitch-range", "play-during", "position",
|
||||||
|
"presentation-level", "punctuation-trim", "quotes", "region-break-after",
|
||||||
|
"region-break-before", "region-break-inside", "region-fragment",
|
||||||
|
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
|
||||||
|
"right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
|
||||||
|
"ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
|
||||||
|
"shape-outside", "size", "speak", "speak-as", "speak-header",
|
||||||
|
"speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
|
||||||
|
"tab-size", "table-layout", "target", "target-name", "target-new",
|
||||||
|
"target-position", "text-align", "text-align-last", "text-decoration",
|
||||||
|
"text-decoration-color", "text-decoration-line", "text-decoration-skip",
|
||||||
|
"text-decoration-style", "text-emphasis", "text-emphasis-color",
|
||||||
|
"text-emphasis-position", "text-emphasis-style", "text-height",
|
||||||
|
"text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
|
||||||
|
"text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
|
||||||
|
"text-wrap", "top", "transform", "transform-origin", "transform-style",
|
||||||
|
"transition", "transition-delay", "transition-duration",
|
||||||
|
"transition-property", "transition-timing-function", "unicode-bidi",
|
||||||
|
"vertical-align", "visibility", "voice-balance", "voice-duration",
|
||||||
|
"voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
|
||||||
|
"voice-volume", "volume", "white-space", "widows", "width", "word-break",
|
||||||
|
"word-spacing", "word-wrap", "z-index",
|
||||||
|
// SVG-specific
|
||||||
|
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
|
||||||
|
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
|
||||||
|
"color-interpolation", "color-interpolation-filters",
|
||||||
|
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
|
||||||
|
"marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
|
||||||
|
"stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
|
||||||
|
"stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
|
||||||
|
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
|
||||||
|
"glyph-orientation-vertical", "text-anchor", "writing-mode"
|
||||||
|
], propertyKeywords = keySet(propertyKeywords_);
|
||||||
|
|
||||||
|
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"
|
||||||
|
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
|
||||||
|
|
||||||
|
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"
|
||||||
|
], colorKeywords = keySet(colorKeywords_);
|
||||||
|
|
||||||
|
var valueKeywords_ = [
|
||||||
|
"above", "absolute", "activeborder", "activecaption", "afar",
|
||||||
|
"after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
|
||||||
|
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
|
||||||
|
"arabic-indic", "armenian", "asterisks", "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", "button", "button-bevel",
|
||||||
|
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
|
||||||
|
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
||||||
|
"cell", "center", "checkbox", "circle", "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", "cover", "crop",
|
||||||
|
"cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
|
||||||
|
"decimal-leading-zero", "default", "default-button", "destination-atop",
|
||||||
|
"destination-in", "destination-out", "destination-over", "devanagari",
|
||||||
|
"disc", "discard", "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", "ew-resize", "expanded", "extra-condensed",
|
||||||
|
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "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-table", "inset", "inside", "intrinsic", "invert",
|
||||||
|
"italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
|
||||||
|
"landscape", "lao", "large", "larger", "left", "level", "lighter",
|
||||||
|
"line-through", "linear", "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",
|
||||||
|
"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", "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", "plus-darker", "plus-lighter", "pointer",
|
||||||
|
"polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
|
||||||
|
"radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
|
||||||
|
"relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
|
||||||
|
"ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
|
||||||
|
"s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
|
||||||
|
"searchfield-cancel-button", "searchfield-decoration",
|
||||||
|
"searchfield-results-button", "searchfield-results-decoration",
|
||||||
|
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
|
||||||
|
"single", "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", "square",
|
||||||
|
"square-button", "start", "static", "status-bar", "stretch", "stroke",
|
||||||
|
"sub", "subpixel-antialiased", "super", "sw-resize", "table",
|
||||||
|
"table-caption", "table-cell", "table-column", "table-column-group",
|
||||||
|
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
||||||
|
"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",
|
||||||
|
"transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
|
||||||
|
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
|
||||||
|
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
||||||
|
"vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
||||||
|
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
||||||
|
"window", "windowframe", "windowtext", "x-large", "x-small", "xor",
|
||||||
|
"xx-large", "xx-small"
|
||||||
|
], valueKeywords = keySet(valueKeywords_);
|
||||||
|
|
||||||
|
var fontProperties_ = [
|
||||||
|
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
|
||||||
|
"font-stretch", "font-weight", "font-style"
|
||||||
|
], fontProperties = keySet(fontProperties_);
|
||||||
|
|
||||||
|
var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_)
|
||||||
|
.concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
|
||||||
|
CodeMirror.registerHelper("hintWords", "css", allWords);
|
||||||
|
|
||||||
|
function tokenCComment(stream, state) {
|
||||||
|
var maybeEnd = false, ch;
|
||||||
|
while ((ch = stream.next()) != null) {
|
||||||
|
if (maybeEnd && ch == "/") {
|
||||||
|
state.tokenize = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
maybeEnd = (ch == "*");
|
||||||
|
}
|
||||||
|
return ["comment", "comment"];
|
||||||
|
}
|
||||||
|
|
||||||
|
function tokenSGMLComment(stream, state) {
|
||||||
|
if (stream.skipTo("-->")) {
|
||||||
|
stream.match("-->");
|
||||||
|
state.tokenize = null;
|
||||||
|
} else {
|
||||||
|
stream.skipToEnd();
|
||||||
|
}
|
||||||
|
return ["comment", "comment"];
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeMirror.defineMIME("text/css", {
|
||||||
|
mediaTypes: mediaTypes,
|
||||||
|
mediaFeatures: mediaFeatures,
|
||||||
|
propertyKeywords: propertyKeywords,
|
||||||
|
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||||
|
colorKeywords: colorKeywords,
|
||||||
|
valueKeywords: valueKeywords,
|
||||||
|
fontProperties: fontProperties,
|
||||||
|
tokenHooks: {
|
||||||
|
"<": function(stream, state) {
|
||||||
|
if (!stream.match("!--")) return false;
|
||||||
|
state.tokenize = tokenSGMLComment;
|
||||||
|
return tokenSGMLComment(stream, state);
|
||||||
|
},
|
||||||
|
"/": function(stream, state) {
|
||||||
|
if (!stream.eat("*")) return false;
|
||||||
|
state.tokenize = tokenCComment;
|
||||||
|
return tokenCComment(stream, state);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
name: "css"
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.defineMIME("text/x-scss", {
|
||||||
|
mediaTypes: mediaTypes,
|
||||||
|
mediaFeatures: mediaFeatures,
|
||||||
|
propertyKeywords: propertyKeywords,
|
||||||
|
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||||
|
colorKeywords: colorKeywords,
|
||||||
|
valueKeywords: valueKeywords,
|
||||||
|
fontProperties: fontProperties,
|
||||||
|
allowNested: true,
|
||||||
|
tokenHooks: {
|
||||||
|
"/": function(stream, state) {
|
||||||
|
if (stream.eat("/")) {
|
||||||
|
stream.skipToEnd();
|
||||||
|
return ["comment", "comment"];
|
||||||
|
} else if (stream.eat("*")) {
|
||||||
|
state.tokenize = tokenCComment;
|
||||||
|
return tokenCComment(stream, state);
|
||||||
|
} else {
|
||||||
|
return ["operator", "operator"];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
":": function(stream) {
|
||||||
|
if (stream.match(/\s*\{/))
|
||||||
|
return [null, "{"];
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
"$": function(stream) {
|
||||||
|
stream.match(/^[\w-]+/);
|
||||||
|
if (stream.match(/^\s*:/, false))
|
||||||
|
return ["variable-2", "variable-definition"];
|
||||||
|
return ["variable-2", "variable"];
|
||||||
|
},
|
||||||
|
"#": function(stream) {
|
||||||
|
if (!stream.eat("{")) return false;
|
||||||
|
return [null, "interpolation"];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
name: "css",
|
||||||
|
helperType: "scss"
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.defineMIME("text/x-less", {
|
||||||
|
mediaTypes: mediaTypes,
|
||||||
|
mediaFeatures: mediaFeatures,
|
||||||
|
propertyKeywords: propertyKeywords,
|
||||||
|
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||||
|
colorKeywords: colorKeywords,
|
||||||
|
valueKeywords: valueKeywords,
|
||||||
|
fontProperties: fontProperties,
|
||||||
|
allowNested: true,
|
||||||
|
tokenHooks: {
|
||||||
|
"/": function(stream, state) {
|
||||||
|
if (stream.eat("/")) {
|
||||||
|
stream.skipToEnd();
|
||||||
|
return ["comment", "comment"];
|
||||||
|
} else if (stream.eat("*")) {
|
||||||
|
state.tokenize = tokenCComment;
|
||||||
|
return tokenCComment(stream, state);
|
||||||
|
} else {
|
||||||
|
return ["operator", "operator"];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@": function(stream) {
|
||||||
|
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
|
||||||
|
stream.eatWhile(/[\w\\\-]/);
|
||||||
|
if (stream.match(/^\s*:/, false))
|
||||||
|
return ["variable-2", "variable-definition"];
|
||||||
|
return ["variable-2", "variable"];
|
||||||
|
},
|
||||||
|
"&": function() {
|
||||||
|
return ["atom", "atom"];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
name: "css",
|
||||||
|
helperType: "less"
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -1,58 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: Html Embedded Scripts mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../xml/xml.js"></script>
|
|
||||||
<script src="../javascript/javascript.js"></script>
|
|
||||||
<script src="../css/css.js"></script>
|
|
||||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
|
||||||
<script src="htmlembedded.js"></script>
|
|
||||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">Html Embedded Scripts</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>Html Embedded Scripts mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
<%
|
|
||||||
function hello(who) {
|
|
||||||
return "Hello " + who;
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
This is an example of EJS (embedded javascript)
|
|
||||||
<p>The program says <%= hello("world") %>.</p>
|
|
||||||
<script>
|
|
||||||
alert("And here is some normal JS code"); // also colored
|
|
||||||
</script>
|
|
||||||
</textarea></form>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
mode: "application/x-ejs",
|
|
||||||
indentUnit: 4,
|
|
||||||
indentWithTabs: true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
|
|
||||||
JavaScript, CSS and XML.<br />Other dependancies include those of the scriping language chosen.</p>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>application/x-aspx</code> (ASP.NET),
|
|
||||||
<code>application/x-ejs</code> (Embedded Javascript), <code>application/x-jsp</code> (JavaServer Pages)</p>
|
|
||||||
</article>
|
|
@ -1,85 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: HTML mixed mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../xml/xml.js"></script>
|
|
||||||
<script src="../javascript/javascript.js"></script>
|
|
||||||
<script src="../css/css.js"></script>
|
|
||||||
<script src="../vbscript/vbscript.js"></script>
|
|
||||||
<script src="htmlmixed.js"></script>
|
|
||||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">HTML mixed</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>HTML mixed mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
<html style="color: green">
|
|
||||||
<!-- this is a comment -->
|
|
||||||
<head>
|
|
||||||
<title>Mixed HTML Example</title>
|
|
||||||
<style type="text/css">
|
|
||||||
h1 {font-family: comic sans; color: #f0f;}
|
|
||||||
div {background: yellow !important;}
|
|
||||||
body {
|
|
||||||
max-width: 50em;
|
|
||||||
margin: 1em 2em 1em 5em;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Mixed HTML Example</h1>
|
|
||||||
<script>
|
|
||||||
function jsFunc(arg1, arg2) {
|
|
||||||
if (arg1 && arg2) document.body.innerHTML = "achoo";
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
</textarea></form>
|
|
||||||
<script>
|
|
||||||
// Define an extended mixed-mode that understands vbscript and
|
|
||||||
// leaves mustache/handlebars embedded templates in html mode
|
|
||||||
var mixedMode = {
|
|
||||||
name: "htmlmixed",
|
|
||||||
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
|
|
||||||
mode: null},
|
|
||||||
{matches: /(text|application)\/(x-)?vb(a|script)/i,
|
|
||||||
mode: "vbscript"}]
|
|
||||||
};
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: mixedMode});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>The HTML mixed mode depends on the XML, JavaScript, and CSS modes.</p>
|
|
||||||
|
|
||||||
<p>It takes an optional mode configuration
|
|
||||||
option, <code>scriptTypes</code>, which can be used to add custom
|
|
||||||
behavior for specific <code><script type="..."></code> tags. If
|
|
||||||
given, it should hold an array of <code>{matches, mode}</code>
|
|
||||||
objects, where <code>matches</code> is a string or regexp that
|
|
||||||
matches the script type, and <code>mode</code> is
|
|
||||||
either <code>null</code>, for script types that should stay in
|
|
||||||
HTML mode, or a <a href="../../doc/manual.html#option_mode">mode
|
|
||||||
spec</a> corresponding to the mode that should be used for the
|
|
||||||
script.</p>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>text/html</code>
|
|
||||||
(redefined, only takes effect if you load this parser after the
|
|
||||||
XML parser).</p>
|
|
||||||
|
|
||||||
</article>
|
|
128
core/vendor/tinymce/plugins/codemirror/codemirror/mode/index.html
vendored
Normal file
128
core/vendor/tinymce/plugins/codemirror/codemirror/mode/index.html
vendored
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<title>CodeMirror: Language Modes</title>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<link rel=stylesheet href="../doc/docs.css">
|
||||||
|
|
||||||
|
<div id=nav>
|
||||||
|
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a href="../index.html">Home</a>
|
||||||
|
<li><a href="../doc/manual.html">Manual</a>
|
||||||
|
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li><a class=active href="#">Language modes</a>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<article>
|
||||||
|
|
||||||
|
<h2>Language modes</h2>
|
||||||
|
|
||||||
|
<p>This is a list of every mode in the distribution. Each mode lives
|
||||||
|
in a subdirectory of the <code>mode/</code> directory, and typically
|
||||||
|
defines a single JavaScript file that implements the mode. Loading
|
||||||
|
such file will make the language available to CodeMirror, through
|
||||||
|
the <a href="manual.html#option_mode"><code>mode</code></a>
|
||||||
|
option.</p>
|
||||||
|
|
||||||
|
<div style="-webkit-columns: 100px 2; -moz-columns: 100px 2; columns: 100px 2;">
|
||||||
|
<ul style="margin-top: 0">
|
||||||
|
<li><a href="apl/index.html">APL</a></li>
|
||||||
|
<li><a href="asterisk/index.html">Asterisk dialplan</a></li>
|
||||||
|
<li><a href="clike/index.html">C, C++, C#</a></li>
|
||||||
|
<li><a href="clojure/index.html">Clojure</a></li>
|
||||||
|
<li><a href="cobol/index.html">COBOL</a></li>
|
||||||
|
<li><a href="coffeescript/index.html">CoffeeScript</a></li>
|
||||||
|
<li><a href="commonlisp/index.html">Common Lisp</a></li>
|
||||||
|
<li><a href="css/index.html">CSS</a></li>
|
||||||
|
<li><a href="cypher/index.html">Cypher</a></li>
|
||||||
|
<li><a href="python/index.html">Cython</a></li>
|
||||||
|
<li><a href="d/index.html">D</a></li>
|
||||||
|
<li><a href="django/index.html">Django</a> (templating language)</li>
|
||||||
|
<li><a href="dockerfile/index.html">Dockerfile</a></li>
|
||||||
|
<li><a href="diff/index.html">diff</a></li>
|
||||||
|
<li><a href="dtd/index.html">DTD</a></li>
|
||||||
|
<li><a href="dylan/index.html">Dylan</a></li>
|
||||||
|
<li><a href="ecl/index.html">ECL</a></li>
|
||||||
|
<li><a href="eiffel/index.html">Eiffel</a></li>
|
||||||
|
<li><a href="erlang/index.html">Erlang</a></li>
|
||||||
|
<li><a href="fortran/index.html">Fortran</a></li>
|
||||||
|
<li><a href="mllike/index.html">F#</a></li>
|
||||||
|
<li><a href="gas/index.html">Gas</a> (AT&T-style assembly)</li>
|
||||||
|
<li><a href="gherkin/index.html">Gherkin</a></li>
|
||||||
|
<li><a href="go/index.html">Go</a></li>
|
||||||
|
<li><a href="groovy/index.html">Groovy</a></li>
|
||||||
|
<li><a href="haml/index.html">HAML</a></li>
|
||||||
|
<li><a href="haskell/index.html">Haskell</a></li>
|
||||||
|
<li><a href="haxe/index.html">Haxe</a></li>
|
||||||
|
<li><a href="htmlembedded/index.html">HTML embedded scripts</a></li>
|
||||||
|
<li><a href="htmlmixed/index.html">HTML mixed-mode</a></li>
|
||||||
|
<li><a href="http/index.html">HTTP</a></li>
|
||||||
|
<li><a href="idl/index.html">IDL</a></li>
|
||||||
|
<li><a href="clike/index.html">Java</a></li>
|
||||||
|
<li><a href="jade/index.html">Jade</a></li>
|
||||||
|
<li><a href="javascript/index.html">JavaScript</a></li>
|
||||||
|
<li><a href="jinja2/index.html">Jinja2</a></li>
|
||||||
|
<li><a href="julia/index.html">Julia</a></li>
|
||||||
|
<li><a href="kotlin/index.html">Kotlin</a></li>
|
||||||
|
<li><a href="css/less.html">LESS</a></li>
|
||||||
|
<li><a href="livescript/index.html">LiveScript</a></li>
|
||||||
|
<li><a href="lua/index.html">Lua</a></li>
|
||||||
|
<li><a href="markdown/index.html">Markdown</a> (<a href="gfm/index.html">GitHub-flavour</a>)</li>
|
||||||
|
<li><a href="mirc/index.html">mIRC</a></li>
|
||||||
|
<li><a href="modelica/index.html">Modelica</a></li>
|
||||||
|
<li><a href="nginx/index.html">Nginx</a></li>
|
||||||
|
<li><a href="ntriples/index.html">NTriples</a></li>
|
||||||
|
<li><a href="clike/index.html">Objective C</a></li>
|
||||||
|
<li><a href="mllike/index.html">OCaml</a></li>
|
||||||
|
<li><a href="octave/index.html">Octave</a> (MATLAB)</li>
|
||||||
|
<li><a href="pascal/index.html">Pascal</a></li>
|
||||||
|
<li><a href="pegjs/index.html">PEG.js</a></li>
|
||||||
|
<li><a href="perl/index.html">Perl</a></li>
|
||||||
|
<li><a href="php/index.html">PHP</a></li>
|
||||||
|
<li><a href="pig/index.html">Pig Latin</a></li>
|
||||||
|
<li><a href="properties/index.html">Properties files</a></li>
|
||||||
|
<li><a href="puppet/index.html">Puppet</a></li>
|
||||||
|
<li><a href="python/index.html">Python</a></li>
|
||||||
|
<li><a href="q/index.html">Q</a></li>
|
||||||
|
<li><a href="r/index.html">R</a></li>
|
||||||
|
<li><a href="rpm/index.html">RPM</a></li>
|
||||||
|
<li><a href="rst/index.html">reStructuredText</a></li>
|
||||||
|
<li><a href="ruby/index.html">Ruby</a></li>
|
||||||
|
<li><a href="rust/index.html">Rust</a></li>
|
||||||
|
<li><a href="sass/index.html">Sass</a></li>
|
||||||
|
<li><a href="clike/scala.html">Scala</a></li>
|
||||||
|
<li><a href="scheme/index.html">Scheme</a></li>
|
||||||
|
<li><a href="css/scss.html">SCSS</a></li>
|
||||||
|
<li><a href="shell/index.html">Shell</a></li>
|
||||||
|
<li><a href="sieve/index.html">Sieve</a></li>
|
||||||
|
<li><a href="slim/index.html">Slim</a></li>
|
||||||
|
<li><a href="smalltalk/index.html">Smalltalk</a></li>
|
||||||
|
<li><a href="smarty/index.html">Smarty</a></li>
|
||||||
|
<li><a href="smartymixed/index.html">Smarty/HTML mixed</a></li>
|
||||||
|
<li><a href="solr/index.html">Solr</a></li>
|
||||||
|
<li><a href="sql/index.html">SQL</a> (several dialects)</li>
|
||||||
|
<li><a href="sparql/index.html">SPARQL</a></li>
|
||||||
|
<li><a href="stex/index.html">sTeX, LaTeX</a></li>
|
||||||
|
<li><a href="tcl/index.html">Tcl</a></li>
|
||||||
|
<li><a href="textile/index.html">Textile</a></li>
|
||||||
|
<li><a href="tiddlywiki/index.html">Tiddlywiki</a></li>
|
||||||
|
<li><a href="tiki/index.html">Tiki wiki</a></li>
|
||||||
|
<li><a href="toml/index.html">TOML</a></li>
|
||||||
|
<li><a href="tornado/index.html">Tornado</a> (templating language)</li>
|
||||||
|
<li><a href="turtle/index.html">Turtle</a></li>
|
||||||
|
<li><a href="vb/index.html">VB.NET</a></li>
|
||||||
|
<li><a href="vbscript/index.html">VBScript</a></li>
|
||||||
|
<li><a href="velocity/index.html">Velocity</a></li>
|
||||||
|
<li><a href="verilog/index.html">Verilog/SystemVerilog</a></li>
|
||||||
|
<li><a href="xml/index.html">XML/HTML</a></li>
|
||||||
|
<li><a href="xquery/index.html">XQuery</a></li>
|
||||||
|
<li><a href="yaml/index.html">YAML</a></li>
|
||||||
|
<li><a href="z80/index.html">Z80</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</article>
|
684
core/vendor/tinymce/plugins/codemirror/codemirror/mode/javascript/javascript.js
vendored
Normal file
684
core/vendor/tinymce/plugins/codemirror/codemirror/mode/javascript/javascript.js
vendored
Normal file
@ -0,0 +1,684 @@
|
|||||||
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
|
// TODO actually recognize syntax of TypeScript constructs
|
||||||
|
|
||||||
|
(function(mod) {
|
||||||
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
|
mod(require("../../lib/codemirror"));
|
||||||
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
|
define(["../../lib/codemirror"], mod);
|
||||||
|
else // Plain browser env
|
||||||
|
mod(CodeMirror);
|
||||||
|
})(function(CodeMirror) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
|
var indentUnit = config.indentUnit;
|
||||||
|
var statementIndent = parserConfig.statementIndent;
|
||||||
|
var jsonldMode = parserConfig.jsonld;
|
||||||
|
var jsonMode = parserConfig.json || jsonldMode;
|
||||||
|
var isTS = parserConfig.typescript;
|
||||||
|
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
|
||||||
|
|
||||||
|
// Tokenizer
|
||||||
|
|
||||||
|
var keywords = function(){
|
||||||
|
function kw(type) {return {type: type, style: "keyword"};}
|
||||||
|
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
||||||
|
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
||||||
|
|
||||||
|
var jsKeywords = {
|
||||||
|
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
||||||
|
"return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C,
|
||||||
|
"var": kw("var"), "const": kw("var"), "let": kw("var"),
|
||||||
|
"function": kw("function"), "catch": kw("catch"),
|
||||||
|
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
||||||
|
"in": operator, "typeof": operator, "instanceof": operator,
|
||||||
|
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
||||||
|
"this": kw("this"), "module": kw("module"), "class": kw("class"), "super": kw("atom"),
|
||||||
|
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C
|
||||||
|
};
|
||||||
|
|
||||||
|
// Extend the 'normal' keywords with the TypeScript language extensions
|
||||||
|
if (isTS) {
|
||||||
|
var type = {type: "variable", style: "variable-3"};
|
||||||
|
var tsKeywords = {
|
||||||
|
// object-like things
|
||||||
|
"interface": kw("interface"),
|
||||||
|
"extends": kw("extends"),
|
||||||
|
"constructor": kw("constructor"),
|
||||||
|
|
||||||
|
// scope modifiers
|
||||||
|
"public": kw("public"),
|
||||||
|
"private": kw("private"),
|
||||||
|
"protected": kw("protected"),
|
||||||
|
"static": kw("static"),
|
||||||
|
|
||||||
|
// types
|
||||||
|
"string": type, "number": type, "bool": type, "any": type
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var attr in tsKeywords) {
|
||||||
|
jsKeywords[attr] = tsKeywords[attr];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsKeywords;
|
||||||
|
}();
|
||||||
|
|
||||||
|
var isOperatorChar = /[+\-*&%=<>!?|~^]/;
|
||||||
|
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
||||||
|
|
||||||
|
function readRegexp(stream) {
|
||||||
|
var escaped = false, next, inSet = false;
|
||||||
|
while ((next = stream.next()) != null) {
|
||||||
|
if (!escaped) {
|
||||||
|
if (next == "/" && !inSet) return;
|
||||||
|
if (next == "[") inSet = true;
|
||||||
|
else if (inSet && next == "]") inSet = false;
|
||||||
|
}
|
||||||
|
escaped = !escaped && next == "\\";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used as scratch variables to communicate multiple values without
|
||||||
|
// consing up tons of objects.
|
||||||
|
var type, content;
|
||||||
|
function ret(tp, style, cont) {
|
||||||
|
type = tp; content = cont;
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
function tokenBase(stream, state) {
|
||||||
|
var ch = stream.next();
|
||||||
|
if (ch == '"' || ch == "'") {
|
||||||
|
state.tokenize = tokenString(ch);
|
||||||
|
return state.tokenize(stream, state);
|
||||||
|
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
|
||||||
|
return ret("number", "number");
|
||||||
|
} else if (ch == "." && stream.match("..")) {
|
||||||
|
return ret("spread", "meta");
|
||||||
|
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||||
|
return ret(ch);
|
||||||
|
} else if (ch == "=" && stream.eat(">")) {
|
||||||
|
return ret("=>", "operator");
|
||||||
|
} else if (ch == "0" && stream.eat(/x/i)) {
|
||||||
|
stream.eatWhile(/[\da-f]/i);
|
||||||
|
return ret("number", "number");
|
||||||
|
} else if (/\d/.test(ch)) {
|
||||||
|
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
||||||
|
return ret("number", "number");
|
||||||
|
} else if (ch == "/") {
|
||||||
|
if (stream.eat("*")) {
|
||||||
|
state.tokenize = tokenComment;
|
||||||
|
return tokenComment(stream, state);
|
||||||
|
} else if (stream.eat("/")) {
|
||||||
|
stream.skipToEnd();
|
||||||
|
return ret("comment", "comment");
|
||||||
|
} else if (state.lastType == "operator" || state.lastType == "keyword c" ||
|
||||||
|
state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
|
||||||
|
readRegexp(stream);
|
||||||
|
stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
|
||||||
|
return ret("regexp", "string-2");
|
||||||
|
} else {
|
||||||
|
stream.eatWhile(isOperatorChar);
|
||||||
|
return ret("operator", "operator", stream.current());
|
||||||
|
}
|
||||||
|
} else if (ch == "`") {
|
||||||
|
state.tokenize = tokenQuasi;
|
||||||
|
return tokenQuasi(stream, state);
|
||||||
|
} else if (ch == "#") {
|
||||||
|
stream.skipToEnd();
|
||||||
|
return ret("error", "error");
|
||||||
|
} else if (isOperatorChar.test(ch)) {
|
||||||
|
stream.eatWhile(isOperatorChar);
|
||||||
|
return ret("operator", "operator", stream.current());
|
||||||
|
} else if (wordRE.test(ch)) {
|
||||||
|
stream.eatWhile(wordRE);
|
||||||
|
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
||||||
|
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
|
||||||
|
ret("variable", "variable", word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tokenString(quote) {
|
||||||
|
return function(stream, state) {
|
||||||
|
var escaped = false, next;
|
||||||
|
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
|
||||||
|
state.tokenize = tokenBase;
|
||||||
|
return ret("jsonld-keyword", "meta");
|
||||||
|
}
|
||||||
|
while ((next = stream.next()) != null) {
|
||||||
|
if (next == quote && !escaped) break;
|
||||||
|
escaped = !escaped && next == "\\";
|
||||||
|
}
|
||||||
|
if (!escaped) state.tokenize = tokenBase;
|
||||||
|
return ret("string", "string");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function tokenComment(stream, state) {
|
||||||
|
var maybeEnd = false, ch;
|
||||||
|
while (ch = stream.next()) {
|
||||||
|
if (ch == "/" && maybeEnd) {
|
||||||
|
state.tokenize = tokenBase;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
maybeEnd = (ch == "*");
|
||||||
|
}
|
||||||
|
return ret("comment", "comment");
|
||||||
|
}
|
||||||
|
|
||||||
|
function tokenQuasi(stream, state) {
|
||||||
|
var escaped = false, next;
|
||||||
|
while ((next = stream.next()) != null) {
|
||||||
|
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
|
||||||
|
state.tokenize = tokenBase;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
escaped = !escaped && next == "\\";
|
||||||
|
}
|
||||||
|
return ret("quasi", "string-2", stream.current());
|
||||||
|
}
|
||||||
|
|
||||||
|
var brackets = "([{}])";
|
||||||
|
// This is a crude lookahead trick to try and notice that we're
|
||||||
|
// parsing the argument patterns for a fat-arrow function before we
|
||||||
|
// actually hit the arrow token. It only works if the arrow is on
|
||||||
|
// the same line as the arguments and there's no strange noise
|
||||||
|
// (comments) in between. Fallback is to only notice when we hit the
|
||||||
|
// arrow, and not declare the arguments as locals for the arrow
|
||||||
|
// body.
|
||||||
|
function findFatArrow(stream, state) {
|
||||||
|
if (state.fatArrowAt) state.fatArrowAt = null;
|
||||||
|
var arrow = stream.string.indexOf("=>", stream.start);
|
||||||
|
if (arrow < 0) return;
|
||||||
|
|
||||||
|
var depth = 0, sawSomething = false;
|
||||||
|
for (var pos = arrow - 1; pos >= 0; --pos) {
|
||||||
|
var ch = stream.string.charAt(pos);
|
||||||
|
var bracket = brackets.indexOf(ch);
|
||||||
|
if (bracket >= 0 && bracket < 3) {
|
||||||
|
if (!depth) { ++pos; break; }
|
||||||
|
if (--depth == 0) break;
|
||||||
|
} else if (bracket >= 3 && bracket < 6) {
|
||||||
|
++depth;
|
||||||
|
} else if (wordRE.test(ch)) {
|
||||||
|
sawSomething = true;
|
||||||
|
} else if (sawSomething && !depth) {
|
||||||
|
++pos;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sawSomething && !depth) state.fatArrowAt = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parser
|
||||||
|
|
||||||
|
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
|
||||||
|
|
||||||
|
function JSLexical(indented, column, type, align, prev, info) {
|
||||||
|
this.indented = indented;
|
||||||
|
this.column = column;
|
||||||
|
this.type = type;
|
||||||
|
this.prev = prev;
|
||||||
|
this.info = info;
|
||||||
|
if (align != null) this.align = align;
|
||||||
|
}
|
||||||
|
|
||||||
|
function inScope(state, varname) {
|
||||||
|
for (var v = state.localVars; v; v = v.next)
|
||||||
|
if (v.name == varname) return true;
|
||||||
|
for (var cx = state.context; cx; cx = cx.prev) {
|
||||||
|
for (var v = cx.vars; v; v = v.next)
|
||||||
|
if (v.name == varname) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseJS(state, style, type, content, stream) {
|
||||||
|
var cc = state.cc;
|
||||||
|
// Communicate our context to the combinators.
|
||||||
|
// (Less wasteful than consing up a hundred closures on every call.)
|
||||||
|
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
|
||||||
|
|
||||||
|
if (!state.lexical.hasOwnProperty("align"))
|
||||||
|
state.lexical.align = true;
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
||||||
|
if (combinator(type, content)) {
|
||||||
|
while(cc.length && cc[cc.length - 1].lex)
|
||||||
|
cc.pop()();
|
||||||
|
if (cx.marked) return cx.marked;
|
||||||
|
if (type == "variable" && inScope(state, content)) return "variable-2";
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combinator utils
|
||||||
|
|
||||||
|
var cx = {state: null, column: null, marked: null, cc: null};
|
||||||
|
function pass() {
|
||||||
|
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
||||||
|
}
|
||||||
|
function cont() {
|
||||||
|
pass.apply(null, arguments);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function register(varname) {
|
||||||
|
function inList(list) {
|
||||||
|
for (var v = list; v; v = v.next)
|
||||||
|
if (v.name == varname) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var state = cx.state;
|
||||||
|
if (state.context) {
|
||||||
|
cx.marked = "def";
|
||||||
|
if (inList(state.localVars)) return;
|
||||||
|
state.localVars = {name: varname, next: state.localVars};
|
||||||
|
} else {
|
||||||
|
if (inList(state.globalVars)) return;
|
||||||
|
if (parserConfig.globalVars)
|
||||||
|
state.globalVars = {name: varname, next: state.globalVars};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combinators
|
||||||
|
|
||||||
|
var defaultVars = {name: "this", next: {name: "arguments"}};
|
||||||
|
function pushcontext() {
|
||||||
|
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
||||||
|
cx.state.localVars = defaultVars;
|
||||||
|
}
|
||||||
|
function popcontext() {
|
||||||
|
cx.state.localVars = cx.state.context.vars;
|
||||||
|
cx.state.context = cx.state.context.prev;
|
||||||
|
}
|
||||||
|
function pushlex(type, info) {
|
||||||
|
var result = function() {
|
||||||
|
var state = cx.state, indent = state.indented;
|
||||||
|
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
||||||
|
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
|
||||||
|
indent = outer.indented;
|
||||||
|
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
||||||
|
};
|
||||||
|
result.lex = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
function poplex() {
|
||||||
|
var state = cx.state;
|
||||||
|
if (state.lexical.prev) {
|
||||||
|
if (state.lexical.type == ")")
|
||||||
|
state.indented = state.lexical.indented;
|
||||||
|
state.lexical = state.lexical.prev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
poplex.lex = true;
|
||||||
|
|
||||||
|
function expect(wanted) {
|
||||||
|
function exp(type) {
|
||||||
|
if (type == wanted) return cont();
|
||||||
|
else if (wanted == ";") return pass();
|
||||||
|
else return cont(exp);
|
||||||
|
};
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
function statement(type, value) {
|
||||||
|
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
|
||||||
|
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
|
||||||
|
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
||||||
|
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||||
|
if (type == ";") return cont();
|
||||||
|
if (type == "if") {
|
||||||
|
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
||||||
|
cx.state.cc.pop()();
|
||||||
|
return cont(pushlex("form"), expression, statement, poplex, maybeelse);
|
||||||
|
}
|
||||||
|
if (type == "function") return cont(functiondef);
|
||||||
|
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
||||||
|
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
||||||
|
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
||||||
|
block, poplex, poplex);
|
||||||
|
if (type == "case") return cont(expression, expect(":"));
|
||||||
|
if (type == "default") return cont(expect(":"));
|
||||||
|
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
||||||
|
statement, poplex, popcontext);
|
||||||
|
if (type == "module") return cont(pushlex("form"), pushcontext, afterModule, popcontext, poplex);
|
||||||
|
if (type == "class") return cont(pushlex("form"), className, poplex);
|
||||||
|
if (type == "export") return cont(pushlex("form"), afterExport, poplex);
|
||||||
|
if (type == "import") return cont(pushlex("form"), afterImport, poplex);
|
||||||
|
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||||
|
}
|
||||||
|
function expression(type) {
|
||||||
|
return expressionInner(type, false);
|
||||||
|
}
|
||||||
|
function expressionNoComma(type) {
|
||||||
|
return expressionInner(type, true);
|
||||||
|
}
|
||||||
|
function expressionInner(type, noComma) {
|
||||||
|
if (cx.state.fatArrowAt == cx.stream.start) {
|
||||||
|
var body = noComma ? arrowBodyNoComma : arrowBody;
|
||||||
|
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
|
||||||
|
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
||||||
|
}
|
||||||
|
|
||||||
|
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
||||||
|
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
||||||
|
if (type == "function") return cont(functiondef, maybeop);
|
||||||
|
if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
|
||||||
|
if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
|
||||||
|
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
||||||
|
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
||||||
|
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
||||||
|
if (type == "quasi") { return pass(quasi, maybeop); }
|
||||||
|
return cont();
|
||||||
|
}
|
||||||
|
function maybeexpression(type) {
|
||||||
|
if (type.match(/[;\}\)\],]/)) return pass();
|
||||||
|
return pass(expression);
|
||||||
|
}
|
||||||
|
function maybeexpressionNoComma(type) {
|
||||||
|
if (type.match(/[;\}\)\],]/)) return pass();
|
||||||
|
return pass(expressionNoComma);
|
||||||
|
}
|
||||||
|
|
||||||
|
function maybeoperatorComma(type, value) {
|
||||||
|
if (type == ",") return cont(expression);
|
||||||
|
return maybeoperatorNoComma(type, value, false);
|
||||||
|
}
|
||||||
|
function maybeoperatorNoComma(type, value, noComma) {
|
||||||
|
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
||||||
|
var expr = noComma == false ? expression : expressionNoComma;
|
||||||
|
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
||||||
|
if (type == "operator") {
|
||||||
|
if (/\+\+|--/.test(value)) return cont(me);
|
||||||
|
if (value == "?") return cont(expression, expect(":"), expr);
|
||||||
|
return cont(expr);
|
||||||
|
}
|
||||||
|
if (type == "quasi") { return pass(quasi, me); }
|
||||||
|
if (type == ";") return;
|
||||||
|
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
||||||
|
if (type == ".") return cont(property, me);
|
||||||
|
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
||||||
|
}
|
||||||
|
function quasi(type, value) {
|
||||||
|
if (type != "quasi") return pass();
|
||||||
|
if (value.slice(value.length - 2) != "${") return cont(quasi);
|
||||||
|
return cont(expression, continueQuasi);
|
||||||
|
}
|
||||||
|
function continueQuasi(type) {
|
||||||
|
if (type == "}") {
|
||||||
|
cx.marked = "string-2";
|
||||||
|
cx.state.tokenize = tokenQuasi;
|
||||||
|
return cont(quasi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function arrowBody(type) {
|
||||||
|
findFatArrow(cx.stream, cx.state);
|
||||||
|
return pass(type == "{" ? statement : expression);
|
||||||
|
}
|
||||||
|
function arrowBodyNoComma(type) {
|
||||||
|
findFatArrow(cx.stream, cx.state);
|
||||||
|
return pass(type == "{" ? statement : expressionNoComma);
|
||||||
|
}
|
||||||
|
function maybelabel(type) {
|
||||||
|
if (type == ":") return cont(poplex, statement);
|
||||||
|
return pass(maybeoperatorComma, expect(";"), poplex);
|
||||||
|
}
|
||||||
|
function property(type) {
|
||||||
|
if (type == "variable") {cx.marked = "property"; return cont();}
|
||||||
|
}
|
||||||
|
function objprop(type, value) {
|
||||||
|
if (type == "variable" || cx.style == "keyword") {
|
||||||
|
cx.marked = "property";
|
||||||
|
if (value == "get" || value == "set") return cont(getterSetter);
|
||||||
|
return cont(afterprop);
|
||||||
|
} else if (type == "number" || type == "string") {
|
||||||
|
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
||||||
|
return cont(afterprop);
|
||||||
|
} else if (type == "jsonld-keyword") {
|
||||||
|
return cont(afterprop);
|
||||||
|
} else if (type == "[") {
|
||||||
|
return cont(expression, expect("]"), afterprop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getterSetter(type) {
|
||||||
|
if (type != "variable") return pass(afterprop);
|
||||||
|
cx.marked = "property";
|
||||||
|
return cont(functiondef);
|
||||||
|
}
|
||||||
|
function afterprop(type) {
|
||||||
|
if (type == ":") return cont(expressionNoComma);
|
||||||
|
if (type == "(") return pass(functiondef);
|
||||||
|
}
|
||||||
|
function commasep(what, end) {
|
||||||
|
function proceed(type) {
|
||||||
|
if (type == ",") {
|
||||||
|
var lex = cx.state.lexical;
|
||||||
|
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
||||||
|
return cont(what, proceed);
|
||||||
|
}
|
||||||
|
if (type == end) return cont();
|
||||||
|
return cont(expect(end));
|
||||||
|
}
|
||||||
|
return function(type) {
|
||||||
|
if (type == end) return cont();
|
||||||
|
return pass(what, proceed);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function contCommasep(what, end, info) {
|
||||||
|
for (var i = 3; i < arguments.length; i++)
|
||||||
|
cx.cc.push(arguments[i]);
|
||||||
|
return cont(pushlex(end, info), commasep(what, end), poplex);
|
||||||
|
}
|
||||||
|
function block(type) {
|
||||||
|
if (type == "}") return cont();
|
||||||
|
return pass(statement, block);
|
||||||
|
}
|
||||||
|
function maybetype(type) {
|
||||||
|
if (isTS && type == ":") return cont(typedef);
|
||||||
|
}
|
||||||
|
function typedef(type) {
|
||||||
|
if (type == "variable"){cx.marked = "variable-3"; return cont();}
|
||||||
|
}
|
||||||
|
function vardef() {
|
||||||
|
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
||||||
|
}
|
||||||
|
function pattern(type, value) {
|
||||||
|
if (type == "variable") { register(value); return cont(); }
|
||||||
|
if (type == "[") return contCommasep(pattern, "]");
|
||||||
|
if (type == "{") return contCommasep(proppattern, "}");
|
||||||
|
}
|
||||||
|
function proppattern(type, value) {
|
||||||
|
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
|
||||||
|
register(value);
|
||||||
|
return cont(maybeAssign);
|
||||||
|
}
|
||||||
|
if (type == "variable") cx.marked = "property";
|
||||||
|
return cont(expect(":"), pattern, maybeAssign);
|
||||||
|
}
|
||||||
|
function maybeAssign(_type, value) {
|
||||||
|
if (value == "=") return cont(expressionNoComma);
|
||||||
|
}
|
||||||
|
function vardefCont(type) {
|
||||||
|
if (type == ",") return cont(vardef);
|
||||||
|
}
|
||||||
|
function maybeelse(type, value) {
|
||||||
|
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
||||||
|
}
|
||||||
|
function forspec(type) {
|
||||||
|
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
||||||
|
}
|
||||||
|
function forspec1(type) {
|
||||||
|
if (type == "var") return cont(vardef, expect(";"), forspec2);
|
||||||
|
if (type == ";") return cont(forspec2);
|
||||||
|
if (type == "variable") return cont(formaybeinof);
|
||||||
|
return pass(expression, expect(";"), forspec2);
|
||||||
|
}
|
||||||
|
function formaybeinof(_type, value) {
|
||||||
|
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
||||||
|
return cont(maybeoperatorComma, forspec2);
|
||||||
|
}
|
||||||
|
function forspec2(type, value) {
|
||||||
|
if (type == ";") return cont(forspec3);
|
||||||
|
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
||||||
|
return pass(expression, expect(";"), forspec3);
|
||||||
|
}
|
||||||
|
function forspec3(type) {
|
||||||
|
if (type != ")") cont(expression);
|
||||||
|
}
|
||||||
|
function functiondef(type, value) {
|
||||||
|
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
||||||
|
if (type == "variable") {register(value); return cont(functiondef);}
|
||||||
|
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
|
||||||
|
}
|
||||||
|
function funarg(type) {
|
||||||
|
if (type == "spread") return cont(funarg);
|
||||||
|
return pass(pattern, maybetype);
|
||||||
|
}
|
||||||
|
function className(type, value) {
|
||||||
|
if (type == "variable") {register(value); return cont(classNameAfter);}
|
||||||
|
}
|
||||||
|
function classNameAfter(type, value) {
|
||||||
|
if (value == "extends") return cont(expression, classNameAfter);
|
||||||
|
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
||||||
|
}
|
||||||
|
function classBody(type, value) {
|
||||||
|
if (type == "variable" || cx.style == "keyword") {
|
||||||
|
cx.marked = "property";
|
||||||
|
if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
|
||||||
|
return cont(functiondef, classBody);
|
||||||
|
}
|
||||||
|
if (value == "*") {
|
||||||
|
cx.marked = "keyword";
|
||||||
|
return cont(classBody);
|
||||||
|
}
|
||||||
|
if (type == ";") return cont(classBody);
|
||||||
|
if (type == "}") return cont();
|
||||||
|
}
|
||||||
|
function classGetterSetter(type) {
|
||||||
|
if (type != "variable") return pass();
|
||||||
|
cx.marked = "property";
|
||||||
|
return cont();
|
||||||
|
}
|
||||||
|
function afterModule(type, value) {
|
||||||
|
if (type == "string") return cont(statement);
|
||||||
|
if (type == "variable") { register(value); return cont(maybeFrom); }
|
||||||
|
}
|
||||||
|
function afterExport(_type, value) {
|
||||||
|
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
||||||
|
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
||||||
|
return pass(statement);
|
||||||
|
}
|
||||||
|
function afterImport(type) {
|
||||||
|
if (type == "string") return cont();
|
||||||
|
return pass(importSpec, maybeFrom);
|
||||||
|
}
|
||||||
|
function importSpec(type, value) {
|
||||||
|
if (type == "{") return contCommasep(importSpec, "}");
|
||||||
|
if (type == "variable") register(value);
|
||||||
|
return cont();
|
||||||
|
}
|
||||||
|
function maybeFrom(_type, value) {
|
||||||
|
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
|
||||||
|
}
|
||||||
|
function arrayLiteral(type) {
|
||||||
|
if (type == "]") return cont();
|
||||||
|
return pass(expressionNoComma, maybeArrayComprehension);
|
||||||
|
}
|
||||||
|
function maybeArrayComprehension(type) {
|
||||||
|
if (type == "for") return pass(comprehension, expect("]"));
|
||||||
|
if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
|
||||||
|
return pass(commasep(expressionNoComma, "]"));
|
||||||
|
}
|
||||||
|
function comprehension(type) {
|
||||||
|
if (type == "for") return cont(forspec, comprehension);
|
||||||
|
if (type == "if") return cont(expression, comprehension);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interface
|
||||||
|
|
||||||
|
return {
|
||||||
|
startState: function(basecolumn) {
|
||||||
|
var state = {
|
||||||
|
tokenize: tokenBase,
|
||||||
|
lastType: "sof",
|
||||||
|
cc: [],
|
||||||
|
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
||||||
|
localVars: parserConfig.localVars,
|
||||||
|
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
||||||
|
indented: 0
|
||||||
|
};
|
||||||
|
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
||||||
|
state.globalVars = parserConfig.globalVars;
|
||||||
|
return state;
|
||||||
|
},
|
||||||
|
|
||||||
|
token: function(stream, state) {
|
||||||
|
if (stream.sol()) {
|
||||||
|
if (!state.lexical.hasOwnProperty("align"))
|
||||||
|
state.lexical.align = false;
|
||||||
|
state.indented = stream.indentation();
|
||||||
|
findFatArrow(stream, state);
|
||||||
|
}
|
||||||
|
if (state.tokenize != tokenComment && stream.eatSpace()) return null;
|
||||||
|
var style = state.tokenize(stream, state);
|
||||||
|
if (type == "comment") return style;
|
||||||
|
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
||||||
|
return parseJS(state, style, type, content, stream);
|
||||||
|
},
|
||||||
|
|
||||||
|
indent: function(state, textAfter) {
|
||||||
|
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
||||||
|
if (state.tokenize != tokenBase) return 0;
|
||||||
|
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
||||||
|
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
||||||
|
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
||||||
|
var c = state.cc[i];
|
||||||
|
if (c == poplex) lexical = lexical.prev;
|
||||||
|
else if (c != maybeelse) break;
|
||||||
|
}
|
||||||
|
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
||||||
|
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
||||||
|
lexical = lexical.prev;
|
||||||
|
var type = lexical.type, closing = firstChar == type;
|
||||||
|
|
||||||
|
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
|
||||||
|
else if (type == "form" && firstChar == "{") return lexical.indented;
|
||||||
|
else if (type == "form") return lexical.indented + indentUnit;
|
||||||
|
else if (type == "stat")
|
||||||
|
return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);
|
||||||
|
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
||||||
|
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
||||||
|
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
||||||
|
else return lexical.indented + (closing ? 0 : indentUnit);
|
||||||
|
},
|
||||||
|
|
||||||
|
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
|
||||||
|
blockCommentStart: jsonMode ? null : "/*",
|
||||||
|
blockCommentEnd: jsonMode ? null : "*/",
|
||||||
|
lineComment: jsonMode ? null : "//",
|
||||||
|
fold: "brace",
|
||||||
|
|
||||||
|
helperType: jsonMode ? "json" : "javascript",
|
||||||
|
jsonldMode: jsonldMode,
|
||||||
|
jsonMode: jsonMode
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
||||||
|
|
||||||
|
CodeMirror.defineMIME("text/javascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("application/javascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("application/x-javascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
||||||
|
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
||||||
|
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
|
||||||
|
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
||||||
|
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
||||||
|
|
||||||
|
});
|
765
core/vendor/tinymce/plugins/codemirror/codemirror/mode/markdown/markdown.js
vendored
Normal file
765
core/vendor/tinymce/plugins/codemirror/codemirror/mode/markdown/markdown.js
vendored
Normal file
@ -0,0 +1,765 @@
|
|||||||
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
|
(function(mod) {
|
||||||
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
|
mod(require("../../lib/codemirror", require("../xml/xml"), require("../meta")));
|
||||||
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
|
define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
|
||||||
|
else // Plain browser env
|
||||||
|
mod(CodeMirror);
|
||||||
|
})(function(CodeMirror) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
||||||
|
|
||||||
|
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
|
||||||
|
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
|
||||||
|
|
||||||
|
function getMode(name) {
|
||||||
|
if (CodeMirror.findModeByName) {
|
||||||
|
var found = CodeMirror.findModeByName(name);
|
||||||
|
if (found) name = found.mime || found.mimes[0];
|
||||||
|
}
|
||||||
|
var mode = CodeMirror.getMode(cmCfg, name);
|
||||||
|
return mode.name == "null" ? null : mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should characters that affect highlighting be highlighted separate?
|
||||||
|
// Does not include characters that will be output (such as `1.` and `-` for lists)
|
||||||
|
if (modeCfg.highlightFormatting === undefined)
|
||||||
|
modeCfg.highlightFormatting = false;
|
||||||
|
|
||||||
|
// Maximum number of nested blockquotes. Set to 0 for infinite nesting.
|
||||||
|
// Excess `>` will emit `error` token.
|
||||||
|
if (modeCfg.maxBlockquoteDepth === undefined)
|
||||||
|
modeCfg.maxBlockquoteDepth = 0;
|
||||||
|
|
||||||
|
// Should underscores in words open/close em/strong?
|
||||||
|
if (modeCfg.underscoresBreakWords === undefined)
|
||||||
|
modeCfg.underscoresBreakWords = true;
|
||||||
|
|
||||||
|
// Turn on fenced code blocks? ("```" to start/end)
|
||||||
|
if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
|
||||||
|
|
||||||
|
// Turn on task lists? ("- [ ] " and "- [x] ")
|
||||||
|
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
|
||||||
|
|
||||||
|
// Turn on strikethrough syntax
|
||||||
|
if (modeCfg.strikethrough === undefined)
|
||||||
|
modeCfg.strikethrough = false;
|
||||||
|
|
||||||
|
var codeDepth = 0;
|
||||||
|
|
||||||
|
var header = 'header'
|
||||||
|
, code = 'comment'
|
||||||
|
, quote = 'quote'
|
||||||
|
, list1 = 'variable-2'
|
||||||
|
, list2 = 'variable-3'
|
||||||
|
, list3 = 'keyword'
|
||||||
|
, hr = 'hr'
|
||||||
|
, image = 'tag'
|
||||||
|
, formatting = 'formatting'
|
||||||
|
, linkinline = 'link'
|
||||||
|
, linkemail = 'link'
|
||||||
|
, linktext = 'link'
|
||||||
|
, linkhref = 'string'
|
||||||
|
, em = 'em'
|
||||||
|
, strong = 'strong'
|
||||||
|
, strikethrough = 'strikethrough';
|
||||||
|
|
||||||
|
var hrRE = /^([*\-=_])(?:\s*\1){2,}\s*$/
|
||||||
|
, ulRE = /^[*\-+]\s+/
|
||||||
|
, olRE = /^[0-9]+\.\s+/
|
||||||
|
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
||||||
|
, atxHeaderRE = /^#+/
|
||||||
|
, setextHeaderRE = /^(?:\={1,}|-{1,})$/
|
||||||
|
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
|
||||||
|
|
||||||
|
function switchInline(stream, state, f) {
|
||||||
|
state.f = state.inline = f;
|
||||||
|
return f(stream, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
function switchBlock(stream, state, f) {
|
||||||
|
state.f = state.block = f;
|
||||||
|
return f(stream, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Blocks
|
||||||
|
|
||||||
|
function blankLine(state) {
|
||||||
|
// Reset linkTitle state
|
||||||
|
state.linkTitle = false;
|
||||||
|
// Reset EM state
|
||||||
|
state.em = false;
|
||||||
|
// Reset STRONG state
|
||||||
|
state.strong = false;
|
||||||
|
// Reset strikethrough state
|
||||||
|
state.strikethrough = false;
|
||||||
|
// Reset state.quote
|
||||||
|
state.quote = 0;
|
||||||
|
if (!htmlFound && state.f == htmlBlock) {
|
||||||
|
state.f = inlineNormal;
|
||||||
|
state.block = blockNormal;
|
||||||
|
}
|
||||||
|
// Reset state.trailingSpace
|
||||||
|
state.trailingSpace = 0;
|
||||||
|
state.trailingSpaceNewLine = false;
|
||||||
|
// Mark this line as blank
|
||||||
|
state.thisLineHasContent = false;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function blockNormal(stream, state) {
|
||||||
|
|
||||||
|
var sol = stream.sol();
|
||||||
|
|
||||||
|
var prevLineIsList = (state.list !== false);
|
||||||
|
if (state.list !== false && state.indentationDiff >= 0) { // Continued list
|
||||||
|
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
|
||||||
|
state.indentation -= state.indentationDiff;
|
||||||
|
}
|
||||||
|
state.list = null;
|
||||||
|
} else if (state.list !== false && state.indentation > 0) {
|
||||||
|
state.list = null;
|
||||||
|
state.listDepth = Math.floor(state.indentation / 4);
|
||||||
|
} else if (state.list !== false) { // No longer a list
|
||||||
|
state.list = false;
|
||||||
|
state.listDepth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = null;
|
||||||
|
if (state.indentationDiff >= 4) {
|
||||||
|
state.indentation -= 4;
|
||||||
|
stream.skipToEnd();
|
||||||
|
return code;
|
||||||
|
} else if (stream.eatSpace()) {
|
||||||
|
return null;
|
||||||
|
} else if (match = stream.match(atxHeaderRE)) {
|
||||||
|
state.header = match[0].length <= 6 ? match[0].length : 6;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||||
|
state.f = state.inline;
|
||||||
|
return getType(state);
|
||||||
|
} else if (state.prevLineHasContent && (match = stream.match(setextHeaderRE))) {
|
||||||
|
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||||
|
state.f = state.inline;
|
||||||
|
return getType(state);
|
||||||
|
} else if (stream.eat('>')) {
|
||||||
|
state.indentation++;
|
||||||
|
state.quote = sol ? 1 : state.quote + 1;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "quote";
|
||||||
|
stream.eatSpace();
|
||||||
|
return getType(state);
|
||||||
|
} else if (stream.peek() === '[') {
|
||||||
|
return switchInline(stream, state, footnoteLink);
|
||||||
|
} else if (stream.match(hrRE, true)) {
|
||||||
|
return hr;
|
||||||
|
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
||||||
|
var listType = null;
|
||||||
|
if (stream.match(ulRE, true)) {
|
||||||
|
listType = 'ul';
|
||||||
|
} else {
|
||||||
|
stream.match(olRE, true);
|
||||||
|
listType = 'ol';
|
||||||
|
}
|
||||||
|
state.indentation += 4;
|
||||||
|
state.list = true;
|
||||||
|
state.listDepth++;
|
||||||
|
if (modeCfg.taskLists && stream.match(taskListRE, false)) {
|
||||||
|
state.taskList = true;
|
||||||
|
}
|
||||||
|
state.f = state.inline;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
|
||||||
|
return getType(state);
|
||||||
|
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) {
|
||||||
|
// try switching mode
|
||||||
|
state.localMode = getMode(RegExp.$1);
|
||||||
|
if (state.localMode) state.localState = state.localMode.startState();
|
||||||
|
state.f = state.block = local;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||||
|
state.code = true;
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
return switchInline(stream, state, state.inline);
|
||||||
|
}
|
||||||
|
|
||||||
|
function htmlBlock(stream, state) {
|
||||||
|
var style = htmlMode.token(stream, state.htmlState);
|
||||||
|
if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) ||
|
||||||
|
(state.md_inside && stream.current().indexOf(">") > -1)) {
|
||||||
|
state.f = inlineNormal;
|
||||||
|
state.block = blockNormal;
|
||||||
|
state.htmlState = null;
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
function local(stream, state) {
|
||||||
|
if (stream.sol() && stream.match("```", false)) {
|
||||||
|
state.localMode = state.localState = null;
|
||||||
|
state.f = state.block = leavingLocal;
|
||||||
|
return null;
|
||||||
|
} else if (state.localMode) {
|
||||||
|
return state.localMode.token(stream, state.localState);
|
||||||
|
} else {
|
||||||
|
stream.skipToEnd();
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function leavingLocal(stream, state) {
|
||||||
|
stream.match("```");
|
||||||
|
state.block = blockNormal;
|
||||||
|
state.f = inlineNormal;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||||
|
state.code = true;
|
||||||
|
var returnType = getType(state);
|
||||||
|
state.code = false;
|
||||||
|
return returnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inline
|
||||||
|
function getType(state) {
|
||||||
|
var styles = [];
|
||||||
|
|
||||||
|
if (state.formatting) {
|
||||||
|
styles.push(formatting);
|
||||||
|
|
||||||
|
if (typeof state.formatting === "string") state.formatting = [state.formatting];
|
||||||
|
|
||||||
|
for (var i = 0; i < state.formatting.length; i++) {
|
||||||
|
styles.push(formatting + "-" + state.formatting[i]);
|
||||||
|
|
||||||
|
if (state.formatting[i] === "header") {
|
||||||
|
styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
|
||||||
|
// Add `error` instead if the maximum blockquote nesting depth is passed
|
||||||
|
if (state.formatting[i] === "quote") {
|
||||||
|
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||||
|
styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote);
|
||||||
|
} else {
|
||||||
|
styles.push("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.taskOpen) {
|
||||||
|
styles.push("meta");
|
||||||
|
return styles.length ? styles.join(' ') : null;
|
||||||
|
}
|
||||||
|
if (state.taskClosed) {
|
||||||
|
styles.push("property");
|
||||||
|
return styles.length ? styles.join(' ') : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.linkHref) {
|
||||||
|
styles.push(linkhref);
|
||||||
|
return styles.length ? styles.join(' ') : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.strong) { styles.push(strong); }
|
||||||
|
if (state.em) { styles.push(em); }
|
||||||
|
if (state.strikethrough) { styles.push(strikethrough); }
|
||||||
|
|
||||||
|
if (state.linkText) { styles.push(linktext); }
|
||||||
|
|
||||||
|
if (state.code) { styles.push(code); }
|
||||||
|
|
||||||
|
if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
|
||||||
|
|
||||||
|
if (state.quote) {
|
||||||
|
styles.push(quote);
|
||||||
|
|
||||||
|
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
|
||||||
|
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||||
|
styles.push(quote + "-" + state.quote);
|
||||||
|
} else {
|
||||||
|
styles.push(quote + "-" + modeCfg.maxBlockquoteDepth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.list !== false) {
|
||||||
|
var listMod = (state.listDepth - 1) % 3;
|
||||||
|
if (!listMod) {
|
||||||
|
styles.push(list1);
|
||||||
|
} else if (listMod === 1) {
|
||||||
|
styles.push(list2);
|
||||||
|
} else {
|
||||||
|
styles.push(list3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.trailingSpaceNewLine) {
|
||||||
|
styles.push("trailing-space-new-line");
|
||||||
|
} else if (state.trailingSpace) {
|
||||||
|
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return styles.length ? styles.join(' ') : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleText(stream, state) {
|
||||||
|
if (stream.match(textRE, true)) {
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function inlineNormal(stream, state) {
|
||||||
|
var style = state.text(stream, state);
|
||||||
|
if (typeof style !== 'undefined')
|
||||||
|
return style;
|
||||||
|
|
||||||
|
if (state.list) { // List marker (*, +, -, 1., etc)
|
||||||
|
state.list = null;
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.taskList) {
|
||||||
|
var taskOpen = stream.match(taskListRE, true)[1] !== "x";
|
||||||
|
if (taskOpen) state.taskOpen = true;
|
||||||
|
else state.taskClosed = true;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "task";
|
||||||
|
state.taskList = false;
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.taskOpen = false;
|
||||||
|
state.taskClosed = false;
|
||||||
|
|
||||||
|
if (state.header && stream.match(/^#+$/, true)) {
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get sol() value now, before character is consumed
|
||||||
|
var sol = stream.sol();
|
||||||
|
|
||||||
|
var ch = stream.next();
|
||||||
|
|
||||||
|
if (ch === '\\') {
|
||||||
|
stream.next();
|
||||||
|
if (modeCfg.highlightFormatting) {
|
||||||
|
var type = getType(state);
|
||||||
|
return type ? type + " formatting-escape" : "formatting-escape";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Matches link titles present on next line
|
||||||
|
if (state.linkTitle) {
|
||||||
|
state.linkTitle = false;
|
||||||
|
var matchCh = ch;
|
||||||
|
if (ch === '(') {
|
||||||
|
matchCh = ')';
|
||||||
|
}
|
||||||
|
matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||||
|
var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
|
||||||
|
if (stream.match(new RegExp(regex), true)) {
|
||||||
|
return linkhref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this block is changed, it may need to be updated in GFM mode
|
||||||
|
if (ch === '`') {
|
||||||
|
var previousFormatting = state.formatting;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "code";
|
||||||
|
var t = getType(state);
|
||||||
|
var before = stream.pos;
|
||||||
|
stream.eatWhile('`');
|
||||||
|
var difference = 1 + stream.pos - before;
|
||||||
|
if (!state.code) {
|
||||||
|
codeDepth = difference;
|
||||||
|
state.code = true;
|
||||||
|
return getType(state);
|
||||||
|
} else {
|
||||||
|
if (difference === codeDepth) { // Must be exact
|
||||||
|
state.code = false;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
state.formatting = previousFormatting;
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
} else if (state.code) {
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
|
||||||
|
stream.match(/\[[^\]]*\]/);
|
||||||
|
state.inline = state.f = linkHref;
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === '[' && stream.match(/.*\](\(| ?\[)/, false)) {
|
||||||
|
state.linkText = true;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === ']' && state.linkText) {
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||||
|
var type = getType(state);
|
||||||
|
state.linkText = false;
|
||||||
|
state.inline = state.f = linkHref;
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
|
||||||
|
state.f = state.inline = linkInline;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||||
|
var type = getType(state);
|
||||||
|
if (type){
|
||||||
|
type += " ";
|
||||||
|
} else {
|
||||||
|
type = "";
|
||||||
|
}
|
||||||
|
return type + linkinline;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
|
||||||
|
state.f = state.inline = linkInline;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||||
|
var type = getType(state);
|
||||||
|
if (type){
|
||||||
|
type += " ";
|
||||||
|
} else {
|
||||||
|
type = "";
|
||||||
|
}
|
||||||
|
return type + linkemail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === '<' && stream.match(/^\w/, false)) {
|
||||||
|
if (stream.string.indexOf(">") != -1) {
|
||||||
|
var atts = stream.string.substring(1,stream.string.indexOf(">"));
|
||||||
|
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
|
||||||
|
state.md_inside = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stream.backUp(1);
|
||||||
|
state.htmlState = CodeMirror.startState(htmlMode);
|
||||||
|
return switchBlock(stream, state, htmlBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === '<' && stream.match(/^\/\w*?>/)) {
|
||||||
|
state.md_inside = false;
|
||||||
|
return "tag";
|
||||||
|
}
|
||||||
|
|
||||||
|
var ignoreUnderscore = false;
|
||||||
|
if (!modeCfg.underscoresBreakWords) {
|
||||||
|
if (ch === '_' && stream.peek() !== '_' && stream.match(/(\w)/, false)) {
|
||||||
|
var prevPos = stream.pos - 2;
|
||||||
|
if (prevPos >= 0) {
|
||||||
|
var prevCh = stream.string.charAt(prevPos);
|
||||||
|
if (prevCh !== '_' && prevCh.match(/(\w)/, false)) {
|
||||||
|
ignoreUnderscore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ch === '*' || (ch === '_' && !ignoreUnderscore)) {
|
||||||
|
if (sol && stream.peek() === ' ') {
|
||||||
|
// Do nothing, surrounded by newline and space
|
||||||
|
} else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "strong";
|
||||||
|
var t = getType(state);
|
||||||
|
state.strong = false;
|
||||||
|
return t;
|
||||||
|
} else if (!state.strong && stream.eat(ch)) { // Add STRONG
|
||||||
|
state.strong = ch;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "strong";
|
||||||
|
return getType(state);
|
||||||
|
} else if (state.em === ch) { // Remove EM
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "em";
|
||||||
|
var t = getType(state);
|
||||||
|
state.em = false;
|
||||||
|
return t;
|
||||||
|
} else if (!state.em) { // Add EM
|
||||||
|
state.em = ch;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "em";
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
} else if (ch === ' ') {
|
||||||
|
if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces
|
||||||
|
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
||||||
|
return getType(state);
|
||||||
|
} else { // Not surrounded by spaces, back up pointer
|
||||||
|
stream.backUp(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modeCfg.strikethrough) {
|
||||||
|
if (ch === '~' && stream.eatWhile(ch)) {
|
||||||
|
if (state.strikethrough) {// Remove strikethrough
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
|
||||||
|
var t = getType(state);
|
||||||
|
state.strikethrough = false;
|
||||||
|
return t;
|
||||||
|
} else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
|
||||||
|
state.strikethrough = true;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
} else if (ch === ' ') {
|
||||||
|
if (stream.match(/^~~/, true)) { // Probably surrounded by space
|
||||||
|
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
||||||
|
return getType(state);
|
||||||
|
} else { // Not surrounded by spaces, back up pointer
|
||||||
|
stream.backUp(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch === ' ') {
|
||||||
|
if (stream.match(/ +$/, false)) {
|
||||||
|
state.trailingSpace++;
|
||||||
|
} else if (state.trailingSpace) {
|
||||||
|
state.trailingSpaceNewLine = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
function linkInline(stream, state) {
|
||||||
|
var ch = stream.next();
|
||||||
|
|
||||||
|
if (ch === ">") {
|
||||||
|
state.f = state.inline = inlineNormal;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||||
|
var type = getType(state);
|
||||||
|
if (type){
|
||||||
|
type += " ";
|
||||||
|
} else {
|
||||||
|
type = "";
|
||||||
|
}
|
||||||
|
return type + linkinline;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.match(/^[^>]+/, true);
|
||||||
|
|
||||||
|
return linkinline;
|
||||||
|
}
|
||||||
|
|
||||||
|
function linkHref(stream, state) {
|
||||||
|
// Check if space, and return NULL if so (to avoid marking the space)
|
||||||
|
if(stream.eatSpace()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var ch = stream.next();
|
||||||
|
if (ch === '(' || ch === '[') {
|
||||||
|
state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||||
|
state.linkHref = true;
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
return 'error';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLinkHrefInside(endChar) {
|
||||||
|
return function(stream, state) {
|
||||||
|
var ch = stream.next();
|
||||||
|
|
||||||
|
if (ch === endChar) {
|
||||||
|
state.f = state.inline = inlineNormal;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||||
|
var returnState = getType(state);
|
||||||
|
state.linkHref = false;
|
||||||
|
return returnState;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream.match(inlineRE(endChar), true)) {
|
||||||
|
stream.backUp(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.linkHref = true;
|
||||||
|
return getType(state);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function footnoteLink(stream, state) {
|
||||||
|
if (stream.match(/^[^\]]*\]:/, false)) {
|
||||||
|
state.f = footnoteLinkInside;
|
||||||
|
stream.next(); // Consume [
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||||
|
state.linkText = true;
|
||||||
|
return getType(state);
|
||||||
|
}
|
||||||
|
return switchInline(stream, state, inlineNormal);
|
||||||
|
}
|
||||||
|
|
||||||
|
function footnoteLinkInside(stream, state) {
|
||||||
|
if (stream.match(/^\]:/, true)) {
|
||||||
|
state.f = state.inline = footnoteUrl;
|
||||||
|
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||||
|
var returnType = getType(state);
|
||||||
|
state.linkText = false;
|
||||||
|
return returnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.match(/^[^\]]+/, true);
|
||||||
|
|
||||||
|
return linktext;
|
||||||
|
}
|
||||||
|
|
||||||
|
function footnoteUrl(stream, state) {
|
||||||
|
// Check if space, and return NULL if so (to avoid marking the space)
|
||||||
|
if(stream.eatSpace()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// Match URL
|
||||||
|
stream.match(/^[^\s]+/, true);
|
||||||
|
// Check for link title
|
||||||
|
if (stream.peek() === undefined) { // End of line, set flag to check next line
|
||||||
|
state.linkTitle = true;
|
||||||
|
} else { // More content on line, check if link title
|
||||||
|
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
|
||||||
|
}
|
||||||
|
state.f = state.inline = inlineNormal;
|
||||||
|
return linkhref;
|
||||||
|
}
|
||||||
|
|
||||||
|
var savedInlineRE = [];
|
||||||
|
function inlineRE(endChar) {
|
||||||
|
if (!savedInlineRE[endChar]) {
|
||||||
|
// Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741)
|
||||||
|
endChar = (endChar+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||||
|
// Match any non-endChar, escaped character, as well as the closing
|
||||||
|
// endChar.
|
||||||
|
savedInlineRE[endChar] = new RegExp('^(?:[^\\\\]|\\\\.)*?(' + endChar + ')');
|
||||||
|
}
|
||||||
|
return savedInlineRE[endChar];
|
||||||
|
}
|
||||||
|
|
||||||
|
var mode = {
|
||||||
|
startState: function() {
|
||||||
|
return {
|
||||||
|
f: blockNormal,
|
||||||
|
|
||||||
|
prevLineHasContent: false,
|
||||||
|
thisLineHasContent: false,
|
||||||
|
|
||||||
|
block: blockNormal,
|
||||||
|
htmlState: null,
|
||||||
|
indentation: 0,
|
||||||
|
|
||||||
|
inline: inlineNormal,
|
||||||
|
text: handleText,
|
||||||
|
|
||||||
|
formatting: false,
|
||||||
|
linkText: false,
|
||||||
|
linkHref: false,
|
||||||
|
linkTitle: false,
|
||||||
|
em: false,
|
||||||
|
strong: false,
|
||||||
|
header: 0,
|
||||||
|
taskList: false,
|
||||||
|
list: false,
|
||||||
|
listDepth: 0,
|
||||||
|
quote: 0,
|
||||||
|
trailingSpace: 0,
|
||||||
|
trailingSpaceNewLine: false,
|
||||||
|
strikethrough: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
copyState: function(s) {
|
||||||
|
return {
|
||||||
|
f: s.f,
|
||||||
|
|
||||||
|
prevLineHasContent: s.prevLineHasContent,
|
||||||
|
thisLineHasContent: s.thisLineHasContent,
|
||||||
|
|
||||||
|
block: s.block,
|
||||||
|
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
|
||||||
|
indentation: s.indentation,
|
||||||
|
|
||||||
|
localMode: s.localMode,
|
||||||
|
localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null,
|
||||||
|
|
||||||
|
inline: s.inline,
|
||||||
|
text: s.text,
|
||||||
|
formatting: false,
|
||||||
|
linkTitle: s.linkTitle,
|
||||||
|
em: s.em,
|
||||||
|
strong: s.strong,
|
||||||
|
strikethrough: s.strikethrough,
|
||||||
|
header: s.header,
|
||||||
|
taskList: s.taskList,
|
||||||
|
list: s.list,
|
||||||
|
listDepth: s.listDepth,
|
||||||
|
quote: s.quote,
|
||||||
|
trailingSpace: s.trailingSpace,
|
||||||
|
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
||||||
|
md_inside: s.md_inside
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
token: function(stream, state) {
|
||||||
|
|
||||||
|
// Reset state.formatting
|
||||||
|
state.formatting = false;
|
||||||
|
|
||||||
|
if (stream.sol()) {
|
||||||
|
var forceBlankLine = !!state.header;
|
||||||
|
|
||||||
|
// Reset state.header
|
||||||
|
state.header = 0;
|
||||||
|
|
||||||
|
if (stream.match(/^\s*$/, true) || forceBlankLine) {
|
||||||
|
state.prevLineHasContent = false;
|
||||||
|
blankLine(state);
|
||||||
|
return forceBlankLine ? this.token(stream, state) : null;
|
||||||
|
} else {
|
||||||
|
state.prevLineHasContent = state.thisLineHasContent;
|
||||||
|
state.thisLineHasContent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset state.taskList
|
||||||
|
state.taskList = false;
|
||||||
|
|
||||||
|
// Reset state.code
|
||||||
|
state.code = false;
|
||||||
|
|
||||||
|
// Reset state.trailingSpace
|
||||||
|
state.trailingSpace = 0;
|
||||||
|
state.trailingSpaceNewLine = false;
|
||||||
|
|
||||||
|
state.f = state.block;
|
||||||
|
var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
|
||||||
|
var difference = Math.floor((indentation - state.indentation) / 4) * 4;
|
||||||
|
if (difference > 4) difference = 4;
|
||||||
|
var adjustedIndentation = state.indentation + difference;
|
||||||
|
state.indentationDiff = adjustedIndentation - state.indentation;
|
||||||
|
state.indentation = adjustedIndentation;
|
||||||
|
if (indentation > 0) return null;
|
||||||
|
}
|
||||||
|
return state.f(stream, state);
|
||||||
|
},
|
||||||
|
|
||||||
|
innerMode: function(state) {
|
||||||
|
if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode};
|
||||||
|
if (state.localState) return {state: state.localState, mode: state.localMode};
|
||||||
|
return {state: state, mode: mode};
|
||||||
|
},
|
||||||
|
|
||||||
|
blankLine: blankLine,
|
||||||
|
|
||||||
|
getType: getType,
|
||||||
|
|
||||||
|
fold: "markdown"
|
||||||
|
};
|
||||||
|
return mode;
|
||||||
|
}, "xml");
|
||||||
|
|
||||||
|
CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||||
|
|
||||||
|
});
|
@ -1,64 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
|
|
||||||
<title>CodeMirror: PHP mode</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<link rel=stylesheet href="../../doc/docs.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
||||||
<script src="../../lib/codemirror.js"></script>
|
|
||||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
|
||||||
<script src="../xml/xml.js"></script>
|
|
||||||
<script src="../javascript/javascript.js"></script>
|
|
||||||
<script src="../css/css.js"></script>
|
|
||||||
<script src="../clike/clike.js"></script>
|
|
||||||
<script src="php.js"></script>
|
|
||||||
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
|
||||||
<div id=nav>
|
|
||||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="../../index.html">Home</a>
|
|
||||||
<li><a href="../../doc/manual.html">Manual</a>
|
|
||||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
|
||||||
</ul>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Language modes</a>
|
|
||||||
<li><a class=active href="#">PHP</a>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<h2>PHP mode</h2>
|
|
||||||
<form><textarea id="code" name="code">
|
|
||||||
<?php
|
|
||||||
$a = array('a' => 1, 'b' => 2, 3 => 'c');
|
|
||||||
|
|
||||||
echo "$a[a] ${a[3] /* } comment */} {$a[b]} \$a[a]";
|
|
||||||
|
|
||||||
function hello($who) {
|
|
||||||
return "Hello $who!";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<p>The program says <?= hello("World") ?>.</p>
|
|
||||||
<script>
|
|
||||||
alert("And here is some JS code"); // also colored
|
|
||||||
</script>
|
|
||||||
</textarea></form>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
||||||
lineNumbers: true,
|
|
||||||
matchBrackets: true,
|
|
||||||
mode: "application/x-httpd-php",
|
|
||||||
indentUnit: 4,
|
|
||||||
indentWithTabs: true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>Simple HTML/PHP mode based on
|
|
||||||
the <a href="../clike/">C-like</a> mode. Depends on XML,
|
|
||||||
JavaScript, CSS, HTMLMixed, and C-like modes.</p>
|
|
||||||
|
|
||||||
<p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
|
|
||||||
</article>
|
|
File diff suppressed because one or more lines are too long
@ -1,154 +0,0 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var mode = CodeMirror.getMode({indentUnit: 2}, "php");
|
|
||||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
|
||||||
|
|
||||||
MT('simple_test',
|
|
||||||
'[meta <?php] ' +
|
|
||||||
'[keyword echo] [string "aaa"]; ' +
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
MT('variable_interpolation_non_alphanumeric',
|
|
||||||
'[meta <?php]',
|
|
||||||
'[keyword echo] [string "aaa$~$!$@$#$$$%$^$&$*$($)$.$<$>$/$\\$}$\\\"$:$;$?$|$[[$]]$+$=aaa"]',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
MT('variable_interpolation_digits',
|
|
||||||
'[meta <?php]',
|
|
||||||
'[keyword echo] [string "aaa$1$2$3$4$5$6$7$8$9$0aaa"]',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
MT('variable_interpolation_simple_syntax_1',
|
|
||||||
'[meta <?php]',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaa][string .aaa"];',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
MT('variable_interpolation_simple_syntax_2',
|
|
||||||
'[meta <?php]',
|
|
||||||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2]', ']][string aa"];',
|
|
||||||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2345]', ']][string aa"];',
|
|
||||||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2.3]', ']][string aa"];',
|
|
||||||
'[keyword echo] [string "][variable-2 $aaaa][[','[variable aaaaa]', ']][string aa"];',
|
|
||||||
'[keyword echo] [string "][variable-2 $aaaa][[','[variable-2 $aaaaa]',']][string aa"];',
|
|
||||||
|
|
||||||
'[keyword echo] [string "1aaa][variable-2 $aaaa][[','[number 2]', ']][string aa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[number 2345]', ']][string aa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[number 2.3]', ']][string aa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[variable aaaaa]', ']][string aa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[variable-2 $aaaaa]',']][string aa"];',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
MT('variable_interpolation_simple_syntax_3',
|
|
||||||
'[meta <?php]',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string .aaaaaa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaaa][string ->][variable-2 $aaaaa][string .aaaaaa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string [[2]].aaaaaa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string ->aaaa2.aaaaaa"];',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
MT('variable_interpolation_escaping',
|
|
||||||
'[meta <?php] [comment /* Escaping */]',
|
|
||||||
'[keyword echo] [string "aaa\\$aaaa->aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa\\$aaaa[[2]]aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa\\$aaaa[[asd]]aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa{\\$aaaa->aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa{\\$aaaa[[2]]aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa{\\aaaaa[[asd]]aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa\\${aaaa->aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa\\${aaaa[[2]]aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa\\${aaaa[[asd]]aaa.aaa"];',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
MT('variable_interpolation_complex_syntax_1',
|
|
||||||
'[meta <?php]',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $]{[variable aaaa]}[string ->aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $]{[variable-2 $aaaa]}[string ->aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $]{[variable-2 $aaaa][[',' [number 42]',']]}[string ->aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "aaa][variable-2 $]{[variable aaaa][meta ?>]aaaaaa');
|
|
||||||
|
|
||||||
MT('variable_interpolation_complex_syntax_2',
|
|
||||||
'[meta <?php] [comment /* Monsters */]',
|
|
||||||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*}?>} $aaa<?php } */]}[string ->aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*}?>*/][[',' [string "aaa][variable-2 $aaa][string {}][variable-2 $]{[variable aaa]}[string "]',']]}[string ->aaa.aaa"];',
|
|
||||||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*} } $aaa } */]}[string ->aaa.aaa"];');
|
|
||||||
|
|
||||||
|
|
||||||
function build_recursive_monsters(nt, t, n){
|
|
||||||
var monsters = [t];
|
|
||||||
for (var i = 1; i <= n; ++i)
|
|
||||||
monsters[i] = nt.join(monsters[i - 1]);
|
|
||||||
return monsters;
|
|
||||||
}
|
|
||||||
|
|
||||||
var m1 = build_recursive_monsters(
|
|
||||||
['[string "][variable-2 $]{[variable aaa] [operator +] ', '}[string "]'],
|
|
||||||
'[comment /* }?>} */] [string "aaa][variable-2 $aaa][string .aaa"]',
|
|
||||||
10
|
|
||||||
);
|
|
||||||
|
|
||||||
MT('variable_interpolation_complex_syntax_3_1',
|
|
||||||
'[meta <?php] [comment /* Recursive monsters */]',
|
|
||||||
'[keyword echo] ' + m1[4] + ';',
|
|
||||||
'[keyword echo] ' + m1[7] + ';',
|
|
||||||
'[keyword echo] ' + m1[8] + ';',
|
|
||||||
'[keyword echo] ' + m1[5] + ';',
|
|
||||||
'[keyword echo] ' + m1[1] + ';',
|
|
||||||
'[keyword echo] ' + m1[6] + ';',
|
|
||||||
'[keyword echo] ' + m1[9] + ';',
|
|
||||||
'[keyword echo] ' + m1[0] + ';',
|
|
||||||
'[keyword echo] ' + m1[10] + ';',
|
|
||||||
'[keyword echo] ' + m1[2] + ';',
|
|
||||||
'[keyword echo] ' + m1[3] + ';',
|
|
||||||
'[keyword echo] [string "end"];',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
var m2 = build_recursive_monsters(
|
|
||||||
['[string "a][variable-2 $]{[variable aaa] [operator +] ', ' [operator +] ', '}[string .a"]'],
|
|
||||||
'[comment /* }?>{{ */] [string "a?>}{{aa][variable-2 $aaa][string .a}a?>a"]',
|
|
||||||
5
|
|
||||||
);
|
|
||||||
|
|
||||||
MT('variable_interpolation_complex_syntax_3_2',
|
|
||||||
'[meta <?php] [comment /* Recursive monsters 2 */]',
|
|
||||||
'[keyword echo] ' + m2[0] + ';',
|
|
||||||
'[keyword echo] ' + m2[1] + ';',
|
|
||||||
'[keyword echo] ' + m2[5] + ';',
|
|
||||||
'[keyword echo] ' + m2[4] + ';',
|
|
||||||
'[keyword echo] ' + m2[2] + ';',
|
|
||||||
'[keyword echo] ' + m2[3] + ';',
|
|
||||||
'[keyword echo] [string "end"];',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
function build_recursive_monsters_2(mf1, mf2, nt, t, n){
|
|
||||||
var monsters = [t];
|
|
||||||
for (var i = 1; i <= n; ++i)
|
|
||||||
monsters[i] = nt[0] + mf1[i - 1] + nt[1] + mf2[i - 1] + nt[2] + monsters[i - 1] + nt[3];
|
|
||||||
return monsters;
|
|
||||||
}
|
|
||||||
|
|
||||||
var m3 = build_recursive_monsters_2(
|
|
||||||
m1,
|
|
||||||
m2,
|
|
||||||
['[string "a][variable-2 $]{[variable aaa] [operator +] ', ' [operator +] ', ' [operator +] ', '}[string .a"]'],
|
|
||||||
'[comment /* }?>{{ */] [string "a?>}{{aa][variable-2 $aaa][string .a}a?>a"]',
|
|
||||||
4
|
|
||||||
);
|
|
||||||
|
|
||||||
MT('variable_interpolation_complex_syntax_3_3',
|
|
||||||
'[meta <?php] [comment /* Recursive monsters 2 */]',
|
|
||||||
'[keyword echo] ' + m3[4] + ';',
|
|
||||||
'[keyword echo] ' + m3[0] + ';',
|
|
||||||
'[keyword echo] ' + m3[3] + ';',
|
|
||||||
'[keyword echo] ' + m3[1] + ';',
|
|
||||||
'[keyword echo] ' + m3[2] + ';',
|
|
||||||
'[keyword echo] [string "end"];',
|
|
||||||
'[meta ?>]');
|
|
||||||
|
|
||||||
MT("variable_interpolation_heredoc",
|
|
||||||
"[meta <?php]",
|
|
||||||
"[string <<<here]",
|
|
||||||
"[string doc ][variable-2 $]{[variable yay]}[string more]",
|
|
||||||
"[string here]; [comment // normal]");
|
|
||||||
})();
|
|
384
core/vendor/tinymce/plugins/codemirror/codemirror/mode/xml/xml.js
vendored
Normal file
384
core/vendor/tinymce/plugins/codemirror/codemirror/mode/xml/xml.js
vendored
Normal file
@ -0,0 +1,384 @@
|
|||||||
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
|
(function(mod) {
|
||||||
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
|
mod(require("../../lib/codemirror"));
|
||||||
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
|
define(["../../lib/codemirror"], mod);
|
||||||
|
else // Plain browser env
|
||||||
|
mod(CodeMirror);
|
||||||
|
})(function(CodeMirror) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||||
|
var indentUnit = config.indentUnit;
|
||||||
|
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
|
||||||
|
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
|
||||||
|
if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
|
||||||
|
|
||||||
|
var Kludges = parserConfig.htmlMode ? {
|
||||||
|
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||||
|
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||||
|
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||||
|
'track': true, 'wbr': true, 'menuitem': true},
|
||||||
|
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
||||||
|
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
||||||
|
'th': true, 'tr': true},
|
||||||
|
contextGrabbers: {
|
||||||
|
'dd': {'dd': true, 'dt': true},
|
||||||
|
'dt': {'dd': true, 'dt': true},
|
||||||
|
'li': {'li': true},
|
||||||
|
'option': {'option': true, 'optgroup': true},
|
||||||
|
'optgroup': {'optgroup': true},
|
||||||
|
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
||||||
|
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
||||||
|
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
||||||
|
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
||||||
|
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
||||||
|
'rp': {'rp': true, 'rt': true},
|
||||||
|
'rt': {'rp': true, 'rt': true},
|
||||||
|
'tbody': {'tbody': true, 'tfoot': true},
|
||||||
|
'td': {'td': true, 'th': true},
|
||||||
|
'tfoot': {'tbody': true},
|
||||||
|
'th': {'td': true, 'th': true},
|
||||||
|
'thead': {'tbody': true, 'tfoot': true},
|
||||||
|
'tr': {'tr': true}
|
||||||
|
},
|
||||||
|
doNotIndent: {"pre": true},
|
||||||
|
allowUnquoted: true,
|
||||||
|
allowMissing: true,
|
||||||
|
caseFold: true
|
||||||
|
} : {
|
||||||
|
autoSelfClosers: {},
|
||||||
|
implicitlyClosed: {},
|
||||||
|
contextGrabbers: {},
|
||||||
|
doNotIndent: {},
|
||||||
|
allowUnquoted: false,
|
||||||
|
allowMissing: false,
|
||||||
|
caseFold: false
|
||||||
|
};
|
||||||
|
var alignCDATA = parserConfig.alignCDATA;
|
||||||
|
|
||||||
|
// Return variables for tokenizers
|
||||||
|
var type, setStyle;
|
||||||
|
|
||||||
|
function inText(stream, state) {
|
||||||
|
function chain(parser) {
|
||||||
|
state.tokenize = parser;
|
||||||
|
return parser(stream, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
var ch = stream.next();
|
||||||
|
if (ch == "<") {
|
||||||
|
if (stream.eat("!")) {
|
||||||
|
if (stream.eat("[")) {
|
||||||
|
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
||||||
|
else return null;
|
||||||
|
} else if (stream.match("--")) {
|
||||||
|
return chain(inBlock("comment", "-->"));
|
||||||
|
} else if (stream.match("DOCTYPE", true, true)) {
|
||||||
|
stream.eatWhile(/[\w\._\-]/);
|
||||||
|
return chain(doctype(1));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (stream.eat("?")) {
|
||||||
|
stream.eatWhile(/[\w\._\-]/);
|
||||||
|
state.tokenize = inBlock("meta", "?>");
|
||||||
|
return "meta";
|
||||||
|
} else {
|
||||||
|
type = stream.eat("/") ? "closeTag" : "openTag";
|
||||||
|
state.tokenize = inTag;
|
||||||
|
return "tag bracket";
|
||||||
|
}
|
||||||
|
} else if (ch == "&") {
|
||||||
|
var ok;
|
||||||
|
if (stream.eat("#")) {
|
||||||
|
if (stream.eat("x")) {
|
||||||
|
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||||
|
} else {
|
||||||
|
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
||||||
|
}
|
||||||
|
return ok ? "atom" : "error";
|
||||||
|
} else {
|
||||||
|
stream.eatWhile(/[^&<]/);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function inTag(stream, state) {
|
||||||
|
var ch = stream.next();
|
||||||
|
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
||||||
|
state.tokenize = inText;
|
||||||
|
type = ch == ">" ? "endTag" : "selfcloseTag";
|
||||||
|
return "tag bracket";
|
||||||
|
} else if (ch == "=") {
|
||||||
|
type = "equals";
|
||||||
|
return null;
|
||||||
|
} else if (ch == "<") {
|
||||||
|
state.tokenize = inText;
|
||||||
|
state.state = baseState;
|
||||||
|
state.tagName = state.tagStart = null;
|
||||||
|
var next = state.tokenize(stream, state);
|
||||||
|
return next ? next + " tag error" : "tag error";
|
||||||
|
} else if (/[\'\"]/.test(ch)) {
|
||||||
|
state.tokenize = inAttribute(ch);
|
||||||
|
state.stringStartCol = stream.column();
|
||||||
|
return state.tokenize(stream, state);
|
||||||
|
} else {
|
||||||
|
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
|
||||||
|
return "word";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function inAttribute(quote) {
|
||||||
|
var closure = function(stream, state) {
|
||||||
|
while (!stream.eol()) {
|
||||||
|
if (stream.next() == quote) {
|
||||||
|
state.tokenize = inTag;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "string";
|
||||||
|
};
|
||||||
|
closure.isInAttribute = true;
|
||||||
|
return closure;
|
||||||
|
}
|
||||||
|
|
||||||
|
function inBlock(style, terminator) {
|
||||||
|
return function(stream, state) {
|
||||||
|
while (!stream.eol()) {
|
||||||
|
if (stream.match(terminator)) {
|
||||||
|
state.tokenize = inText;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
stream.next();
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function doctype(depth) {
|
||||||
|
return function(stream, state) {
|
||||||
|
var ch;
|
||||||
|
while ((ch = stream.next()) != null) {
|
||||||
|
if (ch == "<") {
|
||||||
|
state.tokenize = doctype(depth + 1);
|
||||||
|
return state.tokenize(stream, state);
|
||||||
|
} else if (ch == ">") {
|
||||||
|
if (depth == 1) {
|
||||||
|
state.tokenize = inText;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
state.tokenize = doctype(depth - 1);
|
||||||
|
return state.tokenize(stream, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "meta";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function Context(state, tagName, startOfLine) {
|
||||||
|
this.prev = state.context;
|
||||||
|
this.tagName = tagName;
|
||||||
|
this.indent = state.indented;
|
||||||
|
this.startOfLine = startOfLine;
|
||||||
|
if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
||||||
|
this.noIndent = true;
|
||||||
|
}
|
||||||
|
function popContext(state) {
|
||||||
|
if (state.context) state.context = state.context.prev;
|
||||||
|
}
|
||||||
|
function maybePopContext(state, nextTagName) {
|
||||||
|
var parentTagName;
|
||||||
|
while (true) {
|
||||||
|
if (!state.context) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parentTagName = state.context.tagName;
|
||||||
|
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||||
|
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
popContext(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function baseState(type, stream, state) {
|
||||||
|
if (type == "openTag") {
|
||||||
|
state.tagStart = stream.column();
|
||||||
|
return tagNameState;
|
||||||
|
} else if (type == "closeTag") {
|
||||||
|
return closeTagNameState;
|
||||||
|
} else {
|
||||||
|
return baseState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function tagNameState(type, stream, state) {
|
||||||
|
if (type == "word") {
|
||||||
|
state.tagName = stream.current();
|
||||||
|
setStyle = "tag";
|
||||||
|
return attrState;
|
||||||
|
} else {
|
||||||
|
setStyle = "error";
|
||||||
|
return tagNameState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function closeTagNameState(type, stream, state) {
|
||||||
|
if (type == "word") {
|
||||||
|
var tagName = stream.current();
|
||||||
|
if (state.context && state.context.tagName != tagName &&
|
||||||
|
Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
||||||
|
popContext(state);
|
||||||
|
if (state.context && state.context.tagName == tagName) {
|
||||||
|
setStyle = "tag";
|
||||||
|
return closeState;
|
||||||
|
} else {
|
||||||
|
setStyle = "tag error";
|
||||||
|
return closeStateErr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setStyle = "error";
|
||||||
|
return closeStateErr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeState(type, _stream, state) {
|
||||||
|
if (type != "endTag") {
|
||||||
|
setStyle = "error";
|
||||||
|
return closeState;
|
||||||
|
}
|
||||||
|
popContext(state);
|
||||||
|
return baseState;
|
||||||
|
}
|
||||||
|
function closeStateErr(type, stream, state) {
|
||||||
|
setStyle = "error";
|
||||||
|
return closeState(type, stream, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
function attrState(type, _stream, state) {
|
||||||
|
if (type == "word") {
|
||||||
|
setStyle = "attribute";
|
||||||
|
return attrEqState;
|
||||||
|
} else if (type == "endTag" || type == "selfcloseTag") {
|
||||||
|
var tagName = state.tagName, tagStart = state.tagStart;
|
||||||
|
state.tagName = state.tagStart = null;
|
||||||
|
if (type == "selfcloseTag" ||
|
||||||
|
Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
|
||||||
|
maybePopContext(state, tagName);
|
||||||
|
} else {
|
||||||
|
maybePopContext(state, tagName);
|
||||||
|
state.context = new Context(state, tagName, tagStart == state.indented);
|
||||||
|
}
|
||||||
|
return baseState;
|
||||||
|
}
|
||||||
|
setStyle = "error";
|
||||||
|
return attrState;
|
||||||
|
}
|
||||||
|
function attrEqState(type, stream, state) {
|
||||||
|
if (type == "equals") return attrValueState;
|
||||||
|
if (!Kludges.allowMissing) setStyle = "error";
|
||||||
|
return attrState(type, stream, state);
|
||||||
|
}
|
||||||
|
function attrValueState(type, stream, state) {
|
||||||
|
if (type == "string") return attrContinuedState;
|
||||||
|
if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;}
|
||||||
|
setStyle = "error";
|
||||||
|
return attrState(type, stream, state);
|
||||||
|
}
|
||||||
|
function attrContinuedState(type, stream, state) {
|
||||||
|
if (type == "string") return attrContinuedState;
|
||||||
|
return attrState(type, stream, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
startState: function() {
|
||||||
|
return {tokenize: inText,
|
||||||
|
state: baseState,
|
||||||
|
indented: 0,
|
||||||
|
tagName: null, tagStart: null,
|
||||||
|
context: null};
|
||||||
|
},
|
||||||
|
|
||||||
|
token: function(stream, state) {
|
||||||
|
if (!state.tagName && stream.sol())
|
||||||
|
state.indented = stream.indentation();
|
||||||
|
|
||||||
|
if (stream.eatSpace()) return null;
|
||||||
|
type = null;
|
||||||
|
var style = state.tokenize(stream, state);
|
||||||
|
if ((style || type) && style != "comment") {
|
||||||
|
setStyle = null;
|
||||||
|
state.state = state.state(type || style, stream, state);
|
||||||
|
if (setStyle)
|
||||||
|
style = setStyle == "error" ? style + " error" : setStyle;
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
},
|
||||||
|
|
||||||
|
indent: function(state, textAfter, fullLine) {
|
||||||
|
var context = state.context;
|
||||||
|
// Indent multi-line strings (e.g. css).
|
||||||
|
if (state.tokenize.isInAttribute) {
|
||||||
|
if (state.tagStart == state.indented)
|
||||||
|
return state.stringStartCol + 1;
|
||||||
|
else
|
||||||
|
return state.indented + indentUnit;
|
||||||
|
}
|
||||||
|
if (context && context.noIndent) return CodeMirror.Pass;
|
||||||
|
if (state.tokenize != inTag && state.tokenize != inText)
|
||||||
|
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||||
|
// Indent the starts of attribute names.
|
||||||
|
if (state.tagName) {
|
||||||
|
if (multilineTagIndentPastTag)
|
||||||
|
return state.tagStart + state.tagName.length + 2;
|
||||||
|
else
|
||||||
|
return state.tagStart + indentUnit * multilineTagIndentFactor;
|
||||||
|
}
|
||||||
|
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||||
|
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
||||||
|
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
||||||
|
while (context) {
|
||||||
|
if (context.tagName == tagAfter[2]) {
|
||||||
|
context = context.prev;
|
||||||
|
break;
|
||||||
|
} else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
||||||
|
context = context.prev;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (tagAfter) { // Opening tag spotted
|
||||||
|
while (context) {
|
||||||
|
var grabbers = Kludges.contextGrabbers[context.tagName];
|
||||||
|
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
||||||
|
context = context.prev;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (context && !context.startOfLine)
|
||||||
|
context = context.prev;
|
||||||
|
if (context) return context.indent + indentUnit;
|
||||||
|
else return 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
electricInput: /<\/[\s\w:]+>$/,
|
||||||
|
blockCommentStart: "<!--",
|
||||||
|
blockCommentEnd: "-->",
|
||||||
|
|
||||||
|
configuration: parserConfig.htmlMode ? "html" : "xml",
|
||||||
|
helperType: parserConfig.htmlMode ? "html" : "xml"
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.defineMIME("text/xml", "xml");
|
||||||
|
CodeMirror.defineMIME("application/xml", "xml");
|
||||||
|
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||||
|
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||||
|
|
||||||
|
});
|
@ -3,6 +3,6 @@ tinymce.addI18n('fr_FR',{
|
|||||||
'Start search': 'Rechercher',
|
'Start search': 'Rechercher',
|
||||||
'Find next': 'Chercher suiv.',
|
'Find next': 'Chercher suiv.',
|
||||||
'Find previous': 'Chercher préc.',
|
'Find previous': 'Chercher préc.',
|
||||||
'Replace': 'Remplacer',
|
'Replace': 'Replace',
|
||||||
'Replace all': 'Tout remplacer'
|
'Replace all': 'Replace all'
|
||||||
});
|
});
|
||||||
|
107
core/vendor/tinymce/plugins/codemirror/plugin.js
vendored
107
core/vendor/tinymce/plugins/codemirror/plugin.js
vendored
@ -5,65 +5,99 @@
|
|||||||
* @author Arjan Haverkamp
|
* @author Arjan Haverkamp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jshint unused:false */
|
/* jshint unused:false */
|
||||||
/*global tinymce:true */
|
/* global tinymce:true */
|
||||||
|
|
||||||
tinymce.PluginManager.requireLangPack('codemirror');
|
tinymce.PluginManager.requireLangPack('codemirror')
|
||||||
|
|
||||||
tinymce.PluginManager.add('codemirror', function(editor, url) {
|
tinymce.PluginManager.add('codemirror', function(editor, url) {
|
||||||
|
|
||||||
function showSourceEditor() {
|
function showSourceEditor() {
|
||||||
|
editor.focus()
|
||||||
editor.focus();
|
editor.selection.collapse(true)
|
||||||
editor.selection.collapse(true);
|
|
||||||
|
|
||||||
// Insert caret marker
|
// Insert caret marker
|
||||||
if (editor.settings.codemirror.saveCursorPosition) {
|
if (editor.settings.codemirror.saveCursorPosition) {
|
||||||
editor.selection.setContent('<span style="display: none;" class="CmCaReT">�</span>');
|
editor.selection.setContent('<span style="display: none;" class="CmCaReT">�</span>')
|
||||||
}
|
}
|
||||||
|
|
||||||
codemirrorWidth = 800;
|
var codemirrorWidth = 800
|
||||||
if (editor.settings.codemirror.width) {
|
if (editor.settings.codemirror.width) {
|
||||||
codemirrorWidth = editor.settings.codemirror.width;
|
codemirrorWidth = editor.settings.codemirror.width
|
||||||
}
|
}
|
||||||
|
|
||||||
codemirrorHeight = 550;
|
var codemirrorHeight = 550
|
||||||
if (editor.settings.codemirror.width) {
|
if (editor.settings.codemirror.width) {
|
||||||
codemirrorHeight = editor.settings.codemirror.height;
|
codemirrorHeight = editor.settings.codemirror.height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var buttonsConfig = (tinymce.majorVersion < 5)
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
text: 'Ok',
|
||||||
|
subtype: 'primary',
|
||||||
|
onclick: function() {
|
||||||
|
var doc = document.querySelectorAll('.mce-container-body>iframe')[0]
|
||||||
|
doc.contentWindow.submit()
|
||||||
|
win.close()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Cancel',
|
||||||
|
onclick: 'close'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
type: 'custom',
|
||||||
|
text: 'Ok',
|
||||||
|
name: 'codemirrorOk',
|
||||||
|
primary: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'cancel',
|
||||||
|
text: 'Cancel',
|
||||||
|
name: 'codemirrorCancel'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
title: 'HTML source code',
|
title: 'HTML source code',
|
||||||
url: url + '/source.html',
|
url: url + '/source.html',
|
||||||
width: codemirrorWidth,
|
width: codemirrorWidth,
|
||||||
height: codemirrorHeight,
|
height: codemirrorHeight,
|
||||||
resizable : true,
|
resizable: true,
|
||||||
maximizable : true,
|
maximizable: true,
|
||||||
fullScreen: editor.settings.codemirror.fullscreen,
|
fullScreen: editor.settings.codemirror.fullscreen,
|
||||||
saveCursorPosition: false,
|
saveCursorPosition: false,
|
||||||
buttons: [
|
buttons: buttonsConfig
|
||||||
{ text: 'Ok', subtype: 'primary', onclick: function(){
|
}
|
||||||
var doc = document.querySelectorAll('.mce-container-body>iframe')[0];
|
|
||||||
doc.contentWindow.submit();
|
|
||||||
win.close();
|
|
||||||
}},
|
|
||||||
{ text: 'Cancel', onclick: 'close' }
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
var win = editor.windowManager.open(config);
|
if (tinymce.majorVersion >= 5) {
|
||||||
|
config.onAction = function (dialogApi, actionData) {
|
||||||
|
if (actionData.name === 'codemirrorOk') {
|
||||||
|
var doc = document.querySelectorAll('.tox-dialog__body-iframe iframe')[0]
|
||||||
|
doc.contentWindow.submit()
|
||||||
|
win.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var win = (tinymce.majorVersion < 5)
|
||||||
|
? editor.windowManager.open(config)
|
||||||
|
: editor.windowManager.openUrl(config)
|
||||||
|
|
||||||
if (editor.settings.codemirror.fullscreen) {
|
if (editor.settings.codemirror.fullscreen) {
|
||||||
win.fullscreen(true);
|
win.fullscreen(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
if (tinymce.majorVersion < 5) {
|
||||||
// Add a button to the button bar
|
// Add a button to the button bar
|
||||||
editor.addButton('code', {
|
editor.addButton('code', {
|
||||||
title: 'Source code',
|
title: 'Source code',
|
||||||
icon: 'code',
|
icon: 'code',
|
||||||
onclick: showSourceEditor
|
onclick: showSourceEditor
|
||||||
});
|
})
|
||||||
|
|
||||||
// Add a menu item to the tools menu
|
// Add a menu item to the tools menu
|
||||||
editor.addMenuItem('code', {
|
editor.addMenuItem('code', {
|
||||||
@ -71,5 +105,20 @@ tinymce.PluginManager.add('codemirror', function(editor, url) {
|
|||||||
text: 'Source code',
|
text: 'Source code',
|
||||||
context: 'tools',
|
context: 'tools',
|
||||||
onclick: showSourceEditor
|
onclick: showSourceEditor
|
||||||
});
|
})
|
||||||
});
|
} else {
|
||||||
|
editor.ui.registry.addButton('code', {
|
||||||
|
icon: 'sourcecode',
|
||||||
|
title: 'Source code',
|
||||||
|
tooltip: 'Source code',
|
||||||
|
onAction: showSourceEditor
|
||||||
|
})
|
||||||
|
|
||||||
|
editor.ui.registry.addMenuItem('code', {
|
||||||
|
icon: 'sourcecode',
|
||||||
|
text: 'Source code',
|
||||||
|
onAction: showSourceEditor,
|
||||||
|
context: 'tools'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
@ -1 +1 @@
|
|||||||
tinymce.PluginManager.requireLangPack("codemirror");tinymce.PluginManager.add("codemirror",function(e,r){function o(){e.focus();e.selection.collapse(true);if(e.settings.codemirror.saveCursorPosition){e.selection.setContent('<span style="display: none;" class="CmCaReT">�</span>')}codemirrorWidth=800;if(e.settings.codemirror.width){codemirrorWidth=e.settings.codemirror.width}codemirrorHeight=550;if(e.settings.codemirror.width){codemirrorHeight=e.settings.codemirror.height}var o={title:"HTML source code",url:r+"/source.html",width:codemirrorWidth,height:codemirrorHeight,resizable:true,maximizable:true,fullScreen:e.settings.codemirror.fullscreen,buttons:[{text:"Ok",subtype:"primary",onclick:function(){var e=document.querySelectorAll(".mce-container-body>iframe")[0];e.contentWindow.submit();i.close()}},{text:"Cancel",onclick:"close"}]};var i=e.windowManager.open(o);if(e.settings.codemirror.fullscreen){i.fullscreen(true)}}e.addButton("code",{title:"Source code",icon:"code",onclick:o});e.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:o})});
|
tinymce.PluginManager.requireLangPack("codemirror");tinymce.PluginManager.add("codemirror",function(e,o){function t(){e.focus();e.selection.collapse(true);if(e.settings.codemirror.saveCursorPosition){e.selection.setContent('<span style="display: none;" class="CmCaReT">�</span>')}var t=800;if(e.settings.codemirror.width){t=e.settings.codemirror.width}var r=550;if(e.settings.codemirror.width){r=e.settings.codemirror.height}var i=tinymce.majorVersion<5?[{text:"Ok",subtype:"primary",onclick:function(){var e=document.querySelectorAll(".mce-container-body>iframe")[0];e.contentWindow.submit();n.close()}},{text:"Cancel",onclick:"close"}]:[{type:"custom",text:"Ok",name:"codemirrorOk",primary:true},{type:"cancel",text:"Cancel",name:"codemirrorCancel"}];var c={title:"HTML source code",url:o+"/source.html",width:t,height:r,resizable:true,maximizable:true,fullScreen:e.settings.codemirror.fullscreen,saveCursorPosition:false,buttons:i};if(tinymce.majorVersion>=5){c.onAction=function(e,o){if(o.name==="codemirrorOk"){var t=document.querySelectorAll(".tox-dialog__body-iframe iframe")[0];t.contentWindow.submit();n.close()}}}var n=tinymce.majorVersion<5?e.windowManager.open(c):e.windowManager.openUrl(c);if(e.settings.codemirror.fullscreen){n.fullscreen(true)}}if(tinymce.majorVersion<5){e.addButton("code",{title:"Source code",icon:"code",onclick:t});e.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:t})}else{e.ui.registry.addButton("code",{icon:"sourcecode",title:"Source code",tooltip:"Source code",onAction:t});e.ui.registry.addMenuItem("code",{icon:"sourcecode",text:"Source code",onAction:t,context:"tools"})}});
|
@ -1,7 +1,8 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script>
|
<meta charset="UTF-8">
|
||||||
|
<script>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* source.html
|
* source.html
|
||||||
@ -35,6 +36,7 @@ function inArray(key, arr)
|
|||||||
CMsettings = {
|
CMsettings = {
|
||||||
path: userSettings.path || 'codemirror-4.8',
|
path: userSettings.path || 'codemirror-4.8',
|
||||||
indentOnInit: userSettings.indentOnInit || false,
|
indentOnInit: userSettings.indentOnInit || false,
|
||||||
|
disableFilesMerge: userSettings.disableFilesMerge || false,
|
||||||
config: {// Default config
|
config: {// Default config
|
||||||
mode: 'htmlmixed',
|
mode: 'htmlmixed',
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
@ -70,11 +72,29 @@ function inArray(key, arr)
|
|||||||
CMsettings.cssFiles.push('addon/display/fullscreen.css');
|
CMsettings.cssFiles.push('addon/display/fullscreen.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CMsettings.disableFilesMerge) {
|
||||||
|
if (
|
||||||
|
Array.isArray(userSettings.jsFiles) &&
|
||||||
|
Array.isArray(userSettings.cssFiles) &&
|
||||||
|
(userSettings.jsFiles.length > 0) &&
|
||||||
|
(userSettings.cssFiles.length > 0)
|
||||||
|
) {
|
||||||
|
CMsettings.jsFiles = []
|
||||||
|
CMsettings.cssFiles = []
|
||||||
|
} else {
|
||||||
|
if (console) {
|
||||||
|
console.error('Codemirror plugin: jsFiles and cssFiles must be specified if disableFilesMerge is set to true')
|
||||||
|
console.warn('Codemirror plugin: ignoring disableFilesMerge')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Merge config
|
// Merge config
|
||||||
for (i in userSettings.config) {
|
for (i in userSettings.config) {
|
||||||
CMsettings.config[i] = userSettings.config[i];
|
CMsettings.config[i] = userSettings.config[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Merge jsFiles
|
// Merge jsFiles
|
||||||
for (i in userSettings.jsFiles) {
|
for (i in userSettings.jsFiles) {
|
||||||
if (!inArray(userSettings.jsFiles[i], CMsettings.jsFiles)) {
|
if (!inArray(userSettings.jsFiles[i], CMsettings.jsFiles)) {
|
||||||
@ -124,7 +144,7 @@ function start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create legend for keyboard shortcuts for find & replace:
|
// Create legend for keyboard shortcuts for find & replace:
|
||||||
var head = parent.document.querySelectorAll('.mce-foot')[0],
|
var head = parent.document.querySelectorAll((tinymce.majorVersion < 5) ? '.mce-foot': '.tox-dialog__footer')[0],
|
||||||
div = parent.document.createElement('div'),
|
div = parent.document.createElement('div'),
|
||||||
td1 = '<td style="font-size:11px;background:#777;color:#fff;padding:0 4px">',
|
td1 = '<td style="font-size:11px;background:#777;color:#fff;padding:0 4px">',
|
||||||
td2 = '<td style="font-size:11px;padding-right:5px">';
|
td2 = '<td style="font-size:11px;padding-right:5px">';
|
||||||
@ -244,7 +264,7 @@ function submit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
html,body { height:100%; }
|
html,body { height:100%; }
|
||||||
body {
|
body {
|
||||||
@ -267,6 +287,7 @@ body {
|
|||||||
background-repeat: repeat-x;
|
background-repeat: repeat-x;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body></body>
|
<body>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
21
index.php
21
index.php
@ -21,6 +21,27 @@ if(version_compare(PHP_VERSION, '5.6.0', '<')) {
|
|||||||
exit('PHP 5.6+ required.');
|
exit('PHP 5.6+ required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Configuration Proxy */
|
||||||
|
$proxy = 'cache-etu.univ-artois.fr:3128';
|
||||||
|
if (!empty($proxy)) {
|
||||||
|
$proxy = str_replace('http://', 'tcp://', $proxy);
|
||||||
|
$context = array(
|
||||||
|
'http' => array(
|
||||||
|
'proxy' => $proxy,
|
||||||
|
'request_fulluri' => true,
|
||||||
|
'verify_peer' => false,
|
||||||
|
'verify_peer_name' => false,
|
||||||
|
),
|
||||||
|
"ssl"=>array(
|
||||||
|
"verify_peer"=>false,
|
||||||
|
"verify_peer_name"=>false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
stream_context_set_default($context);
|
||||||
|
} else {
|
||||||
|
echo "Proxy not found" . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set locale to French */
|
/* Set locale to French */
|
||||||
date_default_timezone_set('Europe/Paris');
|
date_default_timezone_set('Europe/Paris');
|
||||||
setlocale (LC_TIME, 'fra_FRA', 'french');
|
setlocale (LC_TIME, 'fra_FRA', 'french');
|
||||||
|
Loading…
Reference in New Issue
Block a user