fluentd-ui 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/application.js +2 -0
- data/app/assets/javascripts/codemirror.js +29 -0
- data/app/assets/javascripts/codemirror_fluentd.js +59 -0
- data/app/assets/stylesheets/application.css +6 -0
- data/app/views/fluentd/settings/edit.html.haml +1 -1
- data/app/views/shared/vue/_setting.html.erb +1 -1
- data/bower.json +2 -1
- data/lib/fluentd-ui/version.rb +1 -1
- data/spec/features/source_and_output_spec.rb +16 -6
- data/vendor/assets/javascripts/bower/codemirror/.bower.json +29 -0
- data/vendor/assets/javascripts/bower/codemirror/AUTHORS +423 -0
- data/vendor/assets/javascripts/bower/codemirror/CONTRIBUTING.md +76 -0
- data/vendor/assets/javascripts/bower/codemirror/LICENSE +19 -0
- data/vendor/assets/javascripts/bower/codemirror/README.md +11 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/comment.js +183 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/continuecomment.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.js +155 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.css +6 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/panel.js +94 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/placeholder.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/rulers.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closebrackets.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closetag.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/continuelist.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchbrackets.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchtags.js +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/trailingspace.js +27 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/brace-fold.js +105 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/comment-fold.js +57 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldcode.js +145 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.css +20 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.js +134 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/indent-fold.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/markdown-fold.js +49 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/xml-fold.js +182 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/anyword-hint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/css-hint.js +56 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/html-hint.js +348 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/javascript-hint.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.js +389 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/sql-hint.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/xml-hint.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/coffeescript-lint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/css-lint.js +35 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/javascript-lint.js +136 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/json-lint.js +31 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.css +73 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.js +204 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/yaml-lint.js +28 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.css +112 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.js +643 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/loadmode.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex_test.js +33 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/overlay.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/simple.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/colorize.js +40 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode-standalone.js +157 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.js +72 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.node.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/annotatescrollbar.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/scrollpastend.js +46 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.css +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/match-highlighter.js +128 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.css +8 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.js +90 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/search.js +164 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/searchcursor.js +189 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/active-line.js +71 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/mark-selection.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.css +86 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.js +670 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/worker.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/wrap/hardwrap.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/bower.json +16 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/emacs.js +411 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/sublime.js +540 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/vim.js +4901 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.css +309 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.js +8029 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/apl/apl.js +175 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/asterisk/asterisk.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/clike.js +489 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/scala.html +767 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clojure/clojure.js +243 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cobol/cobol.js +255 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/coffeescript/coffeescript.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/commonlisp/commonlisp.js +122 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/css.js +717 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less.html +152 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less_test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss.html +157 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss_test.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/test.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cypher/cypher.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/d/d.js +218 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dart/dart.js +50 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/diff/diff.js +47 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/django/django.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dockerfile/dockerfile.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dtd/dtd.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dylan/dylan.js +299 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ebnf/ebnf.js +195 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ecl/ecl.js +207 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/eiffel/eiffel.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/erlang/erlang.js +622 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/fortran/fortran.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gas/gas.js +345 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/gfm.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/test.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gherkin/gherkin.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/go/go.js +184 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/groovy/groovy.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/haml.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/test.js +97 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haskell/haskell.js +267 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haxe/haxe.js +518 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlembedded/htmlembedded.js +86 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlmixed/htmlmixed.js +121 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/http/http.js +113 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/idl/idl.js +290 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jade/jade.js +590 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/javascript.js +686 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/json-ld.html +72 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/test.js +200 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/typescript.html +61 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jinja2/jinja2.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/julia/julia.js +301 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/kotlin/kotlin.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/livescript/livescript.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/lua/lua.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/markdown.js +765 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/test.js +754 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/meta.js +165 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mirc/mirc.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mllike/mllike.js +205 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/modelica/modelica.js +245 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/nginx/nginx.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ntriples/ntriples.js +186 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/octave/octave.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pascal/pascal.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pegjs/pegjs.js +114 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/perl/perl.js +832 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/php.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/test.js +154 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pig/pig.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/properties/properties.js +78 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/puppet/puppet.js +220 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/python/python.js +359 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/q/q.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/r/r.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rpm/rpm.js +101 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rst/rst.js +557 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/ruby.js +285 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/test.js +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rust/rust.js +451 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sass/sass.js +327 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/scheme/scheme.js +248 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/shell.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/test.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sieve/sieve.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/slim.js +575 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/test.js +96 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smalltalk/smalltalk.js +168 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smarty/smarty.js +221 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smartymixed/smartymixed.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/solr/solr.js +104 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/soy/soy.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sparql/sparql.js +174 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/spreadsheet/spreadsheet.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sql/sql.js +391 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/stex.js +251 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/test.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tcl/tcl.js +147 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/test.js +417 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/textile.js +469 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.js +323 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/toml/toml.js +88 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tornado/tornado.js +68 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/turtle/turtle.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vb/vb.js +274 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vbscript/vbscript.js +350 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/velocity/velocity.js +201 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/test.js +273 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/verilog.js +364 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/xml.js +384 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/test.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/xquery.js +447 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/yaml/yaml.js +117 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/z80/z80.js +100 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-day.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-night.css +37 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance-mobile.css +5 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance.css +77 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/blackboard.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/cobalt.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/eclipse.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/elegant.css +13 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/erlang-dark.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/lesser-dark.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mbo.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mdn-like.css +44 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/midnight.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/monokai.css +31 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neat.css +12 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neo.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/night.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/pastel-on-dark.css +50 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/rubyblue.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/solarized.css +165 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/the-matrix.css +28 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-bright.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-eighties.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/twilight.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/vibrant-ink.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-dark.css +51 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-light.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/zenburn.css +37 -0
- metadata +225 -2
@@ -0,0 +1,164 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// Define search commands. Depends on dialog.js or another
|
5
|
+
// implementation of the openDialog method.
|
6
|
+
|
7
|
+
// Replace works a little oddly -- it will do the replace on the next
|
8
|
+
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
|
9
|
+
// replace by making sure the match is no longer selected when hitting
|
10
|
+
// Ctrl-G.
|
11
|
+
|
12
|
+
(function(mod) {
|
13
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
14
|
+
mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog"));
|
15
|
+
else if (typeof define == "function" && define.amd) // AMD
|
16
|
+
define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod);
|
17
|
+
else // Plain browser env
|
18
|
+
mod(CodeMirror);
|
19
|
+
})(function(CodeMirror) {
|
20
|
+
"use strict";
|
21
|
+
function searchOverlay(query, caseInsensitive) {
|
22
|
+
if (typeof query == "string")
|
23
|
+
query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
|
24
|
+
else if (!query.global)
|
25
|
+
query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
|
26
|
+
|
27
|
+
return {token: function(stream) {
|
28
|
+
query.lastIndex = stream.pos;
|
29
|
+
var match = query.exec(stream.string);
|
30
|
+
if (match && match.index == stream.pos) {
|
31
|
+
stream.pos += match[0].length;
|
32
|
+
return "searching";
|
33
|
+
} else if (match) {
|
34
|
+
stream.pos = match.index;
|
35
|
+
} else {
|
36
|
+
stream.skipToEnd();
|
37
|
+
}
|
38
|
+
}};
|
39
|
+
}
|
40
|
+
|
41
|
+
function SearchState() {
|
42
|
+
this.posFrom = this.posTo = this.query = null;
|
43
|
+
this.overlay = null;
|
44
|
+
}
|
45
|
+
function getSearchState(cm) {
|
46
|
+
return cm.state.search || (cm.state.search = new SearchState());
|
47
|
+
}
|
48
|
+
function queryCaseInsensitive(query) {
|
49
|
+
return typeof query == "string" && query == query.toLowerCase();
|
50
|
+
}
|
51
|
+
function getSearchCursor(cm, query, pos) {
|
52
|
+
// Heuristic: if the query string is all lowercase, do a case insensitive search.
|
53
|
+
return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
|
54
|
+
}
|
55
|
+
function dialog(cm, text, shortText, deflt, f) {
|
56
|
+
if (cm.openDialog) cm.openDialog(text, f, {value: deflt});
|
57
|
+
else f(prompt(shortText, deflt));
|
58
|
+
}
|
59
|
+
function confirmDialog(cm, text, shortText, fs) {
|
60
|
+
if (cm.openConfirm) cm.openConfirm(text, fs);
|
61
|
+
else if (confirm(shortText)) fs[0]();
|
62
|
+
}
|
63
|
+
function parseQuery(query) {
|
64
|
+
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
|
65
|
+
if (isRE) {
|
66
|
+
try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
|
67
|
+
catch(e) {} // Not a regular expression after all, do a string search
|
68
|
+
}
|
69
|
+
if (typeof query == "string" ? query == "" : query.test(""))
|
70
|
+
query = /x^/;
|
71
|
+
return query;
|
72
|
+
}
|
73
|
+
var queryDialog =
|
74
|
+
'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
75
|
+
function doSearch(cm, rev) {
|
76
|
+
var state = getSearchState(cm);
|
77
|
+
if (state.query) return findNext(cm, rev);
|
78
|
+
dialog(cm, queryDialog, "Search for:", cm.getSelection(), function(query) {
|
79
|
+
cm.operation(function() {
|
80
|
+
if (!query || state.query) return;
|
81
|
+
state.query = parseQuery(query);
|
82
|
+
cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
|
83
|
+
state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
|
84
|
+
cm.addOverlay(state.overlay);
|
85
|
+
if (cm.showMatchesOnScrollbar) {
|
86
|
+
if (state.annotate) { state.annotate.clear(); state.annotate = null; }
|
87
|
+
state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
|
88
|
+
}
|
89
|
+
state.posFrom = state.posTo = cm.getCursor();
|
90
|
+
findNext(cm, rev);
|
91
|
+
});
|
92
|
+
});
|
93
|
+
}
|
94
|
+
function findNext(cm, rev) {cm.operation(function() {
|
95
|
+
var state = getSearchState(cm);
|
96
|
+
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
|
97
|
+
if (!cursor.find(rev)) {
|
98
|
+
cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
|
99
|
+
if (!cursor.find(rev)) return;
|
100
|
+
}
|
101
|
+
cm.setSelection(cursor.from(), cursor.to());
|
102
|
+
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
|
103
|
+
state.posFrom = cursor.from(); state.posTo = cursor.to();
|
104
|
+
});}
|
105
|
+
function clearSearch(cm) {cm.operation(function() {
|
106
|
+
var state = getSearchState(cm);
|
107
|
+
if (!state.query) return;
|
108
|
+
state.query = null;
|
109
|
+
cm.removeOverlay(state.overlay);
|
110
|
+
if (state.annotate) { state.annotate.clear(); state.annotate = null; }
|
111
|
+
});}
|
112
|
+
|
113
|
+
var replaceQueryDialog =
|
114
|
+
'Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
115
|
+
var replacementQueryDialog = 'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
|
116
|
+
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";
|
117
|
+
function replace(cm, all) {
|
118
|
+
if (cm.getOption("readOnly")) return;
|
119
|
+
dialog(cm, replaceQueryDialog, "Replace:", cm.getSelection(), function(query) {
|
120
|
+
if (!query) return;
|
121
|
+
query = parseQuery(query);
|
122
|
+
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
|
123
|
+
if (all) {
|
124
|
+
cm.operation(function() {
|
125
|
+
for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
|
126
|
+
if (typeof query != "string") {
|
127
|
+
var match = cm.getRange(cursor.from(), cursor.to()).match(query);
|
128
|
+
cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
129
|
+
} else cursor.replace(text);
|
130
|
+
}
|
131
|
+
});
|
132
|
+
} else {
|
133
|
+
clearSearch(cm);
|
134
|
+
var cursor = getSearchCursor(cm, query, cm.getCursor());
|
135
|
+
var advance = function() {
|
136
|
+
var start = cursor.from(), match;
|
137
|
+
if (!(match = cursor.findNext())) {
|
138
|
+
cursor = getSearchCursor(cm, query);
|
139
|
+
if (!(match = cursor.findNext()) ||
|
140
|
+
(start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
|
141
|
+
}
|
142
|
+
cm.setSelection(cursor.from(), cursor.to());
|
143
|
+
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
|
144
|
+
confirmDialog(cm, doReplaceConfirm, "Replace?",
|
145
|
+
[function() {doReplace(match);}, advance]);
|
146
|
+
};
|
147
|
+
var doReplace = function(match) {
|
148
|
+
cursor.replace(typeof query == "string" ? text :
|
149
|
+
text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
150
|
+
advance();
|
151
|
+
};
|
152
|
+
advance();
|
153
|
+
}
|
154
|
+
});
|
155
|
+
});
|
156
|
+
}
|
157
|
+
|
158
|
+
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
|
159
|
+
CodeMirror.commands.findNext = doSearch;
|
160
|
+
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
|
161
|
+
CodeMirror.commands.clearSearch = clearSearch;
|
162
|
+
CodeMirror.commands.replace = replace;
|
163
|
+
CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
|
164
|
+
});
|
@@ -0,0 +1,189 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
var Pos = CodeMirror.Pos;
|
14
|
+
|
15
|
+
function SearchCursor(doc, query, pos, caseFold) {
|
16
|
+
this.atOccurrence = false; this.doc = doc;
|
17
|
+
if (caseFold == null && typeof query == "string") caseFold = false;
|
18
|
+
|
19
|
+
pos = pos ? doc.clipPos(pos) : Pos(0, 0);
|
20
|
+
this.pos = {from: pos, to: pos};
|
21
|
+
|
22
|
+
// The matches method is filled in based on the type of query.
|
23
|
+
// It takes a position and a direction, and returns an object
|
24
|
+
// describing the next occurrence of the query, or null if no
|
25
|
+
// more matches were found.
|
26
|
+
if (typeof query != "string") { // Regexp match
|
27
|
+
if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g");
|
28
|
+
this.matches = function(reverse, pos) {
|
29
|
+
if (reverse) {
|
30
|
+
query.lastIndex = 0;
|
31
|
+
var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start;
|
32
|
+
for (;;) {
|
33
|
+
query.lastIndex = cutOff;
|
34
|
+
var newMatch = query.exec(line);
|
35
|
+
if (!newMatch) break;
|
36
|
+
match = newMatch;
|
37
|
+
start = match.index;
|
38
|
+
cutOff = match.index + (match[0].length || 1);
|
39
|
+
if (cutOff == line.length) break;
|
40
|
+
}
|
41
|
+
var matchLen = (match && match[0].length) || 0;
|
42
|
+
if (!matchLen) {
|
43
|
+
if (start == 0 && line.length == 0) {match = undefined;}
|
44
|
+
else if (start != doc.getLine(pos.line).length) {
|
45
|
+
matchLen++;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
} else {
|
49
|
+
query.lastIndex = pos.ch;
|
50
|
+
var line = doc.getLine(pos.line), match = query.exec(line);
|
51
|
+
var matchLen = (match && match[0].length) || 0;
|
52
|
+
var start = match && match.index;
|
53
|
+
if (start + matchLen != line.length && !matchLen) matchLen = 1;
|
54
|
+
}
|
55
|
+
if (match && matchLen)
|
56
|
+
return {from: Pos(pos.line, start),
|
57
|
+
to: Pos(pos.line, start + matchLen),
|
58
|
+
match: match};
|
59
|
+
};
|
60
|
+
} else { // String query
|
61
|
+
var origQuery = query;
|
62
|
+
if (caseFold) query = query.toLowerCase();
|
63
|
+
var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
|
64
|
+
var target = query.split("\n");
|
65
|
+
// Different methods for single-line and multi-line queries
|
66
|
+
if (target.length == 1) {
|
67
|
+
if (!query.length) {
|
68
|
+
// Empty string would match anything and never progress, so
|
69
|
+
// we define it to match nothing instead.
|
70
|
+
this.matches = function() {};
|
71
|
+
} else {
|
72
|
+
this.matches = function(reverse, pos) {
|
73
|
+
if (reverse) {
|
74
|
+
var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig);
|
75
|
+
var match = line.lastIndexOf(query);
|
76
|
+
if (match > -1) {
|
77
|
+
match = adjustPos(orig, line, match);
|
78
|
+
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
79
|
+
}
|
80
|
+
} else {
|
81
|
+
var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig);
|
82
|
+
var match = line.indexOf(query);
|
83
|
+
if (match > -1) {
|
84
|
+
match = adjustPos(orig, line, match) + pos.ch;
|
85
|
+
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
86
|
+
}
|
87
|
+
}
|
88
|
+
};
|
89
|
+
}
|
90
|
+
} else {
|
91
|
+
var origTarget = origQuery.split("\n");
|
92
|
+
this.matches = function(reverse, pos) {
|
93
|
+
var last = target.length - 1;
|
94
|
+
if (reverse) {
|
95
|
+
if (pos.line - (target.length - 1) < doc.firstLine()) return;
|
96
|
+
if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return;
|
97
|
+
var to = Pos(pos.line, origTarget[last].length);
|
98
|
+
for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln)
|
99
|
+
if (target[i] != fold(doc.getLine(ln))) return;
|
100
|
+
var line = doc.getLine(ln), cut = line.length - origTarget[0].length;
|
101
|
+
if (fold(line.slice(cut)) != target[0]) return;
|
102
|
+
return {from: Pos(ln, cut), to: to};
|
103
|
+
} else {
|
104
|
+
if (pos.line + (target.length - 1) > doc.lastLine()) return;
|
105
|
+
var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length;
|
106
|
+
if (fold(line.slice(cut)) != target[0]) return;
|
107
|
+
var from = Pos(pos.line, cut);
|
108
|
+
for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln)
|
109
|
+
if (target[i] != fold(doc.getLine(ln))) return;
|
110
|
+
if (fold(doc.getLine(ln).slice(0, origTarget[last].length)) != target[last]) return;
|
111
|
+
return {from: from, to: Pos(ln, origTarget[last].length)};
|
112
|
+
}
|
113
|
+
};
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
SearchCursor.prototype = {
|
119
|
+
findNext: function() {return this.find(false);},
|
120
|
+
findPrevious: function() {return this.find(true);},
|
121
|
+
|
122
|
+
find: function(reverse) {
|
123
|
+
var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
|
124
|
+
function savePosAndFail(line) {
|
125
|
+
var pos = Pos(line, 0);
|
126
|
+
self.pos = {from: pos, to: pos};
|
127
|
+
self.atOccurrence = false;
|
128
|
+
return false;
|
129
|
+
}
|
130
|
+
|
131
|
+
for (;;) {
|
132
|
+
if (this.pos = this.matches(reverse, pos)) {
|
133
|
+
this.atOccurrence = true;
|
134
|
+
return this.pos.match || true;
|
135
|
+
}
|
136
|
+
if (reverse) {
|
137
|
+
if (!pos.line) return savePosAndFail(0);
|
138
|
+
pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length);
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
var maxLine = this.doc.lineCount();
|
142
|
+
if (pos.line == maxLine - 1) return savePosAndFail(maxLine);
|
143
|
+
pos = Pos(pos.line + 1, 0);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
},
|
147
|
+
|
148
|
+
from: function() {if (this.atOccurrence) return this.pos.from;},
|
149
|
+
to: function() {if (this.atOccurrence) return this.pos.to;},
|
150
|
+
|
151
|
+
replace: function(newText) {
|
152
|
+
if (!this.atOccurrence) return;
|
153
|
+
var lines = CodeMirror.splitLines(newText);
|
154
|
+
this.doc.replaceRange(lines, this.pos.from, this.pos.to);
|
155
|
+
this.pos.to = Pos(this.pos.from.line + lines.length - 1,
|
156
|
+
lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
// Maps a position in a case-folded line back to a position in the original line
|
161
|
+
// (compensating for codepoints increasing in number during folding)
|
162
|
+
function adjustPos(orig, folded, pos) {
|
163
|
+
if (orig.length == folded.length) return pos;
|
164
|
+
for (var pos1 = Math.min(pos, orig.length);;) {
|
165
|
+
var len1 = orig.slice(0, pos1).toLowerCase().length;
|
166
|
+
if (len1 < pos) ++pos1;
|
167
|
+
else if (len1 > pos) --pos1;
|
168
|
+
else return pos1;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
|
173
|
+
return new SearchCursor(this.doc, query, pos, caseFold);
|
174
|
+
});
|
175
|
+
CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
|
176
|
+
return new SearchCursor(this, query, pos, caseFold);
|
177
|
+
});
|
178
|
+
|
179
|
+
CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
|
180
|
+
var ranges = [], next;
|
181
|
+
var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
|
182
|
+
while (next = cur.findNext()) {
|
183
|
+
if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break;
|
184
|
+
ranges.push({anchor: cur.from(), head: cur.to()});
|
185
|
+
}
|
186
|
+
if (ranges.length)
|
187
|
+
this.setSelections(ranges, 0);
|
188
|
+
});
|
189
|
+
});
|
@@ -0,0 +1,71 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// Because sometimes you need to style the cursor's line.
|
5
|
+
//
|
6
|
+
// Adds an option 'styleActiveLine' which, when enabled, gives the
|
7
|
+
// active line's wrapping <div> the CSS class "CodeMirror-activeline",
|
8
|
+
// and gives its background <div> the class "CodeMirror-activeline-background".
|
9
|
+
|
10
|
+
(function(mod) {
|
11
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12
|
+
mod(require("../../lib/codemirror"));
|
13
|
+
else if (typeof define == "function" && define.amd) // AMD
|
14
|
+
define(["../../lib/codemirror"], mod);
|
15
|
+
else // Plain browser env
|
16
|
+
mod(CodeMirror);
|
17
|
+
})(function(CodeMirror) {
|
18
|
+
"use strict";
|
19
|
+
var WRAP_CLASS = "CodeMirror-activeline";
|
20
|
+
var BACK_CLASS = "CodeMirror-activeline-background";
|
21
|
+
|
22
|
+
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
|
23
|
+
var prev = old && old != CodeMirror.Init;
|
24
|
+
if (val && !prev) {
|
25
|
+
cm.state.activeLines = [];
|
26
|
+
updateActiveLines(cm, cm.listSelections());
|
27
|
+
cm.on("beforeSelectionChange", selectionChange);
|
28
|
+
} else if (!val && prev) {
|
29
|
+
cm.off("beforeSelectionChange", selectionChange);
|
30
|
+
clearActiveLines(cm);
|
31
|
+
delete cm.state.activeLines;
|
32
|
+
}
|
33
|
+
});
|
34
|
+
|
35
|
+
function clearActiveLines(cm) {
|
36
|
+
for (var i = 0; i < cm.state.activeLines.length; i++) {
|
37
|
+
cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
|
38
|
+
cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
function sameArray(a, b) {
|
43
|
+
if (a.length != b.length) return false;
|
44
|
+
for (var i = 0; i < a.length; i++)
|
45
|
+
if (a[i] != b[i]) return false;
|
46
|
+
return true;
|
47
|
+
}
|
48
|
+
|
49
|
+
function updateActiveLines(cm, ranges) {
|
50
|
+
var active = [];
|
51
|
+
for (var i = 0; i < ranges.length; i++) {
|
52
|
+
var range = ranges[i];
|
53
|
+
if (!range.empty()) continue;
|
54
|
+
var line = cm.getLineHandleVisualStart(range.head.line);
|
55
|
+
if (active[active.length - 1] != line) active.push(line);
|
56
|
+
}
|
57
|
+
if (sameArray(cm.state.activeLines, active)) return;
|
58
|
+
cm.operation(function() {
|
59
|
+
clearActiveLines(cm);
|
60
|
+
for (var i = 0; i < active.length; i++) {
|
61
|
+
cm.addLineClass(active[i], "wrap", WRAP_CLASS);
|
62
|
+
cm.addLineClass(active[i], "background", BACK_CLASS);
|
63
|
+
}
|
64
|
+
cm.state.activeLines = active;
|
65
|
+
});
|
66
|
+
}
|
67
|
+
|
68
|
+
function selectionChange(cm, sel) {
|
69
|
+
updateActiveLines(cm, sel.ranges);
|
70
|
+
}
|
71
|
+
});
|
@@ -0,0 +1,118 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// Because sometimes you need to mark the selected *text*.
|
5
|
+
//
|
6
|
+
// Adds an option 'styleSelectedText' which, when enabled, gives
|
7
|
+
// selected text the CSS class given as option value, or
|
8
|
+
// "CodeMirror-selectedtext" when the value is not a string.
|
9
|
+
|
10
|
+
(function(mod) {
|
11
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12
|
+
mod(require("../../lib/codemirror"));
|
13
|
+
else if (typeof define == "function" && define.amd) // AMD
|
14
|
+
define(["../../lib/codemirror"], mod);
|
15
|
+
else // Plain browser env
|
16
|
+
mod(CodeMirror);
|
17
|
+
})(function(CodeMirror) {
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
|
21
|
+
var prev = old && old != CodeMirror.Init;
|
22
|
+
if (val && !prev) {
|
23
|
+
cm.state.markedSelection = [];
|
24
|
+
cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
|
25
|
+
reset(cm);
|
26
|
+
cm.on("cursorActivity", onCursorActivity);
|
27
|
+
cm.on("change", onChange);
|
28
|
+
} else if (!val && prev) {
|
29
|
+
cm.off("cursorActivity", onCursorActivity);
|
30
|
+
cm.off("change", onChange);
|
31
|
+
clear(cm);
|
32
|
+
cm.state.markedSelection = cm.state.markedSelectionStyle = null;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
function onCursorActivity(cm) {
|
37
|
+
cm.operation(function() { update(cm); });
|
38
|
+
}
|
39
|
+
|
40
|
+
function onChange(cm) {
|
41
|
+
if (cm.state.markedSelection.length)
|
42
|
+
cm.operation(function() { clear(cm); });
|
43
|
+
}
|
44
|
+
|
45
|
+
var CHUNK_SIZE = 8;
|
46
|
+
var Pos = CodeMirror.Pos;
|
47
|
+
var cmp = CodeMirror.cmpPos;
|
48
|
+
|
49
|
+
function coverRange(cm, from, to, addAt) {
|
50
|
+
if (cmp(from, to) == 0) return;
|
51
|
+
var array = cm.state.markedSelection;
|
52
|
+
var cls = cm.state.markedSelectionStyle;
|
53
|
+
for (var line = from.line;;) {
|
54
|
+
var start = line == from.line ? from : Pos(line, 0);
|
55
|
+
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
|
56
|
+
var end = atEnd ? to : Pos(endLine, 0);
|
57
|
+
var mark = cm.markText(start, end, {className: cls});
|
58
|
+
if (addAt == null) array.push(mark);
|
59
|
+
else array.splice(addAt++, 0, mark);
|
60
|
+
if (atEnd) break;
|
61
|
+
line = endLine;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
function clear(cm) {
|
66
|
+
var array = cm.state.markedSelection;
|
67
|
+
for (var i = 0; i < array.length; ++i) array[i].clear();
|
68
|
+
array.length = 0;
|
69
|
+
}
|
70
|
+
|
71
|
+
function reset(cm) {
|
72
|
+
clear(cm);
|
73
|
+
var ranges = cm.listSelections();
|
74
|
+
for (var i = 0; i < ranges.length; i++)
|
75
|
+
coverRange(cm, ranges[i].from(), ranges[i].to());
|
76
|
+
}
|
77
|
+
|
78
|
+
function update(cm) {
|
79
|
+
if (!cm.somethingSelected()) return clear(cm);
|
80
|
+
if (cm.listSelections().length > 1) return reset(cm);
|
81
|
+
|
82
|
+
var from = cm.getCursor("start"), to = cm.getCursor("end");
|
83
|
+
|
84
|
+
var array = cm.state.markedSelection;
|
85
|
+
if (!array.length) return coverRange(cm, from, to);
|
86
|
+
|
87
|
+
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
|
88
|
+
if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
|
89
|
+
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
|
90
|
+
return reset(cm);
|
91
|
+
|
92
|
+
while (cmp(from, coverStart.from) > 0) {
|
93
|
+
array.shift().clear();
|
94
|
+
coverStart = array[0].find();
|
95
|
+
}
|
96
|
+
if (cmp(from, coverStart.from) < 0) {
|
97
|
+
if (coverStart.to.line - from.line < CHUNK_SIZE) {
|
98
|
+
array.shift().clear();
|
99
|
+
coverRange(cm, from, coverStart.to, 0);
|
100
|
+
} else {
|
101
|
+
coverRange(cm, from, coverStart.from, 0);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
while (cmp(to, coverEnd.to) < 0) {
|
106
|
+
array.pop().clear();
|
107
|
+
coverEnd = array[array.length - 1].find();
|
108
|
+
}
|
109
|
+
if (cmp(to, coverEnd.to) > 0) {
|
110
|
+
if (to.line - coverEnd.from.line < CHUNK_SIZE) {
|
111
|
+
array.pop().clear();
|
112
|
+
coverRange(cm, coverEnd.from, to);
|
113
|
+
} else {
|
114
|
+
coverRange(cm, coverEnd.to, to);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
});
|