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,44 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// declare global: tern, server
|
5
|
+
|
6
|
+
var server;
|
7
|
+
|
8
|
+
this.onmessage = function(e) {
|
9
|
+
var data = e.data;
|
10
|
+
switch (data.type) {
|
11
|
+
case "init": return startServer(data.defs, data.plugins, data.scripts);
|
12
|
+
case "add": return server.addFile(data.name, data.text);
|
13
|
+
case "del": return server.delFile(data.name);
|
14
|
+
case "req": return server.request(data.body, function(err, reqData) {
|
15
|
+
postMessage({id: data.id, body: reqData, err: err && String(err)});
|
16
|
+
});
|
17
|
+
case "getFile":
|
18
|
+
var c = pending[data.id];
|
19
|
+
delete pending[data.id];
|
20
|
+
return c(data.err, data.text);
|
21
|
+
default: throw new Error("Unknown message type: " + data.type);
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
var nextId = 0, pending = {};
|
26
|
+
function getFile(file, c) {
|
27
|
+
postMessage({type: "getFile", name: file, id: ++nextId});
|
28
|
+
pending[nextId] = c;
|
29
|
+
}
|
30
|
+
|
31
|
+
function startServer(defs, plugins, scripts) {
|
32
|
+
if (scripts) importScripts.apply(null, scripts);
|
33
|
+
|
34
|
+
server = new tern.Server({
|
35
|
+
getFile: getFile,
|
36
|
+
async: true,
|
37
|
+
defs: defs,
|
38
|
+
plugins: plugins
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
var console = {
|
43
|
+
log: function(v) { postMessage({type: "debug", message: v}); }
|
44
|
+
};
|
@@ -0,0 +1,139 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
var Pos = CodeMirror.Pos;
|
15
|
+
|
16
|
+
function findParagraph(cm, pos, options) {
|
17
|
+
var startRE = options.paragraphStart || cm.getHelper(pos, "paragraphStart");
|
18
|
+
for (var start = pos.line, first = cm.firstLine(); start > first; --start) {
|
19
|
+
var line = cm.getLine(start);
|
20
|
+
if (startRE && startRE.test(line)) break;
|
21
|
+
if (!/\S/.test(line)) { ++start; break; }
|
22
|
+
}
|
23
|
+
var endRE = options.paragraphEnd || cm.getHelper(pos, "paragraphEnd");
|
24
|
+
for (var end = pos.line + 1, last = cm.lastLine(); end <= last; ++end) {
|
25
|
+
var line = cm.getLine(end);
|
26
|
+
if (endRE && endRE.test(line)) { ++end; break; }
|
27
|
+
if (!/\S/.test(line)) break;
|
28
|
+
}
|
29
|
+
return {from: start, to: end};
|
30
|
+
}
|
31
|
+
|
32
|
+
function findBreakPoint(text, column, wrapOn, killTrailingSpace) {
|
33
|
+
for (var at = column; at > 0; --at)
|
34
|
+
if (wrapOn.test(text.slice(at - 1, at + 1))) break;
|
35
|
+
if (at == 0) at = column;
|
36
|
+
var endOfText = at;
|
37
|
+
if (killTrailingSpace)
|
38
|
+
while (text.charAt(endOfText - 1) == " ") --endOfText;
|
39
|
+
return {from: endOfText, to: at};
|
40
|
+
}
|
41
|
+
|
42
|
+
function wrapRange(cm, from, to, options) {
|
43
|
+
from = cm.clipPos(from); to = cm.clipPos(to);
|
44
|
+
var column = options.column || 80;
|
45
|
+
var wrapOn = options.wrapOn || /\s\S|-[^\.\d]/;
|
46
|
+
var killTrailing = options.killTrailingSpace !== false;
|
47
|
+
var changes = [], curLine = "", curNo = from.line;
|
48
|
+
var lines = cm.getRange(from, to, false);
|
49
|
+
if (!lines.length) return null;
|
50
|
+
var leadingSpace = lines[0].match(/^[ \t]*/)[0];
|
51
|
+
|
52
|
+
for (var i = 0; i < lines.length; ++i) {
|
53
|
+
var text = lines[i], oldLen = curLine.length, spaceInserted = 0;
|
54
|
+
if (curLine && text && !wrapOn.test(curLine.charAt(curLine.length - 1) + text.charAt(0))) {
|
55
|
+
curLine += " ";
|
56
|
+
spaceInserted = 1;
|
57
|
+
}
|
58
|
+
var spaceTrimmed = "";
|
59
|
+
if (i) {
|
60
|
+
spaceTrimmed = text.match(/^\s*/)[0];
|
61
|
+
text = text.slice(spaceTrimmed.length);
|
62
|
+
}
|
63
|
+
curLine += text;
|
64
|
+
if (i) {
|
65
|
+
var firstBreak = curLine.length > column && leadingSpace == spaceTrimmed &&
|
66
|
+
findBreakPoint(curLine, column, wrapOn, killTrailing);
|
67
|
+
// If this isn't broken, or is broken at a different point, remove old break
|
68
|
+
if (!firstBreak || firstBreak.from != oldLen || firstBreak.to != oldLen + spaceInserted) {
|
69
|
+
changes.push({text: [spaceInserted ? " " : ""],
|
70
|
+
from: Pos(curNo, oldLen),
|
71
|
+
to: Pos(curNo + 1, spaceTrimmed.length)});
|
72
|
+
} else {
|
73
|
+
curLine = leadingSpace + text;
|
74
|
+
++curNo;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
while (curLine.length > column) {
|
78
|
+
var bp = findBreakPoint(curLine, column, wrapOn, killTrailing);
|
79
|
+
changes.push({text: ["", leadingSpace],
|
80
|
+
from: Pos(curNo, bp.from),
|
81
|
+
to: Pos(curNo, bp.to)});
|
82
|
+
curLine = leadingSpace + curLine.slice(bp.to);
|
83
|
+
++curNo;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
if (changes.length) cm.operation(function() {
|
87
|
+
for (var i = 0; i < changes.length; ++i) {
|
88
|
+
var change = changes[i];
|
89
|
+
cm.replaceRange(change.text, change.from, change.to);
|
90
|
+
}
|
91
|
+
});
|
92
|
+
return changes.length ? {from: changes[0].from, to: CodeMirror.changeEnd(changes[changes.length - 1])} : null;
|
93
|
+
}
|
94
|
+
|
95
|
+
CodeMirror.defineExtension("wrapParagraph", function(pos, options) {
|
96
|
+
options = options || {};
|
97
|
+
if (!pos) pos = this.getCursor();
|
98
|
+
var para = findParagraph(this, pos, options);
|
99
|
+
return wrapRange(this, Pos(para.from, 0), Pos(para.to - 1), options);
|
100
|
+
});
|
101
|
+
|
102
|
+
CodeMirror.commands.wrapLines = function(cm) {
|
103
|
+
cm.operation(function() {
|
104
|
+
var ranges = cm.listSelections(), at = cm.lastLine() + 1;
|
105
|
+
for (var i = ranges.length - 1; i >= 0; i--) {
|
106
|
+
var range = ranges[i], span;
|
107
|
+
if (range.empty()) {
|
108
|
+
var para = findParagraph(cm, range.head, {});
|
109
|
+
span = {from: Pos(para.from, 0), to: Pos(para.to - 1)};
|
110
|
+
} else {
|
111
|
+
span = {from: range.from(), to: range.to()};
|
112
|
+
}
|
113
|
+
if (span.to.line >= at) continue;
|
114
|
+
at = span.from.line;
|
115
|
+
wrapRange(cm, span.from, span.to, {});
|
116
|
+
}
|
117
|
+
});
|
118
|
+
};
|
119
|
+
|
120
|
+
CodeMirror.defineExtension("wrapRange", function(from, to, options) {
|
121
|
+
return wrapRange(this, from, to, options || {});
|
122
|
+
});
|
123
|
+
|
124
|
+
CodeMirror.defineExtension("wrapParagraphsInRange", function(from, to, options) {
|
125
|
+
options = options || {};
|
126
|
+
var cm = this, paras = [];
|
127
|
+
for (var line = from.line; line <= to.line;) {
|
128
|
+
var para = findParagraph(cm, Pos(line, 0), options);
|
129
|
+
paras.push(para);
|
130
|
+
line = para.to;
|
131
|
+
}
|
132
|
+
var madeChange = false;
|
133
|
+
if (paras.length) cm.operation(function() {
|
134
|
+
for (var i = paras.length - 1; i >= 0; --i)
|
135
|
+
madeChange = madeChange || wrapRange(cm, Pos(paras[i].from, 0), Pos(paras[i].to - 1), options);
|
136
|
+
});
|
137
|
+
return madeChange;
|
138
|
+
});
|
139
|
+
});
|
@@ -0,0 +1,411 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
var Pos = CodeMirror.Pos;
|
15
|
+
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
16
|
+
|
17
|
+
// Kill 'ring'
|
18
|
+
|
19
|
+
var killRing = [];
|
20
|
+
function addToRing(str) {
|
21
|
+
killRing.push(str);
|
22
|
+
if (killRing.length > 50) killRing.shift();
|
23
|
+
}
|
24
|
+
function growRingTop(str) {
|
25
|
+
if (!killRing.length) return addToRing(str);
|
26
|
+
killRing[killRing.length - 1] += str;
|
27
|
+
}
|
28
|
+
function getFromRing(n) { return killRing[killRing.length - (n ? Math.min(n, 1) : 1)] || ""; }
|
29
|
+
function popFromRing() { if (killRing.length > 1) killRing.pop(); return getFromRing(); }
|
30
|
+
|
31
|
+
var lastKill = null;
|
32
|
+
|
33
|
+
function kill(cm, from, to, mayGrow, text) {
|
34
|
+
if (text == null) text = cm.getRange(from, to);
|
35
|
+
|
36
|
+
if (mayGrow && lastKill && lastKill.cm == cm && posEq(from, lastKill.pos) && cm.isClean(lastKill.gen))
|
37
|
+
growRingTop(text);
|
38
|
+
else
|
39
|
+
addToRing(text);
|
40
|
+
cm.replaceRange("", from, to, "+delete");
|
41
|
+
|
42
|
+
if (mayGrow) lastKill = {cm: cm, pos: from, gen: cm.changeGeneration()};
|
43
|
+
else lastKill = null;
|
44
|
+
}
|
45
|
+
|
46
|
+
// Boundaries of various units
|
47
|
+
|
48
|
+
function byChar(cm, pos, dir) {
|
49
|
+
return cm.findPosH(pos, dir, "char", true);
|
50
|
+
}
|
51
|
+
|
52
|
+
function byWord(cm, pos, dir) {
|
53
|
+
return cm.findPosH(pos, dir, "word", true);
|
54
|
+
}
|
55
|
+
|
56
|
+
function byLine(cm, pos, dir) {
|
57
|
+
return cm.findPosV(pos, dir, "line", cm.doc.sel.goalColumn);
|
58
|
+
}
|
59
|
+
|
60
|
+
function byPage(cm, pos, dir) {
|
61
|
+
return cm.findPosV(pos, dir, "page", cm.doc.sel.goalColumn);
|
62
|
+
}
|
63
|
+
|
64
|
+
function byParagraph(cm, pos, dir) {
|
65
|
+
var no = pos.line, line = cm.getLine(no);
|
66
|
+
var sawText = /\S/.test(dir < 0 ? line.slice(0, pos.ch) : line.slice(pos.ch));
|
67
|
+
var fst = cm.firstLine(), lst = cm.lastLine();
|
68
|
+
for (;;) {
|
69
|
+
no += dir;
|
70
|
+
if (no < fst || no > lst)
|
71
|
+
return cm.clipPos(Pos(no - dir, dir < 0 ? 0 : null));
|
72
|
+
line = cm.getLine(no);
|
73
|
+
var hasText = /\S/.test(line);
|
74
|
+
if (hasText) sawText = true;
|
75
|
+
else if (sawText) return Pos(no, 0);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
function bySentence(cm, pos, dir) {
|
80
|
+
var line = pos.line, ch = pos.ch;
|
81
|
+
var text = cm.getLine(pos.line), sawWord = false;
|
82
|
+
for (;;) {
|
83
|
+
var next = text.charAt(ch + (dir < 0 ? -1 : 0));
|
84
|
+
if (!next) { // End/beginning of line reached
|
85
|
+
if (line == (dir < 0 ? cm.firstLine() : cm.lastLine())) return Pos(line, ch);
|
86
|
+
text = cm.getLine(line + dir);
|
87
|
+
if (!/\S/.test(text)) return Pos(line, ch);
|
88
|
+
line += dir;
|
89
|
+
ch = dir < 0 ? text.length : 0;
|
90
|
+
continue;
|
91
|
+
}
|
92
|
+
if (sawWord && /[!?.]/.test(next)) return Pos(line, ch + (dir > 0 ? 1 : 0));
|
93
|
+
if (!sawWord) sawWord = /\w/.test(next);
|
94
|
+
ch += dir;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
function byExpr(cm, pos, dir) {
|
99
|
+
var wrap;
|
100
|
+
if (cm.findMatchingBracket && (wrap = cm.findMatchingBracket(pos, true))
|
101
|
+
&& wrap.match && (wrap.forward ? 1 : -1) == dir)
|
102
|
+
return dir > 0 ? Pos(wrap.to.line, wrap.to.ch + 1) : wrap.to;
|
103
|
+
|
104
|
+
for (var first = true;; first = false) {
|
105
|
+
var token = cm.getTokenAt(pos);
|
106
|
+
var after = Pos(pos.line, dir < 0 ? token.start : token.end);
|
107
|
+
if (first && dir > 0 && token.end == pos.ch || !/\w/.test(token.string)) {
|
108
|
+
var newPos = cm.findPosH(after, dir, "char");
|
109
|
+
if (posEq(after, newPos)) return pos;
|
110
|
+
else pos = newPos;
|
111
|
+
} else {
|
112
|
+
return after;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
// Prefixes (only crudely supported)
|
118
|
+
|
119
|
+
function getPrefix(cm, precise) {
|
120
|
+
var digits = cm.state.emacsPrefix;
|
121
|
+
if (!digits) return precise ? null : 1;
|
122
|
+
clearPrefix(cm);
|
123
|
+
return digits == "-" ? -1 : Number(digits);
|
124
|
+
}
|
125
|
+
|
126
|
+
function repeated(cmd) {
|
127
|
+
var f = typeof cmd == "string" ? function(cm) { cm.execCommand(cmd); } : cmd;
|
128
|
+
return function(cm) {
|
129
|
+
var prefix = getPrefix(cm);
|
130
|
+
f(cm);
|
131
|
+
for (var i = 1; i < prefix; ++i) f(cm);
|
132
|
+
};
|
133
|
+
}
|
134
|
+
|
135
|
+
function findEnd(cm, pos, by, dir) {
|
136
|
+
var prefix = getPrefix(cm);
|
137
|
+
if (prefix < 0) { dir = -dir; prefix = -prefix; }
|
138
|
+
for (var i = 0; i < prefix; ++i) {
|
139
|
+
var newPos = by(cm, pos, dir);
|
140
|
+
if (posEq(newPos, pos)) break;
|
141
|
+
pos = newPos;
|
142
|
+
}
|
143
|
+
return pos;
|
144
|
+
}
|
145
|
+
|
146
|
+
function move(by, dir) {
|
147
|
+
var f = function(cm) {
|
148
|
+
cm.extendSelection(findEnd(cm, cm.getCursor(), by, dir));
|
149
|
+
};
|
150
|
+
f.motion = true;
|
151
|
+
return f;
|
152
|
+
}
|
153
|
+
|
154
|
+
function killTo(cm, by, dir) {
|
155
|
+
var selections = cm.listSelections(), cursor;
|
156
|
+
var i = selections.length;
|
157
|
+
while (i--) {
|
158
|
+
cursor = selections[i].head;
|
159
|
+
kill(cm, cursor, findEnd(cm, cursor, by, dir), true);
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
function killRegion(cm) {
|
164
|
+
if (cm.somethingSelected()) {
|
165
|
+
var selections = cm.listSelections(), selection;
|
166
|
+
var i = selections.length;
|
167
|
+
while (i--) {
|
168
|
+
selection = selections[i];
|
169
|
+
kill(cm, selection.anchor, selection.head);
|
170
|
+
}
|
171
|
+
return true;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
function addPrefix(cm, digit) {
|
176
|
+
if (cm.state.emacsPrefix) {
|
177
|
+
if (digit != "-") cm.state.emacsPrefix += digit;
|
178
|
+
return;
|
179
|
+
}
|
180
|
+
// Not active yet
|
181
|
+
cm.state.emacsPrefix = digit;
|
182
|
+
cm.on("keyHandled", maybeClearPrefix);
|
183
|
+
cm.on("inputRead", maybeDuplicateInput);
|
184
|
+
}
|
185
|
+
|
186
|
+
var prefixPreservingKeys = {"Alt-G": true, "Ctrl-X": true, "Ctrl-Q": true, "Ctrl-U": true};
|
187
|
+
|
188
|
+
function maybeClearPrefix(cm, arg) {
|
189
|
+
if (!cm.state.emacsPrefixMap && !prefixPreservingKeys.hasOwnProperty(arg))
|
190
|
+
clearPrefix(cm);
|
191
|
+
}
|
192
|
+
|
193
|
+
function clearPrefix(cm) {
|
194
|
+
cm.state.emacsPrefix = null;
|
195
|
+
cm.off("keyHandled", maybeClearPrefix);
|
196
|
+
cm.off("inputRead", maybeDuplicateInput);
|
197
|
+
}
|
198
|
+
|
199
|
+
function maybeDuplicateInput(cm, event) {
|
200
|
+
var dup = getPrefix(cm);
|
201
|
+
if (dup > 1 && event.origin == "+input") {
|
202
|
+
var one = event.text.join("\n"), txt = "";
|
203
|
+
for (var i = 1; i < dup; ++i) txt += one;
|
204
|
+
cm.replaceSelection(txt);
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
function addPrefixMap(cm) {
|
209
|
+
cm.state.emacsPrefixMap = true;
|
210
|
+
cm.addKeyMap(prefixMap);
|
211
|
+
cm.on("keyHandled", maybeRemovePrefixMap);
|
212
|
+
cm.on("inputRead", maybeRemovePrefixMap);
|
213
|
+
}
|
214
|
+
|
215
|
+
function maybeRemovePrefixMap(cm, arg) {
|
216
|
+
if (typeof arg == "string" && (/^\d$/.test(arg) || arg == "Ctrl-U")) return;
|
217
|
+
cm.removeKeyMap(prefixMap);
|
218
|
+
cm.state.emacsPrefixMap = false;
|
219
|
+
cm.off("keyHandled", maybeRemovePrefixMap);
|
220
|
+
cm.off("inputRead", maybeRemovePrefixMap);
|
221
|
+
}
|
222
|
+
|
223
|
+
// Utilities
|
224
|
+
|
225
|
+
function setMark(cm) {
|
226
|
+
cm.setCursor(cm.getCursor());
|
227
|
+
cm.setExtending(!cm.getExtending());
|
228
|
+
cm.on("change", function() { cm.setExtending(false); });
|
229
|
+
}
|
230
|
+
|
231
|
+
function clearMark(cm) {
|
232
|
+
cm.setExtending(false);
|
233
|
+
cm.setCursor(cm.getCursor());
|
234
|
+
}
|
235
|
+
|
236
|
+
function getInput(cm, msg, f) {
|
237
|
+
if (cm.openDialog)
|
238
|
+
cm.openDialog(msg + ": <input type=\"text\" style=\"width: 10em\"/>", f, {bottom: true});
|
239
|
+
else
|
240
|
+
f(prompt(msg, ""));
|
241
|
+
}
|
242
|
+
|
243
|
+
function operateOnWord(cm, op) {
|
244
|
+
var start = cm.getCursor(), end = cm.findPosH(start, 1, "word");
|
245
|
+
cm.replaceRange(op(cm.getRange(start, end)), start, end);
|
246
|
+
cm.setCursor(end);
|
247
|
+
}
|
248
|
+
|
249
|
+
function toEnclosingExpr(cm) {
|
250
|
+
var pos = cm.getCursor(), line = pos.line, ch = pos.ch;
|
251
|
+
var stack = [];
|
252
|
+
while (line >= cm.firstLine()) {
|
253
|
+
var text = cm.getLine(line);
|
254
|
+
for (var i = ch == null ? text.length : ch; i > 0;) {
|
255
|
+
var ch = text.charAt(--i);
|
256
|
+
if (ch == ")")
|
257
|
+
stack.push("(");
|
258
|
+
else if (ch == "]")
|
259
|
+
stack.push("[");
|
260
|
+
else if (ch == "}")
|
261
|
+
stack.push("{");
|
262
|
+
else if (/[\(\{\[]/.test(ch) && (!stack.length || stack.pop() != ch))
|
263
|
+
return cm.extendSelection(Pos(line, i));
|
264
|
+
}
|
265
|
+
--line; ch = null;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
function quit(cm) {
|
270
|
+
cm.execCommand("clearSearch");
|
271
|
+
clearMark(cm);
|
272
|
+
}
|
273
|
+
|
274
|
+
// Actual keymap
|
275
|
+
|
276
|
+
var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({
|
277
|
+
"Ctrl-W": function(cm) {kill(cm, cm.getCursor("start"), cm.getCursor("end"));},
|
278
|
+
"Ctrl-K": repeated(function(cm) {
|
279
|
+
var start = cm.getCursor(), end = cm.clipPos(Pos(start.line));
|
280
|
+
var text = cm.getRange(start, end);
|
281
|
+
if (!/\S/.test(text)) {
|
282
|
+
text += "\n";
|
283
|
+
end = Pos(start.line + 1, 0);
|
284
|
+
}
|
285
|
+
kill(cm, start, end, true, text);
|
286
|
+
}),
|
287
|
+
"Alt-W": function(cm) {
|
288
|
+
addToRing(cm.getSelection());
|
289
|
+
clearMark(cm);
|
290
|
+
},
|
291
|
+
"Ctrl-Y": function(cm) {
|
292
|
+
var start = cm.getCursor();
|
293
|
+
cm.replaceRange(getFromRing(getPrefix(cm)), start, start, "paste");
|
294
|
+
cm.setSelection(start, cm.getCursor());
|
295
|
+
},
|
296
|
+
"Alt-Y": function(cm) {cm.replaceSelection(popFromRing(), "around", "paste");},
|
297
|
+
|
298
|
+
"Ctrl-Space": setMark, "Ctrl-Shift-2": setMark,
|
299
|
+
|
300
|
+
"Ctrl-F": move(byChar, 1), "Ctrl-B": move(byChar, -1),
|
301
|
+
"Right": move(byChar, 1), "Left": move(byChar, -1),
|
302
|
+
"Ctrl-D": function(cm) { killTo(cm, byChar, 1); },
|
303
|
+
"Delete": function(cm) { killRegion(cm) || killTo(cm, byChar, 1); },
|
304
|
+
"Ctrl-H": function(cm) { killTo(cm, byChar, -1); },
|
305
|
+
"Backspace": function(cm) { killRegion(cm) || killTo(cm, byChar, -1); },
|
306
|
+
|
307
|
+
"Alt-F": move(byWord, 1), "Alt-B": move(byWord, -1),
|
308
|
+
"Alt-D": function(cm) { killTo(cm, byWord, 1); },
|
309
|
+
"Alt-Backspace": function(cm) { killTo(cm, byWord, -1); },
|
310
|
+
|
311
|
+
"Ctrl-N": move(byLine, 1), "Ctrl-P": move(byLine, -1),
|
312
|
+
"Down": move(byLine, 1), "Up": move(byLine, -1),
|
313
|
+
"Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
|
314
|
+
"End": "goLineEnd", "Home": "goLineStart",
|
315
|
+
|
316
|
+
"Alt-V": move(byPage, -1), "Ctrl-V": move(byPage, 1),
|
317
|
+
"PageUp": move(byPage, -1), "PageDown": move(byPage, 1),
|
318
|
+
|
319
|
+
"Ctrl-Up": move(byParagraph, -1), "Ctrl-Down": move(byParagraph, 1),
|
320
|
+
|
321
|
+
"Alt-A": move(bySentence, -1), "Alt-E": move(bySentence, 1),
|
322
|
+
"Alt-K": function(cm) { killTo(cm, bySentence, 1); },
|
323
|
+
|
324
|
+
"Ctrl-Alt-K": function(cm) { killTo(cm, byExpr, 1); },
|
325
|
+
"Ctrl-Alt-Backspace": function(cm) { killTo(cm, byExpr, -1); },
|
326
|
+
"Ctrl-Alt-F": move(byExpr, 1), "Ctrl-Alt-B": move(byExpr, -1),
|
327
|
+
|
328
|
+
"Shift-Ctrl-Alt-2": function(cm) {
|
329
|
+
var cursor = cm.getCursor();
|
330
|
+
cm.setSelection(findEnd(cm, cursor, byExpr, 1), cursor);
|
331
|
+
},
|
332
|
+
"Ctrl-Alt-T": function(cm) {
|
333
|
+
var leftStart = byExpr(cm, cm.getCursor(), -1), leftEnd = byExpr(cm, leftStart, 1);
|
334
|
+
var rightEnd = byExpr(cm, leftEnd, 1), rightStart = byExpr(cm, rightEnd, -1);
|
335
|
+
cm.replaceRange(cm.getRange(rightStart, rightEnd) + cm.getRange(leftEnd, rightStart) +
|
336
|
+
cm.getRange(leftStart, leftEnd), leftStart, rightEnd);
|
337
|
+
},
|
338
|
+
"Ctrl-Alt-U": repeated(toEnclosingExpr),
|
339
|
+
|
340
|
+
"Alt-Space": function(cm) {
|
341
|
+
var pos = cm.getCursor(), from = pos.ch, to = pos.ch, text = cm.getLine(pos.line);
|
342
|
+
while (from && /\s/.test(text.charAt(from - 1))) --from;
|
343
|
+
while (to < text.length && /\s/.test(text.charAt(to))) ++to;
|
344
|
+
cm.replaceRange(" ", Pos(pos.line, from), Pos(pos.line, to));
|
345
|
+
},
|
346
|
+
"Ctrl-O": repeated(function(cm) { cm.replaceSelection("\n", "start"); }),
|
347
|
+
"Ctrl-T": repeated(function(cm) {
|
348
|
+
cm.execCommand("transposeChars");
|
349
|
+
}),
|
350
|
+
|
351
|
+
"Alt-C": repeated(function(cm) {
|
352
|
+
operateOnWord(cm, function(w) {
|
353
|
+
var letter = w.search(/\w/);
|
354
|
+
if (letter == -1) return w;
|
355
|
+
return w.slice(0, letter) + w.charAt(letter).toUpperCase() + w.slice(letter + 1).toLowerCase();
|
356
|
+
});
|
357
|
+
}),
|
358
|
+
"Alt-U": repeated(function(cm) {
|
359
|
+
operateOnWord(cm, function(w) { return w.toUpperCase(); });
|
360
|
+
}),
|
361
|
+
"Alt-L": repeated(function(cm) {
|
362
|
+
operateOnWord(cm, function(w) { return w.toLowerCase(); });
|
363
|
+
}),
|
364
|
+
|
365
|
+
"Alt-;": "toggleComment",
|
366
|
+
|
367
|
+
"Ctrl-/": repeated("undo"), "Shift-Ctrl--": repeated("undo"),
|
368
|
+
"Ctrl-Z": repeated("undo"), "Cmd-Z": repeated("undo"),
|
369
|
+
"Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",
|
370
|
+
"Ctrl-S": "findNext", "Ctrl-R": "findPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",
|
371
|
+
"Alt-/": "autocomplete",
|
372
|
+
"Ctrl-J": "newlineAndIndent", "Enter": false, "Tab": "indentAuto",
|
373
|
+
|
374
|
+
"Alt-G G": function(cm) {
|
375
|
+
var prefix = getPrefix(cm, true);
|
376
|
+
if (prefix != null && prefix > 0) return cm.setCursor(prefix - 1);
|
377
|
+
|
378
|
+
getInput(cm, "Goto line", function(str) {
|
379
|
+
var num;
|
380
|
+
if (str && !isNaN(num = Number(str)) && num == num|0 && num > 0)
|
381
|
+
cm.setCursor(num - 1);
|
382
|
+
});
|
383
|
+
},
|
384
|
+
|
385
|
+
"Ctrl-X Tab": function(cm) {
|
386
|
+
cm.indentSelection(getPrefix(cm, true) || cm.getOption("indentUnit"));
|
387
|
+
},
|
388
|
+
"Ctrl-X Ctrl-X": function(cm) {
|
389
|
+
cm.setSelection(cm.getCursor("head"), cm.getCursor("anchor"));
|
390
|
+
},
|
391
|
+
"Ctrl-X Ctrl-S": "save",
|
392
|
+
"Ctrl-X Ctrl-W": "save",
|
393
|
+
"Ctrl-X S": "saveAll",
|
394
|
+
"Ctrl-X F": "open",
|
395
|
+
"Ctrl-X U": repeated("undo"),
|
396
|
+
"Ctrl-X K": "close",
|
397
|
+
"Ctrl-X Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), true); },
|
398
|
+
|
399
|
+
"Ctrl-Q Tab": repeated("insertTab"),
|
400
|
+
"Ctrl-U": addPrefixMap
|
401
|
+
});
|
402
|
+
|
403
|
+
var prefixMap = {"Ctrl-G": clearPrefix};
|
404
|
+
function regPrefix(d) {
|
405
|
+
prefixMap[d] = function(cm) { addPrefix(cm, d); };
|
406
|
+
keyMap["Ctrl-" + d] = function(cm) { addPrefix(cm, d); };
|
407
|
+
prefixPreservingKeys["Ctrl-" + d] = true;
|
408
|
+
}
|
409
|
+
for (var i = 0; i < 10; ++i) regPrefix(String(i));
|
410
|
+
regPrefix("-");
|
411
|
+
});
|