stackprofiler 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/README.md +1 -1
- data/config.ru +3 -2
- data/lib/stackprofiler.rb +0 -1
- data/lib/stackprofiler/filters/build_tree.rb +3 -4
- data/lib/stackprofiler/filters/gem_removal.rb +3 -0
- data/lib/stackprofiler/web_ui.rb +34 -11
- data/lib/stackprofiler/web_ui/public/css/stackprofiler.css +77 -0
- data/lib/stackprofiler/web_ui/public/js/stackprofiler.js +129 -58
- data/lib/stackprofiler/web_ui/public/vendor/ace/ace.js +18298 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-beautify.js +334 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-chromevox.js +541 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-elastic_tabstops_lite.js +275 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-emmet.js +1190 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-error_marker.js +6 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-keybinding_menu.js +170 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-language_tools.js +1934 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-linking.js +52 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-modelist.js +187 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-old_ie.js +494 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-searchbox.js +409 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-settings_menu.js +637 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-spellcheck.js +71 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-split.js +246 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-static_highlight.js +154 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-statusbar.js +51 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-textarea.js +632 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-themelist.js +58 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/ext-whitespace.js +181 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/keybinding-emacs.js +1182 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/keybinding-vim.js +5320 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-haml.js +525 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-html.js +2427 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-html_ruby.js +2955 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-javascript.js +1025 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-json.js +668 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-ruby.js +839 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-xml.js +637 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/mode-yaml.js +256 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/theme-xcode.js +89 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-coffee.js +7599 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-css.js +8682 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-html.js +11527 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-javascript.js +10429 -0
- data/lib/stackprofiler/web_ui/public/vendor/ace/worker-json.js +2319 -0
- data/lib/stackprofiler/web_ui/views/index.erb +1 -1
- data/lib/stackprofiler/web_ui/views/layout.erb +2 -55
- data/stackprofiler.gemspec +2 -4
- metadata +42 -19
- data/lib/stackprofiler/web_ui/views/code.erb +0 -17
@@ -0,0 +1,52 @@
|
|
1
|
+
ace.define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) {
|
2
|
+
|
3
|
+
var Editor = require("ace/editor").Editor;
|
4
|
+
|
5
|
+
require("../config").defineOptions(Editor.prototype, "editor", {
|
6
|
+
enableLinking: {
|
7
|
+
set: function(val) {
|
8
|
+
if (val) {
|
9
|
+
this.on("click", onClick);
|
10
|
+
this.on("mousemove", onMouseMove);
|
11
|
+
} else {
|
12
|
+
this.off("click", onClick);
|
13
|
+
this.off("mousemove", onMouseMove);
|
14
|
+
}
|
15
|
+
},
|
16
|
+
value: false
|
17
|
+
}
|
18
|
+
})
|
19
|
+
|
20
|
+
function onMouseMove(e) {
|
21
|
+
var editor = e.editor;
|
22
|
+
var ctrl = e.getAccelKey();
|
23
|
+
|
24
|
+
if (ctrl) {
|
25
|
+
var editor = e.editor;
|
26
|
+
var docPos = e.getDocumentPosition();
|
27
|
+
var session = editor.session;
|
28
|
+
var token = session.getTokenAt(docPos.row, docPos.column);
|
29
|
+
|
30
|
+
editor._emit("linkHover", {position: docPos, token: token});
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
function onClick(e) {
|
35
|
+
var ctrl = e.getAccelKey();
|
36
|
+
var button = e.getButton();
|
37
|
+
|
38
|
+
if (button == 0 && ctrl) {
|
39
|
+
var editor = e.editor;
|
40
|
+
var docPos = e.getDocumentPosition();
|
41
|
+
var session = editor.session;
|
42
|
+
var token = session.getTokenAt(docPos.row, docPos.column);
|
43
|
+
|
44
|
+
editor._emit("linkClick", {position: docPos, token: token});
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
});
|
49
|
+
(function() {
|
50
|
+
ace.require(["ace/ext/linking"], function() {});
|
51
|
+
})();
|
52
|
+
|
@@ -0,0 +1,187 @@
|
|
1
|
+
ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var modes = [];
|
5
|
+
function getModeForPath(path) {
|
6
|
+
var mode = modesByName.text;
|
7
|
+
var fileName = path.split(/[\/\\]/).pop();
|
8
|
+
for (var i = 0; i < modes.length; i++) {
|
9
|
+
if (modes[i].supportsFile(fileName)) {
|
10
|
+
mode = modes[i];
|
11
|
+
break;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
return mode;
|
15
|
+
}
|
16
|
+
|
17
|
+
var Mode = function(name, caption, extensions) {
|
18
|
+
this.name = name;
|
19
|
+
this.caption = caption;
|
20
|
+
this.mode = "ace/mode/" + name;
|
21
|
+
this.extensions = extensions;
|
22
|
+
if (/\^/.test(extensions)) {
|
23
|
+
var re = extensions.replace(/\|(\^)?/g, function(a, b){
|
24
|
+
return "$|" + (b ? "^" : "^.*\\.");
|
25
|
+
}) + "$";
|
26
|
+
} else {
|
27
|
+
var re = "^.*\\.(" + extensions + ")$";
|
28
|
+
}
|
29
|
+
|
30
|
+
this.extRe = new RegExp(re, "gi");
|
31
|
+
};
|
32
|
+
|
33
|
+
Mode.prototype.supportsFile = function(filename) {
|
34
|
+
return filename.match(this.extRe);
|
35
|
+
};
|
36
|
+
var supportedModes = {
|
37
|
+
ABAP: ["abap"],
|
38
|
+
ActionScript:["as"],
|
39
|
+
ADA: ["ada|adb"],
|
40
|
+
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
|
41
|
+
AsciiDoc: ["asciidoc"],
|
42
|
+
Assembly_x86:["asm"],
|
43
|
+
AutoHotKey: ["ahk"],
|
44
|
+
BatchFile: ["bat|cmd"],
|
45
|
+
C9Search: ["c9search_results"],
|
46
|
+
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
|
47
|
+
Cirru: ["cirru|cr"],
|
48
|
+
Clojure: ["clj|cljs"],
|
49
|
+
Cobol: ["CBL|COB"],
|
50
|
+
coffee: ["coffee|cf|cson|^Cakefile"],
|
51
|
+
ColdFusion: ["cfm"],
|
52
|
+
CSharp: ["cs"],
|
53
|
+
CSS: ["css"],
|
54
|
+
Curly: ["curly"],
|
55
|
+
D: ["d|di"],
|
56
|
+
Dart: ["dart"],
|
57
|
+
Diff: ["diff|patch"],
|
58
|
+
Dockerfile: ["^Dockerfile"],
|
59
|
+
Dot: ["dot"],
|
60
|
+
Dummy: ["dummy"],
|
61
|
+
DummySyntax: ["dummy"],
|
62
|
+
Eiffel: ["e"],
|
63
|
+
EJS: ["ejs"],
|
64
|
+
Elixir: ["ex|exs"],
|
65
|
+
Elm: ["elm"],
|
66
|
+
Erlang: ["erl|hrl"],
|
67
|
+
Forth: ["frt|fs|ldr"],
|
68
|
+
FTL: ["ftl"],
|
69
|
+
Gcode: ["gcode"],
|
70
|
+
Gherkin: ["feature"],
|
71
|
+
Gitignore: ["^.gitignore"],
|
72
|
+
Glsl: ["glsl|frag|vert"],
|
73
|
+
golang: ["go"],
|
74
|
+
Groovy: ["groovy"],
|
75
|
+
HAML: ["haml"],
|
76
|
+
Handlebars: ["hbs|handlebars|tpl|mustache"],
|
77
|
+
Haskell: ["hs"],
|
78
|
+
haXe: ["hx"],
|
79
|
+
HTML: ["html|htm|xhtml"],
|
80
|
+
HTML_Ruby: ["erb|rhtml|html.erb"],
|
81
|
+
INI: ["ini|conf|cfg|prefs"],
|
82
|
+
Io: ["io"],
|
83
|
+
Jack: ["jack"],
|
84
|
+
Jade: ["jade"],
|
85
|
+
Java: ["java"],
|
86
|
+
JavaScript: ["js|jsm"],
|
87
|
+
JSON: ["json"],
|
88
|
+
JSONiq: ["jq"],
|
89
|
+
JSP: ["jsp"],
|
90
|
+
JSX: ["jsx"],
|
91
|
+
Julia: ["jl"],
|
92
|
+
LaTeX: ["tex|latex|ltx|bib"],
|
93
|
+
LESS: ["less"],
|
94
|
+
Liquid: ["liquid"],
|
95
|
+
Lisp: ["lisp"],
|
96
|
+
LiveScript: ["ls"],
|
97
|
+
LogiQL: ["logic|lql"],
|
98
|
+
LSL: ["lsl"],
|
99
|
+
Lua: ["lua"],
|
100
|
+
LuaPage: ["lp"],
|
101
|
+
Lucene: ["lucene"],
|
102
|
+
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
|
103
|
+
Markdown: ["md|markdown"],
|
104
|
+
Mask: ["mask"],
|
105
|
+
MATLAB: ["matlab"],
|
106
|
+
MEL: ["mel"],
|
107
|
+
MUSHCode: ["mc|mush"],
|
108
|
+
MySQL: ["mysql"],
|
109
|
+
Nix: ["nix"],
|
110
|
+
ObjectiveC: ["m|mm"],
|
111
|
+
OCaml: ["ml|mli"],
|
112
|
+
Pascal: ["pas|p"],
|
113
|
+
Perl: ["pl|pm"],
|
114
|
+
pgSQL: ["pgsql"],
|
115
|
+
PHP: ["php|phtml"],
|
116
|
+
Powershell: ["ps1"],
|
117
|
+
Praat: ["praat|praatscript|psc|proc"],
|
118
|
+
Prolog: ["plg|prolog"],
|
119
|
+
Properties: ["properties"],
|
120
|
+
Protobuf: ["proto"],
|
121
|
+
Python: ["py"],
|
122
|
+
R: ["r"],
|
123
|
+
RDoc: ["Rd"],
|
124
|
+
RHTML: ["Rhtml"],
|
125
|
+
Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
|
126
|
+
Rust: ["rs"],
|
127
|
+
SASS: ["sass"],
|
128
|
+
SCAD: ["scad"],
|
129
|
+
Scala: ["scala"],
|
130
|
+
Scheme: ["scm|rkt"],
|
131
|
+
SCSS: ["scss"],
|
132
|
+
SH: ["sh|bash|^.bashrc"],
|
133
|
+
SJS: ["sjs"],
|
134
|
+
Smarty: ["smarty|tpl"],
|
135
|
+
snippets: ["snippets"],
|
136
|
+
Soy_Template:["soy"],
|
137
|
+
Space: ["space"],
|
138
|
+
SQL: ["sql"],
|
139
|
+
Stylus: ["styl|stylus"],
|
140
|
+
SVG: ["svg"],
|
141
|
+
Tcl: ["tcl"],
|
142
|
+
Tex: ["tex"],
|
143
|
+
Text: ["txt"],
|
144
|
+
Textile: ["textile"],
|
145
|
+
Toml: ["toml"],
|
146
|
+
Twig: ["twig"],
|
147
|
+
Typescript: ["ts|typescript|str"],
|
148
|
+
Vala: ["vala"],
|
149
|
+
VBScript: ["vbs|vb"],
|
150
|
+
Velocity: ["vm"],
|
151
|
+
Verilog: ["v|vh|sv|svh"],
|
152
|
+
VHDL: ["vhd|vhdl"],
|
153
|
+
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
|
154
|
+
XQuery: ["xq"],
|
155
|
+
YAML: ["yaml|yml"]
|
156
|
+
};
|
157
|
+
|
158
|
+
var nameOverrides = {
|
159
|
+
ObjectiveC: "Objective-C",
|
160
|
+
CSharp: "C#",
|
161
|
+
golang: "Go",
|
162
|
+
C_Cpp: "C and C++",
|
163
|
+
coffee: "CoffeeScript",
|
164
|
+
HTML_Ruby: "HTML (Ruby)",
|
165
|
+
FTL: "FreeMarker"
|
166
|
+
};
|
167
|
+
var modesByName = {};
|
168
|
+
for (var name in supportedModes) {
|
169
|
+
var data = supportedModes[name];
|
170
|
+
var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
|
171
|
+
var filename = name.toLowerCase();
|
172
|
+
var mode = new Mode(filename, displayName, data[0]);
|
173
|
+
modesByName[filename] = mode;
|
174
|
+
modes.push(mode);
|
175
|
+
}
|
176
|
+
|
177
|
+
module.exports = {
|
178
|
+
getModeForPath: getModeForPath,
|
179
|
+
modes: modes,
|
180
|
+
modesByName: modesByName
|
181
|
+
};
|
182
|
+
|
183
|
+
});
|
184
|
+
(function() {
|
185
|
+
ace.require(["ace/ext/modelist"], function() {});
|
186
|
+
})();
|
187
|
+
|
@@ -0,0 +1,494 @@
|
|
1
|
+
ace.define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module) {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var dom = require("../lib/dom");
|
5
|
+
var lang = require("../lib/lang");
|
6
|
+
var event = require("../lib/event");
|
7
|
+
var searchboxCss = "\
|
8
|
+
.ace_search {\
|
9
|
+
background-color: #ddd;\
|
10
|
+
border: 1px solid #cbcbcb;\
|
11
|
+
border-top: 0 none;\
|
12
|
+
max-width: 325px;\
|
13
|
+
overflow: hidden;\
|
14
|
+
margin: 0;\
|
15
|
+
padding: 4px;\
|
16
|
+
padding-right: 6px;\
|
17
|
+
padding-bottom: 0;\
|
18
|
+
position: absolute;\
|
19
|
+
top: 0px;\
|
20
|
+
z-index: 99;\
|
21
|
+
white-space: normal;\
|
22
|
+
}\
|
23
|
+
.ace_search.left {\
|
24
|
+
border-left: 0 none;\
|
25
|
+
border-radius: 0px 0px 5px 0px;\
|
26
|
+
left: 0;\
|
27
|
+
}\
|
28
|
+
.ace_search.right {\
|
29
|
+
border-radius: 0px 0px 0px 5px;\
|
30
|
+
border-right: 0 none;\
|
31
|
+
right: 0;\
|
32
|
+
}\
|
33
|
+
.ace_search_form, .ace_replace_form {\
|
34
|
+
border-radius: 3px;\
|
35
|
+
border: 1px solid #cbcbcb;\
|
36
|
+
float: left;\
|
37
|
+
margin-bottom: 4px;\
|
38
|
+
overflow: hidden;\
|
39
|
+
}\
|
40
|
+
.ace_search_form.ace_nomatch {\
|
41
|
+
outline: 1px solid red;\
|
42
|
+
}\
|
43
|
+
.ace_search_field {\
|
44
|
+
background-color: white;\
|
45
|
+
border-right: 1px solid #cbcbcb;\
|
46
|
+
border: 0 none;\
|
47
|
+
-webkit-box-sizing: border-box;\
|
48
|
+
-moz-box-sizing: border-box;\
|
49
|
+
box-sizing: border-box;\
|
50
|
+
float: left;\
|
51
|
+
height: 22px;\
|
52
|
+
outline: 0;\
|
53
|
+
padding: 0 7px;\
|
54
|
+
width: 214px;\
|
55
|
+
margin: 0;\
|
56
|
+
}\
|
57
|
+
.ace_searchbtn,\
|
58
|
+
.ace_replacebtn {\
|
59
|
+
background: #fff;\
|
60
|
+
border: 0 none;\
|
61
|
+
border-left: 1px solid #dcdcdc;\
|
62
|
+
cursor: pointer;\
|
63
|
+
float: left;\
|
64
|
+
height: 22px;\
|
65
|
+
margin: 0;\
|
66
|
+
padding: 0;\
|
67
|
+
position: relative;\
|
68
|
+
}\
|
69
|
+
.ace_searchbtn:last-child,\
|
70
|
+
.ace_replacebtn:last-child {\
|
71
|
+
border-top-right-radius: 3px;\
|
72
|
+
border-bottom-right-radius: 3px;\
|
73
|
+
}\
|
74
|
+
.ace_searchbtn:disabled {\
|
75
|
+
background: none;\
|
76
|
+
cursor: default;\
|
77
|
+
}\
|
78
|
+
.ace_searchbtn {\
|
79
|
+
background-position: 50% 50%;\
|
80
|
+
background-repeat: no-repeat;\
|
81
|
+
width: 27px;\
|
82
|
+
}\
|
83
|
+
.ace_searchbtn.prev {\
|
84
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADFJREFUeNpiSU1NZUAC/6E0I0yACYskCpsJiySKIiY0SUZk40FyTEgCjGgKwTRAgAEAQJUIPCE+qfkAAAAASUVORK5CYII=); \
|
85
|
+
}\
|
86
|
+
.ace_searchbtn.next {\
|
87
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNpiTE1NZQCC/0DMyIAKwGJMUAYDEo3M/s+EpvM/mkKwCQxYjIeLMaELoLMBAgwAU7UJObTKsvAAAAAASUVORK5CYII=); \
|
88
|
+
}\
|
89
|
+
.ace_searchbtn_close {\
|
90
|
+
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\
|
91
|
+
border-radius: 50%;\
|
92
|
+
border: 0 none;\
|
93
|
+
color: #656565;\
|
94
|
+
cursor: pointer;\
|
95
|
+
float: right;\
|
96
|
+
font: 16px/16px Arial;\
|
97
|
+
height: 14px;\
|
98
|
+
margin: 5px 1px 9px 5px;\
|
99
|
+
padding: 0;\
|
100
|
+
text-align: center;\
|
101
|
+
width: 14px;\
|
102
|
+
}\
|
103
|
+
.ace_searchbtn_close:hover {\
|
104
|
+
background-color: #656565;\
|
105
|
+
background-position: 50% 100%;\
|
106
|
+
color: white;\
|
107
|
+
}\
|
108
|
+
.ace_replacebtn.prev {\
|
109
|
+
width: 54px\
|
110
|
+
}\
|
111
|
+
.ace_replacebtn.next {\
|
112
|
+
width: 27px\
|
113
|
+
}\
|
114
|
+
.ace_button {\
|
115
|
+
margin-left: 2px;\
|
116
|
+
cursor: pointer;\
|
117
|
+
-webkit-user-select: none;\
|
118
|
+
-moz-user-select: none;\
|
119
|
+
-o-user-select: none;\
|
120
|
+
-ms-user-select: none;\
|
121
|
+
user-select: none;\
|
122
|
+
overflow: hidden;\
|
123
|
+
opacity: 0.7;\
|
124
|
+
border: 1px solid rgba(100,100,100,0.23);\
|
125
|
+
padding: 1px;\
|
126
|
+
-moz-box-sizing: border-box;\
|
127
|
+
box-sizing: border-box;\
|
128
|
+
color: black;\
|
129
|
+
}\
|
130
|
+
.ace_button:hover {\
|
131
|
+
background-color: #eee;\
|
132
|
+
opacity:1;\
|
133
|
+
}\
|
134
|
+
.ace_button:active {\
|
135
|
+
background-color: #ddd;\
|
136
|
+
}\
|
137
|
+
.ace_button.checked {\
|
138
|
+
border-color: #3399ff;\
|
139
|
+
opacity:1;\
|
140
|
+
}\
|
141
|
+
.ace_search_options{\
|
142
|
+
margin-bottom: 3px;\
|
143
|
+
text-align: right;\
|
144
|
+
-webkit-user-select: none;\
|
145
|
+
-moz-user-select: none;\
|
146
|
+
-o-user-select: none;\
|
147
|
+
-ms-user-select: none;\
|
148
|
+
user-select: none;\
|
149
|
+
}";
|
150
|
+
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
151
|
+
var keyUtil = require("../lib/keys");
|
152
|
+
|
153
|
+
dom.importCssString(searchboxCss, "ace_searchbox");
|
154
|
+
|
155
|
+
var html = '<div class="ace_search right">\
|
156
|
+
<button type="button" action="hide" class="ace_searchbtn_close"></button>\
|
157
|
+
<div class="ace_search_form">\
|
158
|
+
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\
|
159
|
+
<button type="button" action="findNext" class="ace_searchbtn next"></button>\
|
160
|
+
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\
|
161
|
+
<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>\
|
162
|
+
</div>\
|
163
|
+
<div class="ace_replace_form">\
|
164
|
+
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\
|
165
|
+
<button type="button" action="replaceAndFindNext" class="ace_replacebtn">Replace</button>\
|
166
|
+
<button type="button" action="replaceAll" class="ace_replacebtn">All</button>\
|
167
|
+
</div>\
|
168
|
+
<div class="ace_search_options">\
|
169
|
+
<span action="toggleRegexpMode" class="ace_button" title="RegExp Search">.*</span>\
|
170
|
+
<span action="toggleCaseSensitive" class="ace_button" title="CaseSensitive Search">Aa</span>\
|
171
|
+
<span action="toggleWholeWords" class="ace_button" title="Whole Word Search">\\b</span>\
|
172
|
+
</div>\
|
173
|
+
</div>'.replace(/>\s+/g, ">");
|
174
|
+
|
175
|
+
var SearchBox = function(editor, range, showReplaceForm) {
|
176
|
+
var div = dom.createElement("div");
|
177
|
+
div.innerHTML = html;
|
178
|
+
this.element = div.firstChild;
|
179
|
+
|
180
|
+
this.$init();
|
181
|
+
this.setEditor(editor);
|
182
|
+
};
|
183
|
+
|
184
|
+
(function() {
|
185
|
+
this.setEditor = function(editor) {
|
186
|
+
editor.searchBox = this;
|
187
|
+
editor.container.appendChild(this.element);
|
188
|
+
this.editor = editor;
|
189
|
+
};
|
190
|
+
|
191
|
+
this.$initElements = function(sb) {
|
192
|
+
this.searchBox = sb.querySelector(".ace_search_form");
|
193
|
+
this.replaceBox = sb.querySelector(".ace_replace_form");
|
194
|
+
this.searchOptions = sb.querySelector(".ace_search_options");
|
195
|
+
this.regExpOption = sb.querySelector("[action=toggleRegexpMode]");
|
196
|
+
this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]");
|
197
|
+
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
|
198
|
+
this.searchInput = this.searchBox.querySelector(".ace_search_field");
|
199
|
+
this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
|
200
|
+
};
|
201
|
+
|
202
|
+
this.$init = function() {
|
203
|
+
var sb = this.element;
|
204
|
+
|
205
|
+
this.$initElements(sb);
|
206
|
+
|
207
|
+
var _this = this;
|
208
|
+
event.addListener(sb, "mousedown", function(e) {
|
209
|
+
setTimeout(function(){
|
210
|
+
_this.activeInput.focus();
|
211
|
+
}, 0);
|
212
|
+
event.stopPropagation(e);
|
213
|
+
});
|
214
|
+
event.addListener(sb, "click", function(e) {
|
215
|
+
var t = e.target || e.srcElement;
|
216
|
+
var action = t.getAttribute("action");
|
217
|
+
if (action && _this[action])
|
218
|
+
_this[action]();
|
219
|
+
else if (_this.$searchBarKb.commands[action])
|
220
|
+
_this.$searchBarKb.commands[action].exec(_this);
|
221
|
+
event.stopPropagation(e);
|
222
|
+
});
|
223
|
+
|
224
|
+
event.addCommandKeyListener(sb, function(e, hashId, keyCode) {
|
225
|
+
var keyString = keyUtil.keyCodeToString(keyCode);
|
226
|
+
var command = _this.$searchBarKb.findKeyCommand(hashId, keyString);
|
227
|
+
if (command && command.exec) {
|
228
|
+
command.exec(_this);
|
229
|
+
event.stopEvent(e);
|
230
|
+
}
|
231
|
+
});
|
232
|
+
|
233
|
+
this.$onChange = lang.delayedCall(function() {
|
234
|
+
_this.find(false, false);
|
235
|
+
});
|
236
|
+
|
237
|
+
event.addListener(this.searchInput, "input", function() {
|
238
|
+
_this.$onChange.schedule(20);
|
239
|
+
});
|
240
|
+
event.addListener(this.searchInput, "focus", function() {
|
241
|
+
_this.activeInput = _this.searchInput;
|
242
|
+
_this.searchInput.value && _this.highlight();
|
243
|
+
});
|
244
|
+
event.addListener(this.replaceInput, "focus", function() {
|
245
|
+
_this.activeInput = _this.replaceInput;
|
246
|
+
_this.searchInput.value && _this.highlight();
|
247
|
+
});
|
248
|
+
};
|
249
|
+
this.$closeSearchBarKb = new HashHandler([{
|
250
|
+
bindKey: "Esc",
|
251
|
+
name: "closeSearchBar",
|
252
|
+
exec: function(editor) {
|
253
|
+
editor.searchBox.hide();
|
254
|
+
}
|
255
|
+
}]);
|
256
|
+
this.$searchBarKb = new HashHandler();
|
257
|
+
this.$searchBarKb.bindKeys({
|
258
|
+
"Ctrl-f|Command-f|Ctrl-H|Command-Option-F": function(sb) {
|
259
|
+
var isReplace = sb.isReplace = !sb.isReplace;
|
260
|
+
sb.replaceBox.style.display = isReplace ? "" : "none";
|
261
|
+
sb[isReplace ? "replaceInput" : "searchInput"].focus();
|
262
|
+
},
|
263
|
+
"Ctrl-G|Command-G": function(sb) {
|
264
|
+
sb.findNext();
|
265
|
+
},
|
266
|
+
"Ctrl-Shift-G|Command-Shift-G": function(sb) {
|
267
|
+
sb.findPrev();
|
268
|
+
},
|
269
|
+
"esc": function(sb) {
|
270
|
+
setTimeout(function() { sb.hide();});
|
271
|
+
},
|
272
|
+
"Return": function(sb) {
|
273
|
+
if (sb.activeInput == sb.replaceInput)
|
274
|
+
sb.replace();
|
275
|
+
sb.findNext();
|
276
|
+
},
|
277
|
+
"Shift-Return": function(sb) {
|
278
|
+
if (sb.activeInput == sb.replaceInput)
|
279
|
+
sb.replace();
|
280
|
+
sb.findPrev();
|
281
|
+
},
|
282
|
+
"Alt-Return": function(sb) {
|
283
|
+
if (sb.activeInput == sb.replaceInput)
|
284
|
+
sb.replaceAll();
|
285
|
+
sb.findAll();
|
286
|
+
},
|
287
|
+
"Tab": function(sb) {
|
288
|
+
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
|
289
|
+
}
|
290
|
+
});
|
291
|
+
|
292
|
+
this.$searchBarKb.addCommands([{
|
293
|
+
name: "toggleRegexpMode",
|
294
|
+
bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"},
|
295
|
+
exec: function(sb) {
|
296
|
+
sb.regExpOption.checked = !sb.regExpOption.checked;
|
297
|
+
sb.$syncOptions();
|
298
|
+
}
|
299
|
+
}, {
|
300
|
+
name: "toggleCaseSensitive",
|
301
|
+
bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"},
|
302
|
+
exec: function(sb) {
|
303
|
+
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
|
304
|
+
sb.$syncOptions();
|
305
|
+
}
|
306
|
+
}, {
|
307
|
+
name: "toggleWholeWords",
|
308
|
+
bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"},
|
309
|
+
exec: function(sb) {
|
310
|
+
sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
|
311
|
+
sb.$syncOptions();
|
312
|
+
}
|
313
|
+
}]);
|
314
|
+
|
315
|
+
this.$syncOptions = function() {
|
316
|
+
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
|
317
|
+
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked);
|
318
|
+
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked);
|
319
|
+
this.find(false, false);
|
320
|
+
};
|
321
|
+
|
322
|
+
this.highlight = function(re) {
|
323
|
+
this.editor.session.highlight(re || this.editor.$search.$options.re);
|
324
|
+
this.editor.renderer.updateBackMarkers()
|
325
|
+
};
|
326
|
+
this.find = function(skipCurrent, backwards) {
|
327
|
+
var range = this.editor.find(this.searchInput.value, {
|
328
|
+
skipCurrent: skipCurrent,
|
329
|
+
backwards: backwards,
|
330
|
+
wrap: true,
|
331
|
+
regExp: this.regExpOption.checked,
|
332
|
+
caseSensitive: this.caseSensitiveOption.checked,
|
333
|
+
wholeWord: this.wholeWordOption.checked
|
334
|
+
});
|
335
|
+
var noMatch = !range && this.searchInput.value;
|
336
|
+
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
337
|
+
this.editor._emit("findSearchBox", { match: !noMatch });
|
338
|
+
this.highlight();
|
339
|
+
};
|
340
|
+
this.findNext = function() {
|
341
|
+
this.find(true, false);
|
342
|
+
};
|
343
|
+
this.findPrev = function() {
|
344
|
+
this.find(true, true);
|
345
|
+
};
|
346
|
+
this.findAll = function(){
|
347
|
+
var range = this.editor.findAll(this.searchInput.value, {
|
348
|
+
regExp: this.regExpOption.checked,
|
349
|
+
caseSensitive: this.caseSensitiveOption.checked,
|
350
|
+
wholeWord: this.wholeWordOption.checked
|
351
|
+
});
|
352
|
+
var noMatch = !range && this.searchInput.value;
|
353
|
+
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
354
|
+
this.editor._emit("findSearchBox", { match: !noMatch });
|
355
|
+
this.highlight();
|
356
|
+
this.hide();
|
357
|
+
};
|
358
|
+
this.replace = function() {
|
359
|
+
if (!this.editor.getReadOnly())
|
360
|
+
this.editor.replace(this.replaceInput.value);
|
361
|
+
};
|
362
|
+
this.replaceAndFindNext = function() {
|
363
|
+
if (!this.editor.getReadOnly()) {
|
364
|
+
this.editor.replace(this.replaceInput.value);
|
365
|
+
this.findNext()
|
366
|
+
}
|
367
|
+
};
|
368
|
+
this.replaceAll = function() {
|
369
|
+
if (!this.editor.getReadOnly())
|
370
|
+
this.editor.replaceAll(this.replaceInput.value);
|
371
|
+
};
|
372
|
+
|
373
|
+
this.hide = function() {
|
374
|
+
this.element.style.display = "none";
|
375
|
+
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
|
376
|
+
this.editor.focus();
|
377
|
+
};
|
378
|
+
this.show = function(value, isReplace) {
|
379
|
+
this.element.style.display = "";
|
380
|
+
this.replaceBox.style.display = isReplace ? "" : "none";
|
381
|
+
|
382
|
+
this.isReplace = isReplace;
|
383
|
+
|
384
|
+
if (value)
|
385
|
+
this.searchInput.value = value;
|
386
|
+
this.searchInput.focus();
|
387
|
+
this.searchInput.select();
|
388
|
+
|
389
|
+
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
|
390
|
+
};
|
391
|
+
|
392
|
+
this.isFocused = function() {
|
393
|
+
var el = document.activeElement;
|
394
|
+
return el == this.searchInput || el == this.replaceInput;
|
395
|
+
}
|
396
|
+
}).call(SearchBox.prototype);
|
397
|
+
|
398
|
+
exports.SearchBox = SearchBox;
|
399
|
+
|
400
|
+
exports.Search = function(editor, isReplace) {
|
401
|
+
var sb = editor.searchBox || new SearchBox(editor);
|
402
|
+
sb.show(editor.session.getTextRange(), isReplace);
|
403
|
+
};
|
404
|
+
|
405
|
+
});
|
406
|
+
|
407
|
+
ace.define("ace/ext/old_ie",["require","exports","module","ace/lib/useragent","ace/tokenizer","ace/ext/searchbox","ace/mode/text"], function(require, exports, module) {
|
408
|
+
"use strict";
|
409
|
+
var MAX_TOKEN_COUNT = 1000;
|
410
|
+
var useragent = require("../lib/useragent");
|
411
|
+
var TokenizerModule = require("../tokenizer");
|
412
|
+
|
413
|
+
function patch(obj, name, regexp, replacement) {
|
414
|
+
eval("obj['" + name + "']=" + obj[name].toString().replace(
|
415
|
+
regexp, replacement
|
416
|
+
));
|
417
|
+
}
|
418
|
+
|
419
|
+
if (useragent.isIE && useragent.isIE < 10 && window.top.document.compatMode === "BackCompat")
|
420
|
+
useragent.isOldIE = true;
|
421
|
+
|
422
|
+
if (typeof document != "undefined" && !document.documentElement.querySelector) {
|
423
|
+
useragent.isOldIE = true;
|
424
|
+
var qs = function(el, selector) {
|
425
|
+
if (selector.charAt(0) == ".") {
|
426
|
+
var classNeme = selector.slice(1);
|
427
|
+
} else {
|
428
|
+
var m = selector.match(/(\w+)=(\w+)/);
|
429
|
+
var attr = m && m[1];
|
430
|
+
var attrVal = m && m[2];
|
431
|
+
}
|
432
|
+
for (var i = 0; i < el.all.length; i++) {
|
433
|
+
var ch = el.all[i];
|
434
|
+
if (classNeme) {
|
435
|
+
if (ch.className.indexOf(classNeme) != -1)
|
436
|
+
return ch;
|
437
|
+
} else if (attr) {
|
438
|
+
if (ch.getAttribute(attr) == attrVal)
|
439
|
+
return ch;
|
440
|
+
}
|
441
|
+
}
|
442
|
+
};
|
443
|
+
var sb = require("./searchbox").SearchBox.prototype;
|
444
|
+
patch(
|
445
|
+
sb, "$initElements",
|
446
|
+
/([^\s=]*).querySelector\((".*?")\)/g,
|
447
|
+
"qs($1, $2)"
|
448
|
+
);
|
449
|
+
}
|
450
|
+
|
451
|
+
var compliantExecNpcg = /()??/.exec("")[1] === undefined;
|
452
|
+
if (compliantExecNpcg)
|
453
|
+
return;
|
454
|
+
var proto = TokenizerModule.Tokenizer.prototype;
|
455
|
+
TokenizerModule.Tokenizer_orig = TokenizerModule.Tokenizer;
|
456
|
+
proto.getLineTokens_orig = proto.getLineTokens;
|
457
|
+
|
458
|
+
patch(
|
459
|
+
TokenizerModule, "Tokenizer",
|
460
|
+
"ruleRegExps.push(adjustedregex);\n",
|
461
|
+
function(m) {
|
462
|
+
return m + '\
|
463
|
+
if (state[i].next && RegExp(adjustedregex).test(""))\n\
|
464
|
+
rule._qre = RegExp(adjustedregex, "g");\n\
|
465
|
+
';
|
466
|
+
}
|
467
|
+
);
|
468
|
+
TokenizerModule.Tokenizer.prototype = proto;
|
469
|
+
patch(
|
470
|
+
proto, "getLineTokens",
|
471
|
+
/if \(match\[i \+ 1\] === undefined\)\s*continue;/,
|
472
|
+
"if (!match[i + 1]) {\n\
|
473
|
+
if (value)continue;\n\
|
474
|
+
var qre = state[mapping[i]]._qre;\n\
|
475
|
+
if (!qre) continue;\n\
|
476
|
+
qre.lastIndex = lastIndex;\n\
|
477
|
+
if (!qre.exec(line) || qre.lastIndex != lastIndex)\n\
|
478
|
+
continue;\n\
|
479
|
+
}"
|
480
|
+
);
|
481
|
+
|
482
|
+
patch(
|
483
|
+
require("../mode/text").Mode.prototype, "getTokenizer",
|
484
|
+
/Tokenizer/,
|
485
|
+
"TokenizerModule.Tokenizer"
|
486
|
+
);
|
487
|
+
|
488
|
+
useragent.isOldIE = true;
|
489
|
+
|
490
|
+
});
|
491
|
+
(function() {
|
492
|
+
ace.require(["ace/ext/old_ie"], function() {});
|
493
|
+
})();
|
494
|
+
|