maglev-webtools 0.2.1 → 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. data/README.rdoc +38 -29
  2. data/bin/webtools +22 -1
  3. data/lib/web_tools/code_browser.rb +156 -0
  4. data/lib/web_tools/debugger.rb +96 -199
  5. data/lib/web_tools/info.rb +1 -3
  6. data/lib/web_tools/method_list.rb +67 -0
  7. data/lib/web_tools/middleware/debugger.rb +10 -16
  8. data/lib/web_tools/object_log.rb +24 -0
  9. data/lib/web_tools/session_list.rb +119 -0
  10. data/lib/web_tools/shared_page_cache.rb +30 -0
  11. data/lib/web_tools/stat_process.rb +24 -0
  12. data/lib/web_tools/statistics.rb +14 -0
  13. data/lib/web_tools/support/app_model.rb +66 -101
  14. data/lib/web_tools/support/code_browser.rb +88 -86
  15. data/lib/web_tools/support/debugger.rb +303 -0
  16. data/lib/web_tools/support/error_log.rb +33 -0
  17. data/lib/web_tools/support/ruby.rb +60 -121
  18. data/lib/web_tools/support/service_helper.rb +38 -10
  19. data/lib/web_tools/support/smalltalk_extensions.rb +12 -0
  20. data/lib/web_tools/tool.rb +48 -0
  21. data/lib/web_tools/ui.rb +14 -53
  22. data/lib/web_tools/version_report.rb +29 -0
  23. data/lib/web_tools/workspace.rb +77 -0
  24. data/lib/web_tools.rb +14 -4
  25. data/public/CodeBrowser.html +51 -0
  26. data/public/CodeMirror/LICENSE +19 -0
  27. data/public/CodeMirror/css/codemirror.css +67 -0
  28. data/public/CodeMirror/css/default.css +18 -0
  29. data/public/CodeMirror/js/codemirror.js +2131 -0
  30. data/public/CodeMirror/js/ruby.js +195 -0
  31. data/public/CodeMirror/js/smalltalk.js +139 -0
  32. data/public/Debugger.html +28 -0
  33. data/public/MethodList.html +20 -0
  34. data/public/ObjectLog.html +20 -0
  35. data/public/SessionList.html +31 -0
  36. data/public/SharedPageCache.html +78 -0
  37. data/public/Statistics.html +64 -0
  38. data/public/VersionReport.html +50 -0
  39. data/public/Workspace.html +39 -0
  40. data/public/css/CodeBrowser.css +24 -0
  41. data/public/css/Debugger.css +32 -0
  42. data/public/css/MethodList.css +8 -0
  43. data/public/css/ObjectLog.css +5 -0
  44. data/public/css/SessionList.css +9 -0
  45. data/public/css/Statistics.css +24 -0
  46. data/public/{stylesheets → css}/base/images/ui-anim_basic_16x16.gif +0 -0
  47. data/public/{stylesheets → css}/base/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  48. data/public/{stylesheets → css}/base/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  49. data/public/{stylesheets → css}/base/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  50. data/public/{stylesheets → css}/base/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  51. data/public/{stylesheets → css}/base/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  52. data/public/{stylesheets → css}/base/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  53. data/public/{stylesheets → css}/base/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  54. data/public/{stylesheets → css}/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  55. data/public/{stylesheets → css}/base/images/ui-icons_222222_256x240.png +0 -0
  56. data/public/{stylesheets → css}/base/images/ui-icons_2e83ff_256x240.png +0 -0
  57. data/public/{stylesheets → css}/base/images/ui-icons_454545_256x240.png +0 -0
  58. data/public/{stylesheets → css}/base/images/ui-icons_888888_256x240.png +0 -0
  59. data/public/{stylesheets → css}/base/images/ui-icons_cd0a0a_256x240.png +0 -0
  60. data/public/{stylesheets → css}/base/jquery.ui.accordion.css +0 -0
  61. data/public/{stylesheets → css}/base/jquery.ui.all.css +0 -0
  62. data/public/{stylesheets → css}/base/jquery.ui.autocomplete.css +0 -0
  63. data/public/{stylesheets → css}/base/jquery.ui.base.css +0 -0
  64. data/public/{stylesheets → css}/base/jquery.ui.button.css +0 -0
  65. data/public/{stylesheets → css}/base/jquery.ui.core.css +0 -0
  66. data/public/{stylesheets → css}/base/jquery.ui.datepicker.css +0 -0
  67. data/public/{stylesheets → css}/base/jquery.ui.dialog.css +0 -0
  68. data/public/{stylesheets → css}/base/jquery.ui.progressbar.css +0 -0
  69. data/public/{stylesheets → css}/base/jquery.ui.resizable.css +0 -0
  70. data/public/{stylesheets → css}/base/jquery.ui.selectable.css +0 -0
  71. data/public/{stylesheets → css}/base/jquery.ui.slider.css +0 -0
  72. data/public/{stylesheets → css}/base/jquery.ui.tabs.css +0 -0
  73. data/public/{stylesheets → css}/base/jquery.ui.theme.css +0 -0
  74. data/public/css/editor.css +25 -0
  75. data/public/css/jjmenu.css +33 -0
  76. data/public/css/menuitem.gif +0 -0
  77. data/public/css/more.gif +0 -0
  78. data/public/{stylesheets → css}/reset.css +1 -1
  79. data/public/css/smoothness/images/ui-anim_basic_16x16.gif +0 -0
  80. data/public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  81. data/public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  82. data/public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  83. data/public/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  84. data/public/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  85. data/public/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  86. data/public/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  87. data/public/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  88. data/public/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
  89. data/public/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  90. data/public/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
  91. data/public/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
  92. data/public/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  93. data/public/css/smoothness/jquery-ui.css +489 -0
  94. data/public/css/ui-lightness/images/ui-anim_basic_16x16.gif +0 -0
  95. data/public/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  96. data/public/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  97. data/public/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  98. data/public/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  99. data/public/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  100. data/public/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  101. data/public/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  102. data/public/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  103. data/public/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  104. data/public/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  105. data/public/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  106. data/public/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  107. data/public/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  108. data/public/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  109. data/public/css/ui-lightness/jquery-ui.css +489 -0
  110. data/public/css/webtools.css +65 -0
  111. data/public/favicon.ico +0 -0
  112. data/public/flot/API.txt +1201 -0
  113. data/public/flot/FAQ.txt +76 -0
  114. data/public/flot/LICENSE.txt +22 -0
  115. data/public/flot/Makefile +9 -0
  116. data/public/flot/NEWS.txt +508 -0
  117. data/public/flot/PLUGINS.txt +137 -0
  118. data/public/flot/README.txt +90 -0
  119. data/public/flot/examples/ajax.html +143 -0
  120. data/public/flot/examples/annotating.html +75 -0
  121. data/public/flot/examples/arrow-down.gif +0 -0
  122. data/public/flot/examples/arrow-left.gif +0 -0
  123. data/public/flot/examples/arrow-right.gif +0 -0
  124. data/public/flot/examples/arrow-up.gif +0 -0
  125. data/public/flot/examples/basic.html +38 -0
  126. data/public/flot/examples/data-eu-gdp-growth-1.json +4 -0
  127. data/public/flot/examples/data-eu-gdp-growth-2.json +4 -0
  128. data/public/flot/examples/data-eu-gdp-growth-3.json +4 -0
  129. data/public/flot/examples/data-eu-gdp-growth-4.json +4 -0
  130. data/public/flot/examples/data-eu-gdp-growth-5.json +4 -0
  131. data/public/flot/examples/data-eu-gdp-growth.json +4 -0
  132. data/public/flot/examples/data-japan-gdp-growth.json +4 -0
  133. data/public/flot/examples/data-usa-gdp-growth.json +4 -0
  134. data/public/flot/examples/graph-types.html +75 -0
  135. data/public/flot/examples/hs-2004-27-a-large_web.jpg +0 -0
  136. data/public/flot/examples/image.html +45 -0
  137. data/public/flot/examples/index.html +44 -0
  138. data/public/flot/examples/interacting-axes.html +97 -0
  139. data/public/flot/examples/interacting.html +93 -0
  140. data/public/flot/examples/layout.css +6 -0
  141. data/public/flot/examples/multiple-axes.html +60 -0
  142. data/public/flot/examples/navigate.html +118 -0
  143. data/public/flot/examples/percentiles.html +57 -0
  144. data/public/flot/examples/pie.html +756 -0
  145. data/public/flot/examples/realtime.html +83 -0
  146. data/public/flot/examples/resize.html +61 -0
  147. data/public/flot/examples/selection.html +114 -0
  148. data/public/flot/examples/setting-options.html +61 -0
  149. data/public/flot/examples/stacking.html +77 -0
  150. data/public/flot/examples/symbols.html +49 -0
  151. data/public/flot/examples/thresholding.html +54 -0
  152. data/public/flot/examples/time.html +71 -0
  153. data/public/flot/examples/tracking.html +95 -0
  154. data/public/flot/examples/turning-series.html +98 -0
  155. data/public/flot/examples/visitors.html +90 -0
  156. data/public/flot/examples/zooming.html +98 -0
  157. data/public/flot/excanvas.js +1427 -0
  158. data/public/flot/excanvas.min.js +1 -0
  159. data/public/flot/jquery.colorhelpers.js +179 -0
  160. data/public/flot/jquery.colorhelpers.min.js +1 -0
  161. data/public/flot/jquery.flot.crosshair.js +167 -0
  162. data/public/flot/jquery.flot.crosshair.min.js +1 -0
  163. data/public/flot/jquery.flot.fillbetween.js +183 -0
  164. data/public/flot/jquery.flot.fillbetween.min.js +1 -0
  165. data/public/flot/jquery.flot.image.js +238 -0
  166. data/public/flot/jquery.flot.image.min.js +1 -0
  167. data/public/flot/jquery.flot.js +2599 -0
  168. data/public/flot/jquery.flot.min.js +6 -0
  169. data/public/flot/jquery.flot.navigate.js +336 -0
  170. data/public/flot/jquery.flot.navigate.min.js +1 -0
  171. data/public/flot/jquery.flot.pie.js +750 -0
  172. data/public/flot/jquery.flot.pie.min.js +1 -0
  173. data/public/flot/jquery.flot.resize.js +60 -0
  174. data/public/flot/jquery.flot.resize.min.js +1 -0
  175. data/public/flot/jquery.flot.selection.js +344 -0
  176. data/public/flot/jquery.flot.selection.min.js +1 -0
  177. data/public/flot/jquery.flot.stack.js +184 -0
  178. data/public/flot/jquery.flot.stack.min.js +1 -0
  179. data/public/flot/jquery.flot.symbol.js +70 -0
  180. data/public/flot/jquery.flot.symbol.min.js +1 -0
  181. data/public/flot/jquery.flot.threshold.js +103 -0
  182. data/public/flot/jquery.flot.threshold.min.js +1 -0
  183. data/public/flot/jquery.js +8316 -0
  184. data/public/flot/jquery.min.js +23 -0
  185. data/public/genPacking.pl +30 -0
  186. data/public/index.html +28 -0
  187. data/public/install.tpz +66 -0
  188. data/public/installAndRun.tpz +5 -0
  189. data/public/jsTree/jquery.jstree.js +3510 -0
  190. data/public/jsTree/themes/default/d.gif +0 -0
  191. data/public/jsTree/themes/default/d.png +0 -0
  192. data/public/jsTree/themes/default/style.css +73 -0
  193. data/public/jsTree/themes/default/throbber.gif +0 -0
  194. data/public/readMe.txt +9 -0
  195. data/public/scripts/CodeBrowser.js +645 -0
  196. data/public/scripts/Debugger.js +134 -0
  197. data/public/scripts/MethodList.js +72 -0
  198. data/public/scripts/ObjectLog.js +59 -0
  199. data/public/scripts/SessionList.js +164 -0
  200. data/public/scripts/Statistics.js +266 -0
  201. data/public/scripts/editor.js +430 -0
  202. data/public/scripts/jjmenu.js +375 -0
  203. data/public/scripts/jquery-ui.js +1012 -0
  204. data/public/scripts/jquery.js +154 -0
  205. data/public/scripts/webtools.js +374 -0
  206. data/public/src/CodeBrowser.gs +416 -0
  207. data/public/src/Debugger.gs +132 -0
  208. data/public/src/MethodList.gs +130 -0
  209. data/public/src/ObjectLog.gs +73 -0
  210. data/public/src/Server.gs +544 -0
  211. data/public/src/SessionList.gs +172 -0
  212. data/public/src/SharedPageCache.gs +66 -0
  213. data/public/src/StatProcess.gs +280 -0
  214. data/public/src/StatProcessType.gs +242 -0
  215. data/public/src/StatStatistic.gs +381 -0
  216. data/public/src/Statistics.gs +222 -0
  217. data/public/src/Statmonitor.gs +490 -0
  218. data/public/src/Tool.gs +86 -0
  219. data/public/src/VersionReport.gs +52 -0
  220. data/public/src/Workspace.gs +163 -0
  221. data/views/debugger.rhtml +6 -9
  222. metadata +344 -243
  223. data/lib/web_tools/#debugger.rb# +0 -212
  224. data/lib/web_tools/browser.rb +0 -45
  225. data/public/images/favicon.ico +0 -0
  226. data/public/javascript/CodeMirror/LICENSE +0 -23
  227. data/public/javascript/CodeMirror/css/Smalltalk.css +0 -34
  228. data/public/javascript/CodeMirror/js/codemirror.js +0 -582
  229. data/public/javascript/CodeMirror/js/editor.js +0 -1671
  230. data/public/javascript/CodeMirror/js/highlight.js +0 -68
  231. data/public/javascript/CodeMirror/js/parseSmalltalk.js +0 -126
  232. data/public/javascript/CodeMirror/js/parsedummy.js +0 -32
  233. data/public/javascript/CodeMirror/js/select.js +0 -699
  234. data/public/javascript/CodeMirror/js/stringstream.js +0 -159
  235. data/public/javascript/CodeMirror/js/tokenize.js +0 -57
  236. data/public/javascript/CodeMirror/js/undo.js +0 -413
  237. data/public/javascript/CodeMirror/js/util.js +0 -133
  238. data/public/javascript/CodeMirror/testSmalltalkParser.html +0 -116
  239. data/public/javascript/ace/ace-uncompressed.js +0 -17299
  240. data/public/javascript/ace/ace.js +0 -1
  241. data/public/javascript/ace/keybinding-emacs.js +0 -1
  242. data/public/javascript/ace/keybinding-vim.js +0 -1
  243. data/public/javascript/ace/mode-c_cpp.js +0 -1
  244. data/public/javascript/ace/mode-clojure.js +0 -1
  245. data/public/javascript/ace/mode-coffee.js +0 -1
  246. data/public/javascript/ace/mode-csharp.js +0 -1
  247. data/public/javascript/ace/mode-css.js +0 -1
  248. data/public/javascript/ace/mode-groovy.js +0 -1
  249. data/public/javascript/ace/mode-html.js +0 -1
  250. data/public/javascript/ace/mode-java.js +0 -1
  251. data/public/javascript/ace/mode-javascript.js +0 -1
  252. data/public/javascript/ace/mode-json.js +0 -1
  253. data/public/javascript/ace/mode-lua.js +0 -1
  254. data/public/javascript/ace/mode-markdown.js +0 -1
  255. data/public/javascript/ace/mode-ocaml.js +0 -1
  256. data/public/javascript/ace/mode-perl.js +0 -1
  257. data/public/javascript/ace/mode-php.js +0 -1
  258. data/public/javascript/ace/mode-python.js +0 -1
  259. data/public/javascript/ace/mode-ruby.js +0 -1
  260. data/public/javascript/ace/mode-scad.js +0 -1
  261. data/public/javascript/ace/mode-scala.js +0 -1
  262. data/public/javascript/ace/mode-scss.js +0 -1
  263. data/public/javascript/ace/mode-svg.js +0 -1
  264. data/public/javascript/ace/mode-textile.js +0 -1
  265. data/public/javascript/ace/mode-xml.js +0 -1
  266. data/public/javascript/ace/theme-clouds.js +0 -1
  267. data/public/javascript/ace/theme-clouds_midnight.js +0 -1
  268. data/public/javascript/ace/theme-cobalt.js +0 -1
  269. data/public/javascript/ace/theme-crimson_editor.js +0 -1
  270. data/public/javascript/ace/theme-dawn.js +0 -1
  271. data/public/javascript/ace/theme-eclipse.js +0 -1
  272. data/public/javascript/ace/theme-idle_fingers.js +0 -1
  273. data/public/javascript/ace/theme-kr_theme.js +0 -1
  274. data/public/javascript/ace/theme-merbivore.js +0 -1
  275. data/public/javascript/ace/theme-merbivore_soft.js +0 -1
  276. data/public/javascript/ace/theme-mono_industrial.js +0 -1
  277. data/public/javascript/ace/theme-monokai.js +0 -1
  278. data/public/javascript/ace/theme-pastel_on_dark.js +0 -1
  279. data/public/javascript/ace/theme-solarized_dark.js +0 -1
  280. data/public/javascript/ace/theme-solarized_light.js +0 -1
  281. data/public/javascript/ace/theme-textmate.js +0 -1
  282. data/public/javascript/ace/theme-twilight.js +0 -1
  283. data/public/javascript/ace/theme-vibrant_ink.js +0 -1
  284. data/public/javascript/ace/worker-coffee.js +0 -1
  285. data/public/javascript/ace/worker-css.js +0 -1
  286. data/public/javascript/ace/worker-javascript.js +0 -1
  287. data/public/javascript/webtools/browser.js +0 -260
  288. data/public/javascript/webtools/debugger.coffee +0 -286
  289. data/public/javascript/webtools/debugger.js +0 -366
  290. data/public/javascript/webtools/sessions.coffee +0 -17
  291. data/public/javascript/webtools/sessions.js +0 -27
  292. data/public/javascript/webtools/version.coffee +0 -14
  293. data/public/javascript/webtools/version.js +0 -20
  294. data/public/stylesheets/jquery.contextMenu.css +0 -62
  295. data/public/stylesheets/webtools.css +0 -53
  296. data/public/test.html +0 -47
@@ -1,212 +0,0 @@
1
- require 'sinatra'
2
- require 'web_tools'
3
- require 'web_tools/support/service_helper'
4
- require 'rack/contrib/jsonp'
5
- require 'maglev/debugger'
6
- require 'maglev/method_source'
7
-
8
- module WebTools
9
- class Debugger < Sinatra::Base
10
- include WebTools::Support::ServiceHelper
11
- use Rack::JSONP
12
-
13
- def respond_json(obj)
14
- content_type :json
15
- result = case obj
16
- when Maglev::Debugger::Wrapper
17
- obj.to_hash
18
- else
19
- if obj.is_a? Array and
20
- obj.all? {|e| e.is_a? Maglev::Debugger::Wrapper}
21
- obj.collect(&:to_hash)
22
- else
23
- case obj
24
- when Array, Hash
25
- obj
26
- else
27
- details_for(obj)
28
- end
29
- end
30
- end
31
- body(result.to_json)
32
- end
33
-
34
- def process
35
- Maglev::Debugger::Process.new(ObjectSpace._id2ref(params[:oop].to_i))
36
- end
37
-
38
- def frames
39
- params.has_key?("all") ? process.frames : process.ruby_frames
40
- end
41
-
42
- def frame
43
- f = frames[params[:idx].to_i]
44
- f.debug_info!
45
- f
46
- end
47
-
48
- def objects
49
- instance_variables_for(object)
50
- end
51
-
52
- def object
53
- ctxt = frame.debug_info[:context]
54
- obj = nil
55
- variable_list = params[:splat].first.split("/objects/")
56
- variable_list.each do |name|
57
- name = name[0...(-"/objects".size)] if name.end_with? "/objects"
58
- obj = ctxt[name.to_sym]
59
- ctxt = instance_variables_for(obj)
60
- end
61
- obj
62
- end
63
-
64
- def instance_variables_for(object)
65
- object.instance_variables.inject({}) do |hash, var|
66
- hash[var.to_sym] = object.instance_variable_get(var)
67
- hash
68
- end
69
- end
70
-
71
- def details_for(object)
72
- { "instance_variables" => instance_variables_for(object),
73
- "self" => object,
74
- "inspect" => object.inspect,
75
- "class" => object.class,
76
- "do-it" => nil,
77
- "do-it-result" => nil }
78
- end
79
-
80
- before do
81
- Maglev.abort_transaction
82
- end
83
-
84
- # => list of errors
85
- get "/process" do
86
- errors = ObjectLog.errors.collect {|e| Maglev::Debugger::Process.new(e) }
87
- processes = Thread.list.select(&:stop?).collect do |e|
88
- Maglev::Debugger::Process.new(e)
89
- end
90
- respond_json (errors + processes)
91
- end
92
-
93
- get "/process/:oop" do
94
- respond_json process
95
- end
96
-
97
- get "/process/:oop/frames" do
98
- respond_json frames
99
- end
100
-
101
- get "/process/:oop/frames/:idx" do
102
- respond_json frame
103
- end
104
-
105
- get "/process/:oop/frames/:idx/objects" do
106
- respond_json frame.debug_info[:context]
107
- end
108
-
109
- get "/process/:oop/frames/:idx/objects/*" do
110
- if params[:splat].first.end_with? "objects"
111
- respond_json objects
112
- else
113
- respond_json details_for(object)
114
- end
115
- end
116
-
117
- delete "/process/:oop" do
118
- respond_json process.delete
119
- end
120
-
121
- delete "/process/:oop/frames/:idx" do
122
- respond_json frame.delete
123
- end
124
-
125
- post "/process/:oop" do
126
- p = process
127
- return 404 if p.is_a? Maglev::Debugger::ObjectLogError
128
- if params["running"] == "true" and p.thread.alive? and p.thread.stop?
129
- p.thread.wakeup
130
- p.thread.join
131
- if (result = p.thread[:result]).is_a? Maglev::Debugger::Process
132
- p.thread.kill
133
- raise result.exception
134
- else
135
- result
136
- end
137
- else
138
- 404
139
- end
140
- end
141
-
142
- put "/process/:oop/frames/:idx" do
143
- current_frame = frame.to_hash
144
- # TODO: Really check the posted document
145
- if doIt = params["do-it"]
146
- begin
147
- result = frame.context_eval(doIt)
148
- rescue Exception => e
149
- result = e
150
- end
151
- current_frame[:"do-it"] = doIt
152
- current_frame[:"do-it-result"] = details_for(result)
153
- respond_json current_frame
154
- elsif params["index"] == "1" and params[:idx] == "0"
155
- until frame.method_name != current_frame[:method_name]
156
- frame.step(:into) # Step into until we find the next ruby frame
157
- end
158
- respond_json frame
159
- elsif di = params["debug_info"]
160
- if di["stepOffset"] && di["stepOffset"] != current_frame[:debug_info][:stepOffset]
161
- return 404 unless params[:idx] == 0
162
- while di["stepOffset"].to_i > frame[:debug_info][:stepOffset].to_i
163
- frame.step(:over)
164
- end
165
- respond_json frame
166
- elsif di["source"] && di["source"] != current_frame[:debug_info][:source]
167
- klass = current_frame[:defining_class]
168
- frame_above = frames[params[:idx].to_i + 1]
169
- # Pop to one frame before the modified one
170
- frame_above.delete
171
- # Recompile the method
172
- klass.set_method_source(current_frame[:method_name], di["source"])
173
- # Step into the modified method
174
- process.frames.first.step(:into)
175
- params[:idx] = 0
176
- respond_json frame # Retreive the frame again, to show the updated source
177
- end
178
- else
179
- status 404
180
- respond_json frame
181
- end
182
- end
183
-
184
- put "/process/:oop/frames/:idx/objects/*" do
185
- return 404 if params[:splat].first.end_with? "objects"
186
-
187
- if doIt = params["do-it"]
188
- begin
189
- result = object.instance_eval(doIt)
190
- rescue Exception => e
191
- result = e
192
- end
193
- return_value = details_for(object)
194
- return_value["do-it"] = doIt
195
- return_value["do-it-result"] = details_for(result)
196
- respond_json return_value
197
- else
198
- 404
199
- end
200
- end
201
-
202
- # XXX: Remove me, please
203
- options '*' do
204
- [200,
205
- { 'Access-Control-Allow-Origin' => '*',
206
- 'Access-Control-Allow-Methods' => 'PUT, POST, GET, DELETE, OPTIONS',
207
- 'Access-Control-Max-Age' => '1000',
208
- 'Access-Control-Allow-Headers' => '*' },
209
- [""]]
210
- end
211
- end
212
- end
@@ -1,45 +0,0 @@
1
- require 'sinatra/base'
2
- require 'web_tools'
3
- require 'web_tools/support/code_browser'
4
- require 'web_tools/support/service_helper'
5
-
6
- class WebTools::Browser < Sinatra::Base
7
- include WebTools::Support::ServiceHelper
8
-
9
- before do
10
- @ts = Time.now
11
- @stack = nil
12
- @browser = WebTools::CodeBrowser.new
13
- content_type :json
14
- end
15
-
16
- get '/modulelist' do
17
- prepare_data(WebTools::CodeBrowser.class_and_module_list)
18
- end
19
-
20
- get '/module/:name' do
21
- prepare_data(@browser.select_module(params[:name]))
22
- end
23
-
24
- get '/module/:module_name/constant/:const_name' do
25
- prepare_data(@browser.select_constant(params[:module_name],
26
- params[:const_name]))
27
- end
28
-
29
- get '/module/:module_name/method' do
30
- flag = params[:is_instance_method] == 'true' ? true : false
31
- prepare_data(@browser.select_method(params[:module_name],
32
- params[:method_name],
33
- flag))
34
- end
35
-
36
- get '/objectspace/:object_id' do
37
- prepare_data(@browser.object_info(params[:object_id]))
38
- end
39
-
40
- get '/transaction/abort' do
41
- Maglev.abort_transaction
42
- prepare_data(WebTools::CodeBrowser.class_and_module_list)
43
- end
44
- end
45
-
Binary file
@@ -1,23 +0,0 @@
1
- Copyright (c) 2007-2010 Marijn Haverbeke
2
-
3
- This software is provided 'as-is', without any express or implied
4
- warranty. In no event will the authors be held liable for any
5
- damages arising from the use of this software.
6
-
7
- Permission is granted to anyone to use this software for any
8
- purpose, including commercial applications, and to alter it and
9
- redistribute it freely, subject to the following restrictions:
10
-
11
- 1. The origin of this software must not be misrepresented; you must
12
- not claim that you wrote the original software. If you use this
13
- software in a product, an acknowledgment in the product
14
- documentation would be appreciated but is not required.
15
-
16
- 2. Altered source versions must be plainly marked as such, and must
17
- not be misrepresented as being the original software.
18
-
19
- 3. This notice may not be removed or altered from any source
20
- distribution.
21
-
22
- Marijn Haverbeke
23
- marijnh@gmail.com
@@ -1,34 +0,0 @@
1
- html {
2
- cursor: text;
3
- }
4
-
5
- .editbox {
6
- margin: .4em;
7
- padding: 0;
8
- font-family: monospace;
9
- font-size: 10pt;
10
- color: black;
11
- }
12
-
13
- .editbox p {
14
- margin: 0;
15
- }
16
-
17
- span.st-character { color: rgb(128,0,128); }
18
- span.st-comment { color: rgb(0,200,0); font-style: italic; }
19
- span.st-string { color: rgb(128,0,128); }
20
- span.st-symbol { color: rgb(128,0,128); }
21
- span.st-boolean { color: rgb(0,0,128); }
22
- span.st-self { color: rgb(0,0,128); }
23
- span.st-super { color: rgb(0,0,128); }
24
- span.st-nil { color: rgb(0,0,128); }
25
- span.st-return { color: rgb(160,0,0); }
26
- span.st-keyword { color: rgb(0,0,255); }
27
- span.st-global { font-weight: bold; }
28
-
29
- /*
30
- number: 0 127 127
31
- special selector: 0 0 127
32
- brace highlight: 255 128 0
33
- brace mismatch: 255 0 0
34
- */
@@ -1,582 +0,0 @@
1
- /* CodeMirror main module (http://codemirror.net/)
2
- *
3
- * Implements the CodeMirror constructor and prototype, which take care
4
- * of initializing the editor frame, and providing the outside interface.
5
- */
6
-
7
- // The CodeMirrorConfig object is used to specify a default
8
- // configuration. If you specify such an object before loading this
9
- // file, the values you put into it will override the defaults given
10
- // below. You can also assign to it after loading.
11
- var CodeMirrorConfig = window.CodeMirrorConfig || {};
12
-
13
- var CodeMirror = (function(){
14
- function setDefaults(object, defaults) {
15
- for (var option in defaults) {
16
- if (!object.hasOwnProperty(option))
17
- object[option] = defaults[option];
18
- }
19
- }
20
- function forEach(array, action) {
21
- for (var i = 0; i < array.length; i++)
22
- action(array[i]);
23
- }
24
- function createHTMLElement(el) {
25
- if (document.createElementNS && document.documentElement.namespaceURI !== null)
26
- return document.createElementNS("http://www.w3.org/1999/xhtml", el)
27
- else
28
- return document.createElement(el)
29
- }
30
-
31
- // These default options can be overridden by passing a set of
32
- // options to a specific CodeMirror constructor. See manual.html for
33
- // their meaning.
34
- setDefaults(CodeMirrorConfig, {
35
- stylesheet: [],
36
- path: "",
37
- parserfile: [],
38
- basefiles: ["util.js", "stringstream.js", "select.js", "undo.js", "editor.js", "tokenize.js"],
39
- iframeClass: null,
40
- passDelay: 200,
41
- passTime: 50,
42
- lineNumberDelay: 200,
43
- lineNumberTime: 50,
44
- continuousScanning: false,
45
- saveFunction: null,
46
- onLoad: null,
47
- onChange: null,
48
- undoDepth: 50,
49
- undoDelay: 800,
50
- disableSpellcheck: true,
51
- textWrapping: true,
52
- readOnly: false,
53
- width: "",
54
- height: "300px",
55
- minHeight: 100,
56
- autoMatchParens: false,
57
- markParen: null,
58
- unmarkParen: null,
59
- parserConfig: null,
60
- tabMode: "indent", // or "spaces", "default", "shift"
61
- enterMode: "indent", // or "keep", "flat"
62
- electricChars: true,
63
- reindentOnLoad: false,
64
- activeTokens: null,
65
- onCursorActivity: null,
66
- lineNumbers: false,
67
- firstLineNumber: 1,
68
- onLineNumberClick: null,
69
- indentUnit: 2,
70
- domain: null,
71
- noScriptCaching: false,
72
- incrementalLoading: false
73
- });
74
-
75
- function addLineNumberDiv(container, firstNum) {
76
- var nums = createHTMLElement("div"),
77
- scroller = createHTMLElement("div");
78
- nums.style.position = "absolute";
79
- nums.style.height = "100%";
80
- if (nums.style.setExpression) {
81
- try {nums.style.setExpression("height", "this.previousSibling.offsetHeight + 'px'");}
82
- catch(e) {} // Seems to throw 'Not Implemented' on some IE8 versions
83
- }
84
- nums.style.top = "0px";
85
- nums.style.left = "0px";
86
- nums.style.overflow = "hidden";
87
- container.appendChild(nums);
88
- scroller.className = "CodeMirror-line-numbers";
89
- nums.appendChild(scroller);
90
- scroller.innerHTML = "<div>" + firstNum + "</div>";
91
- return nums;
92
- }
93
-
94
- function frameHTML(options) {
95
- if (typeof options.parserfile == "string")
96
- options.parserfile = [options.parserfile];
97
- if (typeof options.basefiles == "string")
98
- options.basefiles = [options.basefiles];
99
- if (typeof options.stylesheet == "string")
100
- options.stylesheet = [options.stylesheet];
101
-
102
- var sp = " spellcheck=\"" + (options.disableSpellcheck ? "false" : "true") + "\"";
103
- var html = ["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html" + sp + "><head>"];
104
- // Hack to work around a bunch of IE8-specific problems.
105
- html.push("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\"/>");
106
- var queryStr = options.noScriptCaching ? "?nocache=" + new Date().getTime().toString(16) : "";
107
- forEach(options.stylesheet, function(file) {
108
- html.push("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + file + queryStr + "\"/>");
109
- });
110
- forEach(options.basefiles.concat(options.parserfile), function(file) {
111
- if (!/^https?:/.test(file)) file = options.path + file;
112
- html.push("<script type=\"text/javascript\" src=\"" + file + queryStr + "\"><" + "/script>");
113
- });
114
- html.push("</head><body style=\"border-width: 0;\" class=\"editbox\"" + sp + "></body></html>");
115
- return html.join("");
116
- }
117
-
118
- var internetExplorer = document.selection && window.ActiveXObject && /MSIE/.test(navigator.userAgent);
119
-
120
- function CodeMirror(place, options) {
121
- // Use passed options, if any, to override defaults.
122
- this.options = options = options || {};
123
- setDefaults(options, CodeMirrorConfig);
124
-
125
- // Backward compatibility for deprecated options.
126
- if (options.dumbTabs) options.tabMode = "spaces";
127
- else if (options.normalTab) options.tabMode = "default";
128
- if (options.cursorActivity) options.onCursorActivity = options.cursorActivity;
129
-
130
- var frame = this.frame = createHTMLElement("iframe");
131
- if (options.iframeClass) frame.className = options.iframeClass;
132
- frame.frameBorder = 0;
133
- frame.style.border = "0";
134
- frame.style.width = '100%';
135
- frame.style.height = '100%';
136
- // display: block occasionally suppresses some Firefox bugs, so we
137
- // always add it, redundant as it sounds.
138
- frame.style.display = "block";
139
-
140
- var div = this.wrapping = createHTMLElement("div");
141
- div.style.position = "relative";
142
- div.className = "CodeMirror-wrapping";
143
- div.style.width = options.width;
144
- div.style.height = (options.height == "dynamic") ? options.minHeight + "px" : options.height;
145
- // This is used by Editor.reroutePasteEvent
146
- var teHack = this.textareaHack = createHTMLElement("textarea");
147
- div.appendChild(teHack);
148
- teHack.style.position = "absolute";
149
- teHack.style.left = "-10000px";
150
- teHack.style.width = "10px";
151
- teHack.tabIndex = 100000;
152
-
153
- // Link back to this object, so that the editor can fetch options
154
- // and add a reference to itself.
155
- frame.CodeMirror = this;
156
- if (options.domain && internetExplorer) {
157
- this.html = frameHTML(options);
158
- frame.src = "javascript:(function(){document.open();" +
159
- (options.domain ? "document.domain=\"" + options.domain + "\";" : "") +
160
- "document.write(window.frameElement.CodeMirror.html);document.close();})()";
161
- }
162
- else {
163
- frame.src = "javascript:;";
164
- }
165
-
166
- if (place.appendChild) place.appendChild(div);
167
- else place(div);
168
- div.appendChild(frame);
169
- if (options.lineNumbers) this.lineNumbers = addLineNumberDiv(div, options.firstLineNumber);
170
-
171
- this.win = frame.contentWindow;
172
- if (!options.domain || !internetExplorer) {
173
- this.win.document.open();
174
- this.win.document.write(frameHTML(options));
175
- this.win.document.close();
176
- }
177
- }
178
-
179
- CodeMirror.prototype = {
180
- init: function() {
181
- // Deprecated, but still supported.
182
- if (this.options.initCallback) this.options.initCallback(this);
183
- if (this.options.onLoad) this.options.onLoad(this);
184
- if (this.options.lineNumbers) this.activateLineNumbers();
185
- if (this.options.reindentOnLoad) this.reindent();
186
- if (this.options.height == "dynamic") this.setDynamicHeight();
187
- },
188
-
189
- getCode: function() {return this.editor.getCode();},
190
- setCode: function(code) {this.editor.importCode(code);},
191
- selection: function() {this.focusIfIE(); return this.editor.selectedText();},
192
- reindent: function() {this.editor.reindent();},
193
- reindentSelection: function() {this.focusIfIE(); this.editor.reindentSelection(null);},
194
-
195
- focusIfIE: function() {
196
- // in IE, a lot of selection-related functionality only works when the frame is focused
197
- if (this.win.select.ie_selection && document.activeElement != this.frame)
198
- this.focus();
199
- },
200
- focus: function() {
201
- this.win.focus();
202
- if (this.editor.selectionSnapshot) // IE hack
203
- this.win.select.setBookmark(this.win.document.body, this.editor.selectionSnapshot);
204
- },
205
- replaceSelection: function(text) {
206
- this.focus();
207
- this.editor.replaceSelection(text);
208
- return true;
209
- },
210
- replaceChars: function(text, start, end) {
211
- this.editor.replaceChars(text, start, end);
212
- },
213
- getSearchCursor: function(string, fromCursor, caseFold) {
214
- return this.editor.getSearchCursor(string, fromCursor, caseFold);
215
- },
216
-
217
- undo: function() {this.editor.history.undo();},
218
- redo: function() {this.editor.history.redo();},
219
- historySize: function() {return this.editor.history.historySize();},
220
- clearHistory: function() {this.editor.history.clear();},
221
-
222
- grabKeys: function(callback, filter) {this.editor.grabKeys(callback, filter);},
223
- ungrabKeys: function() {this.editor.ungrabKeys();},
224
-
225
- setParser: function(name, parserConfig) {this.editor.setParser(name, parserConfig);},
226
- setSpellcheck: function(on) {this.win.document.body.spellcheck = on;},
227
- setStylesheet: function(names) {
228
- if (typeof names === "string") names = [names];
229
- var activeStylesheets = {};
230
- var matchedNames = {};
231
- var links = this.win.document.getElementsByTagName("link");
232
- // Create hashes of active stylesheets and matched names.
233
- // This is O(n^2) but n is expected to be very small.
234
- for (var x = 0, link; link = links[x]; x++) {
235
- if (link.rel.indexOf("stylesheet") !== -1) {
236
- for (var y = 0; y < names.length; y++) {
237
- var name = names[y];
238
- if (link.href.substring(link.href.length - name.length) === name) {
239
- activeStylesheets[link.href] = true;
240
- matchedNames[name] = true;
241
- }
242
- }
243
- }
244
- }
245
- // Activate the selected stylesheets and disable the rest.
246
- for (var x = 0, link; link = links[x]; x++) {
247
- if (link.rel.indexOf("stylesheet") !== -1) {
248
- link.disabled = !(link.href in activeStylesheets);
249
- }
250
- }
251
- // Create any new stylesheets.
252
- for (var y = 0; y < names.length; y++) {
253
- var name = names[y];
254
- if (!(name in matchedNames)) {
255
- var link = this.win.document.createElement("link");
256
- link.rel = "stylesheet";
257
- link.type = "text/css";
258
- link.href = name;
259
- this.win.document.getElementsByTagName('head')[0].appendChild(link);
260
- }
261
- }
262
- },
263
- setTextWrapping: function(on) {
264
- if (on == this.options.textWrapping) return;
265
- this.win.document.body.style.whiteSpace = on ? "" : "nowrap";
266
- this.options.textWrapping = on;
267
- if (this.lineNumbers) {
268
- this.setLineNumbers(false);
269
- this.setLineNumbers(true);
270
- }
271
- },
272
- setIndentUnit: function(unit) {this.win.indentUnit = unit;},
273
- setUndoDepth: function(depth) {this.editor.history.maxDepth = depth;},
274
- setTabMode: function(mode) {this.options.tabMode = mode;},
275
- setEnterMode: function(mode) {this.options.enterMode = mode;},
276
- setLineNumbers: function(on) {
277
- if (on && !this.lineNumbers) {
278
- this.lineNumbers = addLineNumberDiv(this.wrapping,this.options.firstLineNumber);
279
- this.activateLineNumbers();
280
- }
281
- else if (!on && this.lineNumbers) {
282
- this.wrapping.removeChild(this.lineNumbers);
283
- this.wrapping.style.paddingLeft = "";
284
- this.lineNumbers = null;
285
- }
286
- },
287
-
288
- cursorPosition: function(start) {this.focusIfIE(); return this.editor.cursorPosition(start);},
289
- firstLine: function() {return this.editor.firstLine();},
290
- lastLine: function() {return this.editor.lastLine();},
291
- nextLine: function(line) {return this.editor.nextLine(line);},
292
- prevLine: function(line) {return this.editor.prevLine(line);},
293
- lineContent: function(line) {return this.editor.lineContent(line);},
294
- setLineContent: function(line, content) {this.editor.setLineContent(line, content);},
295
- removeLine: function(line){this.editor.removeLine(line);},
296
- insertIntoLine: function(line, position, content) {this.editor.insertIntoLine(line, position, content);},
297
- selectLines: function(startLine, startOffset, endLine, endOffset) {
298
- this.win.focus();
299
- this.editor.selectLines(startLine, startOffset, endLine, endOffset);
300
- },
301
- nthLine: function(n) {
302
- var line = this.firstLine();
303
- for (; n > 1 && line !== false; n--)
304
- line = this.nextLine(line);
305
- return line;
306
- },
307
- lineNumber: function(line) {
308
- var num = 0;
309
- while (line !== false) {
310
- num++;
311
- line = this.prevLine(line);
312
- }
313
- return num;
314
- },
315
- jumpToLine: function(line) {
316
- if (typeof line == "number") line = this.nthLine(line);
317
- this.selectLines(line, 0);
318
- this.win.focus();
319
- },
320
- currentLine: function() { // Deprecated, but still there for backward compatibility
321
- return this.lineNumber(this.cursorLine());
322
- },
323
- cursorLine: function() {
324
- return this.cursorPosition().line;
325
- },
326
- cursorCoords: function(start) {return this.editor.cursorCoords(start);},
327
-
328
- activateLineNumbers: function() {
329
- var frame = this.frame, win = frame.contentWindow, doc = win.document, body = doc.body,
330
- nums = this.lineNumbers, scroller = nums.firstChild, self = this;
331
- var barWidth = null;
332
-
333
- nums.onclick = function(e) {
334
- var handler = self.options.onLineNumberClick;
335
- if (handler) {
336
- var div = (e || window.event).target || (e || window.event).srcElement;
337
- var num = div == nums ? NaN : Number(div.innerHTML);
338
- if (!isNaN(num)) handler(num, div);
339
- }
340
- };
341
-
342
- function sizeBar() {
343
- if (frame.offsetWidth == 0) return;
344
- for (var root = frame; root.parentNode; root = root.parentNode){}
345
- if (!nums.parentNode || root != document || !win.Editor) {
346
- // Clear event handlers (their nodes might already be collected, so try/catch)
347
- try{clear();}catch(e){}
348
- clearInterval(sizeInterval);
349
- return;
350
- }
351
-
352
- if (nums.offsetWidth != barWidth) {
353
- barWidth = nums.offsetWidth;
354
- frame.parentNode.style.paddingLeft = barWidth + "px";
355
- }
356
- }
357
- function doScroll() {
358
- nums.scrollTop = body.scrollTop || doc.documentElement.scrollTop || 0;
359
- }
360
- // Cleanup function, registered by nonWrapping and wrapping.
361
- var clear = function(){};
362
- sizeBar();
363
- var sizeInterval = setInterval(sizeBar, 500);
364
-
365
- function ensureEnoughLineNumbers(fill) {
366
- var lineHeight = scroller.firstChild.offsetHeight;
367
- if (lineHeight == 0) return;
368
- var targetHeight = 50 + Math.max(body.offsetHeight, Math.max(frame.offsetHeight, body.scrollHeight || 0)),
369
- lastNumber = Math.ceil(targetHeight / lineHeight);
370
- for (var i = scroller.childNodes.length; i <= lastNumber; i++) {
371
- var div = createHTMLElement("div");
372
- div.appendChild(document.createTextNode(fill ? String(i + self.options.firstLineNumber) : "\u00a0"));
373
- scroller.appendChild(div);
374
- }
375
- }
376
-
377
- function nonWrapping() {
378
- function update() {
379
- ensureEnoughLineNumbers(true);
380
- doScroll();
381
- }
382
- self.updateNumbers = update;
383
- var onScroll = win.addEventHandler(win, "scroll", doScroll, true),
384
- onResize = win.addEventHandler(win, "resize", update, true);
385
- clear = function(){
386
- onScroll(); onResize();
387
- if (self.updateNumbers == update) self.updateNumbers = null;
388
- };
389
- update();
390
- }
391
-
392
- function wrapping() {
393
- var node, lineNum, next, pos, changes = [], styleNums = self.options.styleNumbers;
394
-
395
- function setNum(n, node) {
396
- // Does not typically happen (but can, if you mess with the
397
- // document during the numbering)
398
- if (!lineNum) lineNum = scroller.appendChild(createHTMLElement("div"));
399
- if (styleNums) styleNums(lineNum, node, n);
400
- // Changes are accumulated, so that the document layout
401
- // doesn't have to be recomputed during the pass
402
- changes.push(lineNum); changes.push(n);
403
- pos = lineNum.offsetHeight + lineNum.offsetTop;
404
- lineNum = lineNum.nextSibling;
405
- }
406
- function commitChanges() {
407
- for (var i = 0; i < changes.length; i += 2)
408
- changes[i].innerHTML = changes[i + 1];
409
- changes = [];
410
- }
411
- function work() {
412
- if (!scroller.parentNode || scroller.parentNode != self.lineNumbers) return;
413
-
414
- var endTime = new Date().getTime() + self.options.lineNumberTime;
415
- while (node) {
416
- setNum(next++, node.previousSibling);
417
- for (; node && !win.isBR(node); node = node.nextSibling) {
418
- var bott = node.offsetTop + node.offsetHeight;
419
- while (scroller.offsetHeight && bott - 3 > pos) {
420
- var oldPos = pos;
421
- setNum("&nbsp;");
422
- if (pos <= oldPos) break;
423
- }
424
- }
425
- if (node) node = node.nextSibling;
426
- if (new Date().getTime() > endTime) {
427
- commitChanges();
428
- pending = setTimeout(work, self.options.lineNumberDelay);
429
- return;
430
- }
431
- }
432
- while (lineNum) setNum(next++);
433
- commitChanges();
434
- doScroll();
435
- }
436
- function start(firstTime) {
437
- doScroll();
438
- ensureEnoughLineNumbers(firstTime);
439
- node = body.firstChild;
440
- lineNum = scroller.firstChild;
441
- pos = 0;
442
- next = self.options.firstLineNumber;
443
- work();
444
- }
445
-
446
- start(true);
447
- var pending = null;
448
- function update() {
449
- if (pending) clearTimeout(pending);
450
- if (self.editor.allClean()) start();
451
- else pending = setTimeout(update, 200);
452
- }
453
- self.updateNumbers = update;
454
- var onScroll = win.addEventHandler(win, "scroll", doScroll, true),
455
- onResize = win.addEventHandler(win, "resize", update, true);
456
- clear = function(){
457
- if (pending) clearTimeout(pending);
458
- if (self.updateNumbers == update) self.updateNumbers = null;
459
- onScroll();
460
- onResize();
461
- };
462
- }
463
- (this.options.textWrapping || this.options.styleNumbers ? wrapping : nonWrapping)();
464
- },
465
-
466
- setDynamicHeight: function() {
467
- var self = this, activity = self.options.onCursorActivity, win = self.win, body = win.document.body,
468
- lineHeight = null, timeout = null, vmargin = 2 * self.frame.offsetTop;
469
- body.style.overflowY = "hidden";
470
- win.document.documentElement.style.overflowY = "hidden";
471
- this.frame.scrolling = "no";
472
-
473
- function updateHeight() {
474
- var trailingLines = 0, node = body.lastChild, computedHeight;
475
- while (node && win.isBR(node)) {
476
- if (!node.hackBR) trailingLines++;
477
- node = node.previousSibling;
478
- }
479
- if (node) {
480
- lineHeight = node.offsetHeight;
481
- computedHeight = node.offsetTop + (1 + trailingLines) * lineHeight;
482
- }
483
- else if (lineHeight) {
484
- computedHeight = trailingLines * lineHeight;
485
- }
486
- if (computedHeight)
487
- self.wrapping.style.height = Math.max(vmargin + computedHeight, self.options.minHeight) + "px";
488
- }
489
- setTimeout(updateHeight, 300);
490
- self.options.onCursorActivity = function(x) {
491
- if (activity) activity(x);
492
- clearTimeout(timeout);
493
- timeout = setTimeout(updateHeight, 100);
494
- };
495
- }
496
- };
497
-
498
- CodeMirror.InvalidLineHandle = {toString: function(){return "CodeMirror.InvalidLineHandle";}};
499
-
500
- CodeMirror.replace = function(element) {
501
- if (typeof element == "string")
502
- element = document.getElementById(element);
503
- return function(newElement) {
504
- element.parentNode.replaceChild(newElement, element);
505
- };
506
- };
507
-
508
- CodeMirror.fromTextArea = function(area, options) {
509
- if (typeof area == "string")
510
- area = document.getElementById(area);
511
-
512
- options = options || {};
513
- if (area.style.width && options.width == null)
514
- options.width = area.style.width;
515
- if (area.style.height && options.height == null)
516
- options.height = area.style.height;
517
- if (options.content == null) options.content = area.value;
518
-
519
- function updateField() {
520
- area.value = mirror.getCode();
521
- }
522
- if (area.form) {
523
- if (typeof area.form.addEventListener == "function")
524
- area.form.addEventListener("submit", updateField, false);
525
- else
526
- area.form.attachEvent("onsubmit", updateField);
527
- var realSubmit = area.form.submit;
528
- function wrapSubmit() {
529
- updateField();
530
- // Can't use realSubmit.apply because IE6 is too stupid
531
- area.form.submit = realSubmit;
532
- area.form.submit();
533
- area.form.submit = wrapSubmit;
534
- }
535
- try {area.form.submit = wrapSubmit;} catch(e){}
536
- }
537
-
538
- function insert(frame) {
539
- if (area.nextSibling)
540
- area.parentNode.insertBefore(frame, area.nextSibling);
541
- else
542
- area.parentNode.appendChild(frame);
543
- }
544
-
545
- area.style.display = "none";
546
- var mirror = new CodeMirror(insert, options);
547
- mirror.save = updateField;
548
- mirror.toTextArea = function() {
549
- updateField();
550
- area.parentNode.removeChild(mirror.wrapping);
551
- area.style.display = "";
552
- if (area.form) {
553
- try {area.form.submit = realSubmit;} catch(e) {}
554
- if (typeof area.form.removeEventListener == "function")
555
- area.form.removeEventListener("submit", updateField, false);
556
- else
557
- area.form.detachEvent("onsubmit", updateField);
558
- }
559
- };
560
-
561
- return mirror;
562
- };
563
-
564
- CodeMirror.isProbablySupported = function() {
565
- // This is rather awful, but can be useful.
566
- var match;
567
- if (window.opera)
568
- return Number(window.opera.version()) >= 9.52;
569
- else if (/Apple Computer, Inc/.test(navigator.vendor) && (match = navigator.userAgent.match(/Version\/(\d+(?:\.\d+)?)\./)))
570
- return Number(match[1]) >= 3;
571
- else if (document.selection && window.ActiveXObject && (match = navigator.userAgent.match(/MSIE (\d+(?:\.\d*)?)\b/)))
572
- return Number(match[1]) >= 6;
573
- else if (match = navigator.userAgent.match(/gecko\/(\d{8})/i))
574
- return Number(match[1]) >= 20050901;
575
- else if (match = navigator.userAgent.match(/AppleWebKit\/(\d+)/))
576
- return Number(match[1]) >= 525;
577
- else
578
- return null;
579
- };
580
-
581
- return CodeMirror;
582
- })();