From 91eb30d2ea54c136de2540cacaeb95b9ab5de8e0 Mon Sep 17 00:00:00 2001 From: Fernandez Anthony Date: Thu, 1 Apr 2021 22:32:17 +0200 Subject: [PATCH] Refactored code mirror integration, better find and replace, add keyboard shortcuts --- README.md | 13 +- Sources/CodeMirror-SwiftUI/Model/Mode.swift | 25 +- .../CodeMirrorView.bundle/Contents/Info.plist | Bin 211 -> 211 bytes .../Resources/addons/comment/comment.js | 219 +- .../addons/comment/continuecomment.js | 122 +- .../Contents/Resources/addons/dialog.css | 99 + .../Contents/Resources/addons/dialog.js | 140 + .../Resources/addons/dialog/dialog.css | 33 +- .../Resources/addons/dialog/dialog.js | 168 +- .../Resources/addons/display/autorefresh.js | 49 +- .../Resources/addons/display/fullscreen.css | 7 +- .../Resources/addons/display/fullscreen.js | 43 +- .../Resources/addons/display/panel.js | 138 +- .../Resources/addons/display/placeholder.js | 81 +- .../Resources/addons/display/rulers.js | 54 +- .../Resources/addons/edit/closebrackets.js | 208 +- .../Resources/addons/edit/closetag.js | 192 +- .../Resources/addons/edit/continuelist.js | 104 +- .../Resources/addons/edit/matchbrackets.js | 166 +- .../Resources/addons/edit/matchtags.js | 69 +- .../Resources/addons/edit/trailingspace.js | 28 +- .../Resources/addons/fold/brace-fold.js | 112 +- .../Resources/addons/fold/comment-fold.js | 61 +- .../Resources/addons/fold/foldcode.js | 162 +- .../Resources/addons/fold/foldgutter.css | 21 +- .../Resources/addons/fold/foldgutter.js | 172 +- .../Resources/addons/fold/indent-fold.js | 50 +- .../Resources/addons/fold/markdown-fold.js | 51 +- .../Resources/addons/fold/xml-fold.js | 191 +- .../Resources/addons/hint/anyword-hint.js | 43 +- .../Resources/addons/hint/css-hint.js | 2 +- .../Resources/addons/hint/html-hint.js | 366 +- .../Resources/addons/hint/javascript-hint.js | 168 +- .../Resources/addons/hint/show-hint.css | 37 +- .../Resources/addons/hint/show-hint.js | 527 +- .../Resources/addons/hint/sql-hint.js | 2 +- .../Resources/addons/hint/xml-hint.js | 137 +- .../addons/lint/coffeescript-lint.js | 49 +- .../Resources/addons/lint/css-lint.js | 42 +- .../Resources/addons/lint/html-lint.js | 61 +- .../Resources/addons/lint/javascript-lint.js | 71 +- .../Resources/addons/lint/json-lint.js | 42 +- .../Contents/Resources/addons/lint/lint.css | 72 +- .../Contents/Resources/addons/lint/lint.js | 268 +- .../Resources/addons/lint/yaml-lint.js | 42 +- .../Contents/Resources/addons/merge/merge.css | 120 +- .../Contents/Resources/addons/merge/merge.js | 1045 ++- .../Resources/addons/mode/loadmode.js | 69 +- .../Resources/addons/mode/multiplex.js | 136 +- .../Resources/addons/mode/multiplex_test.js | 34 +- .../Contents/Resources/addons/mode/overlay.js | 93 +- .../Contents/Resources/addons/mode/simple.js | 224 +- .../Resources/addons/runmode/colorize.js | 42 +- .../addons/runmode/runmode-standalone.js | 341 +- .../Resources/addons/runmode/runmode.js | 79 +- .../Resources/addons/runmode/runmode.node.js | 340 +- .../addons/scroll/annotatescrollbar.js | 134 +- .../Resources/addons/scroll/scrollpastend.js | 50 +- .../addons/scroll/simplescrollbars.css | 67 +- .../addons/scroll/simplescrollbars.js | 158 +- .../Contents/Resources/addons/search.js | 525 ++ .../Resources/addons/search/jump-to-line.js | 56 +- .../addons/search/match-highlighter.js | 173 +- .../addons/search/matchesonscrollbar.css | 9 +- .../addons/search/matchesonscrollbar.js | 102 +- .../Resources/addons/search/search.js | 278 +- .../Resources/addons/search/searchcursor.js | 310 +- .../Resources/addons/selection/active-line.js | 75 +- .../addons/selection/mark-selection.js | 126 +- .../addons/selection/selection-pointer.js | 102 +- .../Resources/addons/show-invisibles.js | 4 +- .../Contents/Resources/addons/tern/tern.css | 88 +- .../Contents/Resources/addons/tern/tern.js | 742 ++- .../Contents/Resources/addons/tern/worker.js | 46 +- .../Resources/addons/wrap/hardwrap.js | 165 +- .../Contents/Resources/index.html | 160 +- .../Contents/Resources/keymap/emacs.js | 429 ++ .../Contents/Resources/keymap/sublime.js | 714 ++ .../Contents/Resources/keymap/vim.js | 5754 +++++++++++++++++ .../Resources/{ => lib}/codemirror.css | 0 .../Resources/{ => lib}/codemirror.js | 0 .../Contents/Resources/modes/{ => apl}/apl.js | 2 +- .../Contents/Resources/modes/apl/index.html | 72 + .../modes/{ => asciiarmor}/asciiarmor.js | 2 +- .../Resources/modes/asciiarmor/index.html | 46 + .../Resources/modes/{ => asn.1}/asn.1.js | 4 +- .../Contents/Resources/modes/asn.1/index.html | 78 + .../modes/{ => asterisk}/asterisk.js | 30 +- .../Resources/modes/asterisk/index.html | 155 + .../modes/{ => brainfuck}/brainfuck.js | 2 +- .../Resources/modes/brainfuck/index.html | 85 + .../Resources/modes/{ => clike}/clike.js | 197 +- .../Contents/Resources/modes/clike/index.html | 380 ++ .../Contents/Resources/modes/clike/scala.html | 767 +++ .../Contents/Resources/modes/clike/test.js | 165 + .../Contents/Resources/modes/clojure.js | 306 - .../Resources/modes/clojure/clojure.js | 292 + .../Resources/modes/clojure/index.html | 95 + .../Contents/Resources/modes/clojure/test.js | 384 ++ .../Resources/modes/{ => cmake}/cmake.js | 2 +- .../Contents/Resources/modes/cmake/index.html | 129 + .../Resources/modes/{ => cobol}/cobol.js | 2 +- .../Contents/Resources/modes/cobol/index.html | 210 + .../modes/{ => coffeescript}/coffeescript.js | 2 +- .../Resources/modes/coffeescript/index.html | 740 +++ .../modes/{ => commonlisp}/commonlisp.js | 2 +- .../Resources/modes/commonlisp/index.html | 177 + .../Resources/modes/{ => crystal}/crystal.js | 2 +- .../Resources/modes/crystal/index.html | 116 + .../Contents/Resources/modes/{ => css}/css.js | 238 +- .../Contents/Resources/modes/css/gss.html | 104 + .../Contents/Resources/modes/css/gss_test.js | 17 + .../Contents/Resources/modes/css/index.html | 81 + .../Contents/Resources/modes/css/less.html | 152 + .../Contents/Resources/modes/css/less_test.js | 54 + .../Contents/Resources/modes/css/scss.html | 158 + .../Contents/Resources/modes/css/scss_test.js | 110 + .../Contents/Resources/modes/css/test.js | 217 + .../Resources/modes/{ => cypher}/cypher.js | 9 +- .../Resources/modes/cypher/index.html | 64 + .../Contents/Resources/modes/cypher/test.js | 37 + .../Contents/Resources/modes/{ => d}/d.js | 9 +- .../Contents/Resources/modes/d/index.html | 273 + .../Contents/Resources/modes/d/test.js | 11 + .../Resources/modes/{ => dart}/dart.js | 17 +- .../Contents/Resources/modes/dart/index.html | 71 + .../Resources/modes/{ => diff}/diff.js | 2 +- .../Contents/Resources/modes/diff/index.html | 117 + .../Resources/modes/{ => django}/django.js | 2 +- .../Resources/modes/django/index.html | 73 + .../modes/{ => dockerfile}/dockerfile.js | 4 +- .../Resources/modes/dockerfile/index.html | 73 + .../Resources/modes/dockerfile/test.js | 128 + .../Contents/Resources/modes/{ => dtd}/dtd.js | 6 +- .../Contents/Resources/modes/dtd/index.html | 89 + .../Resources/modes/{ => dylan}/dylan.js | 2 +- .../Contents/Resources/modes/dylan/index.html | 407 ++ .../Contents/Resources/modes/dylan/test.js | 88 + .../Resources/modes/{ => ebnf}/ebnf.js | 16 +- .../Contents/Resources/modes/ebnf/index.html | 102 + .../Contents/Resources/modes/{ => ecl}/ecl.js | 2 +- .../Contents/Resources/modes/ecl/index.html | 52 + .../Resources/modes/{ => eiffel}/eiffel.js | 2 +- .../Resources/modes/eiffel/index.html | 429 ++ .../Contents/Resources/modes/elm.js | 205 - .../Contents/Resources/modes/elm/elm.js | 243 + .../Contents/Resources/modes/elm/index.html | 61 + .../Resources/modes/{ => erlang}/erlang.js | 2 +- .../Resources/modes/erlang/index.html | 76 + .../Resources/modes/{ => factor}/factor.js | 6 +- .../Resources/modes/factor/index.html | 77 + .../Contents/Resources/modes/{ => fcl}/fcl.js | 2 +- .../Contents/Resources/modes/fcl/index.html | 108 + .../Resources/modes/{ => forth}/forth.js | 2 +- .../Contents/Resources/modes/forth/index.html | 75 + .../Resources/modes/{ => fortran}/fortran.js | 2 +- .../Resources/modes/fortran/index.html | 81 + .../Contents/Resources/modes/{ => gas}/gas.js | 6 +- .../Contents/Resources/modes/gas/index.html | 68 + .../Contents/Resources/modes/{ => gfm}/gfm.js | 2 +- .../Contents/Resources/modes/gfm/index.html | 136 + .../Contents/Resources/modes/gfm/test.js | 198 + .../Resources/modes/{ => gherkin}/gherkin.js | 2 +- .../Resources/modes/gherkin/index.html | 48 + .../Contents/Resources/modes/{ => go}/go.js | 2 +- .../Contents/Resources/modes/go/index.html | 85 + .../Resources/modes/{ => groovy}/groovy.js | 7 +- .../Resources/modes/groovy/index.html | 84 + .../Resources/modes/{ => haml}/haml.js | 4 +- .../Contents/Resources/modes/haml/index.html | 79 + .../Contents/Resources/modes/haml/test.js | 97 + .../modes/{ => handlebars}/handlebars.js | 10 +- .../Resources/modes/handlebars/index.html | 82 + .../haskell-literate.js | 2 +- .../modes/haskell-literate/index.html | 282 + .../Resources/modes/{ => haskell}/haskell.js | 2 +- .../Resources/modes/haskell/index.html | 73 + .../Resources/modes/{ => haxe}/haxe.js | 2 +- .../Contents/Resources/modes/haxe/index.html | 124 + .../modes/{ => htmlembedded}/htmlembedded.js | 2 +- .../Resources/modes/htmlembedded/index.html | 60 + .../modes/{ => htmlmixed}/htmlmixed.js | 9 +- .../Resources/modes/htmlmixed/index.html | 100 + .../Resources/modes/{ => http}/http.js | 2 +- .../Contents/Resources/modes/http/index.html | 45 + .../Contents/Resources/modes/{ => idl}/idl.js | 4 +- .../Contents/Resources/modes/idl/index.html | 65 + .../Contents/Resources/modes/index.html | 166 + .../Resources/modes/javascript/index.html | 114 + .../modes/{ => javascript}/javascript.js | 140 +- .../Resources/modes/javascript/json-ld.html | 72 + .../Resources/modes/javascript/test.js | 521 ++ .../modes/javascript/typescript.html | 62 + .../Resources/modes/jinja2/index.html | 54 + .../Resources/modes/{ => jinja2}/jinja2.js | 8 +- .../Contents/Resources/modes/jsx/index.html | 89 + .../Contents/Resources/modes/{ => jsx}/jsx.js | 6 +- .../Contents/Resources/modes/jsx/test.js | 91 + .../Contents/Resources/modes/julia/index.html | 196 + .../Resources/modes/{ => julia}/julia.js | 206 +- .../Resources/modes/livescript/index.html | 459 ++ .../modes/{ => livescript}/livescript.js | 2 +- .../Contents/Resources/modes/lua/index.html | 85 + .../Contents/Resources/modes/{ => lua}/lua.js | 2 +- .../Resources/modes/markdown/index.html | 418 ++ .../modes/{ => markdown}/markdown.js | 34 +- .../Contents/Resources/modes/markdown/test.js | 1319 ++++ .../Resources/modes/mathematica/index.html | 72 + .../modes/{ => mathematica}/mathematica.js | 2 +- .../Contents/Resources/modes/mbox/index.html | 44 + .../Resources/modes/{ => mbox}/mbox.js | 2 +- .../Contents/Resources/modes/meta.js | 221 + .../Contents/Resources/modes/mirc/index.html | 161 + .../Resources/modes/{ => mirc}/mirc.js | 2 +- .../Resources/modes/mllike/index.html | 198 + .../Resources/modes/{ => mllike}/mllike.js | 5 +- .../Resources/modes/modelica/index.html | 67 + .../modes/{ => modelica}/modelica.js | 8 +- .../Resources/modes/mscgen/index.html | 151 + .../Resources/modes/{ => mscgen}/mscgen.js | 16 +- .../Resources/modes/mscgen/mscgen_test.js | 84 + .../Resources/modes/mscgen/msgenny_test.js | 77 + .../Resources/modes/mscgen/xu_test.js | 87 + .../Contents/Resources/modes/mumps/index.html | 85 + .../Resources/modes/{ => mumps}/mumps.js | 4 +- .../Contents/Resources/modes/nginx/index.html | 181 + .../Resources/modes/{ => nginx}/nginx.js | 2 +- .../Contents/Resources/modes/nsis/index.html | 80 + .../Resources/modes/{ => nsis}/nsis.js | 6 +- .../Resources/modes/ntriples/index.html | 70 + .../modes/{ => ntriples}/ntriples.js | 2 +- .../Resources/modes/octave/index.html | 84 + .../Resources/modes/{ => octave}/octave.js | 4 +- .../Contents/Resources/modes/oz/index.html | 59 + .../Contents/Resources/modes/{ => oz}/oz.js | 6 +- .../Resources/modes/pascal/index.html | 61 + .../Resources/modes/{ => pascal}/pascal.js | 19 +- .../Contents/Resources/modes/pegjs/index.html | 66 + .../Resources/modes/{ => pegjs}/pegjs.js | 8 +- .../Contents/Resources/modes/perl/index.html | 75 + .../Resources/modes/{ => perl}/perl.js | 10 +- .../Contents/Resources/modes/php/index.html | 64 + .../Contents/Resources/modes/{ => php}/php.js | 14 +- .../Contents/Resources/modes/php/test.js | 154 + .../Contents/Resources/modes/pig/index.html | 53 + .../Contents/Resources/modes/{ => pig}/pig.js | 2 +- .../Resources/modes/powershell/index.html | 209 + .../modes/{ => powershell}/powershell.js | 4 +- .../Resources/modes/powershell/test.js | 74 + .../Resources/modes/properties/index.html | 53 + .../modes/{ => properties}/properties.js | 2 +- .../Resources/modes/protobuf/index.html | 104 + .../modes/{ => protobuf}/protobuf.js | 7 +- .../Contents/Resources/modes/pug/index.html | 70 + .../Contents/Resources/modes/{ => pug}/pug.js | 20 +- .../Resources/modes/puppet/index.html | 121 + .../Resources/modes/{ => puppet}/puppet.js | 4 +- .../Resources/modes/python/index.html | 207 + .../Resources/modes/{ => python}/python.js | 60 +- .../Contents/Resources/modes/python/test.js | 44 + .../Contents/Resources/modes/q/index.html | 144 + .../Contents/Resources/modes/{ => q}/q.js | 2 +- .../Contents/Resources/modes/r/index.html | 88 + .../Contents/Resources/modes/{ => r}/r.js | 21 +- .../Resources/modes/rpm/changes/index.html | 66 + .../Contents/Resources/modes/rpm/index.html | 149 + .../Contents/Resources/modes/{ => rpm}/rpm.js | 10 +- .../Contents/Resources/modes/rst/index.html | 535 ++ .../Contents/Resources/modes/{ => rst}/rst.js | 2 +- .../Contents/Resources/modes/ruby/index.html | 183 + .../Resources/modes/{ => ruby}/ruby.js | 57 +- .../Contents/Resources/modes/ruby/test.js | 23 + .../Contents/Resources/modes/rust/index.html | 64 + .../Resources/modes/{ => rust}/rust.js | 8 +- .../Contents/Resources/modes/rust/test.js | 39 + .../Contents/Resources/modes/sas/index.html | 81 + .../Contents/Resources/modes/{ => sas}/sas.js | 4 +- .../Contents/Resources/modes/sass/index.html | 68 + .../Resources/modes/{ => sass}/sass.js | 4 +- .../Contents/Resources/modes/sass/test.js | 122 + .../Resources/modes/scheme/index.html | 77 + .../Resources/modes/{ => scheme}/scheme.js | 32 +- .../Contents/Resources/modes/shell/index.html | 66 + .../Resources/modes/{ => shell}/shell.js | 49 +- .../Contents/Resources/modes/shell/test.js | 80 + .../Contents/Resources/modes/sieve/index.html | 93 + .../Resources/modes/{ => sieve}/sieve.js | 4 +- .../Contents/Resources/modes/slim/index.html | 96 + .../Resources/modes/{ => slim}/slim.js | 2 +- .../Contents/Resources/modes/slim/test.js | 96 + .../Resources/modes/smalltalk/index.html | 68 + .../modes/{ => smalltalk}/smalltalk.js | 2 +- .../Resources/modes/smarty/index.html | 138 + .../Resources/modes/{ => smarty}/smarty.js | 6 +- .../Contents/Resources/modes/solr/index.html | 57 + .../Resources/modes/{ => solr}/solr.js | 2 +- .../Contents/Resources/modes/soy.js | 357 - .../Contents/Resources/modes/soy/index.html | 68 + .../Contents/Resources/modes/soy/soy.js | 637 ++ .../Contents/Resources/modes/soy/test.js | 311 + .../Resources/modes/sparql/index.html | 61 + .../Resources/modes/{ => sparql}/sparql.js | 18 +- .../Resources/modes/spreadsheet/index.html | 42 + .../modes/{ => spreadsheet}/spreadsheet.js | 2 +- .../Contents/Resources/modes/sql/index.html | 89 + .../Contents/Resources/modes/{ => sql}/sql.js | 65 +- .../Contents/Resources/modes/stex/index.html | 116 + .../Resources/modes/{ => stex}/stex.js | 4 +- .../Contents/Resources/modes/stex/test.js | 132 + .../Resources/modes/stylus/index.html | 106 + .../Resources/modes/{ => stylus}/stylus.js | 12 +- .../Contents/Resources/modes/swift/index.html | 70 + .../Resources/modes/{ => swift}/swift.js | 42 +- .../Contents/Resources/modes/swift/test.js | 162 + .../Contents/Resources/modes/tcl/index.html | 142 + .../Contents/Resources/modes/{ => tcl}/tcl.js | 5 +- .../Resources/modes/textile/index.html | 191 + .../Contents/Resources/modes/textile/test.js | 417 ++ .../Resources/modes/{ => textile}/textile.js | 2 +- .../Resources/modes/tiddlywiki/index.html | 154 + .../Resources/modes/tiddlywiki/tiddlywiki.css | 14 + .../modes/{ => tiddlywiki}/tiddlywiki.js | 6 +- .../Contents/Resources/modes/tiki/index.html | 95 + .../Contents/Resources/modes/tiki/tiki.css | 26 + .../Resources/modes/{ => tiki}/tiki.js | 2 +- .../Contents/Resources/modes/toml/index.html | 73 + .../Resources/modes/{ => toml}/toml.js | 2 +- .../Resources/modes/tornado/index.html | 63 + .../Resources/modes/{ => tornado}/tornado.js | 2 +- .../Contents/Resources/modes/troff/index.html | 146 + .../Resources/modes/{ => troff}/troff.js | 2 +- .../Resources/modes/ttcn-cfg/index.html | 116 + .../modes/{ => ttcn-cfg}/ttcn-cfg.js | 2 +- .../Contents/Resources/modes/ttcn/index.html | 119 + .../Resources/modes/{ => ttcn}/ttcn.js | 2 +- .../Resources/modes/turtle/index.html | 51 + .../Resources/modes/{ => turtle}/turtle.js | 2 +- .../Contents/Resources/modes/twig/index.html | 47 + .../Resources/modes/{ => twig}/twig.js | 2 +- .../Contents/Resources/modes/vb/index.html | 49 + .../Contents/Resources/modes/{ => vb}/vb.js | 16 +- .../Resources/modes/vbscript/index.html | 55 + .../modes/{ => vbscript}/vbscript.js | 6 +- .../Resources/modes/velocity/index.html | 120 + .../modes/{ => velocity}/velocity.js | 4 +- .../Resources/modes/verilog/index.html | 120 + .../Contents/Resources/modes/verilog/test.js | 443 ++ .../Resources/modes/{ => verilog}/verilog.js | 146 +- .../Contents/Resources/modes/vhdl/index.html | 95 + .../Resources/modes/{ => vhdl}/vhdl.js | 2 +- .../Contents/Resources/modes/vue/index.html | 69 + .../Contents/Resources/modes/{ => vue}/vue.js | 2 +- .../Contents/Resources/modes/wast/index.html | 73 + .../Contents/Resources/modes/wast/test.js | 340 + .../Contents/Resources/modes/wast/wast.js | 41 + .../Resources/modes/webidl/index.html | 71 + .../Resources/modes/{ => webidl}/webidl.js | 2 +- .../Contents/Resources/modes/xml/index.html | 61 + .../Contents/Resources/modes/xml/test.js | 51 + .../Contents/Resources/modes/{ => xml}/xml.js | 15 +- .../Resources/modes/xquery/index.html | 211 + .../Contents/Resources/modes/xquery/test.js | 67 + .../Resources/modes/{ => xquery}/xquery.js | 2 +- .../Contents/Resources/modes/yacas/index.html | 87 + .../Resources/modes/{ => yacas}/yacas.js | 2 +- .../modes/yaml-frontmatter/index.html | 121 + .../yaml-frontmatter.js | 6 +- .../Contents/Resources/modes/yaml/index.html | 80 + .../Resources/modes/{ => yaml}/yaml.js | 13 +- .../Contents/Resources/modes/z80/index.html | 53 + .../Contents/Resources/modes/{ => z80}/z80.js | 2 +- .../Resources/theme/snip-material.css | 131 + 372 files changed, 42239 insertions(+), 1940 deletions(-) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog.css create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/keymap/emacs.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/keymap/sublime.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/keymap/vim.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/{ => lib}/codemirror.css (100%) rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/{ => lib}/codemirror.js (100%) rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => apl}/apl.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/apl/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => asciiarmor}/asciiarmor.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => asn.1}/asn.1.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => asterisk}/asterisk.js (90%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => brainfuck}/brainfuck.js (96%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => clike}/clike.js (81%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/scala.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/test.js delete mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/clojure.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => cmake}/cmake.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => cobol}/cobol.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => coffeescript}/coffeescript.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => commonlisp}/commonlisp.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => crystal}/crystal.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => css}/css.js (76%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/gss.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/gss_test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/less.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/less_test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/scss.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/scss_test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => cypher}/cypher.js (87%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => d}/d.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => dart}/dart.js (88%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => diff}/diff.js (94%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => django}/django.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => dockerfile}/dockerfile.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => dtd}/dtd.js (96%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => dylan}/dylan.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => ebnf}/ebnf.js (93%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => ecl}/ecl.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => eiffel}/eiffel.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel/index.html delete mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm/elm.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => erlang}/erlang.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => factor}/factor.js (95%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => fcl}/fcl.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => forth}/forth.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => fortran}/fortran.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => gas}/gas.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => gfm}/gfm.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => gherkin}/gherkin.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => go}/go.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => groovy}/groovy.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => haml}/haml.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => handlebars}/handlebars.js (85%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => haskell-literate}/haskell-literate.js (95%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => haskell}/haskell.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => haxe}/haxe.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => htmlembedded}/htmlembedded.js (96%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => htmlmixed}/htmlmixed.js (95%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => http}/http.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => idl}/idl.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => javascript}/javascript.js (87%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/json-ld.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/typescript.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => jinja2}/jinja2.js (95%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => jsx}/jsx.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => julia}/julia.js (61%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => livescript}/livescript.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => lua}/lua.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => markdown}/markdown.js (91%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => mathematica}/mathematica.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => mbox}/mbox.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/meta.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => mirc}/mirc.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => mllike}/mllike.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => modelica}/modelica.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => mscgen}/mscgen.js (93%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/mscgen_test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/msgenny_test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/xu_test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => mumps}/mumps.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => nginx}/nginx.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => nsis}/nsis.js (75%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => ntriples}/ntriples.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => octave}/octave.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => oz}/oz.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => pascal}/pascal.js (89%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => pegjs}/pegjs.js (93%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => perl}/perl.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => php}/php.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pig/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => pig}/pig.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => powershell}/powershell.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => properties}/properties.js (96%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => protobuf}/protobuf.js (93%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => pug}/pug.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => puppet}/puppet.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => python}/python.js (90%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => q}/q.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => r}/r.js (88%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/changes/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => rpm}/rpm.js (93%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => rst}/rst.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => ruby}/ruby.js (84%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => rust}/rust.js (82%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => sas}/sas.js (76%) mode change 100644 => 100755 create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => sass}/sass.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => scheme}/scheme.js (74%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => shell}/shell.js (70%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => sieve}/sieve.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => slim}/slim.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => smalltalk}/smalltalk.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => smarty}/smarty.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => solr}/solr.js (97%) delete mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/soy.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => sparql}/sparql.js (89%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => spreadsheet}/spreadsheet.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => sql}/sql.js (75%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => stex}/stex.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => stylus}/stylus.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => swift}/swift.js (90%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => tcl}/tcl.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => textile}/textile.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/tiddlywiki.css rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => tiddlywiki}/tiddlywiki.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/tiki.css rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => tiki}/tiki.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => toml}/toml.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => tornado}/tornado.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => troff}/troff.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => ttcn-cfg}/ttcn-cfg.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => ttcn}/ttcn.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => turtle}/turtle.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => twig}/twig.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => vb}/vb.js (82%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => vbscript}/vbscript.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => velocity}/velocity.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => verilog}/verilog.js (79%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => vhdl}/vhdl.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => vue}/vue.js (97%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/test.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/wast.js create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => webidl}/webidl.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => xml}/xml.js (96%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/index.html create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/test.js rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => xquery}/xquery.js (99%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => yacas}/yacas.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => yaml-frontmatter}/yaml-frontmatter.js (92%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => yaml}/yaml.js (92%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80/index.html rename Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/{ => z80}/z80.js (98%) create mode 100644 Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/theme/snip-material.css diff --git a/README.md b/README.md index 9501e6c..fc56d30 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ CodeMirror-SwiftUI is a lightweight wrapper of CodeMirror for macOS and iOS pack This package is a fork from [CodeMirror-Swift](https://github.com/ProxymanApp/CodeMirror-Swift) ## Features -- 🍭 Lightweight CodeMirror wrapper (build 5.57.0) +- 🍭 Lightweight CodeMirror wrapper (build 5.59.4) - ✅ 100% Native Swift 5 and modern WKWebView - 👑 Support iOS & macOS - 🎧 Built-in addons @@ -61,6 +61,15 @@ CodeView(theme: themes[selectedTheme], ## Details +#### Code Editor Features + +- CodeMirror v5.59.4 +- Better find and replace dialog integration +- Autocompletion hints (ctrl+space) +- Reindent (ctrl+i) +- Auto close tags and brackets + + #### Parameters CodeView has multiple params: @@ -97,7 +106,7 @@ onContentChange { ... } - [Snip](https://github.com/Pictarine/macos-snippets), a snippet manager for macOS is also using CodeMirror-SwiftUI -[![Screen Shot 2020-08-26 at 7 55 56 PM](https://user-images.githubusercontent.com/1506323/91417795-97808a00-e851-11ea-8100-c9d2b075b59d.png)](https://github.com/Pictarine/macos-snippets) +[![black_light_theme](https://user-images.githubusercontent.com/1506323/110323754-5560ae00-8015-11eb-98a3-7822772cbe00.png)](https://github.com/Pictarine/macos-snippets) ## License diff --git a/Sources/CodeMirror-SwiftUI/Model/Mode.swift b/Sources/CodeMirror-SwiftUI/Model/Mode.swift index f00b7ea..c2bf3dd 100644 --- a/Sources/CodeMirror-SwiftUI/Model/Mode.swift +++ b/Sources/CodeMirror-SwiftUI/Model/Mode.swift @@ -10,9 +10,10 @@ import Foundation public struct Mode: Equatable, Codable { - + let name: String let mimeType: String + } public enum CodeMode: String { @@ -33,6 +34,7 @@ public enum CodeMode: String { case lisp case css case django + case dart case dockerfile case erlang case fortran @@ -49,6 +51,7 @@ public enum CodeMode: String { case lua case markdown case maths + case ntriples case pascal case perl case php @@ -64,11 +67,13 @@ public enum CodeMode: String { case shell case sql case sqllite + case sparql case mysql case latex case swift case text case toml + case turtle case vb case vue case xml @@ -86,6 +91,7 @@ public enum CodeMode: String { CodeMode.kotlin.mode(), CodeMode.scala.mode(), CodeMode.csharp.mode(), + CodeMode.dart.mode(), CodeMode.java.mode(), CodeMode.cobol.mode(), CodeMode.coffeescript.mode(), @@ -108,6 +114,7 @@ public enum CodeMode: String { CodeMode.lua.mode(), CodeMode.markdown.mode(), CodeMode.maths.mode(), + CodeMode.ntriples.mode(), CodeMode.pascal.mode(), CodeMode.perl.mode(), CodeMode.php.mode(), @@ -123,11 +130,13 @@ public enum CodeMode: String { CodeMode.shell.mode(), CodeMode.sql.mode(), CodeMode.sqllite.mode(), + CodeMode.sparql.mode(), CodeMode.mysql.mode(), CodeMode.latex.mode(), CodeMode.swift.mode(), CodeMode.text.mode(), CodeMode.toml.mode(), + CodeMode.turtle.mode(), CodeMode.vb.mode(), CodeMode.vue.mode(), CodeMode.xml.mode(), @@ -175,6 +184,8 @@ public enum CodeMode: String { return Mode(name: "css/scss", mimeType: "text/x-scss") case .django: return Mode(name: "django", mimeType: "text/x-django") + case .dart: + return Mode(name: "dart", mimeType: "application/dart") case .dockerfile: return Mode(name: "dockerfile", mimeType: "text/x-dockerfile") case .erlang: @@ -207,16 +218,18 @@ public enum CodeMode: String { return Mode(name: "markdown", mimeType: "text/markdown") case .maths: return Mode(name: "maths", mimeType: "text/x-mathematica") + case .ntriples: + return Mode(name: "ntriples", mimeType: "application/n-triples") case .pascal: return Mode(name: "pascal", mimeType: "text/x-pascal") case .perl: return Mode(name: "perl", mimeType: "perl") case .php: - return Mode(name: "php", mimeType: "application/x-httpd-php") + return Mode(name: "php", mimeType: "text/x-php") case .powershell: return Mode(name: "powershell", mimeType: "application/x-powershell") case .properties: - return Mode(name: "properties", mimeType: "text/x-properties") + return Mode(name: "properties", mimeType: "text/x-properties") case .protobuf: return Mode(name: "protobuf", mimeType: "text/x-protobuf") case .python: @@ -237,6 +250,8 @@ public enum CodeMode: String { return Mode(name: "sql", mimeType: "text/x-sql") case .sqllite: return Mode(name: "sqllite", mimeType: "text/x-sqlite") + case .sparql: + return Mode(name: "sparql", mimeType: "application/sparql-query") case .mysql: return Mode(name: "mysql", mimeType: "text/x-mysql") case .latex: @@ -246,7 +261,9 @@ public enum CodeMode: String { case .text: return Mode(name: "text", mimeType: "text/plain-text") case .toml: - return Mode(name: "toml", mimeType: "text/x-toml") + return Mode(name: "toml", mimeType: "text/x-toml") + case .turtle: + return Mode(name: "turtle", mimeType: "text/turtle") case .vb: return Mode(name: "vb", mimeType: "text/x-vb") case .vue: diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Info.plist b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Info.plist index 7dc3f1faf855765ff58adf1cb90627f66f5cf364..d70fd909d74cd3d5226042d8f38038590db36037 100644 GIT binary patch delta 20 acmcc2c$slR8<(Y?NtmggDUg~t!5IKXcLq@a delta 20 acmcc2c$slR8<)ABL71tYDUg~t!5IKX6$V8B diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/comment/comment.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/comment/comment.js index 735653d..dac48d0 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/comment/comment.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/comment/comment.js @@ -1,8 +1,211 @@ -'use strict';(function(h){"object"==typeof exports&&"object"==typeof module?h(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],h):h(CodeMirror)})(function(h){function v(b){b=b.search(q);return-1==b?0:b}function E(b,d,a){return/\bstring\b/.test(b.getTokenTypeAt(k(d.line,0)))&&!/^['"`]/.test(a)}function C(b,d){var a=b.getMode();return!1!==a.useInnerComments&&a.innerMode?b.getModeAt(d):a}var z={},q=/[^\s\u00a0]/,k=h.Pos;h.commands.toggleComment=function(b){b.toggleComment()}; -h.defineExtension("toggleComment",function(b){b||(b=z);for(var d=Infinity,a=this.listSelections(),e=null,c=a.length-1;0<=c;c--){var f=a[c].from(),g=a[c].to();f.line>=d||(g.line>=d&&(g=k(d,0)),d=f.line,null==e?this.uncomment(f,g,b)?e="un":(this.lineComment(f,g,b),e="line"):"un"==e?this.uncomment(f,g,b):this.lineComment(f,g,b))}});h.defineExtension("lineComment",function(b,d,a){a||(a=z);var e=this,c=C(e,b),f=e.getLine(b.line);if(null!=f&&!E(e,b,f)){var g=a.lineComment||c.lineComment;if(g){var m=Math.min(0!= -d.ch||d.line==b.line?d.line+1:d.line,e.lastLine()+1),h=null==a.padding?" ":a.padding,l=a.commentBlankLines||b.line==d.line;e.operation(function(){if(a.indent){for(var d=null,c=b.line;cf.length)d=f}for(c=b.line;cm||e.operation(function(){if(0!= -a.fullLines){var l=q.test(e.getLine(m));e.replaceRange(h+g,k(m));e.replaceRange(f+h,k(b.line,0));var w=a.blockCommentLead||c.blockCommentLead;if(null!=w)for(var p=b.line+1;p<=m;++p)(p!=m||l)&&e.replaceRange(w+h,k(p,0))}else e.replaceRange(g,d),e.replaceRange(f,b)})}});h.defineExtension("uncomment",function(b,d,a){a||(a=z);var e=this,c=C(e,b),f=Math.min(0!=d.ch||d.line==b.line?d.line:d.line-1,e.lastLine()),g=Math.min(b.line,f),h=a.lineComment||c.lineComment,v=[],l=null==a.padding?" ":a.padding,w;a:if(h){for(var p= -g;p<=f;++p){var A=e.getLine(p),n=A.indexOf(h);-1c||(b.slice(d,d+l.length)==l&&(d+=l.length),w=!0,e.replaceRange("",k(a,c),k(a,d)))}});if(w)return!0}var r=a.blockCommentStart||c.blockCommentStart,t=a.blockCommentEnd||c.blockCommentEnd;if(!r||!t)return!1;var D=a.blockCommentLead||c.blockCommentLead, -x=e.getLine(g),y=x.indexOf(r);if(-1==y)return!1;var B=f==g?x:e.getLine(f),u=B.indexOf(t,f==g?y+r.length:0);a=k(g,y+1);c=k(f,u+1);if(-1==u||!/comment/.test(e.getTokenTypeAt(a))||!/comment/.test(e.getTokenTypeAt(c))||-1= 0; i--) { + var from = ranges[i].from(), to = ranges[i].to(); + if (from.line >= minLine) continue; + if (to.line >= minLine) to = Pos(minLine, 0); + minLine = from.line; + if (mode == null) { + if (cm.uncomment(from, to, options)) mode = "un"; + else { cm.lineComment(from, to, options); mode = "line"; } + } else if (mode == "un") { + cm.uncomment(from, to, options); + } else { + cm.lineComment(from, to, options); + } + } + }); + + // Rough heuristic to try and detect lines that are part of multi-line string + function probablyInsideString(cm, pos, line) { + return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"\`]/.test(line) + } + + function getMode(cm, pos) { + var mode = cm.getMode() + return mode.useInnerComments === false || !mode.innerMode ? mode : cm.getModeAt(pos) + } + + CodeMirror.defineExtension("lineComment", function(from, to, options) { + if (!options) options = noOptions; + var self = this, mode = getMode(self, from); + var firstLine = self.getLine(from.line); + if (firstLine == null || probablyInsideString(self, from, firstLine)) return; + + var commentString = options.lineComment || mode.lineComment; + if (!commentString) { + if (options.blockCommentStart || mode.blockCommentStart) { + options.fullLines = true; + self.blockComment(from, to, options); + } + return; + } + + var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1); + var pad = options.padding == null ? " " : options.padding; + var blankLines = options.commentBlankLines || from.line == to.line; + + self.operation(function() { + if (options.indent) { + var baseString = null; + for (var i = from.line; i < end; ++i) { + var line = self.getLine(i); + var whitespace = line.slice(0, firstNonWS(line)); + if (baseString == null || baseString.length > whitespace.length) { + baseString = whitespace; + } + } + for (var i = from.line; i < end; ++i) { + var line = self.getLine(i), cut = baseString.length; + if (!blankLines && !nonWS.test(line)) continue; + if (line.slice(0, cut) != baseString) cut = firstNonWS(line); + self.replaceRange(baseString + commentString + pad, Pos(i, 0), Pos(i, cut)); + } + } else { + for (var i = from.line; i < end; ++i) { + if (blankLines || nonWS.test(self.getLine(i))) + self.replaceRange(commentString + pad, Pos(i, 0)); + } + } + }); + }); + + CodeMirror.defineExtension("blockComment", function(from, to, options) { + if (!options) options = noOptions; + var self = this, mode = getMode(self, from); + var startString = options.blockCommentStart || mode.blockCommentStart; + var endString = options.blockCommentEnd || mode.blockCommentEnd; + if (!startString || !endString) { + if ((options.lineComment || mode.lineComment) && options.fullLines != false) + self.lineComment(from, to, options); + return; + } + if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return + + var end = Math.min(to.line, self.lastLine()); + if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end; + + var pad = options.padding == null ? " " : options.padding; + if (from.line > end) return; + + self.operation(function() { + if (options.fullLines != false) { + var lastLineHasText = nonWS.test(self.getLine(end)); + self.replaceRange(pad + endString, Pos(end)); + self.replaceRange(startString + pad, Pos(from.line, 0)); + var lead = options.blockCommentLead || mode.blockCommentLead; + if (lead != null) for (var i = from.line + 1; i <= end; ++i) + if (i != end || lastLineHasText) + self.replaceRange(lead + pad, Pos(i, 0)); + } else { + var atCursor = cmp(self.getCursor("to"), to) == 0, empty = !self.somethingSelected() + self.replaceRange(endString, to); + if (atCursor) self.setSelection(empty ? to : self.getCursor("from"), to) + self.replaceRange(startString, from); + } + }); + }); + + CodeMirror.defineExtension("uncomment", function(from, to, options) { + if (!options) options = noOptions; + var self = this, mode = getMode(self, from); + var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end); + + // Try finding line comments + var lineString = options.lineComment || mode.lineComment, lines = []; + var pad = options.padding == null ? " " : options.padding, didSomething; + lineComment: { + if (!lineString) break lineComment; + for (var i = start; i <= end; ++i) { + var line = self.getLine(i); + var found = line.indexOf(lineString); + if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1; + if (found == -1 && nonWS.test(line)) break lineComment; + if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment; + lines.push(line); + } + self.operation(function() { + for (var i = start; i <= end; ++i) { + var line = lines[i - start]; + var pos = line.indexOf(lineString), endPos = pos + lineString.length; + if (pos < 0) continue; + if (line.slice(endPos, endPos + pad.length) == pad) endPos += pad.length; + didSomething = true; + self.replaceRange("", Pos(i, pos), Pos(i, endPos)); + } + }); + if (didSomething) return true; + } + + // Try block comments + var startString = options.blockCommentStart || mode.blockCommentStart; + var endString = options.blockCommentEnd || mode.blockCommentEnd; + if (!startString || !endString) return false; + var lead = options.blockCommentLead || mode.blockCommentLead; + var startLine = self.getLine(start), open = startLine.indexOf(startString) + if (open == -1) return false + var endLine = end == start ? startLine : self.getLine(end) + var close = endLine.indexOf(endString, end == start ? open + startString.length : 0); + var insideStart = Pos(start, open + 1), insideEnd = Pos(end, close + 1) + if (close == -1 || + !/comment/.test(self.getTokenTypeAt(insideStart)) || + !/comment/.test(self.getTokenTypeAt(insideEnd)) || + self.getRange(insideStart, insideEnd, "\n").indexOf(endString) > -1) + return false; + + // Avoid killing block comments completely outside the selection. + // Positions of the last startString before the start of the selection, and the first endString after it. + var lastStart = startLine.lastIndexOf(startString, from.ch); + var firstEnd = lastStart == -1 ? -1 : startLine.slice(0, from.ch).indexOf(endString, lastStart + startString.length); + if (lastStart != -1 && firstEnd != -1 && firstEnd + endString.length != from.ch) return false; + // Positions of the first endString after the end of the selection, and the last startString before it. + firstEnd = endLine.indexOf(endString, to.ch); + var almostLastStart = endLine.slice(to.ch).lastIndexOf(startString, firstEnd - to.ch); + lastStart = (firstEnd == -1 || almostLastStart == -1) ? -1 : to.ch + almostLastStart; + if (firstEnd != -1 && lastStart != -1 && lastStart != to.ch) return false; + + self.operation(function() { + self.replaceRange("", Pos(end, close - (pad && endLine.slice(close - pad.length, close) == pad ? pad.length : 0)), + Pos(end, close + endString.length)); + var openEnd = open + startString.length; + if (pad && startLine.slice(openEnd, openEnd + pad.length) == pad) openEnd += pad.length; + self.replaceRange("", Pos(start, open), Pos(start, openEnd)); + if (lead) for (var i = start + 1; i <= end; ++i) { + var line = self.getLine(i), found = line.indexOf(lead); + if (found == -1 || nonWS.test(line.slice(0, found))) continue; + var foundEnd = found + lead.length; + if (pad && line.slice(foundEnd, foundEnd + pad.length) == pad) foundEnd += pad.length; + self.replaceRange("", Pos(i, found), Pos(i, foundEnd)); + } + }); + return true; + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/comment/continuecomment.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/comment/continuecomment.js index 4b585c8..7ca1b4a 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/comment/continuecomment.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/comment/continuecomment.js @@ -1,8 +1,114 @@ -'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.checkStringArgs=function(a,c,b){if(null==a)throw new TypeError("The 'this' value for String.prototype."+b+" must not be null or undefined");if(c instanceof RegExp)throw new TypeError("First argument to String.prototype."+b+" must not be a regular expression");return a+""};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1; -$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,b){a!=Array.prototype&&a!=Object.prototype&&(a[c]=b.value)};$jscomp.getGlobal=function(a){a=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,a];for(var c=0;ca||1342177279>>=1)b+=b;return c}},"es6","es3"); -(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){function c(l){if(l.getOption("disableInput"))return a.Pass;for(var c=l.listSelections(),g,n=[],p=0;p=q.length&&-1<(e=k.lastIndexOf(q,h.ch-q.length))&&e>r)if(b(0,k)>=e)d=k.slice(0,e);else{d=l.options.tabSize;var u;e=a.countColumn(k,e,d);d=l.options.indentWithTabs?t.call("\t",u=Math.floor(e/d))+t.call(" ",e-d*u):t.call(" ",e)}else-1<(e= -k.indexOf(g.blockCommentContinue))&&e<=h.ch&&e<=b(0,k)&&(d=k.slice(0,e));null!=d&&(d+=g.blockCommentContinue)}null==d&&m&&f(l)&&((null==k&&(k=l.getLine(h.line)),e=k.indexOf(m),h.ch||e)?-1=e&&(d=-1=d||null),d&&(d=k.slice(0,e)+m+k.slice(e+m.length).match(/^\s*/)[0])):d="");if(null==d)return a.Pass;n[p]="\n"+d}l.operation(function(){for(var a=c.length-1;0<=a;a--)l.replaceRange(n[a],c[a].from(),c[a].to(),"+insert")})}function b(a, -b){n.lastIndex=a;return(a=n.exec(b))?a.index:-1}function f(a){return(a=a.getOption("continueComments"))&&"object"==typeof a?!1!==a.continueLineComment:!0}var n=/\S/g,t=String.prototype.repeat||function(a){return Array(a+1).join(this)};a.defineOption("continueComments",null,function(b,f,g){g&&g!=a.Init&&b.removeKeyMap("continueComment");f&&(g="Enter","string"==typeof f?g=f:"object"==typeof f&&f.key&&(g=f.key),f={name:"continueComment"},f[g]=c,b.addKeyMap(f))})}); +// 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) { + var nonspace = /\S/g; + var repeat = String.prototype.repeat || function (n) { return Array(n + 1).join(this); }; + function continueComment(cm) { + if (cm.getOption("disableInput")) return CodeMirror.Pass; + var ranges = cm.listSelections(), mode, inserts = []; + for (var i = 0; i < ranges.length; i++) { + var pos = ranges[i].head + if (!/\bcomment\b/.test(cm.getTokenTypeAt(pos))) return CodeMirror.Pass; + var modeHere = cm.getModeAt(pos) + if (!mode) mode = modeHere; + else if (mode != modeHere) return CodeMirror.Pass; + + var insert = null, line, found; + var blockStart = mode.blockCommentStart, lineCmt = mode.lineComment; + if (blockStart && mode.blockCommentContinue) { + line = cm.getLine(pos.line); + var end = line.lastIndexOf(mode.blockCommentEnd, pos.ch - mode.blockCommentEnd.length); + // 1. if this block comment ended + // 2. if this is actually inside a line comment + if (end != -1 && end == pos.ch - mode.blockCommentEnd.length || + lineCmt && (found = line.lastIndexOf(lineCmt, pos.ch - 1)) > -1 && + /\bcomment\b/.test(cm.getTokenTypeAt({line: pos.line, ch: found + 1}))) { + // ...then don't continue it + } else if (pos.ch >= blockStart.length && + (found = line.lastIndexOf(blockStart, pos.ch - blockStart.length)) > -1 && + found > end) { + // reuse the existing leading spaces/tabs/mixed + // or build the correct indent using CM's tab/indent options + if (nonspaceAfter(0, line) >= found) { + insert = line.slice(0, found); + } else { + var tabSize = cm.options.tabSize, numTabs; + found = CodeMirror.countColumn(line, found, tabSize); + insert = !cm.options.indentWithTabs ? repeat.call(" ", found) : + repeat.call("\t", (numTabs = Math.floor(found / tabSize))) + + repeat.call(" ", found - tabSize * numTabs); + } + } else if ((found = line.indexOf(mode.blockCommentContinue)) > -1 && + found <= pos.ch && + found <= nonspaceAfter(0, line)) { + insert = line.slice(0, found); + } + if (insert != null) insert += mode.blockCommentContinue + } + if (insert == null && lineCmt && continueLineCommentEnabled(cm)) { + if (line == null) line = cm.getLine(pos.line); + found = line.indexOf(lineCmt); + // cursor at pos 0, line comment also at pos 0 => shift it down, don't continue + if (!pos.ch && !found) insert = ""; + // continue only if the line starts with an optional space + line comment + else if (found > -1 && nonspaceAfter(0, line) >= found) { + // don't continue if there's only space(s) after cursor or the end of the line + insert = nonspaceAfter(pos.ch, line) > -1; + // but always continue if the next line starts with a line comment too + if (!insert) { + var next = cm.getLine(pos.line + 1) || '', + nextFound = next.indexOf(lineCmt); + insert = nextFound > -1 && nonspaceAfter(0, next) >= nextFound || null; + } + if (insert) { + insert = line.slice(0, found) + lineCmt + + line.slice(found + lineCmt.length).match(/^\s*/)[0]; + } + } + } + if (insert == null) return CodeMirror.Pass; + inserts[i] = "\n" + insert; + } + + cm.operation(function() { + for (var i = ranges.length - 1; i >= 0; i--) + cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+insert"); + }); + } + + function nonspaceAfter(ch, str) { + nonspace.lastIndex = ch; + var m = nonspace.exec(str); + return m ? m.index : -1; + } + + function continueLineCommentEnabled(cm) { + var opt = cm.getOption("continueComments"); + if (opt && typeof opt == "object") + return opt.continueLineComment !== false; + return true; + } + + CodeMirror.defineOption("continueComments", null, function(cm, val, prev) { + if (prev && prev != CodeMirror.Init) + cm.removeKeyMap("continueComment"); + if (val) { + var key = "Enter"; + if (typeof val == "string") + key = val; + else if (typeof val == "object" && val.key) + key = val.key; + var map = {name: "continueComment"}; + map[key] = continueComment; + cm.addKeyMap(map); + } + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog.css new file mode 100644 index 0000000..48b7c28 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog.css @@ -0,0 +1,99 @@ +.CodeMirror-find-and-replace-dialog { + display: flex; + /* flex-wrap: wrap; */ + align-items: center; + justify-content: space-between; + background-color: #191919; + padding: 8px; + overflow: hidden; + color: inherit; + /* border: 1px solid #eee; */ + position: relative; + z-index: 10; + border-bottom: 1px solid #737370; +} +.CodeMirror-find-and-replace-dialog--replace-container { + width: 100%; +} + +.CodeMirror-find-and-replace-dialog input { + border: none; + outline: none; + background: transparent; + width: 100%; + color: #e8eaed; + font-size: 14px; +} +.CodeMirror-find-and-replace-dialog input::placeholder { + /* Chrome, Firefox, Opera, Safari 10.1+ */ + color: rgba(232, 234, 237, 0.7); +} +.CodeMirror-find-and-replace-dialog input:-ms-input-placeholder { + /* Internet Explorer 10-11 */ + color: rgba(232, 234, 237, 0.7); +} + +.CodeMirror-find-and-replace-dialog input::-ms-input-placeholder { + /* Microsoft Edge */ + color: rgba(232, 234, 237, 0.7); +} +.CodeMirror-find-and-replace-dialog--search-count { + font-size: 14px; + font-weight: normal; + font-stretch: normal; + font-style: normal; + line-height: normal; + letter-spacing: normal; + color: #e8eaed; + width: 100%; + max-width: 140px; + text-align: right; + border-right: 1px solid #404244; + padding-right: 5px; + margin-right: 5px; + height: 32px; + line-height: 32px; +} + +.CodeMirror-find-and-replace-dialog--buttons { + display: flex; + align-items: center; +} +.CodeMirror-find-and-replace-dialog--buttons button { + appearance: none; + border: none; + outline: none; + box-shadow: none; + cursor: pointer; + background: transparent; + width: 32px; + height: 32px; + margin: 0 5px 0 0; + display: flex; + align-items: center; + justify-content: center; +} +.CodeMirror-find-and-replace-dialog--buttons button svg path { + fill: #e8eaed; +} +.CodeMirror-find-and-replace-dialog--buttons button:hover { + background-color: rgba(255, 255, 255, 0.15); + border-radius: 50%; +} +.CodeMirror-find-and-replace-dialog--buttons button:active { + background-color: rgba(255, 255, 255, 0.25); + border-radius: 50%; +} +.CodeMirror-find-and-replace-dialog--buttons button:disabled { + background-color: transparent; + cursor: default; +} +.CodeMirror-find-and-replace-dialog--buttons button:disabled svg path { + fill: #86888a; +} + +.CodeMirror-find-and-replace-dialog--row { + display: flex; + width: 100%; + align-items: center; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog.js new file mode 100644 index 0000000..5b6c982 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog.js @@ -0,0 +1,140 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Open search dialogs on top of an editor. Relies on dialog.css. + +(function (mod) { + if (typeof exports == "object" && typeof module == "object") + // CommonJS + mod(require("codemirror")); + else if (typeof define == "function" && define.amd) + // AMD + define(["codemirror"], mod); + // Plain browser env + else mod(CodeMirror); +})((CodeMirror) => { + let createPanel = (cm, template, bottom) => { + let el = document.createElement("div"); + el.className = "CodeMirror-find-and-replace-dialog"; + + if (typeof template == "string") { + el.innerHTML = template; + } else { + // Assuming it's a detached DOM element. + el.appendChild(template); + } + let panel = cm.addPanel(el, { + position: bottom ? "bottom" : "top", + }); + return panel; + }; + + let closePanel = (cm) => { + let state = cm.state.findAndReplaceDialog; + if (!state || !state.current) { + return; + } + + state.current.panel.clear(); + + if (state.current.onClose) state.current.onClose(state.current.panel.node); + delete state.current; + cm.focus(); + }; + + CodeMirror.defineExtension("openFindAndReplaceDialog", function ( + template, + options + ) { + if (!this.addPanel) { + throw `CodeMirror-FindAndReplaceDialog requires the panel addon to be included in the page. This can usually be found in the addons folder of the default CodeMirror installation, and must be included BEFORE the FindAndReplaceDialog addon.`; + } + if (!options) options = {}; + if (!this.state.findAndReplaceDialog) this.state.findAndReplaceDialog = {}; + + if (this.state.findAndReplaceDialog.current) { + closePanel(this); + } + + let panel = createPanel(this, template, options.bottom); + this.state.findAndReplaceDialog.current = { + panel: panel, + onClose: options.onClose, + }; + + let inputs = panel.node.getElementsByTagName("input"); + let buttons = panel.node.getElementsByTagName("button"); + if (inputs && inputs.length > 0 && options.inputBehaviour) { + for (let i = 0; i < options.inputBehaviour.length; i++) { + let behaviour = options.inputBehaviour[i]; + let input = inputs[i]; + if (behaviour.value) { + input.value = behaviour.value; + } + + if (!!behaviour.focus) { + input.focus(); + } + + if (!!behaviour.selectValueOnOpen) { + input.select(); + } + + if (behaviour.onInput) { + CodeMirror.on(input, "input", (e) => { + behaviour.onInput(inputs, e); + }); + } + + if (behaviour.onKeyUp) { + CodeMirror.on(input, "keyup", (e) => { + behaviour.onKeyUp(inputs, e); + }); + } + + CodeMirror.on(input, "keydown", (e) => { + if (behaviour.onKeyDown && behaviour.onKeyDown(inputs, e)) { + return; + } + + if ( + e.keyCode === 27 || + (!!behaviour.closeOnEnter && e.keyCode === 13) + ) { + input.blur(); + CodeMirror.e_stop(e); + closePanel(this); + } else if (e.keyCode === 13 && behaviour.callback) { + CodeMirror.e_preventDefault(e); + behaviour.callback(inputs, e); + } + }); + + if (behaviour.closeOnBlur !== false) + CodeMirror.on(input, "blur", () => { + closePanel(this); + }); + } + } + + if (buttons && buttons.length > 0 && options.buttonBehaviour) { + for (let i = 0; i < options.buttonBehaviour.length; i++) { + let behaviour = options.buttonBehaviour[i]; + if (!!behaviour.callback) { + CodeMirror.on(buttons[i], "click", (e) => { + CodeMirror.e_preventDefault(e); + behaviour.callback(inputs, e); + }); + } else { + CodeMirror.on(buttons[i], "click", (e) => { + CodeMirror.e_preventDefault(e); + closePanel(this); + }); + } + } + } + return () => { + closePanel(this); + }; + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog/dialog.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog/dialog.css index 9f33bea..677c078 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog/dialog.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog/dialog.css @@ -1 +1,32 @@ -.CodeMirror-dialog{position:absolute;left:0;right:0;background:inherit;z-index:15;padding:.1em .8em;overflow:hidden;color:inherit}.CodeMirror-dialog-top{border-bottom:1px solid #eee;top:0}.CodeMirror-dialog-bottom{border-top:1px solid #eee;bottom:0}.CodeMirror-dialog input{border:none;outline:0;background:0 0;width:20em;color:inherit;font-family:monospace}.CodeMirror-dialog button{font-size:70%} \ No newline at end of file +.CodeMirror-dialog { + position: absolute; + left: 0; right: 0; + background: inherit; + z-index: 15; + padding: .1em .8em; + overflow: hidden; + color: inherit; +} + +.CodeMirror-dialog-top { + border-bottom: 1px solid #eee; + top: 0; +} + +.CodeMirror-dialog-bottom { + border-top: 1px solid #eee; + bottom: 0; +} + +.CodeMirror-dialog input { + border: none; + outline: none; + background: transparent; + width: 20em; + color: inherit; + font-family: monospace; +} + +.CodeMirror-dialog button { + font-size: 70%; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog/dialog.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog/dialog.js index 5bac5fd..5f1f4aa 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog/dialog.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/dialog/dialog.js @@ -1,5 +1,163 @@ -'use strict';(function(c){"object"==typeof exports&&"object"==typeof module?c(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){function l(a,g,b){a=a.getWrapperElement();var d=a.appendChild(document.createElement("div"));d.className=b?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top";"string"==typeof g?d.innerHTML=g:d.appendChild(g);c.addClass(a,"dialog-opened");return d}function m(a, -c){a.state.currentNotificationClose&&a.state.currentNotificationClose();a.state.currentNotificationClose=c}c.defineExtension("openDialog",function(a,g,b){function d(a){if("string"==typeof a)e.value=a;else if(!h&&(h=!0,c.rmClass(f.parentNode,"dialog-opened"),f.parentNode.removeChild(f),k.focus(),b.onClose))b.onClose(f)}b||(b={});m(this,null);var f=l(this,a,b.bottom),h=!1,k=this,e=f.getElementsByTagName("input")[0];if(e){e.focus();b.value&&(e.value=b.value,!1!==b.selectValueOnOpen&&e.select());if(b.onInput)c.on(e, -"input",function(a){b.onInput(a,e.value,d)});if(b.onKeyUp)c.on(e,"keyup",function(a){b.onKeyUp(a,e.value,d)});c.on(e,"keydown",function(a){if(!(b&&b.onKeyDown&&b.onKeyDown(a,e.value,d))){if(27==a.keyCode||!1!==b.closeOnEnter&&13==a.keyCode)e.blur(),c.e_stop(a),d();13==a.keyCode&&g(e.value,a)}});if(!1!==b.closeOnBlur)c.on(e,"blur",d)}else if(a=f.getElementsByTagName("button")[0]){c.on(a,"click",function(){d();k.focus()});if(!1!==b.closeOnBlur)c.on(a,"blur",d);a.focus()}return d});c.defineExtension("openConfirm", -function(a,g,b){function d(){h||(h=!0,c.rmClass(f.parentNode,"dialog-opened"),f.parentNode.removeChild(f),k.focus())}m(this,null);var f=l(this,a,b&&b.bottom);a=f.getElementsByTagName("button");var h=!1,k=this,e=1;a[0].focus();for(b=0;b=e&&d()},200)});c.on(n,"focus",function(){++e})}});c.defineExtension("openNotification",function(a,g){function b(){f|| -(f=!0,clearTimeout(h),c.rmClass(d.parentNode,"dialog-opened"),d.parentNode.removeChild(d))}m(this,b);var d=l(this,a,g&&g.bottom),f=!1,h;a=g&&"undefined"!==typeof g.duration?g.duration:5E3;c.on(d,"click",function(a){c.e_preventDefault(a);b()});a&&(h=setTimeout(b,a));return b})}); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Open simple dialogs on top of an editor. Relies on dialog.css. + +(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) { + function dialogDiv(cm, template, bottom) { + var wrap = cm.getWrapperElement(); + var dialog; + dialog = wrap.appendChild(document.createElement("div")); + if (bottom) + dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom"; + else + dialog.className = "CodeMirror-dialog CodeMirror-dialog-top"; + + if (typeof template == "string") { + dialog.innerHTML = template; + } else { // Assuming it's a detached DOM element. + dialog.appendChild(template); + } + CodeMirror.addClass(wrap, 'dialog-opened'); + return dialog; + } + + function closeNotification(cm, newVal) { + if (cm.state.currentNotificationClose) + cm.state.currentNotificationClose(); + cm.state.currentNotificationClose = newVal; + } + + CodeMirror.defineExtension("openDialog", function(template, callback, options) { + if (!options) options = {}; + + closeNotification(this, null); + + var dialog = dialogDiv(this, template, options.bottom); + var closed = false, me = this; + function close(newVal) { + if (typeof newVal == 'string') { + inp.value = newVal; + } else { + if (closed) return; + closed = true; + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); + dialog.parentNode.removeChild(dialog); + me.focus(); + + if (options.onClose) options.onClose(dialog); + } + } + + var inp = dialog.getElementsByTagName("input")[0], button; + if (inp) { + inp.focus(); + + if (options.value) { + inp.value = options.value; + if (options.selectValueOnOpen !== false) { + inp.select(); + } + } + + if (options.onInput) + CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); + if (options.onKeyUp) + CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); + + CodeMirror.on(inp, "keydown", function(e) { + if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } + if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { + inp.blur(); + CodeMirror.e_stop(e); + close(); + } + if (e.keyCode == 13) callback(inp.value, e); + }); + + if (options.closeOnBlur !== false) CodeMirror.on(dialog, "focusout", function (evt) { + if (evt.relatedTarget !== null) close(); + }); + } else if (button = dialog.getElementsByTagName("button")[0]) { + CodeMirror.on(button, "click", function() { + close(); + me.focus(); + }); + + if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close); + + button.focus(); + } + return close; + }); + + CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) { + closeNotification(this, null); + var dialog = dialogDiv(this, template, options && options.bottom); + var buttons = dialog.getElementsByTagName("button"); + var closed = false, me = this, blurring = 1; + function close() { + if (closed) return; + closed = true; + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); + dialog.parentNode.removeChild(dialog); + me.focus(); + } + buttons[0].focus(); + for (var i = 0; i < buttons.length; ++i) { + var b = buttons[i]; + (function(callback) { + CodeMirror.on(b, "click", function(e) { + CodeMirror.e_preventDefault(e); + close(); + if (callback) callback(me); + }); + })(callbacks[i]); + CodeMirror.on(b, "blur", function() { + --blurring; + setTimeout(function() { if (blurring <= 0) close(); }, 200); + }); + CodeMirror.on(b, "focus", function() { ++blurring; }); + } + }); + + /* + * openNotification + * Opens a notification, that can be closed with an optional timer + * (default 5000ms timer) and always closes on click. + * + * If a notification is opened while another is opened, it will close the + * currently opened one and open the new one immediately. + */ + CodeMirror.defineExtension("openNotification", function(template, options) { + closeNotification(this, close); + var dialog = dialogDiv(this, template, options && options.bottom); + var closed = false, doneTimer; + var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000; + + function close() { + if (closed) return; + closed = true; + clearTimeout(doneTimer); + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); + dialog.parentNode.removeChild(dialog); + } + + CodeMirror.on(dialog, 'click', function(e) { + CodeMirror.e_preventDefault(e); + close(); + }); + + if (duration) + doneTimer = setTimeout(close, duration); + + return close; + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/autorefresh.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/autorefresh.js index a65ade5..37014dc 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/autorefresh.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/autorefresh.js @@ -1,2 +1,47 @@ -'use strict';(function(c){"object"==typeof exports&&"object"==typeof module?c(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){function f(b,a){function d(){b.display.wrapper.offsetHeight?(e(b,a),b.display.lastWrapHeight!=b.display.wrapper.clientHeight&&b.refresh()):a.timeout=setTimeout(d,a.delay)}a.timeout=setTimeout(d,a.delay);a.hurry=function(){clearTimeout(a.timeout);a.timeout=setTimeout(d,50)};c.on(window,"mouseup", -a.hurry);c.on(window,"keyup",a.hurry)}function e(b,a){clearTimeout(a.timeout);c.off(window,"mouseup",a.hurry);c.off(window,"keyup",a.hurry)}c.defineOption("autoRefresh",!1,function(b,a){b.state.autoRefresh&&(e(b,b.state.autoRefresh),b.state.autoRefresh=null);a&&0==b.display.wrapper.offsetHeight&&f(b,b.state.autoRefresh={delay:a.delay||250})})}); +// 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" + + CodeMirror.defineOption("autoRefresh", false, function(cm, val) { + if (cm.state.autoRefresh) { + stopListening(cm, cm.state.autoRefresh) + cm.state.autoRefresh = null + } + if (val && cm.display.wrapper.offsetHeight == 0) + startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250}) + }) + + function startListening(cm, state) { + function check() { + if (cm.display.wrapper.offsetHeight) { + stopListening(cm, state) + if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight) + cm.refresh() + } else { + state.timeout = setTimeout(check, state.delay) + } + } + state.timeout = setTimeout(check, state.delay) + state.hurry = function() { + clearTimeout(state.timeout) + state.timeout = setTimeout(check, 50) + } + CodeMirror.on(window, "mouseup", state.hurry) + CodeMirror.on(window, "keyup", state.hurry) + } + + function stopListening(_cm, state) { + clearTimeout(state.timeout) + CodeMirror.off(window, "mouseup", state.hurry) + CodeMirror.off(window, "keyup", state.hurry) + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/fullscreen.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/fullscreen.css index a414b02..437acd8 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/fullscreen.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/fullscreen.css @@ -1 +1,6 @@ -.CodeMirror-fullscreen{position:fixed;top:0;left:0;right:0;bottom:0;height:auto;z-index:9} \ No newline at end of file +.CodeMirror-fullscreen { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + height: auto; + z-index: 9; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/fullscreen.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/fullscreen.js index a69e808..eda7300 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/fullscreen.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/fullscreen.js @@ -1,2 +1,41 @@ -'use strict';(function(c){"object"==typeof exports&&"object"==typeof module?c(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){c.defineOption("fullScreen",!1,function(d,a,b){b==c.Init&&(b=!1);!b!=!a&&(a?(a=d.getWrapperElement(),d.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:a.style.width,height:a.style.height},a.style.width="",a.style.height="auto",a.className+=" CodeMirror-fullscreen", -document.documentElement.style.overflow="hidden"):(a=d.getWrapperElement(),a.className=a.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="",b=d.state.fullScreenRestore,a.style.width=b.width,a.style.height=b.height,window.scrollTo(b.scrollLeft,b.scrollTop)),d.refresh())})}); +// 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"; + + CodeMirror.defineOption("fullScreen", false, function(cm, val, old) { + if (old == CodeMirror.Init) old = false; + if (!old == !val) return; + if (val) setFullscreen(cm); + else setNormal(cm); + }); + + function setFullscreen(cm) { + var wrap = cm.getWrapperElement(); + cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, + width: wrap.style.width, height: wrap.style.height}; + wrap.style.width = ""; + wrap.style.height = "auto"; + wrap.className += " CodeMirror-fullscreen"; + document.documentElement.style.overflow = "hidden"; + cm.refresh(); + } + + function setNormal(cm) { + var wrap = cm.getWrapperElement(); + wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, ""); + document.documentElement.style.overflow = ""; + var info = cm.state.fullScreenRestore; + wrap.style.width = info.width; wrap.style.height = info.height; + window.scrollTo(info.scrollLeft, info.scrollTop); + cm.refresh(); + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/panel.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/panel.js index 6bae1e4..29f7e0b 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/panel.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/panel.js @@ -1,5 +1,133 @@ -'use strict';(function(g){"object"==typeof exports&&"object"==typeof module?g(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],g):g(CodeMirror)})(function(g){function f(b,a,c,d){this.cm=b;this.node=a;this.options=c;this.height=d;this.cleared=!1}function k(b){var a=b.getWrapperElement(),c=window.getComputedStyle?window.getComputedStyle(a):a.currentStyle,d=parseInt(c.height),e=b.state.panels={setHeight:a.style.height,panels:[],wrapper:document.createElement("div")}; -a.parentNode.insertBefore(e.wrapper,a);c=b.hasFocus();e.wrapper.appendChild(a);c&&b.focus();b._setSize=b.setSize;null!=d&&(b.setSize=function(a,c){c||(c=e.wrapper.offsetHeight);e.setHeight=c;if("number"!=typeof c){var f=/^(\d+\.?\d*)px$/.exec(c);f?c=Number(f[1]):(e.wrapper.style.height=c,c=e.wrapper.offsetHeight)}f=c-e.panels.map(function(a){return a.node.getBoundingClientRect().height}).reduce(function(a,b){return a+b},0);b._setSize(a,f);d=c})}function h(b,a){for(a=a.nextSibling;a;a=a.nextSibling)if(a== -b.getWrapperElement())return!0;return!1}g.defineExtension("addPanel",function(b,a){a=a||{};this.state.panels||k(this);var c=this.state.panels,d=c.wrapper,e=this.getWrapperElement(),g=a.replace instanceof f&&!a.replace.cleared;a.after instanceof f&&!a.after.cleared?d.insertBefore(b,a.before.node.nextSibling):a.before instanceof f&&!a.before.cleared?d.insertBefore(b,a.before.node):g?(d.insertBefore(b,a.replace.node),a.replace.clear(!0)):"bottom"==a.position?d.appendChild(b):"before-bottom"==a.position? -d.insertBefore(b,e.nextSibling):"after-top"==a.position?d.insertBefore(b,e):d.insertBefore(b,d.firstChild);d=a&&a.height||b.offsetHeight;e=new f(this,b,a,d);c.panels.push(e);this.setSize();a.stable&&h(this,b)&&this.scrollTo(null,this.getScrollInfo().top+d);return e});f.prototype.clear=function(b){if(!this.cleared){this.cleared=!0;var a=this.cm.state.panels;a.panels.splice(a.panels.indexOf(this),1);this.cm.setSize();this.options.stable&&h(this.cm,this.node)&&this.cm.scrollTo(null,this.cm.getScrollInfo().top- -this.height);a.wrapper.removeChild(this.node);if(0==a.panels.length&&!b){b=this.cm;a=b.state.panels;b.state.panels=null;var c=b.getWrapperElement();a.wrapper.parentNode.replaceChild(c,a.wrapper);c.style.height=a.setHeight;b.setSize=b._setSize;b.setSize()}}};f.prototype.changed=function(){this.height=this.node.getBoundingClientRect().height;this.cm.setSize()}}); +// 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) { + CodeMirror.defineExtension("addPanel", function (node, options) { + options = options || {}; + + if (!this.state.panels) initPanels(this); + + var info = this.state.panels; + var wrapper = info.wrapper; + var cmWrapper = this.getWrapperElement(); + var replace = options.replace instanceof Panel && !options.replace.cleared; + + if (options.after instanceof Panel && !options.after.cleared) { + wrapper.insertBefore(node, options.before.node.nextSibling); + } else if (options.before instanceof Panel && !options.before.cleared) { + wrapper.insertBefore(node, options.before.node); + } else if (replace) { + wrapper.insertBefore(node, options.replace.node); + options.replace.clear(true); + } else if (options.position == "bottom") { + wrapper.appendChild(node); + } else if (options.position == "before-bottom") { + wrapper.insertBefore(node, cmWrapper.nextSibling); + } else if (options.position == "after-top") { + wrapper.insertBefore(node, cmWrapper); + } else { + wrapper.insertBefore(node, wrapper.firstChild); + } + + var height = (options && options.height) || node.offsetHeight; + + var panel = new Panel(this, node, options, height); + info.panels.push(panel); + + this.setSize(); + if (options.stable && isAtTop(this, node)) + this.scrollTo(null, this.getScrollInfo().top + height); + + return panel; + }); + + function Panel(cm, node, options, height) { + this.cm = cm; + this.node = node; + this.options = options; + this.height = height; + this.cleared = false; + } + + /* when skipRemove is true, clear() was called from addPanel(). + * Thus removePanels() should not be called (issue 5518) */ + Panel.prototype.clear = function (skipRemove) { + if (this.cleared) return; + this.cleared = true; + var info = this.cm.state.panels; + info.panels.splice(info.panels.indexOf(this), 1); + this.cm.setSize(); + if (this.options.stable && isAtTop(this.cm, this.node)) + this.cm.scrollTo(null, this.cm.getScrollInfo().top - this.height) + info.wrapper.removeChild(this.node); + if (info.panels.length == 0 && !skipRemove) removePanels(this.cm); + }; + + Panel.prototype.changed = function () { + this.height = this.node.getBoundingClientRect().height; + this.cm.setSize(); + }; + + function initPanels(cm) { + var wrap = cm.getWrapperElement() + var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle; + var height = parseInt(style.height); + var info = cm.state.panels = { + setHeight: wrap.style.height, + panels: [], + wrapper: document.createElement("div") + }; + var hasFocus = cm.hasFocus(), scrollPos = cm.getScrollInfo() + wrap.parentNode.insertBefore(info.wrapper, wrap); + info.wrapper.appendChild(wrap); + cm.scrollTo(scrollPos.left, scrollPos.top) + if (hasFocus) cm.focus(); + + cm._setSize = cm.setSize; + if (height != null) cm.setSize = function (width, newHeight) { + if (!newHeight) newHeight = info.wrapper.offsetHeight; + info.setHeight = newHeight; + if (typeof newHeight != "number") { + var px = /^(\d+\.?\d*)px$/.exec(newHeight); + if (px) { + newHeight = Number(px[1]); + } else { + info.wrapper.style.height = newHeight; + newHeight = info.wrapper.offsetHeight; + } + } + var editorheight = newHeight - info.panels + .map(function (p) { return p.node.getBoundingClientRect().height; }) + .reduce(function (a, b) { return a + b; }, 0); + cm._setSize(width, editorheight); + height = newHeight; + }; + } + + function removePanels(cm) { + var info = cm.state.panels; + cm.state.panels = null; + + var wrap = cm.getWrapperElement() + var hasFocus = cm.hasFocus(), scrollPos = cm.getScrollInfo() + info.wrapper.parentNode.replaceChild(wrap, info.wrapper); + cm.scrollTo(scrollPos.left, scrollPos.top) + if (hasFocus) cm.focus(); + wrap.style.height = info.setHeight; + cm.setSize = cm._setSize; + cm.setSize(); + } + + function isAtTop(cm, dom) { + for (var sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling) + if (sibling == cm.getWrapperElement()) return true + return false + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/placeholder.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/placeholder.js index 9ee18ec..cfb8341 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/placeholder.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/placeholder.js @@ -1,3 +1,78 @@ -'use strict';(function(d){"object"==typeof exports&&"object"==typeof module?d(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],d):d(CodeMirror)})(function(d){function f(a){a.state.placeholder&&(a.state.placeholder.parentNode.removeChild(a.state.placeholder),a.state.placeholder=null)}function h(a){f(a);var c=a.state.placeholder=document.createElement("pre");c.style.cssText="height: 0; overflow: visible";c.style.direction=a.getOption("direction"); -c.className="CodeMirror-placeholder CodeMirror-line-like";var b=a.getOption("placeholder");"string"==typeof b&&(b=document.createTextNode(b));c.appendChild(b);a.display.lineSpace.insertBefore(c,a.display.lineSpace.firstChild)}function g(a){k(a)&&h(a)}function e(a){var c=a.getWrapperElement(),b=k(a);c.className=c.className.replace(" CodeMirror-empty","")+(b?" CodeMirror-empty":"");b?h(a):f(a)}function k(a){return 1===a.lineCount()&&""===a.getLine(0)}d.defineOption("placeholder","",function(a,c,b){b= -b&&b!=d.Init;c&&!b?(a.on("blur",g),a.on("change",e),a.on("swapDoc",e),e(a)):!c&&b&&(a.off("blur",g),a.off("change",e),a.off("swapDoc",e),f(a),b=a.getWrapperElement(),b.className=b.className.replace(" CodeMirror-empty",""));c&&!a.hasFocus()&&g(a)})}); +// 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) { + CodeMirror.defineOption("placeholder", "", function(cm, val, old) { + var prev = old && old != CodeMirror.Init; + if (val && !prev) { + cm.on("blur", onBlur); + cm.on("change", onChange); + cm.on("swapDoc", onChange); + CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = function() { onComposition(cm) }) + onChange(cm); + } else if (!val && prev) { + cm.off("blur", onBlur); + cm.off("change", onChange); + cm.off("swapDoc", onChange); + CodeMirror.off(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose) + clearPlaceholder(cm); + var wrapper = cm.getWrapperElement(); + wrapper.className = wrapper.className.replace(" CodeMirror-empty", ""); + } + + if (val && !cm.hasFocus()) onBlur(cm); + }); + + function clearPlaceholder(cm) { + if (cm.state.placeholder) { + cm.state.placeholder.parentNode.removeChild(cm.state.placeholder); + cm.state.placeholder = null; + } + } + function setPlaceholder(cm) { + clearPlaceholder(cm); + var elt = cm.state.placeholder = document.createElement("pre"); + elt.style.cssText = "height: 0; overflow: visible"; + elt.style.direction = cm.getOption("direction"); + elt.className = "CodeMirror-placeholder CodeMirror-line-like"; + var placeHolder = cm.getOption("placeholder") + if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder) + elt.appendChild(placeHolder) + cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild); + } + + function onComposition(cm) { + setTimeout(function() { + var empty = false + if (cm.lineCount() == 1) { + var input = cm.getInputField() + empty = input.nodeName == "TEXTAREA" ? !cm.getLine(0).length + : !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent) + } + if (empty) setPlaceholder(cm) + else clearPlaceholder(cm) + }, 20) + } + + function onBlur(cm) { + if (isEmpty(cm)) setPlaceholder(cm); + } + function onChange(cm) { + var wrapper = cm.getWrapperElement(), empty = isEmpty(cm); + wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : ""); + + if (empty) setPlaceholder(cm); + else clearPlaceholder(cm); + } + + function isEmpty(cm) { + return (cm.lineCount() === 1) && (cm.getLine(0) === ""); + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/rulers.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/rulers.js index 9eddd08..0bb83bb 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/rulers.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/display/rulers.js @@ -1,3 +1,51 @@ -'use strict';(function(c){"object"==typeof exports&&"object"==typeof module?c(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){function e(a){a.state.rulerDiv.textContent="";var g=a.getOption("rulers"),e=a.defaultCharWidth(),k=a.charCoords(c.Pos(a.firstLine(),0),"div").left;a.state.rulerDiv.style.minHeight=a.display.scroller.offsetHeight+30+"px";for(var f=0;fa;a++)b.execCommand("goCharRight");else if("surround"==l){var c=b.getSelections();for(a=0;a",triples:"",explode:"[]{}"},k=d.Pos;d.defineOption("autoCloseBrackets",!1,function(b,a,c){c&&c!=d.Init&&(b.removeKeyMap(m),b.state.closeBrackets= -null);a&&(y(p(a,"pairs")),b.state.closeBrackets=a,b.addKeyMap(m))});var m={Backspace:function(b){var a=t(b);if(!a||b.getOption("disableInput"))return d.Pass;var c=p(a,"pairs");a=b.listSelections();for(var f=0;f", + triples: "", + explode: "[]{}" + }; + + var Pos = CodeMirror.Pos; + + CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + cm.removeKeyMap(keyMap); + cm.state.closeBrackets = null; + } + if (val) { + ensureBound(getOption(val, "pairs")) + cm.state.closeBrackets = val; + cm.addKeyMap(keyMap); + } + }); + + function getOption(conf, name) { + if (name == "pairs" && typeof conf == "string") return conf; + if (typeof conf == "object" && conf[name] != null) return conf[name]; + return defaults[name]; + } + + var keyMap = {Backspace: handleBackspace, Enter: handleEnter}; + function ensureBound(chars) { + for (var i = 0; i < chars.length; i++) { + var ch = chars.charAt(i), key = "'" + ch + "'" + if (!keyMap[key]) keyMap[key] = handler(ch) + } + } + ensureBound(defaults.pairs + "`") + + function handler(ch) { + return function(cm) { return handleChar(cm, ch); }; + } + + function getConfig(cm) { + var deflt = cm.state.closeBrackets; + if (!deflt || deflt.override) return deflt; + var mode = cm.getModeAt(cm.getCursor()); + return mode.closeBrackets || deflt; + } + + function handleBackspace(cm) { + var conf = getConfig(cm); + if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass; + + var pairs = getOption(conf, "pairs"); + var ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + if (!ranges[i].empty()) return CodeMirror.Pass; + var around = charsAround(cm, ranges[i].head); + if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass; + } + for (var i = ranges.length - 1; i >= 0; i--) { + var cur = ranges[i].head; + cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete"); + } + } + + function handleEnter(cm) { + var conf = getConfig(cm); + var explode = conf && getOption(conf, "explode"); + if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass; + + var ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + if (!ranges[i].empty()) return CodeMirror.Pass; + var around = charsAround(cm, ranges[i].head); + if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass; + } + cm.operation(function() { + var linesep = cm.lineSeparator() || "\n"; + cm.replaceSelection(linesep + linesep, null); + moveSel(cm, -1) + ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + var line = ranges[i].head.line; + cm.indentLine(line, null, true); + cm.indentLine(line + 1, null, true); + } + }); + } + + function moveSel(cm, dir) { + var newRanges = [], ranges = cm.listSelections(), primary = 0 + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i] + if (range.head == cm.getCursor()) primary = i + var pos = range.head.ch || dir > 0 ? {line: range.head.line, ch: range.head.ch + dir} : {line: range.head.line - 1} + newRanges.push({anchor: pos, head: pos}) + } + cm.setSelections(newRanges, primary) + } + + function contractSelection(sel) { + var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0; + return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)), + head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))}; + } + + function handleChar(cm, ch) { + var conf = getConfig(cm); + if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass; + + var pairs = getOption(conf, "pairs"); + var pos = pairs.indexOf(ch); + if (pos == -1) return CodeMirror.Pass; + + var closeBefore = getOption(conf,"closeBefore"); + + var triples = getOption(conf, "triples"); + + var identical = pairs.charAt(pos + 1) == ch; + var ranges = cm.listSelections(); + var opening = pos % 2 == 0; + + var type; + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i], cur = range.head, curType; + var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1)); + if (opening && !range.empty()) { + curType = "surround"; + } else if ((identical || !opening) && next == ch) { + if (identical && stringStartsAfter(cm, cur)) + curType = "both"; + else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch) + curType = "skipThree"; + else + curType = "skip"; + } else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 && + cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) { + if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass; + curType = "addFour"; + } else if (identical) { + var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) + if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; + else return CodeMirror.Pass; + } else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) { + curType = "both"; + } else { + return CodeMirror.Pass; + } + if (!type) type = curType; + else if (type != curType) return CodeMirror.Pass; + } + + var left = pos % 2 ? pairs.charAt(pos - 1) : ch; + var right = pos % 2 ? ch : pairs.charAt(pos + 1); + cm.operation(function() { + if (type == "skip") { + moveSel(cm, 1) + } else if (type == "skipThree") { + moveSel(cm, 3) + } else if (type == "surround") { + var sels = cm.getSelections(); + for (var i = 0; i < sels.length; i++) + sels[i] = left + sels[i] + right; + cm.replaceSelections(sels, "around"); + sels = cm.listSelections().slice(); + for (var i = 0; i < sels.length; i++) + sels[i] = contractSelection(sels[i]); + cm.setSelections(sels); + } else if (type == "both") { + cm.replaceSelection(left + right, null); + cm.triggerElectric(left + right); + moveSel(cm, -1) + } else if (type == "addFour") { + cm.replaceSelection(left + left + left + left, "before"); + moveSel(cm, 1) + } + }); + } + + function charsAround(cm, pos) { + var str = cm.getRange(Pos(pos.line, pos.ch - 1), + Pos(pos.line, pos.ch + 1)); + return str.length == 2 ? str : null; + } + + function stringStartsAfter(cm, pos) { + var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1)) + return /\bstring/.test(token.type) && token.start == pos.ch && + (pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos))) + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/closetag.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/closetag.js index c2585f2..7c22a50 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/closetag.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/closetag.js @@ -1,7 +1,185 @@ -'use strict';(function(g){"object"==typeof exports&&"object"==typeof module?g(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],g):g(CodeMirror)})(function(g){function v(a){if(a.getOption("disableInput"))return g.Pass;for(var e=a.listSelections(),c=[],f=a.getOption("autoCloseTags"),k=0;kd.ch&&(l=l.slice(0,l.length-b.end+d.ch));var t=l.toLowerCase();if(!l||"string"==b.type&&(b.end!=d.ch||!/["']/.test(b.string.charAt(b.string.length-1))||1==b.string.length)||"tag"==b.type&&h.close||b.string.indexOf("/")==d.ch-b.start-1||q&&-1",newPos:g.Pos(d.line,d.ch+2)}:(b=p&&-1"+(b?"\n\n":"")+"",newPos:b?g.Pos(d.line+1,0):g.Pos(d.line,d.ch+1)})}f="object"==typeof f&&f.dontIndentOnAutoClose;for(k=e.length-1;0<=k;k--)d=c[k],a.replaceRange(d.text,e[k].head,e[k].anchor,"+insert"),l=a.listSelections().slice(0),l[k]={head:d.newPos,anchor:d.newPos},a.setSelections(l),!f&&d.indent&&(a.indentLine(d.newPos.line,null,!0), -a.indentLine(d.newPos.line+1,null,!0))}function q(a,e){var c=a.listSelections(),f=[],k=e?"/":""!=a.getLine(m.line).charAt(n.end)&&(h+=">");f[b]=h}a.replaceSelections(f);c=a.listSelections();if(!d)for(b=0;b'"]=function(a){return v(a)};a.addKeyMap(c)}});var w="area base br col command embed hr img input keygen link meta param source track wbr".split(" "),x="applet blockquote body button div dl fieldset form frameset h1 h2 h3 h4 h5 h6 head html iframe layer legend object ol p select table ul".split(" ");g.commands.closeTag=function(a){return q(a)}}); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +/** + * Tag-closer extension for CodeMirror. + * + * This extension adds an "autoCloseTags" option that can be set to + * either true to get the default behavior, or an object to further + * configure its behavior. + * + * These are supported options: + * + * `whenClosing` (default true) + * Whether to autoclose when the '/' of a closing tag is typed. + * `whenOpening` (default true) + * Whether to autoclose the tag when the final '>' of an opening + * tag is typed. + * `dontCloseTags` (default is empty tags for HTML, none for XML) + * An array of tag names that should not be autoclosed. + * `indentTags` (default is block tags for HTML, none for XML) + * An array of tag names that should, when opened, cause a + * blank line to be added inside the tag, and the blank line and + * closing line to be indented. + * `emptyTags` (default is none) + * An array of XML tag names that should be autoclosed with '/>'. + * + * See demos/closetag.html for a usage example. + */ + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../fold/xml-fold")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../fold/xml-fold"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) { + if (old != CodeMirror.Init && old) + cm.removeKeyMap("autoCloseTags"); + if (!val) return; + var map = {name: "autoCloseTags"}; + if (typeof val != "object" || val.whenClosing !== false) + map["'/'"] = function(cm) { return autoCloseSlash(cm); }; + if (typeof val != "object" || val.whenOpening !== false) + map["'>'"] = function(cm) { return autoCloseGT(cm); }; + cm.addKeyMap(map); + }); + + var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", + "source", "track", "wbr"]; + var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4", + "h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"]; + + function autoCloseGT(cm) { + if (cm.getOption("disableInput")) return CodeMirror.Pass; + var ranges = cm.listSelections(), replacements = []; + var opt = cm.getOption("autoCloseTags"); + for (var i = 0; i < ranges.length; i++) { + if (!ranges[i].empty()) return CodeMirror.Pass; + var pos = ranges[i].head, tok = cm.getTokenAt(pos); + var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state; + var tagInfo = inner.mode.xmlCurrentTag && inner.mode.xmlCurrentTag(state) + var tagName = tagInfo && tagInfo.name + if (!tagName) return CodeMirror.Pass + + var html = inner.mode.configuration == "html"; + var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose); + var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent); + + if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch); + var lowerTagName = tagName.toLowerCase(); + // Don't process the '>' at the end of an end-tag or self-closing tag + if (!tagName || + tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) || + tok.type == "tag" && tagInfo.close || + tok.string.indexOf("/") == (pos.ch - tok.start - 1) || // match something like + dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 || + closingTagExists(cm, inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state) || [], tagName, pos, true)) + return CodeMirror.Pass; + + var emptyTags = typeof opt == "object" && opt.emptyTags; + if (emptyTags && indexOf(emptyTags, tagName) > -1) { + replacements[i] = { text: "/>", newPos: CodeMirror.Pos(pos.line, pos.ch + 2) }; + continue; + } + + var indent = indentTags && indexOf(indentTags, lowerTagName) > -1; + replacements[i] = {indent: indent, + text: ">" + (indent ? "\n\n" : "") + "", + newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)}; + } + + var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnAutoClose); + for (var i = ranges.length - 1; i >= 0; i--) { + var info = replacements[i]; + cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert"); + var sel = cm.listSelections().slice(0); + sel[i] = {head: info.newPos, anchor: info.newPos}; + cm.setSelections(sel); + if (!dontIndentOnAutoClose && info.indent) { + cm.indentLine(info.newPos.line, null, true); + cm.indentLine(info.newPos.line + 1, null, true); + } + } + } + + function autoCloseCurrent(cm, typingSlash) { + var ranges = cm.listSelections(), replacements = []; + var head = typingSlash ? "/" : "") replacement += ">"; + replacements[i] = replacement; + } + cm.replaceSelections(replacements); + ranges = cm.listSelections(); + if (!dontIndentOnAutoClose) { + for (var i = 0; i < ranges.length; i++) + if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line) + cm.indentLine(ranges[i].head.line); + } + } + + function autoCloseSlash(cm) { + if (cm.getOption("disableInput")) return CodeMirror.Pass; + return autoCloseCurrent(cm, true); + } + + CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); }; + + function indexOf(collection, elt) { + if (collection.indexOf) return collection.indexOf(elt); + for (var i = 0, e = collection.length; i < e; ++i) + if (collection[i] == elt) return i; + return -1; + } + + // If xml-fold is loaded, we use its functionality to try and verify + // whether a given tag is actually unclosed. + function closingTagExists(cm, context, tagName, pos, newTag) { + if (!CodeMirror.scanForClosingTag) return false; + var end = Math.min(cm.lastLine() + 1, pos.line + 500); + var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end); + if (!nextClose || nextClose.tag != tagName) return false; + // If the immediate wrapping context contains onCx instances of + // the same tag, a closing tag only exists if there are at least + // that many closing tags of that type following. + var onCx = newTag ? 1 : 0 + for (var i = context.length - 1; i >= 0; i--) { + if (context[i] == tagName) ++onCx + else break + } + pos = nextClose.to; + for (var i = 1; i < onCx; i++) { + var next = CodeMirror.scanForClosingTag(cm, pos, null, end); + if (!next || next.tag != tagName) return false; + pos = next.to; + } + return true; + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/continuelist.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/continuelist.js index 57abb41..6ec6501 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/continuelist.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/continuelist.js @@ -1,3 +1,101 @@ -'use strict';(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){var n=/^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,x=/^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,y=/[*+-]\s/;f.commands.newlineAndIndentContinueMarkdownList=function(b){if(b.getOption("disableInput"))return f.Pass;for(var q=b.listSelections(),r=[],h=0;h\s*$/.test(e),d=!/>\s*$/.test(e),(a||d)&&b.replaceRange("",{line:c.line,ch:0},{line:c.line,ch:c.ch+1}),r[h]="\n";else if(d=a[1],e=a[5],a=(g=!(y.test(a[2])||0<=a[2].indexOf(">")))? -parseInt(a[3],10)+1+a[4]:a[2].replace("x"," "),r[h]="\n"+d+a+e,g)a:{a=b;c=c.line;e=d=0;g=n.exec(a.getLine(c));l=g[1];do{d+=1;var t=c+d,u=a.getLine(t),k=n.exec(u);if(k){var p=k[1],v=parseInt(g[3],10)+d-e,m=parseInt(k[3],10),w=m;if(l!==p||isNaN(m)){if(l.length>p.length)break a;if(l.lengthm&&(w=v+1),a.replaceRange(u.replace(n,p+w+k[4]+k[5]),{line:t,ch:0},{line:t,ch:u.length})}}while(k)}}b.replaceSelections(r)}}); +// 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"; + + var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, + emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, + unorderedListRE = /[*+-]\s/; + + CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) { + if (cm.getOption("disableInput")) return CodeMirror.Pass; + var ranges = cm.listSelections(), replacements = []; + for (var i = 0; i < ranges.length; i++) { + var pos = ranges[i].head; + + // If we're not in Markdown mode, fall back to normal newlineAndIndent + var eolState = cm.getStateAfter(pos.line); + var inner = CodeMirror.innerMode(cm.getMode(), eolState); + if (inner.mode.name !== "markdown") { + cm.execCommand("newlineAndIndent"); + return; + } else { + eolState = inner.state; + } + + var inList = eolState.list !== false; + var inQuote = eolState.quote !== 0; + + var line = cm.getLine(pos.line), match = listRE.exec(line); + var cursorBeforeBullet = /^\s*$/.test(line.slice(0, pos.ch)); + if (!ranges[i].empty() || (!inList && !inQuote) || !match || cursorBeforeBullet) { + cm.execCommand("newlineAndIndent"); + return; + } + if (emptyListRE.test(line)) { + var endOfQuote = inQuote && />\s*$/.test(line) + var endOfList = !/>\s*$/.test(line) + if (endOfQuote || endOfList) cm.replaceRange("", { + line: pos.line, ch: 0 + }, { + line: pos.line, ch: pos.ch + 1 + }); + replacements[i] = "\n"; + } else { + var indent = match[1], after = match[5]; + var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0); + var bullet = numbered ? (parseInt(match[3], 10) + 1) + match[4] : match[2].replace("x", " "); + replacements[i] = "\n" + indent + bullet + after; + + if (numbered) incrementRemainingMarkdownListNumbers(cm, pos); + } + } + + cm.replaceSelections(replacements); + }; + + // Auto-updating Markdown list numbers when a new item is added to the + // middle of a list + function incrementRemainingMarkdownListNumbers(cm, pos) { + var startLine = pos.line, lookAhead = 0, skipCount = 0; + var startItem = listRE.exec(cm.getLine(startLine)), startIndent = startItem[1]; + + do { + lookAhead += 1; + var nextLineNumber = startLine + lookAhead; + var nextLine = cm.getLine(nextLineNumber), nextItem = listRE.exec(nextLine); + + if (nextItem) { + var nextIndent = nextItem[1]; + var newNumber = (parseInt(startItem[3], 10) + lookAhead - skipCount); + var nextNumber = (parseInt(nextItem[3], 10)), itemNumber = nextNumber; + + if (startIndent === nextIndent && !isNaN(nextNumber)) { + if (newNumber === nextNumber) itemNumber = nextNumber + 1; + if (newNumber > nextNumber) itemNumber = newNumber + 1; + cm.replaceRange( + nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]), + { + line: nextLineNumber, ch: 0 + }, { + line: nextLineNumber, ch: nextLine.length + }); + } else { + if (startIndent.length > nextIndent.length) return; + // This doesn't run if the next line immediately indents, as it is + // not clear of the users intention (new indented item or same level) + if ((startIndent.length < nextIndent.length) && (lookAhead === 1)) return; + skipCount += 1; + } + } + } while (nextItem); + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/matchbrackets.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/matchbrackets.js index 5b257df..43dc884 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/matchbrackets.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/matchbrackets.js @@ -1,6 +1,160 @@ -'use strict';(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)})(function(e){function q(a,c,b){var k=a.getLineHandle(c.line),d=c.ch-1,g=b&&b.afterCursor;null==g&&(g=/(^| )cm-fat-cursor($| )/.test(a.getWrapperElement().className));var h=b&&b.bracketRegex||/[(){}[\]]/;k=!g&&0<=d&&h.test(k.text.charAt(d))&&t[k.text.charAt(d)]||h.test(k.text.charAt(d+1))&&t[k.text.charAt(++d)]; -if(!k)return null;g=">"==k.charAt(1)?1:-1;if(b&&b.strict&&0g))for(e==c.line&&(n=c.ch-(0>b?1:0));n!=q;n+=b){var r=p.charAt(n);if(d.test(r)&&(void 0===k||a.getTokenTypeAt(m(e,n+1))==k)){var l=t[r];if(l&&">"==l.charAt(1)==0document.documentMode),m=e.Pos,t={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};e.defineOption("matchBrackets",!1,function(a,c,b){b&&b!=e.Init&&(a.off("cursorActivity",v),a.state.matchBrackets&&a.state.matchBrackets.currentlyHighlighted&&(a.state.matchBrackets.currentlyHighlighted(), -a.state.matchBrackets.currentlyHighlighted=null));c&&(a.state.matchBrackets="object"==typeof c?c:{},a.on("cursorActivity",v))});e.defineExtension("matchBrackets",function(){u(this,!0)});e.defineExtension("findMatchingBracket",function(a,c,b){if(b||"boolean"==typeof c)b?(b.strict=c,c=b):c=c?{strict:!0}:null;return q(this,a,c)});e.defineExtension("scanForBracket",function(a,c,b,e){return l(this,a,c,b,e)})}); +// 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) { + var ie_lt8 = /MSIE \d/.test(navigator.userAgent) && + (document.documentMode == null || document.documentMode < 8); + + var Pos = CodeMirror.Pos; + + var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"}; + + function bracketRegex(config) { + return config && config.bracketRegex || /[(){}[\]]/ + } + + function findMatchingBracket(cm, where, config) { + var line = cm.getLineHandle(where.line), pos = where.ch - 1; + var afterCursor = config && config.afterCursor + if (afterCursor == null) + afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className) + var re = bracketRegex(config) + + // A cursor is defined as between two characters, but in in vim command mode + // (i.e. not insert mode), the cursor is visually represented as a + // highlighted box on top of the 2nd character. Otherwise, we allow matches + // from before or after the cursor. + var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) || + re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)]; + if (!match) return null; + var dir = match.charAt(1) == ">" ? 1 : -1; + if (config && config.strict && (dir > 0) != (pos == where.ch)) return null; + var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); + + var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style, config); + if (found == null) return null; + return {from: Pos(where.line, pos), to: found && found.pos, + match: found && found.ch == match.charAt(0), forward: dir > 0}; + } + + // bracketRegex is used to specify which type of bracket to scan + // should be a regexp, e.g. /[[\]]/ + // + // Note: If "where" is on an open bracket, then this bracket is ignored. + // + // Returns false when no bracket was found, null when it reached + // maxScanLines and gave up + function scanForBracket(cm, where, dir, style, config) { + var maxScanLen = (config && config.maxScanLineLength) || 10000; + var maxScanLines = (config && config.maxScanLines) || 1000; + + var stack = []; + var re = bracketRegex(config) + var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) + : Math.max(cm.firstLine() - 1, where.line - maxScanLines); + for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) { + var line = cm.getLine(lineNo); + if (!line) continue; + var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1; + if (line.length > maxScanLen) continue; + if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); + for (; pos != end; pos += dir) { + var ch = line.charAt(pos); + if (re.test(ch) && (style === undefined || + (cm.getTokenTypeAt(Pos(lineNo, pos + 1)) || "") == (style || ""))) { + var match = matching[ch]; + if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch); + else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; + else stack.pop(); + } + } + } + return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null; + } + + function matchBrackets(cm, autoclear, config) { + // Disable brace matching in long lines, since it'll cause hugely slow updates + var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000, + highlightNonMatching = config && config.highlightNonMatching; + var marks = [], ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config); + if (match && (match.match || highlightNonMatching !== false) && cm.getLine(match.from.line).length <= maxHighlightLen) { + var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; + marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); + if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) + marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style})); + } + } + + if (marks.length) { + // Kludge to work around the IE bug from issue #1193, where text + // input stops going to the textarea whenever this fires. + if (ie_lt8 && cm.state.focused) cm.focus(); + + var clear = function() { + cm.operation(function() { + for (var i = 0; i < marks.length; i++) marks[i].clear(); + }); + }; + if (autoclear) setTimeout(clear, 800); + else return clear; + } + } + + function doMatchBrackets(cm) { + cm.operation(function() { + if (cm.state.matchBrackets.currentlyHighlighted) { + cm.state.matchBrackets.currentlyHighlighted(); + cm.state.matchBrackets.currentlyHighlighted = null; + } + cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); + }); + } + + function clearHighlighted(cm) { + if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { + cm.state.matchBrackets.currentlyHighlighted(); + cm.state.matchBrackets.currentlyHighlighted = null; + } + } + + CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + cm.off("cursorActivity", doMatchBrackets); + cm.off("focus", doMatchBrackets) + cm.off("blur", clearHighlighted) + clearHighlighted(cm); + } + if (val) { + cm.state.matchBrackets = typeof val == "object" ? val : {}; + cm.on("cursorActivity", doMatchBrackets); + cm.on("focus", doMatchBrackets) + cm.on("blur", clearHighlighted) + } + }); + + CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);}); + CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){ + // Backwards-compatibility kludge + if (oldConfig || typeof config == "boolean") { + if (!oldConfig) { + config = config ? {strict: true} : null + } else { + oldConfig.strict = config + config = oldConfig + } + } + return findMatchingBracket(this, pos, config) + }); + CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){ + return scanForBracket(this, pos, dir, style, config); + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/matchtags.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/matchtags.js index 3387092..2203d93 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/matchtags.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/matchtags.js @@ -1,3 +1,66 @@ -'use strict';(function(d){"object"==typeof exports&&"object"==typeof module?d(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],d):d(CodeMirror)})(function(d){function f(a){a.state.tagHit&&a.state.tagHit.clear();a.state.tagOther&&a.state.tagOther.clear();a.state.tagHit=a.state.tagOther=null}function e(a){a.state.failedTagMatch=!1;a.operation(function(){f(a);if(!a.somethingSelected()){var b=a.getCursor(), -c=a.getViewport();c.from=Math.min(c.from,b.line);c.to=Math.max(b.line+1,c.to);if(b=d.findMatchingTag(a,b,c))a.state.matchBothTags&&(c="open"==b.at?b.open:b.close)&&(a.state.tagHit=a.markText(c.from,c.to,{className:"CodeMirror-matchingtag"})),(b="close"==b.at?b.open:b.close)?a.state.tagOther=a.markText(b.from,b.to,{className:"CodeMirror-matchingtag"}):a.state.failedTagMatch=!0}})}function g(a){a.state.failedTagMatch&&e(a)}d.defineOption("matchTags",!1,function(a,b,c){c&&c!=d.Init&&(a.off("cursorActivity", -e),a.off("viewportChange",g),f(a));b&&(a.state.matchBothTags="object"==typeof b&&b.bothTags,a.on("cursorActivity",e),a.on("viewportChange",g),e(a))});d.commands.toMatchingTag=function(a){var b=d.findMatchingTag(a,a.getCursor());b&&(b="close"==b.at?b.open:b.close)&&a.extendSelection(b.to,b.from)}}); +// 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"), require("../fold/xml-fold")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../fold/xml-fold"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineOption("matchTags", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + cm.off("cursorActivity", doMatchTags); + cm.off("viewportChange", maybeUpdateMatch); + clear(cm); + } + if (val) { + cm.state.matchBothTags = typeof val == "object" && val.bothTags; + cm.on("cursorActivity", doMatchTags); + cm.on("viewportChange", maybeUpdateMatch); + doMatchTags(cm); + } + }); + + function clear(cm) { + if (cm.state.tagHit) cm.state.tagHit.clear(); + if (cm.state.tagOther) cm.state.tagOther.clear(); + cm.state.tagHit = cm.state.tagOther = null; + } + + function doMatchTags(cm) { + cm.state.failedTagMatch = false; + cm.operation(function() { + clear(cm); + if (cm.somethingSelected()) return; + var cur = cm.getCursor(), range = cm.getViewport(); + range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to); + var match = CodeMirror.findMatchingTag(cm, cur, range); + if (!match) return; + if (cm.state.matchBothTags) { + var hit = match.at == "open" ? match.open : match.close; + if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"}); + } + var other = match.at == "close" ? match.open : match.close; + if (other) + cm.state.tagOther = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"}); + else + cm.state.failedTagMatch = true; + }); + } + + function maybeUpdateMatch(cm) { + if (cm.state.failedTagMatch) doMatchTags(cm); + } + + CodeMirror.commands.toMatchingTag = function(cm) { + var found = CodeMirror.findMatchingTag(cm, cm.getCursor()); + if (found) { + var other = found.at == "close" ? found.open : found.close; + if (other) cm.extendSelection(other.to, other.from); + } + }; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/trailingspace.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/trailingspace.js index d77ac72..c39c310 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/trailingspace.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/edit/trailingspace.js @@ -1 +1,27 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){a.defineOption("showTrailingSpace",!1,function(d,e,b){b==a.Init&&(b=!1);b&&!e?d.removeOverlay("trailingspace"):!b&&e&&d.addOverlay({token:function(a){for(var b=a.string.length,c=b;c&&/\s/.test(a.string.charAt(c-1));--c);if(c>a.pos)return a.pos=c,null;a.pos=b;return"trailingspace"},name:"trailingspace"})})}); +// 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) { + CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) { + if (prev == CodeMirror.Init) prev = false; + if (prev && !val) + cm.removeOverlay("trailingspace"); + else if (!prev && val) + cm.addOverlay({ + token: function(stream) { + for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {} + if (i > stream.pos) { stream.pos = i; return null; } + stream.pos = l; + return "trailingspace"; + }, + name: "trailingspace" + }); + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/brace-fold.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/brace-fold.js index f8554ca..79a331c 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/brace-fold.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/brace-fold.js @@ -1,4 +1,108 @@ -'use strict';(function(d){"object"==typeof exports&&"object"==typeof module?d(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],d):d(CodeMirror)})(function(d){d.registerHelper("fold","brace",function(e,a){function b(h){for(var c=a.ch,b=0;;)if(c=0>=c?-1:f.lastIndexOf(h,c-1),-1==c){if(1==b)break;b=1;c=f.length}else{if(1==b&&cp&&(p=n.length);0>c&&(c=n.length);c=Math.min(p,c);if(c==n.length)break;if(e.getTokenTypeAt(d.Pos(l,c+1))==k)if(c==p)++t;else if(!--t){var q=l;var v=c;break a}++c}if(null!=q&&g!=q)return{from:d.Pos(g,m),to:d.Pos(q,v)}}});d.registerHelper("fold","import",function(e,a){function b(h){if(he.lastLine())return null; -var a=e.getTokenAt(d.Pos(h,1));/\S/.test(a.string)||(a=e.getTokenAt(d.Pos(h,a.end+1)));if("keyword"!=a.type||"import"!=a.string)return null;var b=h;for(h=Math.min(e.lastLine(),h+10);b<=h;++b){var f=e.getLine(b).indexOf(";");if(-1!=f)return{startCh:a.end,end:d.Pos(b,f)}}}a=a.line;var g=b(a),f;if(!g||b(a-1)||(f=b(a-2))&&f.end.line==a-1)return null;for(f=g.end;;){var k=b(f.line+1);if(null==k)break;f=k.end}return{from:e.clipPos(d.Pos(a,g.startCh+1)),to:f}});d.registerHelper("fold","include",function(e, -a){function b(a){if(ae.lastLine())return null;var b=e.getTokenAt(d.Pos(a,1));/\S/.test(b.string)||(b=e.getTokenAt(d.Pos(a,b.end+1)));if("meta"==b.type&&"#include"==b.string.slice(0,8))return b.start+8}a=a.line;var g=b(a);if(null==g||null!=b(a-1))return null;for(var f=a;null!=b(f+1);)++f;return{from:d.Pos(a,g+1),to:e.clipPos(d.Pos(f))}})}); +// 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"; + +CodeMirror.registerHelper("fold", "brace", function(cm, start) { + var line = start.line, lineText = cm.getLine(line); + var tokenType; + + function findOpening(openCh) { + for (var at = start.ch, pass = 0;;) { + var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1); + if (found == -1) { + if (pass == 1) break; + pass = 1; + at = lineText.length; + continue; + } + if (pass == 1 && found < start.ch) break; + tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)); + if (!/^(comment|string)/.test(tokenType)) return found + 1; + at = found - 1; + } + } + + var startBrace = findOpening("{"), startBracket = findOpening("[") + var startToken, endToken, startCh + if (startBrace != null && (startBracket == null || startBracket > startBrace)) { + startCh = startBrace; startToken = "{"; endToken = "}" + } else if (startBracket != null) { + startCh = startBracket; startToken = "["; endToken = "]" + } else { + return + } + + var count = 1, lastLine = cm.lastLine(), end, endCh; + outer: for (var i = line; i <= lastLine; ++i) { + var text = cm.getLine(i), pos = i == line ? startCh : 0; + for (;;) { + var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos); + if (nextOpen < 0) nextOpen = text.length; + if (nextClose < 0) nextClose = text.length; + pos = Math.min(nextOpen, nextClose); + if (pos == text.length) break; + if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) { + if (pos == nextOpen) ++count; + else if (!--count) { end = i; endCh = pos; break outer; } + } + ++pos; + } + } + if (end == null || line == end) return; + return {from: CodeMirror.Pos(line, startCh), + to: CodeMirror.Pos(end, endCh)}; +}); + +CodeMirror.registerHelper("fold", "import", function(cm, start) { + function hasImport(line) { + if (line < cm.firstLine() || line > cm.lastLine()) return null; + var start = cm.getTokenAt(CodeMirror.Pos(line, 1)); + if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1)); + if (start.type != "keyword" || start.string != "import") return null; + // Now find closing semicolon, return its position + for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) { + var text = cm.getLine(i), semi = text.indexOf(";"); + if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)}; + } + } + + var startLine = start.line, has = hasImport(startLine), prev; + if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1)) + return null; + for (var end = has.end;;) { + var next = hasImport(end.line + 1); + if (next == null) break; + end = next.end; + } + return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end}; +}); + +CodeMirror.registerHelper("fold", "include", function(cm, start) { + function hasInclude(line) { + if (line < cm.firstLine() || line > cm.lastLine()) return null; + var start = cm.getTokenAt(CodeMirror.Pos(line, 1)); + if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1)); + if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8; + } + + var startLine = start.line, has = hasInclude(startLine); + if (has == null || hasInclude(startLine - 1) != null) return null; + for (var end = startLine;;) { + var next = hasInclude(end + 1); + if (next == null) break; + ++end; + } + return {from: CodeMirror.Pos(startLine, has + 1), + to: cm.clipPos(CodeMirror.Pos(end))}; +}); + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/comment-fold.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/comment-fold.js index 67edeb9..836101d 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/comment-fold.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/comment-fold.js @@ -1,2 +1,59 @@ -'use strict';(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){b.registerGlobalHelper("fold","comment",function(b){return b.blockCommentStart&&b.blockCommentEnd},function(g,d){var e=g.getModeAt(d),m=e.blockCommentStart;e=e.blockCommentEnd;if(m&&e){for(var f=d.line,h=g.getLine(f),a=d.ch,k=0;;)if(a=0>=a?-1:h.lastIndexOf(m,a-1),-1==a){if(1==k)return;k=1; -a=h.length}else{if(1==k&&an&&(n=l.length);0>c&&(c=l.length);c=Math.min(n,c);if(c==l.length)break;if(c==n)++h;else if(!--h){var p=a;var q=c;break a}++c}if(null!=p&&(f!=p||q!=d))return{from:b.Pos(f,d),to:b.Pos(p,q)}}})}); +// 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"; + +CodeMirror.registerGlobalHelper("fold", "comment", function(mode) { + return mode.blockCommentStart && mode.blockCommentEnd; +}, function(cm, start) { + var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd; + if (!startToken || !endToken) return; + var line = start.line, lineText = cm.getLine(line); + + var startCh; + for (var at = start.ch, pass = 0;;) { + var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1); + if (found == -1) { + if (pass == 1) return; + pass = 1; + at = lineText.length; + continue; + } + if (pass == 1 && found < start.ch) return; + if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) && + (found == 0 || lineText.slice(found - endToken.length, found) == endToken || + !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) { + startCh = found + startToken.length; + break; + } + at = found - 1; + } + + var depth = 1, lastLine = cm.lastLine(), end, endCh; + outer: for (var i = line; i <= lastLine; ++i) { + var text = cm.getLine(i), pos = i == line ? startCh : 0; + for (;;) { + var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos); + if (nextOpen < 0) nextOpen = text.length; + if (nextClose < 0) nextClose = text.length; + pos = Math.min(nextOpen, nextClose); + if (pos == text.length) break; + if (pos == nextOpen) ++depth; + else if (!--depth) { end = i; endCh = pos; break outer; } + ++pos; + } + } + if (end == null || line == end && endCh == startCh) return; + return {from: CodeMirror.Pos(line, startCh), + to: CodeMirror.Pos(end, endCh)}; +}); + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldcode.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldcode.js index 6241cfa..887df3f 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldcode.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldcode.js @@ -1,5 +1,157 @@ -'use strict';(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function h(a,c,d,l){function e(d){var b=h(a,c);if(!b||b.to.line-b.from.linea.firstLine();)c=b.Pos(c.line-1,0),f=e(!1);if(f&&!f.cleared&&"unfold"!==l){var m=p(a,d,f);b.on(m,"mousedown",function(a){n.clear();b.e_preventDefault(a)});var n=a.markText(f.from,f.to,{replacedWith:m,clearOnEnter:g(a,d,"clearOnEnter"),__isFold:!0});n.on("clear",function(c,d){b.signal(a,"unfold",a,c,d)});b.signal(a,"fold",a,f.from,f.to)}}function p(a,c,d){a=g(a,c,"widget");"function"==typeof a&&(a=a(d.from, -d.to));"string"==typeof a?(d=document.createTextNode(a),a=document.createElement("span"),a.appendChild(d),a.className="CodeMirror-foldmarker"):a&&(a=a.cloneNode(!0));return a}function g(a,c,d){return c&&void 0!==c[d]?c[d]:(a=a.options.foldOptions)&&void 0!==a[d]?a[d]:k[d]}b.newFoldFunction=function(a,c){return function(d,b){h(d,b,{rangeFinder:a,widget:c})}};b.defineExtension("foldCode",function(a,c,d){h(this,a,c,d)});b.defineExtension("isFolded",function(a){a=this.findMarksAt(a);for(var c=0;c cm.firstLine()) { + pos = CodeMirror.Pos(pos.line - 1, 0); + range = getRange(false); + } + if (!range || range.cleared || force === "unfold") return; + + var myWidget = makeWidget(cm, options, range); + CodeMirror.on(myWidget, "mousedown", function(e) { + myRange.clear(); + CodeMirror.e_preventDefault(e); + }); + var myRange = cm.markText(range.from, range.to, { + replacedWith: myWidget, + clearOnEnter: getOption(cm, options, "clearOnEnter"), + __isFold: true + }); + myRange.on("clear", function(from, to) { + CodeMirror.signal(cm, "unfold", cm, from, to); + }); + CodeMirror.signal(cm, "fold", cm, range.from, range.to); + } + + function makeWidget(cm, options, range) { + var widget = getOption(cm, options, "widget"); + + if (typeof widget == "function") { + widget = widget(range.from, range.to); + } + + if (typeof widget == "string") { + var text = document.createTextNode(widget); + widget = document.createElement("span"); + widget.appendChild(text); + widget.className = "CodeMirror-foldmarker"; + } else if (widget) { + widget = widget.cloneNode(true) + } + return widget; + } + + // Clumsy backwards-compatible interface + CodeMirror.newFoldFunction = function(rangeFinder, widget) { + return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); }; + }; + + // New-style interface + CodeMirror.defineExtension("foldCode", function(pos, options, force) { + doFold(this, pos, options, force); + }); + + CodeMirror.defineExtension("isFolded", function(pos) { + var marks = this.findMarksAt(pos); + for (var i = 0; i < marks.length; ++i) + if (marks[i].__isFold) return true; + }); + + CodeMirror.commands.toggleFold = function(cm) { + cm.foldCode(cm.getCursor()); + }; + CodeMirror.commands.fold = function(cm) { + cm.foldCode(cm.getCursor(), null, "fold"); + }; + CodeMirror.commands.unfold = function(cm) { + cm.foldCode(cm.getCursor(), null, "unfold"); + }; + CodeMirror.commands.foldAll = function(cm) { + cm.operation(function() { + for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) + cm.foldCode(CodeMirror.Pos(i, 0), null, "fold"); + }); + }; + CodeMirror.commands.unfoldAll = function(cm) { + cm.operation(function() { + for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) + cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold"); + }); + }; + + CodeMirror.registerHelper("fold", "combine", function() { + var funcs = Array.prototype.slice.call(arguments, 0); + return function(cm, start) { + for (var i = 0; i < funcs.length; ++i) { + var found = funcs[i](cm, start); + if (found) return found; + } + }; + }); + + CodeMirror.registerHelper("fold", "auto", function(cm, start) { + var helpers = cm.getHelpers(start, "fold"); + for (var i = 0; i < helpers.length; i++) { + var cur = helpers[i](cm, start); + if (cur) return cur; + } + }); + + var defaultOptions = { + rangeFinder: CodeMirror.fold.auto, + widget: "\u2194", + minFoldSize: 0, + scanUp: false, + clearOnEnter: true + }; + + CodeMirror.defineOption("foldOptions", null); + + function getOption(cm, options, name) { + if (options && options[name] !== undefined) + return options[name]; + var editorOptions = cm.options.foldOptions; + if (editorOptions && editorOptions[name] !== undefined) + return editorOptions[name]; + return defaultOptions[name]; + } + + CodeMirror.defineExtension("foldOption", function(options, name) { + return getOption(this, options, name); + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldgutter.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldgutter.css index 7ee0f2a..ad19ae2 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldgutter.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldgutter.css @@ -1 +1,20 @@ -.CodeMirror-foldmarker{color:#00f;text-shadow:#b9f 1px 1px 2px,#b9f -1px -1px 2px,#b9f 1px -1px 2px,#b9f -1px 1px 2px;font-family:arial;line-height:.3;cursor:pointer}.CodeMirror-foldgutter{width:.7em}.CodeMirror-foldgutter-folded,.CodeMirror-foldgutter-open{cursor:pointer}.CodeMirror-foldgutter-open:after{content:"\25BE"}.CodeMirror-foldgutter-folded:after{content:"\25B8"} \ No newline at end of file +.CodeMirror-foldmarker { + color: blue; + text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px; + font-family: arial; + line-height: .3; + cursor: pointer; +} +.CodeMirror-foldgutter { + width: .7em; +} +.CodeMirror-foldgutter-open, +.CodeMirror-foldgutter-folded { + cursor: pointer; +} +.CodeMirror-foldgutter-open:after { + content: "\25BE"; +} +.CodeMirror-foldgutter-folded:after { + content: "\25B8"; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldgutter.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldgutter.js index 3ed7819..7d46a60 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldgutter.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/foldgutter.js @@ -1,9 +1,163 @@ -'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,f,d){a instanceof String&&(a=String(a));for(var h=a.length,g=0;g=f){if(n&&m&&n.test(m.className))return;a=h(e.indicatorOpen)}}(a||m)&&b.setGutterMarker(c,e.gutter,a)})}function k(b){var c=b.getViewport(),a=b.state.foldGutter;a&&(b.operation(function(){g(b,c.from,c.to)}),a.from=c.from,a.to=c.to)}function r(b,c,a){var e=b.state.foldGutter;e&&(e=e.options,a==e.gutter&&((a=d(b,c))?a.clear():b.foldCode(p(c,0),e)))}function n(b){var c=b.state.foldGutter;if(c){var a=c.options;c.from=c.to= -0;clearTimeout(c.changeUpdate);c.changeUpdate=setTimeout(function(){k(b)},a.foldOnChangeTimeSpan||600)}}function t(a){var c=a.state.foldGutter;if(c){var b=c.options;clearTimeout(c.changeUpdate);c.changeUpdate=setTimeout(function(){var b=a.getViewport();c.from==c.to||20c.to&&(g(a,c.to,b.to),c.to=b.to)})},b.updateViewportTimeSpan||400)}}function l(a,c){var b=a.state.foldGutter;b&&(c=c.line, -c>=b.from&&c= minSize) { + if (clsOpen && old && clsOpen.test(old.className)) return; + mark = marker(opts.indicatorOpen); + } + } + if (!mark && !old) return; + cm.setGutterMarker(line, opts.gutter, mark); + }); + } + + // copied from CodeMirror/src/util/dom.js + function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") } + + function updateInViewport(cm) { + var vp = cm.getViewport(), state = cm.state.foldGutter; + if (!state) return; + cm.operation(function() { + updateFoldInfo(cm, vp.from, vp.to); + }); + state.from = vp.from; state.to = vp.to; + } + + function onGutterClick(cm, line, gutter) { + var state = cm.state.foldGutter; + if (!state) return; + var opts = state.options; + if (gutter != opts.gutter) return; + var folded = isFolded(cm, line); + if (folded) folded.clear(); + else cm.foldCode(Pos(line, 0), opts); + } + + function onChange(cm) { + var state = cm.state.foldGutter; + if (!state) return; + var opts = state.options; + state.from = state.to = 0; + clearTimeout(state.changeUpdate); + state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600); + } + + function onViewportChange(cm) { + var state = cm.state.foldGutter; + if (!state) return; + var opts = state.options; + clearTimeout(state.changeUpdate); + state.changeUpdate = setTimeout(function() { + var vp = cm.getViewport(); + if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) { + updateInViewport(cm); + } else { + cm.operation(function() { + if (vp.from < state.from) { + updateFoldInfo(cm, vp.from, state.from); + state.from = vp.from; + } + if (vp.to > state.to) { + updateFoldInfo(cm, state.to, vp.to); + state.to = vp.to; + } + }); + } + }, opts.updateViewportTimeSpan || 400); + } + + function onFold(cm, from) { + var state = cm.state.foldGutter; + if (!state) return; + var line = from.line; + if (line >= state.from && line < state.to) + updateFoldInfo(cm, line, line + 1); + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/indent-fold.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/indent-fold.js index f5237be..0cc1126 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/indent-fold.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/indent-fold.js @@ -1,2 +1,48 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){function g(b,c){var e=b.getLine(c),d=e.search(/\S/);return-1==d||/\bcomment\b/.test(b.getTokenTypeAt(a.Pos(c,d+1)))?-1:a.countColumn(e,null,b.getOption("tabSize"))}a.registerHelper("fold","indent",function(b,c){var e=g(b,c.line);if(!(0>e)){for(var d=null,f=c.line+1,k=b.lastLine();f<=k;++f){var h= -g(b,f);if(-1!=h)if(h>e)d=f;else break}if(d)return{from:a.Pos(c.line,b.getLine(c.line).length),to:a.Pos(d,b.getLine(d).length)}}})}); +// 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 lineIndent(cm, lineNo) { + var text = cm.getLine(lineNo) + var spaceTo = text.search(/\S/) + if (spaceTo == -1 || /\bcomment\b/.test(cm.getTokenTypeAt(CodeMirror.Pos(lineNo, spaceTo + 1)))) + return -1 + return CodeMirror.countColumn(text, null, cm.getOption("tabSize")) +} + +CodeMirror.registerHelper("fold", "indent", function(cm, start) { + var myIndent = lineIndent(cm, start.line) + if (myIndent < 0) return + var lastLineInFold = null + + // Go through lines until we find a line that definitely doesn't belong in + // the block we're folding, or to the end. + for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) { + var indent = lineIndent(cm, i) + if (indent == -1) { + } else if (indent > myIndent) { + // Lines with a greater indent are considered part of the block. + lastLineInFold = i; + } else { + // If this line has non-space, non-comment content, and is + // indented less or equal to the start line, it is the start of + // another block. + break; + } + } + if (lastLineInFold) return { + from: CodeMirror.Pos(start.line, cm.getLine(start.line).length), + to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length) + }; +}); + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/markdown-fold.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/markdown-fold.js index 5e7b712..6a55178 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/markdown-fold.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/fold/markdown-fold.js @@ -1,2 +1,49 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){a.registerHelper("fold","markdown",function(c,d){function g(b){return(b=c.getTokenTypeAt(a.Pos(b,0)))&&/\bheader\b/.test(b)}function h(b,a,c){return(a=a&&a.match(/^#+/))&&g(b)?a[0].length:(a=c&&c.match(/^[=\-]+\s*$/))&&g(b+1)?"="==c[0]?1:2:100}var k=c.getLine(d.line),e=c.getLine(d.line+1), -l=h(d.line,k,e);if(100!==l){for(var m=c.lastLine(),b=d.line,f=c.getLine(b+2);b= -a.max))return a.ch=0,a.text=a.cm.getLine(++a.line),!0}function u(a){if(!(a.line<=a.min))return a.text=a.cm.getLine(--a.line),a.ch=a.text.length,!0}function q(a){for(;;){var b=a.text.indexOf(">",a.ch);if(-1==b)if(t(a))continue;else break;if(m(a,b+1)){var d=a.text.lastIndexOf("/",b);d=-1h&&(!b||b==c[2]))return{tag:c[2],from:k(e,g),to:k(a.line,a.ch)}}else d.push(c[2])}} -function w(a,b){for(var d=[];;){var c;a:for(c=a;;){var f=c.ch?c.text.lastIndexOf(">",c.ch-1):-1;if(-1==f)if(u(c))continue;else{c=void 0;break a}if(m(c,f+1)){var e=c.text.lastIndexOf("/",f);e=-1g&&(!b||b==e[2]))return{tag:e[2],from:k(a.line,a.ch), -to:k(c,f)}}}}}var k=h.Pos,n=/<(\/?)([A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD-:.0-9\u00B7\u0300-\u036F\u203F-\u2040]*)/g;h.registerHelper("fold","xml",function(a,b){for(a=new l(a,b.line,0);;){var d=v(a);if(!d||a.line!=b.line)break;var c=q(a); -if(!c)break;if(!d[1]&&"selfClose"!=c){b=k(a.line,a.ch);if(d=a=p(a,d[2]))d=a.from,d=0<(d.line-b.line||d.ch-b.ch);return d?{from:b,to:a.from}:null}}});h.findMatchingTag=function(a,b,d){var c=new l(a,b.line,b.ch,d);if(-1!=c.text.indexOf(">")||-1!=c.text.indexOf("<")){var f=q(c),e=f&&k(c.line,c.ch),g=f&&r(c);if(f&&g&&!(0<(c.line-b.line||c.ch-b.ch))){b={from:k(c.line,c.ch),to:e,tag:g[2]};if("selfClose"==f)return{open:b,close:null,at:"open"};if(g[1])return{open:w(c,g[2]),close:b,at:"close"};c=new l(a,e.line, -e.ch,d);return{open:b,close:p(c,g[2]),at:"open"}}}};h.findEnclosingTag=function(a,b,d,c){for(var f=new l(a,b.line,b.ch,d);;){var e=w(f,c);if(!e)break;var g=new l(a,b.line,b.ch,d);if(g=p(g,e.tag))return{open:e,close:g}}};h.scanForClosingTag=function(a,b,d,c){a=new l(a,b.line,b.ch,c?{from:0,to:c}:null);return p(a,d)}}); +// 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"; + + var Pos = CodeMirror.Pos; + function cmp(a, b) { return a.line - b.line || a.ch - b.ch; } + + var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; + var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; + var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g"); + + function Iter(cm, line, ch, range) { + this.line = line; this.ch = ch; + this.cm = cm; this.text = cm.getLine(line); + this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine(); + this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine(); + } + + function tagAt(iter, ch) { + var type = iter.cm.getTokenTypeAt(Pos(iter.line, ch)); + return type && /\btag\b/.test(type); + } + + function nextLine(iter) { + if (iter.line >= iter.max) return; + iter.ch = 0; + iter.text = iter.cm.getLine(++iter.line); + return true; + } + function prevLine(iter) { + if (iter.line <= iter.min) return; + iter.text = iter.cm.getLine(--iter.line); + iter.ch = iter.text.length; + return true; + } + + function toTagEnd(iter) { + for (;;) { + var gt = iter.text.indexOf(">", iter.ch); + if (gt == -1) { if (nextLine(iter)) continue; else return; } + if (!tagAt(iter, gt + 1)) { iter.ch = gt + 1; continue; } + var lastSlash = iter.text.lastIndexOf("/", gt); + var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt)); + iter.ch = gt + 1; + return selfClose ? "selfClose" : "regular"; + } + } + function toTagStart(iter) { + for (;;) { + var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1; + if (lt == -1) { if (prevLine(iter)) continue; else return; } + if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; } + xmlTagStart.lastIndex = lt; + iter.ch = lt; + var match = xmlTagStart.exec(iter.text); + if (match && match.index == lt) return match; + } + } + + function toNextTag(iter) { + for (;;) { + xmlTagStart.lastIndex = iter.ch; + var found = xmlTagStart.exec(iter.text); + if (!found) { if (nextLine(iter)) continue; else return; } + if (!tagAt(iter, found.index + 1)) { iter.ch = found.index + 1; continue; } + iter.ch = found.index + found[0].length; + return found; + } + } + function toPrevTag(iter) { + for (;;) { + var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1; + if (gt == -1) { if (prevLine(iter)) continue; else return; } + if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; } + var lastSlash = iter.text.lastIndexOf("/", gt); + var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt)); + iter.ch = gt + 1; + return selfClose ? "selfClose" : "regular"; + } + } + + function findMatchingClose(iter, tag) { + var stack = []; + for (;;) { + var next = toNextTag(iter), end, startLine = iter.line, startCh = iter.ch - (next ? next[0].length : 0); + if (!next || !(end = toTagEnd(iter))) return; + if (end == "selfClose") continue; + if (next[1]) { // closing tag + for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == next[2]) { + stack.length = i; + break; + } + if (i < 0 && (!tag || tag == next[2])) return { + tag: next[2], + from: Pos(startLine, startCh), + to: Pos(iter.line, iter.ch) + }; + } else { // opening tag + stack.push(next[2]); + } + } + } + function findMatchingOpen(iter, tag) { + var stack = []; + for (;;) { + var prev = toPrevTag(iter); + if (!prev) return; + if (prev == "selfClose") { toTagStart(iter); continue; } + var endLine = iter.line, endCh = iter.ch; + var start = toTagStart(iter); + if (!start) return; + if (start[1]) { // closing tag + stack.push(start[2]); + } else { // opening tag + for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == start[2]) { + stack.length = i; + break; + } + if (i < 0 && (!tag || tag == start[2])) return { + tag: start[2], + from: Pos(iter.line, iter.ch), + to: Pos(endLine, endCh) + }; + } + } + } + + CodeMirror.registerHelper("fold", "xml", function(cm, start) { + var iter = new Iter(cm, start.line, 0); + for (;;) { + var openTag = toNextTag(iter) + if (!openTag || iter.line != start.line) return + var end = toTagEnd(iter) + if (!end) return + if (!openTag[1] && end != "selfClose") { + var startPos = Pos(iter.line, iter.ch); + var endPos = findMatchingClose(iter, openTag[2]); + return endPos && cmp(endPos.from, startPos) > 0 ? {from: startPos, to: endPos.from} : null + } + } + }); + CodeMirror.findMatchingTag = function(cm, pos, range) { + var iter = new Iter(cm, pos.line, pos.ch, range); + if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return; + var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch); + var start = end && toTagStart(iter); + if (!end || !start || cmp(iter, pos) > 0) return; + var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]}; + if (end == "selfClose") return {open: here, close: null, at: "open"}; + + if (start[1]) { // closing tag + return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"}; + } else { // opening tag + iter = new Iter(cm, to.line, to.ch, range); + return {open: here, close: findMatchingClose(iter, start[2]), at: "open"}; + } + }; + + CodeMirror.findEnclosingTag = function(cm, pos, range, tag) { + var iter = new Iter(cm, pos.line, pos.ch, range); + for (;;) { + var open = findMatchingOpen(iter, tag); + if (!open) break; + var forward = new Iter(cm, pos.line, pos.ch, range); + var close = findMatchingClose(forward, open.tag); + if (close) return {open: open, close: close}; + } + }; + + // Used by addon/edit/closetag.js + CodeMirror.scanForClosingTag = function(cm, pos, name, end) { + var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null); + return findMatchingClose(iter, name); + }; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/anyword-hint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/anyword-hint.js index 7ec88be..d27a9ec 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/anyword-hint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/anyword-hint.js @@ -1,2 +1,41 @@ -'use strict';(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){var p=/[\w$]+/;b.registerHelper("hint","anyword",function(g,a){for(var l=a&&a.word||p,q=a&&a.range||500,c=g.getCursor(),d=g.getLine(c.line),m=c.ch,e=m;e&&l.test(d.charAt(e-1));)--e;d=e!=m&&d.slice(e,m);a=a&&a.list||[];var n={};l=new RegExp(l.source,"g");for(var h=-1;1>=h;h+=2)for(var k=c.line, -r=Math.min(Math.max(k+h*q,g.firstLine()),g.lastLine())+h;k!=r;k+=h)for(var t=g.getLine(k),f;f=l.exec(t);)k==c.line&&f[0]===d||d&&0!=f[0].lastIndexOf(d,0)||Object.prototype.hasOwnProperty.call(n,f[0])||(n[f[0]]=!0,a.push(f[0]));return{list:a,from:b.Pos(c.line,e),to:b.Pos(c.line,m)}})}); +// 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"; + + var WORD = /[\w$]+/, RANGE = 500; + + CodeMirror.registerHelper("hint", "anyword", function(editor, options) { + var word = options && options.word || WORD; + var range = options && options.range || RANGE; + var cur = editor.getCursor(), curLine = editor.getLine(cur.line); + var end = cur.ch, start = end; + while (start && word.test(curLine.charAt(start - 1))) --start; + var curWord = start != end && curLine.slice(start, end); + + var list = options && options.list || [], seen = {}; + var re = new RegExp(word.source, "g"); + for (var dir = -1; dir <= 1; dir += 2) { + var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; + for (; line != endLine; line += dir) { + var text = editor.getLine(line), m; + while (m = re.exec(text)) { + if (line == cur.line && m[0] === curWord) continue; + if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) { + seen[m[0]] = true; + list.push(m[0]); + } + } + } + } + return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)}; + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/css-hint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/css-hint.js index b3f8105..a8c8fa7 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/css-hint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/css-hint.js @@ -1,4 +1,4 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../../mode/css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/css/css"],a):a(CodeMirror)})(function(a){var m={active:1,after:1,before:1,checked:1,"default":1,disabled:1,empty:1,enabled:1,"first-child":1,"first-letter":1,"first-line":1,"first-of-type":1,focus:1,hover:1,"in-range":1,indeterminate:1,invalid:1,lang:1,"last-child":1,"last-of-type":1, +'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../../mode/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/css"],a):a(CodeMirror)})(function(a){var m={active:1,after:1,before:1,checked:1,"default":1,disabled:1,empty:1,enabled:1,"first-child":1,"first-letter":1,"first-line":1,"first-of-type":1,focus:1,hover:1,"in-range":1,indeterminate:1,invalid:1,lang:1,"last-child":1,"last-of-type":1, link:1,not:1,"nth-child":1,"nth-last-child":1,"nth-last-of-type":1,"nth-of-type":1,"only-of-type":1,"only-child":1,optional:1,"out-of-range":1,placeholder:1,"read-only":1,"read-write":1,required:1,root:1,selection:1,target:1,valid:1,visited:1};a.registerHelper("hint","css",function(d){function f(b){for(var a in b)h&&0!=a.lastIndexOf(h,0)||k.push(a)}var e=d.getCursor(),c=d.getTokenAt(e),b=a.innerMode(d.getMode(),c.state);if("css"==b.mode.name){if("keyword"==c.type&&0=="!important".indexOf(c.string))return{list:["!important"], from:a.Pos(e.line,c.start),to:a.Pos(e.line,c.end)};d=c.start;var l=e.ch,h=c.string.slice(0,l-d);/[^\w$_-]/.test(h)&&(h="",d=l=e.ch);var g=a.resolveMode("text/css"),k=[];b=b.state.state;if("pseudo"==b||"variable-3"==c.type)f(m);else if("block"==b||"maybeprop"==b)f(g.propertyKeywords);else if("prop"==b||"parens"==b||"at"==b||"params"==b)f(g.valueKeywords),f(g.colorKeywords);else if("media"==b||"media_parens"==b)f(g.mediaTypes),f(g.mediaFeatures);if(k.length)return{list:k,from:a.Pos(e.line,d),to:a.Pos(e.line, l)}}})}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/html-hint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/html-hint.js index 9708ec5..9878eca 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/html-hint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/html-hint.js @@ -1,15 +1,351 @@ -'use strict';(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror"),require("./xml-hint")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./xml-hint"],b):b(CodeMirror)})(function(b){function n(a){for(var b in g)g.hasOwnProperty(b)&&(a.attrs[b]=g[b])}var d="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "), -c=["_blank","_self","_top","_parent"],h=["ascii","utf-8","utf-16","latin1","latin1"],k=["get","post","put","delete"],l=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],e="all;screen;print;embossed;braille;handheld;print;projection;screen;tty;tv;speech;3d-glasses;resolution [>][<][=] [X];device-aspect-ratio: X/Y;orientation:portrait;orientation:landscape;device-height: [X];device-width: [X]".split(";"),a={attrs:{}},f={a:{attrs:{href:null,ping:null,type:null,media:e,target:c, -hreflang:d}},abbr:a,acronym:a,address:a,applet:a,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:e,hreflang:d,type:null,shape:["default","rect","circle","poly"]}},article:a,aside:a,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:a,base:{attrs:{href:null,target:c}},basefont:a,bdi:a,bdo:a,big:a,blockquote:{attrs:{cite:null}},body:a,br:a, -button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:l,formmethod:k,formnovalidate:["","novalidate"],formtarget:c,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:a,center:a,cite:a,code:a,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}}, -data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:a,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:a,dir:a,div:a,dl:a,dt:a,em:a,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:a,figure:a,font:a,footer:a,form:{attrs:{action:null,name:null,"accept-charset":h,autocomplete:["on","off"], -enctype:l,method:k,novalidate:["","novalidate"],target:c}},frame:a,frameset:a,h1:a,h2:a,h3:a,h4:a,h5:a,h6:a,head:{attrs:{},children:"title base link style meta script noscript command".split(" ")},header:a,hgroup:a,hr:a,html:{attrs:{manifest:null},children:["head","body"]},i:a,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null, -width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:l,formmethod:k,formnovalidate:["","novalidate"],formtarget:c,multiple:["", -"multiple"],readonly:["","readonly"],required:["","required"],type:"hidden text search tel url email password datetime date month week time datetime-local number range color checkbox radio file submit image reset button".split(" ")}},ins:{attrs:{cite:null,datetime:null}},kbd:a,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:a,li:{attrs:{value:null}},link:{attrs:{href:null,type:null, -hreflang:d,media:e,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:a,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:h,name:"viewport application-name author description generator keywords".split(" "),"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:a,noframes:a,noscript:a,object:{attrs:{data:null,type:null, -name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:a,param:{attrs:{name:null,value:null}},pre:a,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:a,rt:a,ruby:a,s:a,samp:a,script:{attrs:{type:["text/javascript"], -src:null,async:["","async"],defer:["","defer"],charset:h}},section:a,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:a,source:{attrs:{src:null,type:null,media:null}},span:a,strike:a,strong:a,style:{attrs:{type:["text/css"],media:e,scoped:null}},sub:a,summary:a,sup:a,table:a,tbody:a,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null, -cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:a,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:a,time:{attrs:{datetime:null}},title:a,tr:a,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:d}},tt:a,u:a,ul:a,"var":a,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous", -"use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:a},g={accesskey:"abcdefghijklmnopqrstuvwxyz0123456789".split(""),"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null, -lang:["en","es"],spellcheck:["true","false"],autocorrect:["true","false"],autocapitalize:["true","false"],style:null,tabindex:"123456789".split(""),title:null,translate:["yes","no"],onclick:null,rel:"stylesheet alternate author bookmark help license next nofollow noreferrer prefetch prev search tag".split(" ")};n(a);for(var m in f)f.hasOwnProperty(m)&&f[m]!=a&&n(f[m]);b.htmlSchema=f;b.registerHelper("hint","html",function(a,c){var d={schemaInfo:f};if(c)for(var e in c)d[e]=c[e];return b.hint.xml(a, -d)})}); +// 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"), require("./xml-hint")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "./xml-hint"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "); + var targets = ["_blank", "_self", "_top", "_parent"]; + var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"]; + var methods = ["get", "post", "put", "delete"]; + var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]; + var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech", + "3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait", + "orientation:landscape", "device-height: [X]", "device-width: [X]"]; + var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags + + var data = { + a: { + attrs: { + href: null, ping: null, type: null, + media: media, + target: targets, + hreflang: langs + } + }, + abbr: s, + acronym: s, + address: s, + applet: s, + area: { + attrs: { + alt: null, coords: null, href: null, target: null, ping: null, + media: media, hreflang: langs, type: null, + shape: ["default", "rect", "circle", "poly"] + } + }, + article: s, + aside: s, + audio: { + attrs: { + src: null, mediagroup: null, + crossorigin: ["anonymous", "use-credentials"], + preload: ["none", "metadata", "auto"], + autoplay: ["", "autoplay"], + loop: ["", "loop"], + controls: ["", "controls"] + } + }, + b: s, + base: { attrs: { href: null, target: targets } }, + basefont: s, + bdi: s, + bdo: s, + big: s, + blockquote: { attrs: { cite: null } }, + body: s, + br: s, + button: { + attrs: { + form: null, formaction: null, name: null, value: null, + autofocus: ["", "autofocus"], + disabled: ["", "autofocus"], + formenctype: encs, + formmethod: methods, + formnovalidate: ["", "novalidate"], + formtarget: targets, + type: ["submit", "reset", "button"] + } + }, + canvas: { attrs: { width: null, height: null } }, + caption: s, + center: s, + cite: s, + code: s, + col: { attrs: { span: null } }, + colgroup: { attrs: { span: null } }, + command: { + attrs: { + type: ["command", "checkbox", "radio"], + label: null, icon: null, radiogroup: null, command: null, title: null, + disabled: ["", "disabled"], + checked: ["", "checked"] + } + }, + data: { attrs: { value: null } }, + datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } }, + datalist: { attrs: { data: null } }, + dd: s, + del: { attrs: { cite: null, datetime: null } }, + details: { attrs: { open: ["", "open"] } }, + dfn: s, + dir: s, + div: s, + dialog: { attrs: { open: null } }, + dl: s, + dt: s, + em: s, + embed: { attrs: { src: null, type: null, width: null, height: null } }, + eventsource: { attrs: { src: null } }, + fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } }, + figcaption: s, + figure: s, + font: s, + footer: s, + form: { + attrs: { + action: null, name: null, + "accept-charset": charsets, + autocomplete: ["on", "off"], + enctype: encs, + method: methods, + novalidate: ["", "novalidate"], + target: targets + } + }, + frame: s, + frameset: s, + h1: s, h2: s, h3: s, h4: s, h5: s, h6: s, + head: { + attrs: {}, + children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"] + }, + header: s, + hgroup: s, + hr: s, + html: { + attrs: { manifest: null }, + children: ["head", "body"] + }, + i: s, + iframe: { + attrs: { + src: null, srcdoc: null, name: null, width: null, height: null, + sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"], + seamless: ["", "seamless"] + } + }, + img: { + attrs: { + alt: null, src: null, ismap: null, usemap: null, width: null, height: null, + crossorigin: ["anonymous", "use-credentials"] + } + }, + input: { + attrs: { + alt: null, dirname: null, form: null, formaction: null, + height: null, list: null, max: null, maxlength: null, min: null, + name: null, pattern: null, placeholder: null, size: null, src: null, + step: null, value: null, width: null, + accept: ["audio/*", "video/*", "image/*"], + autocomplete: ["on", "off"], + autofocus: ["", "autofocus"], + checked: ["", "checked"], + disabled: ["", "disabled"], + formenctype: encs, + formmethod: methods, + formnovalidate: ["", "novalidate"], + formtarget: targets, + multiple: ["", "multiple"], + readonly: ["", "readonly"], + required: ["", "required"], + type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month", + "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio", + "file", "submit", "image", "reset", "button"] + } + }, + ins: { attrs: { cite: null, datetime: null } }, + kbd: s, + keygen: { + attrs: { + challenge: null, form: null, name: null, + autofocus: ["", "autofocus"], + disabled: ["", "disabled"], + keytype: ["RSA"] + } + }, + label: { attrs: { "for": null, form: null } }, + legend: s, + li: { attrs: { value: null } }, + link: { + attrs: { + href: null, type: null, + hreflang: langs, + media: media, + sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"] + } + }, + map: { attrs: { name: null } }, + mark: s, + menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } }, + meta: { + attrs: { + content: null, + charset: charsets, + name: ["viewport", "application-name", "author", "description", "generator", "keywords"], + "http-equiv": ["content-language", "content-type", "default-style", "refresh"] + } + }, + meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } }, + nav: s, + noframes: s, + noscript: s, + object: { + attrs: { + data: null, type: null, name: null, usemap: null, form: null, width: null, height: null, + typemustmatch: ["", "typemustmatch"] + } + }, + ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } }, + optgroup: { attrs: { disabled: ["", "disabled"], label: null } }, + option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } }, + output: { attrs: { "for": null, form: null, name: null } }, + p: s, + param: { attrs: { name: null, value: null } }, + pre: s, + progress: { attrs: { value: null, max: null } }, + q: { attrs: { cite: null } }, + rp: s, + rt: s, + ruby: s, + s: s, + samp: s, + script: { + attrs: { + type: ["text/javascript"], + src: null, + async: ["", "async"], + defer: ["", "defer"], + charset: charsets + } + }, + section: s, + select: { + attrs: { + form: null, name: null, size: null, + autofocus: ["", "autofocus"], + disabled: ["", "disabled"], + multiple: ["", "multiple"] + } + }, + small: s, + source: { attrs: { src: null, type: null, media: null } }, + span: s, + strike: s, + strong: s, + style: { + attrs: { + type: ["text/css"], + media: media, + scoped: null + } + }, + sub: s, + summary: s, + sup: s, + table: s, + tbody: s, + td: { attrs: { colspan: null, rowspan: null, headers: null } }, + textarea: { + attrs: { + dirname: null, form: null, maxlength: null, name: null, placeholder: null, + rows: null, cols: null, + autofocus: ["", "autofocus"], + disabled: ["", "disabled"], + readonly: ["", "readonly"], + required: ["", "required"], + wrap: ["soft", "hard"] + } + }, + tfoot: s, + th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } }, + thead: s, + time: { attrs: { datetime: null } }, + title: s, + tr: s, + track: { + attrs: { + src: null, label: null, "default": null, + kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"], + srclang: langs + } + }, + tt: s, + u: s, + ul: s, + "var": s, + video: { + attrs: { + src: null, poster: null, width: null, height: null, + crossorigin: ["anonymous", "use-credentials"], + preload: ["auto", "metadata", "none"], + autoplay: ["", "autoplay"], + mediagroup: ["movie"], + muted: ["", "muted"], + controls: ["", "controls"] + } + }, + wbr: s + }; + + var globalAttrs = { + accesskey: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + "class": null, + contenteditable: ["true", "false"], + contextmenu: null, + dir: ["ltr", "rtl", "auto"], + draggable: ["true", "false", "auto"], + dropzone: ["copy", "move", "link", "string:", "file:"], + hidden: ["hidden"], + id: null, + inert: ["inert"], + itemid: null, + itemprop: null, + itemref: null, + itemscope: ["itemscope"], + itemtype: null, + lang: ["en", "es"], + spellcheck: ["true", "false"], + autocorrect: ["true", "false"], + autocapitalize: ["true", "false"], + style: null, + tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"], + title: null, + translate: ["yes", "no"], + onclick: null, + rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"] + }; + function populate(obj) { + for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr)) + obj.attrs[attr] = globalAttrs[attr]; + } + + populate(s); + for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s) + populate(data[tag]); + + CodeMirror.htmlSchema = data; + function htmlHint(cm, options) { + var local = {schemaInfo: data}; + if (options) for (var opt in options) local[opt] = options[opt]; + return CodeMirror.hint.xml(cm, local); + } + CodeMirror.registerHelper("hint", "html", htmlHint); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/javascript-hint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/javascript-hint.js index 05cc0b1..9f06b1b 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/javascript-hint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/javascript-hint.js @@ -1,6 +1,162 @@ -'use strict';(function(h){"object"==typeof exports&&"object"==typeof module?h(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],h):h(CodeMirror)})(function(h){function m(a,b){for(var k=0,g=a.length;kc.ch&&(d.end=c.ch,d.string= -d.string.slice(0,c.ch-d.start)):d={start:c.ch,end:c.ch,string:"",state:d.state,type:"."==d.string?"property":null};for(f=d;"property"==f.type;){f=k(a,n(c.line,f.start));if("."!=f.string)return;f=k(a,n(c.line,f.start));if(!p)var p=[];p.push(f)}return{list:r(d,p,b,g),from:n(c.line,d.start),to:n(c.line,d.end)}}}}function t(a,b){a=a.getTokenAt(b);b.ch==a.start+1&&"."==a.string.charAt(0)?(a.end=a.start,a.string=".",a.type="property"):/^\.[\w$_]*$/.test(a.string)&&(a.type="property",a.start++,a.string= -a.string.replace(/\./,""));return a}function r(a,b,k,g){function c(a){var b;if(b=0==a.lastIndexOf(h,0)){a:if(Array.prototype.indexOf)b=-1!=f.indexOf(a);else{for(b=f.length;b--;)if(f[b]===a){b=!0;break a}b=!1}b=!b}b&&f.push(a)}function d(a){"string"==typeof a?m(u,c):a instanceof Array?m(v,c):a instanceof Function&&m(w,c);if(Object.getOwnPropertyNames&&Object.getPrototypeOf)for(;a;a=Object.getPrototypeOf(a))Object.getOwnPropertyNames(a).forEach(c);else for(var b in a)c(b)}var f=[],h=a.string,l=g&&g.globalScope|| -window;if(b&&b.length){a=b.pop();var e;a.type&&0===a.type.indexOf("variable")?(g&&g.additionalContext&&(e=g.additionalContext[a.string]),g&&!1===g.useGlobalScope||(e=e||l[a.string])):"string"==a.type?e="":"atom"==a.type?e=1:"function"==a.type&&(null==l.jQuery||"$"!=a.string&&"jQuery"!=a.string||"function"!=typeof l.jQuery?null!=l._&&"_"==a.string&&"function"==typeof l._&&(e=l._()):e=l.jQuery());for(;null!=e&&b.length;)e=e[b.pop().string];null!=e&&d(e)}else{for(b=a.state.localVars;b;b=b.next)c(b.name); -for(e=a.state.context;e;e=e.prev)for(b=e.vars;b;b=b.next)c(b.name);for(b=a.state.globalVars;b;b=b.next)c(b.name);g&&!1===g.useGlobalScope||d(l);m(k,c)}return f}var n=h.Pos;h.registerHelper("hint","javascript",function(a,b){return q(a,x,function(a,b){return a.getTokenAt(b)},b)});h.registerHelper("hint","coffeescript",function(a,b){return q(a,y,t,b)});var u="charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight toUpperCase toLowerCase split concat match replace search".split(" "), -v="length concat join splice push pop shift unshift slice reverse sort indexOf lastIndexOf every some filter forEach map reduce reduceRight ".split(" "),w=["prototype","apply","call","bind"],x="break case catch class const continue debugger default delete do else export extends false finally for function if in import instanceof new null return super switch this throw true try typeof var void while with yield".split(" "),y="and break catch class continue delete do else extends false finally for if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes".split(" ")}); +// 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) { + var Pos = CodeMirror.Pos; + + function forEach(arr, f) { + for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]); + } + + function arrayContains(arr, item) { + if (!Array.prototype.indexOf) { + var i = arr.length; + while (i--) { + if (arr[i] === item) { + return true; + } + } + return false; + } + return arr.indexOf(item) != -1; + } + + function scriptHint(editor, keywords, getToken, options) { + // Find the token at the cursor + var cur = editor.getCursor(), token = getToken(editor, cur); + if (/\b(?:string|comment)\b/.test(token.type)) return; + var innerMode = CodeMirror.innerMode(editor.getMode(), token.state); + if (innerMode.mode.helperType === "json") return; + token.state = innerMode.state; + + // If it's not a 'word-style' token, ignore the token. + if (!/^[\w$_]*$/.test(token.string)) { + token = {start: cur.ch, end: cur.ch, string: "", state: token.state, + type: token.string == "." ? "property" : null}; + } else if (token.end > cur.ch) { + token.end = cur.ch; + token.string = token.string.slice(0, cur.ch - token.start); + } + + var tprop = token; + // If it is a property, find out what it is a property of. + while (tprop.type == "property") { + tprop = getToken(editor, Pos(cur.line, tprop.start)); + if (tprop.string != ".") return; + tprop = getToken(editor, Pos(cur.line, tprop.start)); + if (!context) var context = []; + context.push(tprop); + } + return {list: getCompletions(token, context, keywords, options), + from: Pos(cur.line, token.start), + to: Pos(cur.line, token.end)}; + } + + function javascriptHint(editor, options) { + return scriptHint(editor, javascriptKeywords, + function (e, cur) {return e.getTokenAt(cur);}, + options); + }; + CodeMirror.registerHelper("hint", "javascript", javascriptHint); + + function getCoffeeScriptToken(editor, cur) { + // This getToken, it is for coffeescript, imitates the behavior of + // getTokenAt method in javascript.js, that is, returning "property" + // type and treat "." as independent token. + var token = editor.getTokenAt(cur); + if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') { + token.end = token.start; + token.string = '.'; + token.type = "property"; + } + else if (/^\.[\w$_]*$/.test(token.string)) { + token.type = "property"; + token.start++; + token.string = token.string.replace(/\./, ''); + } + return token; + } + + function coffeescriptHint(editor, options) { + return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options); + } + CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint); + + var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " + + "toUpperCase toLowerCase split concat match replace search").split(" "); + var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " + + "lastIndexOf every some filter forEach map reduce reduceRight ").split(" "); + var funcProps = "prototype apply call bind".split(" "); + var javascriptKeywords = ("break case catch class const continue debugger default delete do else export extends false finally for function " + + "if in import instanceof new null return super switch this throw true try typeof var void while with yield").split(" "); + var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " + + "if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" "); + + function forAllProps(obj, callback) { + if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) { + for (var name in obj) callback(name) + } else { + for (var o = obj; o; o = Object.getPrototypeOf(o)) + Object.getOwnPropertyNames(o).forEach(callback) + } + } + + function getCompletions(token, context, keywords, options) { + var found = [], start = token.string, global = options && options.globalScope || window; + function maybeAdd(str) { + if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str); + } + function gatherCompletions(obj) { + if (typeof obj == "string") forEach(stringProps, maybeAdd); + else if (obj instanceof Array) forEach(arrayProps, maybeAdd); + else if (obj instanceof Function) forEach(funcProps, maybeAdd); + forAllProps(obj, maybeAdd) + } + + if (context && context.length) { + // If this is a property, see if it belongs to some object we can + // find in the current environment. + var obj = context.pop(), base; + if (obj.type && obj.type.indexOf("variable") === 0) { + if (options && options.additionalContext) + base = options.additionalContext[obj.string]; + if (!options || options.useGlobalScope !== false) + base = base || global[obj.string]; + } else if (obj.type == "string") { + base = ""; + } else if (obj.type == "atom") { + base = 1; + } else if (obj.type == "function") { + if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') && + (typeof global.jQuery == 'function')) + base = global.jQuery(); + else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function')) + base = global._(); + } + while (base != null && context.length) + base = base[context.pop().string]; + if (base != null) gatherCompletions(base); + } else { + // If not, just look in the global object, any local scope, and optional additional-context + // (reading into JS mode internals to get at the local and global variables) + for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name); + for (var c = token.state.context; c; c = c.prev) + for (var v = c.vars; v; v = v.next) maybeAdd(v.name) + for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name); + if (options && options.additionalContext != null) + for (var key in options.additionalContext) + maybeAdd(key); + if (!options || options.useGlobalScope !== false) + gatherCompletions(global); + forEach(keywords, maybeAdd); + } + return found; + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/show-hint.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/show-hint.css index 311e1c3..78e5072 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/show-hint.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/show-hint.css @@ -1 +1,36 @@ -.CodeMirror-hints{position:absolute;z-index:10;overflow:hidden;list-style:none;margin:0;padding:2px;-webkit-box-shadow:2px 3px 5px rgba(0,0,0,.2);-moz-box-shadow:2px 3px 5px rgba(0,0,0,.2);box-shadow:2px 3px 5px rgba(0,0,0,.2);border-radius:3px;border:1px solid silver;background:#fff;font-size:90%;font-family:monospace;max-height:20em;overflow-y:auto}.CodeMirror-hint{margin:0;padding:0 4px;border-radius:2px;white-space:pre;color:#000;cursor:pointer}li.CodeMirror-hint-active{background:#08f;color:#fff} \ No newline at end of file +.CodeMirror-hints { + position: absolute; + z-index: 10; + overflow: hidden; + list-style: none; + + margin: 0; + padding: 2px; + + -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + box-shadow: 2px 3px 5px rgba(0,0,0,.2); + border-radius: 3px; + border: 0.6px solid #735CD1; + + background: #282A36; + font-size: 70%; + font-family: monospace; + + max-height: 20em; + overflow-y: auto; +} + +.CodeMirror-hint { + margin: 0; + padding: 0 4px; + border-radius: 2px; + white-space: pre; + color: white; + cursor: pointer; +} + +li.CodeMirror-hint-active { + background: #735CD1; + color: white; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/show-hint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/show-hint.js index daac34e..a9f2ded 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/show-hint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/show-hint.js @@ -1,18 +1,509 @@ -'use strict';(function(g){"object"==typeof exports&&"object"==typeof module?g(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],g):g(CodeMirror)})(function(g){function q(a,b){this.cm=a;this.options=b;this.widget=null;this.tick=this.debounce=0;this.startPos=this.cm.getCursor("start");this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var c=this;a.on("cursorActivity",this.activityFunc=function(){c.cursorActivity()})} -function C(a,b){function c(a,c){var e="string"!=typeof c?function(a){return c(a,b)}:d.hasOwnProperty(c)?d[c]:c;g[a]=e}var d={Up:function(){b.moveFocus(-1)},Down:function(){b.moveFocus(1)},PageUp:function(){b.moveFocus(-b.menuSize()+1,!0)},PageDown:function(){b.moveFocus(b.menuSize()-1,!0)},Home:function(){b.setFocus(0)},End:function(){b.setFocus(b.length-1)},Enter:b.pick,Tab:b.pick,Esc:b.close};/Mac/.test(navigator.platform)&&(d["Ctrl-P"]=function(){b.moveFocus(-1)},d["Ctrl-N"]=function(){b.moveFocus(1)}); -var e=a.options.customKeys,g=e?{}:d;if(e)for(var f in e)e.hasOwnProperty(f)&&c(f,e[f]);if(a=a.options.extraKeys)for(f in a)a.hasOwnProperty(f)&&c(f,a[f]);return g}function A(a,b){for(;b&&b!=a;){if("LI"===b.nodeName.toUpperCase()&&b.parentNode==a)return b;b=b.parentNode}}function r(a,b){this.completion=a;this.data=b;this.picked=!1;var c=this,d=a.cm,e=d.getInputField().ownerDocument,p=e.defaultView||e.parentWindow,f=this.hints=e.createElement("ul");f.className="CodeMirror-hints "+a.cm.options.theme; -this.selectedHint=b.selectedHint||0;for(var v=b.list,h=0;hf.clientHeight+ -1;var r=d.getScrollInfo();0z&&(f.style.height=z-5+"px",f.style.top=(x=h.bottom-k.top-m)+"px",m=d.getCursor(),b.from.ch!=m.ch&&(h=d.cursorCoords(m),f.style.left=(w=h.left-n)+"px",k=f.getBoundingClientRect())));m=k.right-l;0l&&(f.style.width=l-5+"px",m-=k.right-k.left-l),f.style.left=(w=h.left-m-n)+"px");if(y)for(h=f.firstChild;h;h=h.nextSibling)h.style.paddingRight=d.display.nativeBarWidth+ -"px";d.addKeyMap(this.keyMap=C(a,{moveFocus:function(a,b){c.changeActive(c.selectedHint+a,b)},setFocus:function(a){c.changeActive(a)},menuSize:function(){return c.screenAmount()},length:v.length,close:function(){a.close()},pick:function(){c.pick()},data:b}));if(a.options.closeOnUnfocus){var u;d.on("blur",this.onBlur=function(){u=setTimeout(function(){a.close()},100)});d.on("focus",this.onFocus=function(){clearTimeout(u)})}d.on("scroll",this.onScroll=function(){var b=d.getScrollInfo(),c=d.getWrapperElement().getBoundingClientRect(), -g=x+r.top-b.top,h=g-(p.pageYOffset||(e.documentElement||e.body).scrollTop);q||(h+=f.offsetHeight);if(h<=c.top||h>=c.bottom)return a.close();f.style.top=g+"px";f.style.left=w+r.left-b.left+"px"});g.on(f,"dblclick",function(a){(a=A(f,a.target||a.srcElement))&&null!=a.hintId&&(c.changeActive(a.hintId),c.pick())});g.on(f,"click",function(b){(b=A(f,b.target||b.srcElement))&&null!=b.hintId&&(c.changeActive(b.hintId),a.options.completeOnSingleClick&&c.pick())});g.on(f,"mousedown",function(){setTimeout(function(){d.focus()}, -20)});this.scrollToActive();g.signal(b,"select",v[this.selectedHint],f.childNodes[this.selectedHint]);return!0}function D(a,b){if(!a.somethingSelected())return b;a=[];for(var c=0;c=this.data.list.length?a=b?this.data.list.length-1:0:0>a&&(a=b?0:this.data.list.length-1);if(this.selectedHint!=a){if(b=this.hints.childNodes[this.selectedHint])b.className=b.className.replace(" CodeMirror-hint-active","");b=this.hints.childNodes[this.selectedHint=a];b.className+=" CodeMirror-hint-active";this.scrollToActive();g.signal(this.data, -"select",this.data.list[this.selectedHint],b)}},scrollToActive:function(){var a=this.hints.childNodes[this.selectedHint];a.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=a.offsetTop+a.offsetHeight-this.hints.clientHeight+3)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}};g.registerHelper("hint","auto",{resolve:function(a,b){var c= -a.getHelpers(b,"hint"),d;return c.length?(a=function(a,b,d){function e(c){if(c==f.length)return b(null);u(f[c],a,d,function(a){a&&0,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};g.defineOption("hintOptions",null)}); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// declare global: DOMRect + +(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"; + + var HINT_ELEMENT_CLASS = "CodeMirror-hint"; + var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active"; + + // This is the old interface, kept around for now to stay + // backwards-compatible. + CodeMirror.showHint = function(cm, getHints, options) { + if (!getHints) return cm.showHint(options); + if (options && options.async) getHints.async = true; + var newOpts = {hint: getHints}; + if (options) for (var prop in options) newOpts[prop] = options[prop]; + return cm.showHint(newOpts); + }; + + CodeMirror.defineExtension("showHint", function(options) { + options = parseOptions(this, this.getCursor("start"), options); + var selections = this.listSelections() + if (selections.length > 1) return; + // By default, don't allow completion when something is selected. + // A hint function can have a `supportsSelection` property to + // indicate that it can handle selections. + if (this.somethingSelected()) { + if (!options.hint.supportsSelection) return; + // Don't try with cross-line selections + for (var i = 0; i < selections.length; i++) + if (selections[i].head.line != selections[i].anchor.line) return; + } + + if (this.state.completionActive) this.state.completionActive.close(); + var completion = this.state.completionActive = new Completion(this, options); + if (!completion.options.hint) return; + + CodeMirror.signal(this, "startCompletion", this); + completion.update(true); + }); + + CodeMirror.defineExtension("closeHint", function() { + if (this.state.completionActive) this.state.completionActive.close() + }) + + function Completion(cm, options) { + this.cm = cm; + this.options = options; + this.widget = null; + this.debounce = 0; + this.tick = 0; + this.startPos = this.cm.getCursor("start"); + this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length; + + if (this.options.updateOnCursorActivity) { + var self = this; + cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); }); + } + } + + var requestAnimationFrame = window.requestAnimationFrame || function(fn) { + return setTimeout(fn, 1000/60); + }; + var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout; + + Completion.prototype = { + close: function() { + if (!this.active()) return; + this.cm.state.completionActive = null; + this.tick = null; + if (this.options.updateOnCursorActivity) { + this.cm.off("cursorActivity", this.activityFunc); + } + + if (this.widget && this.data) CodeMirror.signal(this.data, "close"); + if (this.widget) this.widget.close(); + CodeMirror.signal(this.cm, "endCompletion", this.cm); + }, + + active: function() { + return this.cm.state.completionActive == this; + }, + + pick: function(data, i) { + var completion = data.list[i], self = this; + this.cm.operation(function() { + if (completion.hint) + completion.hint(self.cm, data, completion); + else + self.cm.replaceRange(getText(completion), completion.from || data.from, + completion.to || data.to, "complete"); + CodeMirror.signal(data, "pick", completion); + self.cm.scrollIntoView(); + }); + if (this.options.closeOnPick) { + this.close(); + } + }, + + cursorActivity: function() { + if (this.debounce) { + cancelAnimationFrame(this.debounce); + this.debounce = 0; + } + + var identStart = this.startPos; + if(this.data) { + identStart = this.data.from; + } + + var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line); + if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || + pos.ch < identStart.ch || this.cm.somethingSelected() || + (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) { + this.close(); + } else { + var self = this; + this.debounce = requestAnimationFrame(function() {self.update();}); + if (this.widget) this.widget.disable(); + } + }, + + update: function(first) { + if (this.tick == null) return + var self = this, myTick = ++this.tick + fetchHints(this.options.hint, this.cm, this.options, function(data) { + if (self.tick == myTick) self.finishUpdate(data, first) + }) + }, + + finishUpdate: function(data, first) { + if (this.data) CodeMirror.signal(this.data, "update"); + + var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle); + if (this.widget) this.widget.close(); + + this.data = data; + + if (data && data.list.length) { + if (picked && data.list.length == 1) { + this.pick(data, 0); + } else { + this.widget = new Widget(this, data); + CodeMirror.signal(data, "shown"); + } + } + } + }; + + function parseOptions(cm, pos, options) { + var editor = cm.options.hintOptions; + var out = {}; + for (var prop in defaultOptions) out[prop] = defaultOptions[prop]; + if (editor) for (var prop in editor) + if (editor[prop] !== undefined) out[prop] = editor[prop]; + if (options) for (var prop in options) + if (options[prop] !== undefined) out[prop] = options[prop]; + if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos) + return out; + } + + function getText(completion) { + if (typeof completion == "string") return completion; + else return completion.text; + } + + function buildKeyMap(completion, handle) { + var baseMap = { + Up: function() {handle.moveFocus(-1);}, + Down: function() {handle.moveFocus(1);}, + PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);}, + PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);}, + Home: function() {handle.setFocus(0);}, + End: function() {handle.setFocus(handle.length - 1);}, + Enter: handle.pick, + Tab: handle.pick, + Esc: handle.close + }; + + var mac = /Mac/.test(navigator.platform); + + if (mac) { + baseMap["Ctrl-P"] = function() {handle.moveFocus(-1);}; + baseMap["Ctrl-N"] = function() {handle.moveFocus(1);}; + } + + var custom = completion.options.customKeys; + var ourMap = custom ? {} : baseMap; + function addBinding(key, val) { + var bound; + if (typeof val != "string") + bound = function(cm) { return val(cm, handle); }; + // This mechanism is deprecated + else if (baseMap.hasOwnProperty(val)) + bound = baseMap[val]; + else + bound = val; + ourMap[key] = bound; + } + if (custom) + for (var key in custom) if (custom.hasOwnProperty(key)) + addBinding(key, custom[key]); + var extra = completion.options.extraKeys; + if (extra) + for (var key in extra) if (extra.hasOwnProperty(key)) + addBinding(key, extra[key]); + return ourMap; + } + + function getHintElement(hintsElement, el) { + while (el && el != hintsElement) { + if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el; + el = el.parentNode; + } + } + + function Widget(completion, data) { + this.completion = completion; + this.data = data; + this.picked = false; + var widget = this, cm = completion.cm; + var ownerDocument = cm.getInputField().ownerDocument; + var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow; + + var hints = this.hints = ownerDocument.createElement("ul"); + var theme = completion.cm.options.theme; + hints.className = "CodeMirror-hints " + theme; + this.selectedHint = data.selectedHint || 0; + + var completions = data.list; + for (var i = 0; i < completions.length; ++i) { + var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i]; + var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS); + if (cur.className != null) className = cur.className + " " + className; + elt.className = className; + if (cur.render) cur.render(elt, data, cur); + else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur))); + elt.hintId = i; + } + + var container = completion.options.container || ownerDocument.body; + var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null); + var left = pos.left, top = pos.bottom, below = true; + var offsetLeft = 0, offsetTop = 0; + if (container !== ownerDocument.body) { + // We offset the cursor position because left and top are relative to the offsetParent's top left corner. + var isContainerPositioned = ['absolute', 'relative', 'fixed'].indexOf(parentWindow.getComputedStyle(container).position) !== -1; + var offsetParent = isContainerPositioned ? container : container.offsetParent; + var offsetParentPosition = offsetParent.getBoundingClientRect(); + var bodyPosition = ownerDocument.body.getBoundingClientRect(); + offsetLeft = (offsetParentPosition.left - bodyPosition.left - offsetParent.scrollLeft); + offsetTop = (offsetParentPosition.top - bodyPosition.top - offsetParent.scrollTop); + } + hints.style.left = (left - offsetLeft) + "px"; + hints.style.top = (top - offsetTop) + "px"; + + // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor. + var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth); + var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight); + container.appendChild(hints); + + var box = completion.options.moveOnOverlap ? hints.getBoundingClientRect() : new DOMRect(); + var scrolls = completion.options.paddingForScrollbar ? hints.scrollHeight > hints.clientHeight + 1 : false; + + // Compute in the timeout to avoid reflow on init + var startScroll; + setTimeout(function() { startScroll = cm.getScrollInfo(); }); + + var overlapY = box.bottom - winH; + if (overlapY > 0) { + var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); + if (curTop - height > 0) { // Fits above cursor + hints.style.top = (top = pos.top - height - offsetTop) + "px"; + below = false; + } else if (height > winH) { + hints.style.height = (winH - 5) + "px"; + hints.style.top = (top = pos.bottom - box.top - offsetTop) + "px"; + var cursor = cm.getCursor(); + if (data.from.ch != cursor.ch) { + pos = cm.cursorCoords(cursor); + hints.style.left = (left = pos.left - offsetLeft) + "px"; + box = hints.getBoundingClientRect(); + } + } + } + var overlapX = box.right - winW; + if (overlapX > 0) { + if (box.right - box.left > winW) { + hints.style.width = (winW - 5) + "px"; + overlapX -= (box.right - box.left) - winW; + } + hints.style.left = (left = pos.left - overlapX - offsetLeft) + "px"; + } + if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling) + node.style.paddingRight = cm.display.nativeBarWidth + "px" + + cm.addKeyMap(this.keyMap = buildKeyMap(completion, { + moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); }, + setFocus: function(n) { widget.changeActive(n); }, + menuSize: function() { return widget.screenAmount(); }, + length: completions.length, + close: function() { completion.close(); }, + pick: function() { widget.pick(); }, + data: data + })); + + if (completion.options.closeOnUnfocus) { + var closingOnBlur; + cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); }); + cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); }); + } + + cm.on("scroll", this.onScroll = function() { + var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect(); + var newTop = top + startScroll.top - curScroll.top; + var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop); + if (!below) point += hints.offsetHeight; + if (point <= editor.top || point >= editor.bottom) return completion.close(); + hints.style.top = newTop + "px"; + hints.style.left = (left + startScroll.left - curScroll.left) + "px"; + }); + + CodeMirror.on(hints, "dblclick", function(e) { + var t = getHintElement(hints, e.target || e.srcElement); + if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();} + }); + + CodeMirror.on(hints, "click", function(e) { + var t = getHintElement(hints, e.target || e.srcElement); + if (t && t.hintId != null) { + widget.changeActive(t.hintId); + if (completion.options.completeOnSingleClick) widget.pick(); + } + }); + + CodeMirror.on(hints, "mousedown", function() { + setTimeout(function(){cm.focus();}, 20); + }); + + // The first hint doesn't need to be scrolled to on init + var selectedHintRange = this.getSelectedHintRange(); + if (selectedHintRange.from !== 0 || selectedHintRange.to !== 0) { + this.scrollToActive(); + } + + CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]); + return true; + } + + Widget.prototype = { + close: function() { + if (this.completion.widget != this) return; + this.completion.widget = null; + this.hints.parentNode.removeChild(this.hints); + this.completion.cm.removeKeyMap(this.keyMap); + + var cm = this.completion.cm; + if (this.completion.options.closeOnUnfocus) { + cm.off("blur", this.onBlur); + cm.off("focus", this.onFocus); + } + cm.off("scroll", this.onScroll); + }, + + disable: function() { + this.completion.cm.removeKeyMap(this.keyMap); + var widget = this; + this.keyMap = {Enter: function() { widget.picked = true; }}; + this.completion.cm.addKeyMap(this.keyMap); + }, + + pick: function() { + this.completion.pick(this.data, this.selectedHint); + }, + + changeActive: function(i, avoidWrap) { + if (i >= this.data.list.length) + i = avoidWrap ? this.data.list.length - 1 : 0; + else if (i < 0) + i = avoidWrap ? 0 : this.data.list.length - 1; + if (this.selectedHint == i) return; + var node = this.hints.childNodes[this.selectedHint]; + if (node) node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, ""); + node = this.hints.childNodes[this.selectedHint = i]; + node.className += " " + ACTIVE_HINT_ELEMENT_CLASS; + this.scrollToActive() + CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node); + }, + + scrollToActive: function() { + var selectedHintRange = this.getSelectedHintRange(); + var node1 = this.hints.childNodes[selectedHintRange.from]; + var node2 = this.hints.childNodes[selectedHintRange.to]; + var firstNode = this.hints.firstChild; + if (node1.offsetTop < this.hints.scrollTop) + this.hints.scrollTop = node1.offsetTop - firstNode.offsetTop; + else if (node2.offsetTop + node2.offsetHeight > this.hints.scrollTop + this.hints.clientHeight) + this.hints.scrollTop = node2.offsetTop + node2.offsetHeight - this.hints.clientHeight + firstNode.offsetTop; + }, + + screenAmount: function() { + return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1; + }, + + getSelectedHintRange: function() { + var margin = this.completion.options.scrollMargin || 0; + return { + from: Math.max(0, this.selectedHint - margin), + to: Math.min(this.data.list.length - 1, this.selectedHint + margin), + }; + } + }; + + function applicableHelpers(cm, helpers) { + if (!cm.somethingSelected()) return helpers + var result = [] + for (var i = 0; i < helpers.length; i++) + if (helpers[i].supportsSelection) result.push(helpers[i]) + return result + } + + function fetchHints(hint, cm, options, callback) { + if (hint.async) { + hint(cm, callback, options) + } else { + var result = hint(cm, options) + if (result && result.then) result.then(callback) + else callback(result) + } + } + + function resolveAutoHints(cm, pos) { + var helpers = cm.getHelpers(pos, "hint"), words + if (helpers.length) { + var resolved = function(cm, callback, options) { + var app = applicableHelpers(cm, helpers); + function run(i) { + if (i == app.length) return callback(null) + fetchHints(app[i], cm, options, function(result) { + if (result && result.list.length > 0) callback(result) + else run(i + 1) + }) + } + run(0) + } + resolved.async = true + resolved.supportsSelection = true + return resolved + } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) { + return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) } + } else if (CodeMirror.hint.anyword) { + return function(cm, options) { return CodeMirror.hint.anyword(cm, options) } + } else { + return function() {} + } + } + + CodeMirror.registerHelper("hint", "auto", { + resolve: resolveAutoHints + }); + + CodeMirror.registerHelper("hint", "fromList", function(cm, options) { + var cur = cm.getCursor(), token = cm.getTokenAt(cur) + var term, from = CodeMirror.Pos(cur.line, token.start), to = cur + if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) { + term = token.string.substr(0, cur.ch - token.start) + } else { + term = "" + from = cur + } + var found = []; + for (var i = 0; i < options.words.length; i++) { + var word = options.words[i]; + if (word.slice(0, term.length) == term) + found.push(word); + } + + if (found.length) return {list: found, from: from, to: to}; + }); + + CodeMirror.commands.autocomplete = CodeMirror.showHint; + + var defaultOptions = { + hint: CodeMirror.hint.auto, + completeSingle: true, + alignWithWord: true, + closeCharacters: /[\s()\[\]{};:>,]/, + closeOnPick: true, + closeOnUnfocus: true, + updateOnCursorActivity: true, + completeOnSingleClick: true, + container: null, + customKeys: null, + extraKeys: null, + paddingForScrollbar: true, + moveOnOverlap: true, + }; + + CodeMirror.defineOption("hintOptions", null); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/sql-hint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/sql-hint.js index 77bbce1..dd6b421 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/sql-hint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/hint/sql-hint.js @@ -1,4 +1,4 @@ -'use strict';(function(g){"object"==typeof exports&&"object"==typeof module?g(require("../../lib/codemirror"),require("../../mode/sql/sql")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/sql/sql"],g):g(CodeMirror)})(function(g){function u(a){return"[object Array]"==Object.prototype.toString.call(a)}function E(a){a=a.doc.modeOption;"sql"===a&&(a="text/x-sql");return g.resolveMode(a).keywords}function F(a){a=a.doc.modeOption;"sql"===a&&(a="text/x-sql");return g.resolveMode(a).identifierQuote|| +'use strict';(function(g){"object"==typeof exports&&"object"==typeof module?g(require("../../lib/codemirror"),require("../../mode/sql")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/sql"],g):g(CodeMirror)})(function(g){function u(a){return"[object Array]"==Object.prototype.toString.call(a)}function E(a){a=a.doc.modeOption;"sql"===a&&(a="text/x-sql");return g.resolveMode(a).keywords}function F(a){a=a.doc.modeOption;"sql"===a&&(a="text/x-sql");return g.resolveMode(a).identifierQuote|| "`"}function t(a){return"string"==typeof a?a:a.text}function x(a,b){u(b)&&(b={columns:b});b.text||(b.text=a);return b}function G(a){var b={};if(u(a))for(var c=a.length-1;0<=c;c--){var d=a[c];b[t(d).toUpperCase()]=x(t(d),d)}else if(a)for(c in a)b[c.toUpperCase()]=x(c,a[c]);return b}function y(a){var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function z(a,b){var c=a.length;b=t(b).substr(0,c);return a.toUpperCase()===b.toUpperCase()}function q(a,b,c,d){if(u(c))for(var e=0;ek.ch&&(a.end=k.ch,a.string=a.string.slice(0,k.ch-a.start)); -var l=p.innerMode(c.getMode(),a.state);if(l.mode.xmlCurrentTag){var t=[],m=!1,n=/\btag\b/.test(a.type)&&!/>$/.test(a.string),z=n&&/^\w/.test(a.string),w;if(z){var d=c.getLine(k.line).slice(Math.max(0,a.start-2),a.start);(d=/<\/$/.test(d)?"close":/<$/.test(d)?"open":null)&&(w=a.start-("close"==d?2:1))}else n&&"<"==a.string?d="open":n&&"")}else{e=(n=x&&b[x.name])&&n.attrs;b=b["!attrs"];if(!e&&!b)return;if(!e)e=b;else if(b){d={};for(var q in b)b.hasOwnProperty(q)&&(d[q]=b[q]);for(q in e)e.hasOwnProperty(q)&&(d[q]=e[q]);e=d}if("string"==a.type|| -"="==a.string){d=c.getRange(v(k.line,Math.max(0,k.ch-60)),v(k.line,"string"==a.type?a.start:a.end));b=d.match(/([^\s\u00a0=<>"']+)=$/);var r;if(!b||!e.hasOwnProperty(b[1])||!(r=e[b[1]]))return;"function"==typeof r&&(r=r.call(this,c));"string"==a.type&&(g=a.string,m=0,/['"]/.test(a.string.charAt(0))&&(h=a.string.charAt(0),g=a.string.slice(1),m++),b=a.string.length,/['"]/.test(a.string.charAt(b-1))&&(h=a.string.charAt(b-1),g=a.string.substr(m,b-2)),m&&(c=c.getLine(k.line),c.length>a.end&&c.charAt(a.end)== -h&&a.end++),m=!0);for(c=0;c= 0; + else return hint.lastIndexOf(typed, 0) == 0; + } + + function getHints(cm, options) { + var tags = options && options.schemaInfo; + var quote = (options && options.quoteChar) || '"'; + var matchInMiddle = options && options.matchInMiddle; + if (!tags) return; + var cur = cm.getCursor(), token = cm.getTokenAt(cur); + if (token.end > cur.ch) { + token.end = cur.ch; + token.string = token.string.slice(0, cur.ch - token.start); + } + var inner = CodeMirror.innerMode(cm.getMode(), token.state); + if (!inner.mode.xmlCurrentTag) return + var result = [], replaceToken = false, prefix; + var tag = /\btag\b/.test(token.type) && !/>$/.test(token.string); + var tagName = tag && /^\w/.test(token.string), tagStart; + + if (tagName) { + var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start); + var tagType = /<\/$/.test(before) ? "close" : /<$/.test(before) ? "open" : null; + if (tagType) tagStart = token.start - (tagType == "close" ? 2 : 1); + } else if (tag && token.string == "<") { + tagType = "open"; + } else if (tag && token.string == ""); + } else { + // Attribute completion + var curTag = tagInfo && tags[tagInfo.name], attrs = curTag && curTag.attrs; + var globalAttrs = tags["!attrs"]; + if (!attrs && !globalAttrs) return; + if (!attrs) { + attrs = globalAttrs; + } else if (globalAttrs) { // Combine tag-local and global attributes + var set = {}; + for (var nm in globalAttrs) if (globalAttrs.hasOwnProperty(nm)) set[nm] = globalAttrs[nm]; + for (var nm in attrs) if (attrs.hasOwnProperty(nm)) set[nm] = attrs[nm]; + attrs = set; + } + if (token.type == "string" || token.string == "=") { // A value + var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)), + Pos(cur.line, token.type == "string" ? token.start : token.end)); + var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues; + if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return; + if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget + if (token.type == "string") { + prefix = token.string; + var n = 0; + if (/['"]/.test(token.string.charAt(0))) { + quote = token.string.charAt(0); + prefix = token.string.slice(1); + n++; + } + var len = token.string.length; + if (/['"]/.test(token.string.charAt(len - 1))) { + quote = token.string.charAt(len - 1); + prefix = token.string.substr(n, len - 2); + } + if (n) { // an opening quote + var line = cm.getLine(cur.line); + if (line.length > token.end && line.charAt(token.end) == quote) token.end++; // include a closing quote + } + replaceToken = true; + } + var returnHintsFromAtValues = function(atValues) { + if (atValues) + for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle)) + result.push(quote + atValues[i] + quote); + return returnHints(); + }; + if (atValues && atValues.then) return atValues.then(returnHintsFromAtValues); + return returnHintsFromAtValues(atValues); + } else { // An attribute name + if (token.type == "attribute") { + prefix = token.string; + replaceToken = true; + } + for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || matches(attr, prefix, matchInMiddle))) + result.push(attr); + } + } + function returnHints() { + return { + list: result, + from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur, + to: replaceToken ? Pos(cur.line, token.end) : cur + }; + } + return returnHints(); + } + + CodeMirror.registerHelper("hint", "xml", getHints); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/coffeescript-lint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/coffeescript-lint.js index d32990c..a54c703 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/coffeescript-lint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/coffeescript-lint.js @@ -1,2 +1,47 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){a.registerHelper("lint","coffeescript",function(b){var c=[];if(!window.coffeelint)return window.console&&window.console.error("Error: window.coffeelint not defined, CodeMirror CoffeeScript linting cannot run."),c;try{var f=coffeelint.lint(b);for(b=0;b=f}},"es6","es3"); -(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){a.registerHelper("lint","javascript",function(c,b){if(!window.JSHINT)return window.console&&window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run."),[];b.indent||(b.indent=1);JSHINT(c,b,b.globals);c=JSHINT.data().errors;b=[];if(c)for(var e=0;e=d.line)window.console&&window.console.warn("Cannot display JSHint error (invalid line "+d.line+")",d);else{var f=d.character-1,g=f+1;if(d.evidence){var h=d.evidence.substring(f).search(/.\b/);-1 -1) { + end += index; + } + } + + // Convert to format expected by validation service + var hint = { + message: error.reason, + severity: error.code ? (error.code.startsWith('W') ? "warning" : "error") : "error", + from: CodeMirror.Pos(error.line - 1, start), + to: CodeMirror.Pos(error.line - 1, end) + }; + + output.push(hint); + } + } + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/json-lint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/json-lint.js index 01ace27..ac1d6ec 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/json-lint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/json-lint.js @@ -1,2 +1,40 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){a.registerHelper("lint","json",function(e){var d=[];if(!window.jsonlint)return window.console&&window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run."),d;var c=window.jsonlint.parser||window.jsonlint;c.parseError=function(c,b){b=b.loc;d.push({from:a.Pos(b.first_line- -1,b.first_column),to:a.Pos(b.last_line-1,b.last_column),message:c})};try{c.parse(e)}catch(f){}return d})}); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Depends on jsonlint.js from https://github.com/zaach/jsonlint + +// declare global: jsonlint + +(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.registerHelper("lint", "json", function(text) { + var found = []; + if (!window.jsonlint) { + if (window.console) { + window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run."); + } + return found; + } + // for jsonlint's web dist jsonlint is exported as an object with a single property parser, of which parseError + // is a subproperty + var jsonlint = window.jsonlint.parser || window.jsonlint + jsonlint.parseError = function(str, hash) { + var loc = hash.loc; + found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column), + to: CodeMirror.Pos(loc.last_line - 1, loc.last_column), + message: str}); + }; + try { jsonlint.parse(text); } + catch(e) {} + return found; +}); + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/lint.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/lint.css index 2120ceb..0871865 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/lint.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/lint.css @@ -1 +1,71 @@ -.CodeMirror-lint-markers{width:16px}.CodeMirror-lint-tooltip{background-color:#ffd;border:1px solid #000;border-radius:4px 4px 4px 4px;color:#000;font-family:monospace;font-size:10pt;overflow:hidden;padding:2px 5px;position:fixed;white-space:pre;white-space:pre-wrap;z-index:100;max-width:600px;opacity:0;transition:opacity .4s;-moz-transition:opacity .4s;-webkit-transition:opacity .4s;-o-transition:opacity .4s;-ms-transition:opacity .4s}.CodeMirror-lint-mark-error,.CodeMirror-lint-mark-warning{background-position:left bottom;background-repeat:repeat-x}.CodeMirror-lint-mark-error{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==)}.CodeMirror-lint-mark-warning{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=)}.CodeMirror-lint-marker-error,.CodeMirror-lint-marker-warning{background-position:center center;background-repeat:no-repeat;cursor:pointer;display:inline-block;height:16px;width:16px;vertical-align:middle;position:relative}.CodeMirror-lint-message-error,.CodeMirror-lint-message-warning{padding-left:18px;background-position:top left;background-repeat:no-repeat}.CodeMirror-lint-marker-error,.CodeMirror-lint-message-error{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=)}.CodeMirror-lint-marker-warning,.CodeMirror-lint-message-warning{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=)}.CodeMirror-lint-marker-multiple{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC);background-repeat:no-repeat;background-position:right bottom;width:100%;height:100%} \ No newline at end of file +/* The lint marker gutter */ +.CodeMirror-lint-markers { + width: 16px; +} + +.CodeMirror-lint-tooltip { + background-color: #ffd; + border: 1px solid black; + border-radius: 4px 4px 4px 4px; + color: black; + font-family: monospace; + font-size: 10pt; + overflow: hidden; + padding: 2px 5px; + position: fixed; + white-space: pre; + white-space: pre-wrap; + z-index: 100; + max-width: 600px; + opacity: 0; + transition: opacity .4s; + -moz-transition: opacity .4s; + -webkit-transition: opacity .4s; + -o-transition: opacity .4s; + -ms-transition: opacity .4s; +} + +.CodeMirror-lint-mark { + background-position: left bottom; + background-repeat: repeat-x; +} + +.CodeMirror-lint-mark-warning { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); +} + +.CodeMirror-lint-mark-error { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg=="); +} + +.CodeMirror-lint-marker { + background-position: center center; + background-repeat: no-repeat; + cursor: pointer; + display: inline-block; + height: 16px; + width: 16px; + vertical-align: middle; + position: relative; +} + +.CodeMirror-lint-message { + padding-left: 18px; + background-position: top left; + background-repeat: no-repeat; +} + +.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII="); +} + +.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); +} + +.CodeMirror-lint-marker-multiple { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC"); + background-repeat: no-repeat; + background-position: right bottom; + width: 100%; height: 100%; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/lint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/lint.js index bf5e699..395f0d9 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/lint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/lint.js @@ -1,9 +1,259 @@ -'use strict';(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){function v(a,b,d){function e(a){if(!c.parentNode)return f.off(document,"mousemove",e);c.style.top=Math.max(0,a.clientY-c.offsetHeight-5)+"px";c.style.left=a.clientX+5+"px"}var c=document.createElement("div");c.className="CodeMirror-lint-tooltip cm-s-"+a.options.theme;c.appendChild(d.cloneNode(!0)); -a.state.lint.options.selfContain?a.getWrapperElement().appendChild(c):document.body.appendChild(c);f.on(document,"mousemove",e);e(b);null!=c.style.opacity&&(c.style.opacity=1);return c}function w(a){a.parentNode&&(null==a.style.opacity&&a.parentNode&&a.parentNode.removeChild(a),a.style.opacity=0,setTimeout(function(){a.parentNode&&a.parentNode.removeChild(a)},600))}function q(a,b,d,e){function c(){f.off(e,"mouseout",c);g&&(w(g),g=null)}var g=v(a,b,d),m=setInterval(function(){if(g)for(var a=e;;a=a.parentNode){a&& -11==a.nodeType&&(a=a.host);if(a==document.body)return;if(!a){c();break}}if(!g)return clearInterval(m)},400);f.on(e,"mouseout",c)}function x(a,b,d){this.marked=[];this.options=b;this.timeout=null;this.hasGutter=d;this.onMouseOver=function(b){var c=b.target||b.srcElement;if(/\bCodeMirror-lint-mark-/.test(c.className)){c=c.getBoundingClientRect();var d=a.findMarksAt(a.coordsChar({left:(c.left+c.right)/2,top:(c.top+c.bottom)/2},"client"));c=[];for(var e=0;e -1 ? false : message.push(item.message) }); + + var maxSeverity = null; + var tipLabel = state.hasGutter && document.createDocumentFragment(); + + for (var i = 0; i < anns.length; ++i) { + var ann = anns[i]; + var severity = ann.severity; + if (!severity) severity = "error"; + maxSeverity = getMaxSeverity(maxSeverity, severity); + + if (options.formatAnnotation) ann = options.formatAnnotation(ann); + if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann)); + + if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, { + className: "CodeMirror-lint-mark CodeMirror-lint-mark-" + severity, + __annotation: ann + })); + } + // use original annotations[line] to show multiple messages + if (state.hasGutter) + cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1, + state.options.tooltips)); + } + if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); + } + + function onChange(cm) { + var state = cm.state.lint; + if (!state) return; + clearTimeout(state.timeout); + state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500); + } + + function popupTooltips(cm, annotations, e) { + var target = e.target || e.srcElement; + var tooltip = document.createDocumentFragment(); + for (var i = 0; i < annotations.length; i++) { + var ann = annotations[i]; + tooltip.appendChild(annotationTooltip(ann)); + } + showTooltipFor(cm, e, tooltip, target); + } + + function onMouseOver(cm, e) { + var target = e.target || e.srcElement; + if (!/\bCodeMirror-lint-mark-/.test(target.className)) return; + var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2; + var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client")); + + var annotations = []; + for (var i = 0; i < spans.length; ++i) { + var ann = spans[i].__annotation; + if (ann) annotations.push(ann); + } + if (annotations.length) popupTooltips(cm, annotations, e); + } + + CodeMirror.defineOption("lint", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + clearMarks(cm); + if (cm.state.lint.options.lintOnChange !== false) + cm.off("change", onChange); + CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver); + clearTimeout(cm.state.lint.timeout); + delete cm.state.lint; + } + + if (val) { + var gutters = cm.getOption("gutters"), hasLintGutter = false; + for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true; + var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter); + if (state.options.lintOnChange !== false) + cm.on("change", onChange); + if (state.options.tooltips != false && state.options.tooltips != "gutter") + CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver); + + startLinting(cm); + } + }); + + CodeMirror.defineExtension("performLint", function() { + if (this.state.lint) startLinting(this); + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/yaml-lint.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/yaml-lint.js index 39a372f..b4ac5ab 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/yaml-lint.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/lint/yaml-lint.js @@ -1 +1,41 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){a.registerHelper("lint","yaml",function(b){var c=[];if(!window.jsyaml)return window.console&&window.console.error("Error: window.jsyaml not defined, CodeMirror YAML linting cannot run."),c;try{jsyaml.loadAll(b)}catch(d){b=(b=d.mark)?a.Pos(b.line,b.column):a.Pos(0,0),c.push({from:b,to:b,message:d.message})}return c})}); +// 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"; + +// Depends on js-yaml.js from https://github.com/nodeca/js-yaml + +// declare global: jsyaml + +CodeMirror.registerHelper("lint", "yaml", function(text) { + var found = []; + if (!window.jsyaml) { + if (window.console) { + window.console.error("Error: window.jsyaml not defined, CodeMirror YAML linting cannot run."); + } + return found; + } + try { jsyaml.loadAll(text); } + catch(e) { + var loc = e.mark, + // js-yaml YAMLException doesn't always provide an accurate lineno + // e.g., when there are multiple yaml docs + // --- + // --- + // foo:bar + from = loc ? CodeMirror.Pos(loc.line, loc.column) : CodeMirror.Pos(0, 0), + to = from; + found.push({ from: from, to: to, message: e.message }); + } + return found; +}); + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/merge/merge.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/merge/merge.css index b660ef3..dadd7f5 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/merge/merge.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/merge/merge.css @@ -1 +1,119 @@ -.CodeMirror-merge{position:relative;border:1px solid #ddd;white-space:pre}.CodeMirror-merge,.CodeMirror-merge .CodeMirror{height:350px}.CodeMirror-merge-2pane .CodeMirror-merge-pane{width:47%}.CodeMirror-merge-2pane .CodeMirror-merge-gap{width:6%}.CodeMirror-merge-3pane .CodeMirror-merge-pane{width:31%}.CodeMirror-merge-3pane .CodeMirror-merge-gap{width:3.5%}.CodeMirror-merge-pane{display:inline-block;white-space:normal;vertical-align:top}.CodeMirror-merge-pane-rightmost{position:absolute;right:0;z-index:1}.CodeMirror-merge-gap{z-index:2;display:inline-block;height:100%;-moz-box-sizing:border-box;box-sizing:border-box;overflow:hidden;border-left:1px solid #ddd;border-right:1px solid #ddd;position:relative;background:#f8f8f8}.CodeMirror-merge-scrolllock-wrap{position:absolute;bottom:0;left:50%}.CodeMirror-merge-scrolllock{position:relative;left:-50%;cursor:pointer;color:#555;line-height:1}.CodeMirror-merge-scrolllock:after{content:"\21db\00a0\00a0\21da"}.CodeMirror-merge-scrolllock.CodeMirror-merge-scrolllock-enabled:after{content:"\21db\21da"}.CodeMirror-merge-copybuttons-left,.CodeMirror-merge-copybuttons-right{position:absolute;left:0;top:0;right:0;bottom:0;line-height:1}.CodeMirror-merge-copy{position:absolute;cursor:pointer;color:#44c;z-index:3}.CodeMirror-merge-copy-reverse{position:absolute;cursor:pointer;color:#44c}.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy{left:2px}.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy{right:2px}.CodeMirror-merge-l-inserted,.CodeMirror-merge-r-inserted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==);background-position:bottom left;background-repeat:repeat-x}.CodeMirror-merge-l-deleted,.CodeMirror-merge-r-deleted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==);background-position:bottom left;background-repeat:repeat-x}.CodeMirror-merge-r-chunk{background:#ffffe0}.CodeMirror-merge-r-chunk-start{border-top:1px solid #ee8}.CodeMirror-merge-r-chunk-end{border-bottom:1px solid #ee8}.CodeMirror-merge-r-connect{fill:#ffffe0;stroke:#ee8;stroke-width:1px}.CodeMirror-merge-l-chunk{background:#eef}.CodeMirror-merge-l-chunk-start{border-top:1px solid #88e}.CodeMirror-merge-l-chunk-end{border-bottom:1px solid #88e}.CodeMirror-merge-l-connect{fill:#eef;stroke:#88e;stroke-width:1px}.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk{background:#dfd}.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start{border-top:1px solid #4e4}.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end{border-bottom:1px solid #4e4}.CodeMirror-merge-collapsed-widget:before{content:"(...)"}.CodeMirror-merge-collapsed-widget{cursor:pointer;color:#88b;background:#eef;border:1px solid #ddf;font-size:90%;padding:0 3px;border-radius:4px}.CodeMirror-merge-collapsed-line .CodeMirror-gutter-elt{display:none} \ No newline at end of file +.CodeMirror-merge { + position: relative; + border: 1px solid #ddd; + white-space: pre; +} + +.CodeMirror-merge, .CodeMirror-merge .CodeMirror { + height: 350px; +} + +.CodeMirror-merge-2pane .CodeMirror-merge-pane { width: 47%; } +.CodeMirror-merge-2pane .CodeMirror-merge-gap { width: 6%; } +.CodeMirror-merge-3pane .CodeMirror-merge-pane { width: 31%; } +.CodeMirror-merge-3pane .CodeMirror-merge-gap { width: 3.5%; } + +.CodeMirror-merge-pane { + display: inline-block; + white-space: normal; + vertical-align: top; +} +.CodeMirror-merge-pane-rightmost { + position: absolute; + right: 0px; + z-index: 1; +} + +.CodeMirror-merge-gap { + z-index: 2; + display: inline-block; + height: 100%; + -moz-box-sizing: border-box; + box-sizing: border-box; + overflow: hidden; + border-left: 1px solid #ddd; + border-right: 1px solid #ddd; + position: relative; + background: #f8f8f8; +} + +.CodeMirror-merge-scrolllock-wrap { + position: absolute; + bottom: 0; left: 50%; +} +.CodeMirror-merge-scrolllock { + position: relative; + left: -50%; + cursor: pointer; + color: #555; + line-height: 1; +} +.CodeMirror-merge-scrolllock:after { + content: "\21db\00a0\00a0\21da"; +} +.CodeMirror-merge-scrolllock.CodeMirror-merge-scrolllock-enabled:after { + content: "\21db\21da"; +} + +.CodeMirror-merge-copybuttons-left, .CodeMirror-merge-copybuttons-right { + position: absolute; + left: 0; top: 0; + right: 0; bottom: 0; + line-height: 1; +} + +.CodeMirror-merge-copy { + position: absolute; + cursor: pointer; + color: #44c; + z-index: 3; +} + +.CodeMirror-merge-copy-reverse { + position: absolute; + cursor: pointer; + color: #44c; +} + +.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy { left: 2px; } +.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy { right: 2px; } + +.CodeMirror-merge-r-inserted, .CodeMirror-merge-l-inserted { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==); + background-position: bottom left; + background-repeat: repeat-x; +} + +.CodeMirror-merge-r-deleted, .CodeMirror-merge-l-deleted { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==); + background-position: bottom left; + background-repeat: repeat-x; +} + +.CodeMirror-merge-r-chunk { background: #ffffe0; } +.CodeMirror-merge-r-chunk-start { border-top: 1px solid #ee8; } +.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #ee8; } +.CodeMirror-merge-r-connect { fill: #ffffe0; stroke: #ee8; stroke-width: 1px; } + +.CodeMirror-merge-l-chunk { background: #eef; } +.CodeMirror-merge-l-chunk-start { border-top: 1px solid #88e; } +.CodeMirror-merge-l-chunk-end { border-bottom: 1px solid #88e; } +.CodeMirror-merge-l-connect { fill: #eef; stroke: #88e; stroke-width: 1px; } + +.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk { background: #dfd; } +.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start { border-top: 1px solid #4e4; } +.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #4e4; } + +.CodeMirror-merge-collapsed-widget:before { + content: "(...)"; +} +.CodeMirror-merge-collapsed-widget { + cursor: pointer; + color: #88b; + background: #eef; + border: 1px solid #ddf; + font-size: 90%; + padding: 0 3px; + border-radius: 4px; +} +.CodeMirror-merge-collapsed-line .CodeMirror-gutter-elt { display: none; } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/merge/merge.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/merge/merge.js index 4fc0506..827edb7 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/merge/merge.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/merge/merge.js @@ -1,39 +1,1006 @@ -'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(g,n,m){g instanceof String&&(g=String(g));for(var x=g.length,v=0;vc)return!1;var e=d.getScrollInfo();if("align"==a.mv.options.connect)w=e.top;else{var k=.5*e.clientHeight;w=e.top+k;var h=d.lineAtHeight(w,"local");for(var l=a.chunks,p,g,E,m=0;mh?(g=r.editFrom,E=r.origFrom):t>h&&(g=r.editTo,E=r.origTo));if(t<=h){p=r.editTo;var u=r.origTo}else n<=h&&(p=r.editFrom,u=r.origFrom)}h={before:p,after:g};u={before:u,after:E};d=V(d,b?h:u);b=V(f,b?u:h);var w=b.top-k+(w-d.top)/(d.bot-d.top)*(b.bot-b.top),D;w>e.top&&1>(D=e.top/k)?w=w*D+e.top*(1-D):(b=e.height-e.clientHeight-e.top)b&&1>(D=b/k)&&(w=w*D+(d.height-d.clientHeight-b)*(1-D)))}f.scrollTo(e.left, -w);f.state.scrollSetAt=c;f.state.scrollSetBy=a;return!0}function V(a,b){var c=b.after;null==c&&(c=a.lastLine()+1);return{top:a.heightAtLine(b.before||0,"local"),bot:a.heightAtLine(c,"local")}}function W(a,b,c){(a.lockScroll=b)&&0!=c&&y(a,DIFF_INSERT)&&A(a);(b?g.addClass:g.rmClass)(a.lockButton,"CodeMirror-merge-scrolllock-enabled")}function K(a,b,c){for(var d=0;dc.to&&(M(a,b,d,c.marked,c.to,e.to,f),c.to=e.to))})}function N(a,b,c,d,f,e){var k=c.classLocation;b=a.getLineHandle(b);for(var h=0;hu&&(r&&(h(m, -u),r=!1),m=t)):(r=!0,u==c&&(u=H(l,t,!0),l=0<(p.line-l.line||p.ch-l.ch)?p:l,t=0>(g.line-u.line||g.ch-u.ch)?g:u,l.line==t.line&&l.ch==t.ch||d.push(a.markText(l,t,{className:E})),l=u))}r&&h(m,l.line+1)}function A(a){if(a.showDifferences){if(a.svg){G(a.svg);var b=a.gap.offsetWidth;Z(a.svg,"width",b,"height",a.gap.offsetHeight)}a.copyButtons&&G(a.copyButtons);var c=a.edit.getViewport(),d=a.orig.getViewport(),f=a.mv.wrap.getBoundingClientRect().top,e=f-a.edit.getScrollerElement().getBoundingClientRect().top+ -a.edit.getScrollInfo().top;f=f-a.orig.getScrollerElement().getBoundingClientRect().top+a.orig.getScrollInfo().top;for(var k=0;k=c.from&&h.origFrom<=d.to&&h.origTo>=d.from){var l=a,g=f,C=e,m=b,n="left"==l.type,r=l.orig.heightAtLine(h.origFrom,"local",!0)-g;if(l.svg){var q=r,t=l.edit.heightAtLine(h.editFrom,"local",!0)-C;if(n){var u=q;q=t;t=u}g=l.orig.heightAtLine(h.origTo,"local",!0)-g;var w=l.edit.heightAtLine(h.editTo,"local", -!0)-C;n&&(u=g,g=w,w=u);n=" C "+m/2+" "+t+" "+m/2+" "+q+" "+(m+2)+" "+q;q=" C "+m/2+" "+g+" "+m/2+" "+w+" -1 "+w;Z(l.svg.appendChild(document.createElementNS("http://www.w3.org/2000/svg","path")),"d","M -1 "+t+n+" L "+(m+2)+" "+g+q+" z","class",l.classes.connect)}l.copyButtons&&(m=l.copyButtons.appendChild(z("div","left"==l.type?"\u21dd":"\u21dc","CodeMirror-merge-copy")),t=l.mv.options.allowEditingOriginals,m.title=l.edit.phrase(t?"Push to left":"Revert chunk"),m.chunk=h,m.style.top=(h.origTo>h.origFrom? -r:l.edit.heightAtLine(h.editFrom,"local")-C)+"px",t&&(C=l.edit.heightAtLine(h.editFrom,"local")-C,r=l.copyButtons.appendChild(z("div","right"==l.type?"\u21dd":"\u21dc","CodeMirror-merge-copy-reverse")),r.title="Push to right",r.chunk={editFrom:h.origFrom,editTo:h.origTo,origFrom:h.editFrom,origTo:h.editTo},r.style.top=C+"px","right"==l.type?r.style.left="2px":r.style.right="2px"))}}}}function aa(a,b){for(var c=0,d=0,f=0;fa&&e.editFrom<=a)return null;if(e.editFrom> -a)break;c=e.editTo;d=e.origTo}return d+(a-c)}function O(a,b,c){var d=a.state.trackAlignable;a=a.firstLine();for(var f=0,e=[],k=0;;k++){for(var h=b[k],l=h?c?h.origFrom:h.editFrom:1E9;f -p){e++;f--;continue a}if(n.editTo>m){if(n.editFrom<=m)continue a;break}h+=n.origTo-n.origFrom-(n.editTo-n.editFrom);k++}m==p-h?(g[d]=p,e++):ma.lastLine()&&(b--,d=!1);var f=document.createElement("div");f.className="CodeMirror-merge-spacer";f.style.height=c+"px";f.style.minWidth="1px";return a.addLineWidget(b,f,{height:c,above:d,mergeSpacer:!0,handleMouseEvents:!0})}function ca(a,b,c,d){if(!a.diffOutOfDate){var f=d.origTo>c.lastLine()?q(d.origFrom- -1):q(d.origFrom,0),e=q(d.origTo,0),k=d.editTo>b.lastLine()?q(d.editFrom-1):q(d.editFrom,0);d=q(d.editTo,0);var h=a.mv.options.revertChunk;h?h(a.mv,c,f,e,b,k,d):b.replaceRange(c.getRange(f,e),k,d)}}function da(a){var b=a.lockButton=z("div",null,"CodeMirror-merge-scrolllock"),c=z("div",[b],"CodeMirror-merge-scrolllock-wrap");g.on(b,"click",function(){W(a,!a.lockScroll)});b=[c];!1!==a.mv.options.revertButtons&&(a.copyButtons=z("div",null,"CodeMirror-merge-copybuttons-"+a.type),g.on(a.copyButtons,"click", -function(b){b=b.target||b.srcElement;b.chunk&&("CodeMirror-merge-copy-reverse"==b.className?ca(a,a.orig,a.edit,b.chunk):ca(a,a.edit,a.orig,b.chunk))}),b.unshift(a.copyButtons));"align"!=a.mv.options.connect&&((c=document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg"))&&!c.createSVGRect&&(c=null),(a.svg=c)&&b.push(c));return a.gap=z("div",b,"CodeMirror-merge-gap")}function ea(a){return"string"==typeof a?a:a.getValue()}function S(a,b,c){P||(P=new diff_match_patch);a=P.diff_main(a, -b);for(b=0;bg&&(k&&b.push({origFrom:d,origTo:p,editFrom:c,editTo:g}),c=h,d=m)}else H(g==DIFF_INSERT?f:e,h[1])}(c<=f.line|| -d<=e.line)&&b.push({origFrom:d,origTo:e.line+1,editFrom:c,editTo:f.line+1});return b}function Y(a,b){if(b==a.length-1)return!0;var c=a[b+1][1];if(1==c.length&&bb)a:{k=k.chunks;for(var l=k.length-1;0<=l;l--){var p=k[l];p=(h?p.origTo:p.editTo)-1;if(pf){h=p;break a}h=void 0}null!=h&&(null==c||(0>b?h>c:ha){var k=[{line:h,cm:d}];q.left&&k.push({line:aa(h,q.left.chunks),cm:q.left.orig});q.right&&k.push({line:aa(h,q.right.chunks),cm:q.right.orig});k=na(g,k);if(q.options.onCollapse)q.options.onCollapse(q,h,g,k)}}});"align"==b.connect&&(this.aligners= -[],L(this.left||this.right,!0));l&&l.registerEvents(m);m&&m.registerEvents(l);var y=function(){l&&A(l);m&&A(m)};g.on(window,"resize",y);var t=setInterval(function(){for(var a=r.parentNode;a&&a!=document.body;a=a.parentNode);a||(clearInterval(t),g.off(window,"resize",y))},5E3)};J.prototype={constructor:J,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(a){this.right&& -this.right.setShowDifferences(a);this.left&&this.left.setShowDifferences(a)},rightChunks:function(){if(this.right)return m(this.right),this.right.chunks},leftChunks:function(){if(this.left)return m(this.left),this.left.chunks}};var P,ha=1,B=2,I=4;R.prototype={signal:function(){g.signal(this,"realign");this.height=this.cm.doc.height},set:function(a,b){for(var c=-1;c now) return false; + + var sInfo = editor.getScrollInfo(); + if (dv.mv.options.connect == "align") { + targetPos = sInfo.top; + } else { + var halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen; + var mid = editor.lineAtHeight(midY, "local"); + var around = chunkBoundariesAround(dv.chunks, mid, toOrig); + var off = getOffsets(editor, toOrig ? around.edit : around.orig); + var offOther = getOffsets(other, toOrig ? around.orig : around.edit); + var ratio = (midY - off.top) / (off.bot - off.top); + var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top); + + var botDist, mix; + // Some careful tweaking to make sure no space is left out of view + // when scrolling to top or bottom. + if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) { + targetPos = targetPos * mix + sInfo.top * (1 - mix); + } else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) { + var otherInfo = other.getScrollInfo(); + var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos; + if (botDistOther > botDist && (mix = botDist / halfScreen) < 1) + targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix); + } + } + + other.scrollTo(sInfo.left, targetPos); + other.state.scrollSetAt = now; + other.state.scrollSetBy = dv; + return true; + } + + function getOffsets(editor, around) { + var bot = around.after; + if (bot == null) bot = editor.lastLine() + 1; + return {top: editor.heightAtLine(around.before || 0, "local"), + bot: editor.heightAtLine(bot, "local")}; + } + + function setScrollLock(dv, val, action) { + dv.lockScroll = val; + if (val && action != false) syncScroll(dv, DIFF_INSERT) && makeConnections(dv); + (val ? CodeMirror.addClass : CodeMirror.rmClass)(dv.lockButton, "CodeMirror-merge-scrolllock-enabled"); + } + + // Updating the marks for editor content + + function removeClass(editor, line, classes) { + var locs = classes.classLocation + for (var i = 0; i < locs.length; i++) { + editor.removeLineClass(line, locs[i], classes.chunk); + editor.removeLineClass(line, locs[i], classes.start); + editor.removeLineClass(line, locs[i], classes.end); + } + } + + function clearMarks(editor, arr, classes) { + for (var i = 0; i < arr.length; ++i) { + var mark = arr[i]; + if (mark instanceof CodeMirror.TextMarker) + mark.clear(); + else if (mark.parent) + removeClass(editor, mark, classes); + } + arr.length = 0; + } + + // FIXME maybe add a margin around viewport to prevent too many updates + function updateMarks(editor, diff, state, type, classes) { + var vp = editor.getViewport(); + editor.operation(function() { + if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) { + clearMarks(editor, state.marked, classes); + markChanges(editor, diff, type, state.marked, vp.from, vp.to, classes); + state.from = vp.from; state.to = vp.to; + } else { + if (vp.from < state.from) { + markChanges(editor, diff, type, state.marked, vp.from, state.from, classes); + state.from = vp.from; + } + if (vp.to > state.to) { + markChanges(editor, diff, type, state.marked, state.to, vp.to, classes); + state.to = vp.to; + } + } + }); + } + + function addClass(editor, lineNr, classes, main, start, end) { + var locs = classes.classLocation, line = editor.getLineHandle(lineNr); + for (var i = 0; i < locs.length; i++) { + if (main) editor.addLineClass(line, locs[i], classes.chunk); + if (start) editor.addLineClass(line, locs[i], classes.start); + if (end) editor.addLineClass(line, locs[i], classes.end); + } + return line; + } + + function markChanges(editor, diff, type, marks, from, to, classes) { + var pos = Pos(0, 0); + var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1)); + var cls = type == DIFF_DELETE ? classes.del : classes.insert; + function markChunk(start, end) { + var bfrom = Math.max(from, start), bto = Math.min(to, end); + for (var i = bfrom; i < bto; ++i) + marks.push(addClass(editor, i, classes, true, i == start, i == end - 1)); + // When the chunk is empty, make sure a horizontal line shows up + if (start == end && bfrom == end && bto == end) { + if (bfrom) + marks.push(addClass(editor, bfrom - 1, classes, false, false, true)); + else + marks.push(addClass(editor, bfrom, classes, false, true, false)); + } + } + + var chunkStart = 0, pending = false; + for (var i = 0; i < diff.length; ++i) { + var part = diff[i], tp = part[0], str = part[1]; + if (tp == DIFF_EQUAL) { + var cleanFrom = pos.line + (startOfLineClean(diff, i) ? 0 : 1); + moveOver(pos, str); + var cleanTo = pos.line + (endOfLineClean(diff, i) ? 1 : 0); + if (cleanTo > cleanFrom) { + if (pending) { markChunk(chunkStart, cleanFrom); pending = false } + chunkStart = cleanTo; + } + } else { + pending = true + if (tp == type) { + var end = moveOver(pos, str, true); + var a = posMax(top, pos), b = posMin(bot, end); + if (!posEq(a, b)) + marks.push(editor.markText(a, b, {className: cls})); + pos = end; + } + } + } + if (pending) markChunk(chunkStart, pos.line + 1); + } + + // Updating the gap between editor and original + + function makeConnections(dv) { + if (!dv.showDifferences) return; + + if (dv.svg) { + clear(dv.svg); + var w = dv.gap.offsetWidth; + attrs(dv.svg, "width", w, "height", dv.gap.offsetHeight); + } + if (dv.copyButtons) clear(dv.copyButtons); + + var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport(); + var outerTop = dv.mv.wrap.getBoundingClientRect().top + var sTopEdit = outerTop - dv.edit.getScrollerElement().getBoundingClientRect().top + dv.edit.getScrollInfo().top + var sTopOrig = outerTop - dv.orig.getScrollerElement().getBoundingClientRect().top + dv.orig.getScrollInfo().top; + for (var i = 0; i < dv.chunks.length; i++) { + var ch = dv.chunks[i]; + if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from && + ch.origFrom <= vpOrig.to && ch.origTo >= vpOrig.from) + drawConnectorsForChunk(dv, ch, sTopOrig, sTopEdit, w); + } + } + + function getMatchingOrigLine(editLine, chunks) { + var editStart = 0, origStart = 0; + for (var i = 0; i < chunks.length; i++) { + var chunk = chunks[i]; + if (chunk.editTo > editLine && chunk.editFrom <= editLine) return null; + if (chunk.editFrom > editLine) break; + editStart = chunk.editTo; + origStart = chunk.origTo; + } + return origStart + (editLine - editStart); + } + + // Combines information about chunks and widgets/markers to return + // an array of lines, in a single editor, that probably need to be + // aligned with their counterparts in the editor next to it. + function alignableFor(cm, chunks, isOrig) { + var tracker = cm.state.trackAlignable + var start = cm.firstLine(), trackI = 0 + var result = [] + for (var i = 0;; i++) { + var chunk = chunks[i] + var chunkStart = !chunk ? 1e9 : isOrig ? chunk.origFrom : chunk.editFrom + for (; trackI < tracker.alignable.length; trackI += 2) { + var n = tracker.alignable[trackI] + 1 + if (n <= start) continue + if (n <= chunkStart) result.push(n) + else break + } + if (!chunk) break + result.push(start = isOrig ? chunk.origTo : chunk.editTo) + } + return result + } + + // Given information about alignable lines in two editors, fill in + // the result (an array of three-element arrays) to reflect the + // lines that need to be aligned with each other. + function mergeAlignable(result, origAlignable, chunks, setIndex) { + var rI = 0, origI = 0, chunkI = 0, diff = 0 + outer: for (;; rI++) { + var nextR = result[rI], nextO = origAlignable[origI] + if (!nextR && nextO == null) break + + var rLine = nextR ? nextR[0] : 1e9, oLine = nextO == null ? 1e9 : nextO + while (chunkI < chunks.length) { + var chunk = chunks[chunkI] + if (chunk.origFrom <= oLine && chunk.origTo > oLine) { + origI++ + rI-- + continue outer; + } + if (chunk.editTo > rLine) { + if (chunk.editFrom <= rLine) continue outer; + break + } + diff += (chunk.origTo - chunk.origFrom) - (chunk.editTo - chunk.editFrom) + chunkI++ + } + if (rLine == oLine - diff) { + nextR[setIndex] = oLine + origI++ + } else if (rLine < oLine - diff) { + nextR[setIndex] = rLine + diff + } else { + var record = [oLine - diff, null, null] + record[setIndex] = oLine + result.splice(rI, 0, record) + origI++ + } + } + } + + function findAlignedLines(dv, other) { + var alignable = alignableFor(dv.edit, dv.chunks, false), result = [] + if (other) for (var i = 0, j = 0; i < other.chunks.length; i++) { + var n = other.chunks[i].editTo + while (j < alignable.length && alignable[j] < n) j++ + if (j == alignable.length || alignable[j] != n) alignable.splice(j++, 0, n) + } + for (var i = 0; i < alignable.length; i++) + result.push([alignable[i], null, null]) + + mergeAlignable(result, alignableFor(dv.orig, dv.chunks, true), dv.chunks, 1) + if (other) + mergeAlignable(result, alignableFor(other.orig, other.chunks, true), other.chunks, 2) + + return result + } + + function alignChunks(dv, force) { + if (!dv.dealigned && !force) return; + if (!dv.orig.curOp) return dv.orig.operation(function() { + alignChunks(dv, force); + }); + + dv.dealigned = false; + var other = dv.mv.left == dv ? dv.mv.right : dv.mv.left; + if (other) { + ensureDiff(other); + other.dealigned = false; + } + var linesToAlign = findAlignedLines(dv, other); + + // Clear old aligners + var aligners = dv.mv.aligners; + for (var i = 0; i < aligners.length; i++) + aligners[i].clear(); + aligners.length = 0; + + var cm = [dv.edit, dv.orig], scroll = [], offset = [] + if (other) cm.push(other.orig); + for (var i = 0; i < cm.length; i++) { + scroll.push(cm[i].getScrollInfo().top); + offset.push(-cm[i].getScrollerElement().getBoundingClientRect().top) + } + + if (offset[0] != offset[1] || cm.length == 3 && offset[1] != offset[2]) + alignLines(cm, offset, [0, 0, 0], aligners) + for (var ln = 0; ln < linesToAlign.length; ln++) + alignLines(cm, offset, linesToAlign[ln], aligners); + + for (var i = 0; i < cm.length; i++) + cm[i].scrollTo(null, scroll[i]); + } + + function alignLines(cm, cmOffset, lines, aligners) { + var maxOffset = -1e8, offset = []; + for (var i = 0; i < cm.length; i++) if (lines[i] != null) { + var off = cm[i].heightAtLine(lines[i], "local") - cmOffset[i]; + offset[i] = off; + maxOffset = Math.max(maxOffset, off); + } + for (var i = 0; i < cm.length; i++) if (lines[i] != null) { + var diff = maxOffset - offset[i]; + if (diff > 1) + aligners.push(padAbove(cm[i], lines[i], diff)); + } + } + + function padAbove(cm, line, size) { + var above = true; + if (line > cm.lastLine()) { + line--; + above = false; + } + var elt = document.createElement("div"); + elt.className = "CodeMirror-merge-spacer"; + elt.style.height = size + "px"; elt.style.minWidth = "1px"; + return cm.addLineWidget(line, elt, {height: size, above: above, mergeSpacer: true, handleMouseEvents: true}); + } + + function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) { + var flip = dv.type == "left"; + var top = dv.orig.heightAtLine(chunk.origFrom, "local", true) - sTopOrig; + if (dv.svg) { + var topLpx = top; + var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local", true) - sTopEdit; + if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; } + var botLpx = dv.orig.heightAtLine(chunk.origTo, "local", true) - sTopOrig; + var botRpx = dv.edit.heightAtLine(chunk.editTo, "local", true) - sTopEdit; + if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; } + var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx; + var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx; + attrs(dv.svg.appendChild(document.createElementNS(svgNS, "path")), + "d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z", + "class", dv.classes.connect); + } + if (dv.copyButtons) { + var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc", + "CodeMirror-merge-copy")); + var editOriginals = dv.mv.options.allowEditingOriginals; + copy.title = dv.edit.phrase(editOriginals ? "Push to left" : "Revert chunk"); + copy.chunk = chunk; + copy.style.top = (chunk.origTo > chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px"; + + if (editOriginals) { + var topReverse = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit; + var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc", + "CodeMirror-merge-copy-reverse")); + copyReverse.title = "Push to right"; + copyReverse.chunk = {editFrom: chunk.origFrom, editTo: chunk.origTo, + origFrom: chunk.editFrom, origTo: chunk.editTo}; + copyReverse.style.top = topReverse + "px"; + dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px"; + } + } + } + + function copyChunk(dv, to, from, chunk) { + if (dv.diffOutOfDate) return; + var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0) + var origEnd = Pos(chunk.origTo, 0) + var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0) + var editEnd = Pos(chunk.editTo, 0) + var handler = dv.mv.options.revertChunk + if (handler) + handler(dv.mv, from, origStart, origEnd, to, editStart, editEnd) + else + to.replaceRange(from.getRange(origStart, origEnd), editStart, editEnd) + } + + // Merge view, containing 0, 1, or 2 diff views. + + var MergeView = CodeMirror.MergeView = function(node, options) { + if (!(this instanceof MergeView)) return new MergeView(node, options); + + this.options = options; + var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight; + + var hasLeft = origLeft != null, hasRight = origRight != null; + var panes = 1 + (hasLeft ? 1 : 0) + (hasRight ? 1 : 0); + var wrap = [], left = this.left = null, right = this.right = null; + var self = this; + + if (hasLeft) { + left = this.left = new DiffView(this, "left"); + var leftPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-left"); + wrap.push(leftPane); + wrap.push(buildGap(left)); + } + + var editPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-editor"); + wrap.push(editPane); + + if (hasRight) { + right = this.right = new DiffView(this, "right"); + wrap.push(buildGap(right)); + var rightPane = elt("div", null, "CodeMirror-merge-pane CodeMirror-merge-right"); + wrap.push(rightPane); + } + + (hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost"; + + wrap.push(elt("div", null, null, "height: 0; clear: both;")); + + var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane")); + this.edit = CodeMirror(editPane, copyObj(options)); + + if (left) left.init(leftPane, origLeft, options); + if (right) right.init(rightPane, origRight, options); + if (options.collapseIdentical) + this.editor().operation(function() { + collapseIdenticalStretches(self, options.collapseIdentical); + }); + if (options.connect == "align") { + this.aligners = []; + alignChunks(this.left || this.right, true); + } + if (left) left.registerEvents(right) + if (right) right.registerEvents(left) + + + var onResize = function() { + if (left) makeConnections(left); + if (right) makeConnections(right); + }; + CodeMirror.on(window, "resize", onResize); + var resizeInterval = setInterval(function() { + for (var p = wrapElt.parentNode; p && p != document.body; p = p.parentNode) {} + if (!p) { clearInterval(resizeInterval); CodeMirror.off(window, "resize", onResize); } + }, 5000); + }; + + function buildGap(dv) { + var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock"); + var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap"); + CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); }); + var gapElts = [lockWrap]; + if (dv.mv.options.revertButtons !== false) { + dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type); + CodeMirror.on(dv.copyButtons, "click", function(e) { + var node = e.target || e.srcElement; + if (!node.chunk) return; + if (node.className == "CodeMirror-merge-copy-reverse") { + copyChunk(dv, dv.orig, dv.edit, node.chunk); + return; + } + copyChunk(dv, dv.edit, dv.orig, node.chunk); + }); + gapElts.unshift(dv.copyButtons); + } + if (dv.mv.options.connect != "align") { + var svg = document.createElementNS && document.createElementNS(svgNS, "svg"); + if (svg && !svg.createSVGRect) svg = null; + dv.svg = svg; + if (svg) gapElts.push(svg); + } + + return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap"); + } + + MergeView.prototype = { + constructor: MergeView, + editor: function() { return this.edit; }, + rightOriginal: function() { return this.right && this.right.orig; }, + leftOriginal: function() { return this.left && this.left.orig; }, + setShowDifferences: function(val) { + if (this.right) this.right.setShowDifferences(val); + if (this.left) this.left.setShowDifferences(val); + }, + rightChunks: function() { + if (this.right) { ensureDiff(this.right); return this.right.chunks; } + }, + leftChunks: function() { + if (this.left) { ensureDiff(this.left); return this.left.chunks; } + } + }; + + function asString(obj) { + if (typeof obj == "string") return obj; + else return obj.getValue(); + } + + // Operations on diffs + var dmp; + function getDiff(a, b, ignoreWhitespace) { + if (!dmp) dmp = new diff_match_patch(); + + var diff = dmp.diff_main(a, b); + // The library sometimes leaves in empty parts, which confuse the algorithm + for (var i = 0; i < diff.length; ++i) { + var part = diff[i]; + if (ignoreWhitespace ? !/[^ \t]/.test(part[1]) : !part[1]) { + diff.splice(i--, 1); + } else if (i && diff[i - 1][0] == part[0]) { + diff.splice(i--, 1); + diff[i][1] += part[1]; + } + } + return diff; + } + + function getChunks(diff) { + var chunks = []; + if (!diff.length) return chunks; + var startEdit = 0, startOrig = 0; + var edit = Pos(0, 0), orig = Pos(0, 0); + for (var i = 0; i < diff.length; ++i) { + var part = diff[i], tp = part[0]; + if (tp == DIFF_EQUAL) { + var startOff = !startOfLineClean(diff, i) || edit.line < startEdit || orig.line < startOrig ? 1 : 0; + var cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff; + moveOver(edit, part[1], null, orig); + var endOff = endOfLineClean(diff, i) ? 1 : 0; + var cleanToEdit = edit.line + endOff, cleanToOrig = orig.line + endOff; + if (cleanToEdit > cleanFromEdit) { + if (i) chunks.push({origFrom: startOrig, origTo: cleanFromOrig, + editFrom: startEdit, editTo: cleanFromEdit}); + startEdit = cleanToEdit; startOrig = cleanToOrig; + } + } else { + moveOver(tp == DIFF_INSERT ? edit : orig, part[1]); + } + } + if (startEdit <= edit.line || startOrig <= orig.line) + chunks.push({origFrom: startOrig, origTo: orig.line + 1, + editFrom: startEdit, editTo: edit.line + 1}); + return chunks; + } + + function endOfLineClean(diff, i) { + if (i == diff.length - 1) return true; + var next = diff[i + 1][1]; + if ((next.length == 1 && i < diff.length - 2) || next.charCodeAt(0) != 10) return false; + if (i == diff.length - 2) return true; + next = diff[i + 2][1]; + return (next.length > 1 || i == diff.length - 3) && next.charCodeAt(0) == 10; + } + + function startOfLineClean(diff, i) { + if (i == 0) return true; + var last = diff[i - 1][1]; + if (last.charCodeAt(last.length - 1) != 10) return false; + if (i == 1) return true; + last = diff[i - 2][1]; + return last.charCodeAt(last.length - 1) == 10; + } + + function chunkBoundariesAround(chunks, n, nInEdit) { + var beforeE, afterE, beforeO, afterO; + for (var i = 0; i < chunks.length; i++) { + var chunk = chunks[i]; + var fromLocal = nInEdit ? chunk.editFrom : chunk.origFrom; + var toLocal = nInEdit ? chunk.editTo : chunk.origTo; + if (afterE == null) { + if (fromLocal > n) { afterE = chunk.editFrom; afterO = chunk.origFrom; } + else if (toLocal > n) { afterE = chunk.editTo; afterO = chunk.origTo; } + } + if (toLocal <= n) { beforeE = chunk.editTo; beforeO = chunk.origTo; } + else if (fromLocal <= n) { beforeE = chunk.editFrom; beforeO = chunk.origFrom; } + } + return {edit: {before: beforeE, after: afterE}, orig: {before: beforeO, after: afterO}}; + } + + function collapseSingle(cm, from, to) { + cm.addLineClass(from, "wrap", "CodeMirror-merge-collapsed-line"); + var widget = document.createElement("span"); + widget.className = "CodeMirror-merge-collapsed-widget"; + widget.title = cm.phrase("Identical text collapsed. Click to expand."); + var mark = cm.markText(Pos(from, 0), Pos(to - 1), { + inclusiveLeft: true, + inclusiveRight: true, + replacedWith: widget, + clearOnEnter: true + }); + function clear() { + mark.clear(); + cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line"); + } + if (mark.explicitlyCleared) clear(); + CodeMirror.on(widget, "click", clear); + mark.on("clear", clear); + CodeMirror.on(widget, "click", clear); + return {mark: mark, clear: clear}; + } + + function collapseStretch(size, editors) { + var marks = []; + function clear() { + for (var i = 0; i < marks.length; i++) marks[i].clear(); + } + for (var i = 0; i < editors.length; i++) { + var editor = editors[i]; + var mark = collapseSingle(editor.cm, editor.line, editor.line + size); + marks.push(mark); + mark.mark.on("clear", clear); + } + return marks[0].mark; + } + + function unclearNearChunks(dv, margin, off, clear) { + for (var i = 0; i < dv.chunks.length; i++) { + var chunk = dv.chunks[i]; + for (var l = chunk.editFrom - margin; l < chunk.editTo + margin; l++) { + var pos = l + off; + if (pos >= 0 && pos < clear.length) clear[pos] = false; + } + } + } + + function collapseIdenticalStretches(mv, margin) { + if (typeof margin != "number") margin = 2; + var clear = [], edit = mv.editor(), off = edit.firstLine(); + for (var l = off, e = edit.lastLine(); l <= e; l++) clear.push(true); + if (mv.left) unclearNearChunks(mv.left, margin, off, clear); + if (mv.right) unclearNearChunks(mv.right, margin, off, clear); + + for (var i = 0; i < clear.length; i++) { + if (clear[i]) { + var line = i + off; + for (var size = 1; i < clear.length - 1 && clear[i + 1]; i++, size++) {} + if (size > margin) { + var editors = [{line: line, cm: edit}]; + if (mv.left) editors.push({line: getMatchingOrigLine(line, mv.left.chunks), cm: mv.left.orig}); + if (mv.right) editors.push({line: getMatchingOrigLine(line, mv.right.chunks), cm: mv.right.orig}); + var mark = collapseStretch(size, editors); + if (mv.options.onCollapse) mv.options.onCollapse(mv, line, size, mark); + } + } + } + } + + // General utilities + + function elt(tag, content, className, style) { + var e = document.createElement(tag); + if (className) e.className = className; + if (style) e.style.cssText = style; + if (typeof content == "string") e.appendChild(document.createTextNode(content)); + else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]); + return e; + } + + function clear(node) { + for (var count = node.childNodes.length; count > 0; --count) + node.removeChild(node.firstChild); + } + + function attrs(elt) { + for (var i = 1; i < arguments.length; i += 2) + elt.setAttribute(arguments[i], arguments[i+1]); + } + + function copyObj(obj, target) { + if (!target) target = {}; + for (var prop in obj) if (obj.hasOwnProperty(prop)) target[prop] = obj[prop]; + return target; + } + + function moveOver(pos, str, copy, other) { + var out = copy ? Pos(pos.line, pos.ch) : pos, at = 0; + for (;;) { + var nl = str.indexOf("\n", at); + if (nl == -1) break; + ++out.line; + if (other) ++other.line; + at = nl + 1; + } + out.ch = (at ? 0 : out.ch) + (str.length - at); + if (other) other.ch = (at ? 0 : other.ch) + (str.length - at); + return out; + } + + // Tracks collapsed markers and line widgets, in order to be able to + // accurately align the content of two editors. + + var F_WIDGET = 1, F_WIDGET_BELOW = 2, F_MARKER = 4 + + function TrackAlignable(cm) { + this.cm = cm + this.alignable = [] + this.height = cm.doc.height + var self = this + cm.on("markerAdded", function(_, marker) { + if (!marker.collapsed) return + var found = marker.find(1) + if (found != null) self.set(found.line, F_MARKER) + }) + cm.on("markerCleared", function(_, marker, _min, max) { + if (max != null && marker.collapsed) + self.check(max, F_MARKER, self.hasMarker) + }) + cm.on("markerChanged", this.signal.bind(this)) + cm.on("lineWidgetAdded", function(_, widget, lineNo) { + if (widget.mergeSpacer) return + if (widget.above) self.set(lineNo - 1, F_WIDGET_BELOW) + else self.set(lineNo, F_WIDGET) + }) + cm.on("lineWidgetCleared", function(_, widget, lineNo) { + if (widget.mergeSpacer) return + if (widget.above) self.check(lineNo - 1, F_WIDGET_BELOW, self.hasWidgetBelow) + else self.check(lineNo, F_WIDGET, self.hasWidget) + }) + cm.on("lineWidgetChanged", this.signal.bind(this)) + cm.on("change", function(_, change) { + var start = change.from.line, nBefore = change.to.line - change.from.line + var nAfter = change.text.length - 1, end = start + nAfter + if (nBefore || nAfter) self.map(start, nBefore, nAfter) + self.check(end, F_MARKER, self.hasMarker) + if (nBefore || nAfter) self.check(change.from.line, F_MARKER, self.hasMarker) + }) + cm.on("viewportChange", function() { + if (self.cm.doc.height != self.height) self.signal() + }) + } + + TrackAlignable.prototype = { + signal: function() { + CodeMirror.signal(this, "realign") + this.height = this.cm.doc.height + }, + + set: function(n, flags) { + var pos = -1 + for (; pos < this.alignable.length; pos += 2) { + var diff = this.alignable[pos] - n + if (diff == 0) { + if ((this.alignable[pos + 1] & flags) == flags) return + this.alignable[pos + 1] |= flags + this.signal() + return + } + if (diff > 0) break + } + this.signal() + this.alignable.splice(pos, 0, n, flags) + }, + + find: function(n) { + for (var i = 0; i < this.alignable.length; i += 2) + if (this.alignable[i] == n) return i + return -1 + }, + + check: function(n, flag, pred) { + var found = this.find(n) + if (found == -1 || !(this.alignable[found + 1] & flag)) return + if (!pred.call(this, n)) { + this.signal() + var flags = this.alignable[found + 1] & ~flag + if (flags) this.alignable[found + 1] = flags + else this.alignable.splice(found, 2) + } + }, + + hasMarker: function(n) { + var handle = this.cm.getLineHandle(n) + if (handle.markedSpans) for (var i = 0; i < handle.markedSpans.length; i++) + if (handle.markedSpans[i].marker.collapsed && handle.markedSpans[i].to != null) + return true + return false + }, + + hasWidget: function(n) { + var handle = this.cm.getLineHandle(n) + if (handle.widgets) for (var i = 0; i < handle.widgets.length; i++) + if (!handle.widgets[i].above && !handle.widgets[i].mergeSpacer) return true + return false + }, + + hasWidgetBelow: function(n) { + if (n == this.cm.lastLine()) return false + var handle = this.cm.getLineHandle(n + 1) + if (handle.widgets) for (var i = 0; i < handle.widgets.length; i++) + if (handle.widgets[i].above && !handle.widgets[i].mergeSpacer) return true + return false + }, + + map: function(from, nBefore, nAfter) { + var diff = nAfter - nBefore, to = from + nBefore, widgetFrom = -1, widgetTo = -1 + for (var i = 0; i < this.alignable.length; i += 2) { + var n = this.alignable[i] + if (n == from && (this.alignable[i + 1] & F_WIDGET_BELOW)) widgetFrom = i + if (n == to && (this.alignable[i + 1] & F_WIDGET_BELOW)) widgetTo = i + if (n <= from) continue + else if (n < to) this.alignable.splice(i--, 2) + else this.alignable[i] += diff + } + if (widgetFrom > -1) { + var flags = this.alignable[widgetFrom + 1] + if (flags == F_WIDGET_BELOW) this.alignable.splice(widgetFrom, 2) + else this.alignable[widgetFrom + 1] = flags & ~F_WIDGET_BELOW + } + if (widgetTo > -1 && nAfter) + this.set(from + nAfter, F_WIDGET_BELOW) + } + } + + function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; } + function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; } + function posEq(a, b) { return a.line == b.line && a.ch == b.ch; } + + function findPrevDiff(chunks, start, isOrig) { + for (var i = chunks.length - 1; i >= 0; i--) { + var chunk = chunks[i]; + var to = (isOrig ? chunk.origTo : chunk.editTo) - 1; + if (to < start) return to; + } + } + + function findNextDiff(chunks, start, isOrig) { + for (var i = 0; i < chunks.length; i++) { + var chunk = chunks[i]; + var from = (isOrig ? chunk.origFrom : chunk.editFrom); + if (from > start) return from; + } + } + + function goNearbyDiff(cm, dir) { + var found = null, views = cm.state.diffViews, line = cm.getCursor().line; + if (views) for (var i = 0; i < views.length; i++) { + var dv = views[i], isOrig = cm == dv.orig; + ensureDiff(dv); + var pos = dir < 0 ? findPrevDiff(dv.chunks, line, isOrig) : findNextDiff(dv.chunks, line, isOrig); + if (pos != null && (found == null || (dir < 0 ? pos > found : pos < found))) + found = pos; + } + if (found != null) + cm.setCursor(found, 0); + else + return CodeMirror.Pass; + } + + CodeMirror.commands.goNextDiff = function(cm) { + return goNearbyDiff(cm, 1); + }; + CodeMirror.commands.goPrevDiff = function(cm) { + return goNearbyDiff(cm, -1); + }; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/loadmode.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/loadmode.js index 757bd52..fc695d0 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/loadmode.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/loadmode.js @@ -1,3 +1,66 @@ -'use strict';(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror"),"cjs"):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],function(f){b(f,"amd")}):b(CodeMirror,"plain")})(function(b,f){function l(a,b){var c=b;return function(){0==--c&&a()}}function h(a,c){var e=b.modes[a].dependencies;if(!e)return c();a=[];for(var d=0;d -1 ? found + pattern.length : found; + } + var m = pattern.exec(from ? string.slice(from) : string); + return m ? m.index + from + (returnEnd ? m[0].length : 0) : -1; + } + + return { + startState: function() { + return { + outer: CodeMirror.startState(outer), + innerActive: null, + inner: null + }; + }, + + copyState: function(state) { + return { + outer: CodeMirror.copyState(outer, state.outer), + innerActive: state.innerActive, + inner: state.innerActive && CodeMirror.copyState(state.innerActive.mode, state.inner) + }; + }, + + token: function(stream, state) { + if (!state.innerActive) { + var cutOff = Infinity, oldContent = stream.string; + for (var i = 0; i < others.length; ++i) { + var other = others[i]; + var found = indexOf(oldContent, other.open, stream.pos); + if (found == stream.pos) { + if (!other.parseDelimiters) stream.match(other.open); + state.innerActive = other; + + // Get the outer indent, making sure to handle CodeMirror.Pass + var outerIndent = 0; + if (outer.indent) { + var possibleOuterIndent = outer.indent(state.outer, "", ""); + if (possibleOuterIndent !== CodeMirror.Pass) outerIndent = possibleOuterIndent; + } + + state.inner = CodeMirror.startState(other.mode, outerIndent); + return other.delimStyle && (other.delimStyle + " " + other.delimStyle + "-open"); + } else if (found != -1 && found < cutOff) { + cutOff = found; + } + } + if (cutOff != Infinity) stream.string = oldContent.slice(0, cutOff); + var outerToken = outer.token(stream, state.outer); + if (cutOff != Infinity) stream.string = oldContent; + return outerToken; + } else { + var curInner = state.innerActive, oldContent = stream.string; + if (!curInner.close && stream.sol()) { + state.innerActive = state.inner = null; + return this.token(stream, state); + } + var found = curInner.close ? indexOf(oldContent, curInner.close, stream.pos, curInner.parseDelimiters) : -1; + if (found == stream.pos && !curInner.parseDelimiters) { + stream.match(curInner.close); + state.innerActive = state.inner = null; + return curInner.delimStyle && (curInner.delimStyle + " " + curInner.delimStyle + "-close"); + } + if (found > -1) stream.string = oldContent.slice(0, found); + var innerToken = curInner.mode.token(stream, state.inner); + if (found > -1) stream.string = oldContent; + + if (found == stream.pos && curInner.parseDelimiters) + state.innerActive = state.inner = null; + + if (curInner.innerStyle) { + if (innerToken) innerToken = innerToken + " " + curInner.innerStyle; + else innerToken = curInner.innerStyle; + } + + return innerToken; + } + }, + + indent: function(state, textAfter, line) { + var mode = state.innerActive ? state.innerActive.mode : outer; + if (!mode.indent) return CodeMirror.Pass; + return mode.indent(state.innerActive ? state.inner : state.outer, textAfter, line); + }, + + blankLine: function(state) { + var mode = state.innerActive ? state.innerActive.mode : outer; + if (mode.blankLine) { + mode.blankLine(state.innerActive ? state.inner : state.outer); + } + if (!state.innerActive) { + for (var i = 0; i < others.length; ++i) { + var other = others[i]; + if (other.open === "\n") { + state.innerActive = other; + state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "", "") : 0); + } + } + } else if (state.innerActive.close === "\n") { + state.innerActive = state.inner = null; + } + }, + + electricChars: outer.electricChars, + + innerMode: function(state) { + return state.inner ? {state: state.inner, mode: state.innerActive.mode} : {state: state.outer, mode: outer}; + } + }; +}; + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/multiplex_test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/multiplex_test.js index f73c9c2..c51cad4 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/multiplex_test.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/multiplex_test.js @@ -1 +1,33 @@ -'use strict';(function(){CodeMirror.defineMode("markdown_with_stex",function(){var a=CodeMirror.getMode({},"stex"),b=CodeMirror.getMode({},"markdown");return CodeMirror.multiplexingMode(b,{open:"$",close:"$",mode:a,delimStyle:"delim",innerStyle:"inner"})});var b=CodeMirror.getMode({},"markdown_with_stex");(function(a){test.mode(a,b,Array.prototype.slice.call(arguments,1),"multiplexing")})("stexInsideMarkdown","[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]")})(); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + CodeMirror.defineMode("markdown_with_stex", function(){ + var inner = CodeMirror.getMode({}, "stex"); + var outer = CodeMirror.getMode({}, "markdown"); + + var innerOptions = { + open: '$', + close: '$', + mode: inner, + delimStyle: 'delim', + innerStyle: 'inner' + }; + + return CodeMirror.multiplexingMode(outer, innerOptions); + }); + + var mode = CodeMirror.getMode({}, "markdown_with_stex"); + + function MT(name) { + test.mode( + name, + mode, + Array.prototype.slice.call(arguments, 1), + 'multiplexing'); + } + + MT( + "stexInsideMarkdown", + "[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/overlay.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/overlay.js index 4aab597..016e3c2 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/overlay.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/mode/overlay.js @@ -1,3 +1,90 @@ -'use strict';(function(c){"object"==typeof exports&&"object"==typeof module?c(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){c.overlayMode=function(d,e,f){return{startState:function(){return{base:c.startState(d),overlay:c.startState(e),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(b){return{base:c.copyState(d,b.base),overlay:c.copyState(e,b.overlay),basePos:b.basePos,baseCur:null, -overlayPos:b.overlayPos,overlayCur:null}},token:function(b,a){if(b!=a.streamSeen||Math.min(a.basePos,a.overlayPos)c?0:d.indent[c]}}l.defineSimpleMode=function(b,e){l.defineMode(b, -function(b){return l.simpleMode(b,e)})};l.simpleMode=function(b,e){r(e,"start");var d={},a=e.meta||{},c=!1,g;for(g in e)if(g!=a&&e.hasOwnProperty(g))for(var h=d[g]=[],f=e[g],m=0;m 2 && rule.token && typeof rule.token != "string") { + state.pending = []; + for (var j = 2; j < matches.length; j++) + if (matches[j]) + state.pending.push({text: matches[j], token: rule.token[j - 1]}); + stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0)); + return token[0]; + } else if (token && token.join) { + return token[0]; + } else { + return token; + } + } + } + stream.next(); + return null; + }; + } + + function cmp(a, b) { + if (a === b) return true; + if (!a || typeof a != "object" || !b || typeof b != "object") return false; + var props = 0; + for (var prop in a) if (a.hasOwnProperty(prop)) { + if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false; + props++; + } + for (var prop in b) if (b.hasOwnProperty(prop)) props--; + return props == 0; + } + + function enterLocalMode(config, state, spec, token) { + var pers; + if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next) + if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p; + var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec); + var lState = pers ? pers.state : CodeMirror.startState(mode); + if (spec.persistent && !pers) + state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates}; + + state.localState = lState; + state.local = {mode: mode, + end: spec.end && toRegex(spec.end), + endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false), + endToken: token && token.join ? token[token.length - 1] : token}; + } + + function indexOf(val, arr) { + for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true; + } + + function indentFunction(states, meta) { + return function(state, textAfter, line) { + if (state.local && state.local.mode.indent) + return state.local.mode.indent(state.localState, textAfter, line); + if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1) + return CodeMirror.Pass; + + var pos = state.indent.length - 1, rules = states[state.state]; + scan: for (;;) { + for (var i = 0; i < rules.length; i++) { + var rule = rules[i]; + if (rule.data.dedent && rule.data.dedentIfLineStart !== false) { + var m = rule.regex.exec(textAfter); + if (m && m[0]) { + pos--; + if (rule.next || rule.push) rules = states[rule.next || rule.push]; + textAfter = textAfter.slice(m[0].length); + continue scan; + } + } + } + break; + } + return pos < 0 ? 0 : state.indent[pos]; + }; + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/runmode/colorize.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/runmode/colorize.js index 8610e42..3be5411 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/runmode/colorize.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/runmode/colorize.js @@ -1,2 +1,40 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("./runmode")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./runmode"],a):a(CodeMirror)})(function(a){function f(b,a){if(3==b.nodeType)return a.push(b.nodeValue);for(var c=b.firstChild;c;c=c.nextSibling)f(c,a),e.test(b.nodeType)&&a.push("\n")}var e=/^(p|li|div|h\\d|pre|blockquote|td)$/;a.colorize=function(b,e){b||(b=document.body.getElementsByTagName("pre")); -for(var c=0;c=this.string.length},sol:function(){return 0==this.pos},peek:function(){return this.string.charAt(this.pos)||null},next:function(){if(this.posb},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){a=this.string.indexOf(a,this.pos);if(-1= end) + { return n + (end - i) } + n += nextTab - i; + n += tabSize - (n % tabSize); + i = nextTab + 1; + } + } + + function nothing() {} + + function createObj(base, props) { + var inst; + if (Object.create) { + inst = Object.create(base); + } else { + nothing.prototype = base; + inst = new nothing(); + } + if (props) { copyObj(props, inst); } + return inst + } + + // STRING STREAM + + // Fed to the mode parsers, provides helper functions to make + // parsers more succinct. + + var StringStream = function(string, tabSize, lineOracle) { + this.pos = this.start = 0; + this.string = string; + this.tabSize = tabSize || 8; + this.lastColumnPos = this.lastColumnValue = 0; + this.lineStart = 0; + this.lineOracle = lineOracle; + }; + + StringStream.prototype.eol = function () {return this.pos >= this.string.length}; + StringStream.prototype.sol = function () {return this.pos == this.lineStart}; + StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined}; + StringStream.prototype.next = function () { + if (this.pos < this.string.length) + { return this.string.charAt(this.pos++) } + }; + StringStream.prototype.eat = function (match) { + var ch = this.string.charAt(this.pos); + var ok; + if (typeof match == "string") { ok = ch == match; } + else { ok = ch && (match.test ? match.test(ch) : match(ch)); } + if (ok) {++this.pos; return ch} + }; + StringStream.prototype.eatWhile = function (match) { + var start = this.pos; + while (this.eat(match)){} + return this.pos > start + }; + StringStream.prototype.eatSpace = function () { + var start = this.pos; + while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this.pos; } + return this.pos > start + }; + StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;}; + StringStream.prototype.skipTo = function (ch) { + var found = this.string.indexOf(ch, this.pos); + if (found > -1) {this.pos = found; return true} + }; + StringStream.prototype.backUp = function (n) {this.pos -= n;}; + StringStream.prototype.column = function () { + if (this.lastColumnPos < this.start) { + this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); + this.lastColumnPos = this.start; + } + return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) + }; + StringStream.prototype.indentation = function () { + return countColumn(this.string, null, this.tabSize) - + (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) + }; + StringStream.prototype.match = function (pattern, consume, caseInsensitive) { + if (typeof pattern == "string") { + var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }; + var substr = this.string.substr(this.pos, pattern.length); + if (cased(substr) == cased(pattern)) { + if (consume !== false) { this.pos += pattern.length; } + return true + } + } else { + var match = this.string.slice(this.pos).match(pattern); + if (match && match.index > 0) { return null } + if (match && consume !== false) { this.pos += match[0].length; } + return match + } + }; + StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)}; + StringStream.prototype.hideFirstChars = function (n, inner) { + this.lineStart += n; + try { return inner() } + finally { this.lineStart -= n; } + }; + StringStream.prototype.lookAhead = function (n) { + var oracle = this.lineOracle; + return oracle && oracle.lookAhead(n) + }; + StringStream.prototype.baseToken = function () { + var oracle = this.lineOracle; + return oracle && oracle.baseToken(this.pos) + }; + + // Known modes, by name and by MIME + var modes = {}, mimeModes = {}; + + // Extra arguments are stored as the mode's dependencies, which is + // used by (legacy) mechanisms like loadmode.js to automatically + // load a mode. (Preferred mechanism is the require/define calls.) + function defineMode(name, mode) { + if (arguments.length > 2) + { mode.dependencies = Array.prototype.slice.call(arguments, 2); } + modes[name] = mode; + } + + function defineMIME(mime, spec) { + mimeModes[mime] = spec; + } + + // Given a MIME type, a {name, ...options} config object, or a name + // string, return a mode config object. + function resolveMode(spec) { + if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { + spec = mimeModes[spec]; + } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { + var found = mimeModes[spec.name]; + if (typeof found == "string") { found = {name: found}; } + spec = createObj(found, spec); + spec.name = found.name; + } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { + return resolveMode("application/xml") + } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) { + return resolveMode("application/json") + } + if (typeof spec == "string") { return {name: spec} } + else { return spec || {name: "null"} } + } + + // Given a mode spec (anything that resolveMode accepts), find and + // initialize an actual mode object. + function getMode(options, spec) { + spec = resolveMode(spec); + var mfactory = modes[spec.name]; + if (!mfactory) { return getMode(options, "text/plain") } + var modeObj = mfactory(options, spec); + if (modeExtensions.hasOwnProperty(spec.name)) { + var exts = modeExtensions[spec.name]; + for (var prop in exts) { + if (!exts.hasOwnProperty(prop)) { continue } + if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; } + modeObj[prop] = exts[prop]; + } + } + modeObj.name = spec.name; + if (spec.helperType) { modeObj.helperType = spec.helperType; } + if (spec.modeProps) { for (var prop$1 in spec.modeProps) + { modeObj[prop$1] = spec.modeProps[prop$1]; } } + + return modeObj + } + + // This can be used to attach properties to mode objects from + // outside the actual mode definition. + var modeExtensions = {}; + function extendMode(mode, properties) { + var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); + copyObj(properties, exts); + } + + function copyState(mode, state) { + if (state === true) { return state } + if (mode.copyState) { return mode.copyState(state) } + var nstate = {}; + for (var n in state) { + var val = state[n]; + if (val instanceof Array) { val = val.concat([]); } + nstate[n] = val; + } + return nstate + } + + // Given a mode and a state (for that mode), find the inner mode and + // state at the position that the state refers to. + function innerMode(mode, state) { + var info; + while (mode.innerMode) { + info = mode.innerMode(state); + if (!info || info.mode == mode) { break } + state = info.state; + mode = info.mode; + } + return info || {mode: mode, state: state} + } + + function startState(mode, a1, a2) { + return mode.startState ? mode.startState(a1, a2) : true + } + + var modeMethods = { + __proto__: null, + modes: modes, + mimeModes: mimeModes, + defineMode: defineMode, + defineMIME: defineMIME, + resolveMode: resolveMode, + getMode: getMode, + modeExtensions: modeExtensions, + extendMode: extendMode, + copyState: copyState, + innerMode: innerMode, + startState: startState + }; + + // declare global: globalThis, CodeMirror + + // Create a minimal CodeMirror needed to use runMode, and assign to root. + var root = typeof globalThis !== 'undefined' ? globalThis : window; + root.CodeMirror = {}; + + // Copy StringStream and mode methods into CodeMirror object. + CodeMirror.StringStream = StringStream; + for (var exported in modeMethods) { CodeMirror[exported] = modeMethods[exported]; } + + // Minimal default mode. + CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); }); + CodeMirror.defineMIME("text/plain", "null"); + + CodeMirror.registerHelper = CodeMirror.registerGlobalHelper = Math.min; + CodeMirror.splitLines = function(string) { return string.split(/\r?\n|\r/) }; + + CodeMirror.defaults = { indentUnit: 2 }; + + // 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) { + + CodeMirror.runMode = function(string, modespec, callback, options) { + var mode = CodeMirror.getMode(CodeMirror.defaults, modespec); + var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize; + + // Create a tokenizing callback function if passed-in callback is a DOM element. + if (callback.appendChild) { + var ie = /MSIE \d/.test(navigator.userAgent); + var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9); + var node = callback, col = 0; + node.innerHTML = ""; + callback = function(text, style) { + if (text == "\n") { + // Emitting LF or CRLF on IE8 or earlier results in an incorrect display. + // Emitting a carriage return makes everything ok. + node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text)); + col = 0; + return; + } + var content = ""; + // replace tabs + for (var pos = 0;;) { + var idx = text.indexOf("\t", pos); + if (idx == -1) { + content += text.slice(pos); + col += text.length - pos; + break; + } else { + col += idx - pos; + content += text.slice(pos, idx); + var size = tabSize - col % tabSize; + col += size; + for (var i = 0; i < size; ++i) { content += " "; } + pos = idx + 1; + } + } + // Create a node with token style and append it to the callback DOM element. + if (style) { + var sp = node.appendChild(document.createElement("span")); + sp.className = "cm-" + style.replace(/ +/g, " cm-"); + sp.appendChild(document.createTextNode(content)); + } else { + node.appendChild(document.createTextNode(content)); + } + }; + } + + var lines = CodeMirror.splitLines(string), state = (options && options.state) || CodeMirror.startState(mode); + for (var i = 0, e = lines.length; i < e; ++i) { + if (i) { callback("\n"); } + var stream = new CodeMirror.StringStream(lines[i], null, { + lookAhead: function(n) { return lines[i + n] }, + baseToken: function() {} + }); + if (!stream.string && mode.blankLine) { mode.blankLine(state); } + while (!stream.eol()) { + var style = mode.token(stream, state); + callback(stream.current(), style, i, stream.start, state); + stream.start = stream.pos; + } + } + }; + + }); + +}()); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/runmode/runmode.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/runmode/runmode.js index 66658b1..2cae686 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/runmode/runmode.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/runmode/runmode.js @@ -1,3 +1,76 @@ -'use strict';(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){a.runMode=function(k,c,f,d){c=a.getMode(a.defaults,c);var n=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||9>document.documentMode);if(f.appendChild){var m=d&&d.tabSize||a.defaults.tabSize,l=f,g=0;l.innerHTML="";f=function(a,d){if("\n"==a)l.appendChild(document.createTextNode(n? -"\r":a)),g=0;else{for(var b="",e=0;;){var c=a.indexOf("\t",e);if(-1==c){b+=a.slice(e);g+=a.length-e;break}else{g+=c-e;b+=a.slice(e,c);e=m-g%m;g+=e;for(var f=0;ff||f>=b)return e+(b-c);e+=f-c;e+=d-e%d;c=f+1}};function StringStream(a,b,d){this.pos=this.start=0;this.string=a;this.tabSize=b||8;this.lineStart=this.lastColumnPos=this.lastColumnValue=0;this.context=d} -StringStream.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.posb},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos; -return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){a=this.string.indexOf(a,this.pos);if(-1=this.context.lines.length?null:this.context.lines[a]}};exports.StringStream=StringStream;exports.startState=function(a,b,d){return a.startState?a.startState(b,d):!0};var modes=exports.modes={},mimeModes=exports.mimeModes={};exports.defineMode=function(a,b){2= end) + { return n + (end - i) } + n += nextTab - i; + n += tabSize - (n % tabSize); + i = nextTab + 1; + } +} + +function nothing() {} + +function createObj(base, props) { + var inst; + if (Object.create) { + inst = Object.create(base); + } else { + nothing.prototype = base; + inst = new nothing(); + } + if (props) { copyObj(props, inst); } + return inst +} + +// STRING STREAM + +// Fed to the mode parsers, provides helper functions to make +// parsers more succinct. + +var StringStream = function(string, tabSize, lineOracle) { + this.pos = this.start = 0; + this.string = string; + this.tabSize = tabSize || 8; + this.lastColumnPos = this.lastColumnValue = 0; + this.lineStart = 0; + this.lineOracle = lineOracle; +}; + +StringStream.prototype.eol = function () {return this.pos >= this.string.length}; +StringStream.prototype.sol = function () {return this.pos == this.lineStart}; +StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined}; +StringStream.prototype.next = function () { + if (this.pos < this.string.length) + { return this.string.charAt(this.pos++) } +}; +StringStream.prototype.eat = function (match) { + var ch = this.string.charAt(this.pos); + var ok; + if (typeof match == "string") { ok = ch == match; } + else { ok = ch && (match.test ? match.test(ch) : match(ch)); } + if (ok) {++this.pos; return ch} +}; +StringStream.prototype.eatWhile = function (match) { + var start = this.pos; + while (this.eat(match)){} + return this.pos > start +}; +StringStream.prototype.eatSpace = function () { + var start = this.pos; + while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this.pos; } + return this.pos > start +}; +StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;}; +StringStream.prototype.skipTo = function (ch) { + var found = this.string.indexOf(ch, this.pos); + if (found > -1) {this.pos = found; return true} +}; +StringStream.prototype.backUp = function (n) {this.pos -= n;}; +StringStream.prototype.column = function () { + if (this.lastColumnPos < this.start) { + this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); + this.lastColumnPos = this.start; + } + return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) +}; +StringStream.prototype.indentation = function () { + return countColumn(this.string, null, this.tabSize) - + (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0) +}; +StringStream.prototype.match = function (pattern, consume, caseInsensitive) { + if (typeof pattern == "string") { + var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }; + var substr = this.string.substr(this.pos, pattern.length); + if (cased(substr) == cased(pattern)) { + if (consume !== false) { this.pos += pattern.length; } + return true + } + } else { + var match = this.string.slice(this.pos).match(pattern); + if (match && match.index > 0) { return null } + if (match && consume !== false) { this.pos += match[0].length; } + return match + } +}; +StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)}; +StringStream.prototype.hideFirstChars = function (n, inner) { + this.lineStart += n; + try { return inner() } + finally { this.lineStart -= n; } +}; +StringStream.prototype.lookAhead = function (n) { + var oracle = this.lineOracle; + return oracle && oracle.lookAhead(n) +}; +StringStream.prototype.baseToken = function () { + var oracle = this.lineOracle; + return oracle && oracle.baseToken(this.pos) +}; + +// Known modes, by name and by MIME +var modes = {}, mimeModes = {}; + +// Extra arguments are stored as the mode's dependencies, which is +// used by (legacy) mechanisms like loadmode.js to automatically +// load a mode. (Preferred mechanism is the require/define calls.) +function defineMode(name, mode) { + if (arguments.length > 2) + { mode.dependencies = Array.prototype.slice.call(arguments, 2); } + modes[name] = mode; +} + +function defineMIME(mime, spec) { + mimeModes[mime] = spec; +} + +// Given a MIME type, a {name, ...options} config object, or a name +// string, return a mode config object. +function resolveMode(spec) { + if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { + spec = mimeModes[spec]; + } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { + var found = mimeModes[spec.name]; + if (typeof found == "string") { found = {name: found}; } + spec = createObj(found, spec); + spec.name = found.name; + } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { + return resolveMode("application/xml") + } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) { + return resolveMode("application/json") + } + if (typeof spec == "string") { return {name: spec} } + else { return spec || {name: "null"} } +} + +// Given a mode spec (anything that resolveMode accepts), find and +// initialize an actual mode object. +function getMode(options, spec) { + spec = resolveMode(spec); + var mfactory = modes[spec.name]; + if (!mfactory) { return getMode(options, "text/plain") } + var modeObj = mfactory(options, spec); + if (modeExtensions.hasOwnProperty(spec.name)) { + var exts = modeExtensions[spec.name]; + for (var prop in exts) { + if (!exts.hasOwnProperty(prop)) { continue } + if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; } + modeObj[prop] = exts[prop]; + } + } + modeObj.name = spec.name; + if (spec.helperType) { modeObj.helperType = spec.helperType; } + if (spec.modeProps) { for (var prop$1 in spec.modeProps) + { modeObj[prop$1] = spec.modeProps[prop$1]; } } + + return modeObj +} + +// This can be used to attach properties to mode objects from +// outside the actual mode definition. +var modeExtensions = {}; +function extendMode(mode, properties) { + var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); + copyObj(properties, exts); +} + +function copyState(mode, state) { + if (state === true) { return state } + if (mode.copyState) { return mode.copyState(state) } + var nstate = {}; + for (var n in state) { + var val = state[n]; + if (val instanceof Array) { val = val.concat([]); } + nstate[n] = val; + } + return nstate +} + +// Given a mode and a state (for that mode), find the inner mode and +// state at the position that the state refers to. +function innerMode(mode, state) { + var info; + while (mode.innerMode) { + info = mode.innerMode(state); + if (!info || info.mode == mode) { break } + state = info.state; + mode = info.mode; + } + return info || {mode: mode, state: state} +} + +function startState(mode, a1, a2) { + return mode.startState ? mode.startState(a1, a2) : true +} + +var modeMethods = { + __proto__: null, + modes: modes, + mimeModes: mimeModes, + defineMode: defineMode, + defineMIME: defineMIME, + resolveMode: resolveMode, + getMode: getMode, + modeExtensions: modeExtensions, + extendMode: extendMode, + copyState: copyState, + innerMode: innerMode, + startState: startState +}; + +// Copy StringStream and mode methods into exports (CodeMirror) object. +exports.StringStream = StringStream; +exports.countColumn = countColumn; +for (var exported in modeMethods) { exports[exported] = modeMethods[exported]; } + +// Shim library CodeMirror with the minimal CodeMirror defined above. +require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")]; +require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")]; + +// Minimal default mode. +exports.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); }); +exports.defineMIME("text/plain", "null"); + +exports.registerHelper = exports.registerGlobalHelper = Math.min; +exports.splitLines = function(string) { return string.split(/\r?\n|\r/) }; + +exports.defaults = { indentUnit: 2 }; + +// 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) { + +CodeMirror.runMode = function(string, modespec, callback, options) { + var mode = CodeMirror.getMode(CodeMirror.defaults, modespec); + var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize; + + // Create a tokenizing callback function if passed-in callback is a DOM element. + if (callback.appendChild) { + var ie = /MSIE \d/.test(navigator.userAgent); + var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9); + var node = callback, col = 0; + node.innerHTML = ""; + callback = function(text, style) { + if (text == "\n") { + // Emitting LF or CRLF on IE8 or earlier results in an incorrect display. + // Emitting a carriage return makes everything ok. + node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text)); + col = 0; + return; + } + var content = ""; + // replace tabs + for (var pos = 0;;) { + var idx = text.indexOf("\t", pos); + if (idx == -1) { + content += text.slice(pos); + col += text.length - pos; + break; + } else { + col += idx - pos; + content += text.slice(pos, idx); + var size = tabSize - col % tabSize; + col += size; + for (var i = 0; i < size; ++i) { content += " "; } + pos = idx + 1; + } + } + // Create a node with token style and append it to the callback DOM element. + if (style) { + var sp = node.appendChild(document.createElement("span")); + sp.className = "cm-" + style.replace(/ +/g, " cm-"); + sp.appendChild(document.createTextNode(content)); + } else { + node.appendChild(document.createTextNode(content)); + } + }; + } + + var lines = CodeMirror.splitLines(string), state = (options && options.state) || CodeMirror.startState(mode); + for (var i = 0, e = lines.length; i < e; ++i) { + if (i) { callback("\n"); } + var stream = new CodeMirror.StringStream(lines[i], null, { + lookAhead: function(n) { return lines[i + n] }, + baseToken: function() {} + }); + if (!stream.string && mode.blankLine) { mode.blankLine(state); } + while (!stream.eol()) { + var style = mode.token(stream, state); + callback(stream.current(), style, i, stream.start, state); + stream.start = stream.pos; + } + } +}; + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/annotatescrollbar.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/annotatescrollbar.js index bbb9ace..c12e44c 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/annotatescrollbar.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/annotatescrollbar.js @@ -1,6 +1,128 @@ -'use strict';(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function e(a,f){function c(a){clearTimeout(d.doRedraw);d.doRedraw=setTimeout(function(){d.redraw()},a)}this.cm=a;this.options=f;this.buttonHeight=f.scrollButtonHeight||a.getOption("scrollButtonHeight");this.annotations=[];this.doRedraw=this.doUpdate=null;this.div=a.getWrapperElement().appendChild(document.createElement("div")); -this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none";this.computeScale();var d=this;a.on("refresh",this.resizeHandler=function(){clearTimeout(d.doUpdate);d.doUpdate=setTimeout(function(){d.computeScale()&&c(20)},100)});a.on("markerAdded",this.resizeHandler);a.on("markerCleared",this.resizeHandler);if(!1!==f.listenForChanges)a.on("changes",this.changeHandler=function(){c(250)})}b.defineExtension("annotateScrollbar",function(a){"string"==typeof a&&(a={className:a}); -return new e(this,a)});b.defineOption("scrollButtonHeight",0);e.prototype.computeScale=function(){var a=this.cm;a=(a.getWrapperElement().clientHeight-a.display.barHeight-2*this.buttonHeight)/a.getScrollerElement().scrollHeight;if(a!=this.hScale)return this.hScale=a,!0};e.prototype.update=function(a){this.annotations=a;this.redraw()};e.prototype.redraw=function(a){function f(a,b){m!=a.line&&(m=a.line,k=c.getLineHandle(m));return k.widgets&&k.widgets.length||e&&k.height>t?c.charCoords(a,"local")[b? -"top":"bottom"]:c.heightAtLine(k,"local")+(b?0:k.height)}!1!==a&&this.computeScale();var c=this.cm;a=this.hScale;var d=document.createDocumentFragment(),b=this.annotations,e=c.getOption("lineWrapping"),t=e&&1.5*c.defaultTextHeight(),m=null,k=null,r=c.lastLine();if(c.display.barWidth)for(var g=0,n;gr)){for(var p=n||f(h.from,!0)*a,l=f(h.to,!1)*a;gr);){n=f(b[g+1].from,!0)*a;if(n>l+.9)break;h=b[++g];l=f(h.to,!1)*a}if(l!=p){l=Math.max(l- -p,3);var q=d.appendChild(document.createElement("div"));q.style.cssText="position: absolute; right: 0px; width: "+Math.max(c.display.barWidth-1,2)+"px; top: "+(p+this.buttonHeight)+"px; height: "+l+"px";q.className=this.options.className;h.id&&q.setAttribute("annotation-id",h.id)}}}this.div.textContent="";this.div.appendChild(d)};e.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler);this.cm.off("markerAdded",this.resizeHandler);this.cm.off("markerCleared",this.resizeHandler);this.changeHandler&& -this.cm.off("changes",this.changeHandler);this.div.parentNode.removeChild(this.div)}}); +// 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"; + + CodeMirror.defineExtension("annotateScrollbar", function(options) { + if (typeof options == "string") options = {className: options}; + return new Annotation(this, options); + }); + + CodeMirror.defineOption("scrollButtonHeight", 0); + + function Annotation(cm, options) { + this.cm = cm; + this.options = options; + this.buttonHeight = options.scrollButtonHeight || cm.getOption("scrollButtonHeight"); + this.annotations = []; + this.doRedraw = this.doUpdate = null; + this.div = cm.getWrapperElement().appendChild(document.createElement("div")); + this.div.style.cssText = "position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none"; + this.computeScale(); + + function scheduleRedraw(delay) { + clearTimeout(self.doRedraw); + self.doRedraw = setTimeout(function() { self.redraw(); }, delay); + } + + var self = this; + cm.on("refresh", this.resizeHandler = function() { + clearTimeout(self.doUpdate); + self.doUpdate = setTimeout(function() { + if (self.computeScale()) scheduleRedraw(20); + }, 100); + }); + cm.on("markerAdded", this.resizeHandler); + cm.on("markerCleared", this.resizeHandler); + if (options.listenForChanges !== false) + cm.on("changes", this.changeHandler = function() { + scheduleRedraw(250); + }); + } + + Annotation.prototype.computeScale = function() { + var cm = this.cm; + var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) / + cm.getScrollerElement().scrollHeight + if (hScale != this.hScale) { + this.hScale = hScale; + return true; + } + }; + + Annotation.prototype.update = function(annotations) { + this.annotations = annotations; + this.redraw(); + }; + + Annotation.prototype.redraw = function(compute) { + if (compute !== false) this.computeScale(); + var cm = this.cm, hScale = this.hScale; + + var frag = document.createDocumentFragment(), anns = this.annotations; + + var wrapping = cm.getOption("lineWrapping"); + var singleLineH = wrapping && cm.defaultTextHeight() * 1.5; + var curLine = null, curLineObj = null; + + function getY(pos, top) { + if (curLine != pos.line) { + curLine = pos.line + curLineObj = cm.getLineHandle(pos.line) + var visual = cm.getLineHandleVisualStart(curLineObj) + if (visual != curLineObj) { + curLine = cm.getLineNumber(visual) + curLineObj = visual + } + } + if ((curLineObj.widgets && curLineObj.widgets.length) || + (wrapping && curLineObj.height > singleLineH)) + return cm.charCoords(pos, "local")[top ? "top" : "bottom"]; + var topY = cm.heightAtLine(curLineObj, "local"); + return topY + (top ? 0 : curLineObj.height); + } + + var lastLine = cm.lastLine() + if (cm.display.barWidth) for (var i = 0, nextTop; i < anns.length; i++) { + var ann = anns[i]; + if (ann.to.line > lastLine) continue; + var top = nextTop || getY(ann.from, true) * hScale; + var bottom = getY(ann.to, false) * hScale; + while (i < anns.length - 1) { + if (anns[i + 1].to.line > lastLine) break; + nextTop = getY(anns[i + 1].from, true) * hScale; + if (nextTop > bottom + .9) break; + ann = anns[++i]; + bottom = getY(ann.to, false) * hScale; + } + if (bottom == top) continue; + var height = Math.max(bottom - top, 3); + + var elt = frag.appendChild(document.createElement("div")); + elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: " + + (top + this.buttonHeight) + "px; height: " + height + "px"; + elt.className = this.options.className; + if (ann.id) { + elt.setAttribute("annotation-id", ann.id); + } + } + this.div.textContent = ""; + this.div.appendChild(frag); + }; + + Annotation.prototype.clear = function() { + this.cm.off("refresh", this.resizeHandler); + this.cm.off("markerAdded", this.resizeHandler); + this.cm.off("markerCleared", this.resizeHandler); + if (this.changeHandler) this.cm.off("changes", this.changeHandler); + this.div.parentNode.removeChild(this.div); + }; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/scrollpastend.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/scrollpastend.js index 814f518..2ed9d95 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/scrollpastend.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/scrollpastend.js @@ -1,2 +1,48 @@ -'use strict';(function(c){"object"==typeof exports&&"object"==typeof module?c(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){function e(a,b){c.changeEnd(b).line==a.lastLine()&&d(a)}function d(a){var b="";if(1 1) { + var totalH = cm.display.scroller.clientHeight - 30, + lastLineH = cm.getLineHandle(cm.lastLine()).height; + padding = (totalH - lastLineH) + "px"; + } + if (cm.state.scrollPastEndPadding != padding) { + cm.state.scrollPastEndPadding = padding; + cm.display.lineSpace.parentNode.style.paddingBottom = padding; + cm.off("refresh", updateBottomMargin); + cm.setSize(); + cm.on("refresh", updateBottomMargin); + } + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/simplescrollbars.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/simplescrollbars.css index 618a2f7..5eea7aa 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/simplescrollbars.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/simplescrollbars.css @@ -1 +1,66 @@ -.CodeMirror-simplescroll-horizontal div,.CodeMirror-simplescroll-vertical div{position:absolute;background:#ccc;-moz-box-sizing:border-box;box-sizing:border-box;border:1px solid #bbb;border-radius:2px}.CodeMirror-simplescroll-horizontal,.CodeMirror-simplescroll-vertical{position:absolute;z-index:6;background:#eee}.CodeMirror-simplescroll-horizontal{bottom:0;left:0;height:8px}.CodeMirror-simplescroll-horizontal div{bottom:0;height:100%}.CodeMirror-simplescroll-vertical{right:0;top:0;width:8px}.CodeMirror-simplescroll-vertical div{right:0;width:100%}.CodeMirror-overlayscroll .CodeMirror-gutter-filler,.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler{display:none}.CodeMirror-overlayscroll-horizontal div,.CodeMirror-overlayscroll-vertical div{position:absolute;background:#bcd;border-radius:3px}.CodeMirror-overlayscroll-horizontal,.CodeMirror-overlayscroll-vertical{position:absolute;z-index:6}.CodeMirror-overlayscroll-horizontal{bottom:0;left:0;height:6px}.CodeMirror-overlayscroll-horizontal div{bottom:0;height:100%}.CodeMirror-overlayscroll-vertical{right:0;top:0;width:6px}.CodeMirror-overlayscroll-vertical div{right:0;width:100%} \ No newline at end of file +.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div { + position: absolute; + background: #ccc; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 1px solid #bbb; + border-radius: 2px; +} + +.CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical { + position: absolute; + z-index: 6; + background: #eee; +} + +.CodeMirror-simplescroll-horizontal { + bottom: 0; left: 0; + height: 8px; +} +.CodeMirror-simplescroll-horizontal div { + bottom: 0; + height: 100%; +} + +.CodeMirror-simplescroll-vertical { + right: 0; top: 0; + width: 8px; +} +.CodeMirror-simplescroll-vertical div { + right: 0; + width: 100%; +} + + +.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler { + display: none; +} + +.CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div { + position: absolute; + background: #bcd; + border-radius: 3px; +} + +.CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical { + position: absolute; + z-index: 6; +} + +.CodeMirror-overlayscroll-horizontal { + bottom: 0; left: 0; + height: 6px; +} +.CodeMirror-overlayscroll-horizontal div { + bottom: 0; + height: 100%; +} + +.CodeMirror-overlayscroll-vertical { + right: 0; top: 0; + width: 6px; +} +.CodeMirror-overlayscroll-vertical div { + right: 0; + width: 100%; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/simplescrollbars.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/simplescrollbars.js index b2ab35c..750a2bd 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/simplescrollbars.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/scroll/simplescrollbars.js @@ -1,6 +1,152 @@ -'use strict';(function(c){"object"==typeof exports&&"object"==typeof module?c(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){function g(a,b,h){function e(a){var b=c.wheelEventPixels(a)["horizontal"==d.orientation?"x":"y"],h=d.pos;d.moveTo(d.pos+b);d.pos!=h&&c.e_preventDefault(a)}this.orientation=b;this.scroll=h;this.screen=this.total=this.size=1;this.pos=0;this.node=document.createElement("div");this.node.className= -a+"-"+b;this.inner=this.node.appendChild(document.createElement("div"));var d=this;c.on(this.inner,"mousedown",function(a){function b(){c.off(document,"mousemove",h);c.off(document,"mouseup",b)}function h(a){if(1!=a.which)return b();d.moveTo(g+d.total/d.size*(a[e]-f))}if(1==a.which){c.e_preventDefault(a);var e="horizontal"==d.orientation?"pageX":"pageY",f=a[e],g=d.pos;c.on(document,"mousemove",h);c.on(document,"mouseup",b)}});c.on(this.node,"click",function(a){c.e_preventDefault(a);var b=d.inner.getBoundingClientRect(); -d.moveTo(d.pos+("horizontal"==d.orientation?a.clientXb.right?1:0:a.clientYb.bottom?1:0)*d.screen)});c.on(this.node,"mousewheel",e);c.on(this.node,"DOMMouseScroll",e)}function f(a,b,c){this.addClass=a;this.horiz=new g(a,"horizontal",c);b(this.horiz.node);this.vert=new g(a,"vertical",c);b(this.vert.node);this.width=null}g.prototype.setPos=function(a,b){0>a&&(a=0);a>this.total-this.screen&&(a=this.total-this.screen);if(!b&&a==this.pos)return!1;this.pos=a;this.inner.style["horizontal"== -this.orientation?"left":"top"]=this.size/this.total*a+"px";return!0};g.prototype.moveTo=function(a){this.setPos(a)&&this.scroll(a,this.orientation)};g.prototype.update=function(a,b,c){var e=this.screen!=b||this.total!=a||this.size!=c;e&&(this.screen=b,this.total=a,this.size=c);a=this.size/this.total*this.screen;10>a&&(this.size-=10-a,a=10);this.inner.style["horizontal"==this.orientation?"width":"height"]=a+"px";this.setPos(this.pos,e)};f.prototype.update=function(a){if(null==this.width){var b=window.getComputedStyle? -window.getComputedStyle(this.horiz.node):this.horiz.node.currentStyle;b&&(this.width=parseInt(b.height))}b=this.width||0;var c=a.scrollWidth>a.clientWidth+1,e=a.scrollHeight>a.clientHeight+1;this.vert.node.style.display=e?"block":"none";this.horiz.node.style.display=c?"block":"none";e&&(this.vert.update(a.scrollHeight,a.clientHeight,a.viewHeight-(c?b:0)),this.vert.node.style.bottom=c?b+"px":"0");c&&(this.horiz.update(a.scrollWidth,a.clientWidth,a.viewWidth-(e?b:0)-a.barLeft),this.horiz.node.style.right= -e?b+"px":"0",this.horiz.node.style.left=a.barLeft+"px");return{right:e?b:0,bottom:c?b:0}};f.prototype.setScrollTop=function(a){this.vert.setPos(a)};f.prototype.setScrollLeft=function(a){this.horiz.setPos(a)};f.prototype.clear=function(){var a=this.horiz.node.parentNode;a.removeChild(this.horiz.node);a.removeChild(this.vert.node)};c.scrollbarModel.simple=function(a,b){return new f("CodeMirror-simplescroll",a,b)};c.scrollbarModel.overlay=function(a,b){return new f("CodeMirror-overlayscroll",a,b)}}); +// 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 Bar(cls, orientation, scroll) { + this.orientation = orientation; + this.scroll = scroll; + this.screen = this.total = this.size = 1; + this.pos = 0; + + this.node = document.createElement("div"); + this.node.className = cls + "-" + orientation; + this.inner = this.node.appendChild(document.createElement("div")); + + var self = this; + CodeMirror.on(this.inner, "mousedown", function(e) { + if (e.which != 1) return; + CodeMirror.e_preventDefault(e); + var axis = self.orientation == "horizontal" ? "pageX" : "pageY"; + var start = e[axis], startpos = self.pos; + function done() { + CodeMirror.off(document, "mousemove", move); + CodeMirror.off(document, "mouseup", done); + } + function move(e) { + if (e.which != 1) return done(); + self.moveTo(startpos + (e[axis] - start) * (self.total / self.size)); + } + CodeMirror.on(document, "mousemove", move); + CodeMirror.on(document, "mouseup", done); + }); + + CodeMirror.on(this.node, "click", function(e) { + CodeMirror.e_preventDefault(e); + var innerBox = self.inner.getBoundingClientRect(), where; + if (self.orientation == "horizontal") + where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0; + else + where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0; + self.moveTo(self.pos + where * self.screen); + }); + + function onWheel(e) { + var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"]; + var oldPos = self.pos; + self.moveTo(self.pos + moved); + if (self.pos != oldPos) CodeMirror.e_preventDefault(e); + } + CodeMirror.on(this.node, "mousewheel", onWheel); + CodeMirror.on(this.node, "DOMMouseScroll", onWheel); + } + + Bar.prototype.setPos = function(pos, force) { + if (pos < 0) pos = 0; + if (pos > this.total - this.screen) pos = this.total - this.screen; + if (!force && pos == this.pos) return false; + this.pos = pos; + this.inner.style[this.orientation == "horizontal" ? "left" : "top"] = + (pos * (this.size / this.total)) + "px"; + return true + }; + + Bar.prototype.moveTo = function(pos) { + if (this.setPos(pos)) this.scroll(pos, this.orientation); + } + + var minButtonSize = 10; + + Bar.prototype.update = function(scrollSize, clientSize, barSize) { + var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize + if (sizeChanged) { + this.screen = clientSize; + this.total = scrollSize; + this.size = barSize; + } + + var buttonSize = this.screen * (this.size / this.total); + if (buttonSize < minButtonSize) { + this.size -= minButtonSize - buttonSize; + buttonSize = minButtonSize; + } + this.inner.style[this.orientation == "horizontal" ? "width" : "height"] = + buttonSize + "px"; + this.setPos(this.pos, sizeChanged); + }; + + function SimpleScrollbars(cls, place, scroll) { + this.addClass = cls; + this.horiz = new Bar(cls, "horizontal", scroll); + place(this.horiz.node); + this.vert = new Bar(cls, "vertical", scroll); + place(this.vert.node); + this.width = null; + } + + SimpleScrollbars.prototype.update = function(measure) { + if (this.width == null) { + var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle; + if (style) this.width = parseInt(style.height); + } + var width = this.width || 0; + + var needsH = measure.scrollWidth > measure.clientWidth + 1; + var needsV = measure.scrollHeight > measure.clientHeight + 1; + this.vert.node.style.display = needsV ? "block" : "none"; + this.horiz.node.style.display = needsH ? "block" : "none"; + + if (needsV) { + this.vert.update(measure.scrollHeight, measure.clientHeight, + measure.viewHeight - (needsH ? width : 0)); + this.vert.node.style.bottom = needsH ? width + "px" : "0"; + } + if (needsH) { + this.horiz.update(measure.scrollWidth, measure.clientWidth, + measure.viewWidth - (needsV ? width : 0) - measure.barLeft); + this.horiz.node.style.right = needsV ? width + "px" : "0"; + this.horiz.node.style.left = measure.barLeft + "px"; + } + + return {right: needsV ? width : 0, bottom: needsH ? width : 0}; + }; + + SimpleScrollbars.prototype.setScrollTop = function(pos) { + this.vert.setPos(pos); + }; + + SimpleScrollbars.prototype.setScrollLeft = function(pos) { + this.horiz.setPos(pos); + }; + + SimpleScrollbars.prototype.clear = function() { + var parent = this.horiz.node.parentNode; + parent.removeChild(this.horiz.node); + parent.removeChild(this.vert.node); + }; + + CodeMirror.scrollbarModel.simple = function(place, scroll) { + return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll); + }; + CodeMirror.scrollbarModel.overlay = function(place, scroll) { + return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll); + }; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search.js new file mode 100644 index 0000000..d9c7a7d --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search.js @@ -0,0 +1,525 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Define search commands. Depends on find-and-replace-dialog.js + +((mod) => { + if (typeof exports == "object" && typeof module == "object") + // CommonJS + mod(require("codemirror"), require("codemirror-find-and-replace-dialog")); + else if (typeof define == "function" && define.amd) + // AMD + define(["codemirror", "codemirror-find-and-replace-dialog"], mod); + // Plain browser env + else mod(CodeMirror); +})((CodeMirror) => { + "use strict"; + + var replaceDialog = ` +
+
+
+ + +
+
+ + + +
+
+ +
+
+ +
+
+ + +
+
+
+ `; + + var findDialog = ` +
+ + +
+
+ + + +
+ `; + + let numMatches = 0; + let searchOverlay = (query, caseInsensitive) => { + if (typeof query == "string") + query = new RegExp( + query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), + caseInsensitive ? "gi" : "g" + ); + else if (!query.global) + query = new RegExp(query.source, query.ignoreCase ? "gi" : "g"); + + return { + token: (stream) => { + query.lastIndex = stream.pos; + var match = query.exec(stream.string); + if (match && match.index == stream.pos) { + stream.pos += match[0].length || 1; + return "searching"; + } else if (match) { + stream.pos = match.index; + } else { + stream.skipToEnd(); + } + }, + }; + }; + + function SearchState() { + this.posFrom = this.posTo = this.lastQuery = this.query = null; + this.overlay = null; + } + + let getSearchState = (cm) => { + return cm.state.search || (cm.state.search = new SearchState()); + }; + + let queryCaseInsensitive = (query) => { + return typeof query == "string" && query == query.toLowerCase(); + }; + + let getSearchCursor = (cm, query, pos) => { + // Heuristic: if the query string is all lowercase, do a case insensitive search. + return cm.getSearchCursor( + parseQuery(query), + pos, + queryCaseInsensitive(query) + ); + }; + + let parseString = (string) => { + return string.replace(/\\(.)/g, (_, ch) => { + if (ch == "n") return "\n"; + if (ch == "r") return "\r"; + return ch; + }); + }; + + let parseQuery = (query) => { + if (query.exec) { + return query; + } + var isRE = query.indexOf("/") === 0 && query.lastIndexOf("/") > 0; + if (!!isRE) { + try { + let matches = query.match(/^\/(.*)\/([a-z]*)$/); + query = new RegExp( + matches[1], + matches[2].indexOf("i") == -1 ? "" : "i" + ); + } catch (e) {} // Not a regular expression after all, do a string search + } else { + query = parseString(query); + } + if (typeof query == "string" ? query == "" : query.test("")) query = /x^/; + return query; + }; + + /* Old */ + // let startSearch = (cm, state, query) => { + // if (!query || query === "") return; + // state.queryText = query; + // state.query = parseQuery(query); + // cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); + // state.overlay = searchOverlay( + // state.query, + // queryCaseInsensitive(state.query) + // ); + // cm.addOverlay(state.overlay); + // if (cm.showMatchesOnScrollbar) { + // if (state.annotate) { + // state.annotate.clear(); + // state.annotate = null; + // } + // state.annotate = cm.showMatchesOnScrollbar( + // state.query, + // queryCaseInsensitive(state.query) + // ); + // } + // }; + + /* New */ + let startSearch = (cm, state, query) => { + if (!query || query === "") return; + state.queryText = query; + state.query = parseQuery(query); + // cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); + cm.removeOverlay(state.overlay, true); + state.overlay = searchOverlay( + state.query, + // queryCaseInsensitive(state.query) + true + ); + cm.addOverlay(state.overlay); + if (cm.showMatchesOnScrollbar) { + if (state.annotate) { + state.annotate.clear(); + state.annotate = null; + } + state.annotate = cm.showMatchesOnScrollbar( + state.query, + // queryCaseInsensitive(state.query) + true + ); + } + }; + + let doSearch = (cm, query, reverse, moveToNext) => { + var hiding = null; + var state = getSearchState(cm); + if (query != state.queryText) { + startSearch(cm, state, query); + state.posFrom = state.posTo = cm.getCursor(); + } + if (moveToNext || moveToNext === undefined) { + findNext(cm, reverse || false); + } + updateCount(cm); + }; + + let clearSearch = (cm) => { + cm.operation(() => { + var state = getSearchState(cm); + state.lastQuery = state.query; + if (!state.query) return; + state.query = state.queryText = null; + cm.removeOverlay(state.overlay); + if (state.annotate) { + state.annotate.clear(); + state.annotate = null; + } + }); + }; + + let findNext = (cm, reverse, callback) => { + cm.operation(() => { + var state = getSearchState(cm); + var cursor = getSearchCursor( + cm, + state.query, + reverse ? state.posFrom : state.posTo + ); + if (!cursor.find(reverse)) { + cursor = getSearchCursor( + cm, + state.query, + reverse + ? CodeMirror.Pos(cm.lastLine()) + : CodeMirror.Pos(cm.firstLine(), 0) + ); + if (!cursor.find(reverse)) return; + } + cm.setSelection(cursor.from(), cursor.to()); + cm.scrollIntoView( + { + from: cursor.from(), + to: cursor.to(), + }, + 20 + ); + state.posFrom = cursor.from(); + state.posTo = cursor.to(); + if (callback) callback(cursor.from(), cursor.to()); + }); + }; + + let replaceNext = (cm, query, text) => { + let cursor = getSearchCursor(cm, query, cm.getCursor("from")); + let start = cursor.from(); + let match = cursor.findNext(); + if (!match) { + cursor = getSearchCursor(cm, query); + match = cursor.findNext(); + if ( + !match || + (start && + cursor.from().line === start.line && + cursor.from().ch === start.ch) + ) + return; + } + cm.setSelection(cursor.from(), cursor.to()); + cm.scrollIntoView({ + from: cursor.from(), + to: cursor.to(), + }); + cursor.replace( + typeof query === "string" + ? text + : text.replace(/\$(\d)/g, (_, i) => { + return match[i]; + }) + ); + }; + + let replaceAll = (cm, query, text) => { + cm.operation(() => { + for (var cursor = getSearchCursor(cm, query); cursor.findNext(); ) { + if (typeof query != "string") { + var match = cm.getRange(cursor.from(), cursor.to()).match(query); + cursor.replace( + text.replace(/\$(\d)/g, (_, i) => { + return match[i]; + }) + ); + } else cursor.replace(text); + } + }); + }; + + let closeSearchCallback = (cm, state) => { + if (state.annotate) { + state.annotate.clear(); + state.annotate = null; + } + clearSearch(cm); + }; + + let getOnReadOnlyCallback = (callback) => { + let closeFindDialogOnReadOnly = (cm, opt) => { + if (opt === "readOnly" && !!cm.getOption("readOnly")) { + callback(); + cm.off("optionChange", closeFindDialogOnReadOnly); + } + }; + return closeFindDialogOnReadOnly; + }; + + let updateCount = (cm) => { + let state = getSearchState(cm); + let value = cm.getDoc().getValue(); + let globalQuery; + let queryText = state.queryText; + + if (!queryText || queryText === "") { + resetCount(cm); + return; + } + + while (queryText.charAt(queryText.length - 1) === "\\") { + queryText = queryText.substring(0, queryText.lastIndexOf("\\")); + } + + if (typeof state.query === "string") { + globalQuery = new RegExp(queryText, "ig"); + } else { + globalQuery = new RegExp(state.query.source, state.query.flags + "g"); + } + + let matches = value.match(globalQuery); + let count = matches ? matches.length : 0; + + let countText = count === 1 ? "1 match found." : count + " matches found."; + cm + .getWrapperElement() + .parentNode.querySelector( + ".CodeMirror-find-and-replace-dialog--search-count" + ).innerHTML = countText; + cm + .getWrapperElement() + .parentNode.querySelector( + ".CodeMirror-find-and-replace-dialog--find-previous" + ).disabled = count <= 0; + cm + .getWrapperElement() + .parentNode.querySelector( + ".CodeMirror-find-and-replace-dialog--find-next" + ).disabled = count <= 0; + }; + + let resetCount = (cm) => { + cm + .getWrapperElement() + .parentNode.querySelector( + ".CodeMirror-find-and-replace-dialog--search-count" + ).innerHTML = ""; + cm + .getWrapperElement() + .parentNode.querySelector( + ".CodeMirror-find-and-replace-dialog--find-next" + ).disabled = true; + cm + .getWrapperElement() + .parentNode.querySelector( + ".CodeMirror-find-and-replace-dialog--find-previous" + ).disabled = true; + }; + + let getFindBehaviour = (cm, defaultText, callback) => { + if (!defaultText) { + defaultText = ""; + } + let behaviour = { + value: defaultText, + focus: true, + selectValueOnOpen: true, + closeOnEnter: false, + closeOnBlur: false, + callback: (inputs, e) => { + let query = inputs[0].value; + if (!query) return; + doSearch(cm, query, !!e.shiftKey); + }, + onInput: (inputs, e) => { + let query = inputs[0].value; + if (!query) { + resetCount(cm); + clearSearch(cm); + return; + } + doSearch(cm, query, !!e.shiftKey, false); + }, + }; + if (!!callback) { + behaviour.callback = callback; + } + return behaviour; + }; + + let getFindPrevBtnBehaviour = (cm) => { + return { + callback: (inputs) => { + let query = inputs[0].value; + if (!query) return; + doSearch(cm, query, true); + }, + }; + }; + + let getFindNextBtnBehaviour = (cm) => { + return { + callback: (inputs) => { + let query = inputs[0].value; + if (!query) return; + doSearch(cm, query, false); + }, + }; + }; + + let closeBtnBehaviour = { + callback: null, + }; + + CodeMirror.commands.find = (cm) => { + // if (cm.getOption("readOnly")) return; + clearSearch(cm); + let state = getSearchState(cm); + var query = cm.getSelection() || getSearchState(cm).lastQuery; + let closeDialog = cm.openFindAndReplaceDialog(findDialog, { + shrinkEditor: true, + inputBehaviour: [getFindBehaviour(cm, query)], + buttonBehaviour: [ + getFindPrevBtnBehaviour(cm), + getFindNextBtnBehaviour(cm), + closeBtnBehaviour, + ], + onClose: () => { + closeSearchCallback(cm, state); + }, + }); + + cm.on("optionChange", getOnReadOnlyCallback(closeDialog)); + startSearch(cm, state, query); + updateCount(cm); + }; + + CodeMirror.commands.replace = (cm, all) => { + if (cm.getOption("readOnly")) return; + clearSearch(cm); + + let replaceNextCallback = (inputs) => { + let query = parseQuery(inputs[0].value); + let text = parseString(inputs[1].value); + if (!query) return; + replaceNext(cm, query, text); + doSearch(cm, query); + }; + + let state = getSearchState(cm); + let query = cm.getSelection() || state.lastQuery; + let closeDialog = cm.openFindAndReplaceDialog(replaceDialog, { + shrinkEditor: true, + inputBehaviour: [ + getFindBehaviour(cm, query, (inputs) => { + inputs[1].focus(); + inputs[1].select(); + }), + { + closeOnEnter: false, + closeOnBlur: false, + callback: replaceNextCallback, + }, + ], + buttonBehaviour: [ + getFindPrevBtnBehaviour(cm), + getFindNextBtnBehaviour(cm), + closeBtnBehaviour, + { + callback: replaceNextCallback, + }, + { + callback: (inputs) => { + // Replace all + let query = parseQuery(inputs[0].value); + let text = parseString(inputs[1].value); + if (!query) return; + replaceAll(cm, query, text); + }, + }, + ], + onClose: () => { + closeSearchCallback(cm, state); + }, + }); + + cm.on("optionChange", getOnReadOnlyCallback(closeDialog)); + startSearch(cm, state, query); + updateCount(cm); + }; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/jump-to-line.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/jump-to-line.js index 4a5ce3a..990c235 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/jump-to-line.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/jump-to-line.js @@ -1,3 +1,53 @@ -'use strict';(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../dialog/dialog"],e):e(CodeMirror)})(function(e){function g(a,d,b,c,e){a.openDialog?a.openDialog(d,e,{value:c,selectValueOnOpen:!0}):e(prompt(b,c))}function h(a){return a.phrase("Jump to line:")+' '+ -a.phrase("(Use line:column or scroll% syntax)")+""}function f(a,d){var b=Number(d);return/^[-+]/.test(d)?a.getCursor().line+b:b-1}e.commands.jumpToLine=function(a){var d=a.getCursor();g(a,h(a),a.phrase("Jump to line:"),d.line+1+":"+d.ch,function(b){if(b){var c;(c=/^\s*([\+\-]?\d+)\s*:\s*(\d+)\s*$/.exec(b))?a.setCursor(f(a,c[1]),Number(c[2])):(c=/^\s*([\+\-]?\d+(\.\d+)?)%\s*/.exec(b))?(b=Math.round(a.lineCount()*Number(c[1])/100),/^[-+]/.test(c[1])&&(b=d.line+b+1),a.setCursor(b-1,d.ch)):(c= -/^\s*:?\s*([\+\-]?\d+)\s*/.exec(b))&&a.setCursor(f(a,c[1]),d.ch)}})};e.keyMap["default"]["Alt-G"]="jumpToLine"}); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Defines jumpToLine command. Uses dialog.js if present. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../dialog/dialog")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../dialog/dialog"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + // default search panel location + CodeMirror.defineOption("search", {bottom: false}); + + function dialog(cm, text, shortText, deflt, f) { + if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true, bottom: cm.options.search.bottom}); + else f(prompt(shortText, deflt)); + } + + function getJumpDialog(cm) { + return cm.phrase("Jump to line:") + ' ' + cm.phrase("(Use line:column or scroll% syntax)") + ''; + } + + function interpretLine(cm, string) { + var num = Number(string) + if (/^[-+]/.test(string)) return cm.getCursor().line + num + else return num - 1 + } + + CodeMirror.commands.jumpToLine = function(cm) { + var cur = cm.getCursor(); + dialog(cm, getJumpDialog(cm), cm.phrase("Jump to line:"), (cur.line + 1) + ":" + cur.ch, function(posStr) { + if (!posStr) return; + + var match; + if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) { + cm.setCursor(interpretLine(cm, match[1]), Number(match[2])) + } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) { + var line = Math.round(cm.lineCount() * Number(match[1]) / 100); + if (/^[-+]/.test(match[1])) line = cur.line + line + 1; + cm.setCursor(line - 1, cur.ch); + } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) { + cm.setCursor(interpretLine(cm, match[1]), cur.ch); + } + }); + }; + + CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine"; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/match-highlighter.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/match-highlighter.js index c24cc96..9b181eb 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/match-highlighter.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/match-highlighter.js @@ -1,6 +1,167 @@ -'use strict';(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror"),require("./matchesonscrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./matchesonscrollbar"],f):f(CodeMirror)})(function(f){function q(a){this.options={};for(var b in g)this.options[b]=(a&&a.hasOwnProperty(b)?a:g)[b];this.matchesonscroll=this.overlay=this.timeout=null;this.active=!1}function h(a){var b=a.state.matchHighlighter;(b.active||a.hasFocus())&&k(a, -b)}function l(a){var b=a.state.matchHighlighter;b.active||(b.active=!0,k(a,b))}function k(a,b){clearTimeout(b.timeout);b.timeout=setTimeout(function(){m(a)},b.options.delay)}function n(a,b,d,c){var e=a.state.matchHighlighter;a.addOverlay(e.overlay=r(b,d,c));e.options.annotateScrollbar&&a.showMatchesOnScrollbar&&(b=d?new RegExp("\\b"+b.replace(/[\\\[.+*?(){|^$]/g,"\\$&")+"\\b"):b,e.matchesonscroll=a.showMatchesOnScrollbar(b,!1,{className:"CodeMirror-selection-highlight-scrollbar"}))}function p(a){var b= -a.state.matchHighlighter;b.overlay&&(a.removeOverlay(b.overlay),b.overlay=null,b.matchesonscroll&&(b.matchesonscroll.clear(),b.matchesonscroll=null))}function m(a){a.operation(function(){var b=a.state.matchHighlighter;p(a);if(!a.somethingSelected()&&b.options.showToken){for(var d=!0===b.options.showToken?/[\w$]/:b.options.showToken,c=a.getCursor(),e=a.getLine(c.line),f=c=c.ch;c&&d.test(e.charAt(c-1));)--c;for(;f=b.options.minChars&&n(a,d,!1,b.options.style))}})}function r(a,b,d){return{token:function(c){var e; -if(e=c.match(a))(e=!b)||(e=(!c.start||!b.test(c.string.charAt(c.start-1)))&&(c.pos==c.string.length||!b.test(c.string.charAt(c.pos))));if(e)return d;c.next();c.skipTo(a.charAt(0))||c.skipToEnd()}}}var g={style:"matchhighlight",minChars:2,delay:100,wordsOnly:!1,annotateScrollbar:!1,showToken:!1,trim:!0};f.defineOption("highlightSelectionMatches",!1,function(a,b,d){d&&d!=f.Init&&(p(a),clearTimeout(a.state.matchHighlighter.timeout),a.state.matchHighlighter=null,a.off("cursorActivity",h),a.off("focus", -l));if(b){b=a.state.matchHighlighter=new q(b);if(a.hasFocus())b.active=!0,m(a);else a.on("focus",l);a.on("cursorActivity",h)}})}); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Highlighting text that matches the selection +// +// Defines an option highlightSelectionMatches, which, when enabled, +// will style strings that match the selection throughout the +// document. +// +// The option can be set to true to simply enable it, or to a +// {minChars, style, wordsOnly, showToken, delay} object to explicitly +// configure it. minChars is the minimum amount of characters that should be +// selected for the behavior to occur, and style is the token style to +// apply to the matches. This will be prefixed by "cm-" to create an +// actual CSS class name. If wordsOnly is enabled, the matches will be +// highlighted only if the selected text is a word. showToken, when enabled, +// will cause the current token to be highlighted when nothing is selected. +// delay is used to specify how much time to wait, in milliseconds, before +// highlighting the matches. If annotateScrollbar is enabled, the occurrences +// will be highlighted on the scrollbar via the matchesonscrollbar addon. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("./matchesonscrollbar")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "./matchesonscrollbar"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + var defaults = { + style: "matchhighlight", + minChars: 2, + delay: 100, + wordsOnly: false, + annotateScrollbar: false, + showToken: false, + trim: true + } + + function State(options) { + this.options = {} + for (var name in defaults) + this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name] + this.overlay = this.timeout = null; + this.matchesonscroll = null; + this.active = false; + } + + CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + removeOverlay(cm); + clearTimeout(cm.state.matchHighlighter.timeout); + cm.state.matchHighlighter = null; + cm.off("cursorActivity", cursorActivity); + cm.off("focus", onFocus) + } + if (val) { + var state = cm.state.matchHighlighter = new State(val); + if (cm.hasFocus()) { + state.active = true + highlightMatches(cm) + } else { + cm.on("focus", onFocus) + } + cm.on("cursorActivity", cursorActivity); + } + }); + + function cursorActivity(cm) { + var state = cm.state.matchHighlighter; + if (state.active || cm.hasFocus()) scheduleHighlight(cm, state) + } + + function onFocus(cm) { + var state = cm.state.matchHighlighter + if (!state.active) { + state.active = true + scheduleHighlight(cm, state) + } + } + + function scheduleHighlight(cm, state) { + clearTimeout(state.timeout); + state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay); + } + + function addOverlay(cm, query, hasBoundary, style) { + var state = cm.state.matchHighlighter; + cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style)); + if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) { + var searchFor = hasBoundary ? new RegExp((/\w/.test(query.charAt(0)) ? "\\b" : "") + + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + + (/\w/.test(query.charAt(query.length - 1)) ? "\\b" : "")) : query; + state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false, + {className: "CodeMirror-selection-highlight-scrollbar"}); + } + } + + function removeOverlay(cm) { + var state = cm.state.matchHighlighter; + if (state.overlay) { + cm.removeOverlay(state.overlay); + state.overlay = null; + if (state.matchesonscroll) { + state.matchesonscroll.clear(); + state.matchesonscroll = null; + } + } + } + + function highlightMatches(cm) { + cm.operation(function() { + var state = cm.state.matchHighlighter; + removeOverlay(cm); + if (!cm.somethingSelected() && state.options.showToken) { + var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken; + var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start; + while (start && re.test(line.charAt(start - 1))) --start; + while (end < line.length && re.test(line.charAt(end))) ++end; + if (start < end) + addOverlay(cm, line.slice(start, end), re, state.options.style); + return; + } + var from = cm.getCursor("from"), to = cm.getCursor("to"); + if (from.line != to.line) return; + if (state.options.wordsOnly && !isWord(cm, from, to)) return; + var selection = cm.getRange(from, to) + if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "") + if (selection.length >= state.options.minChars) + addOverlay(cm, selection, false, state.options.style); + }); + } + + function isWord(cm, from, to) { + var str = cm.getRange(from, to); + if (str.match(/^\w+$/) !== null) { + if (from.ch > 0) { + var pos = {line: from.line, ch: from.ch - 1}; + var chr = cm.getRange(pos, from); + if (chr.match(/\W/) === null) return false; + } + if (to.ch < cm.getLine(from.line).length) { + var pos = {line: to.line, ch: to.ch + 1}; + var chr = cm.getRange(to, pos); + if (chr.match(/\W/) === null) return false; + } + return true; + } else return false; + } + + function boundariesAround(stream, re) { + return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) && + (stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos))); + } + + function makeOverlay(query, hasBoundary, style) { + return {token: function(stream) { + if (stream.match(query) && + (!hasBoundary || boundariesAround(stream, hasBoundary))) + return style; + stream.next(); + stream.skipTo(query.charAt(0)) || stream.skipToEnd(); + }}; + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/matchesonscrollbar.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/matchesonscrollbar.css index 16ee905..77932cc 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/matchesonscrollbar.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/matchesonscrollbar.css @@ -1 +1,8 @@ -.CodeMirror-search-match{background:gold;border-top:1px solid orange;border-bottom:1px solid orange;-moz-box-sizing:border-box;box-sizing:border-box;opacity:.5} \ No newline at end of file +.CodeMirror-search-match { + background: gold; + border-top: 1px solid orange; + border-bottom: 1px solid orange; + -moz-box-sizing: border-box; + box-sizing: border-box; + opacity: .5; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/matchesonscrollbar.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/matchesonscrollbar.js index 5e031a7..8a4a827 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/matchesonscrollbar.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/matchesonscrollbar.js @@ -1,5 +1,97 @@ -'use strict';(function(d){"object"==typeof exports&&"object"==typeof module?d(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],d):d(CodeMirror)})(function(d){function g(a,c,b,e){this.cm=a;this.options=e;var f={listenForChanges:!1},d;for(d in e)f[d]=e[d];f.className||(f.className="CodeMirror-search-match");this.annotation=a.annotateScrollbar(f); -this.query=c;this.caseFold=b;this.gap={from:a.firstLine(),to:a.lastLine()+1};this.matches=[];this.update=null;this.findMatches();this.annotation.update(this.matches);var g=this;a.on("change",this.changeHandler=function(a,b){g.onChange(b)})}function h(a,c,b){return a<=c?a:Math.max(c,a+b)}d.defineExtension("showMatchesOnScrollbar",function(a,c,b){"string"==typeof b&&(b={className:b});b||(b={});return new g(this,a,c,b)});g.prototype.findMatches=function(){if(this.gap){for(var a=0;a=this.gap.to)break;c.to.line>=this.gap.from&&this.matches.splice(a--,1)}for(var b=this.cm.getSearchCursor(this.query,d.Pos(this.gap.from,0),{caseFold:this.caseFold,multiline:this.options.multiline}),e=this.options&&this.options.maxMatches||1E3;b.findNext();){c={from:b.from(),to:b.to()};if(c.from.line>=this.gap.to)break;this.matches.splice(a++,0,c);if(this.matches.length>e)break}this.gap=null}};g.prototype.onChange=function(a){var c=a.from.line,b=d.changeEnd(a).line, -e=b-a.to.line;this.gap?(this.gap.from=Math.min(h(this.gap.from,c,e),a.from.line),this.gap.to=Math.max(h(this.gap.to,c,e),a.from.line)):this.gap={from:a.from.line,to:b+1};if(e)for(a=0;a= this.gap.to) break; + if (match.to.line >= this.gap.from) this.matches.splice(i--, 1); + } + var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), {caseFold: this.caseFold, multiline: this.options.multiline}); + var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES; + while (cursor.findNext()) { + var match = {from: cursor.from(), to: cursor.to()}; + if (match.from.line >= this.gap.to) break; + this.matches.splice(i++, 0, match); + if (this.matches.length > maxMatches) break; + } + this.gap = null; + }; + + function offsetLine(line, changeStart, sizeChange) { + if (line <= changeStart) return line; + return Math.max(changeStart, line + sizeChange); + } + + SearchAnnotation.prototype.onChange = function(change) { + var startLine = change.from.line; + var endLine = CodeMirror.changeEnd(change).line; + var sizeChange = endLine - change.to.line; + if (this.gap) { + this.gap.from = Math.min(offsetLine(this.gap.from, startLine, sizeChange), change.from.line); + this.gap.to = Math.max(offsetLine(this.gap.to, startLine, sizeChange), change.from.line); + } else { + this.gap = {from: change.from.line, to: endLine + 1}; + } + + if (sizeChange) for (var i = 0; i < this.matches.length; i++) { + var match = this.matches[i]; + var newFrom = offsetLine(match.from.line, startLine, sizeChange); + if (newFrom != match.from.line) match.from = CodeMirror.Pos(newFrom, match.from.ch); + var newTo = offsetLine(match.to.line, startLine, sizeChange); + if (newTo != match.to.line) match.to = CodeMirror.Pos(newTo, match.to.ch); + } + clearTimeout(this.update); + var self = this; + this.update = setTimeout(function() { self.updateAfterChange(); }, 250); + }; + + SearchAnnotation.prototype.updateAfterChange = function() { + this.findMatches(); + this.annotation.update(this.matches); + }; + + SearchAnnotation.prototype.clear = function() { + this.cm.off("change", this.changeHandler); + this.annotation.clear(); + }; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/search.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/search.js index 97f7bee..118f111 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/search.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/search.js @@ -1,14 +1,264 @@ -'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(b,d,g){b instanceof String&&(b=String(b));for(var k=b.length,h=0;hc.line&&document.querySelector&&(e=a.display.wrapper.querySelector(".CodeMirror-dialog"))&&e.getBoundingClientRect().bottom-4>a.cursorCoords(c,"window").top&&((t=e).style.opacity=.4)}))};z(a,w(a),d,h,function(c,e){var f=b.keyName(c),d=a.getOption("extraKeys");f=d&&d[f]||b.keyMap[a.getOption("keyMap")][f];if("findNext"==f||"findPrev"==f||"findPersistentNext"==f||"findPersistentPrev"==f)b.e_stop(c),p(a,k(a),e),a.execCommand(f); -else if("find"==f||"findPersistent"==f)b.e_stop(c),h(e,c)});f&&d&&(p(a,e,d),q(a,c))}else r(a,w(a),"Search for:",d,function(b){b&&!e.query&&a.operation(function(){p(a,e,b);e.posFrom=e.posTo=a.getCursor();q(a,c)})})}function q(a,c,d){a.operation(function(){var f=k(a),e=l(a,f.query,c?f.posFrom:f.posTo);if(!e.find(c)&&(e=l(a,f.query,c?b.Pos(a.lastLine()):b.Pos(a.firstLine(),0)),!e.find(c)))return;a.setSelection(e.from(),e.to());a.scrollIntoView({from:e.from(),to:e.to()},20);f.posFrom=e.from();f.posTo= -e.to();d&&d(e.from(),e.to())})}function n(a){a.operation(function(){var b=k(a);if(b.lastQuery=b.query)b.query=b.queryText=null,a.removeOverlay(b.overlay),b.annotate&&(b.annotate.clear(),b.annotate=null)})}function w(a){return''+a.phrase("Search:")+' '+a.phrase("(Use /re/ syntax for regexp search)")+""}function B(a){return''+ -a.phrase("Replace?")+" "}function x(a,b,d){a.operation(function(){for(var c=l(a,b);c.findNext();)if("string"!=typeof b){var e=a.getRange(c.from(),c.to()).match(b);c.replace(d.replace(/\$(\d)/g,function(a,b){return e[b]}))}else c.replace(d)})}function y(a,b){if(!a.getOption("readOnly")){var c=a.getSelection()||k(a).lastQuery,d=''+ -(b?a.phrase("Replace all:"):a.phrase("Replace:"))+"";r(a,d+(' '+a.phrase("(Use /re/ syntax for regexp search)")+""),d,c,function(c){c&&(c=v(c),r(a,''+a.phrase("With:")+' ',a.phrase("Replace with:"),"",function(e){e=u(e);if(b)x(a,c,e);else{n(a); -var d=l(a,c,a.getCursor("from")),f=function(){var b=d.from(),h;if(!(h=d.findNext())&&(d=l(a,c),!(h=d.findNext())||b&&d.from().line==b.line&&d.from().ch==b.ch))return;a.setSelection(d.from(),d.to());a.scrollIntoView({from:d.from(),to:d.to()});A(a,B(a),a.phrase("Replace?"),[function(){g(h)},f,function(){x(a,c,e)}])},g=function(a){d.replace("string"==typeof c?e:e.replace(/\$(\d)/g,function(b,c){return a[c]}));f()};f()}}))})}}b.commands.find=function(a){n(a);m(a)};b.commands.findPersistent=function(a){n(a); -m(a,!1,!0)};b.commands.findPersistentNext=function(a){m(a,!1,!0,!0)};b.commands.findPersistentPrev=function(a){m(a,!0,!0,!0)};b.commands.findNext=m;b.commands.findPrev=function(a){m(a,!0)};b.commands.clearSearch=n;b.commands.replace=y;b.commands.replaceAll=function(a){y(a,!0)}}); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Define search commands. Depends on dialog.js or another +// implementation of the openDialog method. + +// Replace works a little oddly -- it will do the replace on the next +// Ctrl-G (or whatever is bound to findNext) press. You prevent a +// replace by making sure the match is no longer selected when hitting +// Ctrl-G. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + // default search panel location + CodeMirror.defineOption("search", {bottom: false}); + + function searchOverlay(query, caseInsensitive) { + if (typeof query == "string") + query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g"); + else if (!query.global) + query = new RegExp(query.source, query.ignoreCase ? "gi" : "g"); + + return {token: function(stream) { + query.lastIndex = stream.pos; + var match = query.exec(stream.string); + if (match && match.index == stream.pos) { + stream.pos += match[0].length || 1; + return "searching"; + } else if (match) { + stream.pos = match.index; + } else { + stream.skipToEnd(); + } + }}; + } + + function SearchState() { + this.posFrom = this.posTo = this.lastQuery = this.query = null; + this.overlay = null; + } + + function getSearchState(cm) { + return cm.state.search || (cm.state.search = new SearchState()); + } + + function queryCaseInsensitive(query) { + return typeof query == "string" && query == query.toLowerCase(); + } + + function getSearchCursor(cm, query, pos) { + // Heuristic: if the query string is all lowercase, do a case insensitive search. + return cm.getSearchCursor(query, pos, {caseFold: queryCaseInsensitive(query), multiline: true}); + } + + function persistentDialog(cm, text, deflt, onEnter, onKeyDown) { + cm.openDialog(text, onEnter, { + value: deflt, + selectValueOnOpen: true, + closeOnEnter: false, + onClose: function() { clearSearch(cm); }, + onKeyDown: onKeyDown, + bottom: cm.options.search.bottom + }); + } + + function dialog(cm, text, shortText, deflt, f) { + if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true, bottom: cm.options.search.bottom}); + else f(prompt(shortText, deflt)); + } + + function confirmDialog(cm, text, shortText, fs) { + if (cm.openConfirm) cm.openConfirm(text, fs); + else if (confirm(shortText)) fs[0](); + } + + function parseString(string) { + return string.replace(/\\([nrt\\])/g, function(match, ch) { + if (ch == "n") return "\n" + if (ch == "r") return "\r" + if (ch == "t") return "\t" + if (ch == "\\") return "\\" + return match + }) + } + + function parseQuery(query) { + var isRE = query.match(/^\/(.*)\/([a-z]*)$/); + if (isRE) { + try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); } + catch(e) {} // Not a regular expression after all, do a string search + } else { + query = parseString(query) + } + if (typeof query == "string" ? query == "" : query.test("")) + query = /x^/; + return query; + } + + function startSearch(cm, state, query) { + state.queryText = query; + state.query = parseQuery(query); + cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); + state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); + cm.addOverlay(state.overlay); + if (cm.showMatchesOnScrollbar) { + if (state.annotate) { state.annotate.clear(); state.annotate = null; } + state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); + } + } + + function doSearch(cm, rev, persistent, immediate) { + var state = getSearchState(cm); + if (state.query) return findNext(cm, rev); + var q = cm.getSelection() || state.lastQuery; + if (q instanceof RegExp && q.source == "x^") q = null + if (persistent && cm.openDialog) { + var hiding = null + var searchNext = function(query, event) { + CodeMirror.e_stop(event); + if (!query) return; + if (query != state.queryText) { + startSearch(cm, state, query); + state.posFrom = state.posTo = cm.getCursor(); + } + if (hiding) hiding.style.opacity = 1 + findNext(cm, event.shiftKey, function(_, to) { + var dialog + if (to.line < 3 && document.querySelector && + (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) && + dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top) + (hiding = dialog).style.opacity = .4 + }) + }; + persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) { + var keyName = CodeMirror.keyName(event) + var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName] + if (cmd == "findNext" || cmd == "findPrev" || + cmd == "findPersistentNext" || cmd == "findPersistentPrev") { + CodeMirror.e_stop(event); + startSearch(cm, getSearchState(cm), query); + cm.execCommand(cmd); + } else if (cmd == "find" || cmd == "findPersistent") { + CodeMirror.e_stop(event); + searchNext(query, event); + } + }); + if (immediate && q) { + startSearch(cm, state, q); + findNext(cm, rev); + } + } else { + dialog(cm, getQueryDialog(cm), "Search for:", q, function(query) { + if (query && !state.query) cm.operation(function() { + startSearch(cm, state, query); + state.posFrom = state.posTo = cm.getCursor(); + findNext(cm, rev); + }); + }); + } + } + + function findNext(cm, rev, callback) {cm.operation(function() { + var state = getSearchState(cm); + var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo); + if (!cursor.find(rev)) { + cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0)); + if (!cursor.find(rev)) return; + } + cm.setSelection(cursor.from(), cursor.to()); + cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20); + state.posFrom = cursor.from(); state.posTo = cursor.to(); + if (callback) callback(cursor.from(), cursor.to()) + });} + + function clearSearch(cm) {cm.operation(function() { + var state = getSearchState(cm); + state.lastQuery = state.query; + if (!state.query) return; + state.query = state.queryText = null; + cm.removeOverlay(state.overlay); + if (state.annotate) { state.annotate.clear(); state.annotate = null; } + });} + + + function getQueryDialog(cm) { + return '' + cm.phrase("Search:") + ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + ''; + } + function getReplaceQueryDialog(cm) { + return ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + ''; + } + function getReplacementQueryDialog(cm) { + return '' + cm.phrase("With:") + ' '; + } + function getDoReplaceConfirm(cm) { + return '' + cm.phrase("Replace?") + ' '; + } + + function replaceAll(cm, query, text) { + cm.operation(function() { + for (var cursor = getSearchCursor(cm, query); cursor.findNext();) { + if (typeof query != "string") { + var match = cm.getRange(cursor.from(), cursor.to()).match(query); + cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];})); + } else cursor.replace(text); + } + }); + } + + function replace(cm, all) { + if (cm.getOption("readOnly")) return; + var query = cm.getSelection() || getSearchState(cm).lastQuery; + var dialogText = '' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + ''; + dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) { + if (!query) return; + query = parseQuery(query); + dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) { + text = parseString(text) + if (all) { + replaceAll(cm, query, text) + } else { + clearSearch(cm); + var cursor = getSearchCursor(cm, query, cm.getCursor("from")); + var advance = function() { + var start = cursor.from(), match; + if (!(match = cursor.findNext())) { + cursor = getSearchCursor(cm, query); + if (!(match = cursor.findNext()) || + (start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return; + } + cm.setSelection(cursor.from(), cursor.to()); + cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); + confirmDialog(cm, getDoReplaceConfirm(cm), cm.phrase("Replace?"), + [function() {doReplace(match);}, advance, + function() {replaceAll(cm, query, text)}]); + }; + var doReplace = function(match) { + cursor.replace(typeof query == "string" ? text : + text.replace(/\$(\d)/g, function(_, i) {return match[i];})); + advance(); + }; + advance(); + } + }); + }); + } + + CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);}; + CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);}; + CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);}; + CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);}; + CodeMirror.commands.findNext = doSearch; + CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);}; + CodeMirror.commands.clearSearch = clearSearch; + CodeMirror.commands.replace = replace; + CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);}; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/searchcursor.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/searchcursor.js index 80fcdf1..d586957 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/searchcursor.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/search/searchcursor.js @@ -1,14 +1,296 @@ -'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(c,g,h){c instanceof String&&(c=String(c));for(var l=c.length,p=0;pm);q++){var x=b.getLine(c++);f=null==f?x:f+"\n"+x}e*=2;a.lastIndex=d.ch;if(q=a.exec(f))return a=f.slice(0,q.index).split("\n"),b=q[0].split("\n"),d=d.line+a.length-1,a=a[a.length-1].length,{from:k(d,a),to:k(d+b.length-1,1==b.length?a+b[0].length:b[b.length- -1].length),match:q}}}function p(b,a,d){for(var f,e=0;e<=b.length;){a.lastIndex=e;e=a.exec(b);if(!e)break;var c=e.index+e[0].length;if(c>b.length-d)break;if(!f||c>f.index+f[0].length)f=e;e=e.index+1}return f}function t(b,a,d){a=g(a,"g");var f=d.line,e=d.ch;for(d=b.firstLine();f>=d;f--,e=-1){var c=b.getLine(f);if(e=p(c,a,0>e?0:c.length-e))return{from:k(f,e.index),to:k(f,e.index+e[0].length),match:e}}}function y(b,a,d){if(!/\\s|\\n|\n|\\W|\\D|\[\^/.test(a.source))return t(b,a,d);a=g(a,"gm");var f=1, -e=b.getLine(d.line).length-d.ch;d=d.line;for(var c=b.firstLine();d>=c;){for(var m=0;m=c;m++){var q=b.getLine(d--);var h=null==h?q:q+"\n"+h}f*=2;if(m=p(h,a,e))return a=h.slice(0,m.index).split("\n"),b=m[0].split("\n"),d+=a.length,a=a[a.length-1].length,{from:k(d,a),to:k(d+b.length-1,1==b.length?a+b[0].length:b[b.length-1].length),match:m}}}function r(b,a,d,f){if(b.length==a.length)return d;var e=0;for(a=d+Math.max(0,b.length-a.length);;){if(e==a)return e;var c=e+a>>1,m=f(b.slice(0,c)).length; -if(m==d)return c;m>d?a=c:e=c+1}}function z(b,a,d,f){if(!a.length)return null;f=f?u:v;a=f(a).split(/\r|\n\r?/);var e=d.line;d=d.ch;var c=b.lastLine()+1-a.length;a:for(;e<=c;e++,d=0){var m=b.getLine(e).slice(d),h=f(m);if(1==a.length){var g=h.indexOf(a[0]);if(-1==g)continue a;r(m,h,g,f);return{from:k(e,r(m,h,g,f)+d),to:k(e,r(m,h,g+a[0].length,f)+d)}}g=h.length-a[0].length;if(h.slice(g)!=a[0])continue a;for(var n=1;n=h;e--,c=-1){var g=b.getLine(e);-1 last) break + var curLine = doc.getLine(line++) + string = string == null ? curLine : string + "\n" + curLine + } + chunk = chunk * 2 + regexp.lastIndex = start.ch + var match = regexp.exec(string) + if (match) { + var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n") + var startLine = start.line + before.length - 1, startCh = before[before.length - 1].length + return {from: Pos(startLine, startCh), + to: Pos(startLine + inside.length - 1, + inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length), + match: match} + } + } + } + + function lastMatchIn(string, regexp, endMargin) { + var match, from = 0 + while (from <= string.length) { + regexp.lastIndex = from + var newMatch = regexp.exec(string) + if (!newMatch) break + var end = newMatch.index + newMatch[0].length + if (end > string.length - endMargin) break + if (!match || end > match.index + match[0].length) + match = newMatch + from = newMatch.index + 1 + } + return match + } + + function searchRegexpBackward(doc, regexp, start) { + regexp = ensureFlags(regexp, "g") + for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) { + var string = doc.getLine(line) + var match = lastMatchIn(string, regexp, ch < 0 ? 0 : string.length - ch) + if (match) + return {from: Pos(line, match.index), + to: Pos(line, match.index + match[0].length), + match: match} + } + } + + function searchRegexpBackwardMultiline(doc, regexp, start) { + if (!maybeMultiline(regexp)) return searchRegexpBackward(doc, regexp, start) + regexp = ensureFlags(regexp, "gm") + var string, chunkSize = 1, endMargin = doc.getLine(start.line).length - start.ch + for (var line = start.line, first = doc.firstLine(); line >= first;) { + for (var i = 0; i < chunkSize && line >= first; i++) { + var curLine = doc.getLine(line--) + string = string == null ? curLine : curLine + "\n" + string + } + chunkSize *= 2 + + var match = lastMatchIn(string, regexp, endMargin) + if (match) { + var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n") + var startLine = line + before.length, startCh = before[before.length - 1].length + return {from: Pos(startLine, startCh), + to: Pos(startLine + inside.length - 1, + inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length), + match: match} + } + } + } + + var doFold, noFold + if (String.prototype.normalize) { + doFold = function(str) { return str.normalize("NFD").toLowerCase() } + noFold = function(str) { return str.normalize("NFD") } + } else { + doFold = function(str) { return str.toLowerCase() } + noFold = function(str) { return str } + } + + // Maps a position in a case-folded line back to a position in the original line + // (compensating for codepoints increasing in number during folding) + function adjustPos(orig, folded, pos, foldFunc) { + if (orig.length == folded.length) return pos + for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) { + if (min == max) return min + var mid = (min + max) >> 1 + var len = foldFunc(orig.slice(0, mid)).length + if (len == pos) return mid + else if (len > pos) max = mid + else min = mid + 1 + } + } + + function searchStringForward(doc, query, start, caseFold) { + // Empty string would match anything and never progress, so we + // define it to match nothing instead. + if (!query.length) return null + var fold = caseFold ? doFold : noFold + var lines = fold(query).split(/\r|\n\r?/) + + search: for (var line = start.line, ch = start.ch, last = doc.lastLine() + 1 - lines.length; line <= last; line++, ch = 0) { + var orig = doc.getLine(line).slice(ch), string = fold(orig) + if (lines.length == 1) { + var found = string.indexOf(lines[0]) + if (found == -1) continue search + var start = adjustPos(orig, string, found, fold) + ch + return {from: Pos(line, adjustPos(orig, string, found, fold) + ch), + to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold) + ch)} + } else { + var cutFrom = string.length - lines[0].length + if (string.slice(cutFrom) != lines[0]) continue search + for (var i = 1; i < lines.length - 1; i++) + if (fold(doc.getLine(line + i)) != lines[i]) continue search + var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1] + if (endString.slice(0, lastLine.length) != lastLine) continue search + return {from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch), + to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))} + } + } + } + + function searchStringBackward(doc, query, start, caseFold) { + if (!query.length) return null + var fold = caseFold ? doFold : noFold + var lines = fold(query).split(/\r|\n\r?/) + + search: for (var line = start.line, ch = start.ch, first = doc.firstLine() - 1 + lines.length; line >= first; line--, ch = -1) { + var orig = doc.getLine(line) + if (ch > -1) orig = orig.slice(0, ch) + var string = fold(orig) + if (lines.length == 1) { + var found = string.lastIndexOf(lines[0]) + if (found == -1) continue search + return {from: Pos(line, adjustPos(orig, string, found, fold)), + to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold))} + } else { + var lastLine = lines[lines.length - 1] + if (string.slice(0, lastLine.length) != lastLine) continue search + for (var i = 1, start = line - lines.length + 1; i < lines.length - 1; i++) + if (fold(doc.getLine(start + i)) != lines[i]) continue search + var top = doc.getLine(line + 1 - lines.length), topString = fold(top) + if (topString.slice(topString.length - lines[0].length) != lines[0]) continue search + return {from: Pos(line + 1 - lines.length, adjustPos(top, topString, top.length - lines[0].length, fold)), + to: Pos(line, adjustPos(orig, string, lastLine.length, fold))} + } + } + } + + function SearchCursor(doc, query, pos, options) { + this.atOccurrence = false + this.doc = doc + pos = pos ? doc.clipPos(pos) : Pos(0, 0) + this.pos = {from: pos, to: pos} + + var caseFold + if (typeof options == "object") { + caseFold = options.caseFold + } else { // Backwards compat for when caseFold was the 4th argument + caseFold = options + options = null + } + + if (typeof query == "string") { + if (caseFold == null) caseFold = false + this.matches = function(reverse, pos) { + return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos, caseFold) + } + } else { + query = ensureFlags(query, "gm") + if (!options || options.multiline !== false) + this.matches = function(reverse, pos) { + return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos) + } + else + this.matches = function(reverse, pos) { + return (reverse ? searchRegexpBackward : searchRegexpForward)(doc, query, pos) + } + } + } + + SearchCursor.prototype = { + findNext: function() {return this.find(false)}, + findPrevious: function() {return this.find(true)}, + + find: function(reverse) { + var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to)) + + // Implements weird auto-growing behavior on null-matches for + // backwards-compatibility with the vim code (unfortunately) + while (result && CodeMirror.cmpPos(result.from, result.to) == 0) { + if (reverse) { + if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1) + else if (result.from.line == this.doc.firstLine()) result = null + else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1))) + } else { + if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1) + else if (result.to.line == this.doc.lastLine()) result = null + else result = this.matches(reverse, Pos(result.to.line + 1, 0)) + } + } + + if (result) { + this.pos = result + this.atOccurrence = true + return this.pos.match || true + } else { + var end = Pos(reverse ? this.doc.firstLine() : this.doc.lastLine() + 1, 0) + this.pos = {from: end, to: end} + return this.atOccurrence = false + } + }, + + from: function() {if (this.atOccurrence) return this.pos.from}, + to: function() {if (this.atOccurrence) return this.pos.to}, + + replace: function(newText, origin) { + if (!this.atOccurrence) return + var lines = CodeMirror.splitLines(newText) + this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin) + this.pos.to = Pos(this.pos.from.line + lines.length - 1, + lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0)) + } + } + + CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) { + return new SearchCursor(this.doc, query, pos, caseFold) + }) + CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) { + return new SearchCursor(this, query, pos, caseFold) + }) + + CodeMirror.defineExtension("selectMatches", function(query, caseFold) { + var ranges = [] + var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold) + while (cur.findNext()) { + if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break + ranges.push({anchor: cur.from(), head: cur.to()}) + } + if (ranges.length) + this.setSelections(ranges, 0) + }) +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/selection/active-line.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/selection/active-line.js index b4d15e7..c7b14ce 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/selection/active-line.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/selection/active-line.js @@ -1,3 +1,72 @@ -'use strict';(function(d){"object"==typeof exports&&"object"==typeof module?d(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],d):d(CodeMirror)})(function(d){function g(a){for(var b=0;b=g.line,h=q?g:r(e,0);f=b.markText(f,h,{className:d});null==c?p.push(f):p.splice(c++,0,f);if(q)break}}function f(b){b=b.state.markedSelection;for(var a=0;a=m(c,k.from))return h(a);for(;0m(b,k.from)&&(k.to.line-b.linem(c,l.to);)d.pop().clear(),l=d[d.length-1].find();0= to.line; + var end = atEnd ? to : Pos(endLine, 0); + var mark = cm.markText(start, end, {className: cls}); + if (addAt == null) array.push(mark); + else array.splice(addAt++, 0, mark); + if (atEnd) break; + line = endLine; + } + } + + function clear(cm) { + var array = cm.state.markedSelection; + for (var i = 0; i < array.length; ++i) array[i].clear(); + array.length = 0; + } + + function reset(cm) { + clear(cm); + var ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) + coverRange(cm, ranges[i].from(), ranges[i].to()); + } + + function update(cm) { + if (!cm.somethingSelected()) return clear(cm); + if (cm.listSelections().length > 1) return reset(cm); + + var from = cm.getCursor("start"), to = cm.getCursor("end"); + + var array = cm.state.markedSelection; + if (!array.length) return coverRange(cm, from, to); + + var coverStart = array[0].find(), coverEnd = array[array.length - 1].find(); + if (!coverStart || !coverEnd || to.line - from.line <= CHUNK_SIZE || + cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0) + return reset(cm); + + while (cmp(from, coverStart.from) > 0) { + array.shift().clear(); + coverStart = array[0].find(); + } + if (cmp(from, coverStart.from) < 0) { + if (coverStart.to.line - from.line < CHUNK_SIZE) { + array.shift().clear(); + coverRange(cm, from, coverStart.to, 0); + } else { + coverRange(cm, from, coverStart.from, 0); + } + } + + while (cmp(to, coverEnd.to) < 0) { + array.pop().clear(); + coverEnd = array[array.length - 1].find(); + } + if (cmp(to, coverEnd.to) > 0) { + if (to.line - coverEnd.from.line < CHUNK_SIZE) { + array.pop().clear(); + coverRange(cm, coverEnd.from, to); + } else { + coverRange(cm, coverEnd.to, to); + } + } + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/selection/selection-pointer.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/selection/selection-pointer.js index 94f3084..f0bd61a 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/selection/selection-pointer.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/selection/selection-pointer.js @@ -1,4 +1,98 @@ -'use strict';(function(c){"object"==typeof exports&&"object"==typeof module?c(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){function e(b){b.state.selectionPointer.rects=null;f(b)}function f(b){b.state.selectionPointer.willUpdate||(b.state.selectionPointer.willUpdate=!0,setTimeout(function(){var a=b.state.selectionPointer;if(a){if(null==a.rects&&null!=a.mouseX&&(a.rects=[],b.somethingSelected()))for(var d=b.display.selectionDiv.firstChild;d;d= -d.nextSibling)a.rects.push(d.getBoundingClientRect());d=!1;if(null!=a.mouseX)for(var g=0;g=a.mouseX&&c.top<=a.mouseY&&c.bottom>=a.mouseY&&(d=!0)}a=d?a.value:"";b.display.lineDiv.style.cursor!=a&&(b.display.lineDiv.style.cursor=a)}b.state.selectionPointer.willUpdate=!1},50))}c.defineOption("selectionPointer",!1,function(b,a){var d=b.state.selectionPointer;d&&(c.off(b.getWrapperElement(),"mousemove",d.mousemove),c.off(b.getWrapperElement(), -"mouseout",d.mouseout),c.off(window,"scroll",d.windowScroll),b.off("cursorActivity",e),b.off("scroll",e),b.state.selectionPointer=null,b.display.lineDiv.style.cursor="");a&&(d=b.state.selectionPointer={value:"string"==typeof a?a:"default",mousemove:function(a){var c=b.state.selectionPointer;(null==a.buttons?a.which:a.buttons)?c.mouseX=c.mouseY=null:(c.mouseX=a.clientX,c.mouseY=a.clientY);f(b)},mouseout:function(a){b.getWrapperElement().contains(a.relatedTarget)||(a=b.state.selectionPointer,a.mouseX= -a.mouseY=null,f(b))},windowScroll:function(){e(b)},rects:null,mouseX:null,mouseY:null,willUpdate:!1},c.on(b.getWrapperElement(),"mousemove",d.mousemove),c.on(b.getWrapperElement(),"mouseout",d.mouseout),c.on(window,"scroll",d.windowScroll),b.on("cursorActivity",e),b.on("scroll",e))})}); +// 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"; + + CodeMirror.defineOption("selectionPointer", false, function(cm, val) { + var data = cm.state.selectionPointer; + if (data) { + CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove); + CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout); + CodeMirror.off(window, "scroll", data.windowScroll); + cm.off("cursorActivity", reset); + cm.off("scroll", reset); + cm.state.selectionPointer = null; + cm.display.lineDiv.style.cursor = ""; + } + if (val) { + data = cm.state.selectionPointer = { + value: typeof val == "string" ? val : "default", + mousemove: function(event) { mousemove(cm, event); }, + mouseout: function(event) { mouseout(cm, event); }, + windowScroll: function() { reset(cm); }, + rects: null, + mouseX: null, mouseY: null, + willUpdate: false + }; + CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove); + CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout); + CodeMirror.on(window, "scroll", data.windowScroll); + cm.on("cursorActivity", reset); + cm.on("scroll", reset); + } + }); + + function mousemove(cm, event) { + var data = cm.state.selectionPointer; + if (event.buttons == null ? event.which : event.buttons) { + data.mouseX = data.mouseY = null; + } else { + data.mouseX = event.clientX; + data.mouseY = event.clientY; + } + scheduleUpdate(cm); + } + + function mouseout(cm, event) { + if (!cm.getWrapperElement().contains(event.relatedTarget)) { + var data = cm.state.selectionPointer; + data.mouseX = data.mouseY = null; + scheduleUpdate(cm); + } + } + + function reset(cm) { + cm.state.selectionPointer.rects = null; + scheduleUpdate(cm); + } + + function scheduleUpdate(cm) { + if (!cm.state.selectionPointer.willUpdate) { + cm.state.selectionPointer.willUpdate = true; + setTimeout(function() { + update(cm); + cm.state.selectionPointer.willUpdate = false; + }, 50); + } + } + + function update(cm) { + var data = cm.state.selectionPointer; + if (!data) return; + if (data.rects == null && data.mouseX != null) { + data.rects = []; + if (cm.somethingSelected()) { + for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling) + data.rects.push(sel.getBoundingClientRect()); + } + } + var inside = false; + if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) { + var rect = data.rects[i]; + if (rect.left <= data.mouseX && rect.right >= data.mouseX && + rect.top <= data.mouseY && rect.bottom >= data.mouseY) + inside = true; + } + var cursor = inside ? data.value : ""; + if (cm.display.lineDiv.style.cursor != cursor) + cm.display.lineDiv.style.cursor = cursor; + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/show-invisibles.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/show-invisibles.js index c0dfab3..a0b17f2 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/show-invisibles.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/show-invisibles.js @@ -5,10 +5,10 @@ ((mod) => { if (typeof exports === 'object' && typeof module === 'object') // CommonJS - return mod(require('codemirror/lib/codemirror')); + return mod(require('../lib/codemirror')); if (typeof define === 'function' && define.amd) // AMD - return define(['codemirror/lib/codemirror'], mod); + return define(['../lib/codemirror'], mod); mod(CodeMirror); })((CodeMirror) => { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/tern.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/tern.css index c377ab1..c4b8a2f 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/tern.css +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/tern.css @@ -1 +1,87 @@ -.CodeMirror-Tern-completion{padding-left:22px;position:relative;line-height:1.5}.CodeMirror-Tern-completion:before{position:absolute;left:2px;bottom:2px;border-radius:50%;font-size:12px;font-weight:700;height:15px;width:15px;line-height:16px;text-align:center;color:#fff;-moz-box-sizing:border-box;box-sizing:border-box}.CodeMirror-Tern-completion-unknown:before{content:"?";background:#4bb}.CodeMirror-Tern-completion-object:before{content:"O";background:#77c}.CodeMirror-Tern-completion-fn:before{content:"F";background:#7c7}.CodeMirror-Tern-completion-array:before{content:"A";background:#c66}.CodeMirror-Tern-completion-number:before{content:"1";background:#999}.CodeMirror-Tern-completion-string:before{content:"S";background:#999}.CodeMirror-Tern-completion-bool:before{content:"B";background:#999}.CodeMirror-Tern-completion-guess{color:#999}.CodeMirror-Tern-tooltip{border:1px solid silver;border-radius:3px;color:#444;padding:2px 5px;font-size:90%;font-family:monospace;background-color:#fff;white-space:pre-wrap;max-width:40em;position:absolute;z-index:10;-webkit-box-shadow:2px 3px 5px rgba(0,0,0,.2);-moz-box-shadow:2px 3px 5px rgba(0,0,0,.2);box-shadow:2px 3px 5px rgba(0,0,0,.2);transition:opacity 1s;-moz-transition:opacity 1s;-webkit-transition:opacity 1s;-o-transition:opacity 1s;-ms-transition:opacity 1s}.CodeMirror-Tern-hint-doc{max-width:25em;margin-top:-3px}.CodeMirror-Tern-fname{color:#000}.CodeMirror-Tern-farg{color:#70a}.CodeMirror-Tern-farg-current{text-decoration:underline}.CodeMirror-Tern-type{color:#07c}.CodeMirror-Tern-fhint-guess{opacity:.7} \ No newline at end of file +.CodeMirror-Tern-completion { + padding-left: 22px; + position: relative; + line-height: 1.5; +} +.CodeMirror-Tern-completion:before { + position: absolute; + left: 2px; + bottom: 2px; + border-radius: 50%; + font-size: 12px; + font-weight: bold; + height: 15px; + width: 15px; + line-height: 16px; + text-align: center; + color: white; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.CodeMirror-Tern-completion-unknown:before { + content: "?"; + background: #4bb; +} +.CodeMirror-Tern-completion-object:before { + content: "O"; + background: #77c; +} +.CodeMirror-Tern-completion-fn:before { + content: "F"; + background: #7c7; +} +.CodeMirror-Tern-completion-array:before { + content: "A"; + background: #c66; +} +.CodeMirror-Tern-completion-number:before { + content: "1"; + background: #999; +} +.CodeMirror-Tern-completion-string:before { + content: "S"; + background: #999; +} +.CodeMirror-Tern-completion-bool:before { + content: "B"; + background: #999; +} + +.CodeMirror-Tern-completion-guess { + color: #999; +} + +.CodeMirror-Tern-tooltip { + border: 1px solid silver; + border-radius: 3px; + color: #444; + padding: 2px 5px; + font-size: 90%; + font-family: monospace; + background-color: white; + white-space: pre-wrap; + + max-width: 40em; + position: absolute; + z-index: 10; + -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + box-shadow: 2px 3px 5px rgba(0,0,0,.2); + + transition: opacity 1s; + -moz-transition: opacity 1s; + -webkit-transition: opacity 1s; + -o-transition: opacity 1s; + -ms-transition: opacity 1s; +} + +.CodeMirror-Tern-hint-doc { + max-width: 25em; + margin-top: -3px; +} + +.CodeMirror-Tern-fname { color: black; } +.CodeMirror-Tern-farg { color: #70a; } +.CodeMirror-Tern-farg-current { text-decoration: underline; } +.CodeMirror-Tern-type { color: #07c; } +.CodeMirror-Tern-fhint-guess { opacity: .7; } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/tern.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/tern.js index cb8462f..7be3681 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/tern.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/tern.js @@ -1,23 +1,719 @@ -'use strict';(function(h){"object"==typeof exports&&"object"==typeof module?h(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],h):h(CodeMirror)})(function(h){function C(a,c,b){var d=a.docs[c];d?b(z(a,d)):a.options.getFile?a.options.getFile(c,b):b(null)}function w(a,c,b){for(var d in a.docs){var e=a.docs[d];if(e.doc==c)return e}if(!b)for(b=0;;++b)if(d="[doc"+(b||"")+"]",!a.docs[d]){b=d;break}return a.addDoc(b,c)}function D(a,c){if("string"==typeof c)return a.docs[c]; -c instanceof h&&(c=c.getDoc());if(c instanceof h.Doc)return w(a,c)}function N(a,c,b){var d=w(a,c),e=a.cachedArgHints;e&&e.doc==c&&0<=A(e.start,b.to)&&(a.cachedArgHints=null);e=d.changed;null==e&&(d.changed=e={from:b.from.line,to:b.from.line});var f=b.from.line+(b.text.length-1);b.from.line=e.to&&(e.to=f+1);e.from>b.from.line&&(e.from=b.from.line);c.lineCount()>E&&100=p;--g){for(var l=c.getLine(g),u=d=0;;){u=l.indexOf("\t",u);if(-1==u)break;d+=f-(u+d)%f-1;u+=1}d=b.column-d;if("("==l.charAt(d)){k=!0;break}}if(k){var m=r(g,d);if((b=a.cachedArgHints)&&b.doc==c.getDoc()&&0==A(m,b.start))return I(a,c,e);a.request(c,{type:"type",preferFunction:!0,end:m},function(b,d){!b&&d.type&&/^fn\(/.test(d.type)&& -(a.cachedArgHints={start:m,type:R(d.type),name:d.exprName||d.name||"fn",guess:d.guess,doc:c.getDoc()},I(a,c,e))})}}}}function I(a,c,b){y(a);var d=a.cachedArgHints,e=d.type;d=t("span",d.guess?n+"fhint-guess":null,t("span",n+"fname",d.name),"(");for(var f=0;f\u00a0":")"));e.rettype&&d.appendChild(t("span",n+"type",e.rettype));b=c.cursorCoords(null,"page");var p=a.activeArgHints=B(b.right+1,b.bottom,d,c);setTimeout(function(){p.clear=J(c,function(){a.activeArgHints==p&&y(a)})},20)}function R(a){function c(c){for(var b=0,e=d;;){var f=a.charAt(d);if(c.test(f)&&!b)return a.slice(e,d);/[{\[\(]/.test(f)?++b:/[}\]\)]/.test(f)&&--b;++d}}var b=[],d=3;if(")"!=a.charAt(d))for(;;){var e=a.slice(d).match(/^([^, \(\[\{]+): /); -e&&(d+=e[0].length,e=e[1]);b.push({name:e,type:c(/[\),]/)});if(")"==a.charAt(d))break;d+=2}e=a.slice(d).match(/^\) -> (.*)$/);return{args:b,rettype:e&&e[1]}}function S(a,c){function b(b){b={type:"definition",variable:b||null};var d=w(a,c.getDoc());a.server.request(K(a,d,b),function(b,e){if(b)return v(a,c,b);if(!e.file&&e.url)window.open(e.url);else{if(e.file){b=a.docs[e.file];var f;if(f=b){var g=b.doc;var l=e.context.slice(0,e.contextOffset).split("\n");var h=e.start.line-(l.length-1);f=r(h,(1==l.length? -e.start.ch:g.getLine(h).length)-l[0].length);var m=g.getLine(h).slice(f.ch);for(h+=1;h=A(g,k.end)&&(f=d.length-1))}c.setSelections(d,f)})}function V(a,c){for(var b=Object.create(null),d=0;dE&&!1!==f&&100>c.changed.to-c.changed.from&&c.changed.from<=d.line&&c.changed.to>b.end.line?(e.push(Y(c,d,b.end)),b.file="#0",f=e[0].offsetLines,null!=b.start&&(b.start=r(b.start.line- -f,b.start.ch)),b.end=r(b.end.line-f,b.end.ch)):(e.push({type:"full",name:c.name,text:z(a,c)}),b.file=c.name,c.changed=null):b.file= -c.name;for(var g in a.docs)f=a.docs[g],f.changed&&f!=c&&(e.push({type:"full",name:f.name,text:z(a,f)}),f.changed=null);return{query:b,files:e}}function Y(a,c,b){for(var d=a.doc,e=null,f=null,g=c.line-1,p=Math.max(0,g-50);g>=p;--g){var k=d.getLine(g);0>k.search(/\bfunction\b/)||(k=h.countColumn(k,null,4),null!=e&&e<=k||(e=k,f=g))}null==f&&(f=p);g=Math.min(d.lastLine(),b.line+20);if(null==e||e==h.countColumn(d.getLine(c.line),null,4))c=g;else for(c=b.line+1;c",b):b(prompt(c,""))}function H(a,c,b){function d(){a.state.ternTooltip=null;f.parentNode&&Z(f);k()}a.state.ternTooltip&& -x(a.state.ternTooltip);var e=a.cursorCoords(),f=a.state.ternTooltip=B(e.right+1,e.bottom,c,a),g=!1,p=!1;h.on(f,"mousemove",function(){g=!0});h.on(f,"mouseout",function(a){(a=a.relatedTarget||a.toElement)&&h.contains(f,a)||(p?d():g=!1)});setTimeout(function(){p=!0;g||d()},b.options.hintDelay?b.options.hintDelay:1700);var k=J(a,d)}function J(a,c){a.on("cursorActivity",c);a.on("blur",c);a.on("scroll",c);a.on("setDoc",c);return function(){a.off("cursorActivity",c);a.off("blur",c);a.off("scroll",c);a.off("setDoc", -c)}}function B(a,c,b,d){b=t("div",n+"tooltip",b);b.style.left=a+"px";b.style.top=c+"px";(((d.options||{}).hintOptions||{}).container||document.body).appendChild(b);return b}function x(a){var c=a&&a.parentNode;c&&c.removeChild(a)}function Z(a){a.style.opacity="0";setTimeout(function(){x(a)},1100)}function v(a,c,b){a.options.showError?a.options.showError(c,b):H(c,String(b),a)}function y(a){a.activeArgHints&&(a.activeArgHints.clear&&a.activeArgHints.clear(),x(a.activeArgHints),a.activeArgHints=null)} -function z(a,c){var b=c.doc.getValue();a.options.fileFilter&&(b=a.options.fileFilter(b,c.name,c.doc));return b}function aa(a){function c(a,c){c&&(a.id=++d,e[d]=c);b.postMessage(a)}var b=a.worker=new Worker(a.options.workerScript);b.postMessage({type:"init",defs:a.options.defs,plugins:a.options.plugins,scripts:a.options.workerDeps});var d=0,e={};b.onmessage=function(b){var d=b.data;"getFile"==d.type?C(a,d.name,function(a,b){c({type:"getFile",err:String(a),text:b,id:d.id})}):"debug"==d.type?window.console.log(d.message): -d.id&&e[d.id]&&(e[d.id](d.err,d.body),delete e[d.id])};b.onerror=function(a){for(var b in e)e[b](a);e={}};this.addFile=function(a,b){c({type:"add",name:a,text:b})};this.delFile=function(a){c({type:"del",name:a})};this.request=function(a,b){c({type:"req",body:a},b)}}h.TernServer=function(a){var c=this;this.options=a||{};a=this.options.plugins||(this.options.plugins={});a.doc_comment||(a.doc_comment=!0);this.docs=Object.create(null);this.server=this.options.useWorker?new aa(this):new tern.Server({getFile:function(a, -d){return C(c,a,d)},async:!0,defs:this.options.defs||[],plugins:a});this.trackChange=function(a,d){N(c,a,d)};this.activeArgHints=this.cachedArgHints=null;this.jumpStack=[];this.getHint=function(a,d){return O(c,a,d)};this.getHint.async=!0};h.TernServer.prototype={addDoc:function(a,c){var b={doc:c,name:a,changed:null};this.server.addFile(a,z(this,b));h.on(c,"change",this.trackChange);return this.docs[a]=b},delDoc:function(a){if(a=D(this,a))h.off(a.doc,"change",this.trackChange),delete this.docs[a.name], -this.server.delFile(a.name)},hideDoc:function(a){y(this);(a=D(this,a))&&a.changed&&F(this,a)},complete:function(a){a.showHint({hint:this.getHint})},showType:function(a,c,b){G(this,a,c,"type",b)},showDocs:function(a,c,b){G(this,a,c,"documentation",b)},updateArgHints:function(a){Q(this,a)},jumpToDef:function(a){S(this,a)},jumpBack:function(a){var c=this.jumpStack.pop(),b=c&&this.docs[c.file];b&&L(this,w(this,a.getDoc()),b,c.start,c.end)},rename:function(a){U(this,a)},selectName:function(a){W(this,a)}, -request:function(a,c,b,d){var e=this,f=w(this,a.getDoc()),g=K(this,f,c,d);if(a=g.query&&this.options.queryOptions&&this.options.queryOptions[g.query.type])for(var h in a)g.query[h]=a[h];this.server.request(g,function(a,d){!a&&e.options.responseFilter&&(d=e.options.responseFilter(f,c,g,a,d));b(a,d)})},destroy:function(){y(this);this.worker&&(this.worker.terminate(),this.worker=null)}};var r=h.Pos,n="CodeMirror-Tern-",E=250,X=0,A=h.cmpPos}); +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Glue code between CodeMirror and Tern. +// +// Create a CodeMirror.TernServer to wrap an actual Tern server, +// register open documents (CodeMirror.Doc instances) with it, and +// call its methods to activate the assisting functions that Tern +// provides. +// +// Options supported (all optional): +// * defs: An array of JSON definition data structures. +// * plugins: An object mapping plugin names to configuration +// options. +// * getFile: A function(name, c) that can be used to access files in +// the project that haven't been loaded yet. Simply do c(null) to +// indicate that a file is not available. +// * fileFilter: A function(value, docName, doc) that will be applied +// to documents before passing them on to Tern. +// * switchToDoc: A function(name, doc) that should, when providing a +// multi-file view, switch the view or focus to the named file. +// * showError: A function(editor, message) that can be used to +// override the way errors are displayed. +// * completionTip: Customize the content in tooltips for completions. +// Is passed a single argument—the completion's data as returned by +// Tern—and may return a string, DOM node, or null to indicate that +// no tip should be shown. By default the docstring is shown. +// * typeTip: Like completionTip, but for the tooltips shown for type +// queries. +// * responseFilter: A function(doc, query, request, error, data) that +// will be applied to the Tern responses before treating them +// +// +// It is possible to run the Tern server in a web worker by specifying +// these additional options: +// * useWorker: Set to true to enable web worker mode. You'll probably +// want to feature detect the actual value you use here, for example +// !!window.Worker. +// * workerScript: The main script of the worker. Point this to +// wherever you are hosting worker.js from this directory. +// * workerDeps: An array of paths pointing (relative to workerScript) +// to the Acorn and Tern libraries and any Tern plugins you want to +// load. Or, if you minified those into a single script and included +// them in the workerScript, simply leave this undefined. + +(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"; + // declare global: tern + + CodeMirror.TernServer = function(options) { + var self = this; + this.options = options || {}; + var plugins = this.options.plugins || (this.options.plugins = {}); + if (!plugins.doc_comment) plugins.doc_comment = true; + this.docs = Object.create(null); + if (this.options.useWorker) { + this.server = new WorkerServer(this); + } else { + this.server = new tern.Server({ + getFile: function(name, c) { return getFile(self, name, c); }, + async: true, + defs: this.options.defs || [], + plugins: plugins + }); + } + this.trackChange = function(doc, change) { trackChange(self, doc, change); }; + + this.cachedArgHints = null; + this.activeArgHints = null; + this.jumpStack = []; + + this.getHint = function(cm, c) { return hint(self, cm, c); }; + this.getHint.async = true; + }; + + CodeMirror.TernServer.prototype = { + addDoc: function(name, doc) { + var data = {doc: doc, name: name, changed: null}; + this.server.addFile(name, docValue(this, data)); + CodeMirror.on(doc, "change", this.trackChange); + return this.docs[name] = data; + }, + + delDoc: function(id) { + var found = resolveDoc(this, id); + if (!found) return; + CodeMirror.off(found.doc, "change", this.trackChange); + delete this.docs[found.name]; + this.server.delFile(found.name); + }, + + hideDoc: function(id) { + closeArgHints(this); + var found = resolveDoc(this, id); + if (found && found.changed) sendDoc(this, found); + }, + + complete: function(cm) { + cm.showHint({hint: this.getHint}); + }, + + showType: function(cm, pos, c) { showContextInfo(this, cm, pos, "type", c); }, + + showDocs: function(cm, pos, c) { showContextInfo(this, cm, pos, "documentation", c); }, + + updateArgHints: function(cm) { updateArgHints(this, cm); }, + + jumpToDef: function(cm) { jumpToDef(this, cm); }, + + jumpBack: function(cm) { jumpBack(this, cm); }, + + rename: function(cm) { rename(this, cm); }, + + selectName: function(cm) { selectName(this, cm); }, + + request: function (cm, query, c, pos) { + var self = this; + var doc = findDoc(this, cm.getDoc()); + var request = buildRequest(this, doc, query, pos); + var extraOptions = request.query && this.options.queryOptions && this.options.queryOptions[request.query.type] + if (extraOptions) for (var prop in extraOptions) request.query[prop] = extraOptions[prop]; + + this.server.request(request, function (error, data) { + if (!error && self.options.responseFilter) + data = self.options.responseFilter(doc, query, request, error, data); + c(error, data); + }); + }, + + destroy: function () { + closeArgHints(this) + if (this.worker) { + this.worker.terminate(); + this.worker = null; + } + } + }; + + var Pos = CodeMirror.Pos; + var cls = "CodeMirror-Tern-"; + var bigDoc = 250; + + function getFile(ts, name, c) { + var buf = ts.docs[name]; + if (buf) + c(docValue(ts, buf)); + else if (ts.options.getFile) + ts.options.getFile(name, c); + else + c(null); + } + + function findDoc(ts, doc, name) { + for (var n in ts.docs) { + var cur = ts.docs[n]; + if (cur.doc == doc) return cur; + } + if (!name) for (var i = 0;; ++i) { + n = "[doc" + (i || "") + "]"; + if (!ts.docs[n]) { name = n; break; } + } + return ts.addDoc(name, doc); + } + + function resolveDoc(ts, id) { + if (typeof id == "string") return ts.docs[id]; + if (id instanceof CodeMirror) id = id.getDoc(); + if (id instanceof CodeMirror.Doc) return findDoc(ts, id); + } + + function trackChange(ts, doc, change) { + var data = findDoc(ts, doc); + + var argHints = ts.cachedArgHints; + if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) >= 0) + ts.cachedArgHints = null; + + var changed = data.changed; + if (changed == null) + data.changed = changed = {from: change.from.line, to: change.from.line}; + var end = change.from.line + (change.text.length - 1); + if (change.from.line < changed.to) changed.to = changed.to - (change.to.line - end); + if (end >= changed.to) changed.to = end + 1; + if (changed.from > change.from.line) changed.from = change.from.line; + + if (doc.lineCount() > bigDoc && change.to - changed.from > 100) setTimeout(function() { + if (data.changed && data.changed.to - data.changed.from > 100) sendDoc(ts, data); + }, 200); + } + + function sendDoc(ts, doc) { + ts.server.request({files: [{type: "full", name: doc.name, text: docValue(ts, doc)}]}, function(error) { + if (error) window.console.error(error); + else doc.changed = null; + }); + } + + // Completion + + function hint(ts, cm, c) { + ts.request(cm, {type: "completions", types: true, docs: true, urls: true}, function(error, data) { + if (error) return showError(ts, cm, error); + var completions = [], after = ""; + var from = data.start, to = data.end; + if (cm.getRange(Pos(from.line, from.ch - 2), from) == "[\"" && + cm.getRange(to, Pos(to.line, to.ch + 2)) != "\"]") + after = "\"]"; + + for (var i = 0; i < data.completions.length; ++i) { + var completion = data.completions[i], className = typeToIcon(completion.type); + if (data.guess) className += " " + cls + "guess"; + completions.push({text: completion.name + after, + displayText: completion.displayName || completion.name, + className: className, + data: completion}); + } + + var obj = {from: from, to: to, list: completions}; + var tooltip = null; + CodeMirror.on(obj, "close", function() { remove(tooltip); }); + CodeMirror.on(obj, "update", function() { remove(tooltip); }); + CodeMirror.on(obj, "select", function(cur, node) { + remove(tooltip); + var content = ts.options.completionTip ? ts.options.completionTip(cur.data) : cur.data.doc; + if (content) { + tooltip = makeTooltip(node.parentNode.getBoundingClientRect().right + window.pageXOffset, + node.getBoundingClientRect().top + window.pageYOffset, content, cm); + tooltip.className += " " + cls + "hint-doc"; + } + }); + c(obj); + }); + } + + function typeToIcon(type) { + var suffix; + if (type == "?") suffix = "unknown"; + else if (type == "number" || type == "string" || type == "bool") suffix = type; + else if (/^fn\(/.test(type)) suffix = "fn"; + else if (/^\[/.test(type)) suffix = "array"; + else suffix = "object"; + return cls + "completion " + cls + "completion-" + suffix; + } + + // Type queries + + function showContextInfo(ts, cm, pos, queryName, c) { + ts.request(cm, queryName, function(error, data) { + if (error) return showError(ts, cm, error); + if (ts.options.typeTip) { + var tip = ts.options.typeTip(data); + } else { + var tip = elt("span", null, elt("strong", null, data.type || "not found")); + if (data.doc) + tip.appendChild(document.createTextNode(" — " + data.doc)); + if (data.url) { + tip.appendChild(document.createTextNode(" ")); + var child = tip.appendChild(elt("a", null, "[docs]")); + child.href = data.url; + child.target = "_blank"; + } + } + tempTooltip(cm, tip, ts); + if (c) c(); + }, pos); + } + + // Maintaining argument hints + + function updateArgHints(ts, cm) { + closeArgHints(ts); + + if (cm.somethingSelected()) return; + var state = cm.getTokenAt(cm.getCursor()).state; + var inner = CodeMirror.innerMode(cm.getMode(), state); + if (inner.mode.name != "javascript") return; + var lex = inner.state.lexical; + if (lex.info != "call") return; + + var ch, argPos = lex.pos || 0, tabSize = cm.getOption("tabSize"); + for (var line = cm.getCursor().line, e = Math.max(0, line - 9), found = false; line >= e; --line) { + var str = cm.getLine(line), extra = 0; + for (var pos = 0;;) { + var tab = str.indexOf("\t", pos); + if (tab == -1) break; + extra += tabSize - (tab + extra) % tabSize - 1; + pos = tab + 1; + } + ch = lex.column - extra; + if (str.charAt(ch) == "(") {found = true; break;} + } + if (!found) return; + + var start = Pos(line, ch); + var cache = ts.cachedArgHints; + if (cache && cache.doc == cm.getDoc() && cmpPos(start, cache.start) == 0) + return showArgHints(ts, cm, argPos); + + ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) { + if (error || !data.type || !(/^fn\(/).test(data.type)) return; + ts.cachedArgHints = { + start: start, + type: parseFnType(data.type), + name: data.exprName || data.name || "fn", + guess: data.guess, + doc: cm.getDoc() + }; + showArgHints(ts, cm, argPos); + }); + } + + function showArgHints(ts, cm, pos) { + closeArgHints(ts); + + var cache = ts.cachedArgHints, tp = cache.type; + var tip = elt("span", cache.guess ? cls + "fhint-guess" : null, + elt("span", cls + "fname", cache.name), "("); + for (var i = 0; i < tp.args.length; ++i) { + if (i) tip.appendChild(document.createTextNode(", ")); + var arg = tp.args[i]; + tip.appendChild(elt("span", cls + "farg" + (i == pos ? " " + cls + "farg-current" : ""), arg.name || "?")); + if (arg.type != "?") { + tip.appendChild(document.createTextNode(":\u00a0")); + tip.appendChild(elt("span", cls + "type", arg.type)); + } + } + tip.appendChild(document.createTextNode(tp.rettype ? ") ->\u00a0" : ")")); + if (tp.rettype) tip.appendChild(elt("span", cls + "type", tp.rettype)); + var place = cm.cursorCoords(null, "page"); + var tooltip = ts.activeArgHints = makeTooltip(place.right + 1, place.bottom, tip, cm) + setTimeout(function() { + tooltip.clear = onEditorActivity(cm, function() { + if (ts.activeArgHints == tooltip) closeArgHints(ts) }) + }, 20) + } + + function parseFnType(text) { + var args = [], pos = 3; + + function skipMatching(upto) { + var depth = 0, start = pos; + for (;;) { + var next = text.charAt(pos); + if (upto.test(next) && !depth) return text.slice(start, pos); + if (/[{\[\(]/.test(next)) ++depth; + else if (/[}\]\)]/.test(next)) --depth; + ++pos; + } + } + + // Parse arguments + if (text.charAt(pos) != ")") for (;;) { + var name = text.slice(pos).match(/^([^, \(\[\{]+): /); + if (name) { + pos += name[0].length; + name = name[1]; + } + args.push({name: name, type: skipMatching(/[\),]/)}); + if (text.charAt(pos) == ")") break; + pos += 2; + } + + var rettype = text.slice(pos).match(/^\) -> (.*)$/); + + return {args: args, rettype: rettype && rettype[1]}; + } + + // Moving to the definition of something + + function jumpToDef(ts, cm) { + function inner(varName) { + var req = {type: "definition", variable: varName || null}; + var doc = findDoc(ts, cm.getDoc()); + ts.server.request(buildRequest(ts, doc, req), function(error, data) { + if (error) return showError(ts, cm, error); + if (!data.file && data.url) { window.open(data.url); return; } + + if (data.file) { + var localDoc = ts.docs[data.file], found; + if (localDoc && (found = findContext(localDoc.doc, data))) { + ts.jumpStack.push({file: doc.name, + start: cm.getCursor("from"), + end: cm.getCursor("to")}); + moveTo(ts, doc, localDoc, found.start, found.end); + return; + } + } + showError(ts, cm, "Could not find a definition."); + }); + } + + if (!atInterestingExpression(cm)) + dialog(cm, "Jump to variable", function(name) { if (name) inner(name); }); + else + inner(); + } + + function jumpBack(ts, cm) { + var pos = ts.jumpStack.pop(), doc = pos && ts.docs[pos.file]; + if (!doc) return; + moveTo(ts, findDoc(ts, cm.getDoc()), doc, pos.start, pos.end); + } + + function moveTo(ts, curDoc, doc, start, end) { + doc.doc.setSelection(start, end); + if (curDoc != doc && ts.options.switchToDoc) { + closeArgHints(ts); + ts.options.switchToDoc(doc.name, doc.doc); + } + } + + // The {line,ch} representation of positions makes this rather awkward. + function findContext(doc, data) { + var before = data.context.slice(0, data.contextOffset).split("\n"); + var startLine = data.start.line - (before.length - 1); + var start = Pos(startLine, (before.length == 1 ? data.start.ch : doc.getLine(startLine).length) - before[0].length); + + var text = doc.getLine(startLine).slice(start.ch); + for (var cur = startLine + 1; cur < doc.lineCount() && text.length < data.context.length; ++cur) + text += "\n" + doc.getLine(cur); + if (text.slice(0, data.context.length) == data.context) return data; + + var cursor = doc.getSearchCursor(data.context, 0, false); + var nearest, nearestDist = Infinity; + while (cursor.findNext()) { + var from = cursor.from(), dist = Math.abs(from.line - start.line) * 10000; + if (!dist) dist = Math.abs(from.ch - start.ch); + if (dist < nearestDist) { nearest = from; nearestDist = dist; } + } + if (!nearest) return null; + + if (before.length == 1) + nearest.ch += before[0].length; + else + nearest = Pos(nearest.line + (before.length - 1), before[before.length - 1].length); + if (data.start.line == data.end.line) + var end = Pos(nearest.line, nearest.ch + (data.end.ch - data.start.ch)); + else + var end = Pos(nearest.line + (data.end.line - data.start.line), data.end.ch); + return {start: nearest, end: end}; + } + + function atInterestingExpression(cm) { + var pos = cm.getCursor("end"), tok = cm.getTokenAt(pos); + if (tok.start < pos.ch && tok.type == "comment") return false; + return /[\w)\]]/.test(cm.getLine(pos.line).slice(Math.max(pos.ch - 1, 0), pos.ch + 1)); + } + + // Variable renaming + + function rename(ts, cm) { + var token = cm.getTokenAt(cm.getCursor()); + if (!/\w/.test(token.string)) return showError(ts, cm, "Not at a variable"); + dialog(cm, "New name for " + token.string, function(newName) { + ts.request(cm, {type: "rename", newName: newName, fullDocs: true}, function(error, data) { + if (error) return showError(ts, cm, error); + applyChanges(ts, data.changes); + }); + }); + } + + function selectName(ts, cm) { + var name = findDoc(ts, cm.doc).name; + ts.request(cm, {type: "refs"}, function(error, data) { + if (error) return showError(ts, cm, error); + var ranges = [], cur = 0; + var curPos = cm.getCursor(); + for (var i = 0; i < data.refs.length; i++) { + var ref = data.refs[i]; + if (ref.file == name) { + ranges.push({anchor: ref.start, head: ref.end}); + if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0) + cur = ranges.length - 1; + } + } + cm.setSelections(ranges, cur); + }); + } + + var nextChangeOrig = 0; + function applyChanges(ts, changes) { + var perFile = Object.create(null); + for (var i = 0; i < changes.length; ++i) { + var ch = changes[i]; + (perFile[ch.file] || (perFile[ch.file] = [])).push(ch); + } + for (var file in perFile) { + var known = ts.docs[file], chs = perFile[file];; + if (!known) continue; + chs.sort(function(a, b) { return cmpPos(b.start, a.start); }); + var origin = "*rename" + (++nextChangeOrig); + for (var i = 0; i < chs.length; ++i) { + var ch = chs[i]; + known.doc.replaceRange(ch.text, ch.start, ch.end, origin); + } + } + } + + // Generic request-building helper + + function buildRequest(ts, doc, query, pos) { + var files = [], offsetLines = 0, allowFragments = !query.fullDocs; + if (!allowFragments) delete query.fullDocs; + if (typeof query == "string") query = {type: query}; + query.lineCharPositions = true; + if (query.end == null) { + query.end = pos || doc.doc.getCursor("end"); + if (doc.doc.somethingSelected()) + query.start = doc.doc.getCursor("start"); + } + var startPos = query.start || query.end; + + if (doc.changed) { + if (doc.doc.lineCount() > bigDoc && allowFragments !== false && + doc.changed.to - doc.changed.from < 100 && + doc.changed.from <= startPos.line && doc.changed.to > query.end.line) { + files.push(getFragmentAround(doc, startPos, query.end)); + query.file = "#0"; + var offsetLines = files[0].offsetLines; + if (query.start != null) query.start = Pos(query.start.line - -offsetLines, query.start.ch); + query.end = Pos(query.end.line - offsetLines, query.end.ch); + } else { + files.push({type: "full", + name: doc.name, + text: docValue(ts, doc)}); + query.file = doc.name; + doc.changed = null; + } + } else { + query.file = doc.name; + } + for (var name in ts.docs) { + var cur = ts.docs[name]; + if (cur.changed && cur != doc) { + files.push({type: "full", name: cur.name, text: docValue(ts, cur)}); + cur.changed = null; + } + } + + return {query: query, files: files}; + } + + function getFragmentAround(data, start, end) { + var doc = data.doc; + var minIndent = null, minLine = null, endLine, tabSize = 4; + for (var p = start.line - 1, min = Math.max(0, p - 50); p >= min; --p) { + var line = doc.getLine(p), fn = line.search(/\bfunction\b/); + if (fn < 0) continue; + var indent = CodeMirror.countColumn(line, null, tabSize); + if (minIndent != null && minIndent <= indent) continue; + minIndent = indent; + minLine = p; + } + if (minLine == null) minLine = min; + var max = Math.min(doc.lastLine(), end.line + 20); + if (minIndent == null || minIndent == CodeMirror.countColumn(doc.getLine(start.line), null, tabSize)) + endLine = max; + else for (endLine = end.line + 1; endLine < max; ++endLine) { + var indent = CodeMirror.countColumn(doc.getLine(endLine), null, tabSize); + if (indent <= minIndent) break; + } + var from = Pos(minLine, 0); + + return {type: "part", + name: data.name, + offsetLines: from.line, + text: doc.getRange(from, Pos(endLine, end.line == endLine ? null : 0))}; + } + + // Generic utilities + + var cmpPos = CodeMirror.cmpPos; + + function elt(tagname, cls /*, ... elts*/) { + var e = document.createElement(tagname); + if (cls) e.className = cls; + for (var i = 2; i < arguments.length; ++i) { + var elt = arguments[i]; + if (typeof elt == "string") elt = document.createTextNode(elt); + e.appendChild(elt); + } + return e; + } + + function dialog(cm, text, f) { + if (cm.openDialog) + cm.openDialog(text + ": ", f); + else + f(prompt(text, "")); + } + + // Tooltips + + function tempTooltip(cm, content, ts) { + if (cm.state.ternTooltip) remove(cm.state.ternTooltip); + var where = cm.cursorCoords(); + var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content, cm); + function maybeClear() { + old = true; + if (!mouseOnTip) clear(); + } + function clear() { + cm.state.ternTooltip = null; + if (tip.parentNode) fadeOut(tip) + clearActivity() + } + var mouseOnTip = false, old = false; + CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; }); + CodeMirror.on(tip, "mouseout", function(e) { + var related = e.relatedTarget || e.toElement + if (!related || !CodeMirror.contains(tip, related)) { + if (old) clear(); + else mouseOnTip = false; + } + }); + setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700); + var clearActivity = onEditorActivity(cm, clear) + } + + function onEditorActivity(cm, f) { + cm.on("cursorActivity", f) + cm.on("blur", f) + cm.on("scroll", f) + cm.on("setDoc", f) + return function() { + cm.off("cursorActivity", f) + cm.off("blur", f) + cm.off("scroll", f) + cm.off("setDoc", f) + } + } + + function makeTooltip(x, y, content, cm) { + var node = elt("div", cls + "tooltip", content); + node.style.left = x + "px"; + node.style.top = y + "px"; + var container = ((cm.options || {}).hintOptions || {}).container || document.body; + container.appendChild(node); + return node; + } + + function remove(node) { + var p = node && node.parentNode; + if (p) p.removeChild(node); + } + + function fadeOut(tooltip) { + tooltip.style.opacity = "0"; + setTimeout(function() { remove(tooltip); }, 1100); + } + + function showError(ts, cm, msg) { + if (ts.options.showError) + ts.options.showError(cm, msg); + else + tempTooltip(cm, String(msg), ts); + } + + function closeArgHints(ts) { + if (ts.activeArgHints) { + if (ts.activeArgHints.clear) ts.activeArgHints.clear() + remove(ts.activeArgHints) + ts.activeArgHints = null + } + } + + function docValue(ts, doc) { + var val = doc.doc.getValue(); + if (ts.options.fileFilter) val = ts.options.fileFilter(val, doc.name, doc.doc); + return val; + } + + // Worker wrapper + + function WorkerServer(ts) { + var worker = ts.worker = new Worker(ts.options.workerScript); + worker.postMessage({type: "init", + defs: ts.options.defs, + plugins: ts.options.plugins, + scripts: ts.options.workerDeps}); + var msgId = 0, pending = {}; + + function send(data, c) { + if (c) { + data.id = ++msgId; + pending[msgId] = c; + } + worker.postMessage(data); + } + worker.onmessage = function(e) { + var data = e.data; + if (data.type == "getFile") { + getFile(ts, data.name, function(err, text) { + send({type: "getFile", err: String(err), text: text, id: data.id}); + }); + } else if (data.type == "debug") { + window.console.log(data.message); + } else if (data.id && pending[data.id]) { + pending[data.id](data.err, data.body); + delete pending[data.id]; + } + }; + worker.onerror = function(e) { + for (var id in pending) pending[id](e); + pending = {}; + }; + + this.addFile = function(name, text) { send({type: "add", name: name, text: text}); }; + this.delFile = function(name) { send({type: "del", name: name}); }; + this.request = function(body, c) { send({type: "req", body: body}, c); }; + } +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/worker.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/worker.js index 9589bcf..e134ad4 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/worker.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/tern/worker.js @@ -1,2 +1,44 @@ -'use strict';var server;this.onmessage=function(b){var a=b.data;switch(a.type){case "init":return startServer(a.defs,a.plugins,a.scripts);case "add":return server.addFile(a.name,a.text);case "del":return server.delFile(a.name);case "req":return server.request(a.body,function(b,d){postMessage({id:a.id,body:d,err:b&&String(b)})});case "getFile":return b=pending[a.id],delete pending[a.id],b(a.err,a.text);default:throw Error("Unknown message type: "+a.type);}};var nextId=0,pending={}; -function getFile(b,a){postMessage({type:"getFile",name:b,id:++nextId});pending[nextId]=a}function startServer(b,a,c){c&&importScripts.apply(null,c);server=new tern.Server({getFile:getFile,async:!0,defs:b,plugins:a})}this.console={log:function(b){postMessage({type:"debug",message:b})}}; +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// declare global: tern, server + +var server; + +this.onmessage = function(e) { + var data = e.data; + switch (data.type) { + case "init": return startServer(data.defs, data.plugins, data.scripts); + case "add": return server.addFile(data.name, data.text); + case "del": return server.delFile(data.name); + case "req": return server.request(data.body, function(err, reqData) { + postMessage({id: data.id, body: reqData, err: err && String(err)}); + }); + case "getFile": + var c = pending[data.id]; + delete pending[data.id]; + return c(data.err, data.text); + default: throw new Error("Unknown message type: " + data.type); + } +}; + +var nextId = 0, pending = {}; +function getFile(file, c) { + postMessage({type: "getFile", name: file, id: ++nextId}); + pending[nextId] = c; +} + +function startServer(defs, plugins, scripts) { + if (scripts) importScripts.apply(null, scripts); + + server = new tern.Server({ + getFile: getFile, + async: true, + defs: defs, + plugins: plugins + }); +} + +this.console = { + log: function(v) { postMessage({type: "debug", message: v}); } +}; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/wrap/hardwrap.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/wrap/hardwrap.js index efdfefd..516368c 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/wrap/hardwrap.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/addons/wrap/hardwrap.js @@ -1,5 +1,160 @@ -'use strict';(function(k){"object"==typeof exports&&"object"==typeof module?k(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],k):k(CodeMirror)})(function(k){function p(c,a,b){for(var e=b.paragraphStart||c.getHelper(a,"paragraphStart"),d=a.line,f=c.firstLine();d>f;--d){var g=c.getLine(d);if(e&&e.test(g))break;if(!/\S/.test(g)){++d;break}}b=b.paragraphEnd||c.getHelper(a,"paragraphEnd");a=a.line+1;for(e=c.lastLine();a<=e;++a){g=c.getLine(a);if(b&& -b.test(g)){++a;break}if(!/\S/.test(g))break}return{from:d,to:a}}function v(c,a,b,e){for(var d=a;d=d&& -(d=b.length+1);for(var r=0;rd&&b==t&&v(h,d,f,e);u&&u.from==n&&u.to==n+p?(h=b+l,++q):g.push({text:[p?" ":""],from:m(q,n),to:m(q+1,t.length)})}for(;h.length>d;)l=v(h,d,f,e),g.push({text:["",b],from:m(q,l.from),to:m(q,l.to)}),h=b+h.slice(l.to),++q}g.length&&c.operation(function(){for(var b=0;b= -d||(d=a.line,n(c,a,b,{}))})};k.defineExtension("wrapRange",function(c,a,b){return n(this,c,a,b||{})});k.defineExtension("wrapParagraphsInRange",function(c,a,b){b=b||{};var e=this,d=[];for(c=c.line;c<=a.line;)c=p(e,m(c,0),b),d.push(c),c=c.to;var f=!1;d.length&&e.operation(function(){for(var a=d.length-1;0<=a;--a)f=f||n(e,m(d[a].from,0),m(d[a].to-1),b)});return f})}); +// 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"; + + var Pos = CodeMirror.Pos; + + function findParagraph(cm, pos, options) { + var startRE = options.paragraphStart || cm.getHelper(pos, "paragraphStart"); + for (var start = pos.line, first = cm.firstLine(); start > first; --start) { + var line = cm.getLine(start); + if (startRE && startRE.test(line)) break; + if (!/\S/.test(line)) { ++start; break; } + } + var endRE = options.paragraphEnd || cm.getHelper(pos, "paragraphEnd"); + for (var end = pos.line + 1, last = cm.lastLine(); end <= last; ++end) { + var line = cm.getLine(end); + if (endRE && endRE.test(line)) { ++end; break; } + if (!/\S/.test(line)) break; + } + return {from: start, to: end}; + } + + function findBreakPoint(text, column, wrapOn, killTrailingSpace, forceBreak) { + var at = column + while (at < text.length && text.charAt(at) == " ") at++ + for (; at > 0; --at) + if (wrapOn.test(text.slice(at - 1, at + 1))) break; + + if (!forceBreak && at <= text.match(/^[ \t]*/)[0].length) { + // didn't find a break point before column, in non-forceBreak mode try to + // find one after 'column'. + for (at = column + 1; at < text.length - 1; ++at) { + if (wrapOn.test(text.slice(at - 1, at + 1))) break; + } + } + + for (var first = true;; first = false) { + var endOfText = at; + if (killTrailingSpace) + while (text.charAt(endOfText - 1) == " ") --endOfText; + if (endOfText == 0 && first) at = column; + else return {from: endOfText, to: at}; + } + } + + function wrapRange(cm, from, to, options) { + from = cm.clipPos(from); to = cm.clipPos(to); + var column = options.column || 80; + var wrapOn = options.wrapOn || /\s\S|-[^\.\d]/; + var forceBreak = options.forceBreak !== false; + var killTrailing = options.killTrailingSpace !== false; + var changes = [], curLine = "", curNo = from.line; + var lines = cm.getRange(from, to, false); + if (!lines.length) return null; + var leadingSpace = lines[0].match(/^[ \t]*/)[0]; + if (leadingSpace.length >= column) column = leadingSpace.length + 1 + + for (var i = 0; i < lines.length; ++i) { + var text = lines[i], oldLen = curLine.length, spaceInserted = 0; + if (curLine && text && !wrapOn.test(curLine.charAt(curLine.length - 1) + text.charAt(0))) { + curLine += " "; + spaceInserted = 1; + } + var spaceTrimmed = ""; + if (i) { + spaceTrimmed = text.match(/^\s*/)[0]; + text = text.slice(spaceTrimmed.length); + } + curLine += text; + if (i) { + var firstBreak = curLine.length > column && leadingSpace == spaceTrimmed && + findBreakPoint(curLine, column, wrapOn, killTrailing, forceBreak); + // If this isn't broken, or is broken at a different point, remove old break + if (!firstBreak || firstBreak.from != oldLen || firstBreak.to != oldLen + spaceInserted) { + changes.push({text: [spaceInserted ? " " : ""], + from: Pos(curNo, oldLen), + to: Pos(curNo + 1, spaceTrimmed.length)}); + } else { + curLine = leadingSpace + text; + ++curNo; + } + } + while (curLine.length > column) { + var bp = findBreakPoint(curLine, column, wrapOn, killTrailing, forceBreak); + if (bp.from != bp.to || + forceBreak && leadingSpace !== curLine.slice(0, bp.to)) { + changes.push({text: ["", leadingSpace], + from: Pos(curNo, bp.from), + to: Pos(curNo, bp.to)}); + curLine = leadingSpace + curLine.slice(bp.to); + ++curNo; + } else { + break; + } + } + } + if (changes.length) cm.operation(function() { + for (var i = 0; i < changes.length; ++i) { + var change = changes[i]; + if (change.text || CodeMirror.cmpPos(change.from, change.to)) + cm.replaceRange(change.text, change.from, change.to); + } + }); + return changes.length ? {from: changes[0].from, to: CodeMirror.changeEnd(changes[changes.length - 1])} : null; + } + + CodeMirror.defineExtension("wrapParagraph", function(pos, options) { + options = options || {}; + if (!pos) pos = this.getCursor(); + var para = findParagraph(this, pos, options); + return wrapRange(this, Pos(para.from, 0), Pos(para.to - 1), options); + }); + + CodeMirror.commands.wrapLines = function(cm) { + cm.operation(function() { + var ranges = cm.listSelections(), at = cm.lastLine() + 1; + for (var i = ranges.length - 1; i >= 0; i--) { + var range = ranges[i], span; + if (range.empty()) { + var para = findParagraph(cm, range.head, {}); + span = {from: Pos(para.from, 0), to: Pos(para.to - 1)}; + } else { + span = {from: range.from(), to: range.to()}; + } + if (span.to.line >= at) continue; + at = span.from.line; + wrapRange(cm, span.from, span.to, {}); + } + }); + }; + + CodeMirror.defineExtension("wrapRange", function(from, to, options) { + return wrapRange(this, from, to, options || {}); + }); + + CodeMirror.defineExtension("wrapParagraphsInRange", function(from, to, options) { + options = options || {}; + var cm = this, paras = []; + for (var line = from.line; line <= to.line;) { + var para = findParagraph(cm, Pos(line, 0), options); + paras.push(para); + line = para.to; + } + var madeChange = false; + if (paras.length) cm.operation(function() { + for (var i = paras.length - 1; i >= 0; --i) + madeChange = madeChange || wrapRange(cm, Pos(paras[i].from, 0), Pos(paras[i].to - 1), options); + }); + return madeChange; + }); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/index.html index c1d1f10..82019fe 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/index.html +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/index.html @@ -4,14 +4,19 @@ - - + + - - + + + + + + + + - @@ -20,12 +25,19 @@ + + + + + + + + + - - @@ -134,8 +146,129 @@ + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

APL mode

+
+ + + +

Simple mode that tries to handle APL as well as it can.

+

It attempts to label functions/operators based upon + monadic/dyadic usage (but this is far from fully fleshed out). + This means there are meaningful classnames so hover states can + have popups etc.

+ +

MIME types defined: text/apl (APL code)

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor/asciiarmor.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor/asciiarmor.js index fa1b0f8..f560f42 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor/asciiarmor.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor/index.html new file mode 100644 index 0000000..2ca76cc --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asciiarmor/index.html @@ -0,0 +1,46 @@ + + +CodeMirror: ASCII Armor (PGP) mode + + + + + + + + + +
+

ASCII Armor (PGP) mode

+
+ + + +

MIME types +defined: application/pgp, application/pgp-encrypted, application/pgp-keys, application/pgp-signature

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1/asn.1.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1/asn.1.js index 9600247..df1330b 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1/asn.1.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -190,7 +190,7 @@ " NetworkAddress BITS BMPString TimeStamp TimeTicks" + " TruthValue RowStatus DisplayString GeneralString" + " GraphicString IA5String NumericString" + - " PrintableString SnmpAdminAtring TeletexString" + + " PrintableString SnmpAdminString TeletexString" + " UTF8String VideotexString VisibleString StringStore" + " ISO646String T61String UniversalString Unsigned32" + " Integer32 Gauge Gauge32 Counter Counter32 Counter64"), diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1/index.html new file mode 100644 index 0000000..c79f489 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asn.1/index.html @@ -0,0 +1,78 @@ + + +CodeMirror: ASN.1 mode + + + + + + + + + +
+

ASN.1 example

+
+ +
+ + +
+

Language: Abstract Syntax Notation One + (ASN.1) +

+

MIME types defined: text/x-ttcn-asn

+ +
+

The development of this mode has been sponsored by Ericsson + .

+

Coded by Asmelash Tsegay Gebretsadkan

+
+ diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk/asterisk.js similarity index 90% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk/asterisk.js index b7ebfc5..49a7270 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk/asterisk.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /* * ===================================================================================== @@ -9,7 +9,7 @@ * Description: CodeMirror mode for Asterisk dialplan * * Created: 05/17/2012 09:20:25 PM - * Revision: none + * Revision: 08/05/2019 AstLinux Project: Support block-comments * * Author: Stas Kobzar (stas@modulis.ca), * Company: Modulis.ca Inc. @@ -67,7 +67,26 @@ CodeMirror.defineMode("asterisk", function() { var cur = ''; var ch = stream.next(); // comment + if (state.blockComment) { + if (ch == "-" && stream.match("-;", true)) { + state.blockComment = false; + } else if (stream.skipTo("--;")) { + stream.next(); + stream.next(); + stream.next(); + state.blockComment = false; + } else { + stream.skipToEnd(); + } + return "comment"; + } if(ch == ";") { + if (stream.match("--", true)) { + if (!stream.match("-", false)) { // Except ;--- is not a block comment + state.blockComment = true; + return "comment"; + } + } stream.skipToEnd(); return "comment"; } @@ -124,6 +143,7 @@ CodeMirror.defineMode("asterisk", function() { return { startState: function() { return { + blockComment: false, extenStart: false, extenSame: false, extenInclude: false, @@ -187,7 +207,11 @@ CodeMirror.defineMode("asterisk", function() { } return null; - } + }, + + blockCommentStart: ";--", + blockCommentEnd: "--;", + lineComment: ";" }; }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk/index.html new file mode 100644 index 0000000..de43e34 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/asterisk/index.html @@ -0,0 +1,155 @@ + + +CodeMirror: Asterisk dialplan mode + + + + + + + + + + +
+

Asterisk dialplan mode

+
+ + +

MIME types defined: text/x-asterisk.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck/brainfuck.js similarity index 96% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck/brainfuck.js index 3becf2a..af6d889 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck/brainfuck.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11 diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck/index.html new file mode 100644 index 0000000..7849e59 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/brainfuck/index.html @@ -0,0 +1,85 @@ + + +CodeMirror: Brainfuck mode + + + + + + + + + + +
+

Brainfuck mode

+
+ + + +

A mode for Brainfuck

+ +

MIME types defined: text/x-brainfuck

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/clike.js similarity index 81% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/clike.js index dec87a4..05b8f77 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/clike.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -65,7 +65,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { 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]/; + 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; @@ -79,15 +82,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { 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 (isPunctuationChar.test(ch)) { + curPunc = ch; + return null; + } if (ch == "/") { if (stream.eat("*")) { state.tokenize = tokenComment; @@ -113,7 +116,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { return "keyword"; } if (contains(types, cur)) return "type"; - if (contains(builtin, cur)) { + if (contains(builtin, cur) + || (isReservedIdentifier && isReservedIdentifier(cur))) { if (contains(blockKeywords, cur)) curPunc = "newstatement"; return "builtin"; } @@ -263,8 +267,52 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { } } 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"; - var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t"; + "static else struct switch extern typedef union for goto while enum const " + + "volatile inline restrict asm fortran"; + + // Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20. + var cppKeywords = "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"; + + var objCKeywords = "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"; + + var objCBuiltins = "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION " + + " NS_RETURNS_RETAINEDNS_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" + + // 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 @@ -286,6 +334,14 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { 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"; @@ -294,8 +350,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { 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 (stream.match(/^(?:R|u8R|uR|UR|LR)/)) { + var match = stream.match(/^"([^\s\\()]{0,16})\(/); if (!match) { return false; } @@ -304,8 +360,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { return tokenRawString(stream, state); } // Unicode strings/chars. - if (stream.match(/(u8|u|U|L)/)) { - if (stream.match(/["']/, /* eat */ false)) { + if (stream.match(/^(?:u8|u|U|L)/)) { + if (stream.match(/^["']/, /* eat */ false)) { return "string"; } return false; @@ -368,31 +424,30 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { def(["text/x-csrc", "text/x-c", "text/x-chdr"], { name: "clike", keywords: words(cKeywords), - types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " + - "int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " + - "uint32_t uint64_t"), - blockKeywords: words("case do else for if switch while struct"), - defKeywords: words("struct"), + types: cTypes, + blockKeywords: words(cBlockKeywords), + defKeywords: words(cDefKeywords), typeFirstDefinitions: true, atoms: words("NULL true false"), - hooks: {"#": cppHook, "*": pointerHook}, + isReservedIdentifier: cIsReservedIdentifier, + hooks: { + "#": cppHook, + "*": pointerHook, + }, modeProps: {fold: ["brace", "include"]} }); def(["text/x-c++src", "text/x-c++hdr"], { name: "clike", - keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " + - "static_cast typeid catch operator template typename class friend private " + - "this using const_cast inline public throw virtual delete mutable protected " + - "alignas alignof constexpr decltype nullptr noexcept thread_local final " + - "static_assert override"), - types: words(cTypes + " bool wchar_t"), - blockKeywords: words("catch class do else finally for if struct switch try while"), - defKeywords: words("class namespace struct enum union"), + keywords: words(cKeywords + " " + cppKeywords), + types: cTypes, + blockKeywords: words(cBlockKeywords + " class try catch"), + defKeywords: words(cDefKeywords + " class namespace"), typeFirstDefinitions: true, - atoms: words("true false NULL"), + atoms: words("true false NULL nullptr"), dontIndentStatements: /^template$/, isIdentifierChar: /[\w\$_~\xa1-\uffff]/, + isReservedIdentifier: cIsReservedIdentifier, hooks: { "#": cppHook, "*": pointerHook, @@ -425,7 +480,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { 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 " + + "do else enum extends final finally 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"), @@ -513,7 +568,6 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { 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 " + @@ -573,7 +627,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { return state.tokenize(stream, state) } }, - modeProps: {closeBrackets: {triples: '"'}} + modeProps: {closeBrackets: {pairs: '()[]{}""', triples: '"'}} }); function tokenKotlinString(tripleString){ @@ -628,15 +682,23 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { 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); }, + "/": function(stream, state) { + if (!stream.eat("*")) return false; + state.tokenize = tokenNestedComment(1); + 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 != "}" || + if ((state.prevToken == "operator" && textAfter != "}" && state.context.type != "}") || state.prevToken == "variable" && firstChar == "." || (state.prevToken == "}" || state.prevToken == ")") && firstChar == ".") return indentUnit * 2 + ctx.indented; @@ -687,7 +749,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { "gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " + "gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " + "gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " + - "gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + + "gl_TextureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + "gl_ProjectionMatrixInverseTranspose " + "gl_ModelViewProjectionMatrixInverseTranspose " + "gl_TextureMatrixInverseTranspose " + @@ -708,11 +770,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { def("text/x-nesc", { name: "clike", - keywords: words(cKeywords + "as atomic async call command component components configuration event generic " + + 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: words(cTypes), - blockKeywords: words("case do else for if switch while struct"), + types: cTypes, + blockKeywords: words(cBlockKeywords), atoms: words("null true false"), hooks: {"#": cppHook}, modeProps: {fold: ["brace", "include"]} @@ -720,28 +782,67 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { def("text/x-objectivec", { name: "clike", - keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in " + - "inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"), - types: words(cTypes), - atoms: words("YES NO NULL NILL ON OFF true false"), + keywords: words(cKeywords + " " + objCKeywords), + types: objCTypes, + builtin: words(objCBuiltins), + 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: { - "@": function(stream) { - stream.eatWhile(/[\w\$]/); - return "keyword"; - }, "#": cppHook, - indent: function(_state, ctx, textAfter) { - if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented + "*": pointerHook, + }, + modeProps: {fold: ["brace", "include"]} + }); + + def("text/x-objectivec++", { + name: "clike", + keywords: words(cKeywords + " " + objCKeywords + " " + cppKeywords), + types: objCTypes, + builtin: words(objCBuiltins), + blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized class try catch"), + defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class class namespace"), + dontIndentStatements: /^@.*$|^template$/, + typeFirstDefinitions: true, + atoms: words("YES NO NULL Nil nil true false nullptr"), + 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"; } }, - modeProps: {fold: "brace"} + namespaceSeparator: "::", + 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: words(cTypes), + types: cTypes, blockKeywords: words("case catch class else for foreach if switch try while"), defKeywords: words("function local class"), typeFirstDefinitions: true, diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/index.html new file mode 100644 index 0000000..b1c8819 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/index.html @@ -0,0 +1,380 @@ + + +CodeMirror: C-like mode + + + + + + + + + + + + +
+

C-like mode

+ +
+ +

C++ example

+ +
+ +

Objective-C example

+ +
+ +

Java example

+ +
+ +

Scala example

+ +
+ +

Kotlin mode

+ +
+ +

Ceylon mode

+ +
+ + + +

Simple mode that tries to handle C-like languages as well as it + can. Takes two configuration parameters: keywords, an + object whose property names are the keywords in the language, + and useCPP, which determines whether C preprocessor + directives are recognized.

+ +

MIME types defined: text/x-csrc + (C), text/x-c++src (C++), text/x-java + (Java), text/x-csharp (C#), + text/x-objectivec (Objective-C), + text/x-scala (Scala), text/x-vertex + x-shader/x-fragment (shader programs), + text/x-squirrel (Squirrel) and + text/x-ceylon (Ceylon)

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/scala.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/scala.html new file mode 100644 index 0000000..3d2123c --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/scala.html @@ -0,0 +1,767 @@ + + +CodeMirror: Scala mode + + + + + + + + + + +
+

Scala mode

+
+ +
+ + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/test.js new file mode 100644 index 0000000..9441b95 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clike/test.js @@ -0,0 +1,165 @@ +// 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 ][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 */]"); + + var mode_java = CodeMirror.getMode({indentUnit: 2}, "text/x-java"); + function MTJAVA(name) { test.mode("java_" + name, mode_java, Array.prototype.slice.call(arguments, 1)); } + MTJAVA("types", + "[type byte];", + "[type short];", + "[type int];", + "[type long];", + "[type float];", + "[type double];", + "[type boolean];", + "[type char];", + "[type void];", + "[type Boolean];", + "[type Byte];", + "[type Character];", + "[type Double];", + "[type Float];", + "[type Integer];", + "[type Long];", + "[type Number];", + "[type Object];", + "[type Short];", + "[type String];", + "[type StringBuffer];", + "[type StringBuilder];", + "[type Void];"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure.js deleted file mode 100644 index ed6af2c..0000000 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure.js +++ /dev/null @@ -1,306 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -/** - * Author: Hans Engel - * Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun) - */ - -(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("clojure", function (options) { - var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2", - ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable"; - var INDENT_WORD_SKIP = options.indentUnit || 2; - var NORMAL_INDENT_UNIT = options.indentUnit || 2; - - function makeKeywords(str) { - var obj = {}, words = str.split(" "); - for (var i = 0; i < words.length; ++i) obj[words[i]] = true; - return obj; - } - - var atoms = makeKeywords("true false nil"); - - var keywords = makeKeywords( - "defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest " + - "slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn " + - "do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync " + - "doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars " + - "binding gen-class gen-and-load-class gen-and-save-class handler-case handle"); - - var builtins = makeKeywords( - "* *' *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* " + - "*compile-path* *compiler-options* *data-readers* *e *err* *file* *flush-on-newline* *fn-loader* *in* " + - "*math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* " + - "*source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* + +' - -' -> " + - "->> ->ArrayChunk ->Vec ->VecNode ->VecSeq -cache-protocol-fn -reset-methods .. / < <= = == > >= EMPTY-NODE accessor " + - "aclone add-classpath add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! " + - "alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double " + - "aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 " + - "bases bean bigdec bigint biginteger binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set " + - "bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* bound? butlast " + - "byte byte-array bytes case cat cast char char-array char-escape-string char-name-string char? chars chunk chunk-append " + - "chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors " + - "clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement completing concat cond condp " + - "conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec dec' decimal? " + - "declare dedupe default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol " + - "defrecord defstruct deftype delay delay? deliver denominator deref derive descendants destructure disj disj! dissoc " + - "dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array doubles drop drop-last " + - "drop-while eduction empty empty? ensure enumeration-seq error-handler error-mode eval even? every-pred every? ex-data ex-info " + - "extend extend-protocol extend-type extenders extends? false? ffirst file-seq filter filterv find find-keyword " + - "find-ns find-protocol-impl find-protocol-method find-var first flatten float float-array float? floats flush fn fn? " + - "fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future? " + - "gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator group-by hash " + - "hash-combine hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc inc' init-proxy instance? " + - "int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt keep " + - "keep-indexed key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file " + - "load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array " + - "make-hierarchy map map-indexed map? mapcat mapv max max-key memfn memoize merge merge-with meta method-sig methods " + - "min min-key mod munge name namespace namespace-munge neg? newline next nfirst nil? nnext not not-any? not-empty " + - "not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias " + - "ns-unmap nth nthnext nthrest num number? numerator object-array odd? or parents partial partition partition-all " + - "partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers " + - "primitives-classnames print print-ctor print-dup print-method print-simple print-str printf println println-str " + - "prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues " + - "quot rand rand-int rand-nth random-sample range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern " + - "re-seq read read-line read-string realized? reduce reduce-kv reductions ref ref-history-count ref-max-history " + - "ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods " + - "remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! resolve rest " + - "restart-agent resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? " + - "seque sequence sequential? set set-error-handler! set-error-mode! set-validator! set? short short-array shorts " + - "shuffle shutdown-agents slurp some some-fn sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? " + - "special-symbol? spit split-at split-with str string? struct struct-map subs subseq subvec supers swap! symbol " + - "symbol? sync take take-last take-nth take-while test the-ns thread-bound? time to-array to-array-2d trampoline transduce " + - "transient tree-seq true? type unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec " + - "unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int " + - "unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int "+ - "unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote " + - "unquote-splicing update update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector-of " + - "vector? volatile! volatile? vreset! vswap! when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context " + - "with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn xml-seq zero? zipmap " + - "*default-data-reader-fn* as-> cond-> cond->> reduced reduced? send-via set-agent-send-executor! " + - "set-agent-send-off-executor! some-> some->>"); - - var indentKeys = makeKeywords( - // Built-ins - "ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto " + - "locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type " + - "try catch " + - - // Binding forms - "let letfn binding loop for doseq dotimes when-let if-let " + - - // Data structures - "defstruct struct-map assoc " + - - // clojure.test - "testing deftest " + - - // contrib - "handler-case handle dotrace deftrace"); - - var tests = { - digit: /\d/, - digit_or_colon: /[\d:]/, - hex: /[0-9a-f]/i, - sign: /[+-]/, - exponent: /e/i, - keyword_char: /[^\s\(\[\;\)\]]/, - symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/, - block_indent: /^(?:def|with)[^\/]+$|\/(?:def|with)/ - }; - - function stateStack(indent, type, prev) { // represents a state stack object - this.indent = indent; - this.type = type; - this.prev = prev; - } - - function pushStack(state, indent, type) { - state.indentStack = new stateStack(indent, type, state.indentStack); - } - - function popStack(state) { - state.indentStack = state.indentStack.prev; - } - - function isNumber(ch, stream){ - // hex - if ( ch === '0' && stream.eat(/x/i) ) { - stream.eatWhile(tests.hex); - return true; - } - - // leading sign - if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) { - stream.eat(tests.sign); - ch = stream.next(); - } - - if ( tests.digit.test(ch) ) { - stream.eat(ch); - stream.eatWhile(tests.digit); - - if ( '.' == stream.peek() ) { - stream.eat('.'); - stream.eatWhile(tests.digit); - } else if ('/' == stream.peek() ) { - stream.eat('/'); - stream.eatWhile(tests.digit); - } - - if ( stream.eat(tests.exponent) ) { - stream.eat(tests.sign); - stream.eatWhile(tests.digit); - } - - return true; - } - - return false; - } - - // Eat character that starts after backslash \ - function eatCharacter(stream) { - var first = stream.next(); - // Read special literals: backspace, newline, space, return. - // Just read all lowercase letters. - if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) { - return; - } - // Read unicode character: \u1000 \uA0a1 - if (first === "u") { - stream.match(/[0-9a-z]{4}/i, true); - } - } - - return { - startState: function () { - return { - indentStack: null, - indentation: 0, - mode: false - }; - }, - - token: function (stream, state) { - if (state.indentStack == null && stream.sol()) { - // update indentation, but only if indentStack is empty - state.indentation = stream.indentation(); - } - - // skip spaces - if (state.mode != "string" && stream.eatSpace()) { - return null; - } - var returnType = null; - - switch(state.mode){ - case "string": // multi-line string parsing mode - var next, escaped = false; - while ((next = stream.next()) != null) { - if (next == "\"" && !escaped) { - - state.mode = false; - break; - } - escaped = !escaped && next == "\\"; - } - returnType = STRING; // continue on in string mode - break; - default: // default parsing mode - var ch = stream.next(); - - if (ch == "\"") { - state.mode = "string"; - returnType = STRING; - } else if (ch == "\\") { - eatCharacter(stream); - returnType = CHARACTER; - } else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) { - returnType = ATOM; - } else if (ch == ";") { // comment - stream.skipToEnd(); // rest of the line is a comment - returnType = COMMENT; - } else if (isNumber(ch,stream)){ - returnType = NUMBER; - } else if (ch == "(" || ch == "[" || ch == "{" ) { - var keyWord = '', indentTemp = stream.column(), letter; - /** - Either - (indent-word .. - (non-indent-word .. - (;something else, bracket, etc. - */ - - if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) { - keyWord += letter; - } - - if (keyWord.length > 0 && (indentKeys.propertyIsEnumerable(keyWord) || - tests.block_indent.test(keyWord))) { // indent-word - pushStack(state, indentTemp + INDENT_WORD_SKIP, ch); - } else { // non-indent word - // we continue eating the spaces - stream.eatSpace(); - if (stream.eol() || stream.peek() == ";") { - // nothing significant after - // we restart indentation the user defined spaces after - pushStack(state, indentTemp + NORMAL_INDENT_UNIT, ch); - } else { - pushStack(state, indentTemp + stream.current().length, ch); // else we match - } - } - stream.backUp(stream.current().length - 1); // undo all the eating - - returnType = BRACKET; - } else if (ch == ")" || ch == "]" || ch == "}") { - returnType = BRACKET; - if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : (ch == "]" ? "[" :"{"))) { - popStack(state); - } - } else if ( ch == ":" ) { - stream.eatWhile(tests.symbol); - return ATOM; - } else { - stream.eatWhile(tests.symbol); - - if (keywords && keywords.propertyIsEnumerable(stream.current())) { - returnType = KEYWORD; - } else if (builtins && builtins.propertyIsEnumerable(stream.current())) { - returnType = BUILTIN; - } else if (atoms && atoms.propertyIsEnumerable(stream.current())) { - returnType = ATOM; - } else { - returnType = VAR; - } - } - } - - return returnType; - }, - - indent: function (state) { - if (state.indentStack == null) return state.indentation; - return state.indentStack.indent; - }, - - closeBrackets: {pairs: "()[]{}\"\""}, - lineComment: ";;" - }; -}); - -CodeMirror.defineMIME("text/x-clojure", "clojure"); -CodeMirror.defineMIME("text/x-clojurescript", "clojure"); -CodeMirror.defineMIME("application/edn", "clojure"); - -}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/clojure.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/clojure.js new file mode 100644 index 0000000..0b9d6ac --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/clojure.js @@ -0,0 +1,292 @@ +// 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"; + +CodeMirror.defineMode("clojure", function (options) { + var atoms = ["false", "nil", "true"]; + var specialForms = [".", "catch", "def", "do", "if", "monitor-enter", + "monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"]; + var coreSymbols = ["*", "*'", "*1", "*2", "*3", "*agent*", + "*allow-unresolved-vars*", "*assert*", "*clojure-version*", + "*command-line-args*", "*compile-files*", "*compile-path*", + "*compiler-options*", "*data-readers*", "*default-data-reader-fn*", "*e", + "*err*", "*file*", "*flush-on-newline*", "*fn-loader*", "*in*", + "*math-context*", "*ns*", "*out*", "*print-dup*", "*print-length*", + "*print-level*", "*print-meta*", "*print-namespace-maps*", + "*print-readably*", "*read-eval*", "*reader-resolver*", "*source-path*", + "*suppress-read*", "*unchecked-math*", "*use-context-classloader*", + "*verbose-defrecords*", "*warn-on-reflection*", "+", "+'", "-", "-'", + "->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode", + "->VecSeq", "-cache-protocol-fn", "-reset-methods", "..", "/", "<", "<=", + "=", "==", ">", ">=", "EMPTY-NODE", "Inst", "StackTraceElement->vec", + "Throwable->map", "accessor", "aclone", "add-classpath", "add-watch", + "agent", "agent-error", "agent-errors", "aget", "alength", "alias", + "all-ns", "alter", "alter-meta!", "alter-var-root", "amap", "ancestors", + "and", "any?", "apply", "areduce", "array-map", "as->", "aset", + "aset-boolean", "aset-byte", "aset-char", "aset-double", "aset-float", + "aset-int", "aset-long", "aset-short", "assert", "assoc", "assoc!", + "assoc-in", "associative?", "atom", "await", "await-for", "await1", + "bases", "bean", "bigdec", "bigint", "biginteger", "binding", "bit-and", + "bit-and-not", "bit-clear", "bit-flip", "bit-not", "bit-or", "bit-set", + "bit-shift-left", "bit-shift-right", "bit-test", "bit-xor", "boolean", + "boolean-array", "boolean?", "booleans", "bound-fn", "bound-fn*", + "bound?", "bounded-count", "butlast", "byte", "byte-array", "bytes", + "bytes?", "case", "cast", "cat", "char", "char-array", + "char-escape-string", "char-name-string", "char?", "chars", "chunk", + "chunk-append", "chunk-buffer", "chunk-cons", "chunk-first", "chunk-next", + "chunk-rest", "chunked-seq?", "class", "class?", "clear-agent-errors", + "clojure-version", "coll?", "comment", "commute", "comp", "comparator", + "compare", "compare-and-set!", "compile", "complement", "completing", + "concat", "cond", "cond->", "cond->>", "condp", "conj", "conj!", "cons", + "constantly", "construct-proxy", "contains?", "count", "counted?", + "create-ns", "create-struct", "cycle", "dec", "dec'", "decimal?", + "declare", "dedupe", "default-data-readers", "definline", "definterface", + "defmacro", "defmethod", "defmulti", "defn", "defn-", "defonce", + "defprotocol", "defrecord", "defstruct", "deftype", "delay", "delay?", + "deliver", "denominator", "deref", "derive", "descendants", "destructure", + "disj", "disj!", "dissoc", "dissoc!", "distinct", "distinct?", "doall", + "dorun", "doseq", "dosync", "dotimes", "doto", "double", "double-array", + "double?", "doubles", "drop", "drop-last", "drop-while", "eduction", + "empty", "empty?", "ensure", "ensure-reduced", "enumeration-seq", + "error-handler", "error-mode", "eval", "even?", "every-pred", "every?", + "ex-data", "ex-info", "extend", "extend-protocol", "extend-type", + "extenders", "extends?", "false?", "ffirst", "file-seq", "filter", + "filterv", "find", "find-keyword", "find-ns", "find-protocol-impl", + "find-protocol-method", "find-var", "first", "flatten", "float", + "float-array", "float?", "floats", "flush", "fn", "fn?", "fnext", "fnil", + "for", "force", "format", "frequencies", "future", "future-call", + "future-cancel", "future-cancelled?", "future-done?", "future?", + "gen-class", "gen-interface", "gensym", "get", "get-in", "get-method", + "get-proxy-class", "get-thread-bindings", "get-validator", "group-by", + "halt-when", "hash", "hash-combine", "hash-map", "hash-ordered-coll", + "hash-set", "hash-unordered-coll", "ident?", "identical?", "identity", + "if-let", "if-not", "if-some", "ifn?", "import", "in-ns", "inc", "inc'", + "indexed?", "init-proxy", "inst-ms", "inst-ms*", "inst?", "instance?", + "int", "int-array", "int?", "integer?", "interleave", "intern", + "interpose", "into", "into-array", "ints", "io!", "isa?", "iterate", + "iterator-seq", "juxt", "keep", "keep-indexed", "key", "keys", "keyword", + "keyword?", "last", "lazy-cat", "lazy-seq", "let", "letfn", "line-seq", + "list", "list*", "list?", "load", "load-file", "load-reader", + "load-string", "loaded-libs", "locking", "long", "long-array", "longs", + "loop", "macroexpand", "macroexpand-1", "make-array", "make-hierarchy", + "map", "map-entry?", "map-indexed", "map?", "mapcat", "mapv", "max", + "max-key", "memfn", "memoize", "merge", "merge-with", "meta", + "method-sig", "methods", "min", "min-key", "mix-collection-hash", "mod", + "munge", "name", "namespace", "namespace-munge", "nat-int?", "neg-int?", + "neg?", "newline", "next", "nfirst", "nil?", "nnext", "not", "not-any?", + "not-empty", "not-every?", "not=", "ns", "ns-aliases", "ns-imports", + "ns-interns", "ns-map", "ns-name", "ns-publics", "ns-refers", + "ns-resolve", "ns-unalias", "ns-unmap", "nth", "nthnext", "nthrest", + "num", "number?", "numerator", "object-array", "odd?", "or", "parents", + "partial", "partition", "partition-all", "partition-by", "pcalls", "peek", + "persistent!", "pmap", "pop", "pop!", "pop-thread-bindings", "pos-int?", + "pos?", "pr", "pr-str", "prefer-method", "prefers", + "primitives-classnames", "print", "print-ctor", "print-dup", + "print-method", "print-simple", "print-str", "printf", "println", + "println-str", "prn", "prn-str", "promise", "proxy", + "proxy-call-with-super", "proxy-mappings", "proxy-name", "proxy-super", + "push-thread-bindings", "pvalues", "qualified-ident?", + "qualified-keyword?", "qualified-symbol?", "quot", "rand", "rand-int", + "rand-nth", "random-sample", "range", "ratio?", "rational?", + "rationalize", "re-find", "re-groups", "re-matcher", "re-matches", + "re-pattern", "re-seq", "read", "read-line", "read-string", + "reader-conditional", "reader-conditional?", "realized?", "record?", + "reduce", "reduce-kv", "reduced", "reduced?", "reductions", "ref", + "ref-history-count", "ref-max-history", "ref-min-history", "ref-set", + "refer", "refer-clojure", "reify", "release-pending-sends", "rem", + "remove", "remove-all-methods", "remove-method", "remove-ns", + "remove-watch", "repeat", "repeatedly", "replace", "replicate", "require", + "reset!", "reset-meta!", "reset-vals!", "resolve", "rest", + "restart-agent", "resultset-seq", "reverse", "reversible?", "rseq", + "rsubseq", "run!", "satisfies?", "second", "select-keys", "send", + "send-off", "send-via", "seq", "seq?", "seqable?", "seque", "sequence", + "sequential?", "set", "set-agent-send-executor!", + "set-agent-send-off-executor!", "set-error-handler!", "set-error-mode!", + "set-validator!", "set?", "short", "short-array", "shorts", "shuffle", + "shutdown-agents", "simple-ident?", "simple-keyword?", "simple-symbol?", + "slurp", "some", "some->", "some->>", "some-fn", "some?", "sort", + "sort-by", "sorted-map", "sorted-map-by", "sorted-set", "sorted-set-by", + "sorted?", "special-symbol?", "spit", "split-at", "split-with", "str", + "string?", "struct", "struct-map", "subs", "subseq", "subvec", "supers", + "swap!", "swap-vals!", "symbol", "symbol?", "sync", "tagged-literal", + "tagged-literal?", "take", "take-last", "take-nth", "take-while", "test", + "the-ns", "thread-bound?", "time", "to-array", "to-array-2d", + "trampoline", "transduce", "transient", "tree-seq", "true?", "type", + "unchecked-add", "unchecked-add-int", "unchecked-byte", "unchecked-char", + "unchecked-dec", "unchecked-dec-int", "unchecked-divide-int", + "unchecked-double", "unchecked-float", "unchecked-inc", + "unchecked-inc-int", "unchecked-int", "unchecked-long", + "unchecked-multiply", "unchecked-multiply-int", "unchecked-negate", + "unchecked-negate-int", "unchecked-remainder-int", "unchecked-short", + "unchecked-subtract", "unchecked-subtract-int", "underive", "unquote", + "unquote-splicing", "unreduced", "unsigned-bit-shift-right", "update", + "update-in", "update-proxy", "uri?", "use", "uuid?", "val", "vals", + "var-get", "var-set", "var?", "vary-meta", "vec", "vector", "vector-of", + "vector?", "volatile!", "volatile?", "vreset!", "vswap!", "when", + "when-first", "when-let", "when-not", "when-some", "while", + "with-bindings", "with-bindings*", "with-in-str", "with-loading-context", + "with-local-vars", "with-meta", "with-open", "with-out-str", + "with-precision", "with-redefs", "with-redefs-fn", "xml-seq", "zero?", + "zipmap"]; + var haveBodyParameter = [ + "->", "->>", "as->", "binding", "bound-fn", "case", "catch", "comment", + "cond", "cond->", "cond->>", "condp", "def", "definterface", "defmethod", + "defn", "defmacro", "defprotocol", "defrecord", "defstruct", "deftype", + "do", "doseq", "dotimes", "doto", "extend", "extend-protocol", + "extend-type", "fn", "for", "future", "if", "if-let", "if-not", "if-some", + "let", "letfn", "locking", "loop", "ns", "proxy", "reify", "struct-map", + "some->", "some->>", "try", "when", "when-first", "when-let", "when-not", + "when-some", "while", "with-bindings", "with-bindings*", "with-in-str", + "with-loading-context", "with-local-vars", "with-meta", "with-open", + "with-out-str", "with-precision", "with-redefs", "with-redefs-fn"]; + + CodeMirror.registerHelper("hintWords", "clojure", + [].concat(atoms, specialForms, coreSymbols)); + + var atom = createLookupMap(atoms); + var specialForm = createLookupMap(specialForms); + var coreSymbol = createLookupMap(coreSymbols); + var hasBodyParameter = createLookupMap(haveBodyParameter); + var delimiter = /^(?:[\\\[\]\s"(),;@^`{}~]|$)/; + var numberLiteral = /^(?:[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?(?=[\\\[\]\s"#'(),;@^`{}~]|$))/; + var characterLiteral = /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/; + + // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*/ + // simple-symbol := /^(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)/ + // qualified-symbol := ((<.>)*)? + var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~.][^\\\[\]\s"(),;@^`{}~.\/]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/; + + function base(stream, state) { + if (stream.eatSpace() || stream.eat(",")) return ["space", null]; + if (stream.match(numberLiteral)) return [null, "number"]; + if (stream.match(characterLiteral)) return [null, "string-2"]; + if (stream.eat(/^"/)) return (state.tokenize = inString)(stream, state); + if (stream.eat(/^[(\[{]/)) return ["open", "bracket"]; + if (stream.eat(/^[)\]}]/)) return ["close", "bracket"]; + if (stream.eat(/^;/)) {stream.skipToEnd(); return ["space", "comment"];} + if (stream.eat(/^[#'@^`~]/)) return [null, "meta"]; + + var matches = stream.match(qualifiedSymbol); + var symbol = matches && matches[0]; + + if (!symbol) { + // advance stream by at least one character so we don't get stuck. + stream.next(); + stream.eatWhile(function (c) {return !is(c, delimiter);}); + return [null, "error"]; + } + + if (symbol === "comment" && state.lastToken === "(") + return (state.tokenize = inComment)(stream, state); + if (is(symbol, atom) || symbol.charAt(0) === ":") return ["symbol", "atom"]; + if (is(symbol, specialForm) || is(symbol, coreSymbol)) return ["symbol", "keyword"]; + if (state.lastToken === "(") return ["symbol", "builtin"]; // other operator + + return ["symbol", "variable"]; + } + + function inString(stream, state) { + var escaped = false, next; + + while (next = stream.next()) { + if (next === "\"" && !escaped) {state.tokenize = base; break;} + escaped = !escaped && next === "\\"; + } + + return [null, "string"]; + } + + function inComment(stream, state) { + var parenthesisCount = 1; + var next; + + while (next = stream.next()) { + if (next === ")") parenthesisCount--; + if (next === "(") parenthesisCount++; + if (parenthesisCount === 0) { + stream.backUp(1); + state.tokenize = base; + break; + } + } + + return ["space", "comment"]; + } + + function createLookupMap(words) { + var obj = {}; + + for (var i = 0; i < words.length; ++i) obj[words[i]] = true; + + return obj; + } + + function is(value, test) { + if (test instanceof RegExp) return test.test(value); + if (test instanceof Object) return test.propertyIsEnumerable(value); + } + + return { + startState: function () { + return { + ctx: {prev: null, start: 0, indentTo: 0}, + lastToken: null, + tokenize: base + }; + }, + + token: function (stream, state) { + if (stream.sol() && (typeof state.ctx.indentTo !== "number")) + state.ctx.indentTo = state.ctx.start + 1; + + var typeStylePair = state.tokenize(stream, state); + var type = typeStylePair[0]; + var style = typeStylePair[1]; + var current = stream.current(); + + if (type !== "space") { + if (state.lastToken === "(" && state.ctx.indentTo === null) { + if (type === "symbol" && is(current, hasBodyParameter)) + state.ctx.indentTo = state.ctx.start + options.indentUnit; + else state.ctx.indentTo = "next"; + } else if (state.ctx.indentTo === "next") { + state.ctx.indentTo = stream.column(); + } + + state.lastToken = current; + } + + if (type === "open") + state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null}; + else if (type === "close") state.ctx = state.ctx.prev || state.ctx; + + return style; + }, + + indent: function (state) { + var i = state.ctx.indentTo; + + return (typeof i === "number") ? + i : + state.ctx.start + 1; + }, + + closeBrackets: {pairs: "()[]{}\"\""}, + lineComment: ";;" + }; +}); + +CodeMirror.defineMIME("text/x-clojure", "clojure"); +CodeMirror.defineMIME("text/x-clojurescript", "clojure"); +CodeMirror.defineMIME("application/edn", "clojure"); + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/index.html new file mode 100644 index 0000000..d063434 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/index.html @@ -0,0 +1,95 @@ + + +CodeMirror: Clojure mode + + + + + + + + + + + +
+

Clojure mode

+
+ + +

MIME types defined: text/x-clojure.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/test.js new file mode 100644 index 0000000..642473b --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/clojure/test.js @@ -0,0 +1,384 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function () { + var mode = CodeMirror.getMode({indentUnit: 2}, "clojure"); + + function MT(name) { + test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); + } + + MT("atoms", + "[atom false]", + "[atom nil]", + "[atom true]" + ); + + MT("keywords", + "[atom :foo]", + "[atom ::bar]", + "[atom :foo/bar]", + "[atom :foo.bar/baz]" + ); + + MT("numbers", + "[number 42] [number +42] [number -421]", + "[number 42N] [number +42N] [number -42N]", + "[number 0.42] [number +0.42] [number -0.42]", + "[number 42M] [number +42M] [number -42M]", + "[number 42.42M] [number +42.42M] [number -42.42M]", + "[number 1/42] [number +1/42] [number -1/42]", + "[number 0x42af] [number +0x42af] [number -0x42af]", + "[number 0x42AF] [number +0x42AF] [number -0x42AF]", + "[number 1e2] [number 1e+2] [number 1e-2]", + "[number +1e2] [number +1e+2] [number +1e-2]", + "[number -1e2] [number -1e+2] [number -1e-2]", + "[number -1.0e2] [number -0.1e+2] [number -1.01e-2]", + "[number 1E2] [number 1E+2] [number 1E-2]", + "[number +1E2] [number +1E+2] [number +1E-2]", + "[number -1E2] [number -1E+2] [number -1E-2]", + "[number -1.0E2] [number -0.1E+2] [number -1.01E-2]", + "[number 2r101010] [number +2r101010] [number -2r101010]", + "[number 2r101010] [number +2r101010] [number -2r101010]", + "[number 8r52] [number +8r52] [number -8r52]", + "[number 36rhello] [number +36rhello] [number -36rhello]", + "[number 36rz] [number +36rz] [number -36rz]", + "[number 36rZ] [number +36rZ] [number -36rZ]", + + // invalid numbers + "[error 42foo]", + "[error 42Nfoo]", + "[error 42Mfoo]", + "[error 42.42Mfoo]", + "[error 42.42M!]", + "[error 42!]", + "[error 0x42afm]" + ); + + MT("characters", + "[string-2 \\1]", + "[string-2 \\a]", + "[string-2 \\a\\b\\c]", + "[string-2 \\#]", + "[string-2 \\\\]", + "[string-2 \\\"]", + "[string-2 \\(]", + "[string-2 \\A]", + "[string-2 \\backspace]", + "[string-2 \\formfeed]", + "[string-2 \\newline]", + "[string-2 \\space]", + "[string-2 \\return]", + "[string-2 \\tab]", + "[string-2 \\u1000]", + "[string-2 \\uAaAa]", + "[string-2 \\u9F9F]", + "[string-2 \\o123]", + "[string-2 \\符]", + "[string-2 \\シ]", + "[string-2 \\ۇ]", + // FIXME + // "[string-2 \\🙂]", + + // invalid character literals + "[error \\abc]", + "[error \\a123]", + "[error \\a!]", + "[error \\newlines]", + "[error \\NEWLINE]", + "[error \\u9F9FF]", + "[error \\o1234]" + ); + + MT("strings", + "[string \"I'm a teapot.\"]", + "[string \"I'm a \\\"teapot\\\".\"]", + "[string \"I'm]", // this is + "[string a]", // a multi-line + "[string teapot.\"]" // string + + // TODO unterminated (multi-line) strings? + ); + + MT("comments", + "[comment ; this is an in-line comment.]", + "[comment ;; this is a line comment.]", + "[keyword comment]", + "[bracket (][comment comment (foo 1 2 3)][bracket )]" + ); + + MT("reader macro characters", + "[meta #][variable _]", + "[meta #][variable -Inf]", + "[meta ##][variable Inf]", + "[meta ##][variable NaN]", + "[meta @][variable x]", + "[meta ^][bracket {][atom :tag] [variable String][bracket }]", + "[meta `][bracket (][builtin f] [variable x][bracket )]", + "[meta ~][variable foo#]", + "[meta '][number 1]", + "[meta '][atom :foo]", + "[meta '][string \"foo\"]", + "[meta '][variable x]", + "[meta '][bracket (][builtin a] [variable b] [variable c][bracket )]", + "[meta '][bracket [[][variable a] [variable b] [variable c][bracket ]]]", + "[meta '][bracket {][variable a] [number 1] [atom :foo] [number 2] [variable c] [number 3][bracket }]", + "[meta '#][bracket {][variable a] [number 1] [atom :foo][bracket }]" + ); + + MT("symbols", + "[variable foo!]", + "[variable foo#]", + "[variable foo$]", + "[variable foo&]", + "[variable foo']", + "[variable foo*]", + "[variable foo+]", + "[variable foo-]", + "[variable foo.]", + "[variable foo/bar]", + "[variable foo:bar]", + "[variable foo<]", + "[variable foo=]", + "[variable foo>]", + "[variable foo?]", + "[variable foo_]", + "[variable foo|]", + "[variable foobarBaz]", + "[variable foo¡]", + "[variable 符号]", + "[variable シンボル]", + "[variable ئۇيغۇر]", + "[variable 🙂❤🇺🇸]", + + // invalid symbols + "[error 3foo]", + "[error 3+]", + "[error 3|]", + "[error 3_]" + ); + + MT("numbers and other forms", + "[number 42][bracket (][builtin foo][bracket )]", + "[number 42][bracket [[][variable foo][bracket ]]]", + "[number 42][meta #][bracket {][variable foo][bracket }]", + "[number 42][bracket {][atom :foo] [variable bar][bracket }]", + "[number 42][meta `][variable foo]", + "[number 42][meta ~][variable foo]", + "[number 42][meta #][variable foo]" + ); + + var specialForms = [".", "catch", "def", "do", "if", "monitor-enter", + "monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"]; + + MT("should highlight special forms as keywords", + typeTokenPairs("keyword", specialForms) + ); + + var coreSymbols1 = [ + "*", "*'", "*1", "*2", "*3", "*agent*", "*allow-unresolved-vars*", "*assert*", + "*clojure-version*", "*command-line-args*", "*compile-files*", "*compile-path*", "*compiler-options*", + "*data-readers*", "*default-data-reader-fn*", "*e", "*err*", "*file*", "*flush-on-newline*", "*fn-loader*", + "*in*", "*math-context*", "*ns*", "*out*", "*print-dup*", "*print-length*", "*print-level*", "*print-meta*", + "*print-namespace-maps*", "*print-readably*", "*read-eval*", "*reader-resolver*", "*source-path*", + "*suppress-read*", "*unchecked-math*", "*use-context-classloader*", "*verbose-defrecords*", + "*warn-on-reflection*", "+", "+'", "-", "-'", "->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode", + "->VecSeq", "-cache-protocol-fn", "-reset-methods", "..", "/", "<", "<=", "=", "==", ">", ">=", + "EMPTY-NODE", "Inst", "StackTraceElement->vec", "Throwable->map", "accessor", "aclone", "add-classpath", + "add-watch", "agent", "agent-error", "agent-errors", "aget", "alength", "alias", "all-ns", "alter", + "alter-meta!", "alter-var-root", "amap", "ancestors", "and", "any?", "apply", "areduce", "array-map", + "as->", "aset", "aset-boolean", "aset-byte", "aset-char", "aset-double", "aset-float", "aset-int", + "aset-long", "aset-short", "assert", "assoc", "assoc!", "assoc-in", "associative?", "atom", "await", + "await-for", "await1", "bases", "bean", "bigdec", "bigint", "biginteger", "binding", "bit-and", "bit-and-not", + "bit-clear", "bit-flip", "bit-not", "bit-or", "bit-set", "bit-shift-left", "bit-shift-right", "bit-test", + "bit-xor", "boolean", "boolean-array", "boolean?", "booleans", "bound-fn", "bound-fn*", "bound?", + "bounded-count", "butlast", "byte", "byte-array", "bytes", "bytes?", "case", "cast", "cat", "char", + "char-array", "char-escape-string", "char-name-string", "char?", "chars", "chunk", "chunk-append", + "chunk-buffer", "chunk-cons", "chunk-first", "chunk-next", "chunk-rest", "chunked-seq?", "class", "class?", + "clear-agent-errors", "clojure-version", "coll?", "comment", "commute", "comp", "comparator", "compare", + "compare-and-set!", "compile", "complement", "completing", "concat", "cond", "cond->", "cond->>", "condp", + "conj", "conj!", "cons", "constantly", "construct-proxy", "contains?", "count", "counted?", "create-ns", + "create-struct", "cycle", "dec", "dec'", "decimal?", "declare", "dedupe", "default-data-readers", "definline", + "definterface", "defmacro", "defmethod", "defmulti", "defn", "defn-", "defonce", "defprotocol", "defrecord", + "defstruct", "deftype", "delay", "delay?", "deliver", "denominator", "deref", "derive", "descendants", + "destructure", "disj", "disj!", "dissoc", "dissoc!", "distinct", "distinct?", "doall", "dorun", "doseq", + "dosync", "dotimes", "doto", "double", "double-array", "double?", "doubles", "drop", "drop-last", "drop-while", + "eduction", "empty", "empty?", "ensure", "ensure-reduced", "enumeration-seq", "error-handler", "error-mode", + "eval", "even?", "every-pred", "every?", "ex-data", "ex-info", "extend", "extend-protocol", "extend-type", + "extenders", "extends?", "false?", "ffirst", "file-seq", "filter", "filterv", "find", "find-keyword", "find-ns", + "find-protocol-impl", "find-protocol-method", "find-var", "first", "flatten", "float", "float-array", "float?", + "floats", "flush", "fn", "fn?", "fnext", "fnil", "for", "force", "format", "frequencies", "future", "future-call", + "future-cancel", "future-cancelled?", "future-done?", "future?", "gen-class", "gen-interface", "gensym", "get", + "get-in", "get-method", "get-proxy-class", "get-thread-bindings", "get-validator", "group-by", "halt-when", "hash", + "hash-combine", "hash-map", "hash-ordered-coll", "hash-set", "hash-unordered-coll", "ident?", "identical?", + "identity", "if-let", "if-not", "if-some", "ifn?", "import", "in-ns", "inc", "inc'", "indexed?", "init-proxy", + "inst-ms", "inst-ms*", "inst?", "instance?", "int", "int-array", "int?", "integer?", "interleave", "intern", + "interpose", "into", "into-array", "ints", "io!", "isa?", "iterate", "iterator-seq", "juxt", "keep", "keep-indexed", + "key", "keys", "keyword", "keyword?", "last", "lazy-cat", "lazy-seq", "let", "letfn", "line-seq", "list", "list*", + "list?", "load", "load-file", "load-reader", "load-string", "loaded-libs", "locking", "long", "long-array", "longs", + "loop", "macroexpand", "macroexpand-1", "make-array", "make-hierarchy", "map", "map-entry?", "map-indexed", "map?", + "mapcat", "mapv", "max", "max-key", "memfn", "memoize", "merge", "merge-with", "meta", "method-sig", "methods"]; + + var coreSymbols2 = [ + "min", "min-key", "mix-collection-hash", "mod", "munge", "name", "namespace", "namespace-munge", "nat-int?", + "neg-int?", "neg?", "newline", "next", "nfirst", "nil?", "nnext", "not", "not-any?", "not-empty", "not-every?", + "not=", "ns", "ns-aliases", "ns-imports", "ns-interns", "ns-map", "ns-name", "ns-publics", "ns-refers", "ns-resolve", + "ns-unalias", "ns-unmap", "nth", "nthnext", "nthrest", "num", "number?", "numerator", "object-array", "odd?", "or", + "parents", "partial", "partition", "partition-all", "partition-by", "pcalls", "peek", "persistent!", "pmap", "pop", + "pop!", "pop-thread-bindings", "pos-int?", "pos?", "pr", "pr-str", "prefer-method", "prefers", + "primitives-classnames", "print", "print-ctor", "print-dup", "print-method", "print-simple", "print-str", "printf", + "println", "println-str", "prn", "prn-str", "promise", "proxy", "proxy-call-with-super", "proxy-mappings", + "proxy-name", "proxy-super", "push-thread-bindings", "pvalues", "qualified-ident?", "qualified-keyword?", + "qualified-symbol?", "quot", "rand", "rand-int", "rand-nth", "random-sample", "range", "ratio?", "rational?", + "rationalize", "re-find", "re-groups", "re-matcher", "re-matches", "re-pattern", "re-seq", "read", "read-line", + "read-string", "reader-conditional", "reader-conditional?", "realized?", "record?", "reduce", "reduce-kv", "reduced", + "reduced?", "reductions", "ref", "ref-history-count", "ref-max-history", "ref-min-history", "ref-set", "refer", + "refer-clojure", "reify", "release-pending-sends", "rem", "remove", "remove-all-methods", "remove-method", "remove-ns", + "remove-watch", "repeat", "repeatedly", "replace", "replicate", "require", "reset!", "reset-meta!", "reset-vals!", + "resolve", "rest", "restart-agent", "resultset-seq", "reverse", "reversible?", "rseq", "rsubseq", "run!", "satisfies?", + "second", "select-keys", "send", "send-off", "send-via", "seq", "seq?", "seqable?", "seque", "sequence", "sequential?", + "set", "set-agent-send-executor!", "set-agent-send-off-executor!", "set-error-handler!", "set-error-mode!", + "set-validator!", "set?", "short", "short-array", "shorts", "shuffle", "shutdown-agents", "simple-ident?", + "simple-keyword?", "simple-symbol?", "slurp", "some", "some->", "some->>", "some-fn", "some?", "sort", "sort-by", + "sorted-map", "sorted-map-by", "sorted-set", "sorted-set-by", "sorted?", "special-symbol?", "spit", "split-at", + "split-with", "str", "string?", "struct", "struct-map", "subs", "subseq", "subvec", "supers", "swap!", "swap-vals!", + "symbol", "symbol?", "sync", "tagged-literal", "tagged-literal?", "take", "take-last", "take-nth", "take-while", "test", + "the-ns", "thread-bound?", "time", "to-array", "to-array-2d", "trampoline", "transduce", "transient", "tree-seq", + "true?", "type", "unchecked-add", "unchecked-add-int", "unchecked-byte", "unchecked-char", "unchecked-dec", + "unchecked-dec-int", "unchecked-divide-int", "unchecked-double", "unchecked-float", "unchecked-inc", "unchecked-inc-int", + "unchecked-int", "unchecked-long", "unchecked-multiply", "unchecked-multiply-int", "unchecked-negate", + "unchecked-negate-int", "unchecked-remainder-int", "unchecked-short", "unchecked-subtract", "unchecked-subtract-int", + "underive", "unquote", "unquote-splicing", "unreduced", "unsigned-bit-shift-right", "update", "update-in", + "update-proxy", "uri?", "use", "uuid?", "val", "vals", "var-get", "var-set", "var?", "vary-meta", "vec", "vector", + "vector-of", "vector?", "volatile!", "volatile?", "vreset!", "vswap!", "when", "when-first", "when-let", "when-not", + "when-some", "while", "with-bindings", "with-bindings*", "with-in-str", "with-loading-context", "with-local-vars", + "with-meta", "with-open", "with-out-str", "with-precision", "with-redefs", "with-redefs-fn", "xml-seq", "zero?", + "zipmap" + ]; + + MT("should highlight core symbols as keywords (part 1/2)", + typeTokenPairs("keyword", coreSymbols1) + ); + + MT("should highlight core symbols as keywords (part 2/2)", + typeTokenPairs("keyword", coreSymbols2) + ); + + MT("should properly indent forms in list literals", + "[bracket (][builtin foo] [atom :a] [number 1] [atom true] [atom nil][bracket )]", + "", + "[bracket (][builtin foo] [atom :a]", + " [number 1]", + " [atom true]", + " [atom nil][bracket )]", + "", + "[bracket (][builtin foo] [atom :a] [number 1]", + " [atom true]", + " [atom nil][bracket )]", + "", + "[bracket (]", + " [builtin foo]", + " [atom :a]", + " [number 1]", + " [atom true]", + " [atom nil][bracket )]", + "", + "[bracket (][builtin foo] [bracket [[][atom :a][bracket ]]]", + " [number 1]", + " [atom true]", + " [atom nil][bracket )]" + ); + + MT("should properly indent forms in vector literals", + "[bracket [[][atom :a] [number 1] [atom true] [atom nil][bracket ]]]", + "", + "[bracket [[][atom :a]", + " [number 1]", + " [atom true]", + " [atom nil][bracket ]]]", + "", + "[bracket [[][atom :a] [number 1]", + " [atom true]", + " [atom nil][bracket ]]]", + "", + "[bracket [[]", + " [variable foo]", + " [atom :a]", + " [number 1]", + " [atom true]", + " [atom nil][bracket ]]]" + ); + + MT("should properly indent forms in map literals", + "[bracket {][atom :a] [atom :a] [atom :b] [number 1] [atom :c] [atom true] [atom :d] [atom nil] [bracket }]", + "", + "[bracket {][atom :a] [atom :a]", + " [atom :b] [number 1]", + " [atom :c] [atom true]", + " [atom :d] [atom nil][bracket }]", + "", + "[bracket {][atom :a]", + " [atom :a]", + " [atom :b]", + " [number 1]", + " [atom :c]", + " [atom true]", + " [atom :d]", + " [atom nil][bracket }]", + "", + "[bracket {]", + " [atom :a] [atom :a]", + " [atom :b] [number 1]", + " [atom :c] [atom true]", + " [atom :d] [atom nil][bracket }]" + ); + + MT("should properly indent forms in set literals", + "[meta #][bracket {][atom :a] [number 1] [atom true] [atom nil] [bracket }]", + "", + "[meta #][bracket {][atom :a]", + " [number 1]", + " [atom true]", + " [atom nil][bracket }]", + "", + "[meta #][bracket {]", + " [atom :a]", + " [number 1]", + " [atom true]", + " [atom nil][bracket }]" + ); + + var haveBodyParameter = [ + "->", "->>", "as->", "binding", "bound-fn", "case", "catch", "cond", + "cond->", "cond->>", "condp", "def", "definterface", "defmethod", "defn", + "defmacro", "defprotocol", "defrecord", "defstruct", "deftype", "do", + "doseq", "dotimes", "doto", "extend", "extend-protocol", "extend-type", + "fn", "for", "future", "if", "if-let", "if-not", "if-some", "let", + "letfn", "locking", "loop", "ns", "proxy", "reify", "some->", "some->>", + "struct-map", "try", "when", "when-first", "when-let", "when-not", + "when-some", "while", "with-bindings", "with-bindings*", "with-in-str", + "with-loading-context", "with-local-vars", "with-meta", "with-open", + "with-out-str", "with-precision", "with-redefs", "with-redefs-fn"]; + + function testFormsThatHaveBodyParameter(forms) { + for (var i = 0; i < forms.length; i++) { + MT("should indent body argument of `" + forms[i] + "` by `options.indentUnit` spaces", + "[bracket (][keyword " + forms[i] + "] [variable foo] [variable bar]", + " [variable baz]", + " [variable qux][bracket )]" + ); + } + } + + testFormsThatHaveBodyParameter(haveBodyParameter); + + MT("should indent body argument of `comment` by `options.indentUnit` spaces", + "[bracket (][comment comment foo bar]", + "[comment baz]", + "[comment qux][bracket )]" + ); + + function typeTokenPairs(type, tokens) { + return "[" + type + " " + tokens.join("] [" + type + " ") + "]"; + } +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake/cmake.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake/cmake.js index 9f9eda5..496c71d 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake/cmake.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake/index.html new file mode 100644 index 0000000..edd6838 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cmake/index.html @@ -0,0 +1,129 @@ + + +CodeMirror: CMake mode + + + + + + + + + + +
+

CMake mode

+
+ + +

MIME types defined: text/x-cmake.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol/cobol.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol/cobol.js index 897022b..275857b 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol/cobol.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /** * Author: Gautam Mehta diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol/index.html new file mode 100644 index 0000000..40feb00 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cobol/index.html @@ -0,0 +1,210 @@ + + +CodeMirror: COBOL mode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

COBOL mode

+ +

Select Theme Select Font Size + + + + +

+ + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript/coffeescript.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript/coffeescript.js index ae955db..a54e9d5 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript/coffeescript.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /** * Link to the project's GitHub page: diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript/index.html new file mode 100644 index 0000000..6d51aab --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/coffeescript/index.html @@ -0,0 +1,740 @@ + + +CodeMirror: CoffeeScript mode + + + + + + + + + +
+

CoffeeScript mode

+
+ + +

MIME types defined: application/vnd.coffeescript, text/coffeescript, text/x-coffeescript.

+ +

The CoffeeScript mode was written by Jeff Pickhardt.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp/commonlisp.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp/commonlisp.js index 8cd212d..52abbb2 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp/commonlisp.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp/index.html new file mode 100644 index 0000000..59b4460 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/commonlisp/index.html @@ -0,0 +1,177 @@ + + +CodeMirror: Common Lisp mode + + + + + + + + + +
+

Common Lisp mode

+
+ + +

MIME types defined: text/x-common-lisp.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal/crystal.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal/crystal.js index dada112..5c601c6 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal/crystal.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal/index.html new file mode 100644 index 0000000..bbd2650 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/crystal/index.html @@ -0,0 +1,116 @@ + + +CodeMirror: Crystal mode + + + + + + + + + + + +
+

Crystal mode

+
+ + +

MIME types defined: text/x-crystal.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/css.js similarity index 76% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/css.js index f5f3a41..88a869b 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/css.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -29,7 +29,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { valueKeywords = parserConfig.valueKeywords || {}, allowNested = parserConfig.allowNested, lineComment = parserConfig.lineComment, - supportsAtComponent = parserConfig.supportsAtComponent === true; + supportsAtComponent = parserConfig.supportsAtComponent === true, + highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false; var type, override; function ret(style, tp) { type = tp; return style; } @@ -63,7 +64,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { if (/[\d.]/.test(stream.peek())) { stream.eatWhile(/[\w.%]/); return ret("number", "unit"); - } else if (stream.match(/^-[\w\\\-]+/)) { + } else if (stream.match(/^-[\w\\\-]*/)) { stream.eatWhile(/[\w\\\-]/); if (stream.match(/^\s*:/, false)) return ret("variable-2", "variable-definition"); @@ -77,12 +78,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) { return ret("qualifier", "qualifier"); } else if (/[:;{}\[\]\(\)]/.test(ch)) { return ret(null, ch); - } else if (((ch == "u" || ch == "U") && stream.match(/rl(-prefix)?\(/i)) || - ((ch == "d" || ch == "D") && stream.match("omain(", true, true)) || - ((ch == "r" || ch == "R") && stream.match("egexp(", true, true))) { - stream.backUp(1); - state.tokenize = tokenParenthesized; - return ret("property", "word"); + } else if (stream.match(/^[\w-.]+(?=\()/)) { + if (/^(url(-prefix)?|domain|regexp)$/i.test(stream.current())) { + state.tokenize = tokenParenthesized; + } + return ret("variable callee", "variable"); } else if (/[\w\\\-]/.test(ch)) { stream.eatWhile(/[\w\\\-]/); return ret("property", "word"); @@ -108,7 +108,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { function tokenParenthesized(stream, state) { stream.next(); // Must be '(' - if (!stream.match(/\s*[\"\')]/, false)) + if (!stream.match(/^\s*[\"\')]/, false)) state.tokenize = tokenString(")"); else state.tokenize = null; @@ -198,7 +198,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { override = "property"; return "maybeprop"; } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) { - override = "string-2"; + override = highlightNonStandardPropertyKeywords ? "string-2" : "property"; return "maybeprop"; } else if (allowNested) { override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag"; @@ -292,7 +292,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { else if (propertyKeywords.hasOwnProperty(word)) override = "property"; else if (nonStandardPropertyKeywords.hasOwnProperty(word)) - override = "string-2"; + override = highlightNonStandardPropertyKeywords ? "string-2" : "property"; else if (valueKeywords.hasOwnProperty(word)) override = "atom"; else if (colorKeywords.hasOwnProperty(word)) @@ -443,117 +443,149 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "monochrome", "min-monochrome", "max-monochrome", "resolution", "min-resolution", "max-resolution", "scan", "grid", "orientation", "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio", - "pointer", "any-pointer", "hover", "any-hover" + "pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme" ], mediaFeatures = keySet(mediaFeatures_); var mediaValueKeywords_ = [ "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover", - "interlace", "progressive" + "interlace", "progressive", + "dark", "light" ], mediaValueKeywords = keySet(mediaValueKeywords_); var propertyKeywords_ = [ "align-content", "align-items", "align-self", "alignment-adjust", - "alignment-baseline", "anchor-point", "animation", "animation-delay", + "alignment-baseline", "all", "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-blend-mode", "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", + "animation-timing-function", "appearance", "azimuth", "backdrop-filter", + "backface-visibility", "background", "background-attachment", + "background-blend-mode", "background-clip", "background-color", + "background-image", "background-origin", "background-position", + "background-position-x", "background-position-y", "background-repeat", + "background-size", "baseline-shift", "binding", "bleed", "block-size", + "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", "caret-color", "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-rows", "grid-column", "grid-column-end", "grid-column-gap", - "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", - "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", "justify-items", "justify-self", "left", "letter-spacing", - "line-break", "line-height", "line-stacking", "line-stacking-ruby", + "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", "caret-color", + "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", "contain", + "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-family", "font-feature-settings", "font-kerning", + "font-language-override", "font-optical-sizing", "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-variation-settings", "font-weight", "gap", + "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", "grid-auto-rows", + "grid-column", "grid-column-end", "grid-column-gap", "grid-column-start", + "grid-gap", "grid-row", "grid-row-end", "grid-row-gap", "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", + "inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline", + "inset-inline-end", "inset-inline-start", "isolation", "justify-content", + "justify-items", "justify-self", "left", "letter-spacing", "line-break", + "line-height", "line-height-step", "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", - "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", "place-content", "place-items", "place-self", "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", + "margin-bottom", "margin-left", "margin-right", "margin-top", "marks", + "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", + "marquee-style", "mask-clip", "mask-composite", "mask-image", "mask-mode", + "mask-origin", "mask-position", "mask-repeat", "mask-size","mask-type", + "max-block-size", "max-height", "max-inline-size", + "max-width", "min-block-size", "min-height", "min-inline-size", "min-width", + "mix-blend-mode", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", + "nav-up", "object-fit", "object-position", "offset", "offset-anchor", + "offset-distance", "offset-path", "offset-position", "offset-rotate", + "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", "place-content", "place-items", "place-self", "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", "rotate", "rotation", "rotation-point", + "row-gap", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", + "scale", "scroll-behavior", "scroll-margin", "scroll-margin-block", + "scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom", + "scroll-margin-inline", "scroll-margin-inline-end", + "scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right", + "scroll-margin-top", "scroll-padding", "scroll-padding-block", + "scroll-padding-block-end", "scroll-padding-block-start", + "scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end", + "scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right", + "scroll-padding-top", "scroll-snap-align", "scroll-snap-type", + "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-combine-upright", "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", - "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration", - "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", - "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break", - "word-spacing", "word-wrap", "z-index", + "text-decoration-skip-ink", "text-decoration-style", "text-emphasis", + "text-emphasis-color", "text-emphasis-position", "text-emphasis-style", + "text-height", "text-indent", "text-justify", "text-orientation", + "text-outline", "text-overflow", "text-rendering", "text-shadow", + "text-size-adjust", "text-space-collapse", "text-transform", + "text-underline-position", "text-wrap", "top", "touch-action", "transform", "transform-origin", + "transform-style", "transition", "transition-delay", "transition-duration", + "transition-property", "transition-timing-function", "translate", + "unicode-bidi", "user-select", "vertical-align", "visibility", "voice-balance", + "voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate", + "voice-stress", "voice-volume", "volume", "white-space", "widows", "width", + "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "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", + "marker", "marker-end", "marker-mid", "marker-start", "paint-order", "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" + "glyph-orientation-vertical", "text-anchor", "writing-mode", ], propertyKeywords = keySet(propertyKeywords_); var nonStandardPropertyKeywords_ = [ + "border-block", "border-block-color", "border-block-end", + "border-block-end-color", "border-block-end-style", "border-block-end-width", + "border-block-start", "border-block-start-color", "border-block-start-style", + "border-block-start-width", "border-block-style", "border-block-width", + "border-inline", "border-inline-color", "border-inline-end", + "border-inline-end-color", "border-inline-end-style", + "border-inline-end-width", "border-inline-start", "border-inline-start-color", + "border-inline-start-style", "border-inline-start-width", + "border-inline-style", "border-inline-width", "margin-block", + "margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end", + "margin-inline-start", "padding-block", "padding-block-end", + "padding-block-start", "padding-inline", "padding-inline-end", + "padding-inline-start", "scroll-snap-stop", "scrollbar-3d-light-color", "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" + "scrollbar-track-color", "searchfield-cancel-button", "searchfield-decoration", + "searchfield-results-button", "searchfield-results-decoration", "shape-inside", "zoom" ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_); var fontProperties_ = [ - "font-family", "src", "unicode-range", "font-variant", "font-feature-settings", - "font-stretch", "font-weight", "font-style" + "font-display", "font-family", "src", "unicode-range", "font-variant", + "font-feature-settings", "font-stretch", "font-weight", "font-style" ], fontProperties = keySet(fontProperties_); var counterDescriptors_ = [ @@ -595,7 +627,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page", - "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary", + "avoid-region", "axis-pan", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel", "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian", @@ -619,7 +651,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et", "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed", - "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", + "extra-expanded", "fantasy", "fast", "fill", "fill-box", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove", "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew", "help", "hidden", "hide", "higher", "highlight", "highlighttext", @@ -634,7 +666,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian", - "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d", + "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "match", "matrix", "matrix3d", "media-controls-background", "media-current-time-display", "media-fullscreen-button", "media-mute-button", "media-play-button", "media-return-to-realtime-button", "media-rewind-button", @@ -643,13 +675,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "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", "multiply", "myanmar", "n-resize", + "mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "myanmar", "n-resize", "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", "outside", "outside-shape", "overlay", "overline", "padding", "padding-box", - "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter", + "painted", "page", "paused", "persian", "perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", @@ -667,8 +699,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali", "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", - "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub", - "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", + "square-button", "start", "static", "status-bar", "stretch", "stroke", "stroke-box", "sub", + "subpixel-antialiased", "svg_masks", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", "table-row-group", "tamil", @@ -678,10 +710,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) { "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", "trad-chinese-formal", "trad-chinese-informal", "transform", "translate", "translate3d", "translateX", "translateY", "translateZ", - "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up", + "transparent", "ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", - "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", + "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small" @@ -749,7 +781,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) { } }, ":": function(stream) { - if (stream.match(/\s*\{/, false)) + if (stream.match(/^\s*\{/, false)) return [null, null] return false; }, diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/gss.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/gss.html new file mode 100644 index 0000000..17d24f8 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/gss.html @@ -0,0 +1,104 @@ + + +CodeMirror: Closure Stylesheets (GSS) mode + + + + + + + + + + + + + +
+

Closure Stylesheets (GSS) mode

+
+ + +

A mode for Closure Stylesheets (GSS).

+

MIME type defined: text/x-gss.

+ +

Parsing/Highlighting Tests: normal, verbose.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/gss_test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/gss_test.js new file mode 100644 index 0000000..2401bc4 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/gss_test.js @@ -0,0 +1,17 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + "use strict"; + + var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); } + + MT("atComponent", + "[def @component] {", + "[tag foo] {", + " [property color]: [keyword black];", + "}", + "}"); + +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/index.html new file mode 100644 index 0000000..42b327c --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/index.html @@ -0,0 +1,81 @@ + + +CodeMirror: CSS mode + + + + + + + + + + + + +
+

CSS mode

+
+ + +

CSS mode supports this option:

+ +
highlightNonStandardPropertyKeywords: boolean
+
Whether to highlight non-standard CSS property keywords such as margin-inline or zoom (default: true).
+
+ +

MIME types defined: text/css, text/x-scss (demo), text/x-less (demo).

+ +

Parsing/Highlighting Tests: normal, verbose.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/less.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/less.html new file mode 100644 index 0000000..f7611ef --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/less.html @@ -0,0 +1,152 @@ + + +CodeMirror: LESS mode + + + + + + + + + + +
+

LESS mode

+
+ + +

The LESS mode is a sub-mode of the CSS mode (defined in css.js).

+ +

Parsing/Highlighting Tests: normal, verbose.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/less_test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/less_test.js new file mode 100644 index 0000000..abeb6a2 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/less_test.js @@ -0,0 +1,54 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + "use strict"; + + var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); } + + MT("variable", + "[variable-2 @base]: [atom #f04615];", + "[qualifier .class] {", + " [property width]: [variable&callee percentage]([number 0.5]); [comment // returns `50%`]", + " [property color]: [variable&callee saturate]([variable-2 @base], [number 5%]);", + "}"); + + MT("amp", + "[qualifier .child], [qualifier .sibling] {", + " [qualifier .parent] [atom &] {", + " [property color]: [keyword black];", + " }", + " [atom &] + [atom &] {", + " [property color]: [keyword red];", + " }", + "}"); + + MT("mixin", + "[qualifier .mixin] ([variable dark]; [variable-2 @color]) {", + " [property color]: [variable&callee darken]([variable-2 @color], [number 10%]);", + "}", + "[qualifier .mixin] ([variable light]; [variable-2 @color]) {", + " [property color]: [variable&callee lighten]([variable-2 @color], [number 10%]);", + "}", + "[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {", + " [property display]: [atom block];", + "}", + "[variable-2 @switch]: [variable light];", + "[qualifier .class] {", + " [qualifier .mixin]([variable-2 @switch]; [atom #888]);", + "}"); + + MT("nest", + "[qualifier .one] {", + " [def @media] ([property width]: [number 400px]) {", + " [property font-size]: [number 1.2em];", + " [def @media] [attribute print] [keyword and] [property color] {", + " [property color]: [keyword blue];", + " }", + " }", + "}"); + + + MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/scss.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/scss.html new file mode 100644 index 0000000..525bab2 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/scss.html @@ -0,0 +1,158 @@ + + +CodeMirror: SCSS mode + + + + + + + + + + +
+

SCSS mode

+
+ + +

The SCSS mode is a sub-mode of the CSS mode (defined in css.js).

+ +

Parsing/Highlighting Tests: normal, verbose.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/scss_test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/scss_test.js new file mode 100644 index 0000000..68afc66 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/scss_test.js @@ -0,0 +1,110 @@ +// 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-scss"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); } + + MT('url_with_quotation', + "[tag foo] { [property background]:[variable&callee url]([string test.jpg]) }"); + + MT('url_with_double_quotes', + "[tag foo] { [property background]:[variable&callee url]([string \"test.jpg\"]) }"); + + MT('url_with_single_quotes', + "[tag foo] { [property background]:[variable&callee url]([string \'test.jpg\']) }"); + + MT('string', + "[def @import] [string \"compass/css3\"]"); + + MT('important_keyword', + "[tag foo] { [property background]:[variable&callee url]([string \'test.jpg\']) [keyword !important] }"); + + MT('variable', + "[variable-2 $blue]:[atom #333]"); + + MT('variable_as_attribute', + "[tag foo] { [property color]:[variable-2 $blue] }"); + + MT('numbers', + "[tag foo] { [property padding]:[number 10px] [number 10] [number 10em] [number 8in] }"); + + MT('number_percentage', + "[tag foo] { [property width]:[number 80%] }"); + + MT('selector', + "[builtin #hello][qualifier .world]{}"); + + MT('singleline_comment', + "[comment // this is a comment]"); + + MT('multiline_comment', + "[comment /*foobar*/]"); + + MT('attribute_with_hyphen', + "[tag foo] { [property font-size]:[number 10px] }"); + + MT('string_after_attribute', + "[tag foo] { [property content]:[string \"::\"] }"); + + MT('directives', + "[def @include] [qualifier .mixin]"); + + MT('basic_structure', + "[tag p] { [property background]:[keyword red]; }"); + + MT('nested_structure', + "[tag p] { [tag a] { [property color]:[keyword red]; } }"); + + MT('mixin', + "[def @mixin] [tag table-base] {}"); + + MT('number_without_semicolon', + "[tag p] {[property width]:[number 12]}", + "[tag a] {[property color]:[keyword red];}"); + + MT('atom_in_nested_block', + "[tag p] { [tag a] { [property color]:[atom #000]; } }"); + + MT('interpolation_in_property', + "[tag foo] { #{[variable-2 $hello]}:[number 2]; }"); + + MT('interpolation_in_selector', + "[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }"); + + MT('interpolation_error', + "[tag foo]#{[variable foo]} { [property color]:[atom #000]; }"); + + MT("divide_operator", + "[tag foo] { [property width]:[number 4] [operator /] [number 2] }"); + + MT('nested_structure_with_id_selector', + "[tag p] { [builtin #hello] { [property color]:[keyword red]; } }"); + + MT('indent_mixin', + "[def @mixin] [tag container] (", + " [variable-2 $a]: [number 10],", + " [variable-2 $b]: [number 10])", + "{}"); + + MT('indent_nested', + "[tag foo] {", + " [tag bar] {", + " }", + "}"); + + MT('indent_parentheses', + "[tag foo] {", + " [property color]: [variable&callee darken]([variable-2 $blue],", + " [number 9%]);", + "}"); + + MT('indent_vardef', + "[variable-2 $name]:", + " [string 'val'];", + "[tag tag] {", + " [tag inner] {", + " [property margin]: [number 3px];", + " }", + "}"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/test.js new file mode 100644 index 0000000..64352d7 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/css/test.js @@ -0,0 +1,217 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "css"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + // Error, because "foobarhello" is neither a known type or property, but + // property was expected (after "and"), and it should be in parentheses. + MT("atMediaUnknownType", + "[def @media] [attribute screen] [keyword and] [error foobarhello] { }"); + + // Soft error, because "foobarhello" is not a known property or type. + MT("atMediaUnknownProperty", + "[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }"); + + // Make sure nesting works with media queries + MT("atMediaMaxWidthNested", + "[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }"); + + MT("atMediaFeatureValueKeyword", + "[def @media] ([property orientation]: [keyword landscape]) { }"); + + MT("atMediaUnknownFeatureValueKeyword", + "[def @media] ([property orientation]: [error upsidedown]) { }"); + + MT("atMediaUppercase", + "[def @MEDIA] ([property orienTAtion]: [keyword landScape]) { }"); + + MT("tagSelector", + "[tag foo] { }"); + + MT("classSelector", + "[qualifier .foo-bar_hello] { }"); + + MT("idSelector", + "[builtin #foo] { [error #foo] }"); + + MT("tagSelectorUnclosed", + "[tag foo] { [property margin]: [number 0] } [tag bar] { }"); + + MT("tagStringNoQuotes", + "[tag foo] { [property font-family]: [variable hello] [variable world]; }"); + + MT("tagStringDouble", + "[tag foo] { [property font-family]: [string \"hello world\"]; }"); + + MT("tagStringSingle", + "[tag foo] { [property font-family]: [string 'hello world']; }"); + + MT("tagColorKeyword", + "[tag foo] {", + " [property color]: [keyword black];", + " [property color]: [keyword navy];", + " [property color]: [keyword yellow];", + "}"); + + MT("tagColorHex3", + "[tag foo] { [property background]: [atom #fff]; }"); + + MT("tagColorHex4", + "[tag foo] { [property background]: [atom #ffff]; }"); + + MT("tagColorHex6", + "[tag foo] { [property background]: [atom #ffffff]; }"); + + MT("tagColorHex8", + "[tag foo] { [property background]: [atom #ffffffff]; }"); + + MT("tagColorHex5Invalid", + "[tag foo] { [property background]: [atom&error #fffff]; }"); + + MT("tagColorHexInvalid", + "[tag foo] { [property background]: [atom&error #ffg]; }"); + + MT("tagNegativeNumber", + "[tag foo] { [property margin]: [number -5px]; }"); + + MT("tagPositiveNumber", + "[tag foo] { [property padding]: [number 5px]; }"); + + MT("tagVendor", + "[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }"); + + MT("tagBogusProperty", + "[tag foo] { [property&error barhelloworld]: [number 0]; }"); + + MT("tagTwoProperties", + "[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }"); + + MT("tagTwoPropertiesURL", + "[tag foo] { [property background]: [variable&callee url]([string //example.com/foo.png]); [property padding]: [number 0]; }"); + + MT("indent_tagSelector", + "[tag strong], [tag em] {", + " [property background]: [variable&callee rgba](", + " [number 255], [number 255], [number 0], [number .2]", + " );", + "}"); + + MT("indent_atMedia", + "[def @media] {", + " [tag foo] {", + " [property color]:", + " [keyword yellow];", + " }", + "}"); + + MT("indent_comma", + "[tag foo] {", + " [property font-family]: [variable verdana],", + " [atom sans-serif];", + "}"); + + MT("indent_parentheses", + "[tag foo]:[variable-3 before] {", + " [property background]: [variable&callee url](", + "[string blahblah]", + "[string etc]", + "[string ]) [keyword !important];", + "}"); + + MT("font_face", + "[def @font-face] {", + " [property font-family]: [string 'myfont'];", + " [error nonsense]: [string 'abc'];", + " [property src]: [variable&callee url]([string http://blah]),", + " [variable&callee url]([string http://foo]);", + "}"); + + MT("empty_url", + "[def @import] [variable&callee url]() [attribute screen];"); + + MT("parens", + "[qualifier .foo] {", + " [property background-image]: [variable&callee fade]([atom #000], [number 20%]);", + " [property border-image]: [variable&callee linear-gradient](", + " [atom to] [atom bottom],", + " [variable&callee fade]([atom #000], [number 20%]) [number 0%],", + " [variable&callee fade]([atom #000], [number 20%]) [number 100%]", + " );", + "}"); + + MT("css_variable", + ":[variable-3 root] {", + " [variable-2 --main-color]: [atom #06c];", + "}", + "[tag h1][builtin #foo] {", + " [property color]: [variable&callee var]([variable-2 --main-color]);", + "}"); + + MT("blank_css_variable", + ":[variable-3 root] {", + " [variable-2 --]: [atom #06c];", + "}", + "[tag h1][builtin #foo] {", + " [property color]: [variable&callee var]([variable-2 --]);", + "}"); + + MT("supports", + "[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {", + " [property text-align-last]: [atom justify];", + "}"); + + MT("document", + "[def @document] [variable&callee url]([string http://blah]),", + " [variable&callee url-prefix]([string https://]),", + " [variable&callee domain]([string blah.com]),", + " [variable&callee regexp]([string \".*blah.+\"]) {", + " [builtin #id] {", + " [property background-color]: [keyword white];", + " }", + " [tag foo] {", + " [property font-family]: [variable Verdana], [atom sans-serif];", + " }", + "}"); + + MT("document_url", + "[def @document] [variable&callee url]([string http://blah]) { [qualifier .class] { } }"); + + MT("document_urlPrefix", + "[def @document] [variable&callee url-prefix]([string https://]) { [builtin #id] { } }"); + + MT("document_domain", + "[def @document] [variable&callee domain]([string blah.com]) { [tag foo] { } }"); + + MT("document_regexp", + "[def @document] [variable&callee regexp]([string \".*blah.+\"]) { [builtin #id] { } }"); + + MT("counter-style", + "[def @counter-style] [variable binary] {", + " [property system]: [atom numeric];", + " [property symbols]: [number 0] [number 1];", + " [property suffix]: [string \".\"];", + " [property range]: [atom infinite];", + " [property speak-as]: [atom numeric];", + "}"); + + MT("counter-style-additive-symbols", + "[def @counter-style] [variable simple-roman] {", + " [property system]: [atom additive];", + " [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];", + " [property range]: [number 1] [number 49];", + "}"); + + MT("counter-style-use", + "[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }"); + + MT("counter-style-symbols", + "[tag ol] { [property list-style]: [variable&callee symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }"); + + MT("comment-does-not-disrupt", + "[def @font-face] [comment /* foo */] {", + " [property src]: [variable&callee url]([string x]);", + " [property font-family]: [variable One];", + "}") +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/cypher.js similarity index 87% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/cypher.js index 9b24900..6d88fa0 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/cypher.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // By the Neo4j Team and contributors. // https://github.com/neo4j-contrib/CodeMirror @@ -21,11 +21,11 @@ var tokenBase = function(stream/*, state*/) { var ch = stream.next(); if (ch ==='"') { - stream.match(/.*?"/); + stream.match(/^[^"]*"/); return "string"; } if (ch === "'") { - stream.match(/.*?'/); + stream.match(/^[^']*'/); return "string"; } if (/[{}\(\),\.;\[\]]/.test(ch)) { @@ -46,7 +46,7 @@ var word = stream.current(); if (funcs.test(word)) return "builtin"; if (preds.test(word)) return "def"; - if (keywords.test(word)) return "keyword"; + if (keywords.test(word) || systemKeywords.test(word)) return "keyword"; return "variable"; } }; @@ -67,6 +67,7 @@ var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]); var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]); var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]); + var systemKeywords = wordRegexp(["access", "active", "assign", "all", "alter", "as", "catalog", "change", "copy", "create", "constraint", "constraints", "current", "database", "databases", "dbms", "default", "deny", "drop", "element", "elements", "exists", "from", "grant", "graph", "graphs", "if", "index", "indexes", "label", "labels", "management", "match", "name", "names", "new", "node", "nodes", "not", "of", "on", "or", "password", "populated", "privileges", "property", "read", "relationship", "relationships", "remove", "replace", "required", "revoke", "role", "roles", "set", "show", "start", "status", "stop", "suspended", "to", "traverse", "type", "types", "user", "users", "with", "write"]); var operatorChars = /[*+\-<>=&|~%^]/; return { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/index.html new file mode 100644 index 0000000..43631d8 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/index.html @@ -0,0 +1,64 @@ + + +CodeMirror: Cypher Mode for CodeMirror + + + + + + + + + + + +
+

Cypher Mode for CodeMirror

+
+ +
+

MIME types defined: + application/x-cypher-query +

+ + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/test.js new file mode 100644 index 0000000..6918355 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/cypher/test.js @@ -0,0 +1,37 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "cypher"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("unbalancedDoubledQuotedString", + "[string \"a'b\"][variable c]"); + + MT("unbalancedSingleQuotedString", + "[string 'a\"b'][variable c]"); + + MT("doubleQuotedString", + "[string \"a\"][variable b]"); + + MT("singleQuotedString", + "[string 'a'][variable b]"); + + MT("single attribute (with content)", + "[node {][atom a:][string 'a'][node }]"); + + MT("multiple attribute, singleQuotedString (with content)", + "[node {][atom a:][string 'a'][node ,][atom b:][string 'b'][node }]"); + + MT("multiple attribute, doubleQuotedString (with content)", + "[node {][atom a:][string \"a\"][node ,][atom b:][string \"b\"][node }]"); + + MT("single attribute (without content)", + "[node {][atom a:][string 'a'][node }]"); + + MT("multiple attribute, singleQuotedString (without content)", + "[node {][atom a:][string ''][node ,][atom b:][string ''][node }]"); + + MT("multiple attribute, doubleQuotedString (without content)", + "[node {][atom a:][string \"\"][node ,][atom b:][string \"\"][node }]"); + })(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/d.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/d.js index 77b09c2..efab570 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/d.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -182,7 +182,12 @@ CodeMirror.defineMode("d", function(config, parserConfig) { else return ctx.indented + (closing ? 0 : indentUnit); }, - electricChars: "{}" + electricChars: "{}", + blockCommentStart: "/*", + blockCommentEnd: "*/", + blockCommentContinue: " * ", + lineComment: "//", + fold: "brace" }; }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/index.html new file mode 100644 index 0000000..a4ea6c8 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/index.html @@ -0,0 +1,273 @@ + + +CodeMirror: D mode + + + + + + + + + + +
+

D mode

+
+ + + +

Simple mode that handle D-Syntax (DLang Homepage).

+ +

MIME types defined: text/x-d + .

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/test.js new file mode 100644 index 0000000..f8ac9de --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/d/test.js @@ -0,0 +1,11 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "d"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("nested_comments", + "[comment /+]","[comment comment]","[comment +/]","[variable void] [variable main](){}"); + +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart/dart.js similarity index 88% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart/dart.js index 4db0d37..fe64517 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart/dart.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -12,13 +12,13 @@ "use strict"; var keywords = ("this super static final const abstract class extends external factory " + - "implements get native set typedef with enum throw rethrow " + + "implements mixin get native set typedef with enum throw rethrow " + "assert break case continue default in return new deferred async await covariant " + "try catch finally do else for if switch while import library export " + - "part of show hide is as").split(" "); + "part of show hide is as extension on yield late required").split(" "); var blockKeywords = "try catch finally do else for if switch while".split(" "); var atoms = "true false null".split(" "); - var builtins = "void bool num int double dynamic var String".split(" "); + var builtins = "void bool num int double dynamic var String Null Never".split(" "); function set(words) { var obj = {}; @@ -78,6 +78,15 @@ if (!stream.eat("*")) return false state.tokenize = tokenNestedComment(1) return state.tokenize(stream, state) + }, + token: function(stream, _, style) { + if (style == "variable") { + // Assume uppercase symbols are classes using variable-2 + var isUpper = RegExp('^[_$]*[A-Z][a-zA-Z0-9_$]*$','g'); + if (isUpper.test(stream.current())) { + return 'variable-2'; + } + } } } }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart/index.html new file mode 100644 index 0000000..277fd21 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dart/index.html @@ -0,0 +1,71 @@ + + +CodeMirror: Dart mode + + + + + + + + + +
+

Dart mode

+
+ +
+ + + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff/diff.js similarity index 94% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff/diff.js index fe0305e..a30fd37 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff/diff.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff/index.html new file mode 100644 index 0000000..fa05230 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/diff/index.html @@ -0,0 +1,117 @@ + + +CodeMirror: Diff mode + + + + + + + + + +
+

Diff mode

+
+ + +

MIME types defined: text/x-diff.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django/django.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django/django.js index 7b4ef3b..07be123 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django/django.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django/index.html new file mode 100644 index 0000000..728493e --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/django/index.html @@ -0,0 +1,73 @@ + + +CodeMirror: Django template mode + + + + + + + + + + + + + +
+

Django template mode

+
+ + + +

Mode for HTML with embedded Django template markup.

+ +

MIME types defined: text/x-django

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/dockerfile.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/dockerfile.js index 9859e33..983170f 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/dockerfile.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -32,7 +32,7 @@ instructionOnlyLine = new RegExp("^(\\s*)" + instructionRegex + "(\\s*)(#.*)?$", "i"), instructionWithArguments = new RegExp("^(\\s*)" + instructionRegex + "(\\s+)", "i"); - CodeMirror.defineMode("dockerfile", { + CodeMirror.defineSimpleMode("dockerfile", { start: [ // Block comment: This is a line starting with a comment { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/index.html new file mode 100644 index 0000000..63ad0e5 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/index.html @@ -0,0 +1,73 @@ + + +CodeMirror: Dockerfile mode + + + + + + + + + + +
+

Dockerfile mode

+
+ + + +

Dockerfile syntax highlighting for CodeMirror. Depends on + the simplemode addon.

+ +

MIME types defined: text/x-dockerfile

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/test.js new file mode 100644 index 0000000..51add3c --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dockerfile/test.js @@ -0,0 +1,128 @@ +// 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-dockerfile"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("simple_nodejs_dockerfile", + "[keyword FROM] node:carbon", + "[comment # Create app directory]", + "[keyword WORKDIR] /usr/src/app", + "[comment # Install app dependencies]", + "[comment # A wildcard is used to ensure both package.json AND package-lock.json are copied]", + "[comment # where available (npm@5+)]", + "[keyword COPY] package*.json ./", + "[keyword RUN] npm install", + "[keyword COPY] . .", + "[keyword EXPOSE] [number 8080] [number 3000]", + "[keyword ENV] NODE_ENV development", + "[keyword CMD] [[ [string \"npm\"], [string \"start\"] ]]"); + + // Ideally the last space should not be highlighted. + MT("instruction_without_args_1", + "[keyword CMD] "); + + MT("instruction_without_args_2", + "[comment # An instruction without args...]", + "[keyword ARG] [error #...is an error]"); + + MT("multiline", + "[keyword RUN] apt-get update && apt-get install -y \\", + " mercurial \\", + " subversion \\", + " && apt-get clean \\", + " && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*"); + + MT("from_comment", + " [keyword FROM] debian:stretch # I tend to use stable as that is more stable", + " [keyword FROM] debian:stretch [keyword AS] stable # I am even more stable", + " [keyword FROM] [error # this is an error]"); + + MT("from_as", + "[keyword FROM] golang:1.9.2-alpine3.6 [keyword AS] build", + "[keyword COPY] --from=build /bin/project /bin/project", + "[keyword ENTRYPOINT] [[ [string \"/bin/project\"] ]]", + "[keyword CMD] [[ [string \"--help\"] ]]"); + + MT("arg", + "[keyword ARG] VERSION=latest", + "[keyword FROM] busybox:$VERSION", + "[keyword ARG] VERSION", + "[keyword RUN] echo $VERSION > image_version"); + + MT("label", + "[keyword LABEL] com.example.label-with-value=[string \"foo\"]"); + + MT("label_multiline", + "[keyword LABEL] description=[string \"This text illustrates ]\\", + "[string that label-values can span multiple lines.\"]"); + + MT("maintainer", + "[keyword MAINTAINER] Foo Bar [string \"foo@bar.com\"] ", + "[keyword MAINTAINER] Bar Baz "); + + MT("env", + "[keyword ENV] BUNDLE_PATH=[string \"$GEM_HOME\"] \\", + " BUNDLE_APP_CONFIG=[string \"$GEM_HOME\"]"); + + MT("verify_keyword", + "[keyword RUN] add-apt-repository ppa:chris-lea/node.js"); + + MT("scripts", + "[comment # Set an entrypoint, to automatically install node modules]", + "[keyword ENTRYPOINT] [[ [string \"/bin/bash\"], [string \"-c\"], [string \"if [[ ! -d node_modules ]]; then npm install; fi; exec \\\"${@:0}\\\";\"] ]]", + "[keyword CMD] npm start", + "[keyword RUN] npm run build && \\", + "[comment # a comment between the shell commands]", + " npm run test"); + + MT("strings_single", + "[keyword FROM] buildpack-deps:stretch", + "[keyword RUN] { \\", + " echo [string 'install: --no-document']; \\", + " echo [string 'update: --no-document']; \\", + " } >> /usr/local/etc/gemrc"); + + MT("strings_single_multiline", + "[keyword RUN] set -ex \\", + " \\", + " && buildDeps=[string ' ]\\", + "[string bison ]\\", + "[string dpkg-dev ]\\", + "[string libgdbm-dev ]\\", + "[string ruby ]\\", + "[string '] \\", + " && apt-get update"); + + MT("strings_single_multiline_2", + "[keyword RUN] echo [string 'say \\' ]\\", + "[string it works'] "); + + MT("strings_double", + "[keyword RUN] apt-get install -y --no-install-recommends $buildDeps \\", + " \\", + " && wget -O ruby.tar.xz [string \"https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz\"] \\", + " && echo [string \"$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz\"] | sha256sum -c - "); + + MT("strings_double_multiline", + "[keyword RUN] echo [string \"say \\\" ]\\", + "[string it works\"] "); + + MT("escape", + "[comment # escape=`]", + "[keyword FROM] microsoft/windowsservercore", + "[keyword RUN] powershell.exe -Command `", + " $ErrorActionPreference = [string 'Stop']; `", + " wget https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -OutFile c:\python-3.5.1.exe ; `", + " Start-Process c:\python-3.5.1.exe -ArgumentList [string '/quiet InstallAllUsers=1 PrependPath=1'] -Wait ; `", + " Remove-Item c:\python-3.5.1.exe -Force)"); + + MT("escape_strings", + "[comment # escape=`]", + "[keyword FROM] python:3.6-windowsservercore [keyword AS] python", + "[keyword RUN] $env:PATH = [string 'C:\\Python;C:\\Python\\Scripts;{0}'] -f $env:PATH ; `", + // It should not consider \' as escaped. + // " Set-ItemProperty -Path [string 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\'] -Name Path -Value $env:PATH ;"); + " Set-ItemProperty -Path [string 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\' -Name Path -Value $env:PATH ;]"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd/dtd.js similarity index 96% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd/dtd.js index 52d76ee..1bff91c 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd/dtd.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /* DTD mode @@ -34,7 +34,7 @@ CodeMirror.defineMode("dtd", function(config) { state.tokenize = inBlock("meta", "?>"); return ret("meta", ch); } else if (ch == "#" && stream.eatWhile(/[\w]/)) return ret("atom", "tag"); - else if (ch == "|") return ret("keyword", "seperator"); + else if (ch == "|") return ret("keyword", "separator"); else if (ch.match(/[\(\)\[\]\-\.,\+\?>]/)) return ret(null, ch);//if(ch === ">") return ret(null, "endtag"); else else if (ch.match(/[\[\]]/)) return ret("rule", ch); else if (ch == "\"" || ch == "'") { @@ -112,7 +112,7 @@ CodeMirror.defineMode("dtd", function(config) { indent: function(state, textAfter) { var n = state.stack.length; - if( textAfter.match(/\]\s+|\]/) )n=n-1; + if( textAfter.charAt(0) === ']' )n--; else if(textAfter.substr(textAfter.length-1, textAfter.length) === ">"){ if(textAfter.substr(0,1) === "<") {} else if( type == "doindent" && textAfter.length > 1 ) {} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd/index.html new file mode 100644 index 0000000..9866942 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dtd/index.html @@ -0,0 +1,89 @@ + + +CodeMirror: DTD mode + + + + + + + + + +
+

DTD mode

+
+ + +

MIME types defined: application/xml-dtd.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/dylan.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/dylan.js index 0acc1a3..6725edc 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/dylan.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/index.html new file mode 100644 index 0000000..fbb8fe5 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/index.html @@ -0,0 +1,407 @@ + + +CodeMirror: Dylan mode + + + + + + + + + + + + +
+

Dylan mode

+ + +
+ + + +

MIME types defined: text/x-dylan.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/test.js new file mode 100644 index 0000000..8b121b9 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/dylan/test.js @@ -0,0 +1,88 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "dylan"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT('comments', + '[comment // This is a line comment]', + '[comment /* This is a block comment */]', + '[comment /* This is a multi]', + '[comment line comment]', + '[comment */]', + '[comment /* And this is a /*]', + '[comment /* nested */ comment */]'); + + MT('unary_operators', + '[operator -][variable a]', + '[operator -] [variable a]', + '[operator ~][variable a]', + '[operator ~] [variable a]'); + + MT('binary_operators', + '[variable a] [operator +] [variable b]', + '[variable a] [operator -] [variable b]', + '[variable a] [operator *] [variable b]', + '[variable a] [operator /] [variable b]', + '[variable a] [operator ^] [variable b]', + '[variable a] [operator =] [variable b]', + '[variable a] [operator ==] [variable b]', + '[variable a] [operator ~=] [variable b]', + '[variable a] [operator ~==] [variable b]', + '[variable a] [operator <] [variable b]', + '[variable a] [operator <=] [variable b]', + '[variable a] [operator >] [variable b]', + '[variable a] [operator >=] [variable b]', + '[variable a] [operator &] [variable b]', + '[variable a] [operator |] [variable b]', + '[variable a] [operator :=] [variable b]'); + + MT('integers', + '[number 1]', + '[number 123]', + '[number -123]', + '[number +456]', + '[number #b010]', + '[number #o073]', + '[number #xabcDEF123]'); + + MT('floats', + '[number .3]', + '[number -1.]', + '[number -2.335]', + '[number +3.78d1]', + '[number 3.78s-1]', + '[number -3.32e+5]'); + + MT('characters_and_strings', + "[string 'a']", + "[string '\\\\'']", + '[string ""]', + '[string "a"]', + '[string "abc def"]', + '[string "More escaped characters: \\\\\\\\ \\\\a \\\\b \\\\e \\\\f \\\\n \\\\r \\\\t \\\\0 ..."]'); + + MT('brackets', + '[bracket #[[]]]', + '[bracket #()]', + '[bracket #(][number 1][bracket )]', + '[bracket [[][number 1][punctuation ,] [number 3][bracket ]]]', + '[bracket ()]', + '[bracket {}]', + '[keyword if] [bracket (][variable foo][bracket )]', + '[bracket (][number 1][bracket )]', + '[bracket [[][number 1][bracket ]]]'); + + MT('hash_words', + '[punctuation ##]', + '[atom #f]', '[atom #F]', + '[atom #t]', '[atom #T]', + '[atom #all-keys]', + '[atom #include]', + '[atom #key]', + '[atom #next]', + '[atom #rest]', + '[string #"foo"]', + '[error #invalid]'); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf/ebnf.js similarity index 93% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf/ebnf.js index 9618f8e..d8fb3f3 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf/ebnf.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -41,10 +41,10 @@ state.stringType = stream.peek(); stream.next(); // Skip quote state.stack.unshift(stateType._string); - } else if (stream.match(/^\/\*/)) { //comments starting with /* + } else if (stream.match('/*')) { //comments starting with /* state.stack.unshift(stateType.comment); state.commentType = commentType.slash; - } else if (stream.match(/^\(\*/)) { //comments starting with (* + } else if (stream.match('(*')) { //comments starting with (* state.stack.unshift(stateType.comment); state.commentType = commentType.parenthesis; } @@ -69,10 +69,10 @@ case stateType.comment: while (state.stack[0] === stateType.comment && !stream.eol()) { - if (state.commentType === commentType.slash && stream.match(/\*\//)) { + if (state.commentType === commentType.slash && stream.match('*/')) { state.stack.shift(); // Clear flag state.commentType = null; - } else if (state.commentType === commentType.parenthesis && stream.match(/\*\)/)) { + } else if (state.commentType === commentType.parenthesis && stream.match('*)')) { state.stack.shift(); // Clear flag state.commentType = null; } else { @@ -83,7 +83,7 @@ case stateType.characterClass: while (state.stack[0] === stateType.characterClass && !stream.eol()) { - if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) { + if (!(stream.match(/^[^\]\\]+/) || stream.match('.'))) { state.stack.shift(); } } @@ -168,10 +168,10 @@ } } - if (stream.match(/^\/\//)) { + if (stream.match('//')) { stream.skipToEnd(); return "comment"; - } else if (stream.match(/return/)) { + } else if (stream.match('return')) { return "operator"; } else if (stream.match(/^[a-zA-Z_][a-zA-Z0-9_]*/)) { if (stream.match(/(?=[\(.])/)) { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf/index.html new file mode 100644 index 0000000..70d6873 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ebnf/index.html @@ -0,0 +1,102 @@ + + + + CodeMirror: EBNF Mode + + + + + + + + + + + + +
+

EBNF Mode (bracesMode setting = "javascript")

+
+ +

The EBNF Mode

+

Created by Robert Plummer

+
+ + diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl/ecl.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl/ecl.js index 8df7ebe..9af8aee 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl/ecl.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl/index.html new file mode 100644 index 0000000..c8b1384 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ecl/index.html @@ -0,0 +1,52 @@ + + +CodeMirror: ECL mode + + + + + + + + + +
+

ECL mode

+
+ + +

Based on CodeMirror's clike mode. For more information see HPCC Systems web site.

+

MIME types defined: text/x-ecl.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel/eiffel.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel/eiffel.js index b8b70e3..f6f3f45 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel/eiffel.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel/index.html new file mode 100644 index 0000000..0a431cc --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/eiffel/index.html @@ -0,0 +1,429 @@ + + +CodeMirror: Eiffel mode + + + + + + + + + + +
+

Eiffel mode

+
+ + +

MIME types defined: text/x-eiffel.

+ +

Created by YNH.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm.js deleted file mode 100644 index 9fcfc88..0000000 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm.js +++ /dev/null @@ -1,205 +0,0 @@ -// 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("elm", function() { - - function switchState(source, setState, f) { - setState(f); - return f(source, setState); - } - - // These should all be Unicode extended, as per the Haskell 2010 report - var smallRE = /[a-z_]/; - var largeRE = /[A-Z]/; - var digitRE = /[0-9]/; - var hexitRE = /[0-9A-Fa-f]/; - var octitRE = /[0-7]/; - var idRE = /[a-z_A-Z0-9\']/; - var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]/; - var specialRE = /[(),;[\]`{}]/; - var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer - - function normal() { - return function (source, setState) { - if (source.eatWhile(whiteCharRE)) { - return null; - } - - var ch = source.next(); - if (specialRE.test(ch)) { - if (ch == '{' && source.eat('-')) { - var t = "comment"; - if (source.eat('#')) t = "meta"; - return switchState(source, setState, ncomment(t, 1)); - } - return null; - } - - if (ch == '\'') { - if (source.eat('\\')) - source.next(); // should handle other escapes here - else - source.next(); - - if (source.eat('\'')) - return "string"; - return "error"; - } - - if (ch == '"') { - return switchState(source, setState, stringLiteral); - } - - if (largeRE.test(ch)) { - source.eatWhile(idRE); - if (source.eat('.')) - return "qualifier"; - return "variable-2"; - } - - if (smallRE.test(ch)) { - var isDef = source.pos === 1; - source.eatWhile(idRE); - return isDef ? "type" : "variable"; - } - - if (digitRE.test(ch)) { - if (ch == '0') { - if (source.eat(/[xX]/)) { - source.eatWhile(hexitRE); // should require at least 1 - return "integer"; - } - if (source.eat(/[oO]/)) { - source.eatWhile(octitRE); // should require at least 1 - return "number"; - } - } - source.eatWhile(digitRE); - var t = "number"; - if (source.eat('.')) { - t = "number"; - source.eatWhile(digitRE); // should require at least 1 - } - if (source.eat(/[eE]/)) { - t = "number"; - source.eat(/[-+]/); - source.eatWhile(digitRE); // should require at least 1 - } - return t; - } - - if (symbolRE.test(ch)) { - if (ch == '-' && source.eat(/-/)) { - source.eatWhile(/-/); - if (!source.eat(symbolRE)) { - source.skipToEnd(); - return "comment"; - } - } - source.eatWhile(symbolRE); - return "builtin"; - } - - return "error"; - } - } - - function ncomment(type, nest) { - if (nest == 0) { - return normal(); - } - return function(source, setState) { - var currNest = nest; - while (!source.eol()) { - var ch = source.next(); - if (ch == '{' && source.eat('-')) { - ++currNest; - } else if (ch == '-' && source.eat('}')) { - --currNest; - if (currNest == 0) { - setState(normal()); - return type; - } - } - } - setState(ncomment(type, currNest)); - return type; - } - } - - function stringLiteral(source, setState) { - while (!source.eol()) { - var ch = source.next(); - if (ch == '"') { - setState(normal()); - return "string"; - } - if (ch == '\\') { - if (source.eol() || source.eat(whiteCharRE)) { - setState(stringGap); - return "string"; - } - if (!source.eat('&')) source.next(); // should handle other escapes here - } - } - setState(normal()); - return "error"; - } - - function stringGap(source, setState) { - if (source.eat('\\')) { - return switchState(source, setState, stringLiteral); - } - source.next(); - setState(normal()); - return "error"; - } - - - var wellKnownWords = (function() { - var wkw = {}; - - var keywords = [ - "case", "of", "as", - "if", "then", "else", - "let", "in", - "infix", "infixl", "infixr", - "type", "alias", - "input", "output", "foreign", "loopback", - "module", "where", "import", "exposing", - "_", "..", "|", ":", "=", "\\", "\"", "->", "<-" - ]; - - for (var i = keywords.length; i--;) - wkw[keywords[i]] = "keyword"; - - return wkw; - })(); - - - - return { - startState: function () { return { f: normal() }; }, - copyState: function (s) { return { f: s.f }; }, - - token: function(stream, state) { - var t = state.f(stream, function(s) { state.f = s; }); - var w = stream.current(); - return (wellKnownWords.hasOwnProperty(w)) ? wellKnownWords[w] : t; - } - }; - - }); - - CodeMirror.defineMIME("text/x-elm", "elm"); -}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm/elm.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm/elm.js new file mode 100644 index 0000000..6ce940f --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm/elm.js @@ -0,0 +1,243 @@ +// 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("elm", function() { + + function switchState(source, setState, f) + { + setState(f); + return f(source, setState); + } + + var lowerRE = /[a-z]/; + var upperRE = /[A-Z]/; + var innerRE = /[a-zA-Z0-9_]/; + + var digitRE = /[0-9]/; + var hexRE = /[0-9A-Fa-f]/; + var symbolRE = /[-&*+.\\/<>=?^|:]/; + var specialRE = /[(),[\]{}]/; + var spacesRE = /[ \v\f]/; // newlines are handled in tokenizer + + function normal() + { + return function(source, setState) + { + if (source.eatWhile(spacesRE)) + { + return null; + } + + var char = source.next(); + + if (specialRE.test(char)) + { + return (char === '{' && source.eat('-')) + ? switchState(source, setState, chompMultiComment(1)) + : (char === '[' && source.match('glsl|')) + ? switchState(source, setState, chompGlsl) + : 'builtin'; + } + + if (char === '\'') + { + return switchState(source, setState, chompChar); + } + + if (char === '"') + { + return source.eat('"') + ? source.eat('"') + ? switchState(source, setState, chompMultiString) + : 'string' + : switchState(source, setState, chompSingleString); + } + + if (upperRE.test(char)) + { + source.eatWhile(innerRE); + return 'variable-2'; + } + + if (lowerRE.test(char)) + { + var isDef = source.pos === 1; + source.eatWhile(innerRE); + return isDef ? "def" : "variable"; + } + + if (digitRE.test(char)) + { + if (char === '0') + { + if (source.eat(/[xX]/)) + { + source.eatWhile(hexRE); // should require at least 1 + return "number"; + } + } + else + { + source.eatWhile(digitRE); + } + if (source.eat('.')) + { + source.eatWhile(digitRE); // should require at least 1 + } + if (source.eat(/[eE]/)) + { + source.eat(/[-+]/); + source.eatWhile(digitRE); // should require at least 1 + } + return "number"; + } + + if (symbolRE.test(char)) + { + if (char === '-' && source.eat('-')) + { + source.skipToEnd(); + return "comment"; + } + source.eatWhile(symbolRE); + return "keyword"; + } + + if (char === '_') + { + return "keyword"; + } + + return "error"; + } + } + + function chompMultiComment(nest) + { + if (nest == 0) + { + return normal(); + } + return function(source, setState) + { + while (!source.eol()) + { + var char = source.next(); + if (char == '{' && source.eat('-')) + { + ++nest; + } + else if (char == '-' && source.eat('}')) + { + --nest; + if (nest === 0) + { + setState(normal()); + return 'comment'; + } + } + } + setState(chompMultiComment(nest)); + return 'comment'; + } + } + + function chompMultiString(source, setState) + { + while (!source.eol()) + { + var char = source.next(); + if (char === '"' && source.eat('"') && source.eat('"')) + { + setState(normal()); + return 'string'; + } + } + return 'string'; + } + + function chompSingleString(source, setState) + { + while (source.skipTo('\\"')) { source.next(); source.next(); } + if (source.skipTo('"')) + { + source.next(); + setState(normal()); + return 'string'; + } + source.skipToEnd(); + setState(normal()); + return 'error'; + } + + function chompChar(source, setState) + { + while (source.skipTo("\\'")) { source.next(); source.next(); } + if (source.skipTo("'")) + { + source.next(); + setState(normal()); + return 'string'; + } + source.skipToEnd(); + setState(normal()); + return 'error'; + } + + function chompGlsl(source, setState) + { + while (!source.eol()) + { + var char = source.next(); + if (char === '|' && source.eat(']')) + { + setState(normal()); + return 'string'; + } + } + return 'string'; + } + + var wellKnownWords = { + case: 1, + of: 1, + as: 1, + if: 1, + then: 1, + else: 1, + let: 1, + in: 1, + type: 1, + alias: 1, + module: 1, + where: 1, + import: 1, + exposing: 1, + port: 1 + }; + + return { + startState: function () { return { f: normal() }; }, + copyState: function (s) { return { f: s.f }; }, + + token: function(stream, state) { + var type = state.f(stream, function(s) { state.f = s; }); + var word = stream.current(); + return (wellKnownWords.hasOwnProperty(word)) ? 'keyword' : type; + } + }; + + }); + + CodeMirror.defineMIME("text/x-elm", "elm"); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm/index.html new file mode 100644 index 0000000..004b1d4 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/elm/index.html @@ -0,0 +1,61 @@ + + +CodeMirror: Elm mode + + + + + + + + + +
+

Elm mode

+ +
+ + + +

MIME types defined: text/x-elm.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang/erlang.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang/erlang.js index 9528e19..f0541bb 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang/erlang.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /*jshint unused:true, eqnull:true, curly:true, bitwise:true */ /*jshint undef:true, latedef:true, trailing:true */ diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang/index.html new file mode 100644 index 0000000..0462dd9 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/erlang/index.html @@ -0,0 +1,76 @@ + + +CodeMirror: Erlang mode + + + + + + + + + + + +
+

Erlang mode

+
+ + + +

MIME types defined: text/x-erlang.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor/factor.js similarity index 95% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor/factor.js index ce26877..4c876d4 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor/factor.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Factor syntax highlight - simple mode // @@ -15,8 +15,8 @@ })(function(CodeMirror) { "use strict"; - CodeMirror.defineMode("factor", { - // The start state contains the rules that are intially used + CodeMirror.defineSimpleMode("factor", { + // The start state contains the rules that are initially used start: [ // comments {regex: /#?!.*/, token: "comment"}, diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor/index.html new file mode 100644 index 0000000..6a77230 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/factor/index.html @@ -0,0 +1,77 @@ + + +CodeMirror: Factor mode + + + + + + + + + + + +
+ +

Factor mode

+ +
+
+ + +

+

Simple mode that handles Factor Syntax (Factor on Wikipedia).

+ +

MIME types defined: text/x-factor.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl/fcl.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl/fcl.js index 5181169..2d3f200 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl/fcl.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl/index.html new file mode 100644 index 0000000..9194dfd --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fcl/index.html @@ -0,0 +1,108 @@ + + +CodeMirror: FCL mode + + + + + + + + + + + +
+

FCL mode

+
+ + + +

MIME type: text/x-fcl

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth/forth.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth/forth.js index 1f519d8..f2caa27 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth/forth.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Author: Aliaksei Chapyzhenka diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth/index.html new file mode 100644 index 0000000..6b6477c --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/forth/index.html @@ -0,0 +1,75 @@ + + +CodeMirror: Forth mode + + + + + + + + + + + +
+ +

Forth mode

+ +
+
+ + + +

Simple mode that handle Forth-Syntax (Forth on Wikipedia).

+ +

MIME types defined: text/x-forth.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran/fortran.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran/fortran.js index 4d88f00..85bacc4 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran/fortran.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran/index.html new file mode 100644 index 0000000..1dd4564 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/fortran/index.html @@ -0,0 +1,81 @@ + + +CodeMirror: Fortran mode + + + + + + + + + +
+

Fortran mode

+ + +
+ + + +

MIME types defined: text/x-fortran.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas/gas.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas/gas.js index 0c74bed..b3515ab 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas/gas.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -302,11 +302,11 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) { } if (ch === '{') { - return "braket"; + return "bracket"; } if (ch === '}') { - return "braket"; + return "bracket"; } if (/\d/.test(ch)) { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas/index.html new file mode 100644 index 0000000..c8a89b2 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gas/index.html @@ -0,0 +1,68 @@ + + +CodeMirror: Gas mode + + + + + + + + + +
+

Gas mode

+
+ +
+ + + +

Handles AT&T assembler syntax (more specifically this handles + the GNU Assembler (gas) syntax.) + It takes a single optional configuration parameter: + architecture, which can be one of "ARM", + "ARMv6" or "x86". + Including the parameter adds syntax for the registers and special + directives for the supplied architecture. + +

MIME types defined: text/x-gas

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/gfm.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/gfm.js index 471ae90..492c948 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/gfm.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/index.html new file mode 100644 index 0000000..7d2f38b --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/index.html @@ -0,0 +1,136 @@ + + +CodeMirror: GFM mode + + + + + + + + + + + + + + + + + +
+

GFM mode

+
+ + + +

Optionally depends on other modes for properly highlighted code blocks.

+ +

Gfm mode supports these options (apart those from base Markdown mode):

+
    +
  • + +
    gitHubSpice: boolean
    +
    Hashes, issues... (default: true).
    +
    +
  • +
  • + +
    taskLists: boolean
    +
    - [ ] syntax (default: true).
    +
    +
  • +
  • + +
    strikethrough: boolean
    +
    ~~foo~~ syntax (default: true).
    +
    +
  • +
  • + +
    emoji: boolean
    +
    :emoji: syntax (default: true).
    +
    +
  • +
+ +

Parsing/Highlighting Tests: normal, verbose.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/test.js new file mode 100644 index 0000000..e200287 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gfm/test.js @@ -0,0 +1,198 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var config = {tabSize: 4, indentUnit: 2} + var mode = CodeMirror.getMode(config, "gfm"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + var modeHighlightFormatting = CodeMirror.getMode(config, {name: "gfm", highlightFormatting: true}); + function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); } + + FT("codeBackticks", + "[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]"); + + FT("doubleBackticks", + "[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]"); + + FT("taskList", + "[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]", + "[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]"); + + FT("formatting_strikethrough", + "[strikethrough&formatting&formatting-strikethrough ~~][strikethrough foo][strikethrough&formatting&formatting-strikethrough ~~]"); + + FT("formatting_strikethrough", + "foo [strikethrough&formatting&formatting-strikethrough ~~][strikethrough bar][strikethrough&formatting&formatting-strikethrough ~~]"); + + FT("formatting_emoji", + "foo [builtin&formatting&formatting-emoji :smile:] foo"); + + MT("emInWordAsterisk", + "foo[em *bar*]hello"); + + MT("emInWordUnderscore", + "foo_bar_hello"); + + MT("emStrongUnderscore", + "[em&strong ___foo___] bar"); + + MT("taskListAsterisk", + "[variable-2 * ][link&variable-2 [[]]][variable-2 foo]", // Invalid; must have space or x between [] + "[variable-2 * ][link&variable-2 [[ ]]][variable-2 bar]", // Invalid; must have space after ] + "[variable-2 * ][link&variable-2 [[x]]][variable-2 hello]", // Invalid; must have space after ] + "[variable-2 * ][meta [ ]]][variable-2 ][link&variable-2 [[world]]]", // Valid; tests reference style links + " [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested + + MT("taskListPlus", + "[variable-2 + ][link&variable-2 [[]]][variable-2 foo]", // Invalid; must have space or x between [] + "[variable-2 + ][link&variable-2 [[x]]][variable-2 hello]", // Invalid; must have space after ] + "[variable-2 + ][meta [ ]]][variable-2 ][link&variable-2 [[world]]]", // Valid; tests reference style links + " [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested + + MT("taskListDash", + "[variable-2 - ][link&variable-2 [[]]][variable-2 foo]", // Invalid; must have space or x between [] + "[variable-2 - ][link&variable-2 [[x]]][variable-2 hello]", // Invalid; must have space after ] + "[variable-2 - ][meta [ ]]][variable-2 world]", // Valid; tests reference style links + " [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested + + MT("taskListNumber", + "[variable-2 1. ][link&variable-2 [[]]][variable-2 foo]", // Invalid; must have space or x between [] + "[variable-2 2. ][link&variable-2 [[ ]]][variable-2 bar]", // Invalid; must have space after ] + "[variable-2 3. ][meta [ ]]][variable-2 world]", // Valid; tests reference style links + " [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested + + MT("SHA", + "foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar"); + + MT("SHAEmphasis", + "[em *foo ][em&link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]"); + + MT("shortSHA", + "foo [link be6a8cc] bar"); + + MT("tooShortSHA", + "foo be6a8c bar"); + + MT("longSHA", + "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar"); + + MT("badSHA", + "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar"); + + MT("userSHA", + "foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello"); + + MT("userSHAEmphasis", + "[em *foo ][em&link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]"); + + MT("userProjectSHA", + "foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world"); + + MT("userProjectSHAEmphasis", + "[em *foo ][em&link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]"); + + MT("wordSHA", + "ask for feedback") + + MT("num", + "foo [link #1] bar"); + + MT("numEmphasis", + "[em *foo ][em&link #1][em *]"); + + MT("badNum", + "foo #1bar hello"); + + MT("userNum", + "foo [link bar#1] hello"); + + MT("userNumEmphasis", + "[em *foo ][em&link bar#1][em *]"); + + MT("userProjectNum", + "foo [link bar/hello#1] world"); + + MT("userProjectNumEmphasis", + "[em *foo ][em&link bar/hello#1][em *]"); + + MT("vanillaLink", + "foo [link http://www.example.com/] bar"); + + MT("vanillaLinkNoScheme", + "foo [link www.example.com] bar"); + + MT("vanillaLinkHttps", + "foo [link https://www.example.com/] bar"); + + MT("vanillaLinkDataSchema", + "foo [link data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==] bar"); + + MT("vanillaLinkPunctuation", + "foo [link http://www.example.com/]. bar"); + + MT("vanillaLinkExtension", + "foo [link http://www.example.com/index.html] bar"); + + MT("vanillaLinkEmphasis", + "foo [em *][em&link http://www.example.com/index.html][em *] bar"); + + MT("notALink", + "foo asfd:asdf bar"); + + MT("notALink", + "[comment ``foo `bar` http://www.example.com/``] hello"); + + MT("notALink", + "[comment `foo]", + "[comment&link http://www.example.com/]", + "[comment `] foo", + "", + "[link http://www.example.com/]"); + + MT("strikethrough", + "[strikethrough ~~foo~~]"); + + MT("strikethroughWithStartingSpace", + "~~ foo~~"); + + MT("strikethroughUnclosedStrayTildes", + "[strikethrough ~~foo~~~]"); + + MT("strikethroughUnclosedStrayTildes", + "[strikethrough ~~foo ~~]"); + + MT("strikethroughUnclosedStrayTildes", + "[strikethrough ~~foo ~~ bar]"); + + MT("strikethroughUnclosedStrayTildes", + "[strikethrough ~~foo ~~ bar~~]hello"); + + MT("strikethroughOneLetter", + "[strikethrough ~~a~~]"); + + MT("strikethroughWrapped", + "[strikethrough ~~foo]", + "[strikethrough foo~~]"); + + MT("strikethroughParagraph", + "[strikethrough ~~foo]", + "", + "foo[strikethrough ~~bar]"); + + MT("strikethroughEm", + "[strikethrough ~~foo][em&strikethrough *bar*][strikethrough ~~]"); + + MT("strikethroughEm", + "[em *][em&strikethrough ~~foo~~][em *]"); + + MT("strikethroughStrong", + "[strikethrough ~~][strong&strikethrough **foo**][strikethrough ~~]"); + + MT("strikethroughStrong", + "[strong **][strong&strikethrough ~~foo~~][strong **]"); + + MT("emoji", + "text [builtin :blush:] text [builtin :v:] text [builtin :+1:] text", + ":text text: [builtin :smiley_cat:]"); + +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin/gherkin.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin/gherkin.js index fc2ebee..1b438b9 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin/gherkin.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /* Gherkin mode - http://www.cukes.info/ diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin/index.html new file mode 100644 index 0000000..e51a00c --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/gherkin/index.html @@ -0,0 +1,48 @@ + + +CodeMirror: Gherkin mode + + + + + + + + + +
+

Gherkin mode

+
+ + +

MIME types defined: text/x-feature.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go/go.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go/go.js index 36131f1..c005e42 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go/go.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go/index.html new file mode 100644 index 0000000..10ec024 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/go/index.html @@ -0,0 +1,85 @@ + + +CodeMirror: Go mode + + + + + + + + + + + +
+

Go mode

+
+ + + +

MIME type: text/x-go

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy/groovy.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy/groovy.js index 0df97dd..2b90d01 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy/groovy.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -221,7 +221,10 @@ CodeMirror.defineMode("groovy", function(config) { electricChars: "{}", closeBrackets: {triples: "'\""}, - fold: "brace" + fold: "brace", + blockCommentStart: "/*", + blockCommentEnd: "*/", + lineComment: "//" }; }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy/index.html new file mode 100644 index 0000000..9d40fb8 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/groovy/index.html @@ -0,0 +1,84 @@ + + +CodeMirror: Groovy mode + + + + + + + + + + +
+

Groovy mode

+
+ + + +

MIME types defined: text/x-groovy

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/haml.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/haml.js index 20ae1e1..d941d97 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/haml.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -72,7 +72,7 @@ } } - // donot handle --> as valid ruby, make it HTML close comment instead + // do not handle --> as valid ruby, make it HTML close comment instead if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) { state.tokenize = ruby; return state.tokenize(stream, state); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/index.html new file mode 100644 index 0000000..ac1348d --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/index.html @@ -0,0 +1,79 @@ + + +CodeMirror: HAML mode + + + + + + + + + + + + + +
+

HAML mode

+
+ + +

MIME types defined: text/x-haml.

+ +

Parsing/Highlighting Tests: normal, verbose.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/test.js new file mode 100644 index 0000000..e051452 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haml/test.js @@ -0,0 +1,97 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "haml"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + // Requires at least one media query + MT("elementName", + "[tag %h1] Hey There"); + + MT("oneElementPerLine", + "[tag %h1] Hey There %h2"); + + MT("idSelector", + "[tag %h1][attribute #test] Hey There"); + + MT("classSelector", + "[tag %h1][attribute .hello] Hey There"); + + MT("docType", + "[tag !!! XML]"); + + MT("comment", + "[comment / Hello WORLD]"); + + MT("notComment", + "[tag %h1] This is not a / comment "); + + MT("attributes", + "[tag %a]([variable title][operator =][string \"test\"]){[atom :title] [operator =>] [string \"test\"]}"); + + MT("htmlCode", + "[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket ]"); + + MT("rubyBlock", + "[operator =][variable-2 @item]"); + + MT("selectorRubyBlock", + "[tag %a.selector=] [variable-2 @item]"); + + MT("nestedRubyBlock", + "[tag %a]", + " [operator =][variable puts] [string \"test\"]"); + + MT("multilinePlaintext", + "[tag %p]", + " Hello,", + " World"); + + MT("multilineRuby", + "[tag %p]", + " [comment -# this is a comment]", + " [comment and this is a comment too]", + " Date/Time", + " [operator -] [variable now] [operator =] [tag DateTime][operator .][property now]", + " [tag %strong=] [variable now]", + " [operator -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])", + " [operator =][string \"Happy\"]", + " [operator =][string \"Belated\"]", + " [operator =][string \"Birthday\"]"); + + MT("multilineComment", + "[comment /]", + " [comment Multiline]", + " [comment Comment]"); + + MT("hamlComment", + "[comment -# this is a comment]"); + + MT("multilineHamlComment", + "[comment -# this is a comment]", + " [comment and this is a comment too]"); + + MT("multilineHTMLComment", + "[comment ]"); + + MT("hamlAfterRubyTag", + "[attribute .block]", + " [tag %strong=] [variable now]", + " [attribute .test]", + " [operator =][variable now]", + " [attribute .right]"); + + MT("stretchedRuby", + "[operator =] [variable puts] [string \"Hello\"],", + " [string \"World\"]"); + + MT("interpolationInHashAttribute", + //"[tag %div]{[atom :id] [operator =>] [string \"#{][variable test][string }_#{][variable ting][string }\"]} test"); + "[tag %div]{[atom :id] [operator =>] [string \"#{][variable test][string }_#{][variable ting][string }\"]} test"); + + MT("interpolationInHTMLAttribute", + "[tag %div]([variable title][operator =][string \"#{][variable test][string }_#{][variable ting]()[string }\"]) Test"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars/handlebars.js similarity index 85% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars/handlebars.js index 9f80f24..359871a 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars/handlebars.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -11,12 +11,16 @@ })(function(CodeMirror) { "use strict"; - CodeMirror.defineMode("handlebars-tags", { + CodeMirror.defineSimpleMode("handlebars-tags", { start: [ + { regex: /\{\{\{/, push: "handlebars_raw", token: "tag" }, { regex: /\{\{!--/, push: "dash_comment", token: "comment" }, { regex: /\{\{!/, push: "comment", token: "comment" }, { regex: /\{\{/, push: "handlebars", token: "tag" } ], + handlebars_raw: [ + { regex: /\}\}\}/, pop: true, token: "tag" }, + ], handlebars: [ { regex: /\}\}/, pop: true, token: "tag" }, @@ -58,7 +62,7 @@ if (!parserConfig || !parserConfig.base) return handlebars; return CodeMirror.multiplexingMode( CodeMirror.getMode(config, parserConfig.base), - {open: "{{", close: "}}", mode: handlebars, parseDelimiters: true} + {open: "{{", close: /\}\}\}?/, mode: handlebars, parseDelimiters: true} ); }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars/index.html new file mode 100644 index 0000000..1b5f628 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/handlebars/index.html @@ -0,0 +1,82 @@ + + +CodeMirror: Handlebars mode + + + + + + + + + + + + + +
+

Handlebars

+
+ + +

Handlebars syntax highlighting for CodeMirror.

+ +

MIME types defined: text/x-handlebars-template

+ +

Supported options: base to set the mode to + wrap. For example, use

+
mode: {name: "handlebars", base: "text/html"}
+

to highlight an HTML template.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate/haskell-literate.js similarity index 95% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate/haskell-literate.js index 906415b..4bb9268 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate/haskell-literate.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function (mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate/index.html new file mode 100644 index 0000000..aa3f3ea --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell-literate/index.html @@ -0,0 +1,282 @@ + + +CodeMirror: Haskell-literate mode + + + + + + + + + + +
+

Haskell literate mode

+
+ +
+ +

MIME types + defined: text/x-literate-haskell.

+ +

Parser configuration parameters recognized: base to + set the base mode (defaults to "haskell").

+ + + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell/haskell.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell/haskell.js index acc52b5..2e882dc 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell/haskell.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell/index.html new file mode 100644 index 0000000..598cbb5 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haskell/index.html @@ -0,0 +1,73 @@ + + +CodeMirror: Haskell mode + + + + + + + + + + + +
+

Haskell mode

+
+ + + +

MIME types defined: text/x-haskell.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe/haxe.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe/haxe.js index d159d08..4537685 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe/haxe.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe/index.html new file mode 100644 index 0000000..65e31f4 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/haxe/index.html @@ -0,0 +1,124 @@ + + +CodeMirror: Haxe mode + + + + + + + + + +
+

Haxe mode

+ + +

+ +

Hxml mode:

+ +

+
+ + + +

MIME types defined: text/x-haxe, text/x-hxml.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded/htmlembedded.js similarity index 96% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded/htmlembedded.js index 8099d37..439e63a 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded/htmlembedded.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded/index.html new file mode 100644 index 0000000..d17afec --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlembedded/index.html @@ -0,0 +1,60 @@ + + +CodeMirror: Html Embedded Scripts mode + + + + + + + + + + + + + + +
+

Html Embedded Scripts mode

+
+ + + +

Mode for html embedded scripts like JSP and ASP.NET. Depends on multiplex and HtmlMixed which in turn depends on + JavaScript, CSS and XML.
Other dependencies include those of the scripting language chosen.

+ +

MIME types defined: application/x-aspx (ASP.NET), + application/x-ejs (Embedded JavaScript), application/x-jsp (JavaServer Pages) + and application/x-erb

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed/htmlmixed.js similarity index 95% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed/htmlmixed.js index 33398ec..66a1582 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed/htmlmixed.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -74,7 +74,8 @@ name: "xml", htmlMode: true, multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, - multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag + multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag, + allowMissingTagName: parserConfig.allowMissingTagName, }); var tags = {}; @@ -105,7 +106,7 @@ return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState)); }; state.localMode = mode; - state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "")); + state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", "")); } else if (state.inTag) { state.inTag += stream.current() if (stream.eol()) state.inTag += " " @@ -135,7 +136,7 @@ indent: function (state, textAfter, line) { if (!state.localMode || /^\s*<\//.test(textAfter)) - return htmlMode.indent(state.htmlState, textAfter); + return htmlMode.indent(state.htmlState, textAfter, line); else if (state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line); else diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed/index.html new file mode 100644 index 0000000..c70bf16 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/htmlmixed/index.html @@ -0,0 +1,100 @@ + + +CodeMirror: HTML mixed mode + + + + + + + + + + + + + + +
+

HTML mixed mode

+
+ + +

The HTML mixed mode depends on the XML, JavaScript, and CSS modes.

+ +

It takes an optional mode configuration + option, tags, which can be used to add custom + behavior for specific tags. When given, it should be an object + mapping tag names (for example script) to arrays or + three-element arrays. Those inner arrays indicate [attributeName, + valueRegexp, modeSpec] + specifications. For example, you could use ["type", /^foo$/, + "foo"] to map the attribute type="foo" to + the foo mode. When the first two fields are null + ([null, null, "mode"]), the given mode is used for + any such tag that doesn't match any of the previously given + attributes. For example:

+ +
var myModeSpec = {
+  name: "htmlmixed",
+  tags: {
+    style: [["type", /^text\/(x-)?scss$/, "text/x-scss"],
+            [null, null, "css"]],
+    custom: [[null, null, "customMode"]]
+  }
+}
+ +

MIME types defined: text/html + (redefined, only takes effect if you load this parser after the + XML parser).

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http/http.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http/http.js index 9a3c5f9..0923532 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http/http.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http/index.html new file mode 100644 index 0000000..80d585e --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/http/index.html @@ -0,0 +1,45 @@ + + +CodeMirror: HTTP mode + + + + + + + + + +
+

HTTP mode

+ + +
+ + + +

MIME types defined: message/http.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl/idl.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl/idl.js index 07308d7..37302bb 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl/idl.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -62,7 +62,7 @@ 'empty', 'enable_sysrtn', 'eof', 'eos', 'erase', 'erf', 'erfc', 'erfcx', 'erode', 'errorplot', 'errplot', 'estimator_filter', 'execute', 'exit', 'exp', - 'expand', 'expand_path', 'expint', 'extrac', 'extract_slice', + 'expand', 'expand_path', 'expint', 'extract', 'extract_slice', 'f_cvf', 'f_pdf', 'factorial', 'fft', 'file_basename', 'file_chmod', 'file_copy', 'file_delete', 'file_dirname', 'file_expand_path', 'file_gunzip', 'file_gzip', 'file_info', diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl/index.html new file mode 100644 index 0000000..915b1f2 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/idl/index.html @@ -0,0 +1,65 @@ + + +CodeMirror: IDL mode + + + + + + + + + + +
+

IDL mode

+ +
+ + +

MIME types defined: text/x-idl.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/index.html new file mode 100644 index 0000000..51205dd --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/index.html @@ -0,0 +1,166 @@ + + +CodeMirror: Language Modes + + + + + +
+ +

Language modes

+ +

This is a list of every mode in the distribution. Each mode lives +in a subdirectory of the mode/ directory, and typically +defines a single JavaScript file that implements the mode. Loading +such file will make the language available to CodeMirror, through +the mode +option.

+ +
+ +
+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/index.html new file mode 100644 index 0000000..3023835 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/index.html @@ -0,0 +1,114 @@ + + +CodeMirror: JavaScript mode + + + + + + + + + + + + +
+

JavaScript mode

+ + +
+ + + +

+ JavaScript mode supports several configuration options: +

    +
  • json which will set the mode to expect JSON + data rather than a JavaScript program.
  • +
  • jsonld which will set the mode to expect + JSON-LD linked data rather + than a JavaScript program (demo).
  • +
  • typescript which will activate additional + syntax highlighting and some other things for TypeScript code + (demo).
  • +
  • statementIndent which (given a number) will + determine the amount of indentation to use for statements + continued on a new line.
  • +
  • wordCharacters, a regexp that indicates which + characters should be considered part of an identifier. + Defaults to /[\w$]/, which does not handle + non-ASCII identifiers. Can be set to something more elaborate + to improve Unicode support.
  • +
+

+ +

MIME types defined: text/javascript, application/javascript, application/x-javascript, text/ecmascript, application/ecmascript, application/json, application/x-json, application/manifest+json, application/ld+json, text/typescript, application/typescript.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/javascript.js similarity index 87% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/javascript.js index ba27c5d..0473956 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/javascript.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -67,7 +67,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (ch == '"' || ch == "'") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); - } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) { + } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) { return ret("number", "number"); } else if (ch == "." && stream.match("..")) { return ret("spread", "meta"); @@ -75,10 +75,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return ret(ch); } else if (ch == "=" && stream.eat(">")) { return ret("=>", "operator"); - } else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) { + } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) { return ret("number", "number"); } else if (/\d/.test(ch)) { - stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/); + stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/); return ret("number", "number"); } else if (ch == "/") { if (stream.eat("*")) { @@ -98,18 +98,25 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } else if (ch == "`") { state.tokenize = tokenQuasi; return tokenQuasi(stream, state); - } else if (ch == "#") { + } else if (ch == "#" && stream.peek() == "!") { stream.skipToEnd(); - return ret("error", "error"); + return ret("meta", "meta"); + } else if (ch == "#" && stream.eatWhile(wordRE)) { + return ret("variable", "property") + } else if (ch == "<" && stream.match("!--") || + (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) { + stream.skipToEnd() + return ret("comment", "comment") } else if (isOperatorChar.test(ch)) { if (ch != ">" || !state.lexical || state.lexical.type != ">") { if (stream.eat("=")) { if (ch == "!" || ch == "=") stream.eat("=") - } else if (/[<>*+\-]/.test(ch)) { + } else if (/[<>*+\-|&?]/.test(ch)) { stream.eat(ch) if (ch == ">") stream.eat(ch) } } + if (ch == "?" && stream.eat(".")) return ret(".") return ret("operator", "operator", stream.current()); } else if (wordRE.test(ch)) { stream.eatWhile(wordRE); @@ -119,7 +126,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { var kw = keywords[word] return ret(kw.type, kw.style, word) } - if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false)) + if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false)) return ret("async", "keyword", word) } return ret("variable", "variable", word) @@ -195,8 +202,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { ++depth; } else if (wordRE.test(ch)) { sawSomething = true; - } else if (/["'\/]/.test(ch)) { - return; + } else if (/["'\/`]/.test(ch)) { + for (;; --pos) { + if (pos == 0) return + var next = stream.string.charAt(pos - 1) + if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break } + } } else if (sawSomething && !depth) { ++pos; break; @@ -365,7 +376,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } if (type == "function") return cont(functiondef); if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); - if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), className, poplex); } + if (type == "class" || (isTS && value == "interface")) { + cx.marked = "keyword" + return cont(pushlex("form", type == "class" ? type : value), className, poplex) + } if (type == "variable") { if (isTS && value == "declare") { cx.marked = "keyword" @@ -373,11 +387,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) { cx.marked = "keyword" if (value == "enum") return cont(enumdef); - else if (value == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";")); + else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";")); else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) } else if (isTS && value == "namespace") { cx.marked = "keyword" - return cont(pushlex("form"), expression, block, poplex) + return cont(pushlex("form"), expression, statement, poplex) } else if (isTS && value == "abstract") { cx.marked = "keyword" return cont(statement) @@ -407,7 +421,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function parenExpr(type) { if (type != "(") return pass() - return cont(pushlex(")"), expression, expect(")"), poplex) + return cont(pushlex(")"), maybeexpression, expect(")"), poplex) } function expressionInner(type, value, noComma) { if (cx.state.fatArrowAt == cx.stream.start) { @@ -436,7 +450,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function maybeoperatorComma(type, value) { - if (type == ",") return cont(expression); + if (type == ",") return cont(maybeexpression); return maybeoperatorNoComma(type, value, false); } function maybeoperatorNoComma(type, value, noComma) { @@ -445,7 +459,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext); if (type == "operator") { if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me); - if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false)) + if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false)) return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me); if (value == "?") return cont(expression, expect(":"), expr); return cont(expr); @@ -552,6 +566,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { }, proceed); } if (type == end || value == end) return cont(); + if (sep && sep.indexOf(";") > -1) return pass(what) return cont(expect(end)); } return function(type, value) { @@ -574,6 +589,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "?") return cont(maybetype); } } + function maybetypeOrIn(type, value) { + if (isTS && (type == ":" || value == "in")) return cont(typeexpr) + } function mayberettype(type) { if (isTS && type == ":") { if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr) @@ -587,45 +605,57 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } } function typeexpr(type, value) { - if (value == "keyof" || value == "typeof") { + if (value == "keyof" || value == "typeof" || value == "infer") { cx.marked = "keyword" - return cont(value == "keyof" ? typeexpr : expressionNoComma) + return cont(value == "typeof" ? expressionNoComma : typeexpr) } if (type == "variable" || value == "void") { cx.marked = "type" return cont(afterType) } + if (value == "|" || value == "&") return cont(typeexpr) if (type == "string" || type == "number" || type == "atom") return cont(afterType); if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType) - if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType) - if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType) + if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType) + if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType) if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr) } function maybeReturnType(type) { if (type == "=>") return cont(typeexpr) } + function typeprops(type) { + if (type.match(/[\}\)\]]/)) return cont() + if (type == "," || type == ";") return cont(typeprops) + return pass(typeprop, typeprops) + } function typeprop(type, value) { if (type == "variable" || cx.style == "keyword") { cx.marked = "property" return cont(typeprop) - } else if (value == "?") { + } else if (value == "?" || type == "number" || type == "string") { return cont(typeprop) } else if (type == ":") { return cont(typeexpr) } else if (type == "[") { - return cont(expression, maybetype, expect("]"), typeprop) + return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) + } else if (type == "(") { + return pass(functiondecl, typeprop) + } else if (!type.match(/[;\}\)\],]/)) { + return cont() } } function typearg(type, value) { if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg) if (type == ":") return cont(typeexpr) + if (type == "spread") return cont(typearg) return pass(typeexpr) } function afterType(type, value) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) if (value == "|" || type == "." || value == "&") return cont(typeexpr) - if (type == "[") return cont(expect("]"), afterType) + if (type == "[") return cont(typeexpr, expect("]"), afterType) if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) } + if (value == "?") return cont(typeexpr, expect(":"), typeexpr) } function maybeTypeArgs(_, value) { if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) @@ -644,7 +674,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) } if (type == "variable") { register(value); return cont(); } if (type == "spread") return cont(pattern); - if (type == "[") return contCommasep(pattern, "]"); + if (type == "[") return contCommasep(eltpattern, "]"); if (type == "{") return contCommasep(proppattern, "}"); } function proppattern(type, value) { @@ -655,8 +685,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "variable") cx.marked = "property"; if (type == "spread") return cont(pattern); if (type == "}") return pass(); + if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern); return cont(expect(":"), pattern, maybeAssign); } + function eltpattern() { + return pass(pattern, maybeAssign) + } function maybeAssign(_type, value) { if (value == "=") return cont(expressionNoComma); } @@ -668,25 +702,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function forspec(type, value) { if (value == "await") return cont(forspec); - if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex); + if (type == "(") return cont(pushlex(")"), forspec1, 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); + if (type == "var") return cont(vardef, forspec2); + if (type == "variable") return cont(forspec2); + return pass(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); + if (type == ")") return cont() + if (type == ";") return cont(forspec2) + if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) } + return pass(expression, forspec2) } function functiondef(type, value) { if (value == "*") {cx.marked = "keyword"; return cont(functiondef);} @@ -694,10 +721,25 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext); if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef) } + function functiondecl(type, value) { + if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);} + if (type == "variable") {register(value); return cont(functiondecl);} + if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext); + if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl) + } + function typename(type, value) { + if (type == "keyword" || type == "variable") { + cx.marked = "type" + return cont(typename) + } else if (value == "<") { + return cont(pushlex(">"), commasep(typeparam, ">"), poplex) + } + } function funarg(type, value) { if (value == "@") cont(expression, funarg) if (type == "spread") return cont(funarg); if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); } + if (isTS && type == "this") return cont(maybetype, maybeAssign) return pass(pattern, maybetype, maybeAssign); } function classExpression(type, value) { @@ -726,15 +768,17 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } if (type == "variable" || cx.style == "keyword") { cx.marked = "property"; - return cont(isTS ? classfield : functiondef, classBody); + return cont(classfield, classBody); } + if (type == "number" || type == "string") return cont(classfield, classBody); if (type == "[") - return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody) + return cont(expression, maybetype, expect("]"), classfield, classBody) if (value == "*") { cx.marked = "keyword"; return cont(classBody); } - if (type == ";") return cont(classBody); + if (isTS && type == "(") return pass(functiondecl, classBody) + if (type == ";" || type == ",") return cont(classBody); if (type == "}") return cont(); if (value == "@") return cont(expression, classBody) } @@ -742,7 +786,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (value == "?") return cont(classfield) if (type == ":") return cont(typeexpr, maybeAssign) if (value == "=") return cont(expressionNoComma) - return pass(functiondef) + var context = cx.state.lexical.prev, isInterface = context && context.info == "interface" + return pass(isInterface ? functiondecl : functiondef) } function afterExport(type, value) { if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); } @@ -830,7 +875,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { }, indent: function(state, textAfter) { - if (state.tokenize == tokenComment) return CodeMirror.Pass; + if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass; if (state.tokenize != tokenBase) return 0; var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top // Kludge to prevent 'maybelse' from blocking lexical scope pops @@ -887,9 +932,10 @@ 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("application/json", { name: "javascript", json: true }); +CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true }); +CodeMirror.defineMIME("application/manifest+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 }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/json-ld.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/json-ld.html new file mode 100644 index 0000000..6a29c14 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/json-ld.html @@ -0,0 +1,72 @@ + + +CodeMirror: JSON-LD mode + + + + + + + + + + + + +
+

JSON-LD mode

+ + +
+ + + +

This is a specialization of the JavaScript mode.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/test.js new file mode 100644 index 0000000..26a81ff --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/test.js @@ -0,0 +1,521 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "javascript"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("locals", + "[keyword function] [def foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }"); + + MT("comma-and-binop", + "[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }"); + + MT("destructuring", + "([keyword function]([def a], [[[def b], [def c] ]]) {", + " [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);", + " [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];", + "})();"); + + MT("destructure_trailing_comma", + "[keyword let] {[def a], [def b],} [operator =] [variable foo];", + "[keyword let] [def c];"); // Parser still in good state? + + MT("class_body", + "[keyword class] [def Foo] {", + " [property constructor]() {}", + " [property sayName]() {", + " [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];", + " }", + "}"); + + MT("class", + "[keyword class] [def Point] [keyword extends] [variable SuperThing] {", + " [keyword get] [property prop]() { [keyword return] [number 24]; }", + " [property constructor]([def x], [def y]) {", + " [keyword super]([string 'something']);", + " [keyword this].[property x] [operator =] [variable-2 x];", + " }", + "}"); + + MT("anonymous_class_expression", + "[keyword const] [def Adder] [operator =] [keyword class] [keyword extends] [variable Arithmetic] {", + " [property add]([def a], [def b]) {}", + "};"); + + MT("named_class_expression", + "[keyword const] [def Subber] [operator =] [keyword class] [def Subtract] {", + " [property sub]([def a], [def b]) {}", + "};"); + + MT("class_async_method", + "[keyword class] [def Foo] {", + " [property sayName1]() {}", + " [keyword async] [property sayName2]() {}", + "}"); + + MT("import", + "[keyword function] [def foo]() {", + " [keyword import] [def $] [keyword from] [string 'jquery'];", + " [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];", + "}"); + + MT("import_trailing_comma", + "[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']") + + MT("import_dynamic", + "[keyword import]([string 'baz']).[property then]") + + MT("import_dynamic", + "[keyword const] [def t] [operator =] [keyword import]([string 'baz']).[property then]") + + MT("const", + "[keyword function] [def f]() {", + " [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];", + "}"); + + MT("for/of", + "[keyword for]([keyword let] [def of] [keyword of] [variable something]) {}"); + + MT("for await", + "[keyword for] [keyword await]([keyword let] [def of] [keyword of] [variable something]) {}"); + + MT("generator", + "[keyword function*] [def repeat]([def n]) {", + " [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])", + " [keyword yield] [variable-2 i];", + "}"); + + MT("let_scoping", + "[keyword function] [def scoped]([def n]) {", + " { [keyword var] [def i]; } [variable-2 i];", + " { [keyword let] [def j]; [variable-2 j]; } [variable j];", + " [keyword if] ([atom true]) { [keyword const] [def k]; [variable-2 k]; } [variable k];", + "}"); + + MT("switch_scoping", + "[keyword switch] ([variable x]) {", + " [keyword default]:", + " [keyword let] [def j];", + " [keyword return] [variable-2 j]", + "}", + "[variable j];") + + MT("leaving_scope", + "[keyword function] [def a]() {", + " {", + " [keyword const] [def x] [operator =] [number 1]", + " [keyword if] ([atom true]) {", + " [keyword let] [def y] [operator =] [number 2]", + " [keyword var] [def z] [operator =] [number 3]", + " [variable console].[property log]([variable-2 x], [variable-2 y], [variable-2 z])", + " }", + " [variable console].[property log]([variable-2 x], [variable y], [variable-2 z])", + " }", + " [variable console].[property log]([variable x], [variable y], [variable-2 z])", + "}") + + MT("quotedStringAddition", + "[keyword let] [def f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];"); + + MT("quotedFatArrow", + "[keyword let] [def f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];"); + + MT("fatArrow", + "[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);", + "[variable a];", // No longer in scope + "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];", + "[variable c];"); + + MT("fatArrow_stringDefault", + "([def a], [def b] [operator =] [string 'x\\'y']) [operator =>] [variable-2 a] [operator +] [variable-2 b]") + + MT("spread", + "[keyword function] [def f]([def a], [meta ...][def b]) {", + " [variable something]([variable-2 a], [meta ...][variable-2 b]);", + "}"); + + MT("quasi", + "[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); + + MT("quasi_no_function", + "[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); + + MT("indent_statement", + "[keyword var] [def x] [operator =] [number 10]", + "[variable x] [operator +=] [variable y] [operator +]", + " [atom Infinity]", + "[keyword debugger];"); + + MT("indent_if", + "[keyword if] ([number 1])", + " [keyword break];", + "[keyword else] [keyword if] ([number 2])", + " [keyword continue];", + "[keyword else]", + " [number 10];", + "[keyword if] ([number 1]) {", + " [keyword break];", + "} [keyword else] [keyword if] ([number 2]) {", + " [keyword continue];", + "} [keyword else] {", + " [number 10];", + "}"); + + MT("indent_for", + "[keyword for] ([keyword var] [def i] [operator =] [number 0];", + " [variable i] [operator <] [number 100];", + " [variable i][operator ++])", + " [variable doSomething]([variable i]);", + "[keyword debugger];"); + + MT("indent_c_style", + "[keyword function] [def foo]()", + "{", + " [keyword debugger];", + "}"); + + MT("indent_else", + "[keyword for] (;;)", + " [keyword if] ([variable foo])", + " [keyword if] ([variable bar])", + " [number 1];", + " [keyword else]", + " [number 2];", + " [keyword else]", + " [number 3];"); + + MT("indent_funarg", + "[variable foo]([number 10000],", + " [keyword function]([def a]) {", + " [keyword debugger];", + "};"); + + MT("indent_below_if", + "[keyword for] (;;)", + " [keyword if] ([variable foo])", + " [number 1];", + "[number 2];"); + + MT("indent_semicolonless_if", + "[keyword function] [def foo]() {", + " [keyword if] ([variable x])", + " [variable foo]()", + "}") + + MT("indent_semicolonless_if_with_statement", + "[keyword function] [def foo]() {", + " [keyword if] ([variable x])", + " [variable foo]()", + " [variable bar]()", + "}") + + MT("multilinestring", + "[keyword var] [def x] [operator =] [string 'foo\\]", + "[string bar'];"); + + MT("scary_regexp", + "[string-2 /foo[[/]]bar/];"); + + MT("indent_strange_array", + "[keyword var] [def x] [operator =] [[", + " [number 1],,", + " [number 2],", + "]];", + "[number 10];"); + + MT("param_default", + "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {", + " [keyword return] [variable-2 x];", + "}"); + + MT( + "param_destructuring", + "[keyword function] [def foo]([def x] [operator =] [string-2 `foo${][number 10][string-2 }bar`]) {", + " [keyword return] [variable-2 x];", + "}"); + + MT("new_target", + "[keyword function] [def F]([def target]) {", + " [keyword if] ([variable-2 target] [operator &&] [keyword new].[keyword target].[property name]) {", + " [keyword return] [keyword new]", + " .[keyword target];", + " }", + "}"); + + MT("async", + "[keyword async] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }"); + + MT("async_assignment", + "[keyword const] [def foo] [operator =] [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; };"); + + MT("async_object", + "[keyword let] [def obj] [operator =] { [property async]: [atom false] };"); + + // async be highlighted as keyword and foo as def, but it requires potentially expensive look-ahead. See #4173 + MT("async_object_function", + "[keyword let] [def obj] [operator =] { [property async] [property foo]([def args]) { [keyword return] [atom true]; } };"); + + MT("async_object_properties", + "[keyword let] [def obj] [operator =] {", + " [property prop1]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },", + " [property prop2]: [keyword async] [keyword function] ([def args]) { [keyword return] [atom true]; },", + " [property prop3]: [keyword async] [keyword function] [def prop3]([def args]) { [keyword return] [atom true]; },", + "};"); + + MT("async_arrow", + "[keyword const] [def foo] [operator =] [keyword async] ([def args]) [operator =>] { [keyword return] [atom true]; };"); + + MT("async_jquery", + "[variable $].[property ajax]({", + " [property url]: [variable url],", + " [property async]: [atom true],", + " [property method]: [string 'GET']", + "});"); + + MT("async_variable", + "[keyword const] [def async] [operator =] {[property a]: [number 1]};", + "[keyword const] [def foo] [operator =] [string-2 `bar ${][variable async].[property a][string-2 }`];") + + MT("bigint", "[number 1n] [operator +] [number 0x1afn] [operator +] [number 0o064n] [operator +] [number 0b100n];") + + MT("async_comment", + "[keyword async] [comment /**/] [keyword function] [def foo]([def args]) { [keyword return] [atom true]; }"); + + MT("indent_switch", + "[keyword switch] ([variable x]) {", + " [keyword default]:", + " [keyword return] [number 2]", + "}") + + MT("regexp_corner_case", + "[operator +]{} [operator /] [atom undefined];", + "[[[meta ...][string-2 /\\//] ]];", + "[keyword void] [string-2 /\\//];", + "[keyword do] [string-2 /\\//]; [keyword while] ([number 0]);", + "[keyword if] ([number 0]) {} [keyword else] [string-2 /\\//];", + "[string-2 `${][variable async][operator ++][string-2 }//`];", + "[string-2 `${]{} [operator /] [string-2 /\\//}`];") + + MT("return_eol", + "[keyword return]", + "{} [string-2 /5/]") + + MT("numeric separator", + "[number 123_456];", + "[number 0xdead_c0de];", + "[number 0o123_456];", + "[number 0b1101_1101];", + "[number .123_456e0_1];", + "[number 1E+123_456];", + "[number 12_34_56n];") + + MT("underscore property", + "[variable something].[property _property];", + "[variable something].[property _123];", + "[variable something].[property _for];", + "[variable _for];", + "[variable _123];") + + MT("private properties", + "[keyword class] [def C] {", + " [property #x] [operator =] [number 2];", + " [property #read]() {", + " [keyword return] [keyword this].[property #x]", + " }", + "}") + + var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript") + function TS(name) { + test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1)) + } + + TS("typescript_extend_type", + "[keyword class] [def Foo] [keyword extends] [type Some][operator <][type Type][operator >] {}") + + TS("typescript_arrow_type", + "[keyword let] [def x]: ([variable arg]: [type Type]) [operator =>] [type ReturnType]") + + TS("typescript_class", + "[keyword class] [def Foo] {", + " [keyword public] [keyword static] [property main]() {}", + " [keyword private] [property _foo]: [type string];", + "}") + + TS("typescript_literal_types", + "[keyword import] [keyword *] [keyword as] [def Sequelize] [keyword from] [string 'sequelize'];", + "[keyword interface] [def MyAttributes] {", + " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];", + " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", + "}", + "[keyword interface] [def MyInstance] [keyword extends] [type Sequelize].[type Instance] [operator <] [type MyAttributes] [operator >] {", + " [property rawAttributes]: [type MyAttributes];", + " [property truthy]: [string 'true'] [operator |] [number 1] [operator |] [atom true];", + " [property falsy]: [string 'false'] [operator |] [number 0] [operator |] [atom false];", + "}") + + TS("typescript_extend_operators", + "[keyword export] [keyword interface] [def UserModel] [keyword extends]", + " [type Sequelize].[type Model] [operator <] [type UserInstance], [type UserAttributes] [operator >] {", + " [property findById]: (", + " [variable userId]: [type number]", + " ) [operator =>] [type Promise] [operator <] [type Array] [operator <] { [property id], [property name] } [operator >>];", + " [property updateById]: (", + " [variable userId]: [type number],", + " [variable isActive]: [type boolean]", + " ) [operator =>] [type Promise] [operator <] [type AccountHolderNotificationPreferenceInstance] [operator >];", + " }") + + TS("typescript_interface_with_const", + "[keyword const] [def hello]: {", + " [property prop1][operator ?]: [type string];", + " [property prop2][operator ?]: [type string];", + "} [operator =] {};") + + TS("typescript_double_extend", + "[keyword export] [keyword interface] [def UserAttributes] {", + " [property id][operator ?]: [type number];", + " [property createdAt][operator ?]: [type Date];", + "}", + "[keyword export] [keyword interface] [def UserInstance] [keyword extends] [type Sequelize].[type Instance][operator <][type UserAttributes][operator >], [type UserAttributes] {", + " [property id]: [type number];", + " [property createdAt]: [type Date];", + "}"); + + TS("typescript_index_signature", + "[keyword interface] [def A] {", + " [[ [variable prop]: [type string] ]]: [type any];", + " [property prop1]: [type any];", + "}"); + + TS("typescript_generic_class", + "[keyword class] [def Foo][operator <][type T][operator >] {", + " [property bar]() {}", + " [property foo](): [type Foo] {}", + "}") + + TS("typescript_type_when_keyword", + "[keyword export] [keyword type] [type AB] [operator =] [type A] [operator |] [type B];", + "[keyword type] [type Flags] [operator =] {", + " [property p1]: [type string];", + " [property p2]: [type boolean];", + "};") + + TS("typescript_type_when_not_keyword", + "[keyword class] [def HasType] {", + " [property type]: [type string];", + " [property constructor]([def type]: [type string]) {", + " [keyword this].[property type] [operator =] [variable-2 type];", + " }", + " [property setType]({ [def type] }: { [property type]: [type string]; }) {", + " [keyword this].[property type] [operator =] [variable-2 type];", + " }", + "}") + + TS("typescript_function_generics", + "[keyword function] [def a]() {}", + "[keyword function] [def b][operator <][type IA] [keyword extends] [type object], [type IB] [keyword extends] [type object][operator >]() {}", + "[keyword function] [def c]() {}") + + TS("typescript_complex_return_type", + "[keyword function] [def A]() {", + " [keyword return] [keyword this].[property property];", + "}", + "[keyword function] [def B](): [type Promise][operator <]{ [[ [variable key]: [type string] ]]: [type any] } [operator |] [atom null][operator >] {", + " [keyword return] [keyword this].[property property];", + "}") + + TS("typescript_complex_type_casting", + "[keyword const] [def giftpay] [operator =] [variable config].[property get]([string 'giftpay']) [keyword as] { [[ [variable platformUuid]: [type string] ]]: { [property version]: [type number]; [property apiCode]: [type string]; } };") + + TS("typescript_keyof", + "[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {", + " [keyword return]") + + TS("typescript_new_typeargs", + "[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])") + + TS("modifiers", + "[keyword class] [def Foo] {", + " [keyword public] [keyword abstract] [property bar]() {}", + " [property constructor]([keyword readonly] [keyword private] [def x]) {}", + "}") + + TS("arrow prop", + "({[property a]: [def p] [operator =>] [variable-2 p]})") + + TS("generic in function call", + "[keyword this].[property a][operator <][type Type][operator >]([variable foo]);", + "[keyword this].[property a][operator <][variable Type][operator >][variable foo];") + + TS("type guard", + "[keyword class] [def Appler] {", + " [keyword static] [property assertApple]([def fruit]: [type Fruit]): [variable-2 fruit] [keyword is] [type Apple] {", + " [keyword if] ([operator !]([variable-2 fruit] [keyword instanceof] [variable Apple]))", + " [keyword throw] [keyword new] [variable Error]();", + " }", + "}") + + TS("type as variable", + "[variable type] [operator =] [variable x] [keyword as] [type Bar];"); + + TS("enum body", + "[keyword export] [keyword const] [keyword enum] [def CodeInspectionResultType] {", + " [def ERROR] [operator =] [string 'problem_type_error'],", + " [def WARNING] [operator =] [string 'problem_type_warning'],", + " [def META],", + "}") + + TS("parenthesized type", + "[keyword class] [def Foo] {", + " [property x] [operator =] [keyword new] [variable A][operator <][type B], [type string][operator |](() [operator =>] [type void])[operator >]();", + " [keyword private] [property bar]();", + "}") + + TS("abstract class", + "[keyword export] [keyword abstract] [keyword class] [def Foo] {}") + + TS("interface without semicolons", + "[keyword interface] [def Foo] {", + " [property greet]([def x]: [type int]): [type blah]", + " [property bar]: [type void]", + "}") + + var jsonld_mode = CodeMirror.getMode( + {indentUnit: 2}, + {name: "javascript", jsonld: true} + ); + function LD(name) { + test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1)); + } + + LD("json_ld_keywords", + '{', + ' [meta "@context"]: {', + ' [meta "@base"]: [string "http://example.com"],', + ' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],', + ' [property "likesFlavor"]: {', + ' [meta "@container"]: [meta "@list"]', + ' [meta "@reverse"]: [string "@beFavoriteOf"]', + ' },', + ' [property "nick"]: { [meta "@container"]: [meta "@set"] },', + ' [property "nick"]: { [meta "@container"]: [meta "@index"] }', + ' },', + ' [meta "@graph"]: [[ {', + ' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],', + ' [property "name"]: [string "John Lennon"],', + ' [property "modified"]: {', + ' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],', + ' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]', + ' }', + ' } ]]', + '}'); + + LD("json_ld_fake", + '{', + ' [property "@fake"]: [string "@fake"],', + ' [property "@contextual"]: [string "@identifier"],', + ' [property "user@domain.com"]: [string "@graphical"],', + ' [property "@ID"]: [string "@@ID"]', + '}'); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/typescript.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/typescript.html new file mode 100644 index 0000000..7da84d2 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/javascript/typescript.html @@ -0,0 +1,62 @@ + + +CodeMirror: TypeScript mode + + + + + + + + + + +
+

TypeScript mode

+ + +
+ + + +

This is a specialization of the JavaScript mode.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2/index.html new file mode 100644 index 0000000..2f626d1 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2/index.html @@ -0,0 +1,54 @@ + + +CodeMirror: Jinja2 mode + + + + + + + + + +
+

Jinja2 mode

+
+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2/jinja2.js similarity index 95% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2/jinja2.js index 5d57d13..77c9b22 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jinja2/jinja2.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -136,7 +136,11 @@ }, token: function (stream, state) { return state.tokenize(stream, state); - } + }, + blockCommentStart: "{#", + blockCommentEnd: "#}" }; }); + + CodeMirror.defineMIME("text/jinja2", "jinja2"); }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/index.html new file mode 100644 index 0000000..ef03834 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/index.html @@ -0,0 +1,89 @@ + + +CodeMirror: JSX mode + + + + + + + + + + + +
+

JSX mode

+ +
+ + + +

JSX Mode for React's +JavaScript syntax extension.

+ +

MIME types defined: text/jsx, text/typescript-jsx.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/jsx.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/jsx.js index 039e37b..889d3fe 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/jsx.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -32,7 +32,7 @@ function flatXMLIndent(state) { var tagName = state.tagName state.tagName = null - var result = xmlMode.indent(state, "") + var result = xmlMode.indent(state, "", "") state.tagName = tagName return result } @@ -105,7 +105,7 @@ function jsToken(stream, state, cx) { if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) { jsMode.skipExpression(cx.state) - state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")), + state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "", "")), xmlMode, 0, state.context) return null } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/test.js new file mode 100644 index 0000000..5ecd5a8 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/jsx/test.js @@ -0,0 +1,91 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "jsx") + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)) } + + MT("selfclose", + "[keyword var] [def x] [operator =] [bracket&tag <] [tag foo] [bracket&tag />] [operator +] [number 1];") + + MT("openclose", + "([bracket&tag <][tag foo][bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + + MT("openclosefragment", + "([bracket&tag <><][tag foo][bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + + MT("attr", + "([bracket&tag <][tag foo] [attribute abc]=[string 'value'][bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + + MT("braced_attr", + "([bracket&tag <][tag foo] [attribute abc]={[number 10]}[bracket&tag >]hello [atom &][bracket&tag ][operator ++])") + + MT("braced_text", + "([bracket&tag <][tag foo][bracket&tag >]hello {[number 10]} [atom &][bracket&tag ][operator ++])") + + MT("nested_tag", + "([bracket&tag <][tag foo][bracket&tag ><][tag bar][bracket&tag >][operator ++])") + + MT("nested_jsx", + "[keyword return] (", + " [bracket&tag <][tag foo][bracket&tag >]", + " say {[number 1] [operator +] [bracket&tag <][tag bar] [attribute attr]={[number 10]}[bracket&tag />]}!", + " [bracket&tag ][operator ++]", + ")") + + MT("preserve_js_context", + "[variable x] [operator =] [string-2 `quasi${][bracket&tag <][tag foo][bracket&tag />][string-2 }quoted`]") + + MT("string_interpolation", + "[variable x] [operator =] [string-2 `quasi${] [number 10] [string-2 }`]") + + MT("line_comment", + "([bracket&tag <][tag foo] [comment // hello]", + " [bracket&tag >][operator ++])") + + MT("line_comment_not_in_tag", + "([bracket&tag <][tag foo][bracket&tag >] // hello", + " [bracket&tag ][operator ++])") + + MT("block_comment", + "([bracket&tag <][tag foo] [comment /* hello]", + "[comment line 2]", + "[comment line 3 */] [bracket&tag >][operator ++])") + + MT("block_comment_not_in_tag", + "([bracket&tag <][tag foo][bracket&tag >]/* hello", + " line 2", + " line 3 */ [bracket&tag ][operator ++])") + + MT("missing_attr", + "([bracket&tag <][tag foo] [attribute selected][bracket&tag />][operator ++])") + + MT("indent_js", + "([bracket&tag <][tag foo][bracket&tag >]", + " [bracket&tag <][tag bar] [attribute baz]={[keyword function]() {", + " [keyword return] [number 10]", + " }}[bracket&tag />]", + " [bracket&tag ])") + + MT("spread", + "([bracket&tag <][tag foo] [attribute bar]={[meta ...][variable baz] [operator /][number 2]}[bracket&tag />])") + + MT("tag_attribute", + "([bracket&tag <][tag foo] [attribute bar]=[bracket&tag <][tag foo][bracket&tag />/>][operator ++])") + + var ts_mode = CodeMirror.getMode({indentUnit: 2}, "text/typescript-jsx") + function TS(name) { test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1)) } + + TS("tsx_react_integration", + "[keyword interface] [def Props] {", + " [property foo]: [type string];", + "}", + "[keyword class] [def MyComponent] [keyword extends] [type React].[type Component] [operator <] [type Props], [type any] [operator >] {", + " [property render]() {", + " [keyword return] [bracket&tag <][tag span][bracket&tag >]{[keyword this].[property props].[property foo]}[bracket&tag ]", + " }", + "}", + "[bracket&tag <][tag MyComponent] [attribute foo]=[string \"bar\"] [bracket&tag />]; [comment //ok]", + "[bracket&tag <][tag MyComponent] [attribute foo]={[number 0]} [bracket&tag />]; [comment //error]") + +})() diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia/index.html new file mode 100644 index 0000000..7a9217b --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia/index.html @@ -0,0 +1,196 @@ + + +CodeMirror: Julia mode + + + + + + + + + + +
+

Julia mode

+ +
+ + +

MIME types defined: text/x-julia.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia/julia.js similarity index 61% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia/julia.js index 2d89c49..bff5413 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/julia/julia.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -23,47 +23,50 @@ CodeMirror.defineMode("julia", function(config, parserConf) { var uChar = "([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])"; var operators = parserConf.operators || wordRegexp([ - "[<>]:", "[<>=]=", "<<=?", ">>>?=?", "=>", "->", "\\/\\/", - "[\\\\%*+\\-<>!=\\/^|&\\u00F7\\u22BB]=?", "\\?", "\\$", "~", ":", - "\\u00D7", "\\u2208", "\\u2209", "\\u220B", "\\u220C", "\\u2218", - "\\u221A", "\\u221B", "\\u2229", "\\u222A", "\\u2260", "\\u2264", - "\\u2265", "\\u2286", "\\u2288", "\\u228A", "\\u22C5", - "\\b(in|isa)\\b(?!\.?\\()"], ""); + "[<>]:", "[<>=]=", "<<=?", ">>>?=?", "=>", "->", "\\/\\/", + "[\\\\%*+\\-<>!=\\/^|&\\u00F7\\u22BB]=?", "\\?", "\\$", "~", ":", + "\\u00D7", "\\u2208", "\\u2209", "\\u220B", "\\u220C", "\\u2218", + "\\u221A", "\\u221B", "\\u2229", "\\u222A", "\\u2260", "\\u2264", + "\\u2265", "\\u2286", "\\u2288", "\\u228A", "\\u22C5", + "\\b(in|isa)\\b(?!\.?\\()"], ""); var delimiters = parserConf.delimiters || /^[;,()[\]{}]/; var identifiers = parserConf.identifiers || - /^[_A-Za-z\u00A1-\u2217\u2219-\uFFFF][\w\u00A1-\u2217\u2219-\uFFFF]*!*/; + /^[_A-Za-z\u00A1-\u2217\u2219-\uFFFF][\w\u00A1-\u2217\u2219-\uFFFF]*!*/; var chars = wordRegexp([octChar, hexChar, sChar, uChar], "'"); - var openers = wordRegexp(["begin", "function", "type", "struct", "immutable", - "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", - "finally", "catch", "do"]); - var closers = wordRegexp(["end", "else", "elseif", "catch", "finally"]); - var keywords = wordRegexp(["if", "else", "elseif", "while", "for", "begin", - "let", "end", "do", "try", "catch", "finally", "return", "break", - "continue", "global", "local", "const", "export", "import", "importall", - "using", "function", "where", "macro", "module", "baremodule", "struct", - "type", "mutable", "immutable", "quote", "typealias", "abstract", - "primitive", "bitstype"]); - var builtins = wordRegexp(["true", "false", "nothing", "NaN", "Inf"]); + + var openersList = ["begin", "function", "type", "struct", "immutable", "let", + "macro", "for", "while", "quote", "if", "else", "elseif", "try", + "finally", "catch", "do"]; + + var closersList = ["end", "else", "elseif", "catch", "finally"]; + + var keywordsList = ["if", "else", "elseif", "while", "for", "begin", "let", + "end", "do", "try", "catch", "finally", "return", "break", "continue", + "global", "local", "const", "export", "import", "importall", "using", + "function", "where", "macro", "module", "baremodule", "struct", "type", + "mutable", "immutable", "quote", "typealias", "abstract", "primitive", + "bitstype"]; + + var builtinsList = ["true", "false", "nothing", "NaN", "Inf"]; + + CodeMirror.registerHelper("hintWords", "julia", keywordsList.concat(builtinsList)); + + var openers = wordRegexp(openersList); + var closers = wordRegexp(closersList); + var keywords = wordRegexp(keywordsList); + var builtins = wordRegexp(builtinsList); var macro = /^@[_A-Za-z][\w]*/; var symbol = /^:[_A-Za-z\u00A1-\uFFFF][\w\u00A1-\uFFFF]*!*/; var stringPrefixes = /^(`|([_A-Za-z\u00A1-\uFFFF]*"("")?))/; function inArray(state) { - return inGenerator(state, '[') + return (state.nestedArrays > 0); } - function inGenerator(state, bracket, depth) { - if (typeof(bracket) === "undefined") { bracket = '('; } - if (typeof(depth) === "undefined") { depth = 0; } - var scope = currentScope(state, depth); - if ((depth == 0 && scope === "if" && inGenerator(state, bracket, depth + 1)) || - (scope === "for" && inGenerator(state, bracket, depth + 1)) || - (scope === bracket)) { - return true; - } - return false; + function inGenerator(state) { + return (state.nestedGenerators > 0); } function currentScope(state, n) { @@ -77,7 +80,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) { // tokenizers function tokenBase(stream, state) { // Handle multiline comments - if (stream.match(/^#=/, false)) { + if (stream.match('#=', false)) { state.tokenize = tokenComment; return state.tokenize(stream, state); } @@ -115,44 +118,44 @@ CodeMirror.defineMode("julia", function(config, parserConf) { if (ch === '[') { state.scopes.push('['); + state.nestedArrays++; } if (ch === '(') { state.scopes.push('('); + state.nestedGenerators++; } if (inArray(state) && ch === ']') { - if (currentScope(state) === "if") { state.scopes.pop(); } - while (currentScope(state) === "for") { state.scopes.pop(); } + while (state.scopes.length && currentScope(state) !== "[") { state.scopes.pop(); } state.scopes.pop(); + state.nestedArrays--; state.leavingExpr = true; } if (inGenerator(state) && ch === ')') { - if (currentScope(state) === "if") { state.scopes.pop(); } - while (currentScope(state) === "for") { state.scopes.pop(); } + while (state.scopes.length && currentScope(state) !== "(") { state.scopes.pop(); } state.scopes.pop(); + state.nestedGenerators--; state.leavingExpr = true; } if (inArray(state)) { - if (state.lastToken == "end" && stream.match(/^:/)) { + if (state.lastToken == "end" && stream.match(':')) { return "operator"; } - if (stream.match(/^end/)) { + if (stream.match('end')) { return "number"; } } var match; - if (match = stream.match(openers)) { + if (match = stream.match(openers, false)) { state.scopes.push(match[0]); - return "keyword"; } - if (stream.match(closers)) { + if (stream.match(closers, false)) { state.scopes.pop(); - return "keyword"; } // Handle type annotations @@ -181,18 +184,14 @@ CodeMirror.defineMode("julia", function(config, parserConf) { if (stream.match(/^\.?\d/, false)) { var imMatcher = RegExp(/^im\b/); var numberLiteral = false; - // Floats - if (stream.match(/^\d*\.(?!\.)\d*([Eef][\+\-]?\d+)?/i)) { numberLiteral = true; } - if (stream.match(/^\d+\.(?!\.)\d*/)) { numberLiteral = true; } - if (stream.match(/^\.\d+/)) { numberLiteral = true; } - if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { numberLiteral = true; } + if (stream.match(/^0x\.[0-9a-f_]+p[\+\-]?[_\d]+/i)) { numberLiteral = true; } // Integers - if (stream.match(/^0x[0-9a-f]+/i)) { numberLiteral = true; } // Hex - if (stream.match(/^0b[01]+/i)) { numberLiteral = true; } // Binary - if (stream.match(/^0o[0-7]+/i)) { numberLiteral = true; } // Octal - if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal - // Zero by itself with no other piece of number. - if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; } + if (stream.match(/^0x[0-9a-f_]+/i)) { numberLiteral = true; } // Hex + if (stream.match(/^0b[01_]+/i)) { numberLiteral = true; } // Binary + if (stream.match(/^0o[0-7_]+/i)) { numberLiteral = true; } // Octal + // Floats + if (stream.match(/^(?:(?:\d[_\d]*)?\.(?!\.)(?:\d[_\d]*)?|\d[_\d]*\.(?!\.)(?:\d[_\d]*))?([Eef][\+\-]?[_\d]+)?/i)) { numberLiteral = true; } + if (stream.match(/^\d[_\d]*(e[\+\-]?\d+)?/i)) { numberLiteral = true; } // Decimal if (numberLiteral) { // Integer literals may be "long" stream.match(imMatcher); @@ -202,7 +201,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) { } // Handle Chars - if (stream.match(/^'/)) { + if (stream.match('\'')) { state.tokenize = tokenChar; return state.tokenize(stream, state); } @@ -256,68 +255,70 @@ CodeMirror.defineMode("julia", function(config, parserConf) { } function tokenCallOrDef(stream, state) { - var match = stream.match(/^(\(\s*)/); - if (match) { - if (state.firstParenPos < 0) - state.firstParenPos = state.scopes.length; - state.scopes.push('('); - state.charsAdvanced += match[1].length; - } - if (currentScope(state) == '(' && stream.match(/^\)/)) { - state.scopes.pop(); - state.charsAdvanced += 1; - if (state.scopes.length <= state.firstParenPos) { - var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false); - stream.backUp(state.charsAdvanced); + for (;;) { + var match = stream.match(/^(\(\s*)/), charsAdvanced = 0; + if (match) { + if (state.firstParenPos < 0) + state.firstParenPos = state.scopes.length; + state.scopes.push('('); + charsAdvanced += match[1].length; + } + if (currentScope(state) == '(' && stream.match(')')) { + state.scopes.pop(); + charsAdvanced += 1; + if (state.scopes.length <= state.firstParenPos) { + var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false); + stream.backUp(charsAdvanced); + state.firstParenPos = -1; + state.tokenize = tokenBase; + if (isDefinition) + return "def"; + return "builtin"; + } + } + // Unfortunately javascript does not support multiline strings, so we have + // to undo anything done upto here if a function call or definition splits + // over two or more lines. + if (stream.match(/^$/g, false)) { + stream.backUp(charsAdvanced); + while (state.scopes.length > state.firstParenPos) + state.scopes.pop(); state.firstParenPos = -1; - state.charsAdvanced = 0; state.tokenize = tokenBase; - if (isDefinition) - return "def"; return "builtin"; } + if (!stream.match(/^[^()]+/)) { + stream.next() + return null + } } - // Unfortunately javascript does not support multiline strings, so we have - // to undo anything done upto here if a function call or definition splits - // over two or more lines. - if (stream.match(/^$/g, false)) { - stream.backUp(state.charsAdvanced); - while (state.scopes.length > state.firstParenPos) - state.scopes.pop(); - state.firstParenPos = -1; - state.charsAdvanced = 0; - state.tokenize = tokenBase; - return "builtin"; - } - state.charsAdvanced += stream.match(/^([^()]*)/)[1].length; - return state.tokenize(stream, state); } function tokenAnnotation(stream, state) { - stream.match(/.*?(?=,|;|{|}|\(|\)|=|$|\s)/); - if (stream.match(/^{/)) { - state.nestedLevels++; - } else if (stream.match(/^}/)) { - state.nestedLevels--; + stream.match(/.*?(?=[,;{}()=\s]|$)/); + if (stream.match('{')) { + state.nestedParameters++; + } else if (stream.match('}') && state.nestedParameters > 0) { + state.nestedParameters--; } - if (state.nestedLevels > 0) { + if (state.nestedParameters > 0) { stream.match(/.*?(?={|})/) || stream.next(); - } else if (state.nestedLevels == 0) { + } else if (state.nestedParameters == 0) { state.tokenize = tokenBase; } return "builtin"; } function tokenComment(stream, state) { - if (stream.match(/^#=/)) { - state.nestedLevels++; + if (stream.match('#=')) { + state.nestedComments++; } if (!stream.match(/.*?(?=(#=|=#))/)) { stream.skipToEnd(); } - if (stream.match(/^=#/)) { - state.nestedLevels--; - if (state.nestedLevels == 0) + if (stream.match('=#')) { + state.nestedComments--; + if (state.nestedComments == 0) state.tokenize = tokenBase; } return "comment"; @@ -346,7 +347,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) { return "string"; } if (!stream.match(/^[^']+(?=')/)) { stream.skipToEnd(); } - if (stream.match(/^'/)) { state.tokenize = tokenBase; } + if (stream.match('\'')) { state.tokenize = tokenBase; } return "error"; } @@ -380,8 +381,10 @@ CodeMirror.defineMode("julia", function(config, parserConf) { lastToken: null, leavingExpr: false, isDefinition: false, - nestedLevels: 0, - charsAdvanced: 0, + nestedArrays: 0, + nestedComments: 0, + nestedGenerators: 0, + nestedParameters: 0, firstParenPos: -1 }; }, @@ -399,9 +402,9 @@ CodeMirror.defineMode("julia", function(config, parserConf) { indent: function(state, textAfter) { var delta = 0; - if ( textAfter === ']' || textAfter === ')' || textAfter === "end" || - textAfter === "else" || textAfter === "catch" || textAfter === "elseif" || - textAfter === "finally" ) { + if ( textAfter === ']' || textAfter === ')' || /^end\b/.test(textAfter) || + /^else/.test(textAfter) || /^catch\b/.test(textAfter) || /^elseif\b/.test(textAfter) || + /^finally/.test(textAfter) ) { delta = -1; } return (state.scopes.length + delta) * config.indentUnit; @@ -411,6 +414,7 @@ CodeMirror.defineMode("julia", function(config, parserConf) { blockCommentStart: "#=", blockCommentEnd: "=#", lineComment: "#", + closeBrackets: "()[]{}\"\"", fold: "indent" }; return external; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript/index.html new file mode 100644 index 0000000..05e4b2f --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript/index.html @@ -0,0 +1,459 @@ + + +CodeMirror: LiveScript mode + + + + + + + + + + +
+

LiveScript mode

+
+ + +

MIME types defined: text/x-livescript.

+ +

The LiveScript mode was written by Kenneth Bentley.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript/livescript.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript/livescript.js index 1e363f8..595e067 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/livescript/livescript.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /** * Link to the project's GitHub page: diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua/index.html new file mode 100644 index 0000000..05c9446 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua/index.html @@ -0,0 +1,85 @@ + + +CodeMirror: Lua mode + + + + + + + + + + + +
+

Lua mode

+
+ + +

Loosely based on Franciszek + Wawrzak's CodeMirror + 1 mode. One configuration parameter is + supported, specials, to which you can provide an + array of strings to have those identifiers highlighted with + the lua-special style.

+

MIME types defined: text/x-lua.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua/lua.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua/lua.js index 0b19abd..202f373 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/lua/lua.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's // CodeMirror 1 mode. diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/index.html new file mode 100644 index 0000000..4984c04 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/index.html @@ -0,0 +1,418 @@ + + +CodeMirror: Markdown mode + + + + + + + + + + + + +
+

Markdown mode

+
+ + + +

If you also want support strikethrough, emoji and few other goodies, check out GitHub-Flavored Markdown mode.

+ +

Optionally depends on other modes for properly highlighted code blocks, + and XML mode for properly highlighted inline XML blocks.

+ +

Markdown mode supports these options:

+
    +
  • + +
    highlightFormatting: boolean
    +
    Whether to separately highlight markdown meta characters (*[]()etc.) (default: false).
    +
    +
  • +
  • + +
    maxBlockquoteDepth: boolean
    +
    Maximum allowed blockquote nesting (default: 0 - infinite nesting).
    +
    +
  • +
  • + +
    xml: boolean
    +
    Whether to highlight inline XML (default: true).
    +
    +
  • +
  • + +
    fencedCodeBlockHighlighting: boolean
    +
    Whether to syntax-highlight fenced code blocks, if given mode is included, or fencedCodeBlockDefaultMode is set (default: true).
    +
    +
  • +
  • + +
    fencedCodeBlockDefaultMode: string
    +
    Mode to use for fencedCodeBlockHighlighting, if given mode is not included.
    +
    +
  • +
  • + +
    tokenTypeOverrides: Object
    +
    When you want to override default token type names (e.g. {code: "code"}).
    +
    +
  • +
  • + +
    allowAtxHeaderWithoutSpace: boolean
    +
    Allow lazy headers without whitespace between hashtag and text (default: false).
    +
    +
  • +
+ +

MIME types defined: text/x-markdown.

+ +

Parsing/Highlighting Tests: normal, verbose.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/markdown.js similarity index 91% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/markdown.js index d523ec8..038a776 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/markdown.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -48,6 +48,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (modeCfg.fencedCodeBlockHighlighting === undefined) modeCfg.fencedCodeBlockHighlighting = true; + if (modeCfg.fencedCodeBlockDefaultMode === undefined) + modeCfg.fencedCodeBlockDefaultMode = 'text/plain'; + if (modeCfg.xml === undefined) modeCfg.xml = true; @@ -87,11 +90,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/ , taskListRE = /^\[(x| )\](?=\s)/i // Must follow listRE , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ - , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/ + , setextHeaderRE = /^ {0,3}(?:\={1,}|-{2,})\s*$/ , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/ - , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/ + , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/ , linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition - , punctuation = /[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/ + , punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/ , expandedTab = " " // CommonMark specifies tab as 4 spaces function switchInline(stream, state, f) { @@ -162,12 +165,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { if (state.indentationDiff === null) { state.indentationDiff = state.indentation; if (prevLineIsList) { - // Reset inline styles which shouldn't propagate aross list items - state.em = false; - state.strong = false; - state.code = false; - state.strikethrough = false; - state.list = null; // While this list item's marker's indentation is less than the deepest // list item's content's indentation,pop the deepest list item @@ -226,6 +223,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { // Add this list item's content's indentation to the stack state.listStack.push(state.indentation); + // Reset inline styles which shouldn't propagate across list items + state.em = false; + state.strong = false; + state.code = false; + state.strikethrough = false; if (modeCfg.taskLists && stream.match(taskListRE, false)) { state.taskList = true; @@ -237,7 +239,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { state.quote = 0; state.fencedEndRE = new RegExp(match[1] + "+ *$"); // try switching mode - state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]); + state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode ); if (state.localMode) state.localState = CodeMirror.startState(state.localMode); state.f = state.block = local; if (modeCfg.highlightFormatting) state.formatting = "code-block"; @@ -610,7 +612,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return getType(state); } } else if (ch === ' ') { - if (stream.match(/^~~/, true)) { // Probably surrounded by space + 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 @@ -620,7 +622,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } } - if (modeCfg.emoji && ch === ":" && stream.match(/^[a-z_\d+-]+:/)) { + if (modeCfg.emoji && ch === ":" && stream.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)) { state.emoji = true; if (modeCfg.highlightFormatting) state.formatting = "emoji"; var retType = getType(state); @@ -709,7 +711,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } function footnoteLinkInside(stream, state) { - if (stream.match(/^\]:/, true)) { + if (stream.match(']:', true)) { state.f = state.inline = footnoteUrl; if (modeCfg.highlightFormatting) state.formatting = "link"; var returnType = getType(state); @@ -733,7 +735,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { 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); + stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\.)+\)))?/, true); } state.f = state.inline = inlineNormal; return tokenTypes.linkHref + " url"; @@ -869,6 +871,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { getType: getType, + blockCommentStart: "", closeBrackets: "()[]{}''\"\"``", fold: "markdown" }; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/test.js new file mode 100644 index 0000000..fd5a1fb --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/markdown/test.js @@ -0,0 +1,1319 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var config = {tabSize: 4, indentUnit: 2} + var mode = CodeMirror.getMode(config, "markdown"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + var modeHighlightFormatting = CodeMirror.getMode(config, {name: "markdown", highlightFormatting: true}); + function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); } + var modeMT_noXml = CodeMirror.getMode(config, {name: "markdown", xml: false}); + function MT_noXml(name) { test.mode(name, modeMT_noXml, Array.prototype.slice.call(arguments, 1)); } + var modeMT_noFencedHighlight = CodeMirror.getMode(config, {name: "markdown", fencedCodeBlockHighlighting: false}); + function MT_noFencedHighlight(name) { test.mode(name, modeMT_noFencedHighlight, Array.prototype.slice.call(arguments, 1)); } + var modeAtxNoSpace = CodeMirror.getMode(config, {name: "markdown", allowAtxHeaderWithoutSpace: true}); + function AtxNoSpaceTest(name) { test.mode(name, modeAtxNoSpace, Array.prototype.slice.call(arguments, 1)); } + var modeOverrideClasses = CodeMirror.getMode(config, { + name: "markdown", + strikethrough: true, + emoji: true, + tokenTypeOverrides: { + "header" : "override-header", + "code" : "override-code", + "quote" : "override-quote", + "list1" : "override-list1", + "list2" : "override-list2", + "list3" : "override-list3", + "hr" : "override-hr", + "image" : "override-image", + "imageAltText": "override-image-alt-text", + "imageMarker": "override-image-marker", + "linkInline" : "override-link-inline", + "linkEmail" : "override-link-email", + "linkText" : "override-link-text", + "linkHref" : "override-link-href", + "em" : "override-em", + "strong" : "override-strong", + "strikethrough" : "override-strikethrough", + "emoji" : "override-emoji" + }}); + function TokenTypeOverrideTest(name) { test.mode(name, modeOverrideClasses, Array.prototype.slice.call(arguments, 1)); } + var modeFormattingOverride = CodeMirror.getMode(config, { + name: "markdown", + highlightFormatting: true, + tokenTypeOverrides: { + "formatting" : "override-formatting" + }}); + function FormatTokenTypeOverrideTest(name) { test.mode(name, modeFormattingOverride, Array.prototype.slice.call(arguments, 1)); } + var modeET = CodeMirror.getMode(config, {name: "markdown", emoji: true}); + function ET(name) { test.mode(name, modeET, Array.prototype.slice.call(arguments, 1)); } + + + FT("formatting_emAsterisk", + "[em&formatting&formatting-em *][em foo][em&formatting&formatting-em *]"); + + FT("formatting_emUnderscore", + "[em&formatting&formatting-em _][em foo][em&formatting&formatting-em _]"); + + FT("formatting_strongAsterisk", + "[strong&formatting&formatting-strong **][strong foo][strong&formatting&formatting-strong **]"); + + FT("formatting_strongUnderscore", + "[strong&formatting&formatting-strong __][strong foo][strong&formatting&formatting-strong __]"); + + FT("formatting_codeBackticks", + "[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]"); + + FT("formatting_doubleBackticks", + "[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]"); + + FT("formatting_atxHeader", + "[header&header-1&formatting&formatting-header&formatting-header-1 # ][header&header-1 foo # bar ][header&header-1&formatting&formatting-header&formatting-header-1 #]"); + + FT("formatting_setextHeader", + "[header&header-1 foo]", + "[header&header-1&formatting&formatting-header&formatting-header-1 =]"); + + FT("formatting_blockquote", + "[quote"e-1&formatting&formatting-quote&formatting-quote-1 > ][quote"e-1 foo]"); + + FT("formatting_list", + "[variable-2&formatting&formatting-list&formatting-list-ul - ][variable-2 foo]"); + FT("formatting_list", + "[variable-2&formatting&formatting-list&formatting-list-ol 1. ][variable-2 foo]"); + + FT("formatting_link", + "[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string&url (][string&url http://example.com/][string&formatting&formatting-link-string&url )]"); + + FT("formatting_linkReference", + "[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string&url [][string&url bar][string&formatting&formatting-link-string&url ]]]", + "[link&formatting&formatting-link [][link bar][link&formatting&formatting-link ]]:] [string&url http://example.com/]"); + + FT("formatting_linkWeb", + "[link&formatting&formatting-link <][link http://example.com/][link&formatting&formatting-link >]"); + + FT("formatting_linkEmail", + "[link&formatting&formatting-link <][link user@example.com][link&formatting&formatting-link >]"); + + FT("formatting_escape", + "[formatting-escape \\*]"); + + FT("formatting_image", + "[formatting&formatting-image&image&image-marker !][formatting&formatting-image&image&image-alt-text&link [[][image&image-alt-text&link alt text][formatting&formatting-image&image&image-alt-text&link ]]][formatting&formatting-link-string&string&url (][url&string http://link.to/image.jpg][formatting&formatting-link-string&string&url )]"); + + FT("codeBlock", + "[comment&formatting&formatting-code-block ```css]", + "[tag foo]", + "[comment&formatting&formatting-code-block ```]"); + + MT("plainText", + "foo"); + + // Don't style single trailing space + MT("trailingSpace1", + "foo "); + + // Two or more trailing spaces should be styled with line break character + MT("trailingSpace2", + "foo[trailing-space-a ][trailing-space-new-line ]"); + + MT("trailingSpace3", + "foo[trailing-space-a ][trailing-space-b ][trailing-space-new-line ]"); + + MT("trailingSpace4", + "foo[trailing-space-a ][trailing-space-b ][trailing-space-a ][trailing-space-new-line ]"); + + // Code blocks using 4 spaces (regardless of CodeMirror.tabSize value) + MT("codeBlocksUsing4Spaces", + " [comment foo]"); + + // Code blocks using 4 spaces with internal indentation + MT("codeBlocksUsing4SpacesIndentation", + " [comment bar]", + " [comment hello]", + " [comment world]", + " [comment foo]", + "bar"); + + // Code blocks should end even after extra indented lines + MT("codeBlocksWithTrailingIndentedLine", + " [comment foo]", + " [comment bar]", + " [comment baz]", + " ", + "hello"); + + // Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value) + MT("codeBlocksUsing1Tab", + "\t[comment foo]"); + + // No code blocks directly after paragraph + // http://spec.commonmark.org/0.19/#example-65 + MT("noCodeBlocksAfterParagraph", + "Foo", + " Bar"); + + MT("codeBlocksAfterATX", + "[header&header-1 # foo]", + " [comment code]"); + + MT("codeBlocksAfterSetext", + "[header&header-2 foo]", + "[header&header-2 ---]", + " [comment code]"); + + MT("codeBlocksAfterFencedCode", + "[comment ```]", + "[comment foo]", + "[comment ```]", + " [comment code]"); + + // Inline code using backticks + MT("inlineCodeUsingBackticks", + "foo [comment `bar`]"); + + // Block code using single backtick (shouldn't work) + MT("blockCodeSingleBacktick", + "[comment `]", + "[comment foo]", + "[comment `]"); + + // Unclosed backticks + // Instead of simply marking as CODE, it would be nice to have an + // incomplete flag for CODE, that is styled slightly different. + MT("unclosedBackticks", + "foo [comment `bar]"); + + // Per documentation: "To include a literal backtick character within a + // code span, you can use multiple backticks as the opening and closing + // delimiters" + MT("doubleBackticks", + "[comment ``foo ` bar``]"); + + // Tests based on Dingus + // http://daringfireball.net/projects/markdown/dingus + // + // Multiple backticks within an inline code block + MT("consecutiveBackticks", + "[comment `foo```bar`]"); + + // Multiple backticks within an inline code block with a second code block + MT("consecutiveBackticks", + "[comment `foo```bar`] hello [comment `world`]"); + + // Unclosed with several different groups of backticks + MT("unclosedBackticks", + "[comment ``foo ``` bar` hello]"); + + // Closed with several different groups of backticks + MT("closedBackticks", + "[comment ``foo ``` bar` hello``] world"); + + // info string cannot contain backtick, thus should result in inline code + MT("closingFencedMarksOnSameLine", + "[comment ``` code ```] foo"); + + // atx headers + // http://daringfireball.net/projects/markdown/syntax#header + + MT("atxH1", + "[header&header-1 # foo]"); + + MT("atxH2", + "[header&header-2 ## foo]"); + + MT("atxH3", + "[header&header-3 ### foo]"); + + MT("atxH4", + "[header&header-4 #### foo]"); + + MT("atxH5", + "[header&header-5 ##### foo]"); + + MT("atxH6", + "[header&header-6 ###### foo]"); + + // http://spec.commonmark.org/0.19/#example-24 + MT("noAtxH7", + "####### foo"); + + // http://spec.commonmark.org/0.19/#example-25 + MT("noAtxH1WithoutSpace", + "#5 bolt"); + + // CommonMark requires a space after # but most parsers don't + AtxNoSpaceTest("atxNoSpaceAllowed_H1NoSpace", + "[header&header-1 #foo]"); + + AtxNoSpaceTest("atxNoSpaceAllowed_H4NoSpace", + "[header&header-4 ####foo]"); + + AtxNoSpaceTest("atxNoSpaceAllowed_H1Space", + "[header&header-1 # foo]"); + + // Inline styles should be parsed inside headers + MT("atxH1inline", + "[header&header-1 # foo ][header&header-1&em *bar*]"); + + MT("atxIndentedTooMuch", + "[header&header-1 # foo]", + " [comment # bar]"); + + // disable atx inside blockquote until we implement proper blockquote inner mode + // TODO: fix to be CommonMark-compliant + MT("atxNestedInsideBlockquote", + "[quote"e-1 > # foo]"); + + MT("atxAfterBlockquote", + "[quote"e-1 > foo]", + "[header&header-1 # bar]"); + + // Setext headers - H1, H2 + // Per documentation, "Any number of underlining =’s or -’s will work." + // http://daringfireball.net/projects/markdown/syntax#header + // Ideally, the text would be marked as `header` as well, but this is + // not really feasible at the moment. So, instead, we're testing against + // what works today, to avoid any regressions. + // + // Check if single underlining = works + MT("setextH1", + "[header&header-1 foo]", + "[header&header-1 =]"); + + // Check if 3+ ='s work + MT("setextH1", + "[header&header-1 foo]", + "[header&header-1 ===]"); + + // Check if single underlining - should not be interpreted + // as it might lead to an empty list: + // https://spec.commonmark.org/0.28/#setext-heading-underline + MT("setextH2Single", + "foo", + "-"); + + // Check if 3+ -'s work + MT("setextH2", + "[header&header-2 foo]", + "[header&header-2 ---]"); + + // http://spec.commonmark.org/0.19/#example-45 + MT("setextH2AllowSpaces", + "[header&header-2 foo]", + " [header&header-2 ---- ]"); + + // http://spec.commonmark.org/0.19/#example-44 + MT("noSetextAfterIndentedCodeBlock", + " [comment foo]", + "[hr ---]"); + + MT("setextAfterFencedCode", + "[comment ```]", + "[comment foo]", + "[comment ```]", + "[header&header-2 bar]", + "[header&header-2 ---]"); + + MT("setextAfterATX", + "[header&header-1 # foo]", + "[header&header-2 bar]", + "[header&header-2 ---]"); + + // http://spec.commonmark.org/0.19/#example-51 + MT("noSetextAfterQuote", + "[quote"e-1 > foo]", + "[hr ---]", + "", + "[quote"e-1 > foo]", + "[quote"e-1 bar]", + "[hr ---]"); + + MT("noSetextAfterList", + "[variable-2 - foo]", + "[hr ---]"); + + MT("noSetextAfterList_listContinuation", + "[variable-2 - foo]", + "bar", + "[hr ---]"); + + MT("setextAfterList_afterIndentedCode", + "[variable-2 - foo]", + "", + " [comment bar]", + "[header&header-2 baz]", + "[header&header-2 ---]"); + + MT("setextAfterList_afterFencedCodeBlocks", + "[variable-2 - foo]", + "", + " [comment ```]", + " [comment bar]", + " [comment ```]", + "[header&header-2 baz]", + "[header&header-2 ---]"); + + MT("setextAfterList_afterHeader", + "[variable-2 - foo]", + " [variable-2&header&header-1 # bar]", + "[header&header-2 baz]", + "[header&header-2 ---]"); + + MT("setextAfterList_afterHr", + "[variable-2 - foo]", + "", + " [hr ---]", + "[header&header-2 bar]", + "[header&header-2 ---]"); + + MT("setext_nestedInlineMarkup", + "[header&header-1 foo ][em&header&header-1 *bar*]", + "[header&header-1 =]"); + + MT("setext_linkDef", + "[link [[aaa]]:] [string&url http://google.com 'title']", + "[hr ---]"); + + // currently, looks max one line ahead, thus won't catch valid CommonMark + // markup + MT("setext_oneLineLookahead", + "foo", + "[header&header-1 bar]", + "[header&header-1 =]"); + + // ensure we regard space after a single dash as a list + MT("setext_emptyList", + "foo", + "[variable-2 - ]", + "foo"); + + // Single-line blockquote with trailing space + MT("blockquoteSpace", + "[quote"e-1 > foo]"); + + // Single-line blockquote + MT("blockquoteNoSpace", + "[quote"e-1 >foo]"); + + // No blank line before blockquote + MT("blockquoteNoBlankLine", + "foo", + "[quote"e-1 > bar]"); + + MT("blockquoteNested", + "[quote"e-1 > foo]", + "[quote"e-1 >][quote"e-2 > foo]", + "[quote"e-1 >][quote"e-2 >][quote"e-3 > foo]"); + + // ensure quote-level is inferred correctly even if indented + MT("blockquoteNestedIndented", + " [quote"e-1 > foo]", + " [quote"e-1 >][quote"e-2 > foo]", + " [quote"e-1 >][quote"e-2 >][quote"e-3 > foo]"); + + // ensure quote-level is inferred correctly even if indented + MT("blockquoteIndentedTooMuch", + "foo", + " > bar"); + + // Single-line blockquote followed by normal paragraph + MT("blockquoteThenParagraph", + "[quote"e-1 >foo]", + "", + "bar"); + + // Multi-line blockquote (lazy mode) + MT("multiBlockquoteLazy", + "[quote"e-1 >foo]", + "[quote"e-1 bar]"); + + // Multi-line blockquote followed by normal paragraph (lazy mode) + MT("multiBlockquoteLazyThenParagraph", + "[quote"e-1 >foo]", + "[quote"e-1 bar]", + "", + "hello"); + + // Multi-line blockquote (non-lazy mode) + MT("multiBlockquote", + "[quote"e-1 >foo]", + "[quote"e-1 >bar]"); + + // Multi-line blockquote followed by normal paragraph (non-lazy mode) + MT("multiBlockquoteThenParagraph", + "[quote"e-1 >foo]", + "[quote"e-1 >bar]", + "", + "hello"); + + // disallow lists inside blockquote for now because it causes problems outside blockquote + // TODO: fix to be CommonMark-compliant + MT("listNestedInBlockquote", + "[quote"e-1 > - foo]"); + + // disallow fenced blocks inside blockquote because it causes problems outside blockquote + // TODO: fix to be CommonMark-compliant + MT("fencedBlockNestedInBlockquote", + "[quote"e-1 > ```]", + "[quote"e-1 > code]", + "[quote"e-1 > ```]", + // ensure we still allow inline code + "[quote"e-1 > ][quote"e-1&comment `code`]"); + + // Header with leading space after continued blockquote (#3287, negative indentation) + MT("headerAfterContinuedBlockquote", + "[quote"e-1 > foo]", + "[quote"e-1 bar]", + "", + " [header&header-1 # hello]"); + + // Check list types + + MT("listAsterisk", + "foo", + "bar", + "", + "[variable-2 * foo]", + "[variable-2 * bar]"); + + MT("listPlus", + "foo", + "bar", + "", + "[variable-2 + foo]", + "[variable-2 + bar]"); + + MT("listDash", + "foo", + "bar", + "", + "[variable-2 - foo]", + "[variable-2 - bar]"); + + MT("listNumber", + "foo", + "bar", + "", + "[variable-2 1. foo]", + "[variable-2 2. bar]"); + + MT("listFromParagraph", + "foo", + "[variable-2 1. bar]", + "[variable-2 2. hello]"); + + // List after hr + MT("listAfterHr", + "[hr ---]", + "[variable-2 - bar]"); + + // List after header + MT("listAfterHeader", + "[header&header-1 # foo]", + "[variable-2 - bar]"); + + // hr after list + MT("hrAfterList", + "[variable-2 - foo]", + "[hr -----]"); + + MT("hrAfterFencedCode", + "[comment ```]", + "[comment code]", + "[comment ```]", + "[hr ---]"); + + // allow hr inside lists + // (require prev line to be empty or hr, TODO: non-CommonMark-compliant) + MT("hrInsideList", + "[variable-2 - foo]", + "", + " [hr ---]", + " [hr ---]", + "", + " [comment ---]"); + + MT("consecutiveHr", + "[hr ---]", + "[hr ---]", + "[hr ---]"); + + // Formatting in lists (*) + MT("listAsteriskFormatting", + "[variable-2 * ][variable-2&em *foo*][variable-2 bar]", + "[variable-2 * ][variable-2&strong **foo**][variable-2 bar]", + "[variable-2 * ][variable-2&em&strong ***foo***][variable-2 bar]", + "[variable-2 * ][variable-2&comment `foo`][variable-2 bar]"); + + // Formatting in lists (+) + MT("listPlusFormatting", + "[variable-2 + ][variable-2&em *foo*][variable-2 bar]", + "[variable-2 + ][variable-2&strong **foo**][variable-2 bar]", + "[variable-2 + ][variable-2&em&strong ***foo***][variable-2 bar]", + "[variable-2 + ][variable-2&comment `foo`][variable-2 bar]"); + + // Formatting in lists (-) + MT("listDashFormatting", + "[variable-2 - ][variable-2&em *foo*][variable-2 bar]", + "[variable-2 - ][variable-2&strong **foo**][variable-2 bar]", + "[variable-2 - ][variable-2&em&strong ***foo***][variable-2 bar]", + "[variable-2 - ][variable-2&comment `foo`][variable-2 bar]"); + + // Formatting in lists (1.) + MT("listNumberFormatting", + "[variable-2 1. ][variable-2&em *foo*][variable-2 bar]", + "[variable-2 2. ][variable-2&strong **foo**][variable-2 bar]", + "[variable-2 3. ][variable-2&em&strong ***foo***][variable-2 bar]", + "[variable-2 4. ][variable-2&comment `foo`][variable-2 bar]"); + + // Paragraph lists + MT("listParagraph", + "[variable-2 * foo]", + "", + "[variable-2 * bar]"); + + // Multi-paragraph lists + // + // 4 spaces + MT("listMultiParagraph", + "[variable-2 * foo]", + "", + "[variable-2 * bar]", + "", + " [variable-2 hello]"); + + // 4 spaces, extra blank lines (should still be list, per Dingus) + MT("listMultiParagraphExtra", + "[variable-2 * foo]", + "", + "[variable-2 * bar]", + "", + "", + " [variable-2 hello]"); + + // 4 spaces, plus 1 space (should still be list, per Dingus) + MT("listMultiParagraphExtraSpace", + "[variable-2 * foo]", + "", + "[variable-2 * bar]", + "", + " [variable-2 hello]", + "", + " [variable-2 world]"); + + // 1 tab + MT("listTab", + "[variable-2 * foo]", + "", + "[variable-2 * bar]", + "", + "\t[variable-2 hello]"); + + // No indent + MT("listNoIndent", + "[variable-2 * foo]", + "", + "[variable-2 * bar]", + "", + "hello"); + + MT("listCommonMarkIndentationCode", + "[variable-2 * Code blocks also affect]", + " [variable-3 * The next level starts where the contents start.]", + " [variable-3 * Anything less than that will keep the item on the same level.]", + " [variable-3 * Each list item can indent the first level further and further.]", + " [variable-3 * For the most part, this makes sense while writing a list.]", + " [keyword * This means two items with same indentation can be different levels.]", + " [keyword * Each level has an indent requirement that can change between items.]", + " [keyword * A list item that meets this will be part of the next level.]", + " [variable-3 * Otherwise, it will be part of the level where it does meet this.]", + " [variable-2 * World]"); + + // should handle nested and un-nested lists + MT("listCommonMark_MixedIndents", + "[variable-2 * list1]", + " [variable-2 list1]", + " [variable-2&header&header-1 # heading still part of list1]", + " [variable-2 text after heading still part of list1]", + "", + " [comment indented codeblock]", + " [variable-2 list1 after code block]", + " [variable-3 * list2]", + // amount of spaces on empty lines between lists doesn't matter + " ", + // extra empty lines irrelevant + "", + "", + " [variable-3 indented text part of list2]", + " [keyword * list3]", + "", + " [variable-3 text at level of list2]", + "", + " [variable-2 de-indented text part of list1 again]", + "", + " [variable-2&comment ```]", + " [comment code]", + " [variable-2&comment ```]", + "", + " [variable-2 text after fenced code]"); + + // should correctly parse numbered list content indentation + MT("listCommonMark_NumberedListIndent", + "[variable-2 1000. list with base indent of 6]", + "", + " [variable-2 text must be indented 6 spaces at minimum]", + "", + " [variable-2 9-spaces indented text still part of list]", + "", + " [comment indented codeblock starts at 10 spaces]", + "", + " [comment text indented by 5 spaces no longer belong to list]"); + + // should consider tab as 4 spaces + MT("listCommonMark_TabIndented", + "[variable-2 * list]", + "\t[variable-3 * list2]", + "", + "\t\t[variable-3 part of list2]"); + + MT("listAfterBlockquote", + "[quote"e-1 > foo]", + "[variable-2 - bar]"); + + // shouldn't create sublist if it's indented more than allowed + MT("nestedListIndentedTooMuch", + "[variable-2 - foo]", + " [variable-2 - bar]"); + + MT("listIndentedTooMuchAfterParagraph", + "foo", + " - bar"); + + // Blockquote + MT("blockquote", + "[variable-2 * foo]", + "", + "[variable-2 * bar]", + "", + " [variable-2"e"e-1 > hello]"); + + // Code block + MT("blockquoteCode", + "[variable-2 * foo]", + "", + "[variable-2 * bar]", + "", + " [comment > hello]", + "", + " [variable-2 world]"); + + // Code block followed by text + MT("blockquoteCodeText", + "[variable-2 * foo]", + "", + " [variable-2 bar]", + "", + " [comment hello]", + "", + " [variable-2 world]"); + + // Nested list + + MT("listAsteriskNested", + "[variable-2 * foo]", + "", + " [variable-3 * bar]"); + + MT("listPlusNested", + "[variable-2 + foo]", + "", + " [variable-3 + bar]"); + + MT("listDashNested", + "[variable-2 - foo]", + "", + " [variable-3 - bar]"); + + MT("listNumberNested", + "[variable-2 1. foo]", + "", + " [variable-3 2. bar]"); + + MT("listMixed", + "[variable-2 * foo]", + "", + " [variable-3 + bar]", + "", + " [keyword - hello]", + "", + " [variable-2 1. world]"); + + MT("listBlockquote", + "[variable-2 * foo]", + "", + " [variable-3 + bar]", + "", + " [quote"e-1&variable-3 > hello]"); + + MT("listCode", + "[variable-2 * foo]", + "", + " [variable-3 + bar]", + "", + " [comment hello]"); + + // Code with internal indentation + MT("listCodeIndentation", + "[variable-2 * foo]", + "", + " [comment bar]", + " [comment hello]", + " [comment world]", + " [comment foo]", + " [variable-2 bar]"); + + // List nesting edge cases + MT("listNested", + "[variable-2 * foo]", + "", + " [variable-3 * bar]", + "", + " [variable-3 hello]" + ); + MT("listNested", + "[variable-2 * foo]", + "", + " [variable-3 * bar]", + "", + " [keyword * foo]" + ); + + // Code followed by text + MT("listCodeText", + "[variable-2 * foo]", + "", + " [comment bar]", + "", + "hello"); + + // Following tests directly from official Markdown documentation + // http://daringfireball.net/projects/markdown/syntax#hr + + MT("hrSpace", + "[hr * * *]"); + + MT("hr", + "[hr ***]"); + + MT("hrLong", + "[hr *****]"); + + MT("hrSpaceDash", + "[hr - - -]"); + + MT("hrDashLong", + "[hr ---------------------------------------]"); + + //Images + MT("Images", + "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)]") + + //Images with highlight alt text + MT("imageEm", + "[image&image-marker !][image&image-alt-text&link [[][image-alt-text&em&image&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]"); + + MT("imageStrong", + "[image&image-marker !][image&image-alt-text&link [[][image-alt-text&strong&image&link **alt text**][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]"); + + MT("imageEmStrong", + "[image&image-marker !][image&image-alt-text&link [[][image&image-alt-text&em&strong&link ***alt text***][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]"); + + // Inline link with title + MT("linkTitle", + "[link [[foo]]][string&url (http://example.com/ \"bar\")] hello"); + + // Inline link without title + MT("linkNoTitle", + "[link [[foo]]][string&url (http://example.com/)] bar"); + + // Inline link with image + MT("linkImage", + "[link [[][link&image&image-marker !][link&image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)][link ]]][string&url (http://example.com/)] bar"); + + // Inline link with Em + MT("linkEm", + "[link [[][link&em *foo*][link ]]][string&url (http://example.com/)] bar"); + + // Inline link with Strong + MT("linkStrong", + "[link [[][link&strong **foo**][link ]]][string&url (http://example.com/)] bar"); + + // Inline link with EmStrong + MT("linkEmStrong", + "[link [[][link&em&strong ***foo***][link ]]][string&url (http://example.com/)] bar"); + + MT("multilineLink", + "[link [[foo]", + "[link bar]]][string&url (https://foo#_a)]", + "should not be italics") + + // Image with title + MT("imageTitle", + "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/ \"bar\")] hello"); + + // Image without title + MT("imageNoTitle", + "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/)] bar"); + + // Image with asterisks + MT("imageAsterisks", + "[image&image-marker !][image&image-alt-text&link [[ ][image&image-alt-text&em&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)] bar"); + + // Not a link. Should be normal text due to square brackets being used + // regularly in text, especially in quoted material, and no space is allowed + // between square brackets and parentheses (per Dingus). + MT("notALink", + "[link [[foo]]] (bar)"); + + // Reference-style links + MT("linkReference", + "[link [[foo]]][string&url [[bar]]] hello"); + + // Reference-style links with Em + MT("linkReferenceEm", + "[link [[][link&em *foo*][link ]]][string&url [[bar]]] hello"); + + // Reference-style links with Strong + MT("linkReferenceStrong", + "[link [[][link&strong **foo**][link ]]][string&url [[bar]]] hello"); + + // Reference-style links with EmStrong + MT("linkReferenceEmStrong", + "[link [[][link&em&strong ***foo***][link ]]][string&url [[bar]]] hello"); + + // Reference-style links with optional space separator (per documentation) + // "You can optionally use a space to separate the sets of brackets" + MT("linkReferenceSpace", + "[link [[foo]]] [string&url [[bar]]] hello"); + + // Should only allow a single space ("...use *a* space...") + MT("linkReferenceDoubleSpace", + "[link [[foo]]] [link [[bar]]] hello"); + + // Reference-style links with implicit link name + MT("linkImplicit", + "[link [[foo]]][string&url [[]]] hello"); + + // @todo It would be nice if, at some point, the document was actually + // checked to see if the referenced link exists + + // Link label, for reference-style links (taken from documentation) + + MT("labelNoTitle", + "[link [[foo]]:] [string&url http://example.com/]"); + + MT("labelIndented", + " [link [[foo]]:] [string&url http://example.com/]"); + + MT("labelSpaceTitle", + "[link [[foo bar]]:] [string&url http://example.com/ \"hello\"]"); + + MT("labelDoubleTitle", + "[link [[foo bar]]:] [string&url http://example.com/ \"hello\"] \"world\""); + + MT("labelTitleDoubleQuotes", + "[link [[foo]]:] [string&url http://example.com/ \"bar\"]"); + + MT("labelTitleSingleQuotes", + "[link [[foo]]:] [string&url http://example.com/ 'bar']"); + + MT("labelTitleParentheses", + "[link [[foo]]:] [string&url http://example.com/ (bar)]"); + + MT("labelTitleInvalid", + "[link [[foo]]:] [string&url http://example.com/] bar"); + + MT("labelLinkAngleBrackets", + "[link [[foo]]:] [string&url \"bar\"]"); + + MT("labelTitleNextDoubleQuotes", + "[link [[foo]]:] [string&url http://example.com/]", + "[string \"bar\"] hello"); + + MT("labelTitleNextSingleQuotes", + "[link [[foo]]:] [string&url http://example.com/]", + "[string 'bar'] hello"); + + MT("labelTitleNextParentheses", + "[link [[foo]]:] [string&url http://example.com/]", + "[string (bar)] hello"); + + MT("labelTitleNextMixed", + "[link [[foo]]:] [string&url http://example.com/]", + "(bar\" hello"); + + MT("labelEscape", + "[link [[foo \\]] ]]:] [string&url http://example.com/]"); + + MT("labelEscapeColon", + "[link [[foo \\]]: bar]]:] [string&url http://example.com/]"); + + MT("labelEscapeEnd", + "\\[[foo\\]]: http://example.com/"); + + MT("linkWeb", + "[link ] foo"); + + MT("linkWebDouble", + "[link ] foo [link ]"); + + MT("linkEmail", + "[link ] foo"); + + MT("linkEmailDouble", + "[link ] foo [link ]"); + + MT("emAsterisk", + "[em *foo*] bar"); + + MT("emUnderscore", + "[em _foo_] bar"); + + MT("emInWordAsterisk", + "foo[em *bar*]hello"); + + MT("emInWordUnderscore", + "foo_bar_hello"); + + // Per documentation: "...surround an * or _ with spaces, it’ll be + // treated as a literal asterisk or underscore." + + MT("emEscapedBySpaceIn", + "foo [em _bar _ hello_] world"); + + MT("emEscapedBySpaceOut", + "foo _ bar [em _hello_] world"); + + MT("emEscapedByNewline", + "foo", + "_ bar [em _hello_] world"); + + // Unclosed emphasis characters + // Instead of simply marking as EM / STRONG, it would be nice to have an + // incomplete flag for EM and STRONG, that is styled slightly different. + MT("emIncompleteAsterisk", + "foo [em *bar]"); + + MT("emIncompleteUnderscore", + "foo [em _bar]"); + + MT("strongAsterisk", + "[strong **foo**] bar"); + + MT("strongUnderscore", + "[strong __foo__] bar"); + + MT("emStrongAsterisk", + "[em *foo][em&strong **bar*][strong hello**] world"); + + MT("emStrongUnderscore", + "[em _foo ][em&strong __bar_][strong hello__] world"); + + // "...same character must be used to open and close an emphasis span."" + MT("emStrongMixed", + "[em _foo][em&strong **bar*hello__ world]"); + + MT("emStrongMixed", + "[em *foo ][em&strong __bar_hello** world]"); + + MT("linkWithNestedParens", + "[link [[foo]]][string&url (bar(baz))]") + + // These characters should be escaped: + // \ backslash + // ` backtick + // * asterisk + // _ underscore + // {} curly braces + // [] square brackets + // () parentheses + // # hash mark + // + plus sign + // - minus sign (hyphen) + // . dot + // ! exclamation mark + + MT("escapeBacktick", + "foo \\`bar\\`"); + + MT("doubleEscapeBacktick", + "foo \\\\[comment `bar\\\\`]"); + + MT("escapeAsterisk", + "foo \\*bar\\*"); + + MT("doubleEscapeAsterisk", + "foo \\\\[em *bar\\\\*]"); + + MT("escapeUnderscore", + "foo \\_bar\\_"); + + MT("doubleEscapeUnderscore", + "foo \\\\[em _bar\\\\_]"); + + MT("escapeHash", + "\\# foo"); + + MT("doubleEscapeHash", + "\\\\# foo"); + + MT("escapeNewline", + "\\", + "[em *foo*]"); + + // Class override tests + TokenTypeOverrideTest("overrideHeader1", + "[override-header&override-header-1 # Foo]"); + + TokenTypeOverrideTest("overrideHeader2", + "[override-header&override-header-2 ## Foo]"); + + TokenTypeOverrideTest("overrideHeader3", + "[override-header&override-header-3 ### Foo]"); + + TokenTypeOverrideTest("overrideHeader4", + "[override-header&override-header-4 #### Foo]"); + + TokenTypeOverrideTest("overrideHeader5", + "[override-header&override-header-5 ##### Foo]"); + + TokenTypeOverrideTest("overrideHeader6", + "[override-header&override-header-6 ###### Foo]"); + + TokenTypeOverrideTest("overrideCode", + "[override-code `foo`]"); + + TokenTypeOverrideTest("overrideCodeBlock", + "[override-code ```]", + "[override-code foo]", + "[override-code ```]"); + + TokenTypeOverrideTest("overrideQuote", + "[override-quote&override-quote-1 > foo]", + "[override-quote&override-quote-1 > bar]"); + + TokenTypeOverrideTest("overrideQuoteNested", + "[override-quote&override-quote-1 > foo]", + "[override-quote&override-quote-1 >][override-quote&override-quote-2 > bar]", + "[override-quote&override-quote-1 >][override-quote&override-quote-2 >][override-quote&override-quote-3 > baz]"); + + TokenTypeOverrideTest("overrideLists", + "[override-list1 - foo]", + "", + " [override-list2 + bar]", + "", + " [override-list3 * baz]", + "", + " [override-list1 1. qux]", + "", + " [override-list2 - quux]"); + + TokenTypeOverrideTest("overrideHr", + "[override-hr * * *]"); + + TokenTypeOverrideTest("overrideImage", + "[override-image&override-image-marker !][override-image&override-image-alt-text&link [[alt text]]][override-link-href&url (http://link.to/image.jpg)]"); + + TokenTypeOverrideTest("overrideLinkText", + "[override-link-text [[foo]]][override-link-href&url (http://example.com)]"); + + TokenTypeOverrideTest("overrideLinkEmailAndInline", + "[override-link-email <][override-link-inline foo@example.com>]"); + + TokenTypeOverrideTest("overrideEm", + "[override-em *foo*]"); + + TokenTypeOverrideTest("overrideStrong", + "[override-strong **foo**]"); + + TokenTypeOverrideTest("overrideStrikethrough", + "[override-strikethrough ~~foo~~]"); + + TokenTypeOverrideTest("overrideEmoji", + "[override-emoji :foo:]"); + + FormatTokenTypeOverrideTest("overrideFormatting", + "[override-formatting-escape \\*]"); + + // Tests to make sure GFM-specific things aren't getting through + + MT("taskList", + "[variable-2 * ][link&variable-2 [[ ]]][variable-2 bar]"); + + MT("fencedCodeBlocks", + "[comment ```]", + "[comment foo]", + "", + "[comment bar]", + "[comment ```]", + "baz"); + + MT("fencedCodeBlocks_invalidClosingFence_trailingText", + "[comment ```]", + "[comment foo]", + "[comment ``` must not have trailing text]", + "[comment baz]"); + + MT("fencedCodeBlocks_invalidClosingFence_trailingTabs", + "[comment ```]", + "[comment foo]", + "[comment ```\t]", + "[comment baz]"); + + MT("fencedCodeBlocks_validClosingFence", + "[comment ```]", + "[comment foo]", + // may have trailing spaces + "[comment ``` ]", + "baz"); + + MT("fencedCodeBlocksInList_closingFenceIndented", + "[variable-2 - list]", + " [variable-2&comment ```]", + " [comment foo]", + " [variable-2&comment ```]", + " [variable-2 baz]"); + + MT("fencedCodeBlocksInList_closingFenceIndentedTooMuch", + "[variable-2 - list]", + " [variable-2&comment ```]", + " [comment foo]", + " [comment ```]", + " [comment baz]"); + + MT("fencedCodeBlockModeSwitching", + "[comment ```javascript]", + "[variable foo]", + "", + "[comment ```]", + "bar"); + + MT_noFencedHighlight("fencedCodeBlock_noHighlight", + "[comment ```javascript]", + "[comment foo]", + "[comment ```]"); + + MT("fencedCodeBlockModeSwitchingObjc", + "[comment ```objective-c]", + "[keyword @property] [variable NSString] [operator *] [variable foo];", + "[comment ```]", + "bar"); + + MT("fencedCodeBlocksMultipleChars", + "[comment `````]", + "[comment foo]", + "[comment ```]", + "[comment foo]", + "[comment `````]", + "bar"); + + MT("fencedCodeBlocksTildes", + "[comment ~~~]", + "[comment foo]", + "[comment ~~~]", + "bar"); + + MT("fencedCodeBlocksTildesMultipleChars", + "[comment ~~~~~]", + "[comment ~~~]", + "[comment foo]", + "[comment ~~~~~]", + "bar"); + + MT("fencedCodeBlocksMultipleChars", + "[comment `````]", + "[comment foo]", + "[comment ```]", + "[comment foo]", + "[comment `````]", + "bar"); + + MT("fencedCodeBlocksMixed", + "[comment ~~~]", + "[comment ```]", + "[comment foo]", + "[comment ~~~]", + "bar"); + + MT("fencedCodeBlocksAfterBlockquote", + "[quote"e-1 > foo]", + "[comment ```]", + "[comment bar]", + "[comment ```]"); + + // fencedCode indented too much should act as simple indentedCode + // (hence has no highlight formatting) + FT("tooMuchIndentedFencedCode", + " [comment ```]", + " [comment code]", + " [comment ```]"); + + MT("autoTerminateFencedCodeWhenLeavingList", + "[variable-2 - list1]", + " [variable-3 - list2]", + " [variable-3&comment ```]", + " [comment code]", + " [variable-3 - list2]", + " [variable-2&comment ```]", + " [comment code]", + "[quote"e-1 > foo]"); + + // Tests that require XML mode + + MT("xmlMode", + "[tag&bracket <][tag div][tag&bracket >]", + " *foo*", + " [tag&bracket <][tag http://github.com][tag&bracket />]", + "[tag&bracket ]", + "[link ]"); + + MT("xmlModeWithMarkdownInside", + "[tag&bracket <][tag div] [attribute markdown]=[string 1][tag&bracket >]", + "[em *foo*]", + "[link ]", + "[tag
]", + "[link ]", + "[tag&bracket <][tag div][tag&bracket >]", + "[tag&bracket ]"); + + MT("xmlModeLineBreakInTags", + "[tag&bracket <][tag div] [attribute id]=[string \"1\"]", + " [attribute class]=[string \"sth\"][tag&bracket >]xxx", + "[tag&bracket ]"); + + MT("xmlModeCommentWithBlankLine", + "[comment ]"); + + MT("xmlModeCDATA", + "[atom ]"); + + MT("xmlModePreprocessor", + "[meta ]"); + + MT_noXml("xmlHighlightDisabled", + "
foo
"); + + // Tests Emojis + + ET("emojiDefault", + "[builtin :foobar:]"); + + ET("emojiTable", + " :--:"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica/index.html new file mode 100644 index 0000000..accce20 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica/index.html @@ -0,0 +1,72 @@ + + +CodeMirror: Mathematica mode + + + + + + + + + + +
+

Mathematica mode

+ + + + + + +

MIME types defined: text/x-mathematica (Mathematica).

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica/mathematica.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica/mathematica.js index 07e808b..72b3492 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mathematica/mathematica.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Mathematica mode copyright (c) 2015 by Calin Barbat // Based on code by Patrick Scheibe (halirutan) diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox/index.html new file mode 100644 index 0000000..6dcc4b8 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox/index.html @@ -0,0 +1,44 @@ + + +CodeMirror: mbox mode + + + + + + + + + +
+

mbox mode

+
+ + +

MIME types defined: application/mbox.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox/mbox.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox/mbox.js index ba2416a..640437e 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mbox/mbox.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/meta.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/meta.js new file mode 100644 index 0000000..92b6807 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/meta.js @@ -0,0 +1,221 @@ +// 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"; + + CodeMirror.modeInfo = [ + {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]}, + {name: "PGP", mimes: ["application/pgp", "application/pgp-encrypted", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["asc", "pgp", "sig"]}, + {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]}, + {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i}, + {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]}, + {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]}, + {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]}, + {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]}, + {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp", "cs"]}, + {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]}, + {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]}, + {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]}, + {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists\.txt$/}, + {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, + {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]}, + {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]}, + {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]}, + {name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]}, + {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]}, + {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]}, + {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]}, + {name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]}, + {name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]}, + {name: "Django", mime: "text/x-django", mode: "django"}, + {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/}, + {name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]}, + {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]}, + {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"}, + {name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]}, + {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]}, + {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]}, + {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]}, + {name: "Embedded JavaScript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]}, + {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]}, + {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]}, + {name: "Esper", mime: "text/x-esper", mode: "sql"}, + {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]}, + {name: "FCL", mime: "text/x-fcl", mode: "fcl"}, + {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]}, + {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90", "f95"]}, + {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]}, + {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]}, + {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]}, + {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history)\.md$/i}, + {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]}, + {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/}, + {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]}, + {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]}, + {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]}, + {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]}, + {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]}, + {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]}, + {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm", "handlebars", "hbs"], alias: ["xhtml"]}, + {name: "HTTP", mime: "message/http", mode: "http"}, + {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]}, + {name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]}, + {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]}, + {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]}, + {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"], + mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]}, + {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]}, + {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]}, + {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]}, + {name: "Jinja2", mime: "text/jinja2", mode: "jinja2", ext: ["j2", "jinja", "jinja2"]}, + {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]}, + {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]}, + {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]}, + {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]}, + {name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]}, + {name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]}, + {name: "mIRC", mime: "text/mirc", mode: "mirc"}, + {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"}, + {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb", "wl", "wls"]}, + {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]}, + {name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]}, + {name: "MS SQL", mime: "text/x-mssql", mode: "sql"}, + {name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]}, + {name: "MySQL", mime: "text/x-mysql", mode: "sql"}, + {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i}, + {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]}, + {name: "NTriples", mimes: ["application/n-triples", "application/n-quads", "text/n-triples"], + mode: "ntriples", ext: ["nt", "nq"]}, + {name: "Objective-C", mime: "text/x-objectivec", mode: "clike", ext: ["m"], alias: ["objective-c", "objc"]}, + {name: "Objective-C++", mime: "text/x-objectivec++", mode: "clike", ext: ["mm"], alias: ["objective-c++", "objc++"]}, + {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]}, + {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]}, + {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]}, + {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]}, + {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]}, + {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]}, + {name: "PHP", mimes: ["text/x-php", "application/x-httpd-php", "application/x-httpd-php-open"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"]}, + {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]}, + {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]}, + {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]}, + {name: "PostgreSQL", mime: "text/x-pgsql", mode: "sql"}, + {name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]}, + {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]}, + {name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]}, + {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/}, + {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]}, + {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]}, + {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]}, + {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]}, + {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"}, + {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]}, + {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]}, + {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]}, + {name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]}, + {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]}, + {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]}, + {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]}, + {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]}, + {name: "Shell", mimes: ["text/x-sh", "application/x-sh"], mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/}, + {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]}, + {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]}, + {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]}, + {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]}, + {name: "Solr", mime: "text/x-solr", mode: "solr"}, + {name: "SML", mime: "text/x-sml", mode: "mllike", ext: ["sml", "sig", "fun", "smackspec"]}, + {name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]}, + {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]}, + {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]}, + {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]}, + {name: "SQLite", mime: "text/x-sqlite", mode: "sql"}, + {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]}, + {name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"]}, + {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]}, + {name: "sTeX", mime: "text/x-stex", mode: "stex"}, + {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx", "tex"], alias: ["tex"]}, + {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]}, + {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]}, + {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]}, + {name: "TiddlyWiki", mime: "text/x-tiddlywiki", mode: "tiddlywiki"}, + {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"}, + {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]}, + {name: "Tornado", mime: "text/x-tornado", mode: "tornado"}, + {name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]}, + {name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]}, + {name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]}, + {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]}, + {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]}, + {name: "TypeScript-JSX", mime: "text/typescript-jsx", mode: "jsx", ext: ["tsx"], alias: ["tsx"]}, + {name: "Twig", mime: "text/x-twig", mode: "twig"}, + {name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]}, + {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]}, + {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]}, + {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]}, + {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]}, + {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]}, + {name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]}, + {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"]}, + {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]}, + {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]}, + {name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]}, + {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}, + {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]}, + {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]}, + {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}, + {name: "WebAssembly", mime: "text/webassembly", mode: "wast", ext: ["wat", "wast"]}, + ]; + // Ensure all modes have a mime property for backwards compatibility + for (var i = 0; i < CodeMirror.modeInfo.length; i++) { + var info = CodeMirror.modeInfo[i]; + if (info.mimes) info.mime = info.mimes[0]; + } + + CodeMirror.findModeByMIME = function(mime) { + mime = mime.toLowerCase(); + for (var i = 0; i < CodeMirror.modeInfo.length; i++) { + var info = CodeMirror.modeInfo[i]; + if (info.mime == mime) return info; + if (info.mimes) for (var j = 0; j < info.mimes.length; j++) + if (info.mimes[j] == mime) return info; + } + if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME("application/xml") + if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME("application/json") + }; + + CodeMirror.findModeByExtension = function(ext) { + ext = ext.toLowerCase(); + for (var i = 0; i < CodeMirror.modeInfo.length; i++) { + var info = CodeMirror.modeInfo[i]; + if (info.ext) for (var j = 0; j < info.ext.length; j++) + if (info.ext[j] == ext) return info; + } + }; + + CodeMirror.findModeByFileName = function(filename) { + for (var i = 0; i < CodeMirror.modeInfo.length; i++) { + var info = CodeMirror.modeInfo[i]; + if (info.file && info.file.test(filename)) return info; + } + var dot = filename.lastIndexOf("."); + var ext = dot > -1 && filename.substring(dot + 1, filename.length); + if (ext) return CodeMirror.findModeByExtension(ext); + }; + + CodeMirror.findModeByName = function(name) { + name = name.toLowerCase(); + for (var i = 0; i < CodeMirror.modeInfo.length; i++) { + var info = CodeMirror.modeInfo[i]; + if (info.name.toLowerCase() == name) return info; + if (info.alias) for (var j = 0; j < info.alias.length; j++) + if (info.alias[j].toLowerCase() == name) return info; + } + }; +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc/index.html new file mode 100644 index 0000000..f81641b --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc/index.html @@ -0,0 +1,161 @@ + + +CodeMirror: mIRC mode + + + + + + + + + + + +
+

mIRC mode

+
+ + +

MIME types defined: text/mirc.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc/mirc.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc/mirc.js index 71ac4dd..d27b015 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mirc/mirc.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE //mIRC mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike/index.html new file mode 100644 index 0000000..6e8f264 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike/index.html @@ -0,0 +1,198 @@ + + +CodeMirror: ML-like mode + + + + + + + + + + +
+

OCaml mode

+ + + + +

F# mode

+ + + + + +

MIME types defined: text/x-ocaml (OCaml) and text/x-fsharp (F#).

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike/mllike.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike/mllike.js index 92b51cb..a1538f7 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mllike/mllike.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -41,6 +41,9 @@ CodeMirror.defineMode('mllike', function(_config, parserConfig) { words[prop] = parserConfig.extraWords[prop]; } } + var hintWords = []; + for (var k in words) { hintWords.push(k); } + CodeMirror.registerHelper("hintWords", "mllike", hintWords); function tokenBase(stream, state) { var ch = stream.next(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica/index.html new file mode 100644 index 0000000..9ab4b48 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica/index.html @@ -0,0 +1,67 @@ + + +CodeMirror: Modelica mode + + + + + + + + + + + + +
+

Modelica mode

+ +
+ + + +

Simple mode that tries to handle Modelica as well as it can.

+ +

MIME types defined: text/x-modelica + (Modlica code).

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica/modelica.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica/modelica.js index 77ec7a3..2e9622f 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/modelica/modelica.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Modelica support for CodeMirror, copyright (c) by Lennart Ochel @@ -90,7 +90,7 @@ return "error"; } - function tokenUnsignedNuber(stream, state) { + function tokenUnsignedNumber(stream, state) { stream.eatWhile(isDigit); if (stream.eat('.')) { stream.eatWhile(isDigit); @@ -164,9 +164,9 @@ else if(ch == '"') { state.tokenize = tokenString; } - // UNSIGNED_NUBER + // UNSIGNED_NUMBER else if(isDigit.test(ch)) { - state.tokenize = tokenUnsignedNuber; + state.tokenize = tokenUnsignedNumber; } // ERROR else { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/index.html new file mode 100644 index 0000000..5f2e826 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/index.html @@ -0,0 +1,151 @@ + + +CodeMirror: MscGen mode + + + + + + + + + +
+

MscGen mode

+ +
+ +

Xù mode

+ +
+ +

MsGenny mode

+
+ +

+ Simple mode for highlighting MscGen and two derived sequence + chart languages. +

+ + + +

MIME types defined: + text/x-mscgen + text/x-xu + text/x-msgenny +

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/mscgen.js similarity index 93% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/mscgen.js index 2cd6f42..8d39341 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/mscgen.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // mode(s) for the sequence chart dsl's mscgen, xù and msgenny // For more information on mscgen, see the site of the original author: @@ -33,9 +33,9 @@ }, xu: { "keywords" : ["msc", "xu"], - "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], + "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"], "constants" : ["true", "false", "on", "off", "auto"], - "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"], + "attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip", "title", "deactivate", "activate", "activation"], "brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists "arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"], "arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"], @@ -44,7 +44,7 @@ }, msgenny: { "keywords" : null, - "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], + "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"], "constants" : ["true", "false", "on", "off", "auto"], "attributes" : null, "brackets" : ["\\{", "\\}"], @@ -72,11 +72,11 @@ CodeMirror.defineMIME("text/x-msgenny", {name: "mscgen", language: "msgenny"}); function wordRegexpBoundary(pWords) { - return new RegExp("\\b(" + pWords.join("|") + ")\\b", "i"); + return new RegExp("^\\b(?:" + pWords.join("|") + ")\\b", "i"); } function wordRegexp(pWords) { - return new RegExp("(" + pWords.join("|") + ")", "i"); + return new RegExp("^(?:" + pWords.join("|") + ")", "i"); } function startStateFn() { @@ -153,7 +153,7 @@ return "variable"; /* attribute lists */ - if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) { + if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match('[', true, true)) { pConfig.inAttributeList = true; return "bracket"; } @@ -161,7 +161,7 @@ if (pConfig.attributes !== null && pStream.match(wordRegexpBoundary(pConfig.attributes), true, true)) { return "attribute"; } - if (pStream.match(/]/, true, true)) { + if (pStream.match(']', true, true)) { pConfig.inAttributeList = false; return "bracket"; } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/mscgen_test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/mscgen_test.js new file mode 100644 index 0000000..ff3816d --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/mscgen_test.js @@ -0,0 +1,84 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "mscgen"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("empty chart", + "[keyword msc][bracket {]", + "[base ]", + "[bracket }]" + ); + + MT("comments", + "[comment // a single line comment]", + "[comment # another single line comment /* and */ ignored here]", + "[comment /* A multi-line comment even though it contains]", + "[comment msc keywords and \"quoted text\"*/]"); + + MT("strings", + "[string \"// a string\"]", + "[string \"a string running over]", + "[string two lines\"]", + "[string \"with \\\"escaped quote\"]" + ); + + MT("xù/ msgenny keywords classify as 'base'", + "[base watermark]", + "[base wordwrapentities]", + "[base alt loop opt ref else break par seq assert]" + ); + + MT("xù/ msgenny constants classify as 'base'", + "[base auto]" + ); + + MT("mscgen constants classify as 'variable'", + "[variable true]", "[variable false]", "[variable on]", "[variable off]" + ); + + MT("mscgen options classify as keyword", + "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" + ); + + MT("mscgen arcs classify as keyword", + "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]", + "[keyword |||...---]", "[keyword ..--==::]", + "[keyword ->]", "[keyword <-]", "[keyword <->]", + "[keyword =>]", "[keyword <=]", "[keyword <=>]", + "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]", + "[keyword >>]", "[keyword <<]", "[keyword <<>>]", + "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]", + "[keyword :>]", "[keyword <:]", "[keyword <:>]" + ); + + MT("within an attribute list, attributes classify as attribute", + "[bracket [[][attribute label]", + "[attribute id]","[attribute url]","[attribute idurl]", + "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]", + "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]", + "[attribute arcskip][bracket ]]]" + ); + + MT("outside an attribute list, attributes classify as base", + "[base label]", + "[base id]","[base url]","[base idurl]", + "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]", + "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]", + "[base arcskip]" + ); + + MT("a typical program", + "[comment # typical mscgen program]", + "[keyword msc][base ][bracket {]", + "[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]", + "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]", + "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]", + "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]", + "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]", + "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]", + "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]", + "[bracket }]" + ); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/msgenny_test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/msgenny_test.js new file mode 100644 index 0000000..a3ed577 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/msgenny_test.js @@ -0,0 +1,77 @@ +// 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-msgenny"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "msgenny"); } + + MT("comments", + "[comment // a single line comment]", + "[comment # another single line comment /* and */ ignored here]", + "[comment /* A multi-line comment even though it contains]", + "[comment msc keywords and \"quoted text\"*/]"); + + MT("strings", + "[string \"// a string\"]", + "[string \"a string running over]", + "[string two lines\"]", + "[string \"with \\\"escaped quote\"]" + ); + + MT("xù/ msgenny keywords classify as 'keyword'", + "[keyword watermark]", + "[keyword wordwrapentities]", + "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" + ); + + MT("xù/ msgenny constants classify as 'variable'", + "[variable auto]", + "[variable true]", "[variable false]", "[variable on]", "[variable off]" + ); + + MT("mscgen options classify as keyword", + "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" + ); + + MT("mscgen arcs classify as keyword", + "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]", + "[keyword |||...---]", "[keyword ..--==::]", + "[keyword ->]", "[keyword <-]", "[keyword <->]", + "[keyword =>]", "[keyword <=]", "[keyword <=>]", + "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]", + "[keyword >>]", "[keyword <<]", "[keyword <<>>]", + "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]", + "[keyword :>]", "[keyword <:]", "[keyword <:>]" + ); + + MT("within an attribute list, mscgen/ xù attributes classify as base", + "[base [[label]", + "[base idurl id url]", + "[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]", + "[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]", + "[base arcskip]]]" + ); + + MT("outside an attribute list, mscgen/ xù attributes classify as base", + "[base label]", + "[base idurl id url]", + "[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]", + "[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]", + "[base arcskip]" + ); + + MT("a typical program", + "[comment # typical msgenny program]", + "[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]", + "[base a : ][string \"Entity A\"][base ,]", + "[base b : Entity B,]", + "[base c : Entity C;]", + "[base a ][keyword =>>][base b: ][string \"Hello entity B\"][base ;]", + "[base a ][keyword alt][base c][bracket {]", + "[base a ][keyword <<][base b: ][string \"Here's an answer dude!\"][base ;]", + "[keyword ---][base : ][string \"sorry, won't march - comm glitch\"]", + "[base a ][keyword x-][base b: ][string \"Here's an answer dude! (won't arrive...)\"][base ;]", + "[bracket }]", + "[base c ][keyword :>][base *: What about me?;]" + ); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/xu_test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/xu_test.js new file mode 100644 index 0000000..d65a058 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mscgen/xu_test.js @@ -0,0 +1,87 @@ +// 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-xu"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "xu"); } + + MT("empty chart", + "[keyword msc][bracket {]", + "[base ]", + "[bracket }]" + ); + + MT("empty chart", + "[keyword xu][bracket {]", + "[base ]", + "[bracket }]" + ); + + MT("comments", + "[comment // a single line comment]", + "[comment # another single line comment /* and */ ignored here]", + "[comment /* A multi-line comment even though it contains]", + "[comment msc keywords and \"quoted text\"*/]"); + + MT("strings", + "[string \"// a string\"]", + "[string \"a string running over]", + "[string two lines\"]", + "[string \"with \\\"escaped quote\"]" + ); + + MT("xù/ msgenny keywords classify as 'keyword'", + "[keyword watermark]", + "[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" + ); + + MT("xù/ msgenny constants classify as 'variable'", + "[variable auto]", + "[variable true]", "[variable false]", "[variable on]", "[variable off]" + ); + + MT("mscgen options classify as keyword", + "[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]" + ); + + MT("mscgen arcs classify as keyword", + "[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]", + "[keyword |||...---]", "[keyword ..--==::]", + "[keyword ->]", "[keyword <-]", "[keyword <->]", + "[keyword =>]", "[keyword <=]", "[keyword <=>]", + "[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]", + "[keyword >>]", "[keyword <<]", "[keyword <<>>]", + "[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]", + "[keyword :>]", "[keyword <:]", "[keyword <:>]" + ); + + MT("within an attribute list, attributes classify as attribute", + "[bracket [[][attribute label]", + "[attribute id]","[attribute url]","[attribute idurl]", + "[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]", + "[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]", + "[attribute arcskip]","[attribute title]", + "[attribute activate]","[attribute deactivate]","[attribute activation][bracket ]]]" + ); + + MT("outside an attribute list, attributes classify as base", + "[base label]", + "[base id]","[base url]","[base idurl]", + "[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]", + "[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]", + "[base arcskip]", "[base title]" + ); + + MT("a typical program", + "[comment # typical xu program]", + "[keyword xu][base ][bracket {]", + "[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30, ][keyword width][operator =][variable auto][base ;]", + "[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]", + "[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]", + "[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]", + "[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]", + "[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][base , ][attribute title][operator =][string \"This is a title for this message\"][bracket ]]][base ;]", + "[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]", + "[bracket }]" + ); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps/index.html new file mode 100644 index 0000000..4af4e0a --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps/index.html @@ -0,0 +1,85 @@ + + +CodeMirror: MUMPS mode + + + + + + + + + +
+

MUMPS mode

+ + +
+ + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps/mumps.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps/mumps.js index 469f8c3..c53b4bf 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/mumps/mumps.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /* This MUMPS Language script was constructed using vbscript.js as a template. @@ -26,7 +26,7 @@ var brackets = new RegExp("[()]"); var identifiers = new RegExp("^[%A-Za-z][A-Za-z0-9]*"); var commandKeywords = ["break","close","do","else","for","goto", "halt", "hang", "if", "job","kill","lock","merge","new","open", "quit", "read", "set", "tcommit", "trollback", "tstart", "use", "view", "write", "xecute", "b","c","d","e","f","g", "h", "i", "j","k","l","m","n","o", "q", "r", "s", "tc", "tro", "ts", "u", "v", "w", "x"]; - // The following list includes instrinsic functions _and_ special variables + // The following list includes intrinsic functions _and_ special variables var intrinsicFuncsWords = ["\\$ascii", "\\$char", "\\$data", "\\$ecode", "\\$estack", "\\$etrap", "\\$extract", "\\$find", "\\$fnumber", "\\$get", "\\$horolog", "\\$io", "\\$increment", "\\$job", "\\$justify", "\\$length", "\\$name", "\\$next", "\\$order", "\\$piece", "\\$qlength", "\\$qsubscript", "\\$query", "\\$quit", "\\$random", "\\$reverse", "\\$select", "\\$stack", "\\$test", "\\$text", "\\$translate", "\\$view", "\\$x", "\\$y", "\\$a", "\\$c", "\\$d", "\\$e", "\\$ec", "\\$es", "\\$et", "\\$f", "\\$fn", "\\$g", "\\$h", "\\$i", "\\$j", "\\$l", "\\$n", "\\$na", "\\$o", "\\$p", "\\$q", "\\$ql", "\\$qs", "\\$r", "\\$re", "\\$s", "\\$st", "\\$t", "\\$tr", "\\$v", "\\$z"]; var intrinsicFuncs = wordRegexp(intrinsicFuncsWords); var command = wordRegexp(commandKeywords); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx/index.html new file mode 100644 index 0000000..1aa690a --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx/index.html @@ -0,0 +1,181 @@ + + +CodeMirror: NGINX mode + + + + + + + + + + + + + +
+

NGINX mode

+
+ + +

MIME types defined: text/x-nginx-conf.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx/nginx.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx/nginx.js index 00a3224..a09f150 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nginx/nginx.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis/index.html new file mode 100644 index 0000000..71a65d7 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis/index.html @@ -0,0 +1,80 @@ + + +CodeMirror: NSIS mode + + + + + + + + + + + +
+

NSIS mode

+ + + + + + +

MIME types defined: text/x-nsis.

+
\ No newline at end of file diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis/nsis.js similarity index 75% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis/nsis.js index edc1b29..636940f 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/nsis/nsis.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Author: Jan T. Sott (http://github.com/idleberg) @@ -13,7 +13,7 @@ })(function(CodeMirror) { "use strict"; -CodeMirror.defineMode("nsis",{ +CodeMirror.defineSimpleMode("nsis",{ start:[ // Numbers {regex: /(?:[+-]?)(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\d+.?\d*)/, token: "number"}, @@ -31,7 +31,7 @@ CodeMirror.defineMode("nsis",{ {regex: /^\s*(?:\!(else|endif|macroend))\b/, token: "keyword", dedent: true}, // Runtime Commands - {regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecShellWait|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|Int64Cmp|Int64CmpU|Int64Fmt|IntCmp|IntCmpU|IntFmt|IntOp|IntPtrCmp|IntPtrCmpU|IntPtrOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|PEDllCharacteristics|PESubsysVer|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegMultiStr|WriteRegNone|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, + {regex: /^\s*(?:Abort|AddBrandingImage|AddSize|AllowRootDirInstall|AllowSkipFiles|AutoCloseWindow|BGFont|BGGradient|BrandingText|BringToFront|Call|CallInstDLL|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|CreateDirectory|CreateFont|CreateShortCut|Delete|DeleteINISec|DeleteINIStr|DeleteRegKey|DeleteRegValue|DetailPrint|DetailsButtonText|DirText|DirVar|DirVerify|EnableWindow|EnumRegKey|EnumRegValue|Exch|Exec|ExecShell|ExecShellWait|ExecWait|ExpandEnvStrings|File|FileBufSize|FileClose|FileErrorText|FileOpen|FileRead|FileReadByte|FileReadUTF16LE|FileReadWord|FileWriteUTF16LE|FileSeek|FileWrite|FileWriteByte|FileWriteWord|FindClose|FindFirst|FindNext|FindWindow|FlushINI|GetCurInstType|GetCurrentAddress|GetDlgItem|GetDLLVersion|GetDLLVersionLocal|GetErrorLevel|GetFileTime|GetFileTimeLocal|GetFullPathName|GetFunctionAddress|GetInstDirError|GetKnownFolderPath|GetLabelAddress|GetTempFileName|Goto|HideWindow|Icon|IfAbort|IfErrors|IfFileExists|IfRebootFlag|IfRtlLanguage|IfShellVarContextAll|IfSilent|InitPluginsDir|InstallButtonText|InstallColors|InstallDir|InstallDirRegKey|InstProgressFlags|InstType|InstTypeGetText|InstTypeSetText|Int64Cmp|Int64CmpU|Int64Fmt|IntCmp|IntCmpU|IntFmt|IntOp|IntPtrCmp|IntPtrCmpU|IntPtrOp|IsWindow|LangString|LicenseBkColor|LicenseData|LicenseForceSelection|LicenseLangString|LicenseText|LoadAndSetImage|LoadLanguageFile|LockWindow|LogSet|LogText|ManifestDPIAware|ManifestLongPathAware|ManifestMaxVersionTested|ManifestSupportedOS|MessageBox|MiscButtonText|Name|Nop|OutFile|Page|PageCallbacks|PEAddResource|PEDllCharacteristics|PERemoveResource|PESubsysVer|Pop|Push|Quit|ReadEnvStr|ReadINIStr|ReadRegDWORD|ReadRegStr|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|SectionGetFlags|SectionGetInstTypes|SectionGetSize|SectionGetText|SectionIn|SectionSetFlags|SectionSetInstTypes|SectionSetSize|SectionSetText|SendMessage|SetAutoClose|SetBrandingImage|SetCompress|SetCompressor|SetCompressorDictSize|SetCtlColors|SetCurInstType|SetDatablockOptimize|SetDateSave|SetDetailsPrint|SetDetailsView|SetErrorLevel|SetErrors|SetFileAttributes|SetFont|SetOutPath|SetOverwrite|SetRebootFlag|SetRegView|SetShellVarContext|SetSilent|ShowInstDetails|ShowUninstDetails|ShowWindow|SilentInstall|SilentUnInstall|Sleep|SpaceTexts|StrCmp|StrCmpS|StrCpy|StrLen|SubCaption|Unicode|UninstallButtonText|UninstallCaption|UninstallIcon|UninstallSubCaption|UninstallText|UninstPage|UnRegDLL|Var|VIAddVersionKey|VIFileVersion|VIProductVersion|WindowIcon|WriteINIStr|WriteRegBin|WriteRegDWORD|WriteRegExpandStr|WriteRegMultiStr|WriteRegNone|WriteRegStr|WriteUninstaller|XPStyle)\b/, token: "keyword"}, {regex: /^\s*(?:Function|PageEx|Section(?:Group)?)\b/, token: "keyword", indent: true}, {regex: /^\s*(?:(Function|PageEx|Section(?:Group)?)End)\b/, token: "keyword", dedent: true}, diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples/index.html new file mode 100644 index 0000000..275cf08 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples/index.html @@ -0,0 +1,70 @@ + + +CodeMirror: N-Triples mode + + + + + + + + + +
+

N-Triples mode

+

The N-Triples mode also works well with on + N-Quad documents. +

+
+ +
+ + +

MIME types defined: application/n-triples.

+ +
+

N-Quads add a fourth + element to the statement to track which graph the statement is from. + Otherwise, it's identical to N-Triples.

+
+ +
+ + +

MIME types defined: application/n-quads.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples/ntriples.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples/ntriples.js index 148272e..5dd0272 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ntriples/ntriples.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /********************************************************** * This script provides syntax highlighting support for diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave/index.html new file mode 100644 index 0000000..033e351 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave/index.html @@ -0,0 +1,84 @@ + + +CodeMirror: Octave mode + + + + + + + + + + +
+

Octave mode

+ +
+ + +

MIME types defined: text/x-octave.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave/octave.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave/octave.js index b77ad68..33a0336 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/octave/octave.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -17,7 +17,7 @@ CodeMirror.defineMode("octave", function() { } var singleOperators = new RegExp("^[\\+\\-\\*/&|\\^~<>!@'\\\\]"); - var singleDelimiters = new RegExp('^[\\(\\[\\{\\},:=;]'); + var singleDelimiters = new RegExp('^[\\(\\[\\{\\},:=;\\.]'); var doubleOperators = new RegExp("^((==)|(~=)|(<=)|(>=)|(<<)|(>>)|(\\.[\\+\\-\\*/\\^\\\\]))"); var doubleDelimiters = new RegExp("^((!=)|(\\+=)|(\\-=)|(\\*=)|(/=)|(&=)|(\\|=)|(\\^=))"); var tripleDelimiters = new RegExp("^((>>=)|(<<=))"); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz/index.html new file mode 100644 index 0000000..0b44d7f --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz/index.html @@ -0,0 +1,59 @@ + + +CodeMirror: Oz mode + + + + + + + + + + +
+

Oz mode

+ +

MIME type defined: text/x-oz.

+ + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz/oz.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz/oz.js index 50ffda3..73857e4 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/oz/oz.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -45,7 +45,7 @@ CodeMirror.defineMode("oz", function (conf) { } // Special [] keyword - if (stream.match(/(\[])/)) { + if (stream.match('[]')) { return "keyword" } @@ -130,7 +130,7 @@ CodeMirror.defineMode("oz", function (conf) { return "operator"; } - // If nothing match, we skip the entire alphanumerical block + // If nothing match, we skip the entire alphanumeric block stream.eatWhile(/\w/); return "variable"; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal/index.html new file mode 100644 index 0000000..414be54 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal/index.html @@ -0,0 +1,61 @@ + + +CodeMirror: Pascal mode + + + + + + + + + +
+

Pascal mode

+ + +
+ + + +

MIME types defined: text/x-pascal.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal/pascal.js similarity index 89% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal/pascal.js index 3240532..c48698b 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pascal/pascal.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -50,7 +50,11 @@ CodeMirror.defineMode("pascal", function() { state.tokenize = tokenComment; return tokenComment(stream, state); } - if (/[\[\]{}\(\),;\:\.]/.test(ch)) { + if (ch == "{") { + state.tokenize = tokenCommentBraces; + return tokenCommentBraces(stream, state); + } + if (/[\[\]\(\),;\:\.]/.test(ch)) { return null; } if (/\d/.test(ch)) { @@ -98,6 +102,17 @@ CodeMirror.defineMode("pascal", function() { return "comment"; } + function tokenCommentBraces(stream, state) { + var ch; + while (ch = stream.next()) { + if (ch == "}") { + state.tokenize = null; + break; + } + } + return "comment"; + } + // Interface return { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs/index.html new file mode 100644 index 0000000..47129f5 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs/index.html @@ -0,0 +1,66 @@ + + + + CodeMirror: PEG.js Mode + + + + + + + + + + + + +
+

PEG.js Mode

+
+ +

The PEG.js Mode

+

Created by Forbes Lindesay.

+
+ + diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs/pegjs.js similarity index 93% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs/pegjs.js index 6c72074..ac011d3 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pegjs/pegjs.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -39,7 +39,7 @@ CodeMirror.defineMode("pegjs", function (config) { stream.next(); // Skip quote state.inString = true; // Update state } - if (!state.inString && !state.inComment && stream.match(/^\/\*/)) { + if (!state.inString && !state.inComment && stream.match('/*')) { state.inComment = true; } @@ -59,7 +59,7 @@ CodeMirror.defineMode("pegjs", function (config) { return state.lhs ? "property string" : "string"; // Token style } else if (state.inComment) { while (state.inComment && !stream.eol()) { - if (stream.match(/\*\//)) { + if (stream.match('*/')) { state.inComment = false; // Clear flag } else { stream.match(/^.[^\*]*/); @@ -76,7 +76,7 @@ CodeMirror.defineMode("pegjs", function (config) { stream.next(); state.inCharacterClass = true; return 'bracket'; - } else if (stream.match(/^\/\//)) { + } else if (stream.match('//')) { stream.skipToEnd(); return "comment"; } else if (state.braced || stream.peek() === '{') { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl/index.html new file mode 100644 index 0000000..b879b33 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl/index.html @@ -0,0 +1,75 @@ + + +CodeMirror: Perl mode + + + + + + + + + +
+

Perl mode

+ + +
+ + + +

MIME types defined: text/x-perl.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl/perl.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl/perl.js index 66e4ed0..ffe7877 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/perl/perl.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08) // This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl (mail@sabaca.com) @@ -347,7 +347,7 @@ CodeMirror.defineMode("perl",function(){ lc :1, // - return lower-case version of a string lcfirst :1, // - return a string with just the next letter in lower case length :1, // - return the number of bytes in a string - 'link' :1, // - create a hard link in the filesytem + 'link' :1, // - create a hard link in the filesystem listen :1, // - register your socket as a server local : 2, // - create a temporary value for a global variable (dynamic scoping) localtime :1, // - convert UNIX time into record or string using local time @@ -441,7 +441,7 @@ CodeMirror.defineMode("perl",function(){ state :1, // - declare and assign a state variable (persistent lexical scoping) study :1, // - optimize input data for repeated searches 'sub' :1, // - declare a subroutine, possibly anonymously - 'substr' :1, // - get or alter a portion of a stirng + 'substr' :1, // - get or alter a portion of a string symlink :1, // - create a symbolic link to a file syscall :1, // - execute an arbitrary system call sysopen :1, // - open a file, pipe, or descriptor @@ -516,7 +516,7 @@ CodeMirror.defineMode("perl",function(){ if(stream.match(/^\-?[\d\.]/,false)) if(stream.match(/^(\-?(\d*\.\d+(e[+-]?\d+)?|\d+\.\d*)|0x[\da-fA-F]+|0b[01]+|\d+(e[+-]?\d+)?)/)) return 'number'; - if(stream.match(/^<<(?=\w)/)){ // NOTE: < + +CodeMirror: PHP mode + + + + + + + + + + + + + + + +
+

PHP mode

+
+ + + +

Simple HTML/PHP mode based on + the C-like mode. Depends on XML, + JavaScript, CSS, HTMLMixed, and C-like modes.

+ +

MIME types defined: application/x-httpd-php (HTML with PHP code), text/x-php (plain, non-wrapped PHP code).

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php/php.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php/php.js index 589c9a6..3202f50 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php/php.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -53,7 +53,7 @@ [["]", null]] ], closing, escapes); } - if (stream.match(/\-\>\w/, false)) { + if (stream.match(/^->\w/, false)) { // Match object operator state.tokenize = matchSequence([ [["->", null]], @@ -106,7 +106,7 @@ }, "<": function(stream, state) { var before; - if (before = stream.match(/<<\s*/)) { + if (before = stream.match(/^<<\s*/)) { var quoted = stream.eat(/['"]/); stream.eatWhile(/[\w\.]/); var delim = stream.current().slice(before[0].length + (quoted ? 2 : 1)); @@ -160,7 +160,7 @@ if (!isPHP) { if (stream.match(/^<\?\w*/)) { state.curMode = phpMode; - if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, "")) + if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, "", "")) state.curState = state.php; return "meta"; } @@ -213,11 +213,11 @@ token: dispatch, - indent: function(state, textAfter) { + indent: function(state, textAfter, line) { if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) || (state.curMode == phpMode && /^\?>/.test(textAfter))) - return htmlMode.indent(state.html, textAfter); - return state.curMode.indent(state.curState, textAfter); + return htmlMode.indent(state.html, textAfter, line); + return state.curMode.indent(state.curState, textAfter, line); }, blockCommentStart: "/*", diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php/test.js new file mode 100644 index 0000000..ec15814 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/php/test.js @@ -0,0 +1,154 @@ +// 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 ]'); + + MT('variable_interpolation_non_alphanumeric', + '[meta $/$\\$}$\\\"$:$;$?$|$[[$]]$+$=aaa"]', + '[meta ?>]'); + + MT('variable_interpolation_digits', + '[meta ]'); + + MT('variable_interpolation_simple_syntax_1', + '[meta ]'); + + MT('variable_interpolation_simple_syntax_2', + '[meta ]'); + + MT('variable_interpolation_simple_syntax_3', + '[meta [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 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 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 } $aaaaaa.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 ]'); + + 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 ]'); + + 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 ]'); + + MT("variable_interpolation_heredoc", + "[meta +CodeMirror: Pig Latin mode + + + + + + + + + +
+

Pig Latin mode

+
+ + + +

+ Simple mode that handles Pig Latin language. +

+ +

MIME type defined: text/x-pig + (PIG code) +

diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pig.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pig/pig.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pig.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pig/pig.js index 5b56727..3b9c774 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pig.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pig/pig.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /* * Pig Latin Mode for CodeMirror 2 diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/index.html new file mode 100644 index 0000000..fae0298 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/index.html @@ -0,0 +1,209 @@ + + + + + CodeMirror: Powershell mode + + + + + + + + + +
+

PowerShell mode

+ +
+ + +

MIME types defined: application/x-powershell.

+
+ + diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/powershell.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/powershell.js index 2728ef9..4869ae7 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/powershell.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { 'use strict'; @@ -38,7 +38,7 @@ CodeMirror.defineMode('powershell', function() { /param|process|return|switch|throw|trap|try|until|where|while/ ], { suffix: notCharacterOrDash }); - var punctuation = /[\[\]{},;`\.]|@[({]/; + var punctuation = /[\[\]{},;`\\\.]|@[({]/; var wordOperators = buildRegexp([ 'f', /b?not/, diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/test.js new file mode 100644 index 0000000..261406d --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/powershell/test.js @@ -0,0 +1,74 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "powershell"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + function forEach(arr, f) { for (var i = 0; i < arr.length; i++) f(arr[i], i) } + + MT('comment', '[number 1][comment # A]'); + MT('comment_multiline', '[number 1][comment <#]', + '[comment ABC]', + '[comment #>][number 2]'); + + forEach([ + '0', '1234', + '12kb', '12mb', '12Gb', '12Tb', '12PB', '12L', '12D', '12lkb', '12dtb', + '1.234', '1.234e56', '1.', '1.e2', '.2', '.2e34', + '1.2MB', '1.kb', '.1dTB', '1.e1gb', '.2', '.2e34', + '0x1', '0xabcdef', '0x3tb', '0xelmb' + ], function(number) { + MT("number_" + number, "[number " + number + "]"); + }); + + MT('string_literal_escaping', "[string 'a''']"); + MT('string_literal_variable', "[string 'a $x']"); + MT('string_escaping_1', '[string "a `""]'); + MT('string_escaping_2', '[string "a """]'); + MT('string_variable_escaping', '[string "a `$x"]'); + MT('string_variable', '[string "a ][variable-2 $x][string b"]'); + MT('string_variable_spaces', '[string "a ][variable-2 ${x y}][string b"]'); + MT('string_expression', '[string "a ][punctuation $(][variable-2 $x][operator +][number 3][punctuation )][string b"]'); + MT('string_expression_nested', '[string "A][punctuation $(][string "a][punctuation $(][string "w"][punctuation )][string b"][punctuation )][string B"]'); + + MT('string_heredoc', '[string @"]', + '[string abc]', + '[string "@]'); + MT('string_heredoc_quotes', '[string @"]', + '[string abc "\']', + '[string "@]'); + MT('string_heredoc_variable', '[string @"]', + '[string a ][variable-2 $x][string b]', + '[string "@]'); + MT('string_heredoc_nested_string', '[string @"]', + '[string a][punctuation $(][string "w"][punctuation )][string b]', + '[string "@]'); + MT('string_heredoc_literal_quotes', "[string @']", + '[string abc "\']', + "[string '@]"); + + MT('array', "[punctuation @(][string 'a'][punctuation ,][string 'b'][punctuation )]"); + MT('hash', "[punctuation @{][string 'key'][operator :][string 'value'][punctuation }]"); + + MT('variable', "[variable-2 $test]"); + MT('variable_global', "[variable-2 $global:test]"); + MT('variable_spaces', "[variable-2 ${test test}]"); + MT('operator_splat', "[variable-2 @x]"); + MT('variable_builtin', "[builtin $ErrorActionPreference]"); + MT('variable_builtin_symbols', "[builtin $$]"); + + MT('operator', "[operator +]"); + MT('operator_unary', "[operator +][number 3]"); + MT('operator_long', "[operator -match]"); + + forEach([ + '(', ')', '[[', ']]', '{', '}', ',', '`', ';', '.', '\\' + ], function(punctuation) { + MT("punctuation_" + punctuation.replace(/^[\[\]]/,''), "[punctuation " + punctuation + "]"); + }); + + MT('keyword', "[keyword if]"); + + MT('call_builtin', "[builtin Get-ChildItem]"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties/index.html new file mode 100644 index 0000000..d121dc9 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties/index.html @@ -0,0 +1,53 @@ + + +CodeMirror: Properties files mode + + + + + + + + + +
+

Properties files mode

+
+ + +

MIME types defined: text/x-properties, + text/x-ini.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties/properties.js similarity index 96% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties/properties.js index ef8bf37..02fd7fe 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/properties/properties.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf/index.html new file mode 100644 index 0000000..9af2cff --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf/index.html @@ -0,0 +1,104 @@ + + +CodeMirror: ProtoBuf mode + + + + + + + + + +
+

ProtoBuf mode

+
+ +
+ + +

MIME types defined: text/x-protobuf.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf/protobuf.js similarity index 93% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf/protobuf.js index 93cb3b0..40b0842 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/protobuf/protobuf.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -62,7 +62,10 @@ }; CodeMirror.defineMode("protobuf", function() { - return {token: tokenBase}; + return { + token: tokenBase, + fold: "brace" + }; }); CodeMirror.defineMIME("text/x-protobuf", "protobuf"); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug/index.html new file mode 100644 index 0000000..a36f047 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug/index.html @@ -0,0 +1,70 @@ + + +CodeMirror: Pug Templating Mode + + + + + + + + + + + + + +
+

Pug Templating Mode

+
+ +

The Pug Templating Mode

+

Created by Forbes Lindesay. Managed as part of a Brackets extension at https://github.com/ForbesLindesay/jade-brackets.

+

MIME type defined: text/x-pug, text/x-jade.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug/pug.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug/pug.js index 4018233..73e9ae2 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/pug/pug.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -261,7 +261,7 @@ CodeMirror.defineMode("pug", function (config) { } return 'variable'; } - if (stream.match(/^\+#{/, false)) { + if (stream.match('+#{', false)) { stream.next(); state.mixinCallAfter = true; return interpolation(stream, state); @@ -545,12 +545,12 @@ CodeMirror.defineMode("pug", function (config) { || javaScriptArguments(stream, state) || callArguments(stream, state) - || yieldStatement(stream, state) - || doctype(stream, state) + || yieldStatement(stream) + || doctype(stream) || interpolation(stream, state) || caseStatement(stream, state) || when(stream, state) - || defaultStatement(stream, state) + || defaultStatement(stream) || extendsStatement(stream, state) || append(stream, state) || prepend(stream, state) @@ -565,16 +565,16 @@ CodeMirror.defineMode("pug", function (config) { || tag(stream, state) || filter(stream, state) || code(stream, state) - || id(stream, state) - || className(stream, state) + || id(stream) + || className(stream) || attrs(stream, state) || attributesBlock(stream, state) - || indent(stream, state) + || indent(stream) || text(stream, state) || comment(stream, state) - || colon(stream, state) + || colon(stream) || dot(stream, state) - || fail(stream, state); + || fail(stream); return tok === true ? null : tok; } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet/index.html new file mode 100644 index 0000000..fe29237 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet/index.html @@ -0,0 +1,121 @@ + + +CodeMirror: Puppet mode + + + + + + + + + + +
+

Puppet mode

+
+ + +

MIME types defined: text/x-puppet.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet/puppet.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet/puppet.js index 5704130..a92ca11 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/puppet/puppet.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -176,7 +176,7 @@ CodeMirror.defineMode("puppet", function () { // Match characters that we are going to assume // are trying to be regex if (ch == '/') { - stream.match(/.*?\//); + stream.match(/^[^\/]*\//); return 'variable-3'; } // Match all the numbers diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/index.html new file mode 100644 index 0000000..78a3a14 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/index.html @@ -0,0 +1,207 @@ + + +CodeMirror: Python mode + + + + + + + + + + +
+

Python mode

+ +
+ + +

Cython mode

+ +
+ + +

Configuration Options for Python mode:

+
    +
  • version - 2/3 - The version of Python to recognize. Default is 3.
  • +
  • singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.
  • +
  • hangingIndent - int - If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.
  • +
+

Advanced Configuration Options:

+

Useful for superset of python syntax like Enthought enaml, IPython magics and questionmark help

+
    +
  • singleOperators - RegEx - Regular Expression for single operator matching, default :
    ^[\\+\\-\\*/%&|\\^~<>!]
    including
    @
    on Python 3
  • +
  • singleDelimiters - RegEx - Regular Expression for single delimiter matching, default :
    ^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]
  • +
  • doubleOperators - RegEx - Regular Expression for double operators matching, default :
    ^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))
  • +
  • doubleDelimiters - RegEx - Regular Expression for double delimiters matching, default :
    ^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))
  • +
  • tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default :
    ^((//=)|(>>=)|(<<=)|(\\*\\*=))
  • +
  • identifiers - RegEx - Regular Expression for identifier, default :
    ^[_A-Za-z][_A-Za-z0-9]*
    on Python 2 and
    ^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*
    on Python 3.
  • +
  • extra_keywords - list of string - List of extra words ton consider as keywords
  • +
  • extra_builtins - list of string - List of extra words ton consider as builtins
  • +
+ + +

MIME types defined: text/x-python and text/x-cython.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/python.js similarity index 90% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/python.js index a13a850..de5fd38 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/python.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -42,9 +42,9 @@ var ERRORCLASS = "error"; var delimiters = parserConf.delimiters || parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.\\]/; - // (Backwards-compatiblity with old, cumbersome config system) + // (Backwards-compatibility with old, cumbersome config system) var operators = [parserConf.singleOperators, parserConf.doubleOperators, parserConf.doubleDelimiters, parserConf.tripleDelimiters, - parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@])/] + parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/] for (var i = 0; i < operators.length; i++) if (!operators[i]) operators.splice(i--, 1) var hangingIndent = parserConf.hangingIndent || conf.indentUnit; @@ -98,11 +98,11 @@ return tokenBaseInner(stream, state); } - function tokenBaseInner(stream, state) { + function tokenBaseInner(stream, state, inFormat) { if (stream.eatSpace()) return null; // Handle Comments - if (stream.match(/^#.*/)) return "comment"; + if (!inFormat && stream.match(/^#.*/)) return "comment"; // Handle Number Literals if (stream.match(/^[0-9\.]/, false)) { @@ -144,7 +144,7 @@ if (stream.match(stringPrefixes)) { var isFmtString = stream.current().toLowerCase().indexOf('f') !== -1; if (!isFmtString) { - state.tokenize = tokenStringFactory(stream.current()); + state.tokenize = tokenStringFactory(stream.current(), state.tokenize); return state.tokenize(stream, state); } else { state.tokenize = formatStringFactory(stream.current(), state.tokenize); @@ -177,7 +177,7 @@ // Handle non-detected items stream.next(); - return ERRORCLASS; + return inFormat ? null :ERRORCLASS; } function formatStringFactory(delimiter, tokenOuter) { @@ -187,23 +187,18 @@ var singleline = delimiter.length == 1; var OUTCLASS = "string"; - function tokenFString(stream, state) { - // inside f-str Expression - if (stream.match(delimiter)) { - // expression ends pre-maturally, but very common in editing - // Could show error to remind users to close brace here - state.tokenize = tokenString - return OUTCLASS; - } else if (stream.match('{')) { - // starting brace, if not eaten below - return "punctuation"; - } else if (stream.match('}')) { - // return to regular inside string state - state.tokenize = tokenString - return "punctuation"; - } else { - // use tokenBaseInner to parse the expression - return tokenBaseInner(stream, state); + function tokenNestedExpr(depth) { + return function(stream, state) { + var inner = tokenBaseInner(stream, state, true) + if (inner == "punctuation") { + if (stream.current() == "{") { + state.tokenize = tokenNestedExpr(depth + 1) + } else if (stream.current() == "}") { + if (depth > 1) state.tokenize = tokenNestedExpr(depth - 1) + else state.tokenize = tokenString + } + } + return inner } } @@ -222,14 +217,9 @@ return OUTCLASS; } else if (stream.match('{', false)) { // switch to nested mode - state.tokenize = tokenFString - if (stream.current()) { - return OUTCLASS; - } else { - // need to return something, so eat the starting { - stream.next(); - return "punctuation"; - } + state.tokenize = tokenNestedExpr(0) + if (stream.current()) return OUTCLASS; + else return state.tokenize(stream, state) } else if (stream.match('}}')) { return OUTCLASS; } else if (stream.match('}')) { @@ -251,7 +241,7 @@ return tokenString; } - function tokenStringFactory(delimiter) { + function tokenStringFactory(delimiter, tokenOuter) { while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) delimiter = delimiter.substr(1); @@ -266,7 +256,7 @@ if (singleline && stream.eol()) return OUTCLASS; } else if (stream.match(delimiter)) { - state.tokenize = tokenBase; + state.tokenize = tokenOuter; return OUTCLASS; } else { stream.eat(/['"]/); @@ -276,7 +266,7 @@ if (parserConf.singleLineStringErrors) return ERRORCLASS; else - state.tokenize = tokenBase; + state.tokenize = tokenOuter; } return OUTCLASS; } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/test.js new file mode 100644 index 0000000..39b80cf --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/python/test.js @@ -0,0 +1,44 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 4}, + {name: "python", + version: 3, + singleLineStringErrors: false}); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + // Error, because "foobarhello" is neither a known type or property, but + // property was expected (after "and"), and it should be in parentheses. + MT("decoratorStartOfLine", + "[meta @dec]", + "[keyword def] [def function]():", + " [keyword pass]"); + + MT("decoratorIndented", + "[keyword class] [def Foo]:", + " [meta @dec]", + " [keyword def] [def function]():", + " [keyword pass]"); + + MT("matmulWithSpace:", "[variable a] [operator @] [variable b]"); + MT("matmulWithoutSpace:", "[variable a][operator @][variable b]"); + MT("matmulSpaceBefore:", "[variable a] [operator @][variable b]"); + var before_equal_sign = ["+", "-", "*", "/", "=", "!", ">", "<"]; + for (var i = 0; i < before_equal_sign.length; ++i) { + var c = before_equal_sign[i] + MT("before_equal_sign_" + c, "[variable a] [operator " + c + "=] [variable b]"); + } + + MT("fValidStringPrefix", "[string f'this is a]{[variable formatted]}[string string']"); + MT("fValidExpressionInFString", "[string f'expression ]{[number 100][operator *][number 5]}[string string']"); + MT("fInvalidFString", "[error f'this is wrong}]"); + MT("fNestedFString", "[string f'expression ]{[number 100] [operator +] [string f'inner]{[number 5]}[string ']}[string string']"); + MT("uValidStringPrefix", "[string u'this is an unicode string']"); + + MT("nestedString", "[string f']{[variable b][[ [string \"c\"] ]]}[string f'] [comment # oops]") + + MT("bracesInFString", "[string f']{[variable x] [operator +] {}}[string !']") + + MT("nestedFString", "[string f']{[variable b][[ [string f\"c\"] ]]}[string f'] [comment # oops]") +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q/index.html new file mode 100644 index 0000000..a34b7b4 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q/index.html @@ -0,0 +1,144 @@ + + +CodeMirror: Q mode + + + + + + + + + + +
+

Q mode

+ + +
+ + + +

MIME type defined: text/x-q.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q/q.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q/q.js index 9aee18a..c016a6a 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/q/q.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r/index.html new file mode 100644 index 0000000..da8745f --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r/index.html @@ -0,0 +1,88 @@ + + +CodeMirror: R mode + + + + + + + + + +
+

R mode

+
+ + +

MIME types defined: text/x-rsrc.

+ +

Development of the CodeMirror R mode was kindly sponsored + by Ubalo.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r/r.js similarity index 88% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r/r.js index be7db46..c422af9 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/r/r.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -14,15 +14,22 @@ CodeMirror.registerHelper("wordChars", "r", /[\w.]/); CodeMirror.defineMode("r", function(config) { - function wordObj(str) { - var words = str.split(" "), res = {}; + function wordObj(words) { + var res = {}; for (var i = 0; i < words.length; ++i) res[words[i]] = true; return res; } - var atoms = wordObj("NULL NA Inf NaN NA_integer_ NA_real_ NA_complex_ NA_character_"); - var builtins = wordObj("list quote bquote eval return call parse deparse"); - var keywords = wordObj("if else repeat while function for in next break"); - var blockkeywords = wordObj("if else repeat while function for"); + var commonAtoms = ["NULL", "NA", "Inf", "NaN", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_", "TRUE", "FALSE"]; + var commonBuiltins = ["list", "quote", "bquote", "eval", "return", "call", "parse", "deparse"]; + var commonKeywords = ["if", "else", "repeat", "while", "function", "for", "in", "next", "break"]; + var commonBlockKeywords = ["if", "else", "repeat", "while", "function", "for"]; + + CodeMirror.registerHelper("hintWords", "r", commonAtoms.concat(commonBuiltins, commonKeywords)); + + var atoms = wordObj(commonAtoms); + var builtins = wordObj(commonBuiltins); + var keywords = wordObj(commonKeywords); + var blockkeywords = wordObj(commonBlockKeywords); var opChars = /[+\-*\/^<>=!&|~$:]/; var curPunc; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/changes/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/changes/index.html new file mode 100644 index 0000000..9d244ec --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/changes/index.html @@ -0,0 +1,66 @@ + + +CodeMirror: RPM changes mode + + + + + + + + + + + +
+

RPM changes mode

+ +
+ + +

MIME types defined: text/x-rpm-changes.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/index.html new file mode 100644 index 0000000..aa1dec9 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/index.html @@ -0,0 +1,149 @@ + + +CodeMirror: RPM changes mode + + + + + + + + + + + +
+

RPM changes mode

+ +
+ + +

RPM spec mode

+ +
+ + +

MIME types defined: text/x-rpm-spec, text/x-rpm-changes.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/rpm.js similarity index 93% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/rpm.js index 87cde59..bb9ec9f 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rpm/rpm.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -12,14 +12,14 @@ "use strict"; CodeMirror.defineMode("rpm-changes", function() { - var headerSeperator = /^-+$/; + var headerSeparator = /^-+$/; var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /; var simpleEmail = /^[\w+.-]+@[\w.-]+/; return { token: function(stream) { if (stream.sol()) { - if (stream.match(headerSeperator)) { return 'tag'; } + if (stream.match(headerSeparator)) { return 'tag'; } if (stream.match(headerLine)) { return 'tag'; } } if (stream.match(simpleEmail)) { return 'string'; } @@ -80,12 +80,12 @@ CodeMirror.defineMode("rpm-spec", function() { // Macros like '%make_install' or '%attr(0775,root,root)' if (stream.match(/^%[\w]+/)) { - if (stream.match(/^\(/)) { state.macroParameters = true; } + if (stream.match('(')) { state.macroParameters = true; } return "keyword"; } if (state.macroParameters) { if (stream.match(/^\d+/)) { return "number";} - if (stream.match(/^\)/)) { + if (stream.match(')')) { state.macroParameters = false; return "keyword"; } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst/index.html new file mode 100644 index 0000000..4e001f8 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst/index.html @@ -0,0 +1,535 @@ + + +CodeMirror: reStructuredText mode + + + + + + + + + + +
+

reStructuredText mode

+
+ + +

+ The python mode will be used for highlighting blocks + containing Python/IPython terminal sessions: blocks starting with + >>> (for Python) or In [num]: (for + IPython). + + Further, the stex mode will be used for highlighting + blocks containing LaTex code. +

+ +

MIME types defined: text/x-rst.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst/rst.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst/rst.js index bcf110c..f14eb27 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rst/rst.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/index.html new file mode 100644 index 0000000..daebdca --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/index.html @@ -0,0 +1,183 @@ + + +CodeMirror: Ruby mode + + + + + + + + + + +
+

Ruby mode

+
+ + +

MIME types defined: text/x-ruby.

+ +

Development of the CodeMirror Ruby mode was kindly sponsored + by Ubalo.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/ruby.js similarity index 84% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/ruby.js index 874c183..85bbfc6 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/ruby.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -11,24 +11,28 @@ })(function(CodeMirror) { "use strict"; +function wordObj(words) { + var o = {}; + for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true; + return o; +} + +var keywordList = [ + "alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else", + "elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or", + "redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless", + "until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc", + "caller", "lambda", "proc", "public", "protected", "private", "require", "load", + "require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__" +], keywords = wordObj(keywordList); + +var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then", + "catch", "loop", "proc", "begin"]); +var dedentWords = wordObj(["end", "until"]); +var opening = {"[": "]", "{": "}", "(": ")"}; +var closing = {"]": "[", "}": "{", ")": "("}; + CodeMirror.defineMode("ruby", function(config) { - function wordObj(words) { - var o = {}; - for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true; - return o; - } - var keywords = wordObj([ - "alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else", - "elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or", - "redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless", - "until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc", - "caller", "lambda", "proc", "public", "protected", "private", "require", "load", - "require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__" - ]); - var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then", - "catch", "loop", "proc", "begin"]); - var dedentWords = wordObj(["end", "until"]); - var matching = {"[": "]", "{": "}", "(": ")"}; var curPunc; function chain(newtok, stream, state) { @@ -58,13 +62,13 @@ CodeMirror.defineMode("ruby", function(config) { else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; } var delim = stream.eat(/[^\w\s=]/); if (!delim) return "operator"; - if (matching.propertyIsEnumerable(delim)) delim = matching[delim]; + if (opening.propertyIsEnumerable(delim)) delim = opening[delim]; return chain(readQuoted(delim, style, embed, true), stream, state); } else if (ch == "#") { stream.skipToEnd(); return "comment"; - } else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) { - return chain(readHereDoc(m[1]), stream, state); + } else if (ch == "<" && (m = stream.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) { + return chain(readHereDoc(m[2], m[1]), stream, state); } else if (ch == "0") { if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/); else if (stream.eat("b")) stream.eatWhile(/[01]/); @@ -216,8 +220,9 @@ CodeMirror.defineMode("ruby", function(config) { return style; }; } - function readHereDoc(phrase) { + function readHereDoc(phrase, mayIndent) { return function(stream, state) { + if (mayIndent) stream.eatSpace() if (stream.match(phrase)) state.tokenize.pop(); else stream.skipToEnd(); return "string"; @@ -276,12 +281,12 @@ CodeMirror.defineMode("ruby", function(config) { }, indent: function(state, textAfter) { - if (state.tokenize[state.tokenize.length-1] != tokenBase) return 0; + if (state.tokenize[state.tokenize.length-1] != tokenBase) return CodeMirror.Pass; var firstChar = textAfter && textAfter.charAt(0); var ct = state.context; - var closing = ct.type == matching[firstChar] || + var closed = ct.type == closing[firstChar] || ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter); - return ct.indented + (closing ? 0 : config.indentUnit) + + return ct.indented + (closed ? 0 : config.indentUnit) + (state.continuedLine ? config.indentUnit : 0); }, @@ -293,4 +298,6 @@ CodeMirror.defineMode("ruby", function(config) { CodeMirror.defineMIME("text/x-ruby", "ruby"); +CodeMirror.registerHelper("hintWords", "ruby", keywordList); + }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/test.js new file mode 100644 index 0000000..905c0e4 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ruby/test.js @@ -0,0 +1,23 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "ruby"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("divide_equal_operator", + "[variable bar] [operator /=] [variable foo]"); + + MT("divide_equal_operator_no_spacing", + "[variable foo][operator /=][number 42]"); + + MT("complex_regexp", + "[keyword if] [variable cr] [operator =~] [string-2 /(?: \\( #{][tag RE_NOT][string-2 }\\( | #{][tag RE_NOT_PAR_OR][string-2 }* #{][tag RE_OPA_OR][string-2 } )/][variable x]") + + MT("indented_heredoc", + "[keyword def] [def x]", + " [variable y] [operator =] [string <<-FOO]", + "[string bar]", + "[string FOO]", + "[keyword end]") +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/index.html new file mode 100644 index 0000000..071ba02 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/index.html @@ -0,0 +1,64 @@ + + +CodeMirror: Rust mode + + + + + + + + + + +
+

Rust mode

+ + +
+ + + +

MIME types defined: text/x-rustsrc.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/rust.js similarity index 82% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/rust.js index 79b0b76..f95f320 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/rust.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -11,7 +11,7 @@ })(function(CodeMirror) { "use strict"; -CodeMirror.defineMode("rust",{ +CodeMirror.defineSimpleMode("rust",{ start: [ // string and byte string {regex: /b?"/, token: "string", next: "string"}, @@ -25,8 +25,8 @@ CodeMirror.defineMode("rust",{ {regex: /(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/, token: "number"}, - {regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]}, - {regex: /(?:abstract|alignof|as|box|break|continue|const|crate|do|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"}, + {regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type|union)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]}, + {regex: /(?:abstract|alignof|as|async|await|box|break|continue|const|crate|do|dyn|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"}, {regex: /\b(?:Self|isize|usize|char|bool|u8|u16|u32|u64|f16|f32|f64|i8|i16|i32|i64|str|Option)\b/, token: "atom"}, {regex: /\b(?:true|false|Some|None|Ok|Err)\b/, token: "builtin"}, {regex: /\b(fn)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/test.js new file mode 100644 index 0000000..36c5cde --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/rust/test.js @@ -0,0 +1,39 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 4}, "rust"); + function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));} + + MT('integer_test', + '[number 123i32]', + '[number 123u32]', + '[number 123_u32]', + '[number 0xff_u8]', + '[number 0o70_i16]', + '[number 0b1111_1111_1001_0000_i32]', + '[number 0usize]'); + + MT('float_test', + '[number 123.0f64]', + '[number 0.1f64]', + '[number 0.1f32]', + '[number 12E+99_f64]'); + + MT('string-literals-test', + '[string "foo"]', + '[string r"foo"]', + '[string "\\"foo\\""]', + '[string r#""foo""#]', + '[string "foo #\\"# bar"]', + + '[string b"foo"]', + '[string br"foo"]', + '[string b"\\"foo\\""]', + '[string br#""foo""#]', + '[string br##"foo #" bar"##]', + + "[string-2 'h']", + "[string-2 b'h']"); + +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas/index.html new file mode 100644 index 0000000..7877002 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas/index.html @@ -0,0 +1,81 @@ + + +CodeMirror: SAS mode + + + + + + + + + + +
+

SAS mode

+
+ + + +

MIME types defined: text/x-sas.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas/sas.js old mode 100644 new mode 100755 similarity index 76% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas/sas.js index d85b335..49b96b6 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sas/sas.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // SAS mode copyright (c) 2016 Jared Dean, SAS Institute @@ -88,7 +88,7 @@ define('def', 'source2 nosource2 page pageno pagesize', ['ALL']); //proc and datastep - define('def', '_all_ _character_ _cmd_ _freq_ _i_ _infile_ _last_ _msg_ _null_ _numeric_ _temporary_ _type_ abort abs addr adjrsq airy alpha alter altlog altprint and arcos array arsin as atan attrc attrib attrn authserver autoexec awscontrol awsdef awsmenu awsmenumerge awstitle backward band base betainv between blocksize blshift bnot bor brshift bufno bufsize bxor by byerr byline byte calculated call cards cards4 catcache cbufno cdf ceil center cexist change chisq cinv class cleanup close cnonct cntllev coalesce codegen col collate collin column comamid comaux1 comaux2 comdef compbl compound compress config continue convert cos cosh cpuid create cross crosstab css curobs cv daccdb daccdbsl daccsl daccsyd dacctab dairy datalines datalines4 datejul datepart datetime day dbcslang dbcstype dclose ddm delete delimiter depdb depdbsl depsl depsyd deptab dequote descending descript design= device dflang dhms dif digamma dim dinfo display distinct dkricond dkrocond dlm dnum do dopen doptname doptnum dread drop dropnote dsname dsnferr echo else emaildlg emailid emailpw emailserver emailsys encrypt end endsas engine eof eov erf erfc error errorcheck errors exist exp fappend fclose fcol fdelete feedback fetch fetchobs fexist fget file fileclose fileexist filefmt filename fileref fmterr fmtsearch fnonct fnote font fontalias fopen foptname foptnum force formatted formchar formdelim formdlim forward fpoint fpos fput fread frewind frlen from fsep fuzz fwrite gaminv gamma getoption getvarc getvarn go goto group gwindow hbar hbound helpenv helploc hms honorappearance hosthelp hostprint hour hpct html hvar ibessel ibr id if index indexc indexw initcmd initstmt inner input inputc inputn inr insert int intck intnx into intrr invaliddata irr is jbessel join juldate keep kentb kurtosis label lag last lbound leave left length levels lgamma lib library libref line linesize link list log log10 log2 logpdf logpmf logsdf lostcard lowcase lrecl ls macro macrogen maps mautosource max maxdec maxr mdy mean measures median memtype merge merror min minute missing missover mlogic mod mode model modify month mopen mort mprint mrecall msglevel msymtabmax mvarsize myy n nest netpv new news nmiss no nobatch nobs nocaps nocardimage nocenter nocharcode nocmdmac nocol nocum nodate nodbcs nodetails nodmr nodms nodmsbatch nodup nodupkey noduplicates noechoauto noequals noerrorabend noexitwindows nofullstimer noicon noimplmac noint nolist noloadlist nomiss nomlogic nomprint nomrecall nomsgcase nomstored nomultenvappl nonotes nonumber noobs noovp nopad nopercent noprint noprintinit normal norow norsasuser nosetinit nosplash nosymbolgen note notes notitle notitles notsorted noverbose noxsync noxwait npv null number numkeys nummousekeys nway obs on open order ordinal otherwise out outer outp= output over ovp p(1 5 10 25 50 75 90 95 99) pad pad2 paired parm parmcards path pathdll pathname pdf peek peekc pfkey pmf point poisson poke position printer probbeta probbnml probchi probf probgam probhypr probit probnegb probnorm probsig probt procleave prt ps pw pwreq qtr quote r ranbin rancau ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni read recfm register regr remote remove rename repeat replace resolve retain return reuse reverse rewind right round rsquare rtf rtrace rtraceloc s s2 samploc sasautos sascontrol sasfrscr sasmsg sasmstore sasscript sasuser saving scan sdf second select selection separated seq serror set setcomm setot sign simple sin sinh siteinfo skewness skip sle sls sortedby sortpgm sortseq sortsize soundex spedis splashlocation split spool sqrt start std stderr stdin stfips stimer stname stnamel stop stopover subgroup subpopn substr sum sumwgt symbol symbolgen symget symput sysget sysin sysleave sysmsg sysparm sysprint sysprintfont sysprod sysrc system t table tables tan tanh tapeclose tbufsize terminal test then timepart tinv tnonct to today tol tooldef totper transformout translate trantab tranwrd trigamma trim trimn trunc truncover type unformatted uniform union until upcase update user usericon uss validate value var weight when where while wincharset window work workinit workterm write wsum xsync xwait yearcutoff yes yyq min max', ['inDataStep', 'inProc']); + define('def', '_all_ _character_ _cmd_ _freq_ _i_ _infile_ _last_ _msg_ _null_ _numeric_ _temporary_ _type_ abort abs addr adjrsq airy alpha alter altlog altprint and arcos array arsin as atan attrc attrib attrn authserver autoexec awscontrol awsdef awsmenu awsmenumerge awstitle backward band base betainv between blocksize blshift bnot bor brshift bufno bufsize bxor by byerr byline byte calculated call cards cards4 catcache cbufno cdf ceil center cexist change chisq cinv class cleanup close cnonct cntllev coalesce codegen col collate collin column comamid comaux1 comaux2 comdef compbl compound compress config continue convert cos cosh cpuid create cross crosstab css curobs cv daccdb daccdbsl daccsl daccsyd dacctab dairy datalines datalines4 datejul datepart datetime day dbcslang dbcstype dclose ddfm ddm delete delimiter depdb depdbsl depsl depsyd deptab dequote descending descript design= device dflang dhms dif digamma dim dinfo display distinct dkricond dkrocond dlm dnum do dopen doptname doptnum dread drop dropnote dsname dsnferr echo else emaildlg emailid emailpw emailserver emailsys encrypt end endsas engine eof eov erf erfc error errorcheck errors exist exp fappend fclose fcol fdelete feedback fetch fetchobs fexist fget file fileclose fileexist filefmt filename fileref fmterr fmtsearch fnonct fnote font fontalias fopen foptname foptnum force formatted formchar formdelim formdlim forward fpoint fpos fput fread frewind frlen from fsep fuzz fwrite gaminv gamma getoption getvarc getvarn go goto group gwindow hbar hbound helpenv helploc hms honorappearance hosthelp hostprint hour hpct html hvar ibessel ibr id if index indexc indexw initcmd initstmt inner input inputc inputn inr insert int intck intnx into intrr invaliddata irr is jbessel join juldate keep kentb kurtosis label lag last lbound leave left length levels lgamma lib library libref line linesize link list log log10 log2 logpdf logpmf logsdf lostcard lowcase lrecl ls macro macrogen maps mautosource max maxdec maxr mdy mean measures median memtype merge merror min minute missing missover mlogic mod mode model modify month mopen mort mprint mrecall msglevel msymtabmax mvarsize myy n nest netpv new news nmiss no nobatch nobs nocaps nocardimage nocenter nocharcode nocmdmac nocol nocum nodate nodbcs nodetails nodmr nodms nodmsbatch nodup nodupkey noduplicates noechoauto noequals noerrorabend noexitwindows nofullstimer noicon noimplmac noint nolist noloadlist nomiss nomlogic nomprint nomrecall nomsgcase nomstored nomultenvappl nonotes nonumber noobs noovp nopad nopercent noprint noprintinit normal norow norsasuser nosetinit nosplash nosymbolgen note notes notitle notitles notsorted noverbose noxsync noxwait npv null number numkeys nummousekeys nway obs on open order ordinal otherwise out outer outp= output over ovp p(1 5 10 25 50 75 90 95 99) pad pad2 paired parm parmcards path pathdll pathname pdf peek peekc pfkey pmf point poisson poke position printer probbeta probbnml probchi probf probgam probhypr probit probnegb probnorm probsig probt procleave prt ps pw pwreq qtr quote r ranbin rancau random ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni rcorr read recfm register regr remote remove rename repeat repeated replace resolve retain return reuse reverse rewind right round rsquare rtf rtrace rtraceloc s s2 samploc sasautos sascontrol sasfrscr sasmsg sasmstore sasscript sasuser saving scan sdf second select selection separated seq serror set setcomm setot sign simple sin sinh siteinfo skewness skip sle sls sortedby sortpgm sortseq sortsize soundex spedis splashlocation split spool sqrt start std stderr stdin stfips stimer stname stnamel stop stopover sub subgroup subpopn substr sum sumwgt symbol symbolgen symget symput sysget sysin sysleave sysmsg sysparm sysprint sysprintfont sysprod sysrc system t table tables tan tanh tapeclose tbufsize terminal test then timepart tinv tnonct to today tol tooldef totper transformout translate trantab tranwrd trigamma trim trimn trunc truncover type unformatted uniform union until upcase update user usericon uss validate value var weight when where while wincharset window work workinit workterm write wsum xsync xwait yearcutoff yes yyq min max', ['inDataStep', 'inProc']); define('operator', 'and not ', ['inDataStep', 'inProc']); // Main function diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/index.html new file mode 100644 index 0000000..bf5cdb2 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/index.html @@ -0,0 +1,68 @@ + + +CodeMirror: Sass mode + + + + + + + + + + + +
+

Sass mode

+
+ + +

MIME types defined: text/x-sass.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/sass.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/sass.js index 7d8135b..1258e14 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/sass.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -231,7 +231,7 @@ CodeMirror.defineMode("sass", function(config) { } if(ch === "@"){ - if(stream.match(/@extend/)){ + if(stream.match('@extend')){ if(!stream.match(/\s*[\w]/)) dedent(state); } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/test.js new file mode 100644 index 0000000..63d7919 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sass/test.js @@ -0,0 +1,122 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "sass"); + // Since Sass has an indent-based syntax, is almost impossible to test correctly the indentation in all cases. + // So disable it for tests. + mode.indent = undefined; + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("comment", + "[comment // this is a comment]", + "[comment also this is a comment]") + + MT("comment_multiline", + "[comment /* this is a comment]", + "[comment also this is a comment]") + + MT("variable", + "[variable-2 $page-width][operator :] [number 800][unit px]") + + MT("global_attributes", + "[tag body]", + " [property font][operator :]", + " [property family][operator :] [atom sans-serif]", + " [property size][operator :] [number 30][unit em]", + " [property weight][operator :] [atom bold]") + + MT("scoped_styles", + "[builtin #contents]", + " [property width][operator :] [variable-2 $page-width]", + " [builtin #sidebar]", + " [property float][operator :] [atom right]", + " [property width][operator :] [variable-2 $sidebar-width]", + " [builtin #main]", + " [property width][operator :] [variable-2 $page-width] [operator -] [variable-2 $sidebar-width]", + " [property background][operator :] [variable-2 $primary-color]", + " [tag h2]", + " [property color][operator :] [keyword blue]") + + // Sass allows to write the colon as first char instead of a "separator". + // :color red + // Not supported + // MT("property_syntax", + // "[qualifier .foo]", + // " [operator :][property color] [keyword red]") + + MT("import", + "[def @import] [string \"sass/variables\"]", + // Probably it should parsed as above: as a string even without the " or ' + // "[def @import] [string sass/baz]" + "[def @import] [tag sass][operator /][tag baz]") + + MT("def", + "[def @if] [variable-2 $foo] [def @else]") + + MT("tag_on_more_lines", + "[tag td],", + "[tag th]", + " [property font-family][operator :] [string \"Arial\"], [atom serif]") + + MT("important", + "[qualifier .foo]", + " [property text-decoration][operator :] [atom none] [keyword !important]", + "[tag h1]", + " [property font-size][operator :] [number 2.5][unit em]") + + MT("selector", + // SCSS doesn't highlight the : + // "[tag h1]:[variable-3 before],", + // "[tag h2]:[variable-3 before]", + "[tag h1][variable-3 :before],", + "[tag h2][variable-3 :before]", + " [property content][operator :] [string \"::\"]") + + MT("definition_mixin_equal", + "[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]", + "[meta =bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )]", + " [meta -webkit-][property box-sizing][operator :] [variable-2 $bs-type]", + " [property box-sizing][operator :] [variable-2 $bs-type]") + + MT("definition_mixin_with_space", + "[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]", + "[def @mixin] [tag bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )] ", + " [meta -moz-][property box-sizing][operator :] [variable-2 $bs-type]", + " [property box-sizing][operator :] [variable-2 $bs-type]") + + MT("numbers_start_dot_include_plus", + // The % is not highlighted correctly + // "[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][unit %][operator )][operator )]", + "[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][operator %))]", + " [property padding][operator :] [number .3][unit em] [number .6][unit em]", + " [variable-3 +border-radius][operator (][number 8][unit px][operator )]", + " [property background-color][operator :] [variable-2 $button-base]") + + MT("include", + "[qualifier .bar]", + " [def @include] [tag border-radius][operator (][number 8][unit px][operator )]") + + MT("reference_parent", + "[qualifier .col]", + " [property clear][operator :] [atom both]", + // SCSS doesn't highlight the : + // " &:[variable-3 after]", + " &[variable-3 :after]", + " [property content][operator :] [string '']", + " [property clear][operator :] [atom both]") + + MT("reference_parent_with_spaces", + "[tag section]", + " [property border-left][operator :] [number 20][unit px] [atom transparent] [atom solid] ", + " &[qualifier .section3]", + " [qualifier .title]", + " [property color][operator :] [keyword white] ", + " [qualifier .vermas]", + " [property display][operator :] [atom none]") + + MT("font_face", + "[def @font-face]", + " [property font-family][operator :] [string 'icomoon']", + " [property src][operator :] [atom url][operator (][string fonts/icomoon.ttf][operator )]") +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme/index.html new file mode 100644 index 0000000..d0c140e --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme/index.html @@ -0,0 +1,77 @@ + + +CodeMirror: Scheme mode + + + + + + + + + +
+

Scheme mode

+
+ + +

MIME types defined: text/x-scheme.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme/scheme.js similarity index 74% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme/scheme.js index 1d8f7d1..370250d 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/scheme/scheme.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /** * Author: Koh Zi Han, based on implementation by Koh Zi Chun @@ -26,8 +26,8 @@ CodeMirror.defineMode("scheme", function () { return obj; } - var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"); - var indentKeys = makeKeywords("define let letrec let* lambda"); + var keywords = makeKeywords("λ case-lambda call/cc class cond-expand define-class define-values exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax define-macro defmacro delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?"); + var indentKeys = makeKeywords("define let letrec let* lambda define-macro defmacro let-syntax letrec-syntax let-values let*-values define-syntax syntax-rules define-values when unless"); function stateStack(indent, type, prev) { // represents a state stack object this.indent = indent; @@ -73,7 +73,8 @@ CodeMirror.defineMode("scheme", function () { indentStack: null, indentation: 0, mode: false, - sExprComment: false + sExprComment: false, + sExprQuote: false }; }, @@ -121,7 +122,7 @@ CodeMirror.defineMode("scheme", function () { state.sExprComment = 0; }else{ // if not we just comment the entire of the next token - stream.eatWhile(/[^/s]/); // eat non spaces + stream.eatWhile(/[^\s\(\)\[\]]/); // eat symbol atom returnType = COMMENT; break; } @@ -133,7 +134,15 @@ CodeMirror.defineMode("scheme", function () { returnType = STRING; } else if (ch == "'") { - returnType = ATOM; + if (stream.peek() == "(" || stream.peek() == "["){ + if (typeof state.sExprQuote != "number") { + state.sExprQuote = 0; + } // else already in a quoted expression + returnType = ATOM; + } else { + stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/); + returnType = ATOM; + } } else if (ch == '#') { if (stream.eat("|")) { // Multi-line comment state.mode = "comment"; // toggle to comment mode @@ -161,7 +170,7 @@ CodeMirror.defineMode("scheme", function () { } else if (stream.match(/^[-+0-9.]/, false)) { hasRadix = false; numTest = isDecimalNumber; - // re-consume the intial # if all matches failed + // re-consume the initial # if all matches failed } else if (!hasExactness) { stream.eat('#'); } @@ -209,6 +218,7 @@ CodeMirror.defineMode("scheme", function () { stream.backUp(stream.current().length - 1); // undo all the eating if(typeof state.sExprComment == "number") state.sExprComment++; + if(typeof state.sExprQuote == "number") state.sExprQuote++; returnType = BRACKET; } else if (ch == ")" || ch == "]") { @@ -222,6 +232,12 @@ CodeMirror.defineMode("scheme", function () { state.sExprComment = false; // turn off s-expr commenting mode } } + if(typeof state.sExprQuote == "number"){ + if(--state.sExprQuote == 0){ + returnType = ATOM; // final closing bracket + state.sExprQuote = false; // turn off s-expr quote mode + } + } } } else { stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/); @@ -231,7 +247,7 @@ CodeMirror.defineMode("scheme", function () { } else returnType = "variable"; } } - return (typeof state.sExprComment == "number") ? COMMENT : returnType; + return (typeof state.sExprComment == "number") ? COMMENT : ((typeof state.sExprQuote == "number") ? ATOM : returnType); }, indent: function (state) { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/index.html new file mode 100644 index 0000000..6aed459 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/index.html @@ -0,0 +1,66 @@ + + +CodeMirror: Shell mode + + + + + + + + + + +
+

Shell mode

+ + + + + + +

MIME types defined: text/x-sh, application/x-sh.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/shell.js similarity index 70% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/shell.js index b806c2b..8271485 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/shell.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -14,26 +14,27 @@ CodeMirror.defineMode('shell', function() { var words = {}; - function define(style, string) { - var split = string.split(' '); - for(var i = 0; i < split.length; i++) { - words[split[i]] = style; + function define(style, dict) { + for(var i = 0; i < dict.length; i++) { + words[dict[i]] = style; } }; - // Atoms - define('atom', 'true false'); + var commonAtoms = ["true", "false"]; + var commonKeywords = ["if", "then", "do", "else", "elif", "while", "until", "for", "in", "esac", "fi", + "fin", "fil", "done", "exit", "set", "unset", "export", "function"]; + var commonCommands = ["ab", "awk", "bash", "beep", "cat", "cc", "cd", "chown", "chmod", "chroot", "clear", + "cp", "curl", "cut", "diff", "echo", "find", "gawk", "gcc", "get", "git", "grep", "hg", "kill", "killall", + "ln", "ls", "make", "mkdir", "openssl", "mv", "nc", "nl", "node", "npm", "ping", "ps", "restart", "rm", + "rmdir", "sed", "service", "sh", "shopt", "shred", "source", "sort", "sleep", "ssh", "start", "stop", + "su", "sudo", "svn", "tee", "telnet", "top", "touch", "vi", "vim", "wall", "wc", "wget", "who", "write", + "yes", "zsh"]; - // Keywords - define('keyword', 'if then do else elif while until for in esac fi fin ' + - 'fil done exit set unset export function'); + CodeMirror.registerHelper("hintWords", "shell", commonAtoms.concat(commonKeywords, commonCommands)); - // Commands - define('builtin', 'ab awk bash beep cat cc cd chown chmod chroot clear cp ' + - 'curl cut diff echo find gawk gcc get git grep hg kill killall ln ls make ' + - 'mkdir openssl mv nc node npm ping ps restart rm rmdir sed service sh ' + - 'shopt shred source sort sleep ssh start stop su sudo svn tee telnet top ' + - 'touch vi vim wall wc wget who write yes zsh'); + define('atom', commonAtoms); + define('keyword', commonKeywords); + define('builtin', commonCommands); function tokenBase(stream, state) { if (stream.eatSpace()) return null; @@ -69,6 +70,14 @@ CodeMirror.defineMode('shell', function() { stream.eatWhile(/\w/); return 'attribute'; } + if (ch == "<") { + if (stream.match("<<")) return "operator" + var heredoc = stream.match(/^<-?\s*['"]?([^'"]*)['"]?/) + if (heredoc) { + state.tokens.unshift(tokenHeredoc(heredoc[1])) + return 'string-2' + } + } if (/\d/.test(ch)) { stream.eatWhile(/\d/); if(stream.eol() || !/\w/.test(stream.peek())) { @@ -128,6 +137,14 @@ CodeMirror.defineMode('shell', function() { return 'def'; }; + function tokenHeredoc(delim) { + return function(stream, state) { + if (stream.sol() && stream.string == delim) state.tokens.shift() + stream.skipToEnd() + return "string-2" + } + } + function tokenize(stream, state) { return (state.tokens[0] || tokenBase) (stream, state); }; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/test.js new file mode 100644 index 0000000..237375d --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/shell/test.js @@ -0,0 +1,80 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({}, "shell"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("var", + "text [def $var] text"); + MT("varBraces", + "text[def ${var}]text"); + MT("varVar", + "text [def $a$b] text"); + MT("varBracesVarBraces", + "text[def ${a}${b}]text"); + + MT("singleQuotedVar", + "[string 'text $var text']"); + MT("singleQuotedVarBraces", + "[string 'text ${var} text']"); + + MT("doubleQuotedVar", + '[string "text ][def $var][string text"]'); + MT("doubleQuotedVarBraces", + '[string "text][def ${var}][string text"]'); + MT("doubleQuotedVarPunct", + '[string "text ][def $@][string text"]'); + MT("doubleQuotedVarVar", + '[string "][def $a$b][string "]'); + MT("doubleQuotedVarBracesVarBraces", + '[string "][def ${a}${b}][string "]'); + + MT("notAString", + "text\\'text"); + MT("escapes", + "outside\\'\\\"\\`\\\\[string \"inside\\`\\'\\\"\\\\`\\$notAVar\"]outside\\$\\(notASubShell\\)"); + + MT("subshell", + "[builtin echo] [quote $(whoami)] s log, stardate [quote `date`]."); + MT("doubleQuotedSubshell", + "[builtin echo] [string \"][quote $(whoami)][string 's log, stardate `date`.\"]"); + + MT("hashbang", + "[meta #!/bin/bash]"); + MT("comment", + "text [comment # Blurb]"); + + MT("numbers", + "[number 0] [number 1] [number 2]"); + MT("keywords", + "[keyword while] [atom true]; [keyword do]", + " [builtin sleep] [number 3]", + "[keyword done]"); + MT("options", + "[builtin ls] [attribute -l] [attribute --human-readable]"); + MT("operator", + "[def var][operator =]value"); + + MT("doubleParens", + "foo [quote $((bar))]") + + MT("nested braces", + "[builtin echo] [def ${A[${B}]]}]") + + MT("strings in parens", + "[def FOO][operator =]([quote $(<][string \"][def $MYDIR][string \"][quote /myfile grep ][string 'hello$'][quote )])") + + MT("string ending in dollar", + '[def a][operator =][string "xyz$"]; [def b][operator =][string "y"]') + + MT("quote ending in dollar", + "[quote $(echo a$)]") + + MT("heredoc", + "[builtin cat] [string-2 <<- end]", + "[string-2 content one]", + "[string-2 content two end]", + "[string-2 end]", + "[builtin echo]") +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve/index.html new file mode 100644 index 0000000..ebceba3 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve/index.html @@ -0,0 +1,93 @@ + + +CodeMirror: Sieve (RFC5228) mode + + + + + + + + + +
+

Sieve (RFC5228) mode

+
+ + +

MIME types defined: application/sieve.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve/sieve.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve/sieve.js index 0920d0b..b723640 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sieve/sieve.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -43,7 +43,7 @@ CodeMirror.defineMode("sieve", function(config) { if (ch == "(") { state._indent.push("("); // add virtual angel wings so that editor behaves... - // ...more sane incase of broken brackets + // ...more sane in case of broken brackets state._indent.push("{"); return null; } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/index.html new file mode 100644 index 0000000..bade96d --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/index.html @@ -0,0 +1,96 @@ + + +CodeMirror: SLIM mode + + + + + + + + + + + + + + + + + + + + +
+

SLIM mode

+
+ + +

MIME types defined: application/x-slim.

+ +

+ Parsing/Highlighting Tests: + normal, + verbose. +

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/slim.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/slim.js index 991a97e..b8ccb13 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/slim.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Slim Highlighting for CodeMirror copyright (c) HicknHack Software Gmbh diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/test.js new file mode 100644 index 0000000..991797f --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/slim/test.js @@ -0,0 +1,96 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Slim Highlighting for CodeMirror copyright (c) HicknHack Software Gmbh + +(function() { + var mode = CodeMirror.getMode({tabSize: 4, indentUnit: 2}, "slim"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + // Requires at least one media query + MT("elementName", + "[tag h1] Hey There"); + + MT("oneElementPerLine", + "[tag h1] Hey There .h2"); + + MT("idShortcut", + "[attribute&def #test] Hey There"); + + MT("tagWithIdShortcuts", + "[tag h1][attribute&def #test] Hey There"); + + MT("classShortcut", + "[attribute&qualifier .hello] Hey There"); + + MT("tagWithIdAndClassShortcuts", + "[tag h1][attribute&def #test][attribute&qualifier .hello] Hey There"); + + MT("docType", + "[keyword doctype] xml"); + + MT("comment", + "[comment / Hello WORLD]"); + + MT("notComment", + "[tag h1] This is not a / comment "); + + MT("attributes", + "[tag a]([attribute title]=[string \"test\"]) [attribute href]=[string \"link\"]}"); + + MT("multiLineAttributes", + "[tag a]([attribute title]=[string \"test\"]", + " ) [attribute href]=[string \"link\"]}"); + + MT("htmlCode", + "[tag&bracket <][tag h1][tag&bracket >]Title[tag&bracket ]"); + + MT("rubyBlock", + "[operator&special =][variable-2 @item]"); + + MT("selectorRubyBlock", + "[tag a][attribute&qualifier .test][operator&special =] [variable-2 @item]"); + + MT("nestedRubyBlock", + "[tag a]", + " [operator&special =][variable puts] [string \"test\"]"); + + MT("multilinePlaintext", + "[tag p]", + " | Hello,", + " World"); + + MT("multilineRuby", + "[tag p]", + " [comment /# this is a comment]", + " [comment and this is a comment too]", + " | Date/Time", + " [operator&special -] [variable now] [operator =] [tag DateTime][operator .][property now]", + " [tag strong][operator&special =] [variable now]", + " [operator&special -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][property parse]([string \"December 31, 2006\"])", + " [operator&special =][string \"Happy\"]", + " [operator&special =][string \"Belated\"]", + " [operator&special =][string \"Birthday\"]"); + + MT("multilineComment", + "[comment /]", + " [comment Multiline]", + " [comment Comment]"); + + MT("hamlAfterRubyTag", + "[attribute&qualifier .block]", + " [tag strong][operator&special =] [variable now]", + " [attribute&qualifier .test]", + " [operator&special =][variable now]", + " [attribute&qualifier .right]"); + + MT("stretchedRuby", + "[operator&special =] [variable puts] [string \"Hello\"],", + " [string \"World\"]"); + + MT("interpolationInHashAttribute", + "[tag div]{[attribute id] = [string \"]#{[variable test]}[string _]#{[variable ting]}[string \"]} test"); + + MT("interpolationInHTMLAttribute", + "[tag div]([attribute title]=[string \"]#{[variable test]}[string _]#{[variable ting]()}[string \"]) Test"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk/index.html new file mode 100644 index 0000000..a64b2ff --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk/index.html @@ -0,0 +1,68 @@ + + +CodeMirror: Smalltalk mode + + + + + + + + + + +
+

Smalltalk mode

+
+ + + +

Simple Smalltalk mode.

+ +

MIME types defined: text/x-stsrc.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk/smalltalk.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk/smalltalk.js index bb510ba..5039fe2 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smalltalk/smalltalk.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty/index.html new file mode 100644 index 0000000..2f7ea88 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty/index.html @@ -0,0 +1,138 @@ + + +CodeMirror: Smarty mode + + + + + + + + + + +
+

Smarty mode

+
+ +

Mode for Smarty version 2 or 3, which allows for custom delimiter tags.

+ +

Several configuration parameters are supported:

+ +
    +
  • leftDelimiter and rightDelimiter, + which should be strings that determine where the Smarty syntax + starts and ends.
  • +
  • version, which should be 2 or 3.
  • +
  • baseMode, which can be a mode spec + like "text/html" to set a different background mode.
  • +
+ +

MIME types defined: text/x-smarty

+ +

Smarty 2, custom delimiters

+ +
+ +

Smarty 3

+ + + + + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty/smarty.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty/smarty.js index 6e0fbed..57852fe 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/smarty/smarty.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /** * Smarty 2 and 3 mode. @@ -210,9 +210,9 @@ state.last = last; return style; }, - indent: function(state, text) { + indent: function(state, text, line) { if (state.tokenize == tokenTop && baseMode.indent) - return baseMode.indent(state.base, text); + return baseMode.indent(state.base, text, line); else return CodeMirror.Pass; }, diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr/index.html new file mode 100644 index 0000000..f055b5a --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr/index.html @@ -0,0 +1,57 @@ + + +CodeMirror: Solr mode + + + + + + + + + +
+

Solr mode

+ +
+ +
+ + + +

MIME types defined: text/x-solr.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr/solr.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr/solr.js index dc8b825..eda4a7a 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/solr/solr.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy.js deleted file mode 100644 index 6b9d512..0000000 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy.js +++ /dev/null @@ -1,357 +0,0 @@ -// 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("../htmlmixed/htmlmixed")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror", "../htmlmixed/htmlmixed"], mod); - else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { - "use strict"; - - var indentingTags = ["template", "literal", "msg", "fallbackmsg", "let", "if", "elseif", - "else", "switch", "case", "default", "foreach", "ifempty", "for", - "call", "param", "deltemplate", "delcall", "log"]; - - CodeMirror.defineMode("soy", function(config) { - var textMode = CodeMirror.getMode(config, "text/plain"); - var modes = { - html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false}), - attributes: textMode, - text: textMode, - uri: textMode, - trusted_resource_uri: textMode, - css: CodeMirror.getMode(config, "text/css"), - js: CodeMirror.getMode(config, {name: "text/javascript", statementIndent: 2 * config.indentUnit}) - }; - - function last(array) { - return array[array.length - 1]; - } - - function tokenUntil(stream, state, untilRegExp) { - if (stream.sol()) { - for (var indent = 0; indent < state.indent; indent++) { - if (!stream.eat(/\s/)) break; - } - if (indent) return null; - } - var oldString = stream.string; - var match = untilRegExp.exec(oldString.substr(stream.pos)); - if (match) { - // We don't use backUp because it backs up just the position, not the state. - // This uses an undocumented API. - stream.string = oldString.substr(0, stream.pos + match.index); - } - var result = stream.hideFirstChars(state.indent, function() { - var localState = last(state.localStates); - return localState.mode.token(stream, localState.state); - }); - stream.string = oldString; - return result; - } - - function contains(list, element) { - while (list) { - if (list.element === element) return true; - list = list.next; - } - return false; - } - - function prepend(list, element) { - return { - element: element, - next: list - }; - } - - // Reference a variable `name` in `list`. - // Let `loose` be truthy to ignore missing identifiers. - function ref(list, name, loose) { - return contains(list, name) ? "variable-2" : (loose ? "variable" : "variable-2 error"); - } - - function popscope(state) { - if (state.scopes) { - state.variables = state.scopes.element; - state.scopes = state.scopes.next; - } - } - - return { - startState: function() { - return { - kind: [], - kindTag: [], - soyState: [], - templates: null, - variables: prepend(null, 'ij'), - scopes: null, - indent: 0, - quoteKind: null, - localStates: [{ - mode: modes.html, - state: CodeMirror.startState(modes.html) - }] - }; - }, - - copyState: function(state) { - return { - tag: state.tag, // Last seen Soy tag. - kind: state.kind.concat([]), // Values of kind="" attributes. - kindTag: state.kindTag.concat([]), // Opened tags with kind="" attributes. - soyState: state.soyState.concat([]), - templates: state.templates, - variables: state.variables, - scopes: state.scopes, - indent: state.indent, // Indentation of the following line. - quoteKind: state.quoteKind, - localStates: state.localStates.map(function(localState) { - return { - mode: localState.mode, - state: CodeMirror.copyState(localState.mode, localState.state) - }; - }) - }; - }, - - token: function(stream, state) { - var match; - - switch (last(state.soyState)) { - case "comment": - if (stream.match(/^.*?\*\//)) { - state.soyState.pop(); - } else { - stream.skipToEnd(); - } - if (!state.scopes) { - var paramRe = /@param\??\s+(\S+)/g; - var current = stream.current(); - for (var match; (match = paramRe.exec(current)); ) { - state.variables = prepend(state.variables, match[1]); - } - } - return "comment"; - - case "string": - var match = stream.match(/^.*?(["']|\\[\s\S])/); - if (!match) { - stream.skipToEnd(); - } else if (match[1] == state.quoteKind) { - state.quoteKind = null; - state.soyState.pop(); - } - return "string"; - } - - if (!state.soyState.length || last(state.soyState) != "literal") { - if (stream.match(/^\/\*/)) { - state.soyState.push("comment"); - return "comment"; - } else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) { - return "comment"; - } - } - - switch (last(state.soyState)) { - case "templ-def": - if (match = stream.match(/^\.?([\w]+(?!\.[\w]+)*)/)) { - state.templates = prepend(state.templates, match[1]); - state.scopes = prepend(state.scopes, state.variables); - state.soyState.pop(); - return "def"; - } - stream.next(); - return null; - - case "templ-ref": - if (match = stream.match(/^\.?([\w]+)/)) { - state.soyState.pop(); - // If the first character is '.', try to match against a local template name. - if (match[0][0] == '.') { - return ref(state.templates, match[1], true); - } - // Otherwise - return "variable"; - } - stream.next(); - return null; - - case "param-def": - if (match = stream.match(/^\w+/)) { - state.variables = prepend(state.variables, match[0]); - state.soyState.pop(); - state.soyState.push("param-type"); - return "def"; - } - stream.next(); - return null; - - case "param-type": - if (stream.peek() == "}") { - state.soyState.pop(); - return null; - } - if (stream.eatWhile(/^[\w]+/)) { - return "variable-3"; - } - stream.next(); - return null; - - case "var-def": - if (match = stream.match(/^\$([\w]+)/)) { - state.variables = prepend(state.variables, match[1]); - state.soyState.pop(); - return "def"; - } - stream.next(); - return null; - - case "tag": - if (stream.match(/^\/?}/)) { - if (state.tag == "/template" || state.tag == "/deltemplate") { - popscope(state); - state.variables = prepend(null, 'ij'); - state.indent = 0; - } else { - if (state.tag == "/for" || state.tag == "/foreach") { - popscope(state); - } - state.indent -= config.indentUnit * - (stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1); - } - state.soyState.pop(); - return "keyword"; - } else if (stream.match(/^([\w?]+)(?==)/)) { - if (stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) { - var kind = match[1]; - state.kind.push(kind); - state.kindTag.push(state.tag); - var mode = modes[kind] || modes.html; - var localState = last(state.localStates); - if (localState.mode.indent) { - state.indent += localState.mode.indent(localState.state, ""); - } - state.localStates.push({ - mode: mode, - state: CodeMirror.startState(mode) - }); - } - return "attribute"; - } else if (match = stream.match(/^["']/)) { - state.soyState.push("string"); - state.quoteKind = match; - return "string"; - } - if (match = stream.match(/^\$([\w]+)/)) { - return ref(state.variables, match[1]); - } - if (match = stream.match(/^\w+/)) { - return /^(?:as|and|or|not|in)$/.test(match[0]) ? "keyword" : null; - } - stream.next(); - return null; - - case "literal": - if (stream.match(/^(?=\{\/literal})/)) { - state.indent -= config.indentUnit; - state.soyState.pop(); - return this.token(stream, state); - } - return tokenUntil(stream, state, /\{\/literal}/); - } - - if (stream.match(/^\{literal}/)) { - state.indent += config.indentUnit; - state.soyState.push("literal"); - return "keyword"; - - // A tag-keyword must be followed by whitespace, comment or a closing tag. - } else if (match = stream.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)) { - if (match[1] != "/switch") - state.indent += (/^(\/|(else|elseif|ifempty|case|fallbackmsg|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit; - state.tag = match[1]; - if (state.tag == "/" + last(state.kindTag)) { - // We found the tag that opened the current kind="". - state.kind.pop(); - state.kindTag.pop(); - state.localStates.pop(); - var localState = last(state.localStates); - if (localState.mode.indent) { - state.indent -= localState.mode.indent(localState.state, ""); - } - } - state.soyState.push("tag"); - if (state.tag == "template" || state.tag == "deltemplate") { - state.soyState.push("templ-def"); - } else if (state.tag == "call" || state.tag == "delcall") { - state.soyState.push("templ-ref"); - } else if (state.tag == "let") { - state.soyState.push("var-def"); - } else if (state.tag == "for" || state.tag == "foreach") { - state.scopes = prepend(state.scopes, state.variables); - state.soyState.push("var-def"); - } else if (state.tag == "namespace") { - if (!state.scopes) { - state.variables = prepend(null, 'ij'); - } - } else if (state.tag.match(/^@(?:param\??|inject)/)) { - state.soyState.push("param-def"); - } - return "keyword"; - - // Not a tag-keyword; it's an implicit print tag. - } else if (stream.eat('{')) { - state.tag = "print"; - state.indent += 2 * config.indentUnit; - state.soyState.push("tag"); - return "keyword"; - } - - return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/); - }, - - indent: function(state, textAfter) { - var indent = state.indent, top = last(state.soyState); - if (top == "comment") return CodeMirror.Pass; - - if (top == "literal") { - if (/^\{\/literal}/.test(textAfter)) indent -= config.indentUnit; - } else { - if (/^\s*\{\/(template|deltemplate)\b/.test(textAfter)) return 0; - if (/^\{(\/|(fallbackmsg|elseif|else|ifempty)\b)/.test(textAfter)) indent -= config.indentUnit; - if (state.tag != "switch" && /^\{(case|default)\b/.test(textAfter)) indent -= config.indentUnit; - if (/^\{\/switch\b/.test(textAfter)) indent -= config.indentUnit; - } - var localState = last(state.localStates); - if (indent && localState.mode.indent) { - indent += localState.mode.indent(localState.state, textAfter); - } - return indent; - }, - - innerMode: function(state) { - if (state.soyState.length && last(state.soyState) != "literal") return null; - else return last(state.localStates); - }, - - electricInput: /^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/, - lineComment: "//", - blockCommentStart: "/*", - blockCommentEnd: "*/", - blockCommentContinue: " * ", - useInnerComments: false, - fold: "indent" - }; - }, "htmlmixed"); - - CodeMirror.registerHelper("hintWords", "soy", indentingTags.concat( - ["delpackage", "namespace", "alias", "print", "css", "debugger"])); - - CodeMirror.defineMIME("text/x-soy", "soy"); -}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/index.html new file mode 100644 index 0000000..2979846 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/index.html @@ -0,0 +1,68 @@ + + +CodeMirror: Soy (Closure Template) mode + + + + + + + + + + + + + + +
+

Soy (Closure Template) mode

+
+ + + +

A mode for Closure Templates (Soy).

+

MIME type defined: text/x-soy.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/soy.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/soy.js new file mode 100644 index 0000000..1f8a13c --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/soy.js @@ -0,0 +1,637 @@ +// 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"), require("../htmlmixed/htmlmixed")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../htmlmixed/htmlmixed"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + var paramData = { noEndTag: true, soyState: "param-def" }; + var tags = { + "alias": { noEndTag: true }, + "delpackage": { noEndTag: true }, + "namespace": { noEndTag: true, soyState: "namespace-def" }, + "@attribute": paramData, + "@attribute?": paramData, + "@param": paramData, + "@param?": paramData, + "@inject": paramData, + "@inject?": paramData, + "@state": paramData, + "template": { soyState: "templ-def", variableScope: true}, + "literal": { }, + "msg": {}, + "fallbackmsg": { noEndTag: true, reduceIndent: true}, + "select": {}, + "plural": {}, + "let": { soyState: "var-def" }, + "if": {}, + "elseif": { noEndTag: true, reduceIndent: true}, + "else": { noEndTag: true, reduceIndent: true}, + "switch": {}, + "case": { noEndTag: true, reduceIndent: true}, + "default": { noEndTag: true, reduceIndent: true}, + "foreach": { variableScope: true, soyState: "for-loop" }, + "ifempty": { noEndTag: true, reduceIndent: true}, + "for": { variableScope: true, soyState: "for-loop" }, + "call": { soyState: "templ-ref" }, + "param": { soyState: "param-ref"}, + "print": { noEndTag: true }, + "deltemplate": { soyState: "templ-def", variableScope: true}, + "delcall": { soyState: "templ-ref" }, + "log": {}, + "element": { variableScope: true }, + }; + + var indentingTags = Object.keys(tags).filter(function(tag) { + return !tags[tag].noEndTag || tags[tag].reduceIndent; + }); + + CodeMirror.defineMode("soy", function(config) { + var textMode = CodeMirror.getMode(config, "text/plain"); + var modes = { + html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false, allowMissingTagName: true}), + attributes: textMode, + text: textMode, + uri: textMode, + trusted_resource_uri: textMode, + css: CodeMirror.getMode(config, "text/css"), + js: CodeMirror.getMode(config, {name: "text/javascript", statementIndent: 2 * config.indentUnit}) + }; + + function last(array) { + return array[array.length - 1]; + } + + function tokenUntil(stream, state, untilRegExp) { + if (stream.sol()) { + for (var indent = 0; indent < state.indent; indent++) { + if (!stream.eat(/\s/)) break; + } + if (indent) return null; + } + var oldString = stream.string; + var match = untilRegExp.exec(oldString.substr(stream.pos)); + if (match) { + // We don't use backUp because it backs up just the position, not the state. + // This uses an undocumented API. + stream.string = oldString.substr(0, stream.pos + match.index); + } + var result = stream.hideFirstChars(state.indent, function() { + var localState = last(state.localStates); + return localState.mode.token(stream, localState.state); + }); + stream.string = oldString; + return result; + } + + function contains(list, element) { + while (list) { + if (list.element === element) return true; + list = list.next; + } + return false; + } + + function prepend(list, element) { + return { + element: element, + next: list + }; + } + + function popcontext(state) { + if (!state.context) return; + if (state.context.scope) { + state.variables = state.context.scope; + } + state.context = state.context.previousContext; + } + + // Reference a variable `name` in `list`. + // Let `loose` be truthy to ignore missing identifiers. + function ref(list, name, loose) { + return contains(list, name) ? "variable-2" : (loose ? "variable" : "variable-2 error"); + } + + // Data for an open soy tag. + function Context(previousContext, tag, scope) { + this.previousContext = previousContext; + this.tag = tag; + this.kind = null; + this.scope = scope; + } + + function expression(stream, state) { + var match; + if (stream.match(/[[]/)) { + state.soyState.push("list-literal"); + state.context = new Context(state.context, "list-literal", state.variables); + state.lookupVariables = false; + return null; + } else if (stream.match(/map\b/)) { + state.soyState.push("map-literal"); + return "keyword"; + } else if (stream.match(/record\b/)) { + state.soyState.push("record-literal"); + return "keyword"; + } else if (stream.match(/([\w]+)(?=\()/)) { + return "variable callee"; + } else if (match = stream.match(/^["']/)) { + state.soyState.push("string"); + state.quoteKind = match[0]; + return "string"; + } else if (stream.match(/^[(]/)) { + state.soyState.push("open-parentheses"); + return null; + } else if (stream.match(/(null|true|false)(?!\w)/) || + stream.match(/0x([0-9a-fA-F]{2,})/) || + stream.match(/-?([0-9]*[.])?[0-9]+(e[0-9]*)?/)) { + return "atom"; + } else if (stream.match(/(\||[+\-*\/%]|[=!]=|\?:|[<>]=?)/)) { + // Tokenize filter, binary, null propagator, and equality operators. + return "operator"; + } else if (match = stream.match(/^\$([\w]+)/)) { + return ref(state.variables, match[1], !state.lookupVariables); + } else if (match = stream.match(/^\w+/)) { + return /^(?:as|and|or|not|in|if)$/.test(match[0]) ? "keyword" : null; + } + + stream.next(); + return null; + } + + return { + startState: function() { + return { + soyState: [], + variables: prepend(null, 'ij'), + scopes: null, + indent: 0, + quoteKind: null, + context: null, + lookupVariables: true, // Is unknown variables considered an error + localStates: [{ + mode: modes.html, + state: CodeMirror.startState(modes.html) + }] + }; + }, + + copyState: function(state) { + return { + tag: state.tag, // Last seen Soy tag. + soyState: state.soyState.concat([]), + variables: state.variables, + context: state.context, + indent: state.indent, // Indentation of the following line. + quoteKind: state.quoteKind, + lookupVariables: state.lookupVariables, + localStates: state.localStates.map(function(localState) { + return { + mode: localState.mode, + state: CodeMirror.copyState(localState.mode, localState.state) + }; + }) + }; + }, + + token: function(stream, state) { + var match; + + switch (last(state.soyState)) { + case "comment": + if (stream.match(/^.*?\*\//)) { + state.soyState.pop(); + } else { + stream.skipToEnd(); + } + if (!state.context || !state.context.scope) { + var paramRe = /@param\??\s+(\S+)/g; + var current = stream.current(); + for (var match; (match = paramRe.exec(current)); ) { + state.variables = prepend(state.variables, match[1]); + } + } + return "comment"; + + case "string": + var match = stream.match(/^.*?(["']|\\[\s\S])/); + if (!match) { + stream.skipToEnd(); + } else if (match[1] == state.quoteKind) { + state.quoteKind = null; + state.soyState.pop(); + } + return "string"; + } + + if (!state.soyState.length || last(state.soyState) != "literal") { + if (stream.match(/^\/\*/)) { + state.soyState.push("comment"); + return "comment"; + } else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) { + return "comment"; + } + } + + switch (last(state.soyState)) { + case "templ-def": + if (match = stream.match(/^\.?([\w]+(?!\.[\w]+)*)/)) { + state.soyState.pop(); + return "def"; + } + stream.next(); + return null; + + case "templ-ref": + if (match = stream.match(/(\.?[a-zA-Z_][a-zA-Z_0-9]+)+/)) { + state.soyState.pop(); + // If the first character is '.', it can only be a local template. + if (match[0][0] == '.') { + return "variable-2" + } + // Otherwise + return "variable"; + } + if (match = stream.match(/^\$([\w]+)/)) { + state.soyState.pop(); + return ref(state.variables, match[1], !state.lookupVariables); + } + + stream.next(); + return null; + + case "namespace-def": + if (match = stream.match(/^\.?([\w\.]+)/)) { + state.soyState.pop(); + return "variable"; + } + stream.next(); + return null; + + case "param-def": + if (match = stream.match(/^\*/)) { + state.soyState.pop(); + state.soyState.push("param-type"); + return "type"; + } + if (match = stream.match(/^\w+/)) { + state.variables = prepend(state.variables, match[0]); + state.soyState.pop(); + state.soyState.push("param-type"); + return "def"; + } + stream.next(); + return null; + + case "param-ref": + if (match = stream.match(/^\w+/)) { + state.soyState.pop(); + return "property"; + } + stream.next(); + return null; + + case "open-parentheses": + if (stream.match(/[)]/)) { + state.soyState.pop(); + return null; + } + return expression(stream, state); + + case "param-type": + var peekChar = stream.peek(); + if ("}]=>,".indexOf(peekChar) != -1) { + state.soyState.pop(); + return null; + } else if (peekChar == "[") { + state.soyState.push('param-type-record'); + return null; + } else if (peekChar == "(") { + state.soyState.push('param-type-template'); + return null; + } else if (peekChar == "<") { + state.soyState.push('param-type-parameter'); + return null; + } else if (match = stream.match(/^([\w]+|[?])/)) { + return "type"; + } + stream.next(); + return null; + + case "param-type-record": + var peekChar = stream.peek(); + if (peekChar == "]") { + state.soyState.pop(); + return null; + } + if (stream.match(/^\w+/)) { + state.soyState.push('param-type'); + return "property"; + } + stream.next(); + return null; + + case "param-type-parameter": + if (stream.match(/^[>]/)) { + state.soyState.pop(); + return null; + } + if (stream.match(/^[<,]/)) { + state.soyState.push('param-type'); + return null; + } + stream.next(); + return null; + + case "param-type-template": + if (stream.match(/[>]/)) { + state.soyState.pop(); + state.soyState.push('param-type'); + return null; + } + if (stream.match(/^\w+/)) { + state.soyState.push('param-type'); + return "def"; + } + stream.next(); + return null; + + case "var-def": + if (match = stream.match(/^\$([\w]+)/)) { + state.variables = prepend(state.variables, match[1]); + state.soyState.pop(); + return "def"; + } + stream.next(); + return null; + + case "for-loop": + if (stream.match(/\bin\b/)) { + state.soyState.pop(); + return "keyword"; + } + if (stream.peek() == "$") { + state.soyState.push('var-def'); + return null; + } + stream.next(); + return null; + + case "record-literal": + if (stream.match(/^[)]/)) { + state.soyState.pop(); + return null; + } + if (stream.match(/[(,]/)) { + state.soyState.push("map-value") + state.soyState.push("record-key") + return null; + } + stream.next() + return null; + + case "map-literal": + if (stream.match(/^[)]/)) { + state.soyState.pop(); + return null; + } + if (stream.match(/[(,]/)) { + state.soyState.push("map-value") + state.soyState.push("map-value") + return null; + } + stream.next() + return null; + + case "list-literal": + if (stream.match(']')) { + state.soyState.pop(); + state.lookupVariables = true; + popcontext(state); + return null; + } + if (stream.match(/\bfor\b/)) { + state.lookupVariables = true; + state.soyState.push('for-loop'); + return "keyword"; + } + return expression(stream, state); + + case "record-key": + if (stream.match(/[\w]+/)) { + return "property"; + } + if (stream.match(/^[:]/)) { + state.soyState.pop(); + return null; + } + stream.next(); + return null; + + case "map-value": + if (stream.peek() == ")" || stream.peek() == "," || stream.match(/^[:)]/)) { + state.soyState.pop(); + return null; + } + return expression(stream, state); + + case "import": + if (stream.eat(";")) { + state.soyState.pop(); + state.indent -= 2 * config.indentUnit; + return null; + } + if (stream.match(/\w+(?=\s+as)/)) { + return "variable"; + } + if (match = stream.match(/\w+/)) { + return /(from|as)/.test(match[0]) ? "keyword" : "def"; + } + if (match = stream.match(/^["']/)) { + state.soyState.push("string"); + state.quoteKind = match[0]; + return "string"; + } + stream.next(); + return null; + + case "tag": + var endTag; + var tagName; + if (state.tag === undefined) { + endTag = true; + tagName = ''; + } else { + endTag = state.tag[0] == "/"; + tagName = endTag ? state.tag.substring(1) : state.tag; + } + var tag = tags[tagName]; + if (stream.match(/^\/?}/)) { + var selfClosed = stream.current() == "/}"; + if (selfClosed && !endTag) { + popcontext(state); + } + if (state.tag == "/template" || state.tag == "/deltemplate") { + state.variables = prepend(null, 'ij'); + state.indent = 0; + } else { + state.indent -= config.indentUnit * + (selfClosed || indentingTags.indexOf(state.tag) == -1 ? 2 : 1); + } + state.soyState.pop(); + return "keyword"; + } else if (stream.match(/^([\w?]+)(?==)/)) { + if (state.context && state.context.tag == tagName && stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) { + var kind = match[1]; + state.context.kind = kind; + var mode = modes[kind] || modes.html; + var localState = last(state.localStates); + if (localState.mode.indent) { + state.indent += localState.mode.indent(localState.state, "", ""); + } + state.localStates.push({ + mode: mode, + state: CodeMirror.startState(mode) + }); + } + return "attribute"; + } + return expression(stream, state); + + case "template-call-expression": + if (stream.match(/^([\w-?]+)(?==)/)) { + return "attribute"; + } else if (stream.eat('>')) { + state.soyState.pop(); + return "keyword"; + } else if (stream.eat('/>')) { + state.soyState.pop(); + return "keyword"; + } + return expression(stream, state); + case "literal": + if (stream.match('{/literal}', false)) { + state.soyState.pop(); + return this.token(stream, state); + } + return tokenUntil(stream, state, /\{\/literal}/); + } + + if (stream.match('{literal}')) { + state.indent += config.indentUnit; + state.soyState.push("literal"); + state.context = new Context(state.context, "literal", state.variables); + return "keyword"; + + // A tag-keyword must be followed by whitespace, comment or a closing tag. + } else if (match = stream.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)) { + var prevTag = state.tag; + state.tag = match[1]; + var endTag = state.tag[0] == "/"; + var indentingTag = !!tags[state.tag]; + var tagName = endTag ? state.tag.substring(1) : state.tag; + var tag = tags[tagName]; + if (state.tag != "/switch") + state.indent += ((endTag || tag && tag.reduceIndent) && prevTag != "switch" ? 1 : 2) * config.indentUnit; + + state.soyState.push("tag"); + var tagError = false; + if (tag) { + if (!endTag) { + if (tag.soyState) state.soyState.push(tag.soyState); + } + // If a new tag, open a new context. + if (!tag.noEndTag && (indentingTag || !endTag)) { + state.context = new Context(state.context, state.tag, tag.variableScope ? state.variables : null); + // Otherwise close the current context. + } else if (endTag) { + if (!state.context || state.context.tag != tagName) { + tagError = true; + } else if (state.context) { + if (state.context.kind) { + state.localStates.pop(); + var localState = last(state.localStates); + if (localState.mode.indent) { + state.indent -= localState.mode.indent(localState.state, "", ""); + } + } + popcontext(state); + } + } + } else if (endTag) { + // Assume all tags with a closing tag are defined in the config. + tagError = true; + } + return (tagError ? "error " : "") + "keyword"; + + // Not a tag-keyword; it's an implicit print tag. + } else if (stream.eat('{')) { + state.tag = "print"; + state.indent += 2 * config.indentUnit; + state.soyState.push("tag"); + return "keyword"; + } else if (!state.context && stream.match(/\bimport\b/)) { + state.soyState.push("import"); + state.indent += 2 * config.indentUnit; + return "keyword"; + } else if (match = stream.match('<{')) { + state.soyState.push("template-call-expression"); + state.indent += 2 * config.indentUnit; + state.soyState.push("tag"); + return "keyword"; + } else if (match = stream.match('')) { + state.indent -= 1 * config.indentUnit; + return "keyword"; + } + + return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/); + }, + + indent: function(state, textAfter, line) { + var indent = state.indent, top = last(state.soyState); + if (top == "comment") return CodeMirror.Pass; + + if (top == "literal") { + if (/^\{\/literal}/.test(textAfter)) indent -= config.indentUnit; + } else { + if (/^\s*\{\/(template|deltemplate)\b/.test(textAfter)) return 0; + if (/^\{(\/|(fallbackmsg|elseif|else|ifempty)\b)/.test(textAfter)) indent -= config.indentUnit; + if (state.tag != "switch" && /^\{(case|default)\b/.test(textAfter)) indent -= config.indentUnit; + if (/^\{\/switch\b/.test(textAfter)) indent -= config.indentUnit; + } + var localState = last(state.localStates); + if (indent && localState.mode.indent) { + indent += localState.mode.indent(localState.state, textAfter, line); + } + return indent; + }, + + innerMode: function(state) { + if (state.soyState.length && last(state.soyState) != "literal") return null; + else return last(state.localStates); + }, + + electricInput: /^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/, + lineComment: "//", + blockCommentStart: "/*", + blockCommentEnd: "*/", + blockCommentContinue: " * ", + useInnerComments: false, + fold: "indent" + }; + }, "htmlmixed"); + + CodeMirror.registerHelper("wordChars", "soy", /[\w$]/); + + CodeMirror.registerHelper("hintWords", "soy", Object.keys(tags).concat( + ["css", "debugger"])); + + CodeMirror.defineMIME("text/x-soy", "soy"); +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/test.js new file mode 100644 index 0000000..ae13158 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/soy/test.js @@ -0,0 +1,311 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "soy"); + function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));} + + // Test of small keywords and words containing them. + MT('keywords-test', + '[keyword {] [keyword as] worrying [keyword and] notorious [keyword as]', + ' the Fandor[operator -]alias assassin, [keyword or]', + ' Corcand cannot fit [keyword in] [keyword }]'); + + MT('let-test', + '[keyword {template] [def .name][keyword }]', + ' [keyword {let] [def $name]: [string "world"][keyword /}]', + ' [tag&bracket <][tag h1][tag&bracket >]', + ' Hello, [keyword {][variable-2 $name][keyword }]', + ' [tag&bracket ]', + '[keyword {/template}]', + ''); + + MT('function-test', + '[keyword {] [callee&variable css]([string "MyClass"])[keyword }]', + '[tag&bracket <][tag input] [attribute value]=[string "]' + + '[keyword {] [callee&variable index]([variable-2&error $list])[keyword }]' + + '[string "][tag&bracket />]'); + + MT('soy-element-composition-test', + '[keyword <{][callee&variable foo]()[keyword }]', + '[keyword >]'); + + MT('soy-element-composition-attribute-test', + '[keyword <{][callee&variable foo]()[keyword }]', + '[attribute class]=[string "Foo"]', + '[keyword >]'); + + MT('namespace-test', + '[keyword {namespace] [variable namespace][keyword }]') + + MT('namespace-with-attribute-test', + '[keyword {namespace] [variable my.namespace.templates] ' + + '[attribute requirecss]=[string "my.namespace"][keyword }]'); + + MT('operators-test', + '[keyword {] [atom 1] [operator ==] [atom 1] [keyword }]', + '[keyword {] [atom 1] [operator !=] [atom 2] [keyword }]', + '[keyword {] [atom 2] [operator +] [atom 2] [keyword }]', + '[keyword {] [atom 2] [operator -] [atom 2] [keyword }]', + '[keyword {] [atom 2] [operator *] [atom 2] [keyword }]', + '[keyword {] [atom 2] [operator /] [atom 2] [keyword }]', + '[keyword {] [atom 2] [operator %] [atom 2] [keyword }]', + '[keyword {] [atom 2] [operator <=] [atom 2] [keyword }]', + '[keyword {] [atom 2] [operator >=] [atom 2] [keyword }]', + '[keyword {] [atom 3] [operator >] [atom 2] [keyword }]', + '[keyword {] [atom 2] [operator >] [atom 3] [keyword }]', + '[keyword {] [atom null] [operator ?:] [string ""] [keyword }]', + '[keyword {] [variable-2&error $variable] [operator |] safeHtml [keyword }]') + + MT('primitive-test', + '[keyword {] [atom true] [keyword }]', + '[keyword {] [atom false] [keyword }]', + '[keyword {] truethy [keyword }]', + '[keyword {] falsey [keyword }]', + '[keyword {] [atom 42] [keyword }]', + '[keyword {] [atom .42] [keyword }]', + '[keyword {] [atom 0.42] [keyword }]', + '[keyword {] [atom -0.42] [keyword }]', + '[keyword {] [atom -.2] [keyword }]', + '[keyword {] [atom 6.03e23] [keyword }]', + '[keyword {] [atom -0.03e0] [keyword }]', + '[keyword {] [atom 0x1F] [keyword }]', + '[keyword {] [atom 0x1F00BBEA] [keyword }]'); + + MT('param-type-record', + '[keyword {@param] [def record]: [[[property foo]: [type bool], [property bar]: [type int] ]][keyword }]' + ); + + MT('param-type-map', + '[keyword {@param] [def unknown]: [type map]<[type string], [type bool]>[keyword }]' + ); + + MT('param-type-list', + '[keyword {@param] [def list]: [type list]<[type ?]>[keyword }]' + ); + + MT('param-type-any', + '[keyword {@param] [def unknown]: [type ?][keyword }]' + ); + + MT('param-type-nested', + '[keyword {@param] [def a]: ' + + '[type list]<[[[property a]: [type int], ' + + '[property b]: [type map]<[type string], ' + + '[type bool]>]]>][keyword }]'); + + MT('undefined-var', + '[keyword {][variable-2&error $var]'); + + MT('param-scope-test', + '[keyword {template] [def .a][keyword }]', + ' [keyword {@param] [def x]: [type string][keyword }]', + ' [keyword {][variable-2 $x][keyword }]', + '[keyword {/template}]', + '', + '[keyword {template] [def .b][keyword }]', + ' [keyword {][variable-2&error $x][keyword }]', + '[keyword {/template}]', + ''); + + MT('if-variable-test', + '[keyword {if] [variable-2&error $showThing][keyword }]', + ' Yo!', + '[keyword {/if}]', + ''); + + MT('defined-if-variable-test', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@param?] [def showThing]: [type bool][keyword }]', + ' [keyword {if] [variable-2 $showThing][keyword }]', + ' Yo!', + ' [keyword {/if}]', + '[keyword {/template}]', + ''); + + MT('template-calls-test', + '[keyword {call] [variable-2 .foo][keyword /}]', + '[keyword {call] [variable foo][keyword /}]', + '[keyword {call] [variable foo][keyword }] [keyword {/call}]', + '[keyword {call] [variable first1.second.third_3][keyword /}]', + '[keyword {call] [variable first1.second.third_3] [keyword }] [keyword {/call}]', + ''); + + MT('foreach-scope-test', + '[keyword {@param] [def bar]: [type string][keyword }]', + '[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]', + ' [keyword {][variable-2 $foo][keyword }]', + '[keyword {/foreach}]', + '[keyword {][variable-2&error $foo][keyword }]', + '[keyword {][variable-2 $bar][keyword }]'); + + MT('foreach-ifempty-indent-test', + '[keyword {foreach] [def $foo] [keyword in] [variable-2&error $foos][keyword }]', + ' something', + '[keyword {ifempty}]', + ' nothing', + '[keyword {/foreach}]', + ''); + + MT('foreach-index', + '[keyword {foreach] [def $foo],[def $index] [keyword in] [[]] [keyword }]', + ' [keyword {][variable-2 $foo][keyword }] [keyword {][variable-2 $index][keyword }]', + '[keyword {/foreach}]'); + + MT('nested-kind-test', + '[keyword {template] [def .foo] [attribute kind]=[string "html"][keyword }]', + ' [tag&bracket <][tag div][tag&bracket >]', + ' [keyword {call] [variable-2 .bar][keyword }]', + ' [keyword {param] [property propertyName] [attribute kind]=[string "js"][keyword }]', + ' [keyword var] [def bar] [operator =] [number 5];', + ' [keyword {/param}]', + ' [keyword {/call}]', + ' [tag&bracket ]', + '[keyword {/template}]', + ''); + + MT('tag-starting-with-function-call-is-not-a-keyword', + '[keyword {][callee&variable index]([variable-2&error $foo])[keyword }]', + '[keyword {css] [string "some-class"][keyword }]', + '[keyword {][callee&variable css]([string "some-class"])[keyword }]', + ''); + + MT('allow-missing-colon-in-@param', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@param] [def showThing] [type bool][keyword }]', + ' [keyword {if] [variable-2 $showThing][keyword }]', + ' Yo!', + ' [keyword {/if}]', + '[keyword {/template}]', + ''); + + MT('param-type-and-default-value', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@param] [def bar]: [type bool] = [atom true][keyword }]', + '[keyword {/template}]', + ''); + + MT('attribute-type', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@attribute] [def bar]: [type string][keyword }]', + '[keyword {/template}]', + ''); + + MT('attribute-type-optional', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@attribute] [def bar]: [type string][keyword }]', + '[keyword {/template}]', + ''); + + MT('attribute-type-all', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@attribute] [type *][keyword }]', + '[keyword {/template}]', + ''); + + MT('state-variable-reference', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@param] [def bar]:= [atom true][keyword }]', + ' [keyword {@state] [def foobar]:= [variable-2 $bar][keyword }]', + '[keyword {/template}]', + ''); + + MT('param-type-template', + '[keyword {template] [def .foo][keyword }]', + ' [keyword {@param] [def renderer]: ([def s]:[type string])=>[type html][keyword }]', + ' [keyword {call] [variable-2 $renderer] [keyword /}]', + '[keyword {/template}]', + ''); + + MT('single-quote-strings', + '[keyword {][string "foo"] [string \'bar\'][keyword }]', + ''); + + MT('literal-comments', + '[keyword {literal}]/* comment */ // comment[keyword {/literal}]'); + + MT('highlight-command-at-eol', + '[keyword {msg]', + ' [keyword }]'); + + MT('switch-indent-test', + '[keyword {let] [def $marbles]: [atom 5] [keyword /}]', + '[keyword {switch] [variable-2 $marbles][keyword }]', + ' [keyword {case] [atom 0][keyword }]', + ' No marbles', + ' [keyword {default}]', + ' At least 1 marble', + '[keyword {/switch}]', + ''); + + MT('if-elseif-else-indent', + '[keyword {if] [atom true][keyword }]', + ' [keyword {let] [def $a]: [atom 5] [keyword /}]', + '[keyword {elseif] [atom false][keyword }]', + ' [keyword {let] [def $bar]: [atom 5] [keyword /}]', + '[keyword {else}]', + ' [keyword {let] [def $bar]: [atom 5] [keyword /}]', + '[keyword {/if}]'); + + MT('msg-fallbackmsg-indent', + '[keyword {msg] [attribute desc]=[string "A message"][keyword }]', + ' A message', + '[keyword {fallbackmsg] [attribute desc]=[string "A message"][keyword }]', + ' Old message', + '[keyword {/msg}]'); + + MT('literal-indent', + '[keyword {template] [def .name][keyword }]', + ' [keyword {literal}]', + ' Lerum', + ' [keyword {/literal}]', + ' Ipsum', + '[keyword {/template}]'); + + MT('special-chars', + '[keyword {sp}]', + '[keyword {nil}]', + '[keyword {\\r}]', + '[keyword {\\n}]', + '[keyword {\\t}]', + '[keyword {lb}]', + '[keyword {rb}]'); + + MT('let-list-literal', + '[keyword {let] [def $test]: [[[[[string \'a\'] ], [[[string \'b\'] ] ] [keyword /}]'); + + MT('let-record-literal', + '[keyword {let] [def $test]: [keyword record]([property test]: [callee&variable bidiGlobalDir](), ' + + '[property foo]: [atom 5]) [keyword /}]'); + + MT('let-map-literal', + '[keyword {let] [def $test]: [keyword map]([string \'outer\']: [keyword map]([atom 5]: [atom false]), ' + + '[string \'foo\']: [string \'bar\']) [keyword /}]'); + + MT('wrong-closing-tag', + '[keyword {if] [atom true][keyword }]', + ' Optional', + '[keyword&error {/badend][keyword }]'); + + MT('list-comprehension', + '[keyword {let] [def $myList]: [[[[[string \'a\'] ] ] [keyword /}] ' + + '[keyword {let] [def $test]: [[[variable $a] [operator +] [atom 1] [keyword for] ' + + '[def $a] [keyword in] [variable-2 $myList] [keyword if] [variable-2 $a] [operator >=] [atom 3] ] [keyword /}]'); + + MT('list-comprehension-index', + '[keyword {let] [def $test]: [[[variable $a] [operator +] [variable $index] [keyword for] ' + + '[def $a],[def $index] [keyword in] [[]] [keyword if] [variable-2 $a] [operator >=] [variable-2 $index] ] [keyword /}]'); + + + MT('list-comprehension-variable-scope', + '[keyword {let] [def $name]: [string "world"][keyword /}]', + '[keyword {let] [def $test]: [[[variable $a] [operator +] [variable $index] [keyword for] ' + + '[def $a],[def $index] [keyword in] [[]] [keyword if] [variable-2 $a] [operator >=] [variable-2 $index] ] [keyword /}]', + '[keyword {][variable-2&error $a][keyword }]', + '[keyword {][variable-2&error $index][keyword }]', + '[keyword {][variable-2 $test][keyword }]', + '[keyword {][variable-2 $name][keyword }]'); + + MT('import', + '[keyword import] {[def Name], [variable Person] [keyword as] [def P]} [keyword from] [string \'examples/proto/example.proto\'];'); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql/index.html new file mode 100644 index 0000000..59fb877 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql/index.html @@ -0,0 +1,61 @@ + + +CodeMirror: SPARQL mode + + + + + + + + + + +
+

SPARQL mode

+
+ + +

MIME types defined: application/sparql-query.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql/sparql.js similarity index 89% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql/sparql.js index 095dcca..73997c6 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sparql/sparql.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -41,7 +41,7 @@ CodeMirror.defineMode("sparql", function(config) { if(ch == "?" && stream.match(/\s/, false)){ return "operator"; } - stream.match(/^[\w\d]*/); + stream.match(/^[A-Za-z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][A-Za-z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]*/); return "variable-2"; } else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) { @@ -60,12 +60,18 @@ CodeMirror.defineMode("sparql", function(config) { stream.skipToEnd(); return "comment"; } + else if (ch === "^") { + ch = stream.peek(); + if (ch === "^") stream.eat("^"); + else stream.eatWhile(operatorChars); + return "operator"; + } else if (operatorChars.test(ch)) { stream.eatWhile(operatorChars); return "operator"; } else if (ch == ":") { - stream.eatWhile(/[\w\d\._\-]/); + eatPnLocal(stream); return "atom"; } else if (ch == "@") { @@ -75,7 +81,7 @@ CodeMirror.defineMode("sparql", function(config) { else { stream.eatWhile(/[_\w\d]/); if (stream.eat(":")) { - stream.eatWhile(/[\w\d_\-]/); + eatPnLocal(stream); return "atom"; } var word = stream.current(); @@ -88,6 +94,10 @@ CodeMirror.defineMode("sparql", function(config) { } } + function eatPnLocal(stream) { + while (stream.match(/([:\w\d._-]|\\[-\\_~.!$&'()*+,;=/?#@%]|%[a-fA-F0-9][a-fA-F0-9])/)); + } + function tokenLiteral(quote) { return function(stream, state) { var escaped = false, ch; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet/index.html new file mode 100644 index 0000000..6850eaa --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet/index.html @@ -0,0 +1,42 @@ + + +CodeMirror: Spreadsheet mode + + + + + + + + + + +
+

Spreadsheet mode

+
+ + + +

MIME types defined: text/x-spreadsheet.

+ +

The Spreadsheet Mode

+

Created by Robert Plummer

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet/spreadsheet.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet/spreadsheet.js index 222f297..d87f988 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/spreadsheet/spreadsheet.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql/index.html new file mode 100644 index 0000000..05cafbe --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql/index.html @@ -0,0 +1,89 @@ + + +CodeMirror: SQL Mode for CodeMirror + + + + + + + + + + + + + +
+

SQL Mode for CodeMirror

+
+ +
+

MIME types defined: + text/x-sql, + text/x-mysql, + text/x-mariadb, + text/x-cassandra, + text/x-plsql, + text/x-mssql, + text/x-hive, + text/x-pgsql, + text/x-gql, + text/x-gpsql. + text/x-esper. +

+ + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql/sql.js similarity index 75% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql/sql.js index ab99c5a..ead4d6d 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/sql/sql.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -12,13 +12,11 @@ "use strict"; CodeMirror.defineMode("sql", function(config, parserConfig) { - "use strict"; - var client = parserConfig.client || {}, atoms = parserConfig.atoms || {"false": true, "true": true, "null": true}, - builtin = parserConfig.builtin || {}, - keywords = parserConfig.keywords || {}, - operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^]/, + builtin = parserConfig.builtin || set(defaultBuiltin), + keywords = parserConfig.keywords || set(sqlKeywords), + operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^\/]/, support = parserConfig.support || {}, hooks = parserConfig.hooks || {}, dateSQL = parserConfig.dateSQL || {"date" : true, "time" : true, "timestamp" : true}, @@ -67,6 +65,14 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // charset casting: _utf8'str', N'str', n'str' // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html return "keyword"; + } else if (support.escapeConstant && (ch == "e" || ch == "E") + && (stream.peek() == "'" || (stream.peek() == '"' && support.doubleQuote))) { + // escape constant: E'str', e'str' + // ref: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE + state.tokenize = function(stream, state) { + return (state.tokenize = tokenLiteral(stream.next(), true))(stream, state); + } + return "keyword"; } else if (support.commentSlashSlash && ch == "/" && stream.eat("/")) { // 1-line comment stream.skipToEnd(); @@ -90,7 +96,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { return null // .table_name (ODBC) // // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html - if (support.ODBCdotTable && stream.match(/^[\w\d_]+/)) + if (support.ODBCdotTable && stream.match(/^[\w\d_$#]+/)) return "variable-2"; } else if (operatorChars.test(ch)) { // operators @@ -98,7 +104,6 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { return "operator"; } else if (brackets.test(ch)) { // brackets - stream.eatWhile(brackets); return "bracket"; } else if (punctuation.test(ch)) { // punctuation @@ -125,7 +130,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { } // 'string', with char specified in quote escaped by '\' - function tokenLiteral(quote) { + function tokenLiteral(quote, backslashEscapes) { return function(stream, state) { var escaped = false, ch; while ((ch = stream.next()) != null) { @@ -133,7 +138,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { state.tokenize = tokenBase; break; } - escaped = backslashStringEscapes && !escaped && ch == "\\"; + escaped = (backslashStringEscapes || backslashEscapes) && !escaped && ch == "\\"; } return "string"; }; @@ -206,9 +211,6 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { }; }); -(function() { - "use strict"; - // `identifier` function hookIdentifier(stream) { // MySQL/MariaDB identifiers @@ -241,9 +243,9 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // varName can be quoted with ` or ' or " // ref: http://dev.mysql.com/doc/refman/5.5/en/user-variables.html if (stream.eat("@")) { - stream.match(/^session\./); - stream.match(/^local\./); - stream.match(/^global\./); + stream.match('session.'); + stream.match('local.'); + stream.match('global.'); } if (stream.eat("'")) { @@ -283,13 +285,14 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { return obj; } + var defaultBuiltin = "bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric" + // A generic SQL Mode. It's not a standard, it just try to support what is generally supported CodeMirror.defineMIME("text/x-sql", { name: "sql", keywords: set(sqlKeywords + "begin"), - builtin: set("bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric"), + builtin: set(defaultBuiltin), atoms: set("false true null unknown"), - operatorChars: /^[*+\-%<>!=]/, dateSQL: set("date time timestamp"), support: set("ODBCdotTable doubleQuote binaryNumber hexNumber") }); @@ -367,7 +370,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { "$": hookVar, // The preferred way to escape Identifiers is using double quotes, ref: http://sqlite.org/lang_keywords.html "\"": hookIdentifierDoublequote, - // there is also support for backtics, ref: http://sqlite.org/lang_keywords.html + // there is also support for backticks, ref: http://sqlite.org/lang_keywords.html "`": hookIdentifier } }); @@ -392,7 +395,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { client: set("appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define describe echo editfile embedded escape exec execute feedback flagger flush heading headsep instance linesize lno loboffset logsource long longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar release repfooter repheader serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout time timing trimout trimspool ttitle underline verify version wrap"), keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"), builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bigserial bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least length lengthb ln lower lpad ltrim lub make_ref max min mlslabel mod months_between natural naturaln nchar nclob new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null number numeric nvarchar2 nvl others power rawtohex real reftohex round rowcount rowidtochar rowtype rpad rtrim serial sign signtype sin sinh smallint soundex sqlcode sqlerrm sqrt stddev string substr substrb sum sysdate tan tanh to_char text to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid unlogged upper user userenv varchar varchar2 variance varying vsize xml"), - operatorChars: /^[*+\-%<>!=~]/, + operatorChars: /^[*\/+\-%<>!=~]/, dateSQL: set("date time timestamp"), support: set("doubleQuote nCharCast zerolessFloat binaryNumber hexNumber") }); @@ -400,8 +403,8 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // Created to support specific hive keywords CodeMirror.defineMIME("text/x-hive", { name: "sql", - keywords: set("select alter $elem$ $key$ $value$ add after all analyze and archive as asc before between binary both bucket buckets by cascade case cast change cluster clustered clusterstatus collection column columns comment compute concatenate continue create cross cursor data database databases dbproperties deferred delete delimited desc describe directory disable distinct distribute drop else enable end escaped exclusive exists explain export extended external false fetch fields fileformat first format formatted from full function functions grant group having hold_ddltime idxproperties if import in index indexes inpath inputdriver inputformat insert intersect into is items join keys lateral left like limit lines load local location lock locks mapjoin materialized minus msck no_drop nocompress not of offline on option or order out outer outputdriver outputformat overwrite partition partitioned partitions percent plus preserve procedure purge range rcfile read readonly reads rebuild recordreader recordwriter recover reduce regexp rename repair replace restrict revoke right rlike row schema schemas semi sequencefile serde serdeproperties set shared show show_database sort sorted ssl statistics stored streamtable table tables tablesample tblproperties temporary terminated textfile then tmp to touch transform trigger true unarchive undo union uniquejoin unlock update use using utc utc_tmestamp view when where while with"), - builtin: set("bool boolean long timestamp tinyint smallint bigint int float double date datetime unsigned string array struct map uniontype"), + keywords: set("select alter $elem$ $key$ $value$ add after all analyze and archive as asc before between binary both bucket buckets by cascade case cast change cluster clustered clusterstatus collection column columns comment compute concatenate continue create cross cursor data database databases dbproperties deferred delete delimited desc describe directory disable distinct distribute drop else enable end escaped exclusive exists explain export extended external fetch fields fileformat first format formatted from full function functions grant group having hold_ddltime idxproperties if import in index indexes inpath inputdriver inputformat insert intersect into is items join keys lateral left like limit lines load local location lock locks mapjoin materialized minus msck no_drop nocompress not of offline on option or order out outer outputdriver outputformat overwrite partition partitioned partitions percent plus preserve procedure purge range rcfile read readonly reads rebuild recordreader recordwriter recover reduce regexp rename repair replace restrict revoke right rlike row schema schemas semi sequencefile serde serdeproperties set shared show show_database sort sorted ssl statistics stored streamtable table tables tablesample tblproperties temporary terminated textfile then tmp to touch transform trigger unarchive undo union uniquejoin unlock update use using utc utc_tmestamp view when where while with admin authorization char compact compactions conf cube current current_date current_timestamp day decimal defined dependency directories elem_type exchange file following for grouping hour ignore inner interval jar less logical macro minute month more none noscan over owner partialscan preceding pretty principals protection reload rewrite role roles rollup rows second server sets skewed transactions truncate unbounded unset uri user values window year"), + builtin: set("bool boolean long timestamp tinyint smallint bigint int float double date datetime unsigned string array struct map uniontype key_type utctimestamp value_type varchar"), atoms: set("false true null unknown"), operatorChars: /^[*+\-%<>!=]/, dateSQL: set("date timestamp"), @@ -411,14 +414,16 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { CodeMirror.defineMIME("text/x-pgsql", { name: "sql", client: set("source"), - // https://www.postgresql.org/docs/10/static/sql-keywords-appendix.html - keywords: set(sqlKeywords + "a abort abs absent absolute access according action ada add admin after aggregate all allocate also always analyse analyze any are array array_agg array_max_cardinality asensitive assertion assignment asymmetric at atomic attribute attributes authorization avg backward base64 before begin begin_frame begin_partition bernoulli binary bit_length blob blocked bom both breadth c cache call called cardinality cascade cascaded case cast catalog catalog_name ceil ceiling chain characteristics characters character_length character_set_catalog character_set_name character_set_schema char_length check checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema collect column columns column_name command_function command_function_code comment comments commit committed concurrently condition condition_number configuration conflict connect connection connection_name constraint constraints constraint_catalog constraint_name constraint_schema constructor contains content continue control conversion convert copy corr corresponding cost covar_pop covar_samp cross csv cube cume_dist current current_catalog current_date current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cursor_name cycle data database datalink datetime_interval_code datetime_interval_precision day db deallocate dec declare default defaults deferrable deferred defined definer degree delimiter delimiters dense_rank depth deref derived describe descriptor deterministic diagnostics dictionary disable discard disconnect dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue do document domain dynamic dynamic_function dynamic_function_code each element else empty enable encoding encrypted end end-exec end_frame end_partition enforced enum equals escape event every except exception exclude excluding exclusive exec execute exists exp explain expression extension external extract false family fetch file filter final first first_value flag float floor following for force foreign fortran forward found frame_row free freeze fs full function functions fusion g general generated get global go goto grant granted greatest grouping groups handler header hex hierarchy hold hour id identity if ignore ilike immediate immediately immutable implementation implicit import including increment indent index indexes indicator inherit inherits initially inline inner inout input insensitive instance instantiable instead integrity intersect intersection invoker isnull isolation k key key_member key_type label lag language large last last_value lateral lc_collate lc_ctype lead leading leakproof least left length level library like_regex link listen ln load local localtime localtimestamp location locator lock locked logged lower m map mapping match matched materialized max maxvalue max_cardinality member merge message_length message_octet_length message_text method min minute minvalue mod mode modifies module month more move multiset mumps name names namespace national natural nchar nclob nesting new next nfc nfd nfkc nfkd nil no none normalize normalized nothing notify notnull nowait nth_value ntile null nullable nullif nulls number object occurrences_regex octets octet_length of off offset oids old only open operator option options ordering ordinality others out outer output over overlaps overlay overriding owned owner p pad parallel parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partial partition pascal passing passthrough password percent percentile_cont percentile_disc percent_rank period permission placing plans pli policy portion position position_regex power precedes preceding prepare prepared preserve primary prior privileges procedural procedure program public quote range rank read reads reassign recheck recovery recursive ref references referencing refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release rename repeatable replace replica requiring reset respect restart restore restrict restricted result return returned_cardinality returned_length returned_octet_length returned_sqlstate returning returns revoke right role rollback rollup routine routine_catalog routine_name routine_schema row rows row_count row_number rule savepoint scale schema schema_name scope scope_catalog scope_name scope_schema scroll search second section security selective self sensitive sequence sequences serializable server server_name session session_user setof sets share show similar simple size skip snapshot some source space specific specifictype specific_name sql sqlcode sqlerror sqlexception sqlstate sqlwarning sqrt stable standalone start state statement static statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset substring substring_regex succeeds sum symmetric sysid system system_time system_user t tables tablesample tablespace table_name temp template temporary then ties timezone_hour timezone_minute to token top_level_count trailing transaction transactions_committed transactions_rolled_back transaction_active transform transforms translate translate_regex translation treat trigger trigger_catalog trigger_name trigger_schema trim trim_array true truncate trusted type types uescape unbounded uncommitted under unencrypted unique unknown unlink unlisten unlogged unnamed unnest until untyped upper uri usage user user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema using vacuum valid validate validator value value_of varbinary variadic var_pop var_samp verbose version versioning view views volatile when whenever whitespace width_bucket window within work wrapper write xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate year yes loop repeat attach path depends detach zone"), - // https://www.postgresql.org/docs/10/static/datatype.html + // For PostgreSQL - https://www.postgresql.org/docs/11/sql-keywords-appendix.html + // For pl/pgsql lang - https://github.com/postgres/postgres/blob/REL_11_2/src/pl/plpgsql/src/pl_scanner.c + keywords: set(sqlKeywords + "a abort abs absent absolute access according action ada add admin after aggregate alias all allocate also alter always analyse analyze and any are array array_agg array_max_cardinality as asc asensitive assert assertion assignment asymmetric at atomic attach attribute attributes authorization avg backward base64 before begin begin_frame begin_partition bernoulli between bigint binary bit bit_length blob blocked bom boolean both breadth by c cache call called cardinality cascade cascaded case cast catalog catalog_name ceil ceiling chain char char_length character character_length character_set_catalog character_set_name character_set_schema characteristics characters check checkpoint class class_origin clob close cluster coalesce cobol collate collation collation_catalog collation_name collation_schema collect column column_name columns command_function command_function_code comment comments commit committed concurrently condition condition_number configuration conflict connect connection connection_name constant constraint constraint_catalog constraint_name constraint_schema constraints constructor contains content continue control conversion convert copy corr corresponding cost count covar_pop covar_samp create cross csv cube cume_dist current current_catalog current_date current_default_transform_group current_path current_role current_row current_schema current_time current_timestamp current_transform_group_for_type current_user cursor cursor_name cycle data database datalink datatype date datetime_interval_code datetime_interval_precision day db deallocate debug dec decimal declare default defaults deferrable deferred defined definer degree delete delimiter delimiters dense_rank depends depth deref derived desc describe descriptor detach detail deterministic diagnostics dictionary disable discard disconnect dispatch distinct dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue do document domain double drop dump dynamic dynamic_function dynamic_function_code each element else elseif elsif empty enable encoding encrypted end end_frame end_partition endexec enforced enum equals errcode error escape event every except exception exclude excluding exclusive exec execute exists exit exp explain expression extension external extract false family fetch file filter final first first_value flag float floor following for force foreach foreign fortran forward found frame_row free freeze from fs full function functions fusion g general generated get global go goto grant granted greatest group grouping groups handler having header hex hierarchy hint hold hour id identity if ignore ilike immediate immediately immutable implementation implicit import in include including increment indent index indexes indicator info inherit inherits initially inline inner inout input insensitive insert instance instantiable instead int integer integrity intersect intersection interval into invoker is isnull isolation join k key key_member key_type label lag language large last last_value lateral lead leading leakproof least left length level library like like_regex limit link listen ln load local localtime localtimestamp location locator lock locked log logged loop lower m map mapping match matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text method min minute minvalue mod mode modifies module month more move multiset mumps name names namespace national natural nchar nclob nesting new next nfc nfd nfkc nfkd nil no none normalize normalized not nothing notice notify notnull nowait nth_value ntile null nullable nullif nulls number numeric object occurrences_regex octet_length octets of off offset oids old on only open operator option options or order ordering ordinality others out outer output over overlaps overlay overriding owned owner p pad parallel parameter parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partial partition pascal passing passthrough password path percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding precision prepare prepared preserve primary print_strict_params prior privileges procedural procedure procedures program public publication query quote raise range rank read reads real reassign recheck recovery recursive ref references referencing refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release rename repeatable replace replica requiring reset respect restart restore restrict result result_oid return returned_cardinality returned_length returned_octet_length returned_sqlstate returning returns reverse revoke right role rollback rollup routine routine_catalog routine_name routine_schema routines row row_count row_number rows rowtype rule savepoint scale schema schema_name schemas scope scope_catalog scope_name scope_schema scroll search second section security select selective self sensitive sequence sequences serializable server server_name session session_user set setof sets share show similar simple size skip slice smallint snapshot some source space specific specific_name specifictype sql sqlcode sqlerror sqlexception sqlstate sqlwarning sqrt stable stacked standalone start state statement static statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time system_user t table table_name tables tablesample tablespace temp template temporary text then ties time timestamp timezone_hour timezone_minute to token top_level_count trailing transaction transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex translation treat trigger trigger_catalog trigger_name trigger_schema trim trim_array true truncate trusted type types uescape unbounded uncommitted under unencrypted union unique unknown unlink unlisten unlogged unnamed unnest until untyped update upper uri usage use_column use_variable user user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema using vacuum valid validate validator value value_of values var_pop var_samp varbinary varchar variable_conflict variadic varying verbose version versioning view views volatile warning when whenever where while whitespace width_bucket window with within without work wrapper write xml xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate year yes zone"), + // https://www.postgresql.org/docs/11/datatype.html builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr macaddr8 money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"), atoms: set("false true null unknown"), - operatorChars: /^[*+\-%<>!=&|^\/#@?~]/, + operatorChars: /^[*\/+\-%<>!=&|^\/#@?~]/, + backslashStringEscapes: false, dateSQL: set("date time timestamp"), - support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast") + support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast escapeConstant") }); // Google's SQL-like query language, GQL @@ -446,10 +451,10 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { // Spark SQL CodeMirror.defineMIME("text/x-sparksql", { name: "sql", - keywords: set("add after all alter analyze and anti archive array as asc at between bucket buckets by cache cascade case cast change clear cluster clustered codegen collection column columns comment commit compact compactions compute concatenate cost create cross cube current current_date current_timestamp database databases datata dbproperties defined delete delimited deny desc describe dfs directories distinct distribute drop else end escaped except exchange exists explain export extended external false fields fileformat first following for format formatted from full function functions global grant group grouping having if ignore import in index indexes inner inpath inputformat insert intersect interval into is items join keys last lateral lazy left like limit lines list load local location lock locks logical macro map minus msck natural no not null nulls of on optimize option options or order out outer outputformat over overwrite partition partitioned partitions percent preceding principals purge range recordreader recordwriter recover reduce refresh regexp rename repair replace reset restrict revoke right rlike role roles rollback rollup row rows schema schemas select semi separated serde serdeproperties set sets show skewed sort sorted start statistics stored stratify struct table tables tablesample tblproperties temp temporary terminated then to touch transaction transactions transform true truncate unarchive unbounded uncache union unlock unset use using values view when where window with"), + keywords: set("add after all alter analyze and anti archive array as asc at between bucket buckets by cache cascade case cast change clear cluster clustered codegen collection column columns comment commit compact compactions compute concatenate cost create cross cube current current_date current_timestamp database databases data dbproperties defined delete delimited deny desc describe dfs directories distinct distribute drop else end escaped except exchange exists explain export extended external false fields fileformat first following for format formatted from full function functions global grant group grouping having if ignore import in index indexes inner inpath inputformat insert intersect interval into is items join keys last lateral lazy left like limit lines list load local location lock locks logical macro map minus msck natural no not null nulls of on optimize option options or order out outer outputformat over overwrite partition partitioned partitions percent preceding principals purge range recordreader recordwriter recover reduce refresh regexp rename repair replace reset restrict revoke right rlike role roles rollback rollup row rows schema schemas select semi separated serde serdeproperties set sets show skewed sort sorted start statistics stored stratify struct table tables tablesample tblproperties temp temporary terminated then to touch transaction transactions transform true truncate unarchive unbounded uncache union unlock unset use using values view when where window with"), builtin: set("tinyint smallint int bigint boolean float double string binary timestamp decimal array map struct uniontype delimited serde sequencefile textfile rcfile inputformat outputformat"), atoms: set("false true null"), - operatorChars: /^[*+\-%<>!=~&|^]/, + operatorChars: /^[*\/+\-%<>!=~&|^]/, dateSQL: set("date time timestamp"), support: set("ODBCdotTable doubleQuote zerolessFloat") }); @@ -466,8 +471,6 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { dateSQL: set("time"), support: set("decimallessFloat zerolessFloat binaryNumber hexNumber") }); -}()); - }); /* diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/index.html new file mode 100644 index 0000000..2c67ab2 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/index.html @@ -0,0 +1,116 @@ + + +CodeMirror: sTeX mode + + + + + + + + + +
+

sTeX mode

+
+ + +

sTeX mode supports this option:

+ +
inMathMode: boolean
+
Whether to start parsing in math mode (default: false).
+
+ +

MIME types defined: text/x-stex.

+ +

Parsing/Highlighting Tests: normal, verbose.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/stex.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/stex.js index 4490867..20c3bc7 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/stex.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /* * Author: Constantin Jucovschi (c.jucovschi@jacobs-university.de) @@ -103,7 +103,7 @@ // Do we look like '\command' ? If so, attempt to apply the plugin 'command' if (source.match(/^\\[a-zA-Z@]+/)) { var cmdName = source.current().slice(1); - plug = plugins[cmdName] || plugins["DEFAULT"]; + plug = plugins.hasOwnProperty(cmdName) ? plugins[cmdName] : plugins["DEFAULT"]; plug = new plug(); pushCommand(state, plug); setState(state, beginParams); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/test.js new file mode 100644 index 0000000..b1dbcf4 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stex/test.js @@ -0,0 +1,132 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({tabSize: 4}, "stex"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("word", + "foo"); + + MT("twoWords", + "foo bar"); + + MT("beginEndDocument", + "[tag \\begin][bracket {][atom document][bracket }]", + "[tag \\end][bracket {][atom document][bracket }]"); + + MT("beginEndEquation", + "[tag \\begin][bracket {][atom equation][bracket }]", + " E=mc^2", + "[tag \\end][bracket {][atom equation][bracket }]"); + + MT("beginModule", + "[tag \\begin][bracket {][atom module][bracket }[[]]]"); + + MT("beginModuleId", + "[tag \\begin][bracket {][atom module][bracket }[[]id=bbt-size[bracket ]]]"); + + MT("importModule", + "[tag \\importmodule][bracket [[][string b-b-t][bracket ]]{][builtin b-b-t][bracket }]"); + + MT("importModulePath", + "[tag \\importmodule][bracket [[][tag \\KWARCslides][bracket {][string dmath/en/cardinality][bracket }]]{][builtin card][bracket }]"); + + MT("psForPDF", + "[tag \\PSforPDF][bracket [[][atom 1][bracket ]]{]#1[bracket }]"); + + MT("comment", + "[comment % foo]"); + + MT("tagComment", + "[tag \\item][comment % bar]"); + + MT("commentTag", + " [comment % \\item]"); + + MT("commentLineBreak", + "[comment %]", + "foo"); + + MT("tagErrorCurly", + "[tag \\begin][error }][bracket {]"); + + MT("tagErrorSquare", + "[tag \\item][error ]]][bracket {]"); + + MT("commentCurly", + "[comment % }]"); + + MT("tagHash", + "the [tag \\#] key"); + + MT("tagNumber", + "a [tag \\$][atom 5] stetson"); + + MT("tagPercent", + "[atom 100][tag \\%] beef"); + + MT("tagAmpersand", + "L [tag \\&] N"); + + MT("tagUnderscore", + "foo[tag \\_]bar"); + + MT("tagBracketOpen", + "[tag \\emph][bracket {][tag \\{][bracket }]"); + + MT("tagBracketClose", + "[tag \\emph][bracket {][tag \\}][bracket }]"); + + MT("tagLetterNumber", + "section [tag \\S][atom 1]"); + + MT("textTagNumber", + "para [tag \\P][atom 2]"); + + MT("thinspace", + "x[tag \\,]y"); + + MT("thickspace", + "x[tag \\;]y"); + + MT("negativeThinspace", + "x[tag \\!]y"); + + MT("periodNotSentence", + "J.\\ L.\\ is"); + + MT("periodSentence", + "X[tag \\@]. The"); + + MT("italicCorrection", + "[bracket {][tag \\em] If[tag \\/][bracket }] I"); + + MT("tagBracket", + "[tag \\newcommand][bracket {][tag \\pop][bracket }]"); + + MT("inlineMathTagFollowedByNumber", + "[keyword $][tag \\pi][number 2][keyword $]"); + + MT("inlineMath", + "[keyword $][number 3][variable-2 x][tag ^][number 2.45]-[tag \\sqrt][bracket {][tag \\$\\alpha][bracket }] = [number 2][keyword $] other text"); + + MT("inlineMathLatexStyle", + "[keyword \\(][number 3][variable-2 x][tag ^][number 2.45]-[tag \\sqrt][bracket {][tag \\$\\alpha][bracket }] = [number 2][keyword \\)] other text"); + + MT("displayMath", + "More [keyword $$]\t[variable-2 S][tag ^][variable-2 n][tag \\sum] [variable-2 i][keyword $$] other text"); + + MT("displayMath environment", + "[tag \\begin][bracket {][atom equation][bracket }] x [tag \\end][bracket {][atom equation][bracket }] other text"); + + MT("displayMath environment with label", + "[tag \\begin][bracket {][atom equation][bracket }][tag \\label][bracket {][atom eq1][bracket }] x [tag \\end][bracket {][atom equation][bracket }] other text~[tag \\ref][bracket {][atom eq1][bracket }]"); + + MT("mathWithComment", + "[keyword $][variable-2 x] [comment % $]", + "[variable-2 y][keyword $] other text"); + + MT("lineBreakArgument", + "[tag \\\\][bracket [[][atom 1cm][bracket ]]]"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus/index.html new file mode 100644 index 0000000..2c04339 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus/index.html @@ -0,0 +1,106 @@ + + +CodeMirror: Stylus mode + + + + + + + + + + + +
+

Stylus mode

+
+
+ + +

MIME types defined: text/x-styl.

+

Created by Dmitry Kiselyov

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus/stylus.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus/stylus.js index a9f50c0..5cddff0 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/stylus/stylus.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Stylus mode created by Dmitry Kiselyov http://git.io/AaRB @@ -76,7 +76,7 @@ if (ch == "#") { stream.next(); // Hex color - if (stream.match(/^[0-9a-f]{3}([0-9a-f]([0-9a-f]{2}){0,2})?\b/i)) { + if (stream.match(/^[0-9a-f]{3}([0-9a-f]([0-9a-f]{2}){0,2})?\b(?!-)/i)) { return ["atom", "atom"]; } // ID selector @@ -138,7 +138,7 @@ // Variable if (stream.match(/^(\.|\[)[\w-\'\"\]]+/i, false)) { if (!wordIsTag(stream.current())) { - stream.match(/\./); + stream.match('.'); return ["variable-2", "variable-name"]; } } @@ -722,6 +722,9 @@ return indent; }, electricChars: "}", + blockCommentStart: "/*", + blockCommentEnd: "*/", + blockCommentContinue: " * ", lineComment: "//", fold: "indent" }; @@ -731,7 +734,8 @@ var tagKeywords_ = ["a","abbr","address","area","article","aside","audio", "b", "base","bdi", "bdo","bgsound","blockquote","body","br","button","canvas","caption","cite", "code","col","colgroup","data","datalist","dd","del","details","dfn","div", "dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1", "h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe", "img","input","ins","kbd","keygen","label","legend","li","link","main","map", "mark","marquee","menu","menuitem","meta","meter","nav","nobr","noframes", "noscript","object","ol","optgroup","option","output","p","param","pre", "progress","q","rp","rt","ruby","s","samp","script","section","select", "small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track", "u","ul","var","video"]; // github.com/codemirror/CodeMirror/blob/master/mode/css/css.js - var documentTypes_ = ["domain", "regexp", "url", "url-prefix"]; + // Note, "url-prefix" should precede "url" in order to match correctly in documentTypesRegexp + var documentTypes_ = ["domain", "regexp", "url-prefix", "url"]; var mediaTypes_ = ["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"]; 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"]; 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","will-change","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode","font-smoothing","osx-font-smoothing"]; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/index.html new file mode 100644 index 0000000..e593f7e --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/index.html @@ -0,0 +1,70 @@ + + +CodeMirror: Swift mode + + + + + + + + + + +
+

Swift mode

+
+ + + +

A simple mode for Swift

+ +

MIME types defined: text/x-swift (Swift code)

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/swift.js similarity index 90% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/swift.js index 1795d86..55e31e2 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/swift.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Swift mode created by Michael Kaminsky https://github.com/mkaminsky11 @@ -73,9 +73,9 @@ stream.match("..") return "punctuation" } - if (ch == '"' || ch == "'") { - stream.next() - var tokenize = tokenString(ch) + var stringMatch + if (stringMatch = stream.match(/("""|"|')/)) { + var tokenize = tokenString.bind(null, stringMatch[0]) state.tokenize.push(tokenize) return tokenize(stream, state) } @@ -116,25 +116,29 @@ } } - function tokenString(quote) { - return function(stream, state) { - var ch, escaped = false - while (ch = stream.next()) { - if (escaped) { - if (ch == "(") { - state.tokenize.push(tokenUntilClosingParen()) - return "string" - } - escaped = false - } else if (ch == quote) { - break - } else { - escaped = ch == "\\" + function tokenString(openQuote, stream, state) { + var singleLine = openQuote.length == 1 + var ch, escaped = false + while (ch = stream.peek()) { + if (escaped) { + stream.next() + if (ch == "(") { + state.tokenize.push(tokenUntilClosingParen()) + return "string" } + escaped = false + } else if (stream.match(openQuote)) { + state.tokenize.pop() + return "string" + } else { + stream.next() + escaped = ch == "\\" } + } + if (singleLine) { state.tokenize.pop() - return "string" } + return "string" } function tokenComment(stream, state) { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/test.js new file mode 100644 index 0000000..8c93721 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/swift/test.js @@ -0,0 +1,162 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "swift"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + // Ensure all number types are properly represented. + MT("numbers", + "[keyword var] [def a] [operator =] [number 17]", + "[keyword var] [def b] [operator =] [number -0.5]", + "[keyword var] [def c] [operator =] [number 0.3456e-4]", + "[keyword var] [def d] [operator =] [number 345e2]", + "[keyword var] [def e] [operator =] [number 0o7324]", + "[keyword var] [def f] [operator =] [number 0b10010]", + "[keyword var] [def g] [operator =] [number -0x35ade]", + "[keyword var] [def h] [operator =] [number 0xaea.ep-13]", + "[keyword var] [def i] [operator =] [number 0x13ep6]"); + + // Variable/class/etc definition. + MT("definition", + "[keyword var] [def a] [operator =] [number 5]", + "[keyword let] [def b][punctuation :] [variable-2 Int] [operator =] [number 10]", + "[keyword class] [def C] [punctuation {] [punctuation }]", + "[keyword struct] [def D] [punctuation {] [punctuation }]", + "[keyword enum] [def E] [punctuation {] [punctuation }]", + "[keyword extension] [def F] [punctuation {] [punctuation }]", + "[keyword protocol] [def G] [punctuation {] [punctuation }]", + "[keyword func] [def h][punctuation ()] [punctuation {] [punctuation }]", + "[keyword import] [def Foundation]", + "[keyword typealias] [def NewString] [operator =] [variable-2 String]", + "[keyword associatedtype] [def I]", + "[keyword for] [def j] [keyword in] [number 0][punctuation ..][operator <][number 3] [punctuation {] [punctuation }]"); + + // Strings and string interpolation. + MT("strings", + "[keyword var] [def a][punctuation :] [variable-2 String] [operator =] [string \"test\"]", + "[keyword var] [def b][punctuation :] [variable-2 String] [operator =] [string \"\\(][variable a][string )\"]", + "[keyword var] [def c] [operator =] [string \"\"\"]", + "[string multi]", + "[string line]", + "[string \"test\"]", + "[string \"\"\"]", + "[variable print][punctuation (][string \"\"][punctuation )]"); + + // Comments. + MT("comments", + "[comment // This is a comment]", + "[comment /* This is another comment */]", + "[keyword var] [def a] [operator =] [number 5] [comment // Third comment]"); + + // Atoms. + MT("atoms", + "[keyword class] [def FooClass] [punctuation {]", + " [keyword let] [def fooBool][punctuation :] [variable-2 Bool][operator ?]", + " [keyword let] [def fooInt][punctuation :] [variable-2 Int][operator ?]", + " [keyword func] [keyword init][punctuation (][variable fooBool][punctuation :] [variable-2 Bool][punctuation ,] [variable barBool][punctuation :] [variable-2 Bool][punctuation )] [punctuation {]", + " [atom super][property .init][punctuation ()]", + " [atom self][property .fooBool] [operator =] [variable fooBool]", + " [variable fooInt] [operator =] [atom nil]", + " [keyword if] [variable barBool] [operator ==] [atom true] [punctuation {]", + " [variable print][punctuation (][string \"True!\"][punctuation )]", + " [punctuation }] [keyword else] [keyword if] [variable barBool] [operator ==] [atom false] [punctuation {]", + " [keyword for] [atom _] [keyword in] [number 0][punctuation ...][number 5] [punctuation {]", + " [variable print][punctuation (][string \"False!\"][punctuation )]", + " [punctuation }]", + " [punctuation }]", + " [punctuation }]", + "[punctuation }]"); + + // Types. + MT("types", + "[keyword var] [def a] [operator =] [variable-2 Array][operator <][variable-2 Int][operator >]", + "[keyword var] [def b] [operator =] [variable-2 Set][operator <][variable-2 Bool][operator >]", + "[keyword var] [def c] [operator =] [variable-2 Dictionary][operator <][variable-2 String][punctuation ,][variable-2 Character][operator >]", + "[keyword var] [def d][punctuation :] [variable-2 Int64][operator ?] [operator =] [variable-2 Optional][punctuation (][number 8][punctuation )]", + "[keyword func] [def e][punctuation ()] [operator ->] [variable-2 Void] [punctuation {]", + " [keyword var] [def e1][punctuation :] [variable-2 Float] [operator =] [number 1.2]", + "[punctuation }]", + "[keyword func] [def f][punctuation ()] [operator ->] [variable-2 Never] [punctuation {]", + " [keyword var] [def f1][punctuation :] [variable-2 Double] [operator =] [number 2.4]", + "[punctuation }]"); + + // Operators. + MT("operators", + "[keyword var] [def a] [operator =] [number 1] [operator +] [number 2]", + "[keyword var] [def b] [operator =] [number 1] [operator -] [number 2]", + "[keyword var] [def c] [operator =] [number 1] [operator *] [number 2]", + "[keyword var] [def d] [operator =] [number 1] [operator /] [number 2]", + "[keyword var] [def e] [operator =] [number 1] [operator %] [number 2]", + "[keyword var] [def f] [operator =] [number 1] [operator |] [number 2]", + "[keyword var] [def g] [operator =] [number 1] [operator &] [number 2]", + "[keyword var] [def h] [operator =] [number 1] [operator <<] [number 2]", + "[keyword var] [def i] [operator =] [number 1] [operator >>] [number 2]", + "[keyword var] [def j] [operator =] [number 1] [operator ^] [number 2]", + "[keyword var] [def k] [operator =] [operator ~][number 1]", + "[keyword var] [def l] [operator =] [variable foo] [operator ?] [number 1] [punctuation :] [number 2]", + "[keyword var] [def m][punctuation :] [variable-2 Int] [operator =] [variable-2 Optional][punctuation (][number 8][punctuation )][operator !]"); + + // Punctuation. + MT("punctuation", + "[keyword let] [def a] [operator =] [number 1][punctuation ;] [keyword let] [def b] [operator =] [number 2]", + "[keyword let] [def testArr][punctuation :] [punctuation [[][variable-2 Int][punctuation ]]] [operator =] [punctuation [[][variable a][punctuation ,] [variable b][punctuation ]]]", + "[keyword for] [def i] [keyword in] [number 0][punctuation ..][operator <][variable testArr][property .count] [punctuation {]", + " [variable print][punctuation (][variable testArr][punctuation [[][variable i][punctuation ]])]", + "[punctuation }]"); + + // Identifiers. + MT("identifiers", + "[keyword let] [def abc] [operator =] [number 1]", + "[keyword let] [def ABC] [operator =] [number 2]", + "[keyword let] [def _123] [operator =] [number 3]", + "[keyword let] [def _$1$2$3] [operator =] [number 4]", + "[keyword let] [def A1$_c32_$_] [operator =] [number 5]", + "[keyword let] [def `var`] [operator =] [punctuation [[][number 1][punctuation ,] [number 2][punctuation ,] [number 3][punctuation ]]]", + "[keyword let] [def square$] [operator =] [variable `var`][property .map] [punctuation {][variable $0] [operator *] [variable $0][punctuation }]", + "$$ [number 1][variable a] $[atom _] [variable _$] [variable __] `[variable a] [variable b]`"); + + // Properties. + MT("properties", + "[variable print][punctuation (][variable foo][property .abc][punctuation )]", + "[variable print][punctuation (][variable foo][property .ABC][punctuation )]", + "[variable print][punctuation (][variable foo][property ._123][punctuation )]", + "[variable print][punctuation (][variable foo][property ._$1$2$3][punctuation )]", + "[variable print][punctuation (][variable foo][property .A1$_c32_$_][punctuation )]", + "[variable print][punctuation (][variable foo][property .`var`][punctuation )]", + "[variable print][punctuation (][variable foo][property .__][punctuation )]"); + + // Instructions or other things that start with #. + MT("instructions", + "[keyword if] [builtin #available][punctuation (][variable iOS] [number 9][punctuation ,] [operator *][punctuation )] [punctuation {}]", + "[variable print][punctuation (][builtin #file][punctuation ,] [builtin #function][punctuation )]", + "[variable print][punctuation (][builtin #line][punctuation ,] [builtin #column][punctuation )]", + "[builtin #if] [atom true]", + "[keyword import] [def A]", + "[builtin #elseif] [atom false]", + "[keyword import] [def B]", + "[builtin #endif]", + "[builtin #sourceLocation][punctuation (][variable file][punctuation :] [string \"file.swift\"][punctuation ,] [variable line][punctuation :] [number 2][punctuation )]"); + + // Attributes; things that start with @. + MT("attributes", + "[attribute @objc][punctuation (][variable objcFoo][punctuation :)]", + "[attribute @available][punctuation (][variable iOS][punctuation )]"); + + // Property/number edge case. + MT("property_number", + "[variable print][punctuation (][variable foo][property ._123][punctuation )]", + "[variable print][punctuation (]") + + MT("nested_comments", + "[comment /*]", + "[comment But wait /* this is a nested comment */ for real]", + "[comment /**** let * me * show * you ****/]", + "[comment ///// let / me / show / you /////]", + "[comment */]"); + + // TODO: correctly identify when multiple variables are being declared + // by use of a comma-separated list. + // TODO: correctly identify when variables are being declared in a tuple. + // TODO: identify protocols as types when used before an extension? +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl/index.html new file mode 100644 index 0000000..8c18397 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl/index.html @@ -0,0 +1,142 @@ + + +CodeMirror: Tcl mode + + + + + + + + + + +
+

Tcl mode

+
+ + +

MIME types defined: text/x-tcl.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl/tcl.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl/tcl.js index 8c76d52..dec0662 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tcl/tcl.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE //tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara @@ -131,7 +131,8 @@ CodeMirror.defineMode("tcl", function() { token: function(stream, state) { if (stream.eatSpace()) return null; return state.tokenize(stream, state); - } + }, + lineComment: "#" }; }); CodeMirror.defineMIME("text/x-tcl", "tcl"); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/index.html new file mode 100644 index 0000000..865b9ce --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/index.html @@ -0,0 +1,191 @@ + + +CodeMirror: Textile mode + + + + + + + + + +
+

Textile mode

+
+ + +

MIME types defined: text/x-textile.

+ +

Parsing/Highlighting Tests: normal, verbose.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/test.js new file mode 100644 index 0000000..754c5f6 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/test.js @@ -0,0 +1,417 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({tabSize: 4}, 'textile'); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT('simpleParagraphs', + 'Some text.', + '', + 'Some more text.'); + + /* + * Phrase Modifiers + */ + + MT('em', + 'foo [em _bar_]'); + + MT('emBoogus', + 'code_mirror'); + + MT('strong', + 'foo [strong *bar*]'); + + MT('strongBogus', + '3 * 3 = 9'); + + MT('italic', + 'foo [em __bar__]'); + + MT('italicBogus', + 'code__mirror'); + + MT('bold', + 'foo [strong **bar**]'); + + MT('boldBogus', + '3 ** 3 = 27'); + + MT('simpleLink', + '[link "CodeMirror":https://codemirror.net]'); + + MT('referenceLink', + '[link "CodeMirror":code_mirror]', + 'Normal Text.', + '[link [[code_mirror]]https://codemirror.net]'); + + MT('footCite', + 'foo bar[qualifier [[1]]]'); + + MT('footCiteBogus', + 'foo bar[[1a2]]'); + + MT('special-characters', + 'Registered [tag (r)], ' + + 'Trademark [tag (tm)], and ' + + 'Copyright [tag (c)] 2008'); + + MT('cite', + "A book is [keyword ??The Count of Monte Cristo??] by Dumas."); + + MT('additionAndDeletion', + 'The news networks declared [negative -Al Gore-] ' + + '[positive +George W. Bush+] the winner in Florida.'); + + MT('subAndSup', + 'f(x, n) = log [builtin ~4~] x [builtin ^n^]'); + + MT('spanAndCode', + 'A [quote %span element%] and [atom @code element@]'); + + MT('spanBogus', + 'Percentage 25% is not a span.'); + + MT('citeBogus', + 'Question? is not a citation.'); + + MT('codeBogus', + 'user@example.com'); + + MT('subBogus', + '~username'); + + MT('supBogus', + 'foo ^ bar'); + + MT('deletionBogus', + '3 - 3 = 0'); + + MT('additionBogus', + '3 + 3 = 6'); + + MT('image', + 'An image: [string !http://www.example.com/image.png!]'); + + MT('imageWithAltText', + 'An image: [string !http://www.example.com/image.png (Alt Text)!]'); + + MT('imageWithUrl', + 'An image: [string !http://www.example.com/image.png!:http://www.example.com/]'); + + /* + * Headers + */ + + MT('h1', + '[header&header-1 h1. foo]'); + + MT('h2', + '[header&header-2 h2. foo]'); + + MT('h3', + '[header&header-3 h3. foo]'); + + MT('h4', + '[header&header-4 h4. foo]'); + + MT('h5', + '[header&header-5 h5. foo]'); + + MT('h6', + '[header&header-6 h6. foo]'); + + MT('h7Bogus', + 'h7. foo'); + + MT('multipleHeaders', + '[header&header-1 h1. Heading 1]', + '', + 'Some text.', + '', + '[header&header-2 h2. Heading 2]', + '', + 'More text.'); + + MT('h1inline', + '[header&header-1 h1. foo ][header&header-1&em _bar_][header&header-1 baz]'); + + /* + * Lists + */ + + MT('ul', + 'foo', + 'bar', + '', + '[variable-2 * foo]', + '[variable-2 * bar]'); + + MT('ulNoBlank', + 'foo', + 'bar', + '[variable-2 * foo]', + '[variable-2 * bar]'); + + MT('ol', + 'foo', + 'bar', + '', + '[variable-2 # foo]', + '[variable-2 # bar]'); + + MT('olNoBlank', + 'foo', + 'bar', + '[variable-2 # foo]', + '[variable-2 # bar]'); + + MT('ulFormatting', + '[variable-2 * ][variable-2&em _foo_][variable-2 bar]', + '[variable-2 * ][variable-2&strong *][variable-2&em&strong _foo_]' + + '[variable-2&strong *][variable-2 bar]', + '[variable-2 * ][variable-2&strong *foo*][variable-2 bar]'); + + MT('olFormatting', + '[variable-2 # ][variable-2&em _foo_][variable-2 bar]', + '[variable-2 # ][variable-2&strong *][variable-2&em&strong _foo_]' + + '[variable-2&strong *][variable-2 bar]', + '[variable-2 # ][variable-2&strong *foo*][variable-2 bar]'); + + MT('ulNested', + '[variable-2 * foo]', + '[variable-3 ** bar]', + '[keyword *** bar]', + '[variable-2 **** bar]', + '[variable-3 ** bar]'); + + MT('olNested', + '[variable-2 # foo]', + '[variable-3 ## bar]', + '[keyword ### bar]', + '[variable-2 #### bar]', + '[variable-3 ## bar]'); + + MT('ulNestedWithOl', + '[variable-2 * foo]', + '[variable-3 ## bar]', + '[keyword *** bar]', + '[variable-2 #### bar]', + '[variable-3 ** bar]'); + + MT('olNestedWithUl', + '[variable-2 # foo]', + '[variable-3 ** bar]', + '[keyword ### bar]', + '[variable-2 **** bar]', + '[variable-3 ## bar]'); + + MT('definitionList', + '[number - coffee := Hot ][number&em _and_][number black]', + '', + 'Normal text.'); + + MT('definitionListSpan', + '[number - coffee :=]', + '', + '[number Hot ][number&em _and_][number black =:]', + '', + 'Normal text.'); + + MT('boo', + '[number - dog := woof woof]', + '[number - cat := meow meow]', + '[number - whale :=]', + '[number Whale noises.]', + '', + '[number Also, ][number&em _splashing_][number . =:]'); + + /* + * Attributes + */ + + MT('divWithAttribute', + '[punctuation div][punctuation&attribute (#my-id)][punctuation . foo bar]'); + + MT('divWithAttributeAnd2emRightPadding', + '[punctuation div][punctuation&attribute (#my-id)((][punctuation . foo bar]'); + + MT('divWithClassAndId', + '[punctuation div][punctuation&attribute (my-class#my-id)][punctuation . foo bar]'); + + MT('paragraphWithCss', + 'p[attribute {color:red;}]. foo bar'); + + MT('paragraphNestedStyles', + 'p. [strong *foo ][strong&em _bar_][strong *]'); + + MT('paragraphWithLanguage', + 'p[attribute [[fr]]]. Parlez-vous français?'); + + MT('paragraphLeftAlign', + 'p[attribute <]. Left'); + + MT('paragraphRightAlign', + 'p[attribute >]. Right'); + + MT('paragraphRightAlign', + 'p[attribute =]. Center'); + + MT('paragraphJustified', + 'p[attribute <>]. Justified'); + + MT('paragraphWithLeftIndent1em', + 'p[attribute (]. Left'); + + MT('paragraphWithRightIndent1em', + 'p[attribute )]. Right'); + + MT('paragraphWithLeftIndent2em', + 'p[attribute ((]. Left'); + + MT('paragraphWithRightIndent2em', + 'p[attribute ))]. Right'); + + MT('paragraphWithLeftIndent3emRightIndent2em', + 'p[attribute ((())]. Right'); + + MT('divFormatting', + '[punctuation div. ][punctuation&strong *foo ]' + + '[punctuation&strong&em _bar_][punctuation&strong *]'); + + MT('phraseModifierAttributes', + 'p[attribute (my-class)]. This is a paragraph that has a class and' + + ' this [em _][em&attribute (#special-phrase)][em emphasized phrase_]' + + ' has an id.'); + + MT('linkWithClass', + '[link "(my-class). This is a link with class":http://redcloth.org]'); + + /* + * Layouts + */ + + MT('paragraphLayouts', + 'p. This is one paragraph.', + '', + 'p. This is another.'); + + MT('div', + '[punctuation div. foo bar]'); + + MT('pre', + '[operator pre. Text]'); + + MT('bq.', + '[bracket bq. foo bar]', + '', + 'Normal text.'); + + MT('footnote', + '[variable fn123. foo ][variable&strong *bar*]'); + + /* + * Spanning Layouts + */ + + MT('bq..ThenParagraph', + '[bracket bq.. foo bar]', + '', + '[bracket More quote.]', + 'p. Normal Text'); + + MT('bq..ThenH1', + '[bracket bq.. foo bar]', + '', + '[bracket More quote.]', + '[header&header-1 h1. Header Text]'); + + MT('bc..ThenParagraph', + '[atom bc.. # Some ruby code]', + '[atom obj = {foo: :bar}]', + '[atom puts obj]', + '', + '[atom obj[[:love]] = "*love*"]', + '[atom puts obj.love.upcase]', + '', + 'p. Normal text.'); + + MT('fn1..ThenParagraph', + '[variable fn1.. foo bar]', + '', + '[variable More.]', + 'p. Normal Text'); + + MT('pre..ThenParagraph', + '[operator pre.. foo bar]', + '', + '[operator More.]', + 'p. Normal Text'); + + /* + * Tables + */ + + MT('table', + '[variable-3&operator |_. name |_. age|]', + '[variable-3 |][variable-3&strong *Walter*][variable-3 | 5 |]', + '[variable-3 |Florence| 6 |]', + '', + 'p. Normal text.'); + + MT('tableWithAttributes', + '[variable-3&operator |_. name |_. age|]', + '[variable-3 |][variable-3&attribute /2.][variable-3 Jim |]', + '[variable-3 |][variable-3&attribute \\2{color: red}.][variable-3 Sam |]'); + + /* + * HTML + */ + + MT('html', + '[comment
]', + '[comment
]', + '', + '[header&header-1 h1. Welcome]', + '', + '[variable-2 * Item one]', + '[variable-2 * Item two]', + '', + '[comment Example]', + '', + '[comment
]', + '[comment
]'); + + MT('inlineHtml', + 'I can use HTML directly in my [comment Textile].'); + + /* + * No-Textile + */ + + MT('notextile', + '[string-2 notextile. *No* formatting]'); + + MT('notextileInline', + 'Use [string-2 ==*asterisks*==] for [strong *strong*] text.'); + + MT('notextileWithPre', + '[operator pre. *No* formatting]'); + + MT('notextileWithSpanningPre', + '[operator pre.. *No* formatting]', + '', + '[operator *No* formatting]'); + + /* Only toggling phrases between non-word chars. */ + + MT('phrase-in-word', + 'foo_bar_baz'); + + MT('phrase-non-word', + '[negative -x-] aaa-bbb ccc-ddd [negative -eee-] fff [negative -ggg-]'); + + MT('phrase-lone-dash', + 'foo - bar - baz'); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/textile.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/textile.js index bc5a2f3..b378fb6 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/textile/textile.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") { // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/index.html new file mode 100644 index 0000000..28dffe1 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/index.html @@ -0,0 +1,154 @@ + + +CodeMirror: TiddlyWiki mode + + + + + + + + + + + +
+

TiddlyWiki mode

+ + +
+ + + +

TiddlyWiki mode supports a single configuration.

+ +

MIME types defined: text/x-tiddlywiki.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/tiddlywiki.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/tiddlywiki.css new file mode 100644 index 0000000..9a69b63 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/tiddlywiki.css @@ -0,0 +1,14 @@ +span.cm-underlined { + text-decoration: underline; +} +span.cm-strikethrough { + text-decoration: line-through; +} +span.cm-brace { + color: #170; + font-weight: bold; +} +span.cm-table { + color: blue; + font-weight: bold; +} diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/tiddlywiki.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/tiddlywiki.js index 1a3b3bc..6a9ce44 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiddlywiki/tiddlywiki.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /*** |''Name''|tiddlywiki.js| @@ -8,7 +8,7 @@ |''Version''|0.1.7| |''Status''|''stable''| |''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]| - |''Documentation''|http://codemirror.tiddlyspace.com/| + |''Documentation''|https://codemirror.tiddlyspace.com/| |''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]| |''CoreVersion''|2.5.0| |''Requires''|codemirror.js| @@ -114,7 +114,7 @@ CodeMirror.defineMode("tiddlywiki", function () { return 'header'; } - if (ch == '{' && stream.match(/\{\{/)) + if (ch == '{' && stream.match('{{')) return chain(stream, state, twTokenCode); // rudimentary html:// file:// link matching. TW knows much more ... diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/index.html new file mode 100644 index 0000000..1a66d5a --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/index.html @@ -0,0 +1,95 @@ + + +CodeMirror: Tiki wiki mode + + + + + + + + + + +
+

Tiki wiki mode

+ + +
+ + + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/tiki.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/tiki.css new file mode 100644 index 0000000..1d8704c --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/tiki.css @@ -0,0 +1,26 @@ +.cm-tw-syntaxerror { + color: #FFF; + background-color: #900; +} + +.cm-tw-deleted { + text-decoration: line-through; +} + +.cm-tw-header5 { + font-weight: bold; +} +.cm-tw-listitem:first-child { /*Added first child to fix duplicate padding when highlighting*/ + padding-left: 10px; +} + +.cm-tw-box { + border-top-width: 0px !important; + border-style: solid; + border-width: 1px; + border-color: inherit; +} + +.cm-tw-underline { + text-decoration: underline; +} \ No newline at end of file diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/tiki.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/tiki.js index b4794e4..092b859 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tiki/tiki.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml/index.html new file mode 100644 index 0000000..aa19591 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml/index.html @@ -0,0 +1,73 @@ + + +CodeMirror: TOML Mode + + + + + + + + + +
+

TOML Mode

+
+ +

The TOML Mode

+

Created by Forbes Lindesay.

+

MIME type defined: text/x-toml.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml/toml.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml/toml.js index baeca15..891f384 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/toml/toml.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado/index.html new file mode 100644 index 0000000..96d0d0b --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado/index.html @@ -0,0 +1,63 @@ + + +CodeMirror: Tornado template mode + + + + + + + + + + + + +
+

Tornado template mode

+
+ + + +

Mode for HTML with embedded Tornado template markup.

+ +

MIME types defined: text/x-tornado

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado/tornado.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado/tornado.js index dbfbc34..aa589a0 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/tornado/tornado.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff/index.html new file mode 100644 index 0000000..ad5bf7a --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff/index.html @@ -0,0 +1,146 @@ + + +CodeMirror: troff mode + + + + + + + + + + +
+

troff

+ + + + + + +

MIME types defined: troff.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff/troff.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff/troff.js index 86154b6..0c2220d 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/troff/troff.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg/index.html new file mode 100644 index 0000000..73833ac --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg/index.html @@ -0,0 +1,116 @@ + + +CodeMirror: TTCN-CFG mode + + + + + + + + + +
+

TTCN-CFG example

+
+ +
+ + +
+

Language: Testing and Test Control Notation - + Configuration files + (TTCN-CFG) +

+

MIME types defined: text/x-ttcn-cfg.

+ +
+

The development of this mode has been sponsored by Ericsson + .

+

Coded by Asmelash Tsegay Gebretsadkan

+
+ diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg/ttcn-cfg.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg/ttcn-cfg.js index e108051..9d4b840 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn-cfg/ttcn-cfg.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn/index.html new file mode 100644 index 0000000..592d2f2 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn/index.html @@ -0,0 +1,119 @@ + + +CodeMirror: TTCN mode + + + + + + + + + +
+

TTCN example

+
+ +
+ + +
+

Language: Testing and Test Control Notation + (TTCN) +

+

MIME types defined: text/x-ttcn, + text/x-ttcn3, text/x-ttcnpp.

+
+

The development of this mode has been sponsored by Ericsson + .

+

Coded by Asmelash Tsegay Gebretsadkan

+
+ diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn/ttcn.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn/ttcn.js index 3051851..0304e7c 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/ttcn/ttcn.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle/index.html new file mode 100644 index 0000000..6a2b4ba --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle/index.html @@ -0,0 +1,51 @@ + + +CodeMirror: Turtle mode + + + + + + + + + + +
+

Turtle mode

+
+ + +

MIME types defined: text/turtle.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle/turtle.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle/turtle.js index 0988f0a..6952396 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/turtle/turtle.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig/index.html new file mode 100644 index 0000000..3107d50 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig/index.html @@ -0,0 +1,47 @@ + + +CodeMirror: Twig mode + + + + + + + + + + + +
+

Twig mode

+
+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig/twig.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig/twig.js index b4e9897..a6dd3f1 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/twig/twig.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb/index.html new file mode 100644 index 0000000..84922c1 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb/index.html @@ -0,0 +1,49 @@ + + +CodeMirror: VB.NET mode + + + + + + + + + + + +
+

VB.NET mode

+
+ +
+

MIME type defined: text/x-vb.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb/vb.js similarity index 82% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb/vb.js index 735eb7f..6e4b476 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vb/vb.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -25,16 +25,16 @@ CodeMirror.defineMode("vb", function(conf, parserConf) { var tripleDelimiters = new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))"); var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*"); - var openingKeywords = ['class','module', 'sub','enum','select','while','if','function', 'get','set','property', 'try']; - var middleKeywords = ['else','elseif','case', 'catch']; + var openingKeywords = ['class','module', 'sub','enum','select','while','if','function', 'get','set','property', 'try', 'structure', 'synclock', 'using', 'with']; + var middleKeywords = ['else','elseif','case', 'catch', 'finally']; var endKeywords = ['next','loop']; - var operatorKeywords = ['and', 'or', 'not', 'xor', 'in']; + var operatorKeywords = ['and', "andalso", 'or', 'orelse', 'xor', 'in', 'not', 'is', 'isnot', 'like']; var wordOperators = wordRegexp(operatorKeywords); - var commonKeywords = ['as', 'dim', 'break', 'continue','optional', 'then', 'until', - 'goto', 'byval','byref','new','handles','property', 'return', - 'const','private', 'protected', 'friend', 'public', 'shared', 'static', 'true','false']; - var commontypes = ['integer','string','double','decimal','boolean','short','char', 'float','single']; + + var commonKeywords = ["#const", "#else", "#elseif", "#end", "#if", "#region", "addhandler", "addressof", "alias", "as", "byref", "byval", "cbool", "cbyte", "cchar", "cdate", "cdbl", "cdec", "cint", "clng", "cobj", "compare", "const", "continue", "csbyte", "cshort", "csng", "cstr", "cuint", "culng", "cushort", "declare", "default", "delegate", "dim", "directcast", "each", "erase", "error", "event", "exit", "explicit", "false", "for", "friend", "gettype", "goto", "handles", "implements", "imports", "infer", "inherits", "interface", "isfalse", "istrue", "lib", "me", "mod", "mustinherit", "mustoverride", "my", "mybase", "myclass", "namespace", "narrowing", "new", "nothing", "notinheritable", "notoverridable", "of", "off", "on", "operator", "option", "optional", "out", "overloads", "overridable", "overrides", "paramarray", "partial", "private", "protected", "public", "raiseevent", "readonly", "redim", "removehandler", "resume", "return", "shadows", "shared", "static", "step", "stop", "strict", "then", "throw", "to", "true", "trycast", "typeof", "until", "until", "when", "widening", "withevents", "writeonly"]; + + var commontypes = ['object', 'boolean', 'char', 'string', 'byte', 'sbyte', 'short', 'ushort', 'int16', 'uint16', 'integer', 'uinteger', 'int32', 'uint32', 'long', 'ulong', 'int64', 'uint64', 'decimal', 'single', 'double', 'float', 'date', 'datetime', 'intptr', 'uintptr']; var keywords = wordRegexp(commonKeywords); var types = wordRegexp(commontypes); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript/index.html new file mode 100644 index 0000000..5db9c00 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript/index.html @@ -0,0 +1,55 @@ + + +CodeMirror: VBScript mode + + + + + + + + + +
+

VBScript mode

+ + +
+ + + +

MIME types defined: text/vbscript.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript/vbscript.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript/vbscript.js index b66df22..4033948 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vbscript/vbscript.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE /* For extra ASP classic objects, initialize CodeMirror instance with this option: @@ -32,7 +32,7 @@ CodeMirror.defineMode("vbscript", function(conf, parserConf) { var singleOperators = new RegExp("^[\\+\\-\\*/&\\\\\\^<>=]"); var doubleOperators = new RegExp("^((<>)|(<=)|(>=))"); var singleDelimiters = new RegExp('^[\\.,]'); - var brakets = new RegExp('^[\\(\\)]'); + var brackets = new RegExp('^[\\(\\)]'); var identifiers = new RegExp("^[A-Za-z][_A-Za-z0-9]*"); var openingKeywords = ['class','sub','select','while','if','function', 'property', 'with', 'for']; @@ -183,7 +183,7 @@ CodeMirror.defineMode("vbscript", function(conf, parserConf) { return null; } - if (stream.match(brakets)) { + if (stream.match(brackets)) { return "bracket"; } diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity/index.html new file mode 100644 index 0000000..59d05c1 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity/index.html @@ -0,0 +1,120 @@ + + +CodeMirror: Velocity mode + + + + + + + + + + +
+

Velocity mode

+
+ + +

MIME types defined: text/velocity.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity/velocity.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity/velocity.js index 2525fda..1d17c84 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/velocity/velocity.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -48,7 +48,7 @@ CodeMirror.defineMode("velocity", function() { else if (state.inParams) return chain(stream, state, tokenString(ch)); } - // is it one of the special signs []{}().,;? Seperator? + // is it one of the special signs []{}().,;? Separator? else if (/[\[\]{}\(\),;\.]/.test(ch)) { if (ch == "(" && beforeParams) state.inParams = true; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/index.html new file mode 100644 index 0000000..c159dbe --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/index.html @@ -0,0 +1,120 @@ + + +CodeMirror: Verilog/SystemVerilog mode + + + + + + + + + + +
+

SystemVerilog mode

+ +
+ + + +

+Syntax highlighting and indentation for the Verilog and SystemVerilog languages (IEEE 1800). +

Configuration options:

+
    +
  • noIndentKeywords - List of keywords which should not cause indentation to increase. E.g. ["package", "module"]. Default: None
  • +
+

+ +

MIME types defined: text/x-verilog and text/x-systemverilog.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/test.js new file mode 100644 index 0000000..38c1cbe --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/test.js @@ -0,0 +1,443 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 4}, "verilog"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("binary_literals", + "[number 1'b0]", + "[number 1'b1]", + "[number 1'bx]", + "[number 1'bz]", + "[number 1'bX]", + "[number 1'bZ]", + "[number 1'B0]", + "[number 1'B1]", + "[number 1'Bx]", + "[number 1'Bz]", + "[number 1'BX]", + "[number 1'BZ]", + "[number 1'b0]", + "[number 1'b1]", + "[number 2'b01]", + "[number 2'bxz]", + "[number 2'b11]", + "[number 2'b10]", + "[number 2'b1Z]", + "[number 12'b0101_0101_0101]", + "[number 1'b 0]", + "[number 'b0101]" + ); + + MT("octal_literals", + "[number 3'o7]", + "[number 3'O7]", + "[number 3'so7]", + "[number 3'SO7]" + ); + + MT("decimal_literals", + "[number 0]", + "[number 1]", + "[number 7]", + "[number 123_456]", + "[number 'd33]", + "[number 8'd255]", + "[number 8'D255]", + "[number 8'sd255]", + "[number 8'SD255]", + "[number 32'd123]", + "[number 32 'd123]", + "[number 32 'd 123]" + ); + + MT("hex_literals", + "[number 4'h0]", + "[number 4'ha]", + "[number 4'hF]", + "[number 4'hx]", + "[number 4'hz]", + "[number 4'hX]", + "[number 4'hZ]", + "[number 32'hdc78]", + "[number 32'hDC78]", + "[number 32 'hDC78]", + "[number 32'h DC78]", + "[number 32 'h DC78]", + "[number 32'h44x7]", + "[number 32'hFFF?]" + ); + + MT("real_number_literals", + "[number 1.2]", + "[number 0.1]", + "[number 2394.26331]", + "[number 1.2E12]", + "[number 1.2e12]", + "[number 1.30e-2]", + "[number 0.1e-0]", + "[number 23E10]", + "[number 29E-2]", + "[number 236.123_763_e-12]" + ); + + MT("operators", + "[meta ^]" + ); + + MT("keywords", + "[keyword logic]", + "[keyword logic] [variable foo]", + "[keyword reg] [variable abc]" + ); + + MT("variables", + "[variable _leading_underscore]", + "[variable _if]", + "[number 12] [variable foo]", + "[variable foo] [number 14]" + ); + + MT("tick_defines", + "[def `FOO]", + "[def `foo]", + "[def `FOO_bar]" + ); + + MT("system_calls", + "[meta $display]", + "[meta $vpi_printf]" + ); + + MT("line_comment", "[comment // Hello world]"); + + // Alignment tests + MT("align_port_map_style1", + /** + * mod mod(.a(a), + * .b(b) + * ); + */ + "[variable mod] [variable mod][bracket (].[variable a][bracket (][variable a][bracket )],", + " .[variable b][bracket (][variable b][bracket )]", + " [bracket )];", + "" + ); + + MT("align_port_map_style2", + /** + * mod mod( + * .a(a), + * .b(b) + * ); + */ + "[variable mod] [variable mod][bracket (]", + " .[variable a][bracket (][variable a][bracket )],", + " .[variable b][bracket (][variable b][bracket )]", + "[bracket )];", + "" + ); + + MT("align_assignments", + /** + * always @(posedge clk) begin + * if (rst) + * data_out <= 8'b0 + + * 8'b1; + * else + * data_out = 8'b0 + + * 8'b1; + * data_out = + * 8'b0 + 8'b1; + * end + */ + "[keyword always] [def @][bracket (][keyword posedge] [variable clk][bracket )] [keyword begin]", + " [keyword if] [bracket (][variable rst][bracket )]", + " [variable data_out] [meta <=] [number 8'b0] [meta +]", + " [number 8'b1];", + " [keyword else]", + " [variable data_out] [meta =] [number 8'b0] [meta +]", + " [number 8'b1];", + " [variable data_out] [meta =] [number 8'b0] [meta +]", + " [number 8'b1];", + "[keyword end]", + "" + ); + + // Indentation tests + MT("indent_single_statement_if", + "[keyword if] [bracket (][variable foo][bracket )]", + " [keyword break];", + "" + ); + + MT("no_indent_after_single_line_if", + "[keyword if] [bracket (][variable foo][bracket )] [keyword break];", + "" + ); + + MT("indent_after_if_begin_same_line", + "[keyword if] [bracket (][variable foo][bracket )] [keyword begin]", + " [keyword break];", + " [keyword break];", + "[keyword end]", + "" + ); + + MT("indent_after_if_begin_next_line", + "[keyword if] [bracket (][variable foo][bracket )]", + " [keyword begin]", + " [keyword break];", + " [keyword break];", + " [keyword end]", + "" + ); + + MT("indent_single_statement_if_else", + "[keyword if] [bracket (][variable foo][bracket )]", + " [keyword break];", + "[keyword else]", + " [keyword break];", + "" + ); + + MT("indent_if_else_begin_same_line", + "[keyword if] [bracket (][variable foo][bracket )] [keyword begin]", + " [keyword break];", + " [keyword break];", + "[keyword end] [keyword else] [keyword begin]", + " [keyword break];", + " [keyword break];", + "[keyword end]", + "" + ); + + MT("indent_if_else_begin_next_line", + "[keyword if] [bracket (][variable foo][bracket )]", + " [keyword begin]", + " [keyword break];", + " [keyword break];", + " [keyword end]", + "[keyword else]", + " [keyword begin]", + " [keyword break];", + " [keyword break];", + " [keyword end]", + "" + ); + + MT("indent_if_nested_without_begin", + "[keyword if] [bracket (][variable foo][bracket )]", + " [keyword if] [bracket (][variable foo][bracket )]", + " [keyword if] [bracket (][variable foo][bracket )]", + " [keyword break];", + "" + ); + + MT("indent_case", + "[keyword case] [bracket (][variable state][bracket )]", + " [variable FOO]:", + " [keyword break];", + " [variable BAR]:", + " [keyword break];", + "[keyword endcase]", + "" + ); + + MT("unindent_after_end_with_preceding_text", + "[keyword begin]", + " [keyword break]; [keyword end]", + "" + ); + + MT("export_function_one_line_does_not_indent", + "[keyword export] [string \"DPI-C\"] [keyword function] [variable helloFromSV];", + "" + ); + + MT("export_task_one_line_does_not_indent", + "[keyword export] [string \"DPI-C\"] [keyword task] [variable helloFromSV];", + "" + ); + + MT("export_function_two_lines_indents_properly", + "[keyword export]", + " [string \"DPI-C\"] [keyword function] [variable helloFromSV];", + "" + ); + + MT("export_task_two_lines_indents_properly", + "[keyword export]", + " [string \"DPI-C\"] [keyword task] [variable helloFromSV];", + "" + ); + + MT("import_function_one_line_does_not_indent", + "[keyword import] [string \"DPI-C\"] [keyword function] [variable helloFromC];", + "" + ); + + MT("import_task_one_line_does_not_indent", + "[keyword import] [string \"DPI-C\"] [keyword task] [variable helloFromC];", + "" + ); + + MT("import_package_single_line_does_not_indent", + "[keyword import] [variable p]::[variable x];", + "[keyword import] [variable p]::[variable y];", + "" + ); + + MT("covergroup_with_function_indents_properly", + "[keyword covergroup] [variable cg] [keyword with] [keyword function] [variable sample][bracket (][keyword bit] [variable b][bracket )];", + " [variable c] : [keyword coverpoint] [variable c];", + "[keyword endgroup]: [variable cg]", + "" + ); + + MT("indent_uvm_macros", + /** + * `uvm_object_utils_begin(foo) + * `uvm_field_event(foo, UVM_ALL_ON) + * `uvm_object_utils_end + */ + "[def `uvm_object_utils_begin][bracket (][variable foo][bracket )]", + " [def `uvm_field_event][bracket (][variable foo], [variable UVM_ALL_ON][bracket )]", + "[def `uvm_object_utils_end]", + "" + ); + + MT("indent_uvm_macros2", + /** + * `uvm_do_with(mem_read,{ + * bar_nb == 0; + * }) + */ + "[def `uvm_do_with][bracket (][variable mem_read],[bracket {]", + " [variable bar_nb] [meta ==] [number 0];", + "[bracket })]", + "" + ); + + MT("indent_wait_disable_fork", + /** + * virtual task body(); + * repeat (20) begin + * fork + * `uvm_create_on(t,p_seq) + * join_none + * end + * wait fork; + * disable fork; + * endtask : body + */ + "[keyword virtual] [keyword task] [variable body][bracket ()];", + " [keyword repeat] [bracket (][number 20][bracket )] [keyword begin]", + " [keyword fork]", + " [def `uvm_create_on][bracket (][variable t],[variable p_seq][bracket )]", + " [keyword join_none]", + " [keyword end]", + " [keyword wait] [keyword fork];", + " [keyword disable] [keyword fork];", + "[keyword endtask] : [variable body]", + "" + ); + + MT("indent_typedef_class", + /** + * typedef class asdf; + * typedef p p_t[]; + * typedef enum { + * ASDF + * } t; + */ + "[keyword typedef] [keyword class] [variable asdf];", + "[keyword typedef] [variable p] [variable p_t][bracket [[]]];", + "[keyword typedef] [keyword enum] [bracket {]", + " [variable ASDF]", + "[bracket }] [variable t];", + "" + ); + + MT("indent_case_with_macro", + /** + * // It should be assumed that Macros can have ';' inside, or 'begin'/'end' blocks. + * // As such, 'case' statement should indent correctly with macros inside. + * case(foo) + * ASDF : this.foo = seqNum; + * ABCD : `update(f) + * EFGH : `update(g) + * endcase + */ + "[keyword case][bracket (][variable foo][bracket )]", + " [variable ASDF] : [keyword this].[variable foo] [meta =] [variable seqNum];", + " [variable ABCD] : [def `update][bracket (][variable f][bracket )]", + " [variable EFGH] : [def `update][bracket (][variable g][bracket )]", + "[keyword endcase]", + "" + ); + + MT("indent_extern_function", + /** + * extern virtual function void do(ref packet trans); + * extern virtual function void do2(ref packet trans); + */ + "[keyword extern] [keyword virtual] [keyword function] [keyword void] [variable do1][bracket (][keyword ref] [variable packet] [variable trans][bracket )];", + "[keyword extern] [keyword virtual] [keyword function] [keyword void] [variable do2][bracket (][keyword ref] [variable packet] [variable trans][bracket )];", + "" + ); + + MT("indent_assignment", + /** + * for (int i=1;i < fun;i++) begin + * foo = 2 << asdf || 11'h35 >> abcd + * && 8'h6 | 1'b1; + * end + */ + "[keyword for] [bracket (][keyword int] [variable i][meta =][number 1];[variable i] [meta <] [variable fun];[variable i][meta ++][bracket )] [keyword begin]", + " [variable foo] [meta =] [number 2] [meta <<] [variable asdf] [meta ||] [number 11'h35] [meta >>] [variable abcd]", + " [meta &&] [number 8'h6] [meta |] [number 1'b1];", + "[keyword end]", + "" + ); + + MT("indent_foreach_constraint", + /** + * `uvm_rand_send_with(wrTlp, { + * length ==1; + * foreach (Data[i]) { + * payload[i] == Data[i]; + * } + * }) + */ + "[def `uvm_rand_send_with][bracket (][variable wrTlp], [bracket {]", + " [variable length] [meta ==][number 1];", + " [keyword foreach] [bracket (][variable Data][bracket [[][variable i][bracket ]])] [bracket {]", + " [variable payload][bracket [[][variable i][bracket ]]] [meta ==] [variable Data][bracket [[][variable i][bracket ]]];", + " [bracket }]", + "[bracket })]", + "" + ); + + MT("indent_compiler_directives", + /** + * `ifdef DUT + * `else + * `ifndef FOO + * `define FOO + * `endif + * `endif + * `timescale 1ns/1ns + */ + "[def `ifdef] [variable DUT]", + "[def `else]", + " [def `ifndef] [variable FOO]", + " [def `define] [variable FOO]", + " [def `endif]", + "[def `endif]", + "[def `timescale] [number 1][variable ns][meta /][number 1][variable ns]", + "" + ); + +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/verilog.js similarity index 79% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/verilog.js index 3404686..6c799f2 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/verilog/verilog.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -16,6 +16,12 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var indentUnit = config.indentUnit, statementIndentUnit = parserConfig.statementIndentUnit || indentUnit, dontAlignCalls = parserConfig.dontAlignCalls, + // compilerDirectivesUseRegularIndentation - If set, Compiler directive + // indentation follows the same rules as everything else. Otherwise if + // false, compiler directives will track their own indentation. + // For example, `ifdef nested inside another `ifndef will be indented, + // but a `ifdef inside a function block may not be indented. + compilerDirectivesUseRegularIndentation = parserConfig.compilerDirectivesUseRegularIndentation, noIndentKeywords = parserConfig.noIndentKeywords || [], multiLineStrings = parserConfig.multiLineStrings, hooks = parserConfig.hooks || {}; @@ -62,7 +68,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { binary_module_path_operator ::= == | != | && | || | & | | | ^ | ^~ | ~^ */ - var isOperatorChar = /[\+\-\*\/!~&|^%=?:]/; + var isOperatorChar = /[\+\-\*\/!~&|^%=?:<>]/; var isBracketChar = /[\[\]{}()]/; var unsignedNumber = /\d[0-9_]*/; @@ -72,8 +78,13 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var hexLiteral = /\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i; var realLiteral = /(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i; - var closingBracketOrWord = /^((\w+)|[)}\]])/; + var closingBracketOrWord = /^((`?\w+)|[)}\]])/; var closingBracket = /[)}\]]/; + var compilerDirectiveRegex = new RegExp( + "^(`(?:ifdef|ifndef|elsif|else|endif|undef|undefineall|define|include|begin_keywords|celldefine|default|" + + "nettype|end_keywords|endcelldefine|line|nounconnected_drive|pragma|resetall|timescale|unconnected_drive))\\b"); + var compilerDirectiveBeginRegex = /^(`(?:ifdef|ifndef|elsif|else))\b/; + var compilerDirectiveEndRegex = /^(`(?:elsif|else|endif))\b/; var curPunc; var curKeyword; @@ -96,6 +107,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { openClose["do" ] = "while"; openClose["fork" ] = "join;join_any;join_none"; openClose["covergroup"] = "endgroup"; + openClose["macro_begin"] = "macro_end"; for (var i in noIndentKeywords) { var keyword = noIndentKeywords[i]; @@ -105,7 +117,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } // Keywords which open statements that are ended with a semi-colon - var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while"); + var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while extern typedef"); function tokenBase(stream, state) { var ch = stream.peek(), style; @@ -125,6 +137,23 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { if (ch == '`') { stream.next(); if (stream.eatWhile(/[\w\$_]/)) { + var cur = stream.current(); + curKeyword = cur; + // Macros that end in _begin, are start of block and end with _end + if (cur.startsWith("`uvm_") && cur.endsWith("_begin")) { + var keywordClose = curKeyword.substr(0,curKeyword.length - 5) + "end"; + openClose[cur] = keywordClose; + curPunc = "newblock"; + } else { + stream.eatSpace(); + if (stream.peek() == '(') { + // Check if this is a block + curPunc = "newmacro"; + } + var withSpace = stream.current(); + // Move the stream back before the spaces + stream.backUp(withSpace.length - cur.length); + } return "def"; } else { return null; @@ -145,6 +174,12 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { stream.eatWhile(/[\d_.]/); return "def"; } + // Event + if (ch == '@') { + stream.next(); + stream.eatWhile(/[@]/); + return "def"; + } // Strings if (ch == '"') { stream.next(); @@ -178,6 +213,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { // Operators if (stream.eatWhile(isOperatorChar)) { + curPunc = stream.current(); return "meta"; } @@ -187,6 +223,15 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { if (keywords[cur]) { if (openClose[cur]) { curPunc = "newblock"; + if (cur === "fork") { + // Fork can be a statement instead of block in cases of: + // "disable fork;" and "wait fork;" (trailing semicolon) + stream.eatSpace() + if (stream.peek() == ';') { + curPunc = "newstatement"; + } + stream.backUp(stream.current().length - cur.length); + } } if (statementKeywords[cur]) { curPunc = "newstatement"; @@ -226,16 +271,17 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { return "comment"; } - function Context(indented, column, type, align, prev) { + function Context(indented, column, type, scopekind, align, prev) { this.indented = indented; this.column = column; this.type = type; + this.scopekind = scopekind; this.align = align; this.prev = prev; } - function pushContext(state, col, type) { + function pushContext(state, col, type, scopekind) { var indent = state.indented; - var c = new Context(indent, col, type, null, state.context); + var c = new Context(indent, col, type, scopekind ? scopekind : "", null, state.context); return state.context = c; } function popContext(state) { @@ -261,6 +307,16 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } } + function isInsideScopeKind(ctx, scopekind) { + if (ctx == null) { + return false; + } + if (ctx.scopekind === scopekind) { + return true; + } + return isInsideScopeKind(ctx.prev, scopekind); + } + function buildElectricInputRegEx() { // Reindentation should occur on any bracket char: {}()[] // or on a match of any of the block closing keywords, at @@ -287,8 +343,9 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { startState: function(basecolumn) { var state = { tokenize: null, - context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), + context: new Context((basecolumn || 0) - indentUnit, 0, "top", "top", false), indented: 0, + compilerDirectiveIndented: 0, startOfLine: true }; if (hooks.startState) hooks.startState(state); @@ -313,15 +370,42 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { curPunc = null; curKeyword = null; var style = (state.tokenize || tokenBase)(stream, state); - if (style == "comment" || style == "meta" || style == "variable") return style; + if (style == "comment" || style == "meta" || style == "variable") { + if (((curPunc === "=") || (curPunc === "<=")) && !isInsideScopeKind(ctx, "assignment")) { + // '<=' could be nonblocking assignment or lessthan-equals (which shouldn't cause indent) + // Search through the context to see if we are already in an assignment. + // '=' could be inside port declaration with comma or ')' afterward, or inside for(;;) block. + pushContext(state, stream.column() + curPunc.length, "assignment", "assignment"); + if (ctx.align == null) ctx.align = true; + } + return style; + } if (ctx.align == null) ctx.align = true; - if (curPunc == ctx.type) { - popContext(state); - } else if ((curPunc == ";" && ctx.type == "statement") || + var isClosingAssignment = ctx.type == "assignment" && + closingBracket.test(curPunc) && ctx.prev && ctx.prev.type === curPunc; + if (curPunc == ctx.type || isClosingAssignment) { + if (isClosingAssignment) { + ctx = popContext(state); + } + ctx = popContext(state); + if (curPunc == ")") { + // Handle closing macros, assuming they could have a semicolon or begin/end block inside. + if (ctx && (ctx.type === "macro")) { + ctx = popContext(state); + while (ctx && (ctx.type == "statement" || ctx.type == "assignment")) ctx = popContext(state); + } + } else if (curPunc == "}") { + // Handle closing statements like constraint block: "foreach () {}" which + // do not have semicolon at end. + if (ctx && (ctx.type === "statement")) { + while (ctx && (ctx.type == "statement")) ctx = popContext(state); + } + } + } else if (((curPunc == ";" || curPunc == ",") && (ctx.type == "statement" || ctx.type == "assignment")) || (ctx.type && isClosing(curKeyword, ctx.type))) { ctx = popContext(state); - while (ctx && ctx.type == "statement") ctx = popContext(state); + while (ctx && (ctx.type == "statement" || ctx.type == "assignment")) ctx = popContext(state); } else if (curPunc == "{") { pushContext(state, stream.column(), "}"); } else if (curPunc == "[") { @@ -329,9 +413,9 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } else if (curPunc == "(") { pushContext(state, stream.column(), ")"); } else if (ctx && ctx.type == "endcase" && curPunc == ":") { - pushContext(state, stream.column(), "statement"); + pushContext(state, stream.column(), "statement", "case"); } else if (curPunc == "newstatement") { - pushContext(state, stream.column(), "statement"); + pushContext(state, stream.column(), "statement", curKeyword); } else if (curPunc == "newblock") { if (curKeyword == "function" && ctx && (ctx.type == "statement" || ctx.type == "endgroup")) { // The 'function' keyword can appear in some other contexts where it actually does not @@ -339,9 +423,23 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { // Do nothing in this case } else if (curKeyword == "task" && ctx && ctx.type == "statement") { // Same thing for task + } else if (curKeyword == "class" && ctx && ctx.type == "statement") { + // Same thing for class (e.g. typedef) } else { var close = openClose[curKeyword]; - pushContext(state, stream.column(), close); + pushContext(state, stream.column(), close, curKeyword); + } + } else if (curPunc == "newmacro" || (curKeyword && curKeyword.match(compilerDirectiveRegex))) { + if (curPunc == "newmacro") { + // Macros (especially if they have parenthesis) potentially have a semicolon + // or complete statement/block inside, and should be treated as such. + pushContext(state, stream.column(), "macro", "macro"); + } + if (curKeyword.match(compilerDirectiveEndRegex)) { + state.compilerDirectiveIndented -= statementIndentUnit; + } + if (curKeyword.match(compilerDirectiveBeginRegex)) { + state.compilerDirectiveIndented += statementIndentUnit; } } @@ -361,15 +459,23 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { var possibleClosing = textAfter.match(closingBracketOrWord); if (possibleClosing) closing = isClosing(possibleClosing[0], ctx.type); + if (!compilerDirectivesUseRegularIndentation && textAfter.match(compilerDirectiveRegex)) { + if (textAfter.match(compilerDirectiveEndRegex)) { + return state.compilerDirectiveIndented - statementIndentUnit; + } + return state.compilerDirectiveIndented; + } if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); - else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1); + else if ((closingBracket.test(ctx.type) || ctx.type == "assignment") + && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1); else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit; else return ctx.indented + (closing ? 0 : indentUnit); }, blockCommentStart: "/*", blockCommentEnd: "*/", - lineComment: "//" + lineComment: "//", + fold: "indent" }; }); @@ -436,7 +542,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { }; var tlvIndentUnit = 3; var tlvTrackStatements = false; - var tlvIdentMatch = /^([~!@#\$%\^&\*-\+=\?\/\\\|'"<>]+)([\d\w_]*)/; // Matches an identifiere. + var tlvIdentMatch = /^([~!@#\$%\^&\*-\+=\?\/\\\|'"<>]+)([\d\w_]*)/; // Matches an identifier. // Note that ':' is excluded, because of it's use in [:]. var tlvFirstLevelIndentMatch = /^[! ] /; var tlvLineIndentationMatch = /^[! ] */; @@ -613,7 +719,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) { } else { // Just swallow one character and try again. // This enables subsequent identifier match with preceding symbol character, which - // is legal within a statement. (Eg, !$reset). It also enables detection of + // is legal within a statement. (E.g., !$reset). It also enables detection of // comment start with preceding symbols. stream.backUp(stream.current().length - 1); style = "tlv-default"; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl/index.html new file mode 100644 index 0000000..50b6a10 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl/index.html @@ -0,0 +1,95 @@ + + +CodeMirror: VHDL mode + + + + + + + + + + +
+

VHDL mode

+ +
+ + + +

+Syntax highlighting and indentation for the VHDL language. +

Configuration options:

+
    +
  • atoms - List of atom words. Default: "null"
  • +
  • hooks - List of meta hooks. Default: ["`", "$"]
  • +
  • multiLineStrings - Whether multi-line strings are accepted. Default: false
  • +
+

+ +

MIME types defined: text/x-vhdl.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl/vhdl.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl/vhdl.js index 97e086e..133e67a 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vhdl/vhdl.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Originally written by Alf Nielsen, re-written by Michael Zhou (function(mod) { diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue/index.html new file mode 100644 index 0000000..6ea54b7 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue/index.html @@ -0,0 +1,69 @@ + + +CodeMirror: Vue.js mode + + + + + + + + + + + + + + + + + + + + + +
+

Vue.js mode

+
+ + +

MIME types defined: text/x-vue

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue/vue.js similarity index 97% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue/vue.js index 84cd07c..b6e6cc5 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/vue/vue.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function (mod) { "use strict"; diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/index.html new file mode 100644 index 0000000..470e5c8 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/index.html @@ -0,0 +1,73 @@ + + +CodeMirror: Rust mode + + + + + + + + + + +
+

WebAssembly mode

+ + +
+ + + +

MIME types defined: text/webassembly.

+
\ No newline at end of file diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/test.js new file mode 100644 index 0000000..3e5137c --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/test.js @@ -0,0 +1,340 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 4}, "wast"); + function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));} + + MT('number-test', + '[number 0]', + '[number 123]', + '[number nan]', + '[number inf]', + '[number infinity]', + '[number 0.1]', + '[number 123.0]', + '[number 12E+99]'); + + MT('string-literals-test', + '[string "foo"]', + '[string "\\"foo\\""]', + '[string "foo #\\"# bar"]'); + + MT('atom-test', + '[atom funcref]', + '[atom externref]', + '[atom i32]', + '[atom i64]', + '[atom f32]', + '[atom f64]'); + + MT('keyword-test', + '[keyword br]', + '[keyword if]', + '[keyword loop]', + '[keyword i32.add]', + '[keyword local.get]'); + + MT('control-instructions', + '[keyword unreachable]', + '[keyword nop]', + '[keyword br] [variable-2 $label0]', + '[keyword br_if] [variable-2 $label0]', + '[keyword br_table] [variable-2 $label0] [variable-2 $label1] [variable-2 $label3]', + '[keyword return]', + '[keyword call] [variable-2 $func0]', + '[keyword call_indirect] [variable-2 $table] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])', + '[keyword return_call] [variable-2 $func0]', + '[keyword return_call_indirect] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])', + '[keyword select] ([keyword local.get] [number 1]) ([keyword local.get] [number 2]) ([keyword local.get] [number 3])'); + + + MT('memory-instructions', + '[keyword i32.load] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.load8_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.load8_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.load16_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.load16_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.store] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.store8] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i32.store16] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.store] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load8_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load8_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load16_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load16_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load32_s] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.load32_u] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.store8] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.store16] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword i64.store32] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword f32.load] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword f32.store] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword f64.load] [keyword offset]=[number 4] [keyword align]=[number 4]', + '[keyword f64.store] [keyword offset]=[number 4] [keyword align]=[number 4]'); + + MT('atomic-memory-instructions', + '[keyword memory.atomic.notify] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword memory.atomic.wait32] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword memory.atomic.wait64] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.load] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.load8_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.load16_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.store] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.store8] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.store16] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.load] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.load8_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.load16_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.load32_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.store] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.store8] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.store16] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.store32] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.add] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.add] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.sub] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.sub] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.and] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.and] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.or] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.or] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.xor] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.xor] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.xchg] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.xchg] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw.cmpxchg] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw8.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i32.atomic.rmw16.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw.cmpxchg] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw8.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw16.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i64.atomic.rmw32.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]'); + + MT('simd-instructions', + '[keyword v128.load] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword i16x8.load8x8_s] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i16x8.load8x8_u] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i32x4.load16x4_s] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i32x4.load16x4_u] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i64x2.load32x2_s] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword i64x2.load32x2_u] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v8x16.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v16x8.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v32x4.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v64x2.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', + '[keyword v128.store] [keyword offset]=[number 32] [keyword align]=[number 4]', + '[keyword v128.const] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', + '[keyword v8x16.shuffle] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', + '[keyword v8x16.swizzle]', + '[keyword i8x16.splat]', + '[keyword i16x8.splat]', + '[keyword i32x4.splat]', + '[keyword i64x2.splat]', + '[keyword f32x4.splat]', + '[keyword f64x2.splat]', + '[keyword i8x16.extract_lane_s] [number 1]', + '[keyword i8x16.extract_lane_u] [number 1]', + '[keyword i8x16.replace_lane] [number 1]', + '[keyword i16x8.extract_lane_s] [number 1]', + '[keyword i16x8.extract_lane_u] [number 1]', + '[keyword i16x8.replace_lane] [number 1]', + '[keyword i32x4.extract_lane] [number 1]', + '[keyword i32x4.replace_lane] [number 1]', + '[keyword i64x2.extract_lane] [number 1]', + '[keyword i64x2.replace_lane] [number 1]', + '[keyword f32x4.extract_lane] [number 1]', + '[keyword f32x4.replace_lane] [number 1]', + '[keyword f64x2.extract_lane] [number 1]', + '[keyword f64x2.replace_lane] [number 1]', + '[keyword i8x16.eq]', + '[keyword i8x16.ne]', + '[keyword i8x16.lt_s]', + '[keyword i8x16.lt_u]', + '[keyword i8x16.gt_s]', + '[keyword i8x16.gt_u]', + '[keyword i8x16.le_s]', + '[keyword i8x16.le_u]', + '[keyword i8x16.ge_s]', + '[keyword i8x16.ge_u]', + '[keyword i16x8.eq]', + '[keyword i16x8.ne]', + '[keyword i16x8.lt_s]', + '[keyword i16x8.lt_u]', + '[keyword i16x8.gt_s]', + '[keyword i16x8.gt_u]', + '[keyword i16x8.le_s]', + '[keyword i16x8.le_u]', + '[keyword i16x8.ge_s]', + '[keyword i16x8.ge_u]', + '[keyword i32x4.eq]', + '[keyword i32x4.ne]', + '[keyword i32x4.lt_s]', + '[keyword i32x4.lt_u]', + '[keyword i32x4.gt_s]', + '[keyword i32x4.gt_u]', + '[keyword i32x4.le_s]', + '[keyword i32x4.le_u]', + '[keyword i32x4.ge_s]', + '[keyword i32x4.ge_u]', + '[keyword f32x4.eq]', + '[keyword f32x4.ne]', + '[keyword f32x4.lt]', + '[keyword f32x4.gt]', + '[keyword f32x4.le]', + '[keyword f32x4.ge]', + '[keyword f64x2.eq]', + '[keyword f64x2.ne]', + '[keyword f64x2.lt]', + '[keyword f64x2.gt]', + '[keyword f64x2.le]', + '[keyword f64x2.ge]', + '[keyword v128.not]', + '[keyword v128.and]', + '[keyword v128.andnot]', + '[keyword v128.or]', + '[keyword v128.xor]', + '[keyword v128.bitselect]', + '[keyword i8x16.abs]', + '[keyword i8x16.neg]', + '[keyword i8x16.any_true]', + '[keyword i8x16.all_true]', + '[keyword i8x16.bitmask]', + '[keyword i8x16.narrow_i16x8_s]', + '[keyword i8x16.narrow_i16x8_u]', + '[keyword i8x16.shl]', + '[keyword i8x16.shr_s]', + '[keyword i8x16.shr_u]', + '[keyword i8x16.add]', + '[keyword i8x16.add_saturate_s]', + '[keyword i8x16.add_saturate_u]', + '[keyword i8x16.sub]', + '[keyword i8x16.sub_saturate_s]', + '[keyword i8x16.sub_saturate_u]', + '[keyword i8x16.min_s]', + '[keyword i8x16.min_u]', + '[keyword i8x16.max_s]', + '[keyword i8x16.max_u]', + '[keyword i8x16.avgr_u]', + '[keyword i16x8.abs]', + '[keyword i16x8.neg]', + '[keyword i16x8.any_true]', + '[keyword i16x8.all_true]', + '[keyword i16x8.bitmask]', + '[keyword i16x8.narrow_i32x4_s]', + '[keyword i16x8.narrow_i32x4_u]', + '[keyword i16x8.widen_low_i8x16_s]', + '[keyword i16x8.widen_high_i8x16_s]', + '[keyword i16x8.widen_low_i8x16_u]', + '[keyword i16x8.widen_high_i8x16_u]', + '[keyword i16x8.shl]', + '[keyword i16x8.shr_s]', + '[keyword i16x8.shr_u]', + '[keyword i16x8.add]', + '[keyword i16x8.add_saturate_s]', + '[keyword i16x8.add_saturate_u]', + '[keyword i16x8.sub]', + '[keyword i16x8.sub_saturate_s]', + '[keyword i16x8.sub_saturate_u]', + '[keyword i16x8.mul]', + '[keyword i16x8.min_s]', + '[keyword i16x8.min_u]', + '[keyword i16x8.max_s]', + '[keyword i16x8.max_u]', + '[keyword i16x8.avgr_u]', + '[keyword i32x4.abs]', + '[keyword i32x4.neg]', + '[keyword i32x4.any_true]', + '[keyword i32x4.all_true]', + '[keyword i32x4.bitmask]', + '[keyword i32x4.widen_low_i16x8_s]', + '[keyword i32x4.widen_high_i16x8_s]', + '[keyword i32x4.widen_low_i16x8_u]', + '[keyword i32x4.widen_high_i16x8_u]', + '[keyword i32x4.shl]', + '[keyword i32x4.shr_s]', + '[keyword i32x4.shr_u]', + '[keyword i32x4.add]', + '[keyword i32x4.sub]', + '[keyword i32x4.mul]', + '[keyword i32x4.min_s]', + '[keyword i32x4.min_u]', + '[keyword i32x4.max_s]', + '[keyword i32x4.max_u]', + '[keyword i64x2.neg]', + '[keyword i64x2.shl]', + '[keyword i64x2.shr_s]', + '[keyword i64x2.shr_u]', + '[keyword i64x2.add]', + '[keyword i64x2.sub]', + '[keyword i64x2.mul]', + '[keyword f32x4.abs]', + '[keyword f32x4.neg]', + '[keyword f32x4.sqrt]', + '[keyword f32x4.add]', + '[keyword f32x4.sub]', + '[keyword f32x4.mul]', + '[keyword f32x4.div]', + '[keyword f32x4.min]', + '[keyword f32x4.max]', + '[keyword f64x2.abs]', + '[keyword f64x2.neg]', + '[keyword f64x2.sqrt]', + '[keyword f64x2.add]', + '[keyword f64x2.sub]', + '[keyword f64x2.mul]', + '[keyword f64x2.div]', + '[keyword f64x2.min]', + '[keyword f64x2.max]', + '[keyword i32x4.trunc_sat_f32x4_s]', + '[keyword i32x4.trunc_sat_f32x4_u]', + '[keyword f32x4.convert_i32x4_s]', + '[keyword f32x4.convert_i32x4_u]'); + + MT('reference-type-instructions', + '[keyword ref.null] [keyword extern]', + '[keyword ref.null] [keyword func]', + '[keyword ref.is_null] ([keyword ref.func] [variable-2 $f])', + '[keyword ref.func] [variable-2 $f]'); + + MT('table-instructions', + '[keyword table.get] [variable-2 $t] ([keyword i32.const] [number 5])', + '[keyword table.set] [variable-2 $t] ([keyword i32.const] [number 5]) ([keyword ref.func] [variable-2 $f])', + '[keyword table.size] [variable-2 $t]', + '[keyword table.grow] [variable-2 $t] ([keyword ref.null] [keyword extern]) ([keyword i32.const] [number 5])', + '[keyword table.fill] [variable-2 $t] ([keyword i32.const] [number 5]) ([keyword param] [variable-2 $r] [atom externref]) ([keyword i32.const] [number 5])', + '[keyword table.init] [variable-2 $t] [number 1] ([keyword i32.const] [number 5]) ([keyword i32.const] [number 10]) ([keyword i32.const] [number 15])', + '[keyword table.copy] [variable-2 $t] [variable-2 $t2] ([keyword i32.const] [number 5]) ([keyword i32.const] [number 10]) ([keyword i32.const] [number 15])' + ); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/wast.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/wast.js new file mode 100644 index 0000000..a730d39 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/wast/wast.js @@ -0,0 +1,41 @@ +// 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"), require("../../addon/mode/simple")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../../addon/mode/simple"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineSimpleMode('wast', { + start: [ + {regex: /[+\-]?(?:nan(?::0x[0-9a-fA-F]+)?|infinity|inf|0x[0-9a-fA-F]+\.?[0-9a-fA-F]*p[+\/-]?\d+|\d+(?:\.\d*)?[eE][+\-]?\d*|\d+\.\d*|0x[0-9a-fA-F]+|\d+)/, token: "number"}, + {regex: /mut|nop|block|if|then|else|loop|br_if|br_table|br|call(_indirect)?|drop|end|return(_call(_indirect)?)?|local\.(get|set|tee)|global\.(get|set)|i(32|64)\.(store(8|16)|(load(8|16)_[su]))|i64\.(load32_[su]|store32)|[fi](32|64)\.(const|load|store)|f(32|64)\.(abs|add|ceil|copysign|div|eq|floor|[gl][et]|max|min|mul|nearest|neg?|sqrt|sub|trunc)|i(32|64)\.(a[dn]d|c[lt]z|(div|rem)_[su]|eqz?|[gl][te]_[su]|mul|ne|popcnt|rot[lr]|sh(l|r_[su])|sub|x?or)|i64\.extend_[su]_i32|i32\.wrap_i64|i(32|64)\.trunc_f(32|64)_[su]|f(32|64)\.convert_i(32|64)_[su]|f64\.promote_f32|f32\.demote_f64|f32\.reinterpret_i32|i32\.reinterpret_f32|f64\.reinterpret_i64|i64\.reinterpret_f64|select|unreachable|current_memory|memory(\.((atomic\.(notify|wait(32|64)))|grow|size))?|type|\bfunc\b|param|result|local|global|module|start|elem|data|align|offset|import|export|i64\.atomic\.(load32_u|store32|rmw32\.(a[dn]d|sub|x?or|(cmp)?xchg)_u)|i(32|64)\.atomic\.(load((8|16)_u)?|store(8|16)?|rmw(\.(a[dn]d|sub|x?or|(cmp)?xchg)|(8|16)\.(a[dn]d|sub|x?or|(cmp)?xchg)_u))|v128\.(load|store|const|not|andnot|and|or|xor|bitselect)|i(8x16|16x8|32x4|64x2)\.(shl|shr_[su])|i(8x16|16x8)\.(extract_lane_[su]|((add|sub)_saturate_[su])|avgr_u)|(i(8x16|16x8|32x4|64x2)|f(32x4|64x2))\.(splat|replace_lane|neg|add|sub)|i(8x16|16x8|32x4)\.(eq|ne|([lg][te]_[su])|abs|any_true|all_true|bitmask|((min|max)_[su]))|f(32x4|64x2)\.(eq|ne|[lg][te]|abs|sqrt|mul|div|min|max)|[fi](32x4|64x2)\.extract_lane|v8x16\.(shuffle|swizzle)|i16x8\.(load8x8_[su]|narrow_i32x4_[su]|widen_(low|high)_i8x16_[su]|mul)|i32x4\.(load16x4_[su]|widen_(low|high)_i16x8_[su]|mul|trunc_sat_f32x4_[su])|i64x2\.(load32x2_[su]|mul)|(v(8x16|16x8|32x4|64x2)\.load_splat)|i8x16\.narrow_i16x8_[su]|f32x4\.convert_i32x4_[su]|ref\.(func|(is_)?null)|\bextern\b|table(\.(size|get|set|size|grow|fill|init|copy))?/, token: "keyword"}, + {regex: /\b(funcref|externref|[fi](32|64))\b/, token: "atom"}, + {regex: /\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\?@#$%&|:\.]+)/, token: "variable-2"}, + {regex: /"(?:[^"\\\x00-\x1f\x7f]|\\[nt\\'"]|\\[0-9a-fA-F][0-9a-fA-F])*"/, token: "string"}, + {regex: /\(;.*?/, token: "comment", next: "comment"}, + {regex: /;;.*$/, token: "comment"}, + {regex: /\(/, indent: true}, + {regex: /\)/, dedent: true}, + ], + + comment: [ + {regex: /.*?;\)/, token: "comment", next: "start"}, + {regex: /.*/, token: "comment"}, + ], + + meta: { + dontIndentStates: ['comment'], + }, +}); + +// https://github.com/WebAssembly/design/issues/981 mentions text/webassembly, +// which seems like a reasonable choice, although it's not standard right now. +CodeMirror.defineMIME("text/webassembly", "wast"); + +}); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl/index.html new file mode 100644 index 0000000..e9c325e --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl/index.html @@ -0,0 +1,71 @@ + + +CodeMirror: Web IDL mode + + + + + + + + + + +
+

Web IDL mode

+ +
+ +
+ + + +

MIME type defined: text/x-webidl.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl/webidl.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl/webidl.js index 8143336..120de6b 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/webidl/webidl.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/index.html new file mode 100644 index 0000000..c0dec45 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/index.html @@ -0,0 +1,61 @@ + + +CodeMirror: XML mode + + + + + + + + + +
+

XML mode

+
+ +

The XML mode supports these configuration parameters:

+
+
htmlMode (boolean)
+
This switches the mode to parse HTML instead of XML. This + means attributes do not have to be quoted, and some elements + (such as br) do not require a closing tag.
+
matchClosing (boolean)
+
Controls whether the mode checks that close tags match the + corresponding opening tag, and highlights mismatches as errors. + Defaults to true.
+
alignCDATA (boolean)
+
Setting this to true will force the opening tag of CDATA + blocks to not be indented.
+
+ +

MIME types defined: application/xml, text/html.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/test.js new file mode 100644 index 0000000..b586d2b --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/test.js @@ -0,0 +1,51 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function() { + var mode = CodeMirror.getMode({indentUnit: 2}, "xml"), mname = "xml"; + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), mname); } + + MT("matching", + "[tag&bracket <][tag top][tag&bracket >]", + " text", + " [tag&bracket <][tag inner][tag&bracket />]", + "[tag&bracket ]"); + + MT("nonmatching", + "[tag&bracket <][tag top][tag&bracket >]", + " [tag&bracket <][tag inner][tag&bracket />]", + " [tag&bracket ]"); + + MT("doctype", + "[meta ]", + "[tag&bracket <][tag top][tag&bracket />]"); + + MT("cdata", + "[tag&bracket <][tag top][tag&bracket >]", + " [atom ]", + "[tag&bracket ]"); + + // HTML tests + mode = CodeMirror.getMode({indentUnit: 2}, "text/html"); + + MT("selfclose", + "[tag&bracket <][tag html][tag&bracket >]", + " [tag&bracket <][tag link] [attribute rel]=[string stylesheet] [attribute href]=[string \"/foobar\"][tag&bracket >]", + "[tag&bracket ]"); + + MT("list", + "[tag&bracket <][tag ol][tag&bracket >]", + " [tag&bracket <][tag li][tag&bracket >]one", + " [tag&bracket <][tag li][tag&bracket >]two", + "[tag&bracket ]"); + + MT("valueless", + "[tag&bracket <][tag input] [attribute type]=[string checkbox] [attribute checked][tag&bracket />]"); + + MT("pThenArticle", + "[tag&bracket <][tag p][tag&bracket >]", + " foo", + "[tag&bracket <][tag article][tag&bracket >]bar"); + +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/xml.js similarity index 96% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/xml.js index 5927bc9..46806ac 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xml/xml.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -189,7 +189,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { function Context(state, tagName, startOfLine) { this.prev = state.context; - this.tagName = tagName; + this.tagName = tagName || ""; this.indent = state.indented; this.startOfLine = startOfLine; if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) @@ -390,6 +390,17 @@ CodeMirror.defineMode("xml", function(editorConf, config_) { skipAttribute: function(state) { if (state.state == attrValueState) state.state = attrState + }, + + xmlCurrentTag: function(state) { + return state.tagName ? {name: state.tagName, close: state.type == "closeTag"} : null + }, + + xmlCurrentContext: function(state) { + var context = [] + for (var cx = state.context; cx; cx = cx.prev) + context.push(cx.tagName) + return context.reverse() } }; }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/index.html new file mode 100644 index 0000000..bca4d06 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/index.html @@ -0,0 +1,211 @@ + + +CodeMirror: XQuery mode + + + + + + + + + + + +
+

XQuery mode

+ + +
+ +
+ + + +

MIME types defined: application/xquery.

+ +

Development of the CodeMirror XQuery mode was sponsored by + MarkLogic and developed by + Mike Brevoort. +

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/test.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/test.js new file mode 100644 index 0000000..f7ad3ac --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/test.js @@ -0,0 +1,67 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Don't take these too seriously -- the expected results appear to be +// based on the results of actual runs without any serious manual +// verification. If a change you made causes them to fail, the test is +// as likely to wrong as the code. + +(function() { + var mode = CodeMirror.getMode({tabSize: 4}, "xquery"); + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } + + MT("eviltest", + "[keyword xquery] [keyword version] [variable "1][keyword .][atom 0][keyword -][variable ml"][def&variable ;] [comment (: this is : a \"comment\" :)]", + " [keyword let] [variable $let] [keyword :=] [variable <x] [variable attr][keyword =][variable "value">"test"<func>][def&variable ;function]() [variable $var] {[keyword function]()} {[variable $var]}[variable <][keyword /][variable func><][keyword /][variable x>]", + " [keyword let] [variable $joe][keyword :=][atom 1]", + " [keyword return] [keyword element] [variable element] {", + " [keyword attribute] [variable attribute] { [atom 1] },", + " [keyword element] [variable test] { [variable 'a'] }, [keyword attribute] [variable foo] { [variable "bar"] },", + " [def&variable fn:doc]()[[ [variable foo][keyword /][variable @bar] [keyword eq] [variable $let] ]],", + " [keyword //][variable x] } [comment (: a more 'evil' test :)]", + " [comment (: Modified Blakeley example (: with nested comment :) ... :)]", + " [keyword declare] [variable private] [keyword function] [def&variable local:declare]() {()}[variable ;]", + " [keyword declare] [variable private] [keyword function] [def&variable local:private]() {()}[variable ;]", + " [keyword declare] [variable private] [keyword function] [def&variable local:function]() {()}[variable ;]", + " [keyword declare] [variable private] [keyword function] [def&variable local:local]() {()}[variable ;]", + " [keyword let] [variable $let] [keyword :=] [variable <let>let] [variable $let] [keyword :=] [variable "let"<][keyword /let][variable >]", + " [keyword return] [keyword element] [variable element] {", + " [keyword attribute] [variable attribute] { [keyword try] { [def&variable xdmp:version]() } [keyword catch]([variable $e]) { [def&variable xdmp:log]([variable $e]) } },", + " [keyword attribute] [variable fn:doc] { [variable "bar"] [keyword castable] [keyword as] [atom xs:string] },", + " [keyword element] [variable text] { [keyword text] { [variable "text"] } },", + " [def&variable fn:doc]()[[ [qualifier child::][variable eq][keyword /]([variable @bar] [keyword |] [qualifier attribute::][variable attribute]) [keyword eq] [variable $let] ]],", + " [keyword //][variable fn:doc]", + " }"); + + MT("testEmptySequenceKeyword", + "[string \"foo\"] [keyword instance] [keyword of] [keyword empty-sequence]()"); + + MT("testMultiAttr", + "[tag

][variable hello] [variable world][tag

]"); + + MT("test namespaced variable", + "[keyword declare] [keyword namespace] [variable e] [keyword =] [string \"http://example.com/ANamespace\"][variable ;declare] [keyword variable] [variable $e:exampleComThisVarIsNotRecognized] [keyword as] [keyword element]([keyword *]) [variable external;]"); + + MT("test EQName variable", + "[keyword declare] [keyword variable] [variable $\"http://www.example.com/ns/my\":var] [keyword :=] [atom 12][variable ;]", + "[tag ]{[variable $\"http://www.example.com/ns/my\":var]}[tag ]"); + + MT("test EQName function", + "[keyword declare] [keyword function] [def&variable \"http://www.example.com/ns/my\":fn] ([variable $a] [keyword as] [atom xs:integer]) [keyword as] [atom xs:integer] {", + " [variable $a] [keyword +] [atom 2]", + "}[variable ;]", + "[tag ]{[def&variable \"http://www.example.com/ns/my\":fn]([atom 12])}[tag ]"); + + MT("test EQName function with single quotes", + "[keyword declare] [keyword function] [def&variable 'http://www.example.com/ns/my':fn] ([variable $a] [keyword as] [atom xs:integer]) [keyword as] [atom xs:integer] {", + " [variable $a] [keyword +] [atom 2]", + "}[variable ;]", + "[tag ]{[def&variable 'http://www.example.com/ns/my':fn]([atom 12])}[tag ]"); + + MT("testProcessingInstructions", + "[def&variable data]([comment&meta ]) [keyword instance] [keyword of] [atom xs:string]"); + + MT("testQuoteEscapeDouble", + "[keyword let] [variable $rootfolder] [keyword :=] [string \"c:\\builds\\winnt\\HEAD\\qa\\scripts\\\"]", + "[keyword let] [variable $keysfolder] [keyword :=] [def&variable concat]([variable $rootfolder], [string \"keys\\\"])"); +})(); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/xquery.js similarity index 99% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/xquery.js index f5db831..395b6a7 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/xquery/xquery.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas/index.html new file mode 100644 index 0000000..3987256 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas/index.html @@ -0,0 +1,87 @@ + + +CodeMirror: yacas mode + + + + + + + + + + +
+

yacas mode

+ + + + + + +

MIME types defined: text/x-yacas (yacas).

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas/yacas.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas/yacas.js index 34c84fb..b7ac96b 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yacas/yacas.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE // Yacas mode copyright (c) 2015 by Grzegorz Mazur // Loosely based on mathematica mode by Calin Barbat diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter/index.html new file mode 100644 index 0000000..f55b5bd --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter/index.html @@ -0,0 +1,121 @@ + + +CodeMirror: YAML front matter mode + + + + + + + + + + + + + +
+

YAML front matter mode

+
+ +

Defines a mode that parses +a YAML frontmatter +at the start of a file, switching to a base mode at the end of that. +Takes a mode configuration option base to configure the +base mode, which defaults to "gfm".

+ + + +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter/yaml-frontmatter.js similarity index 92% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter/yaml-frontmatter.js index 5f49772..f9050ad 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml-frontmatter/yaml-frontmatter.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function (mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -36,7 +36,7 @@ }, token: function (stream, state) { if (state.state == START) { - if (stream.match(/---/, false)) { + if (stream.match('---', false)) { state.state = FRONTMATTER return yamlMode.token(stream, state.inner) } else { @@ -45,7 +45,7 @@ return innerMode.token(stream, state.inner) } } else if (state.state == FRONTMATTER) { - var end = stream.sol() && stream.match(/---/, false) + var end = stream.sol() && stream.match(/(---|\.\.\.)/, false) var style = yamlMode.token(stream, state.inner) if (end) { state.state = BODY diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml/index.html new file mode 100644 index 0000000..6014d9d --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml/index.html @@ -0,0 +1,80 @@ + + +CodeMirror: YAML mode + + + + + + + + + +
+

YAML mode

+
+ + +

MIME types defined: text/x-yaml.

+ +
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml/yaml.js similarity index 92% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml/yaml.js index f35a401..d464941 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/yaml/yaml.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS @@ -38,9 +38,9 @@ CodeMirror.defineMode("yaml", function() { state.pair = false; state.pairStart = false; /* document start */ - if(stream.match(/---/)) { return "def"; } + if(stream.match('---')) { return "def"; } /* document end */ - if (stream.match(/\.\.\./)) { return "def"; } + if (stream.match('...')) { return "def"; } /* array list item */ if (stream.match(/\s*-\s+/)) { return 'meta'; } } @@ -57,12 +57,12 @@ CodeMirror.defineMode("yaml", function() { return 'meta'; } - /* list seperator */ + /* list separator */ if (state.inlineList > 0 && !esc && ch == ',') { stream.next(); return 'meta'; } - /* pairs seperator */ + /* pairs separator */ if (state.inlinePairs > 0 && !esc && ch == ',') { state.keyCol = 0; state.pair = false; @@ -109,7 +109,8 @@ CodeMirror.defineMode("yaml", function() { escaped: false }; }, - lineComment: "#" + lineComment: "#", + fold: "indent" }; }); diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80/index.html b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80/index.html new file mode 100644 index 0000000..ca53bff --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80/index.html @@ -0,0 +1,53 @@ + + +CodeMirror: Z80 assembly mode + + + + + + + + + +
+

Z80 assembly mode

+ + +
+ + + +

MIME types defined: text/x-z80, text/x-ez80.

+
diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80.js b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80/z80.js similarity index 98% rename from Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80.js rename to Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80/z80.js index aae7021..8cea4ff 100644 --- a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80.js +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/modes/z80/z80.js @@ -1,5 +1,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE +// Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS diff --git a/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/theme/snip-material.css b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/theme/snip-material.css new file mode 100644 index 0000000..d862b11 --- /dev/null +++ b/Sources/CodeMirror-SwiftUI/Resources/CodeMirrorView.bundle/Contents/Resources/theme/snip-material.css @@ -0,0 +1,131 @@ +.cm-s-snip-material.CodeMirror { + background-color: #21232D; + color: #A6ACCD; + font-size: 12px; + line-height: 1.3em; +} + +.cm-s-snip-material .CodeMirror-gutters { + background: #21232D; + color: #676E95; + border: none; +} + +.cm-s-snip-material .CodeMirror-guttermarker, +.cm-s-snip-material .CodeMirror-guttermarker-subtle, +.cm-s-snip-material .CodeMirror-linenumber { + color: #676E95; +} + +.cm-s-snip-material .CodeMirror-cursor { + border-left: 1px solid #FFCC00; +} + +.cm-s-snip-material div.CodeMirror-selected { + background: rgba(113, 124, 180, 0.2); +} + +.cm-s-snip-material.CodeMirror-focused div.CodeMirror-selected { + background: rgba(113, 124, 180, 0.2); +} + +.cm-s-snip-material .CodeMirror-line::selection, +.cm-s-snip-material .CodeMirror-line>span::selection, +.cm-s-snip-material .CodeMirror-line>span>span::selection { + background: rgba(128, 203, 196, 0.2); +} + +.cm-s-snip-material .CodeMirror-line::-moz-selection, +.cm-s-snip-material .CodeMirror-line>span::-moz-selection, +.cm-s-snip-material .CodeMirror-line>span>span::-moz-selection { + background: rgba(128, 203, 196, 0.2); +} + +.cm-s-snip-material .CodeMirror-activeline-background { + background: rgba(0, 0, 0, 0.5); +} + +.cm-s-snip-material .cm-keyword { + color: #C792EA; +} + +.cm-s-snip-material .cm-operator { + color: #89DDFF; +} + +.cm-s-snip-material .cm-variable-2 { + color: #EEFFFF; +} + +.cm-s-snip-material .cm-variable-3, +.cm-s-snip-material .cm-type { + color: #f07178; +} + +.cm-s-snip-material .cm-builtin { + color: #FFCB6B; +} + +.cm-s-snip-material .cm-atom { + color: #F78C6C; +} + +.cm-s-snip-material .cm-number { + color: #FF5370; +} + +.cm-s-snip-material .cm-def { + color: #82AAFF; +} + +.cm-s-snip-material .cm-string { + color: #C3E88D; +} + +.cm-s-snip-material .cm-string-2 { + color: #f07178; +} + +.cm-s-snip-material .cm-comment { + color: #676E95; +} + +.cm-s-snip-material .cm-variable { + color: #f07178; +} + +.cm-s-snip-material .cm-tag { + color: #FF5370; +} + +.cm-s-snip-material .cm-meta { + color: #FFCB6B; +} + +.cm-s-snip-material .cm-attribute { + color: #C792EA; +} + +.cm-s-snip-material .cm-property { + color: #C792EA; +} + +.cm-s-snip-material .cm-qualifier { + color: #DECB6B; +} + +.cm-s-snip-material .cm-variable-3, +.cm-s-snip-material .cm-type { + color: #DECB6B; +} + + +.cm-s-snip-material .cm-error { + color: rgba(255, 255, 255, 1.0); + background-color: #FF5370; +} + +.cm-s-snip-material .CodeMirror-matchingbracket { + text-decoration: underline; + color: white !important; +}