mdbe 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/app.rb +182 -0
- data/bin/mdbe +5 -0
- data/config.ru +2 -0
- data/environment.rb +8 -0
- data/lib/mdbe.rb +39 -0
- data/lib/mdbe/action_controller_debug_patch.rb +12 -0
- data/lib/mdbe/code_evaluation.rb +46 -0
- data/lib/mdbe/database_views.rb +24 -0
- data/lib/mdbe/database_views/abstract_dictionary.rb +69 -0
- data/lib/mdbe/database_views/abstract_exception.rb +25 -0
- data/lib/mdbe/database_views/array.rb +28 -0
- data/lib/mdbe/database_views/boolean.rb +12 -0
- data/lib/mdbe/database_views/class.rb +46 -0
- data/lib/mdbe/database_views/exception.rb +3 -0
- data/lib/mdbe/database_views/execblock.rb +5 -0
- data/lib/mdbe/database_views/fixnum.rb +5 -0
- data/lib/mdbe/database_views/float.rb +5 -0
- data/lib/mdbe/database_views/globals.rb +2 -0
- data/lib/mdbe/database_views/gsnmethod.rb +29 -0
- data/lib/mdbe/database_views/hash.rb +5 -0
- data/lib/mdbe/database_views/maglev_record.rb +42 -0
- data/lib/mdbe/database_views/module.rb +103 -0
- data/lib/mdbe/database_views/nilclass.rb +5 -0
- data/lib/mdbe/database_views/object.rb +80 -0
- data/lib/mdbe/database_views/proc.rb +3 -0
- data/lib/mdbe/database_views/repository.rb +3 -0
- data/lib/mdbe/database_views/ruby_workspace.rb +5 -0
- data/lib/mdbe/database_views/smalltalk_classes.rb +34 -0
- data/lib/mdbe/database_views/smalltalk_classes.st +60 -0
- data/lib/mdbe/database_views/string.rb +31 -0
- data/lib/mdbe/database_views/symbol.rb +32 -0
- data/lib/mdbe/database_views/system.rb +61 -0
- data/lib/mdbe/database_views/thread.rb +101 -0
- data/lib/mdbe/debug_server.rb +22 -0
- data/lib/mdbe/halt.rb +42 -0
- data/lib/mdbe/ruby_workspace.rb +29 -0
- data/lib/mdbe/version.rb +3 -0
- data/lib/tasks/maglev-database-explorer_tasks.rake +4 -0
- data/public/LICENSE +35 -0
- data/public/amber/CHANGELOG +65 -0
- data/public/amber/LICENSE +22 -0
- data/public/amber/Makefile +53 -0
- data/public/amber/README.md +30 -0
- data/public/amber/bin/amber +3 -0
- data/public/amber/bin/amberc +352 -0
- data/public/amber/bin/nodecompile.js +33 -0
- data/public/amber/bin/server +3 -0
- data/public/amber/bin/server.bat +3 -0
- data/public/amber/css/amber-normalize.css +468 -0
- data/public/amber/css/amber-normalize.less +501 -0
- data/public/amber/css/amber.css +539 -0
- data/public/amber/css/documentation.css +84 -0
- data/public/amber/css/profstef.css +75 -0
- data/public/amber/css/style.css +313 -0
- data/public/amber/documentation.html +37 -0
- data/public/amber/examples/Makefile +23 -0
- data/public/amber/examples/README +4 -0
- data/public/amber/examples/android/helloamber/AndroidManifest.xml +19 -0
- data/public/amber/examples/android/helloamber/HelloAmber.st +13 -0
- data/public/amber/examples/android/helloamber/Makefile +56 -0
- data/public/amber/examples/android/helloamber/README.md +80 -0
- data/public/amber/examples/android/helloamber/ant.properties +17 -0
- data/public/amber/examples/android/helloamber/assets/index.html +15 -0
- data/public/amber/examples/android/helloamber/assets/jquery-1.7.2.min.js +4 -0
- data/public/amber/examples/android/helloamber/build.xml +83 -0
- data/public/amber/examples/android/helloamber/local.properties +10 -0
- data/public/amber/examples/android/helloamber/proguard-project.txt +20 -0
- data/public/amber/examples/android/helloamber/project.properties +14 -0
- data/public/amber/examples/android/helloamber/res/layout/main.xml +6 -0
- data/public/amber/examples/android/helloamber/res/values/strings.xml +4 -0
- data/public/amber/examples/android/helloamber/src/org/amberlang/android/helloamber/HelloAmber.java +59 -0
- data/public/amber/examples/myproject/index.html +16 -0
- data/public/amber/examples/nodejs/README +9 -0
- data/public/amber/examples/nodejs/benchfib/Benchfib.st +124 -0
- data/public/amber/examples/nodejs/benchfib/Makefile +8 -0
- data/public/amber/examples/nodejs/benchfib/benchfib +1 -0
- data/public/amber/examples/nodejs/hello/Hello.st +9 -0
- data/public/amber/examples/nodejs/hello/Makefile +8 -0
- data/public/amber/examples/nodejs/hello/README +13 -0
- data/public/amber/examples/nodejs/hello/hello +1 -0
- data/public/amber/examples/nodejs/meta/Makefile +8 -0
- data/public/amber/examples/nodejs/meta/MyScript.st +27 -0
- data/public/amber/examples/nodejs/meta/meta +1 -0
- data/public/amber/examples/nodejs/pystone/Makefile +8 -0
- data/public/amber/examples/nodejs/pystone/Pystone.st +306 -0
- data/public/amber/examples/nodejs/pystone/pystone +1 -0
- data/public/amber/examples/nodejs/trivialserver/Makefile +8 -0
- data/public/amber/examples/nodejs/trivialserver/TrivialServer.st +51 -0
- data/public/amber/examples/nodejs/trivialserver/trivial +1 -0
- data/public/amber/examples/presentation/esug2011/images/asterix.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/background_box.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/background_header.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/balloon.jpg +0 -0
- data/public/amber/examples/presentation/esug2011/images/balloon_header.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/devices.jpg +0 -0
- data/public/amber/examples/presentation/esug2011/images/enyo.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/ide_star_wars.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/nodejs.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/terminal.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/webos.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/amber.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/ambrhino.jpg +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/nodejs.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/pharo.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/php.gif +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/rails.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/arrow-next.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/arrow-prev.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/closedhand.cur +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/openhand.cur +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/shadow-top-back.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/shadow-top-forward.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/shadow.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/jquery.booklet.1.2.0.css +100 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/jquery.booklet.1.2.0.js +1232 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/jquery.booklet.1.2.0.min.js +13 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/jquery.easing.1.3.js +38 -0
- data/public/amber/examples/presentation/index.html +17 -0
- data/public/amber/examples/presentation/js/Presentation.deploy.js +1922 -0
- data/public/amber/examples/presentation/js/Presentation.js +2712 -0
- data/public/amber/examples/presentation/st/Presentation.st +1996 -0
- data/public/amber/examples/trysmalltalk/index.html +18 -0
- data/public/amber/examples/trysmalltalk/js/TrySmalltalk.deploy.js +837 -0
- data/public/amber/examples/trysmalltalk/js/TrySmalltalk.js +1206 -0
- data/public/amber/examples/trysmalltalk/st/TrySmalltalk.st +964 -0
- data/public/amber/examples/twitterwall/css/twitterwall.css +19 -0
- data/public/amber/examples/twitterwall/index.html +35 -0
- data/public/amber/examples/twitterwall/js/TwitterWall.deploy.js +116 -0
- data/public/amber/examples/twitterwall/js/TwitterWall.js +146 -0
- data/public/amber/examples/twitterwall/st/TwitterWall.st +91 -0
- data/public/amber/examples/webos/README +11 -0
- data/public/amber/examples/webos/eris/DuckQwaq.wav +0 -0
- data/public/amber/examples/webos/eris/EnyoAmber.st +36 -0
- data/public/amber/examples/webos/eris/Eris.css +0 -0
- data/public/amber/examples/webos/eris/Eris.st +86 -0
- data/public/amber/examples/webos/eris/Makefile +37 -0
- data/public/amber/examples/webos/eris/README +3 -0
- data/public/amber/examples/webos/eris/appinfo.json +10 -0
- data/public/amber/examples/webos/eris/index.html +12 -0
- data/public/amber/examples/webos/helloamber/EnyoAmber.st +36 -0
- data/public/amber/examples/webos/helloamber/HelloAmber.st +86 -0
- data/public/amber/examples/webos/helloamber/Makefile +38 -0
- data/public/amber/examples/webos/helloamber/README +5 -0
- data/public/amber/examples/webos/helloamber/appinfo.json +10 -0
- data/public/amber/examples/webos/helloamber/index.html +12 -0
- data/public/amber/favicon.ico +0 -0
- data/public/amber/images/amber.png +0 -0
- data/public/amber/images/amber.svg +706 -0
- data/public/amber/images/amber_small.png +0 -0
- data/public/amber/images/off.amber.png +0 -0
- data/public/amber/images/off.png +0 -0
- data/public/amber/images/offHover.amber.png +0 -0
- data/public/amber/images/offHover.png +0 -0
- data/public/amber/images/presentation.png +0 -0
- data/public/amber/images/profstef.png +0 -0
- data/public/amber/images/sprite.amber.png +0 -0
- data/public/amber/images/sprite.png +0 -0
- data/public/amber/images/tinylogo.amber.png +0 -0
- data/public/amber/images/tinylogo.png +0 -0
- data/public/amber/images/twitterwall.png +0 -0
- data/public/amber/index.html +55 -0
- data/public/amber/js/Additional-Examples.deploy.js +15 -0
- data/public/amber/js/Additional-Examples.js +21 -0
- data/public/amber/js/Benchfib.deploy.js +132 -0
- data/public/amber/js/Benchfib.js +167 -0
- data/public/amber/js/Canvas.deploy.js +2446 -0
- data/public/amber/js/Canvas.js +3547 -0
- data/public/amber/js/Compiler-Tests.deploy.js +97 -0
- data/public/amber/js/Compiler-Tests.js +137 -0
- data/public/amber/js/Compiler.deploy.js +1877 -0
- data/public/amber/js/Compiler.js +2622 -0
- data/public/amber/js/Documentation.deploy.js +961 -0
- data/public/amber/js/Documentation.js +1376 -0
- data/public/amber/js/Examples.deploy.js +53 -0
- data/public/amber/js/Examples.js +73 -0
- data/public/amber/js/IDE.deploy.js +3557 -0
- data/public/amber/js/IDE.js +5002 -0
- data/public/amber/js/Kernel-Announcements.deploy.js +107 -0
- data/public/amber/js/Kernel-Announcements.js +152 -0
- data/public/amber/js/Kernel-Classes.deploy.js +774 -0
- data/public/amber/js/Kernel-Classes.js +1095 -0
- data/public/amber/js/Kernel-Collections.deploy.js +3121 -0
- data/public/amber/js/Kernel-Collections.js +4427 -0
- data/public/amber/js/Kernel-Exceptions.deploy.js +244 -0
- data/public/amber/js/Kernel-Exceptions.js +349 -0
- data/public/amber/js/Kernel-Methods.deploy.js +573 -0
- data/public/amber/js/Kernel-Methods.js +807 -0
- data/public/amber/js/Kernel-Objects.deploy.js +2877 -0
- data/public/amber/js/Kernel-Objects.js +4107 -0
- data/public/amber/js/Kernel-Tests.deploy.js +1513 -0
- data/public/amber/js/Kernel-Tests.js +2053 -0
- data/public/amber/js/Kernel-Transcript.deploy.js +142 -0
- data/public/amber/js/Kernel-Transcript.js +202 -0
- data/public/amber/js/Maglev-Core.deploy.js +2996 -0
- data/public/amber/js/Maglev-Core.js +4246 -0
- data/public/amber/js/Maglev-Database-Explorer.deploy.js +4476 -0
- data/public/amber/js/Maglev-Database-Explorer.js +6232 -0
- data/public/amber/js/Maglev-Vendor.deploy.js +350 -0
- data/public/amber/js/Maglev-Vendor.js +465 -0
- data/public/amber/js/README.md +5 -0
- data/public/amber/js/SUnit.deploy.js +351 -0
- data/public/amber/js/SUnit.js +501 -0
- data/public/amber/js/amber.js +273 -0
- data/public/amber/js/boot.js +602 -0
- data/public/amber/js/compat.js +22 -0
- data/public/amber/js/init.js +9 -0
- data/public/amber/js/lib/CodeMirror/LICENSE +19 -0
- data/public/amber/js/lib/CodeMirror/active-line.js +39 -0
- data/public/amber/js/lib/CodeMirror/amber.css +21 -0
- data/public/amber/js/lib/CodeMirror/codemirror.css +67 -0
- data/public/amber/js/lib/CodeMirror/codemirror.js +2144 -0
- data/public/amber/js/lib/CodeMirror/smalltalk.js +134 -0
- data/public/amber/js/lib/jQuery/jquery-1.4.4.min.js +167 -0
- data/public/amber/js/lib/jQuery/jquery-1.6.4.min.js +4 -0
- data/public/amber/js/lib/jQuery/jquery-ui-1.8.16.custom.min.js +791 -0
- data/public/amber/js/lib/jQuery/jquery.textarea.js +267 -0
- data/public/amber/js/lib/peg-0.6.2.min.js +2 -0
- data/public/amber/js/lib/showdown.js +419 -0
- data/public/amber/js/parser.js +4222 -0
- data/public/amber/js/parser.pegjs +223 -0
- data/public/amber/learn.html +40 -0
- data/public/amber/repl/Makefile +8 -0
- data/public/amber/repl/REPL.js +124 -0
- data/public/amber/repl/REPL.st +56 -0
- data/public/amber/repl/amber.js +18085 -0
- data/public/amber/server/FileServer.st +576 -0
- data/public/amber/server/Makefile +8 -0
- data/public/amber/server/server.js +13049 -0
- data/public/amber/st/Benchfib.js +297 -0
- data/public/amber/st/Benchfib.st +124 -0
- data/public/amber/st/Canvas.st +968 -0
- data/public/amber/st/Compiler-Tests.st +471 -0
- data/public/amber/st/Compiler.st +1445 -0
- data/public/amber/st/Documentation.st +758 -0
- data/public/amber/st/Examples.js +100 -0
- data/public/amber/st/Examples.st +38 -0
- data/public/amber/st/IDE.st +2404 -0
- data/public/amber/st/Kernel-Announcements.st +61 -0
- data/public/amber/st/Kernel-Classes.st +462 -0
- data/public/amber/st/Kernel-Collections.st +1611 -0
- data/public/amber/st/Kernel-Exceptions.st +124 -0
- data/public/amber/st/Kernel-Methods.st +291 -0
- data/public/amber/st/Kernel-Objects.st +1587 -0
- data/public/amber/st/Kernel-Tests.st +953 -0
- data/public/amber/st/Kernel-Transcript.st +70 -0
- data/public/amber/st/Maglev-Core.st +1694 -0
- data/public/amber/st/Maglev-Database-Explorer.st +3148 -0
- data/public/amber/st/Maglev-Vendor.st +151 -0
- data/public/amber/st/Makefile +104 -0
- data/public/amber/st/README.md +4 -0
- data/public/amber/st/SUnit.st +172 -0
- data/public/css/bootstrap-combined.no-icons.min.css +731 -0
- data/public/css/bootstrap.css +6811 -0
- data/public/css/images/animated-overlay.gif +0 -0
- data/public/css/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/public/css/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/public/css/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/public/css/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/public/css/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/public/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/css/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/public/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/public/css/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/public/css/images/ui-icons_222222_256x240.png +0 -0
- data/public/css/images/ui-icons_228ef1_256x240.png +0 -0
- data/public/css/images/ui-icons_ef8c08_256x240.png +0 -0
- data/public/css/images/ui-icons_ffd27a_256x240.png +0 -0
- data/public/css/images/ui-icons_ffffff_256x240.png +0 -0
- data/public/css/jquery-ui.min.css +5 -0
- data/public/css/smalltalk_code.css +42 -0
- data/public/css/style.css +210 -0
- data/public/images/bg_tile.png +0 -0
- data/public/images/maglev-logo.gif +0 -0
- data/public/images/mchammer.gif +0 -0
- data/public/images/rails_tiny.png +0 -0
- data/public/images/ruby.png +0 -0
- data/public/images/ruby_smalltalk_bridge.png +0 -0
- data/public/images/smalltalk.png +0 -0
- data/public/img/glyphicons-halflings.png +0 -0
- data/public/index.html +118 -0
- data/public/libs/bootstrap.min.js +7 -0
- data/public/libs/codemirror/CONTRIBUTING.md +72 -0
- data/public/libs/codemirror/LICENSE +23 -0
- data/public/libs/codemirror/README.md +11 -0
- data/public/libs/codemirror/addon/dialog/dialog.css +32 -0
- data/public/libs/codemirror/addon/dialog/dialog.js +80 -0
- data/public/libs/codemirror/addon/display/placeholder.js +54 -0
- data/public/libs/codemirror/addon/edit/closebrackets.js +54 -0
- data/public/libs/codemirror/addon/edit/closetag.js +86 -0
- data/public/libs/codemirror/addon/edit/continuecomment.js +44 -0
- data/public/libs/codemirror/addon/edit/continuelist.js +25 -0
- data/public/libs/codemirror/addon/edit/matchbrackets.js +82 -0
- data/public/libs/codemirror/addon/fold/brace-fold.js +31 -0
- data/public/libs/codemirror/addon/fold/foldcode.js +32 -0
- data/public/libs/codemirror/addon/fold/indent-fold.js +11 -0
- data/public/libs/codemirror/addon/fold/xml-fold.js +64 -0
- data/public/libs/codemirror/addon/hint/html-hint.js +582 -0
- data/public/libs/codemirror/addon/hint/javascript-hint.js +142 -0
- data/public/libs/codemirror/addon/hint/pig-hint.js +117 -0
- data/public/libs/codemirror/addon/hint/python-hint.js +93 -0
- data/public/libs/codemirror/addon/hint/show-hint.css +38 -0
- data/public/libs/codemirror/addon/hint/show-hint.js +180 -0
- data/public/libs/codemirror/addon/hint/xml-hint.js +118 -0
- data/public/libs/codemirror/addon/lint/javascript-lint.js +127 -0
- data/public/libs/codemirror/addon/lint/json-lint.js +14 -0
- data/public/libs/codemirror/addon/lint/lint.css +96 -0
- data/public/libs/codemirror/addon/lint/lint.js +197 -0
- data/public/libs/codemirror/addon/mode/loadmode.js +51 -0
- data/public/libs/codemirror/addon/mode/multiplex.js +95 -0
- data/public/libs/codemirror/addon/mode/overlay.js +59 -0
- data/public/libs/codemirror/addon/runmode/colorize.js +29 -0
- data/public/libs/codemirror/addon/runmode/runmode-standalone.js +130 -0
- data/public/libs/codemirror/addon/runmode/runmode.js +52 -0
- data/public/libs/codemirror/addon/runmode/runmode.node.js +89 -0
- data/public/libs/codemirror/addon/search/match-highlighter.js +60 -0
- data/public/libs/codemirror/addon/search/search.js +131 -0
- data/public/libs/codemirror/addon/search/searchcursor.js +133 -0
- data/public/libs/codemirror/addon/selection/active-line.js +39 -0
- data/public/libs/codemirror/addon/selection/mark-selection.js +34 -0
- data/public/libs/codemirror/bin/compress +91 -0
- data/public/libs/codemirror/bin/lint +11 -0
- data/public/libs/codemirror/demo/activeline.html +70 -0
- data/public/libs/codemirror/demo/bidi.html +61 -0
- data/public/libs/codemirror/demo/btree.html +87 -0
- data/public/libs/codemirror/demo/buffers.html +98 -0
- data/public/libs/codemirror/demo/changemode.html +50 -0
- data/public/libs/codemirror/demo/closebrackets.html +63 -0
- data/public/libs/codemirror/demo/closetag.html +37 -0
- data/public/libs/codemirror/demo/complete.html +70 -0
- data/public/libs/codemirror/demo/emacs.html +60 -0
- data/public/libs/codemirror/demo/folding.html +69 -0
- data/public/libs/codemirror/demo/fullscreen.html +147 -0
- data/public/libs/codemirror/demo/html5complete.html +92 -0
- data/public/libs/codemirror/demo/indentwrap.html +49 -0
- data/public/libs/codemirror/demo/lint.html +90 -0
- data/public/libs/codemirror/demo/loadmode.html +40 -0
- data/public/libs/codemirror/demo/marker.html +59 -0
- data/public/libs/codemirror/demo/markselection.html +36 -0
- data/public/libs/codemirror/demo/matchhighlighter.html +38 -0
- data/public/libs/codemirror/demo/multiplex.html +60 -0
- data/public/libs/codemirror/demo/mustache.html +59 -0
- data/public/libs/codemirror/demo/placeholder.html +36 -0
- data/public/libs/codemirror/demo/preview.html +76 -0
- data/public/libs/codemirror/demo/resize.html +49 -0
- data/public/libs/codemirror/demo/runmode.html +50 -0
- data/public/libs/codemirror/demo/search.html +85 -0
- data/public/libs/codemirror/demo/spanaffectswrapping_shim.html +73 -0
- data/public/libs/codemirror/demo/theme.html +89 -0
- data/public/libs/codemirror/demo/variableheight.html +52 -0
- data/public/libs/codemirror/demo/vim.html +65 -0
- data/public/libs/codemirror/demo/visibletabs.html +53 -0
- data/public/libs/codemirror/demo/widget.html +74 -0
- data/public/libs/codemirror/demo/xmlcomplete.html +81 -0
- data/public/libs/codemirror/index.html +487 -0
- data/public/libs/codemirror/keymap/emacs.js +30 -0
- data/public/libs/codemirror/keymap/vim.js +3044 -0
- data/public/libs/codemirror/lib/codemirror.css +253 -0
- data/public/libs/codemirror/lib/codemirror.js +5585 -0
- data/public/libs/codemirror/mode/apl/apl.js +160 -0
- data/public/libs/codemirror/mode/apl/index.html +61 -0
- data/public/libs/codemirror/mode/asterisk/asterisk.js +183 -0
- data/public/libs/codemirror/mode/asterisk/index.html +142 -0
- data/public/libs/codemirror/mode/clike/clike.js +302 -0
- data/public/libs/codemirror/mode/clike/index.html +103 -0
- data/public/libs/codemirror/mode/clike/scala.html +767 -0
- data/public/libs/codemirror/mode/clojure/clojure.js +222 -0
- data/public/libs/codemirror/mode/clojure/index.html +76 -0
- data/public/libs/codemirror/mode/coffeescript/LICENSE +22 -0
- data/public/libs/codemirror/mode/coffeescript/coffeescript.js +346 -0
- data/public/libs/codemirror/mode/coffeescript/index.html +728 -0
- data/public/libs/codemirror/mode/commonlisp/commonlisp.js +101 -0
- data/public/libs/codemirror/mode/commonlisp/index.html +165 -0
- data/public/libs/codemirror/mode/css/css.js +567 -0
- data/public/libs/codemirror/mode/css/index.html +58 -0
- data/public/libs/codemirror/mode/css/scss.html +145 -0
- data/public/libs/codemirror/mode/css/scss_test.js +80 -0
- data/public/libs/codemirror/mode/css/test.js +113 -0
- data/public/libs/codemirror/mode/d/d.js +205 -0
- data/public/libs/codemirror/mode/d/index.html +262 -0
- data/public/libs/codemirror/mode/diff/diff.js +32 -0
- data/public/libs/codemirror/mode/diff/index.html +105 -0
- data/public/libs/codemirror/mode/ecl/ecl.js +192 -0
- data/public/libs/codemirror/mode/ecl/index.html +39 -0
- data/public/libs/codemirror/mode/erlang/erlang.js +463 -0
- data/public/libs/codemirror/mode/erlang/index.html +64 -0
- data/public/libs/codemirror/mode/gas/gas.js +326 -0
- data/public/libs/codemirror/mode/gas/index.html +57 -0
- data/public/libs/codemirror/mode/gfm/gfm.js +96 -0
- data/public/libs/codemirror/mode/gfm/index.html +74 -0
- data/public/libs/codemirror/mode/gfm/test.js +112 -0
- data/public/libs/codemirror/mode/go/go.js +165 -0
- data/public/libs/codemirror/mode/go/index.html +74 -0
- data/public/libs/codemirror/mode/groovy/groovy.js +210 -0
- data/public/libs/codemirror/mode/groovy/index.html +73 -0
- data/public/libs/codemirror/mode/haskell/haskell.js +242 -0
- data/public/libs/codemirror/mode/haskell/index.html +62 -0
- data/public/libs/codemirror/mode/haxe/haxe.js +429 -0
- data/public/libs/codemirror/mode/haxe/index.html +90 -0
- data/public/libs/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/public/libs/codemirror/mode/htmlembedded/index.html +49 -0
- data/public/libs/codemirror/mode/htmlmixed/htmlmixed.js +104 -0
- data/public/libs/codemirror/mode/htmlmixed/index.html +73 -0
- data/public/libs/codemirror/mode/http/http.js +98 -0
- data/public/libs/codemirror/mode/http/index.html +32 -0
- data/public/libs/codemirror/mode/javascript/index.html +92 -0
- data/public/libs/codemirror/mode/javascript/javascript.js +467 -0
- data/public/libs/codemirror/mode/javascript/typescript.html +48 -0
- data/public/libs/codemirror/mode/jinja2/index.html +38 -0
- data/public/libs/codemirror/mode/jinja2/jinja2.js +42 -0
- data/public/libs/codemirror/mode/less/index.html +741 -0
- data/public/libs/codemirror/mode/less/less.js +266 -0
- data/public/libs/codemirror/mode/livescript/LICENSE +23 -0
- data/public/libs/codemirror/mode/livescript/index.html +446 -0
- data/public/libs/codemirror/mode/livescript/livescript.js +267 -0
- data/public/libs/codemirror/mode/livescript/livescript.ls +266 -0
- data/public/libs/codemirror/mode/lua/index.html +74 -0
- data/public/libs/codemirror/mode/lua/lua.js +140 -0
- data/public/libs/codemirror/mode/markdown/index.html +344 -0
- data/public/libs/codemirror/mode/markdown/markdown.js +526 -0
- data/public/libs/codemirror/mode/markdown/test.js +636 -0
- data/public/libs/codemirror/mode/meta.js +75 -0
- data/public/libs/codemirror/mode/mirc/index.html +149 -0
- data/public/libs/codemirror/mode/mirc/mirc.js +177 -0
- data/public/libs/codemirror/mode/ntriples/index.html +33 -0
- data/public/libs/codemirror/mode/ntriples/ntriples.js +170 -0
- data/public/libs/codemirror/mode/ocaml/index.html +131 -0
- data/public/libs/codemirror/mode/ocaml/ocaml.js +113 -0
- data/public/libs/codemirror/mode/pascal/LICENSE +7 -0
- data/public/libs/codemirror/mode/pascal/index.html +48 -0
- data/public/libs/codemirror/mode/pascal/pascal.js +94 -0
- data/public/libs/codemirror/mode/perl/LICENSE +19 -0
- data/public/libs/codemirror/mode/perl/index.html +62 -0
- data/public/libs/codemirror/mode/perl/perl.js +816 -0
- data/public/libs/codemirror/mode/php/index.html +51 -0
- data/public/libs/codemirror/mode/php/php.js +129 -0
- data/public/libs/codemirror/mode/pig/index.html +42 -0
- data/public/libs/codemirror/mode/pig/pig.js +171 -0
- data/public/libs/codemirror/mode/properties/index.html +41 -0
- data/public/libs/codemirror/mode/properties/properties.js +63 -0
- data/public/libs/codemirror/mode/python/LICENSE.txt +21 -0
- data/public/libs/codemirror/mode/python/index.html +135 -0
- data/public/libs/codemirror/mode/python/python.js +340 -0
- data/public/libs/codemirror/mode/q/index.html +131 -0
- data/public/libs/codemirror/mode/q/q.js +124 -0
- data/public/libs/codemirror/mode/r/LICENSE +24 -0
- data/public/libs/codemirror/mode/r/index.html +74 -0
- data/public/libs/codemirror/mode/r/r.js +141 -0
- data/public/libs/codemirror/mode/rpm/changes/changes.js +19 -0
- data/public/libs/codemirror/mode/rpm/changes/index.html +53 -0
- data/public/libs/codemirror/mode/rpm/spec/index.html +99 -0
- data/public/libs/codemirror/mode/rpm/spec/spec.css +5 -0
- data/public/libs/codemirror/mode/rpm/spec/spec.js +66 -0
- data/public/libs/codemirror/mode/rst/LICENSE.txt +21 -0
- data/public/libs/codemirror/mode/rst/index.html +524 -0
- data/public/libs/codemirror/mode/rst/rst.js +550 -0
- data/public/libs/codemirror/mode/ruby/LICENSE +24 -0
- data/public/libs/codemirror/mode/ruby/index.html +173 -0
- data/public/libs/codemirror/mode/ruby/ruby.js +197 -0
- data/public/libs/codemirror/mode/rust/index.html +48 -0
- data/public/libs/codemirror/mode/rust/rust.js +432 -0
- data/public/libs/codemirror/mode/sass/index.html +54 -0
- data/public/libs/codemirror/mode/sass/sass.js +349 -0
- data/public/libs/codemirror/mode/scheme/index.html +65 -0
- data/public/libs/codemirror/mode/scheme/scheme.js +230 -0
- data/public/libs/codemirror/mode/shell/index.html +51 -0
- data/public/libs/codemirror/mode/shell/shell.js +118 -0
- data/public/libs/codemirror/mode/sieve/LICENSE +19 -0
- data/public/libs/codemirror/mode/sieve/index.html +81 -0
- data/public/libs/codemirror/mode/sieve/sieve.js +183 -0
- data/public/libs/codemirror/mode/smalltalk/index.html +57 -0
- data/public/libs/codemirror/mode/smalltalk/smalltalk.js +141 -0
- data/public/libs/codemirror/mode/smarty/index.html +83 -0
- data/public/libs/codemirror/mode/smarty/smarty.js +148 -0
- data/public/libs/codemirror/mode/sparql/index.html +42 -0
- data/public/libs/codemirror/mode/sparql/sparql.js +143 -0
- data/public/libs/codemirror/mode/sql/index.html +68 -0
- data/public/libs/codemirror/mode/sql/sql.js +268 -0
- data/public/libs/codemirror/mode/stex/index.html +98 -0
- data/public/libs/codemirror/mode/stex/stex.js +246 -0
- data/public/libs/codemirror/mode/stex/test.js +117 -0
- data/public/libs/codemirror/mode/tcl/index.html +129 -0
- data/public/libs/codemirror/mode/tcl/tcl.js +131 -0
- data/public/libs/codemirror/mode/tiddlywiki/index.html +142 -0
- data/public/libs/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/public/libs/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/public/libs/codemirror/mode/tiki/index.html +81 -0
- data/public/libs/codemirror/mode/tiki/tiki.css +26 -0
- data/public/libs/codemirror/mode/tiki/tiki.js +308 -0
- data/public/libs/codemirror/mode/turtle/index.html +39 -0
- data/public/libs/codemirror/mode/turtle/turtle.js +145 -0
- data/public/libs/codemirror/mode/vb/LICENSE.txt +21 -0
- data/public/libs/codemirror/mode/vb/index.html +88 -0
- data/public/libs/codemirror/mode/vb/vb.js +259 -0
- data/public/libs/codemirror/mode/vbscript/index.html +42 -0
- data/public/libs/codemirror/mode/vbscript/vbscript.js +26 -0
- data/public/libs/codemirror/mode/velocity/index.html +103 -0
- data/public/libs/codemirror/mode/velocity/velocity.js +144 -0
- data/public/libs/codemirror/mode/verilog/index.html +121 -0
- data/public/libs/codemirror/mode/verilog/verilog.js +182 -0
- data/public/libs/codemirror/mode/xml/index.html +45 -0
- data/public/libs/codemirror/mode/xml/xml.js +328 -0
- data/public/libs/codemirror/mode/xquery/LICENSE +20 -0
- data/public/libs/codemirror/mode/xquery/index.html +221 -0
- data/public/libs/codemirror/mode/xquery/test.js +64 -0
- data/public/libs/codemirror/mode/xquery/xquery.js +450 -0
- data/public/libs/codemirror/mode/yaml/index.html +68 -0
- data/public/libs/codemirror/mode/yaml/yaml.js +95 -0
- data/public/libs/codemirror/mode/z80/index.html +39 -0
- data/public/libs/codemirror/mode/z80/z80.js +85 -0
- data/public/libs/codemirror/package.json +21 -0
- data/public/libs/codemirror/test/doc_test.js +329 -0
- data/public/libs/codemirror/test/driver.js +138 -0
- data/public/libs/codemirror/test/index.html +182 -0
- data/public/libs/codemirror/test/lint/acorn.js +1593 -0
- data/public/libs/codemirror/test/lint/lint.js +112 -0
- data/public/libs/codemirror/test/lint/parse-js.js +1372 -0
- data/public/libs/codemirror/test/lint/walk.js +216 -0
- data/public/libs/codemirror/test/mode_test.css +10 -0
- data/public/libs/codemirror/test/mode_test.js +192 -0
- data/public/libs/codemirror/test/phantom_driver.js +31 -0
- data/public/libs/codemirror/test/run.js +33 -0
- data/public/libs/codemirror/test/test.js +1400 -0
- data/public/libs/codemirror/test/vim_test.js +1688 -0
- data/public/libs/codemirror/theme/ambiance-mobile.css +5 -0
- data/public/libs/codemirror/theme/ambiance.css +75 -0
- data/public/libs/codemirror/theme/blackboard.css +25 -0
- data/public/libs/codemirror/theme/cobalt.css +18 -0
- data/public/libs/codemirror/theme/eclipse.css +25 -0
- data/public/libs/codemirror/theme/elegant.css +10 -0
- data/public/libs/codemirror/theme/erlang-dark.css +21 -0
- data/public/libs/codemirror/theme/lesser-dark.css +44 -0
- data/public/libs/codemirror/theme/midnight.css +52 -0
- data/public/libs/codemirror/theme/monokai.css +28 -0
- data/public/libs/codemirror/theme/neat.css +9 -0
- data/public/libs/codemirror/theme/night.css +21 -0
- data/public/libs/codemirror/theme/rubyblue.css +21 -0
- data/public/libs/codemirror/theme/solarized.css +207 -0
- data/public/libs/codemirror/theme/twilight.css +26 -0
- data/public/libs/codemirror/theme/vibrant-ink.css +27 -0
- data/public/libs/codemirror/theme/xq-dark.css +46 -0
- data/public/libs/codemirror/theme/xq-light.css +43 -0
- data/public/libs/font-awesome/css/font-awesome-ie7.css +983 -0
- data/public/libs/font-awesome/css/font-awesome-ie7.min.css +24 -0
- data/public/libs/font-awesome/css/font-awesome.css +1268 -0
- data/public/libs/font-awesome/css/font-awesome.min.css +24 -0
- data/public/libs/font-awesome/font/FontAwesome.otf +0 -0
- data/public/libs/font-awesome/font/fontawesome-webfont.eot +0 -0
- data/public/libs/font-awesome/font/fontawesome-webfont.svg +339 -0
- data/public/libs/font-awesome/font/fontawesome-webfont.ttf +0 -0
- data/public/libs/font-awesome/font/fontawesome-webfont.woff +0 -0
- data/public/libs/font-awesome/less/bootstrap.less +78 -0
- data/public/libs/font-awesome/less/core.less +132 -0
- data/public/libs/font-awesome/less/extras.less +79 -0
- data/public/libs/font-awesome/less/font-awesome-ie7.less +413 -0
- data/public/libs/font-awesome/less/font-awesome.less +32 -0
- data/public/libs/font-awesome/less/icons.less +330 -0
- data/public/libs/font-awesome/less/mixins.less +34 -0
- data/public/libs/font-awesome/less/path.less +15 -0
- data/public/libs/font-awesome/less/variables.less +9 -0
- data/public/libs/jquery-1.10.0.min.js +6 -0
- data/public/libs/jquery-ui.min.js +12 -0
- data/public/libs/jquery.jsPlumb-1.4.0-all.js +9571 -0
- data/public/libs/jquery.livequery.js +226 -0
- data/public/libs/jsPlumbInitializer.js +72 -0
- data/public/libs/jstree/README.txt +10 -0
- data/public/libs/jstree/_demo/_dump.sql +20 -0
- data/public/libs/jstree/_demo/_inc/__mysql_errors.log +0 -0
- data/public/libs/jstree/_demo/_inc/class._database.php +146 -0
- data/public/libs/jstree/_demo/_inc/class._database_i.php +152 -0
- data/public/libs/jstree/_demo/_inc/class.tree.php +602 -0
- data/public/libs/jstree/_demo/_install.txt +6 -0
- data/public/libs/jstree/_demo/config.php +14 -0
- data/public/libs/jstree/_demo/file.png +0 -0
- data/public/libs/jstree/_demo/folder.png +0 -0
- data/public/libs/jstree/_demo/index.html +461 -0
- data/public/libs/jstree/_demo/root.png +0 -0
- data/public/libs/jstree/_demo/server.php +69 -0
- data/public/libs/jstree/_docs/!style.css +48 -0
- data/public/libs/jstree/_docs/_drive.png +0 -0
- data/public/libs/jstree/_docs/_html_data.html +2 -0
- data/public/libs/jstree/_docs/_json_data.json +4 -0
- data/public/libs/jstree/_docs/_search_data.json +6 -0
- data/public/libs/jstree/_docs/_search_result.json +1 -0
- data/public/libs/jstree/_docs/_xml_flat.xml +12 -0
- data/public/libs/jstree/_docs/_xml_nest.xml +18 -0
- data/public/libs/jstree/_docs/checkbox.html +171 -0
- data/public/libs/jstree/_docs/contextmenu.html +121 -0
- data/public/libs/jstree/_docs/cookies.html +97 -0
- data/public/libs/jstree/_docs/core.html +689 -0
- data/public/libs/jstree/_docs/crrm.html +316 -0
- data/public/libs/jstree/_docs/dnd.html +199 -0
- data/public/libs/jstree/_docs/hotkeys.html +82 -0
- data/public/libs/jstree/_docs/html_data.html +175 -0
- data/public/libs/jstree/_docs/index.html +86 -0
- data/public/libs/jstree/_docs/json_data.html +249 -0
- data/public/libs/jstree/_docs/languages.html +152 -0
- data/public/libs/jstree/_docs/logo.png +0 -0
- data/public/libs/jstree/_docs/search.html +153 -0
- data/public/libs/jstree/_docs/sort.html +85 -0
- data/public/libs/jstree/_docs/syntax/!script.js +2232 -0
- data/public/libs/jstree/_docs/syntax/!style.css +511 -0
- data/public/libs/jstree/_docs/syntax/clipboard.swf +0 -0
- data/public/libs/jstree/_docs/syntax/help.png +0 -0
- data/public/libs/jstree/_docs/syntax/magnifier.png +0 -0
- data/public/libs/jstree/_docs/syntax/page_white_code.png +0 -0
- data/public/libs/jstree/_docs/syntax/page_white_copy.png +0 -0
- data/public/libs/jstree/_docs/syntax/printer.png +0 -0
- data/public/libs/jstree/_docs/syntax/wrapping.png +0 -0
- data/public/libs/jstree/_docs/themeroller.html +107 -0
- data/public/libs/jstree/_docs/themes.html +127 -0
- data/public/libs/jstree/_docs/types.html +178 -0
- data/public/libs/jstree/_docs/ui.html +197 -0
- data/public/libs/jstree/_docs/unique.html +85 -0
- data/public/libs/jstree/_docs/xml_data.html +218 -0
- data/public/libs/jstree/_lib/jquery.cookie.js +96 -0
- data/public/libs/jstree/_lib/jquery.hotkeys.js +99 -0
- data/public/libs/jstree/_lib/jquery.js +5 -0
- data/public/libs/jstree/jquery.jstree.js +4564 -0
- data/public/libs/jstree/themes/apple/bg.jpg +0 -0
- data/public/libs/jstree/themes/apple/d.png +0 -0
- data/public/libs/jstree/themes/apple/dot_for_ie.gif +0 -0
- data/public/libs/jstree/themes/apple/style.css +61 -0
- data/public/libs/jstree/themes/apple/throbber.gif +0 -0
- data/public/libs/jstree/themes/classic/d.gif +0 -0
- data/public/libs/jstree/themes/classic/d.png +0 -0
- data/public/libs/jstree/themes/classic/dot_for_ie.gif +0 -0
- data/public/libs/jstree/themes/classic/style.css +77 -0
- data/public/libs/jstree/themes/classic/throbber.gif +0 -0
- data/public/libs/jstree/themes/default-rtl/d.gif +0 -0
- data/public/libs/jstree/themes/default-rtl/d.png +0 -0
- data/public/libs/jstree/themes/default-rtl/dots.gif +0 -0
- data/public/libs/jstree/themes/default-rtl/style.css +84 -0
- data/public/libs/jstree/themes/default-rtl/throbber.gif +0 -0
- data/public/libs/jstree/themes/default/d.gif +0 -0
- data/public/libs/jstree/themes/default/d.png +0 -0
- data/public/libs/jstree/themes/default/style.css +74 -0
- data/public/libs/jstree/themes/default/throbber.gif +0 -0
- data/public/themes/geo-bootstrap/README.md +25 -0
- data/public/themes/geo-bootstrap/img/flames.gif +0 -0
- data/public/themes/geo-bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/public/themes/geo-bootstrap/img/glyphicons-halflings.png +0 -0
- data/public/themes/geo-bootstrap/img/microfab.gif +0 -0
- data/public/themes/geo-bootstrap/img/progress.gif +0 -0
- data/public/themes/geo-bootstrap/img/rainbow.gif +0 -0
- data/public/themes/geo-bootstrap/img/stars.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/7upspot.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/americanflag.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/community.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/computer-01.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/computer.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/construction.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/counter.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/counter2.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider1.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider2.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider3.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider4.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/drudgesiren.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/emailme.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/funky.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/geocities.jpg +0 -0
- data/public/themes/geo-bootstrap/img/test/hacker.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/heart.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/hot.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/ie_logo.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/mailkitten.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/mchammer.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/new.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/new2.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/noframes.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/notepad.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/ns_logo.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/sign-in.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/spinningearth.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/underconstruction.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/wabwalk.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/webtrips.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/yahooweek.gif +0 -0
- data/public/themes/geo-bootstrap/package.json +21 -0
- data/public/themes/geo-bootstrap/swatch/bootstrap-responsive.css +1109 -0
- data/public/themes/geo-bootstrap/swatch/bootstrap-responsive.min.css +9 -0
- data/public/themes/geo-bootstrap/swatch/bootstrap.css +6462 -0
- data/public/themes/geo-bootstrap/swatch/bootstrap.min.css +9 -0
- metadata +791 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
var lint = require("./lint/lint");
|
4
|
+
|
5
|
+
lint.checkDir("mode");
|
6
|
+
lint.checkDir("lib");
|
7
|
+
lint.checkDir("addon");
|
8
|
+
|
9
|
+
var ok = lint.success();
|
10
|
+
|
11
|
+
var files = new (require('node-static').Server)('.');
|
12
|
+
|
13
|
+
var server = require('http').createServer(function (req, res) {
|
14
|
+
req.addListener('end', function () {
|
15
|
+
files.serve(req, res);
|
16
|
+
});
|
17
|
+
}).addListener('error', function (err) {
|
18
|
+
throw err;
|
19
|
+
}).listen(3000, function () {
|
20
|
+
var child_process = require('child_process');
|
21
|
+
child_process.exec("which phantomjs", function (err) {
|
22
|
+
if (err) {
|
23
|
+
console.error("PhantomJS is not installed. Download from http://phantomjs.org");
|
24
|
+
process.exit(1);
|
25
|
+
}
|
26
|
+
var cmd = 'phantomjs test/phantom_driver.js';
|
27
|
+
child_process.exec(cmd, function (err, stdout) {
|
28
|
+
server.close();
|
29
|
+
console.log(stdout);
|
30
|
+
process.exit(err || !ok ? 1 : 0);
|
31
|
+
});
|
32
|
+
});
|
33
|
+
});
|
@@ -0,0 +1,1400 @@
|
|
1
|
+
var Pos = CodeMirror.Pos;
|
2
|
+
|
3
|
+
function forEach(arr, f) {
|
4
|
+
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
5
|
+
}
|
6
|
+
|
7
|
+
function addDoc(cm, width, height) {
|
8
|
+
var content = [], line = "";
|
9
|
+
for (var i = 0; i < width; ++i) line += "x";
|
10
|
+
for (var i = 0; i < height; ++i) content.push(line);
|
11
|
+
cm.setValue(content.join("\n"));
|
12
|
+
}
|
13
|
+
|
14
|
+
function byClassName(elt, cls) {
|
15
|
+
if (elt.getElementsByClassName) return elt.getElementsByClassName(cls);
|
16
|
+
var found = [], re = new RegExp("\\b" + cls + "\\b");
|
17
|
+
function search(elt) {
|
18
|
+
if (elt.nodeType == 3) return;
|
19
|
+
if (re.test(elt.className)) found.push(elt);
|
20
|
+
for (var i = 0, e = elt.childNodes.length; i < e; ++i)
|
21
|
+
search(elt.childNodes[i]);
|
22
|
+
}
|
23
|
+
search(elt);
|
24
|
+
return found;
|
25
|
+
}
|
26
|
+
|
27
|
+
var ie_lt8 = /MSIE [1-7]\b/.test(navigator.userAgent);
|
28
|
+
var mac = /Mac/.test(navigator.platform);
|
29
|
+
var phantom = /PhantomJS/.test(navigator.userAgent);
|
30
|
+
var opera = /Opera\/\./.test(navigator.userAgent);
|
31
|
+
var opera_version = opera && navigator.userAgent.match(/Version\/(\d+\.\d+)/);
|
32
|
+
if (opera_version) opera_version = Number(opera_version);
|
33
|
+
var opera_lt10 = opera && (!opera_version || opera_version < 10);
|
34
|
+
|
35
|
+
test("core_fromTextArea", function() {
|
36
|
+
var te = document.getElementById("code");
|
37
|
+
te.value = "CONTENT";
|
38
|
+
var cm = CodeMirror.fromTextArea(te);
|
39
|
+
is(!te.offsetHeight);
|
40
|
+
eq(cm.getValue(), "CONTENT");
|
41
|
+
cm.setValue("foo\nbar");
|
42
|
+
eq(cm.getValue(), "foo\nbar");
|
43
|
+
cm.save();
|
44
|
+
is(/^foo\r?\nbar$/.test(te.value));
|
45
|
+
cm.setValue("xxx");
|
46
|
+
cm.toTextArea();
|
47
|
+
is(te.offsetHeight);
|
48
|
+
eq(te.value, "xxx");
|
49
|
+
});
|
50
|
+
|
51
|
+
testCM("getRange", function(cm) {
|
52
|
+
eq(cm.getLine(0), "1234");
|
53
|
+
eq(cm.getLine(1), "5678");
|
54
|
+
eq(cm.getLine(2), null);
|
55
|
+
eq(cm.getLine(-1), null);
|
56
|
+
eq(cm.getRange(Pos(0, 0), Pos(0, 3)), "123");
|
57
|
+
eq(cm.getRange(Pos(0, -1), Pos(0, 200)), "1234");
|
58
|
+
eq(cm.getRange(Pos(0, 2), Pos(1, 2)), "34\n56");
|
59
|
+
eq(cm.getRange(Pos(1, 2), Pos(100, 0)), "78");
|
60
|
+
}, {value: "1234\n5678"});
|
61
|
+
|
62
|
+
testCM("replaceRange", function(cm) {
|
63
|
+
eq(cm.getValue(), "");
|
64
|
+
cm.replaceRange("foo\n", Pos(0, 0));
|
65
|
+
eq(cm.getValue(), "foo\n");
|
66
|
+
cm.replaceRange("a\nb", Pos(0, 1));
|
67
|
+
eq(cm.getValue(), "fa\nboo\n");
|
68
|
+
eq(cm.lineCount(), 3);
|
69
|
+
cm.replaceRange("xyzzy", Pos(0, 0), Pos(1, 1));
|
70
|
+
eq(cm.getValue(), "xyzzyoo\n");
|
71
|
+
cm.replaceRange("abc", Pos(0, 0), Pos(10, 0));
|
72
|
+
eq(cm.getValue(), "abc");
|
73
|
+
eq(cm.lineCount(), 1);
|
74
|
+
});
|
75
|
+
|
76
|
+
testCM("selection", function(cm) {
|
77
|
+
cm.setSelection(Pos(0, 4), Pos(2, 2));
|
78
|
+
is(cm.somethingSelected());
|
79
|
+
eq(cm.getSelection(), "11\n222222\n33");
|
80
|
+
eqPos(cm.getCursor(false), Pos(2, 2));
|
81
|
+
eqPos(cm.getCursor(true), Pos(0, 4));
|
82
|
+
cm.setSelection(Pos(1, 0));
|
83
|
+
is(!cm.somethingSelected());
|
84
|
+
eq(cm.getSelection(), "");
|
85
|
+
eqPos(cm.getCursor(true), Pos(1, 0));
|
86
|
+
cm.replaceSelection("abc");
|
87
|
+
eq(cm.getSelection(), "abc");
|
88
|
+
eq(cm.getValue(), "111111\nabc222222\n333333");
|
89
|
+
cm.replaceSelection("def", "end");
|
90
|
+
eq(cm.getSelection(), "");
|
91
|
+
eqPos(cm.getCursor(true), Pos(1, 3));
|
92
|
+
cm.setCursor(Pos(2, 1));
|
93
|
+
eqPos(cm.getCursor(true), Pos(2, 1));
|
94
|
+
cm.setCursor(1, 2);
|
95
|
+
eqPos(cm.getCursor(true), Pos(1, 2));
|
96
|
+
}, {value: "111111\n222222\n333333"});
|
97
|
+
|
98
|
+
testCM("extendSelection", function(cm) {
|
99
|
+
cm.setExtending(true);
|
100
|
+
addDoc(cm, 10, 10);
|
101
|
+
cm.setSelection(Pos(3, 5));
|
102
|
+
eqPos(cm.getCursor("head"), Pos(3, 5));
|
103
|
+
eqPos(cm.getCursor("anchor"), Pos(3, 5));
|
104
|
+
cm.setSelection(Pos(2, 5), Pos(5, 5));
|
105
|
+
eqPos(cm.getCursor("head"), Pos(5, 5));
|
106
|
+
eqPos(cm.getCursor("anchor"), Pos(2, 5));
|
107
|
+
eqPos(cm.getCursor("start"), Pos(2, 5));
|
108
|
+
eqPos(cm.getCursor("end"), Pos(5, 5));
|
109
|
+
cm.setSelection(Pos(5, 5), Pos(2, 5));
|
110
|
+
eqPos(cm.getCursor("head"), Pos(2, 5));
|
111
|
+
eqPos(cm.getCursor("anchor"), Pos(5, 5));
|
112
|
+
eqPos(cm.getCursor("start"), Pos(2, 5));
|
113
|
+
eqPos(cm.getCursor("end"), Pos(5, 5));
|
114
|
+
cm.extendSelection(Pos(3, 2));
|
115
|
+
eqPos(cm.getCursor("head"), Pos(3, 2));
|
116
|
+
eqPos(cm.getCursor("anchor"), Pos(5, 5));
|
117
|
+
cm.extendSelection(Pos(6, 2));
|
118
|
+
eqPos(cm.getCursor("head"), Pos(6, 2));
|
119
|
+
eqPos(cm.getCursor("anchor"), Pos(5, 5));
|
120
|
+
cm.extendSelection(Pos(6, 3), Pos(6, 4));
|
121
|
+
eqPos(cm.getCursor("head"), Pos(6, 4));
|
122
|
+
eqPos(cm.getCursor("anchor"), Pos(5, 5));
|
123
|
+
cm.extendSelection(Pos(0, 3), Pos(0, 4));
|
124
|
+
eqPos(cm.getCursor("head"), Pos(0, 3));
|
125
|
+
eqPos(cm.getCursor("anchor"), Pos(5, 5));
|
126
|
+
cm.extendSelection(Pos(4, 5), Pos(6, 5));
|
127
|
+
eqPos(cm.getCursor("head"), Pos(6, 5));
|
128
|
+
eqPos(cm.getCursor("anchor"), Pos(4, 5));
|
129
|
+
cm.setExtending(false);
|
130
|
+
cm.extendSelection(Pos(0, 3), Pos(0, 4));
|
131
|
+
eqPos(cm.getCursor("head"), Pos(0, 4));
|
132
|
+
eqPos(cm.getCursor("anchor"), Pos(0, 3));
|
133
|
+
});
|
134
|
+
|
135
|
+
testCM("lines", function(cm) {
|
136
|
+
eq(cm.getLine(0), "111111");
|
137
|
+
eq(cm.getLine(1), "222222");
|
138
|
+
eq(cm.getLine(-1), null);
|
139
|
+
cm.removeLine(1);
|
140
|
+
cm.setLine(1, "abc");
|
141
|
+
eq(cm.getValue(), "111111\nabc");
|
142
|
+
}, {value: "111111\n222222\n333333"});
|
143
|
+
|
144
|
+
testCM("indent", function(cm) {
|
145
|
+
cm.indentLine(1);
|
146
|
+
eq(cm.getLine(1), " blah();");
|
147
|
+
cm.setOption("indentUnit", 8);
|
148
|
+
cm.indentLine(1);
|
149
|
+
eq(cm.getLine(1), "\tblah();");
|
150
|
+
cm.setOption("indentUnit", 10);
|
151
|
+
cm.setOption("tabSize", 4);
|
152
|
+
cm.indentLine(1);
|
153
|
+
eq(cm.getLine(1), "\t\t blah();");
|
154
|
+
}, {value: "if (x) {\nblah();\n}", indentUnit: 3, indentWithTabs: true, tabSize: 8});
|
155
|
+
|
156
|
+
test("core_defaults", function() {
|
157
|
+
var defsCopy = {}, defs = CodeMirror.defaults;
|
158
|
+
for (var opt in defs) defsCopy[opt] = defs[opt];
|
159
|
+
defs.indentUnit = 5;
|
160
|
+
defs.value = "uu";
|
161
|
+
defs.enterMode = "keep";
|
162
|
+
defs.tabindex = 55;
|
163
|
+
var place = document.getElementById("testground"), cm = CodeMirror(place);
|
164
|
+
try {
|
165
|
+
eq(cm.getOption("indentUnit"), 5);
|
166
|
+
cm.setOption("indentUnit", 10);
|
167
|
+
eq(defs.indentUnit, 5);
|
168
|
+
eq(cm.getValue(), "uu");
|
169
|
+
eq(cm.getOption("enterMode"), "keep");
|
170
|
+
eq(cm.getInputField().tabIndex, 55);
|
171
|
+
}
|
172
|
+
finally {
|
173
|
+
for (var opt in defsCopy) defs[opt] = defsCopy[opt];
|
174
|
+
place.removeChild(cm.getWrapperElement());
|
175
|
+
}
|
176
|
+
});
|
177
|
+
|
178
|
+
testCM("lineInfo", function(cm) {
|
179
|
+
eq(cm.lineInfo(-1), null);
|
180
|
+
var mark = document.createElement("span");
|
181
|
+
var lh = cm.setGutterMarker(1, "FOO", mark);
|
182
|
+
var info = cm.lineInfo(1);
|
183
|
+
eq(info.text, "222222");
|
184
|
+
eq(info.gutterMarkers.FOO, mark);
|
185
|
+
eq(info.line, 1);
|
186
|
+
eq(cm.lineInfo(2).gutterMarkers, null);
|
187
|
+
cm.setGutterMarker(lh, "FOO", null);
|
188
|
+
eq(cm.lineInfo(1).gutterMarkers, null);
|
189
|
+
cm.setGutterMarker(1, "FOO", mark);
|
190
|
+
cm.setGutterMarker(0, "FOO", mark);
|
191
|
+
cm.clearGutter("FOO");
|
192
|
+
eq(cm.lineInfo(0).gutterMarkers, null);
|
193
|
+
eq(cm.lineInfo(1).gutterMarkers, null);
|
194
|
+
}, {value: "111111\n222222\n333333"});
|
195
|
+
|
196
|
+
testCM("coords", function(cm) {
|
197
|
+
cm.setSize(null, 100);
|
198
|
+
addDoc(cm, 32, 200);
|
199
|
+
var top = cm.charCoords(Pos(0, 0));
|
200
|
+
var bot = cm.charCoords(Pos(200, 30));
|
201
|
+
is(top.left < bot.left);
|
202
|
+
is(top.top < bot.top);
|
203
|
+
is(top.top < top.bottom);
|
204
|
+
cm.scrollTo(null, 100);
|
205
|
+
var top2 = cm.charCoords(Pos(0, 0));
|
206
|
+
is(top.top > top2.top);
|
207
|
+
eq(top.left, top2.left);
|
208
|
+
});
|
209
|
+
|
210
|
+
testCM("coordsChar", function(cm) {
|
211
|
+
addDoc(cm, 35, 70);
|
212
|
+
for (var ch = 0; ch <= 35; ch += 5) {
|
213
|
+
for (var line = 0; line < 70; line += 5) {
|
214
|
+
cm.setCursor(line, ch);
|
215
|
+
var coords = cm.charCoords(Pos(line, ch));
|
216
|
+
var pos = cm.coordsChar({left: coords.left, top: coords.top + 5});
|
217
|
+
eqPos(pos, Pos(line, ch));
|
218
|
+
}
|
219
|
+
}
|
220
|
+
});
|
221
|
+
|
222
|
+
testCM("posFromIndex", function(cm) {
|
223
|
+
cm.setValue(
|
224
|
+
"This function should\n" +
|
225
|
+
"convert a zero based index\n" +
|
226
|
+
"to line and ch."
|
227
|
+
);
|
228
|
+
|
229
|
+
var examples = [
|
230
|
+
{ index: -1, line: 0, ch: 0 }, // <- Tests clipping
|
231
|
+
{ index: 0, line: 0, ch: 0 },
|
232
|
+
{ index: 10, line: 0, ch: 10 },
|
233
|
+
{ index: 39, line: 1, ch: 18 },
|
234
|
+
{ index: 55, line: 2, ch: 7 },
|
235
|
+
{ index: 63, line: 2, ch: 15 },
|
236
|
+
{ index: 64, line: 2, ch: 15 } // <- Tests clipping
|
237
|
+
];
|
238
|
+
|
239
|
+
for (var i = 0; i < examples.length; i++) {
|
240
|
+
var example = examples[i];
|
241
|
+
var pos = cm.posFromIndex(example.index);
|
242
|
+
eq(pos.line, example.line);
|
243
|
+
eq(pos.ch, example.ch);
|
244
|
+
if (example.index >= 0 && example.index < 64)
|
245
|
+
eq(cm.indexFromPos(pos), example.index);
|
246
|
+
}
|
247
|
+
});
|
248
|
+
|
249
|
+
testCM("undo", function(cm) {
|
250
|
+
cm.setLine(0, "def");
|
251
|
+
eq(cm.historySize().undo, 1);
|
252
|
+
cm.undo();
|
253
|
+
eq(cm.getValue(), "abc");
|
254
|
+
eq(cm.historySize().undo, 0);
|
255
|
+
eq(cm.historySize().redo, 1);
|
256
|
+
cm.redo();
|
257
|
+
eq(cm.getValue(), "def");
|
258
|
+
eq(cm.historySize().undo, 1);
|
259
|
+
eq(cm.historySize().redo, 0);
|
260
|
+
cm.setValue("1\n\n\n2");
|
261
|
+
cm.clearHistory();
|
262
|
+
eq(cm.historySize().undo, 0);
|
263
|
+
for (var i = 0; i < 20; ++i) {
|
264
|
+
cm.replaceRange("a", Pos(0, 0));
|
265
|
+
cm.replaceRange("b", Pos(3, 0));
|
266
|
+
}
|
267
|
+
eq(cm.historySize().undo, 40);
|
268
|
+
for (var i = 0; i < 40; ++i)
|
269
|
+
cm.undo();
|
270
|
+
eq(cm.historySize().redo, 40);
|
271
|
+
eq(cm.getValue(), "1\n\n\n2");
|
272
|
+
}, {value: "abc"});
|
273
|
+
|
274
|
+
testCM("undoDepth", function(cm) {
|
275
|
+
cm.replaceRange("d", Pos(0));
|
276
|
+
cm.replaceRange("e", Pos(0));
|
277
|
+
cm.replaceRange("f", Pos(0));
|
278
|
+
cm.undo(); cm.undo(); cm.undo();
|
279
|
+
eq(cm.getValue(), "abcd");
|
280
|
+
}, {value: "abc", undoDepth: 2});
|
281
|
+
|
282
|
+
testCM("undoDoesntClearValue", function(cm) {
|
283
|
+
cm.undo();
|
284
|
+
eq(cm.getValue(), "x");
|
285
|
+
}, {value: "x"});
|
286
|
+
|
287
|
+
testCM("undoMultiLine", function(cm) {
|
288
|
+
cm.operation(function() {
|
289
|
+
cm.replaceRange("x", Pos(0, 0));
|
290
|
+
cm.replaceRange("y", Pos(1, 0));
|
291
|
+
});
|
292
|
+
cm.undo();
|
293
|
+
eq(cm.getValue(), "abc\ndef\nghi");
|
294
|
+
cm.operation(function() {
|
295
|
+
cm.replaceRange("y", Pos(1, 0));
|
296
|
+
cm.replaceRange("x", Pos(0, 0));
|
297
|
+
});
|
298
|
+
cm.undo();
|
299
|
+
eq(cm.getValue(), "abc\ndef\nghi");
|
300
|
+
cm.operation(function() {
|
301
|
+
cm.replaceRange("y", Pos(2, 0));
|
302
|
+
cm.replaceRange("x", Pos(1, 0));
|
303
|
+
cm.replaceRange("z", Pos(2, 0));
|
304
|
+
});
|
305
|
+
cm.undo();
|
306
|
+
eq(cm.getValue(), "abc\ndef\nghi", 3);
|
307
|
+
}, {value: "abc\ndef\nghi"});
|
308
|
+
|
309
|
+
testCM("undoComposite", function(cm) {
|
310
|
+
cm.replaceRange("y", Pos(1));
|
311
|
+
cm.operation(function() {
|
312
|
+
cm.replaceRange("x", Pos(0));
|
313
|
+
cm.replaceRange("z", Pos(2));
|
314
|
+
});
|
315
|
+
eq(cm.getValue(), "ax\nby\ncz\n");
|
316
|
+
cm.undo();
|
317
|
+
eq(cm.getValue(), "a\nby\nc\n");
|
318
|
+
cm.undo();
|
319
|
+
eq(cm.getValue(), "a\nb\nc\n");
|
320
|
+
cm.redo(); cm.redo();
|
321
|
+
eq(cm.getValue(), "ax\nby\ncz\n");
|
322
|
+
}, {value: "a\nb\nc\n"});
|
323
|
+
|
324
|
+
testCM("undoSelection", function(cm) {
|
325
|
+
cm.setSelection(Pos(0, 2), Pos(0, 4));
|
326
|
+
cm.replaceSelection("");
|
327
|
+
cm.setCursor(Pos(1, 0));
|
328
|
+
cm.undo();
|
329
|
+
eqPos(cm.getCursor(true), Pos(0, 2));
|
330
|
+
eqPos(cm.getCursor(false), Pos(0, 4));
|
331
|
+
cm.setCursor(Pos(1, 0));
|
332
|
+
cm.redo();
|
333
|
+
eqPos(cm.getCursor(true), Pos(0, 2));
|
334
|
+
eqPos(cm.getCursor(false), Pos(0, 2));
|
335
|
+
}, {value: "abcdefgh\n"});
|
336
|
+
|
337
|
+
testCM("markTextSingleLine", function(cm) {
|
338
|
+
forEach([{a: 0, b: 1, c: "", f: 2, t: 5},
|
339
|
+
{a: 0, b: 4, c: "", f: 0, t: 2},
|
340
|
+
{a: 1, b: 2, c: "x", f: 3, t: 6},
|
341
|
+
{a: 4, b: 5, c: "", f: 3, t: 5},
|
342
|
+
{a: 4, b: 5, c: "xx", f: 3, t: 7},
|
343
|
+
{a: 2, b: 5, c: "", f: 2, t: 3},
|
344
|
+
{a: 2, b: 5, c: "abcd", f: 6, t: 7},
|
345
|
+
{a: 2, b: 6, c: "x", f: null, t: null},
|
346
|
+
{a: 3, b: 6, c: "", f: null, t: null},
|
347
|
+
{a: 0, b: 9, c: "hallo", f: null, t: null},
|
348
|
+
{a: 4, b: 6, c: "x", f: 3, t: 4},
|
349
|
+
{a: 4, b: 8, c: "", f: 3, t: 4},
|
350
|
+
{a: 6, b: 6, c: "a", f: 3, t: 6},
|
351
|
+
{a: 8, b: 9, c: "", f: 3, t: 6}], function(test) {
|
352
|
+
cm.setValue("1234567890");
|
353
|
+
var r = cm.markText(Pos(0, 3), Pos(0, 6), {className: "foo"});
|
354
|
+
cm.replaceRange(test.c, Pos(0, test.a), Pos(0, test.b));
|
355
|
+
var f = r.find();
|
356
|
+
eq(f && f.from.ch, test.f); eq(f && f.to.ch, test.t);
|
357
|
+
});
|
358
|
+
});
|
359
|
+
|
360
|
+
testCM("markTextMultiLine", function(cm) {
|
361
|
+
function p(v) { return v && Pos(v[0], v[1]); }
|
362
|
+
forEach([{a: [0, 0], b: [0, 5], c: "", f: [0, 0], t: [2, 5]},
|
363
|
+
{a: [0, 0], b: [0, 5], c: "foo\n", f: [1, 0], t: [3, 5]},
|
364
|
+
{a: [0, 1], b: [0, 10], c: "", f: [0, 1], t: [2, 5]},
|
365
|
+
{a: [0, 5], b: [0, 6], c: "x", f: [0, 6], t: [2, 5]},
|
366
|
+
{a: [0, 0], b: [1, 0], c: "", f: [0, 0], t: [1, 5]},
|
367
|
+
{a: [0, 6], b: [2, 4], c: "", f: [0, 5], t: [0, 7]},
|
368
|
+
{a: [0, 6], b: [2, 4], c: "aa", f: [0, 5], t: [0, 9]},
|
369
|
+
{a: [1, 2], b: [1, 8], c: "", f: [0, 5], t: [2, 5]},
|
370
|
+
{a: [0, 5], b: [2, 5], c: "xx", f: null, t: null},
|
371
|
+
{a: [0, 0], b: [2, 10], c: "x", f: null, t: null},
|
372
|
+
{a: [1, 5], b: [2, 5], c: "", f: [0, 5], t: [1, 5]},
|
373
|
+
{a: [2, 0], b: [2, 3], c: "", f: [0, 5], t: [2, 2]},
|
374
|
+
{a: [2, 5], b: [3, 0], c: "a\nb", f: [0, 5], t: [2, 5]},
|
375
|
+
{a: [2, 3], b: [3, 0], c: "x", f: [0, 5], t: [2, 3]},
|
376
|
+
{a: [1, 1], b: [1, 9], c: "1\n2\n3", f: [0, 5], t: [4, 5]}], function(test) {
|
377
|
+
cm.setValue("aaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddd\n");
|
378
|
+
var r = cm.markText(Pos(0, 5), Pos(2, 5),
|
379
|
+
{className: "CodeMirror-matchingbracket"});
|
380
|
+
cm.replaceRange(test.c, p(test.a), p(test.b));
|
381
|
+
var f = r.find();
|
382
|
+
eqPos(f && f.from, p(test.f)); eqPos(f && f.to, p(test.t));
|
383
|
+
});
|
384
|
+
});
|
385
|
+
|
386
|
+
testCM("markTextUndo", function(cm) {
|
387
|
+
var marker1, marker2, bookmark;
|
388
|
+
marker1 = cm.markText(Pos(0, 1), Pos(0, 3),
|
389
|
+
{className: "CodeMirror-matchingbracket"});
|
390
|
+
marker2 = cm.markText(Pos(0, 0), Pos(2, 1),
|
391
|
+
{className: "CodeMirror-matchingbracket"});
|
392
|
+
bookmark = cm.setBookmark(Pos(1, 5));
|
393
|
+
cm.operation(function(){
|
394
|
+
cm.replaceRange("foo", Pos(0, 2));
|
395
|
+
cm.replaceRange("bar\nbaz\nbug\n", Pos(2, 0), Pos(3, 0));
|
396
|
+
});
|
397
|
+
var v1 = cm.getValue();
|
398
|
+
cm.setValue("");
|
399
|
+
eq(marker1.find(), null); eq(marker2.find(), null); eq(bookmark.find(), null);
|
400
|
+
cm.undo();
|
401
|
+
eqPos(bookmark.find(), Pos(1, 5), "still there");
|
402
|
+
cm.undo();
|
403
|
+
var m1Pos = marker1.find(), m2Pos = marker2.find();
|
404
|
+
eqPos(m1Pos.from, Pos(0, 1)); eqPos(m1Pos.to, Pos(0, 3));
|
405
|
+
eqPos(m2Pos.from, Pos(0, 0)); eqPos(m2Pos.to, Pos(2, 1));
|
406
|
+
eqPos(bookmark.find(), Pos(1, 5));
|
407
|
+
cm.redo(); cm.redo();
|
408
|
+
eq(bookmark.find(), null);
|
409
|
+
cm.undo();
|
410
|
+
eqPos(bookmark.find(), Pos(1, 5));
|
411
|
+
eq(cm.getValue(), v1);
|
412
|
+
}, {value: "1234\n56789\n00\n"});
|
413
|
+
|
414
|
+
testCM("markTextStayGone", function(cm) {
|
415
|
+
var m1 = cm.markText(Pos(0, 0), Pos(0, 1));
|
416
|
+
cm.replaceRange("hi", Pos(0, 2));
|
417
|
+
m1.clear();
|
418
|
+
cm.undo();
|
419
|
+
eq(m1.find(), null);
|
420
|
+
}, {value: "hello"});
|
421
|
+
|
422
|
+
testCM("undoPreservesNewMarks", function(cm) {
|
423
|
+
cm.markText(Pos(0, 3), Pos(0, 4));
|
424
|
+
cm.markText(Pos(1, 1), Pos(1, 3));
|
425
|
+
cm.replaceRange("", Pos(0, 3), Pos(3, 1));
|
426
|
+
var mBefore = cm.markText(Pos(0, 0), Pos(0, 1));
|
427
|
+
var mAfter = cm.markText(Pos(0, 5), Pos(0, 6));
|
428
|
+
var mAround = cm.markText(Pos(0, 2), Pos(0, 4));
|
429
|
+
cm.undo();
|
430
|
+
eqPos(mBefore.find().from, Pos(0, 0));
|
431
|
+
eqPos(mBefore.find().to, Pos(0, 1));
|
432
|
+
eqPos(mAfter.find().from, Pos(3, 3));
|
433
|
+
eqPos(mAfter.find().to, Pos(3, 4));
|
434
|
+
eqPos(mAround.find().from, Pos(0, 2));
|
435
|
+
eqPos(mAround.find().to, Pos(3, 2));
|
436
|
+
var found = cm.findMarksAt(Pos(2, 2));
|
437
|
+
eq(found.length, 1);
|
438
|
+
eq(found[0], mAround);
|
439
|
+
}, {value: "aaaa\nbbbb\ncccc\ndddd"});
|
440
|
+
|
441
|
+
testCM("markClearBetween", function(cm) {
|
442
|
+
cm.setValue("aaa\nbbb\nccc\nddd\n");
|
443
|
+
cm.markText(Pos(0, 0), Pos(2));
|
444
|
+
cm.replaceRange("aaa\nbbb\nccc", Pos(0, 0), Pos(2));
|
445
|
+
eq(cm.findMarksAt(Pos(1, 1)).length, 0);
|
446
|
+
});
|
447
|
+
|
448
|
+
testCM("bookmark", function(cm) {
|
449
|
+
function p(v) { return v && Pos(v[0], v[1]); }
|
450
|
+
forEach([{a: [1, 0], b: [1, 1], c: "", d: [1, 4]},
|
451
|
+
{a: [1, 1], b: [1, 1], c: "xx", d: [1, 7]},
|
452
|
+
{a: [1, 4], b: [1, 5], c: "ab", d: [1, 6]},
|
453
|
+
{a: [1, 4], b: [1, 6], c: "", d: null},
|
454
|
+
{a: [1, 5], b: [1, 6], c: "abc", d: [1, 5]},
|
455
|
+
{a: [1, 6], b: [1, 8], c: "", d: [1, 5]},
|
456
|
+
{a: [1, 4], b: [1, 4], c: "\n\n", d: [3, 1]},
|
457
|
+
{bm: [1, 9], a: [1, 1], b: [1, 1], c: "\n", d: [2, 8]}], function(test) {
|
458
|
+
cm.setValue("1234567890\n1234567890\n1234567890");
|
459
|
+
var b = cm.setBookmark(p(test.bm) || Pos(1, 5));
|
460
|
+
cm.replaceRange(test.c, p(test.a), p(test.b));
|
461
|
+
eqPos(b.find(), p(test.d));
|
462
|
+
});
|
463
|
+
});
|
464
|
+
|
465
|
+
testCM("bookmarkInsertLeft", function(cm) {
|
466
|
+
var br = cm.setBookmark(Pos(0, 2), {insertLeft: false});
|
467
|
+
var bl = cm.setBookmark(Pos(0, 2), {insertLeft: true});
|
468
|
+
cm.setCursor(Pos(0, 2));
|
469
|
+
cm.replaceSelection("hi");
|
470
|
+
eqPos(br.find(), Pos(0, 2));
|
471
|
+
eqPos(bl.find(), Pos(0, 4));
|
472
|
+
cm.replaceRange("", Pos(0, 4), Pos(0, 5));
|
473
|
+
cm.replaceRange("", Pos(0, 2), Pos(0, 4));
|
474
|
+
cm.replaceRange("", Pos(0, 1), Pos(0, 2));
|
475
|
+
// Verify that deleting next to bookmarks doesn't kill them
|
476
|
+
eqPos(br.find(), Pos(0, 1));
|
477
|
+
eqPos(bl.find(), Pos(0, 1));
|
478
|
+
}, {value: "abcdef"});
|
479
|
+
|
480
|
+
testCM("getAllMarks", function(cm) {
|
481
|
+
addDoc(cm, 10, 10);
|
482
|
+
var m1 = cm.setBookmark(Pos(0, 2));
|
483
|
+
var m2 = cm.markText(Pos(0, 2), Pos(3, 2));
|
484
|
+
var m3 = cm.markText(Pos(1, 2), Pos(1, 8));
|
485
|
+
var m4 = cm.markText(Pos(8, 0), Pos(9, 0));
|
486
|
+
eq(cm.getAllMarks().length, 4);
|
487
|
+
m1.clear();
|
488
|
+
m3.clear();
|
489
|
+
eq(cm.getAllMarks().length, 2);
|
490
|
+
});
|
491
|
+
|
492
|
+
testCM("bug577", function(cm) {
|
493
|
+
cm.setValue("a\nb");
|
494
|
+
cm.clearHistory();
|
495
|
+
cm.setValue("fooooo");
|
496
|
+
cm.undo();
|
497
|
+
});
|
498
|
+
|
499
|
+
testCM("scrollSnap", function(cm) {
|
500
|
+
cm.setSize(100, 100);
|
501
|
+
addDoc(cm, 200, 200);
|
502
|
+
cm.setCursor(Pos(100, 180));
|
503
|
+
var info = cm.getScrollInfo();
|
504
|
+
is(info.left > 0 && info.top > 0);
|
505
|
+
cm.setCursor(Pos(0, 0));
|
506
|
+
info = cm.getScrollInfo();
|
507
|
+
is(info.left == 0 && info.top == 0, "scrolled clean to top");
|
508
|
+
cm.setCursor(Pos(100, 180));
|
509
|
+
cm.setCursor(Pos(199, 0));
|
510
|
+
info = cm.getScrollInfo();
|
511
|
+
is(info.left == 0 && info.top + 2 > info.height - cm.getScrollerElement().clientHeight, "scrolled clean to bottom");
|
512
|
+
});
|
513
|
+
|
514
|
+
testCM("selectionPos", function(cm) {
|
515
|
+
if (phantom) return;
|
516
|
+
cm.setSize(100, 100);
|
517
|
+
addDoc(cm, 200, 100);
|
518
|
+
cm.setSelection(Pos(1, 100), Pos(98, 100));
|
519
|
+
var lineWidth = cm.charCoords(Pos(0, 200), "local").left;
|
520
|
+
var lineHeight = (cm.charCoords(Pos(99)).top - cm.charCoords(Pos(0)).top) / 100;
|
521
|
+
cm.scrollTo(0, 0);
|
522
|
+
var selElt = byClassName(cm.getWrapperElement(), "CodeMirror-selected");
|
523
|
+
var outer = cm.getWrapperElement().getBoundingClientRect();
|
524
|
+
var sawMiddle, sawTop, sawBottom;
|
525
|
+
for (var i = 0, e = selElt.length; i < e; ++i) {
|
526
|
+
var box = selElt[i].getBoundingClientRect();
|
527
|
+
var atLeft = box.left - outer.left < 30;
|
528
|
+
var width = box.right - box.left;
|
529
|
+
var atRight = box.right - outer.left > .8 * lineWidth;
|
530
|
+
if (atLeft && atRight) {
|
531
|
+
sawMiddle = true;
|
532
|
+
is(box.bottom - box.top > 90 * lineHeight, "middle high");
|
533
|
+
is(width > .9 * lineWidth, "middle wide");
|
534
|
+
} else {
|
535
|
+
is(width > .4 * lineWidth, "top/bot wide enough");
|
536
|
+
is(width < .6 * lineWidth, "top/bot slim enough");
|
537
|
+
if (atLeft) {
|
538
|
+
sawBottom = true;
|
539
|
+
is(box.top - outer.top > 96 * lineHeight, "bot below");
|
540
|
+
} else if (atRight) {
|
541
|
+
sawTop = true;
|
542
|
+
is(box.top - outer.top < 2.1 * lineHeight, "top above");
|
543
|
+
}
|
544
|
+
}
|
545
|
+
}
|
546
|
+
is(sawTop && sawBottom && sawMiddle, "all parts");
|
547
|
+
}, null);
|
548
|
+
|
549
|
+
testCM("restoreHistory", function(cm) {
|
550
|
+
cm.setValue("abc\ndef");
|
551
|
+
cm.setLine(1, "hello");
|
552
|
+
cm.setLine(0, "goop");
|
553
|
+
cm.undo();
|
554
|
+
var storedVal = cm.getValue(), storedHist = cm.getHistory();
|
555
|
+
if (window.JSON) storedHist = JSON.parse(JSON.stringify(storedHist));
|
556
|
+
eq(storedVal, "abc\nhello");
|
557
|
+
cm.setValue("");
|
558
|
+
cm.clearHistory();
|
559
|
+
eq(cm.historySize().undo, 0);
|
560
|
+
cm.setValue(storedVal);
|
561
|
+
cm.setHistory(storedHist);
|
562
|
+
cm.redo();
|
563
|
+
eq(cm.getValue(), "goop\nhello");
|
564
|
+
cm.undo(); cm.undo();
|
565
|
+
eq(cm.getValue(), "abc\ndef");
|
566
|
+
});
|
567
|
+
|
568
|
+
testCM("doubleScrollbar", function(cm) {
|
569
|
+
var dummy = document.body.appendChild(document.createElement("p"));
|
570
|
+
dummy.style.cssText = "height: 50px; overflow: scroll; width: 50px";
|
571
|
+
var scrollbarWidth = dummy.offsetWidth + 1 - dummy.clientWidth;
|
572
|
+
document.body.removeChild(dummy);
|
573
|
+
if (scrollbarWidth < 2) return;
|
574
|
+
cm.setSize(null, 100);
|
575
|
+
addDoc(cm, 1, 300);
|
576
|
+
var wrap = cm.getWrapperElement();
|
577
|
+
is(wrap.offsetWidth - byClassName(wrap, "CodeMirror-lines")[0].offsetWidth <= scrollbarWidth * 1.5);
|
578
|
+
});
|
579
|
+
|
580
|
+
testCM("weirdLinebreaks", function(cm) {
|
581
|
+
cm.setValue("foo\nbar\rbaz\r\nquux\n\rplop");
|
582
|
+
is(cm.getValue(), "foo\nbar\nbaz\nquux\n\nplop");
|
583
|
+
is(cm.lineCount(), 6);
|
584
|
+
cm.setValue("\n\n");
|
585
|
+
is(cm.lineCount(), 3);
|
586
|
+
});
|
587
|
+
|
588
|
+
testCM("setSize", function(cm) {
|
589
|
+
cm.setSize(100, 100);
|
590
|
+
var wrap = cm.getWrapperElement();
|
591
|
+
is(wrap.offsetWidth, 100);
|
592
|
+
is(wrap.offsetHeight, 100);
|
593
|
+
cm.setSize("100%", "3em");
|
594
|
+
is(wrap.style.width, "100%");
|
595
|
+
is(wrap.style.height, "3em");
|
596
|
+
cm.setSize(null, 40);
|
597
|
+
is(wrap.style.width, "100%");
|
598
|
+
is(wrap.style.height, "40px");
|
599
|
+
});
|
600
|
+
|
601
|
+
function foldLines(cm, start, end, autoClear) {
|
602
|
+
return cm.markText(Pos(start, 0), Pos(end - 1), {
|
603
|
+
inclusiveLeft: true,
|
604
|
+
inclusiveRight: true,
|
605
|
+
collapsed: true,
|
606
|
+
clearOnEnter: autoClear
|
607
|
+
});
|
608
|
+
}
|
609
|
+
|
610
|
+
testCM("collapsedLines", function(cm) {
|
611
|
+
addDoc(cm, 4, 10);
|
612
|
+
var range = foldLines(cm, 4, 5), cleared = 0;
|
613
|
+
CodeMirror.on(range, "clear", function() {cleared++;});
|
614
|
+
cm.setCursor(Pos(3, 0));
|
615
|
+
CodeMirror.commands.goLineDown(cm);
|
616
|
+
eqPos(cm.getCursor(), Pos(5, 0));
|
617
|
+
cm.setLine(3, "abcdefg");
|
618
|
+
cm.setCursor(Pos(3, 6));
|
619
|
+
CodeMirror.commands.goLineDown(cm);
|
620
|
+
eqPos(cm.getCursor(), Pos(5, 4));
|
621
|
+
cm.setLine(3, "ab");
|
622
|
+
cm.setCursor(Pos(3, 2));
|
623
|
+
CodeMirror.commands.goLineDown(cm);
|
624
|
+
eqPos(cm.getCursor(), Pos(5, 2));
|
625
|
+
cm.operation(function() {range.clear(); range.clear();});
|
626
|
+
eq(cleared, 1);
|
627
|
+
});
|
628
|
+
|
629
|
+
testCM("collapsedRangeCoordsChar", function(cm) {
|
630
|
+
var pos_1_3 = cm.charCoords(Pos(1, 3));
|
631
|
+
pos_1_3.left += 2; pos_1_3.top += 2;
|
632
|
+
var opts = {collapsed: true, inclusiveLeft: true, inclusiveRight: true};
|
633
|
+
var m1 = cm.markText(Pos(0, 0), Pos(2, 0), opts);
|
634
|
+
eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));
|
635
|
+
m1.clear();
|
636
|
+
var m1 = cm.markText(Pos(0, 0), Pos(1, 1), opts);
|
637
|
+
var m2 = cm.markText(Pos(1, 1), Pos(2, 0), opts);
|
638
|
+
eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));
|
639
|
+
m1.clear(); m2.clear();
|
640
|
+
var m1 = cm.markText(Pos(0, 0), Pos(1, 6), opts);
|
641
|
+
eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));
|
642
|
+
}, {value: "123456\nabcdef\nghijkl\nmnopqr\n"});
|
643
|
+
|
644
|
+
testCM("hiddenLinesAutoUnfold", function(cm) {
|
645
|
+
var range = foldLines(cm, 1, 3, true), cleared = 0;
|
646
|
+
CodeMirror.on(range, "clear", function() {cleared++;});
|
647
|
+
cm.setCursor(Pos(3, 0));
|
648
|
+
eq(cleared, 0);
|
649
|
+
cm.execCommand("goCharLeft");
|
650
|
+
eq(cleared, 1);
|
651
|
+
range = foldLines(cm, 1, 3, true);
|
652
|
+
CodeMirror.on(range, "clear", function() {cleared++;});
|
653
|
+
eqPos(cm.getCursor(), Pos(3, 0));
|
654
|
+
cm.setCursor(Pos(0, 3));
|
655
|
+
cm.execCommand("goCharRight");
|
656
|
+
eq(cleared, 2);
|
657
|
+
}, {value: "abc\ndef\nghi\njkl"});
|
658
|
+
|
659
|
+
testCM("hiddenLinesSelectAll", function(cm) { // Issue #484
|
660
|
+
addDoc(cm, 4, 20);
|
661
|
+
foldLines(cm, 0, 10);
|
662
|
+
foldLines(cm, 11, 20);
|
663
|
+
CodeMirror.commands.selectAll(cm);
|
664
|
+
eqPos(cm.getCursor(true), Pos(10, 0));
|
665
|
+
eqPos(cm.getCursor(false), Pos(10, 4));
|
666
|
+
});
|
667
|
+
|
668
|
+
|
669
|
+
testCM("everythingFolded", function(cm) {
|
670
|
+
addDoc(cm, 2, 2);
|
671
|
+
function enterPress() {
|
672
|
+
cm.triggerOnKeyDown({type: "keydown", keyCode: 13, preventDefault: function(){}, stopPropagation: function(){}});
|
673
|
+
}
|
674
|
+
var fold = foldLines(cm, 0, 2);
|
675
|
+
enterPress();
|
676
|
+
eq(cm.getValue(), "xx\nxx");
|
677
|
+
fold.clear();
|
678
|
+
fold = foldLines(cm, 0, 2, true);
|
679
|
+
eq(fold.find(), null);
|
680
|
+
enterPress();
|
681
|
+
eq(cm.getValue(), "\nxx\nxx");
|
682
|
+
});
|
683
|
+
|
684
|
+
testCM("structuredFold", function(cm) {
|
685
|
+
addDoc(cm, 4, 8);
|
686
|
+
var range = cm.markText(Pos(1, 2), Pos(6, 2), {
|
687
|
+
replacedWith: document.createTextNode("Q")
|
688
|
+
});
|
689
|
+
cm.setCursor(0, 3);
|
690
|
+
CodeMirror.commands.goLineDown(cm);
|
691
|
+
eqPos(cm.getCursor(), Pos(6, 2));
|
692
|
+
CodeMirror.commands.goCharLeft(cm);
|
693
|
+
eqPos(cm.getCursor(), Pos(1, 2));
|
694
|
+
CodeMirror.commands.delCharAfter(cm);
|
695
|
+
eq(cm.getValue(), "xxxx\nxxxx\nxxxx");
|
696
|
+
addDoc(cm, 4, 8);
|
697
|
+
range = cm.markText(Pos(1, 2), Pos(6, 2), {
|
698
|
+
replacedWith: document.createTextNode("x"),
|
699
|
+
clearOnEnter: true
|
700
|
+
});
|
701
|
+
var cleared = 0;
|
702
|
+
CodeMirror.on(range, "clear", function(){++cleared;});
|
703
|
+
cm.setCursor(0, 3);
|
704
|
+
CodeMirror.commands.goLineDown(cm);
|
705
|
+
eqPos(cm.getCursor(), Pos(6, 2));
|
706
|
+
CodeMirror.commands.goCharLeft(cm);
|
707
|
+
eqPos(cm.getCursor(), Pos(6, 1));
|
708
|
+
eq(cleared, 1);
|
709
|
+
range.clear();
|
710
|
+
eq(cleared, 1);
|
711
|
+
range = cm.markText(Pos(1, 2), Pos(6, 2), {
|
712
|
+
replacedWith: document.createTextNode("Q"),
|
713
|
+
clearOnEnter: true
|
714
|
+
});
|
715
|
+
range.clear();
|
716
|
+
cm.setCursor(1, 2);
|
717
|
+
CodeMirror.commands.goCharRight(cm);
|
718
|
+
eqPos(cm.getCursor(), Pos(1, 3));
|
719
|
+
}, null);
|
720
|
+
|
721
|
+
testCM("nestedFold", function(cm) {
|
722
|
+
addDoc(cm, 10, 3);
|
723
|
+
function fold(ll, cl, lr, cr) {
|
724
|
+
return cm.markText(Pos(ll, cl), Pos(lr, cr), {collapsed: true});
|
725
|
+
}
|
726
|
+
var inner1 = fold(0, 6, 1, 3), inner2 = fold(0, 2, 1, 8), outer = fold(0, 1, 2, 3), inner0 = fold(0, 5, 0, 6);
|
727
|
+
cm.setCursor(0, 1);
|
728
|
+
CodeMirror.commands.goCharRight(cm);
|
729
|
+
eqPos(cm.getCursor(), Pos(2, 3));
|
730
|
+
inner0.clear();
|
731
|
+
CodeMirror.commands.goCharLeft(cm);
|
732
|
+
eqPos(cm.getCursor(), Pos(0, 1));
|
733
|
+
outer.clear();
|
734
|
+
CodeMirror.commands.goCharRight(cm);
|
735
|
+
eqPos(cm.getCursor(), Pos(0, 2));
|
736
|
+
CodeMirror.commands.goCharRight(cm);
|
737
|
+
eqPos(cm.getCursor(), Pos(1, 8));
|
738
|
+
inner2.clear();
|
739
|
+
CodeMirror.commands.goCharLeft(cm);
|
740
|
+
eqPos(cm.getCursor(), Pos(1, 7));
|
741
|
+
cm.setCursor(0, 5);
|
742
|
+
CodeMirror.commands.goCharRight(cm);
|
743
|
+
eqPos(cm.getCursor(), Pos(0, 6));
|
744
|
+
CodeMirror.commands.goCharRight(cm);
|
745
|
+
eqPos(cm.getCursor(), Pos(1, 3));
|
746
|
+
});
|
747
|
+
|
748
|
+
testCM("badNestedFold", function(cm) {
|
749
|
+
addDoc(cm, 4, 4);
|
750
|
+
cm.markText(Pos(0, 2), Pos(3, 2), {collapsed: true});
|
751
|
+
var caught;
|
752
|
+
try {cm.markText(Pos(0, 1), Pos(0, 3), {collapsed: true});}
|
753
|
+
catch(e) {caught = e;}
|
754
|
+
is(caught instanceof Error, "no error");
|
755
|
+
is(/overlap/i.test(caught.message), "wrong error");
|
756
|
+
});
|
757
|
+
|
758
|
+
testCM("inlineWidget", function(cm) {
|
759
|
+
var w = cm.setBookmark(Pos(0, 2), {widget: document.createTextNode("uu")});
|
760
|
+
cm.setCursor(0, 2);
|
761
|
+
CodeMirror.commands.goLineDown(cm);
|
762
|
+
eqPos(cm.getCursor(), Pos(1, 4));
|
763
|
+
cm.setCursor(0, 2);
|
764
|
+
cm.replaceSelection("hi");
|
765
|
+
eqPos(w.find(), Pos(0, 2));
|
766
|
+
cm.setCursor(0, 1);
|
767
|
+
cm.replaceSelection("ay");
|
768
|
+
eqPos(w.find(), Pos(0, 4));
|
769
|
+
eq(cm.getLine(0), "uayuhiuu");
|
770
|
+
}, {value: "uuuu\nuuuuuu"});
|
771
|
+
|
772
|
+
testCM("wrappingAndResizing", function(cm) {
|
773
|
+
cm.setSize(null, "auto");
|
774
|
+
cm.setOption("lineWrapping", true);
|
775
|
+
var wrap = cm.getWrapperElement(), h0 = wrap.offsetHeight;
|
776
|
+
var doc = "xxx xxx xxx xxx xxx";
|
777
|
+
cm.setValue(doc);
|
778
|
+
for (var step = 10, w = cm.charCoords(Pos(0, 18), "div").right;; w += step) {
|
779
|
+
cm.setSize(w);
|
780
|
+
if (wrap.offsetHeight <= h0 * (opera_lt10 ? 1.2 : 1.5)) {
|
781
|
+
if (step == 10) { w -= 10; step = 1; }
|
782
|
+
else break;
|
783
|
+
}
|
784
|
+
}
|
785
|
+
// Ensure that putting the cursor at the end of the maximally long
|
786
|
+
// line doesn't cause wrapping to happen.
|
787
|
+
cm.setCursor(Pos(0, doc.length));
|
788
|
+
eq(wrap.offsetHeight, h0);
|
789
|
+
cm.replaceSelection("x");
|
790
|
+
is(wrap.offsetHeight > h0, "wrapping happens");
|
791
|
+
// Now add a max-height and, in a document consisting of
|
792
|
+
// almost-wrapped lines, go over it so that a scrollbar appears.
|
793
|
+
cm.setValue(doc + "\n" + doc + "\n");
|
794
|
+
cm.getScrollerElement().style.maxHeight = "100px";
|
795
|
+
cm.replaceRange("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n!\n", Pos(2, 0));
|
796
|
+
forEach([Pos(0, doc.length), Pos(0, doc.length - 1),
|
797
|
+
Pos(0, 0), Pos(1, doc.length), Pos(1, doc.length - 1)],
|
798
|
+
function(pos) {
|
799
|
+
var coords = cm.charCoords(pos);
|
800
|
+
eqPos(pos, cm.coordsChar({left: coords.left + 2, top: coords.top + 5}));
|
801
|
+
});
|
802
|
+
}, null, ie_lt8);
|
803
|
+
|
804
|
+
testCM("measureEndOfLine", function(cm) {
|
805
|
+
cm.setSize(null, "auto");
|
806
|
+
var inner = byClassName(cm.getWrapperElement(), "CodeMirror-lines")[0].firstChild;
|
807
|
+
var lh = inner.offsetHeight;
|
808
|
+
for (var step = 10, w = cm.charCoords(Pos(0, 7), "div").right;; w += step) {
|
809
|
+
cm.setSize(w);
|
810
|
+
if (inner.offsetHeight < 2.5 * lh) {
|
811
|
+
if (step == 10) { w -= 10; step = 1; }
|
812
|
+
else break;
|
813
|
+
}
|
814
|
+
}
|
815
|
+
cm.setValue(cm.getValue() + "\n\n");
|
816
|
+
var endPos = cm.charCoords(Pos(0, 18), "local");
|
817
|
+
is(endPos.top > lh * .8, "not at top");
|
818
|
+
is(endPos.left > w - 20, "not at right");
|
819
|
+
endPos = cm.charCoords(Pos(0, 18));
|
820
|
+
eqPos(cm.coordsChar({left: endPos.left, top: endPos.top + 5}), Pos(0, 18));
|
821
|
+
}, {mode: "text/html", value: "<!-- foo barrr -->", lineWrapping: true}, ie_lt8 || opera_lt10);
|
822
|
+
|
823
|
+
testCM("scrollVerticallyAndHorizontally", function(cm) {
|
824
|
+
cm.setSize(100, 100);
|
825
|
+
addDoc(cm, 40, 40);
|
826
|
+
cm.setCursor(39);
|
827
|
+
var wrap = cm.getWrapperElement(), bar = byClassName(wrap, "CodeMirror-vscrollbar")[0];
|
828
|
+
is(bar.offsetHeight < wrap.offsetHeight, "vertical scrollbar limited by horizontal one");
|
829
|
+
var cursorBox = byClassName(wrap, "CodeMirror-cursor")[0].getBoundingClientRect();
|
830
|
+
var editorBox = wrap.getBoundingClientRect();
|
831
|
+
is(cursorBox.bottom < editorBox.top + cm.getScrollerElement().clientHeight,
|
832
|
+
"bottom line visible");
|
833
|
+
}, {lineNumbers: true});
|
834
|
+
|
835
|
+
testCM("moveVstuck", function(cm) {
|
836
|
+
var lines = byClassName(cm.getWrapperElement(), "CodeMirror-lines")[0].firstChild, h0 = lines.offsetHeight;
|
837
|
+
var val = "fooooooooooooooooooooooooo baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar\n";
|
838
|
+
cm.setValue(val);
|
839
|
+
for (var w = cm.charCoords(Pos(0, 26), "div").right * 2.8;; w += 5) {
|
840
|
+
cm.setSize(w);
|
841
|
+
if (lines.offsetHeight <= 3.5 * h0) break;
|
842
|
+
}
|
843
|
+
cm.setCursor(Pos(0, val.length - 1));
|
844
|
+
cm.moveV(-1, "line");
|
845
|
+
eqPos(cm.getCursor(), Pos(0, 26));
|
846
|
+
}, {lineWrapping: true}, ie_lt8 || opera_lt10);
|
847
|
+
|
848
|
+
testCM("clickTab", function(cm) {
|
849
|
+
var p0 = cm.charCoords(Pos(0, 0));
|
850
|
+
eqPos(cm.coordsChar({left: p0.left + 5, top: p0.top + 5}), Pos(0, 0));
|
851
|
+
eqPos(cm.coordsChar({left: p0.right - 5, top: p0.top + 5}), Pos(0, 1));
|
852
|
+
}, {value: "\t\n\n", lineWrapping: true, tabSize: 8});
|
853
|
+
|
854
|
+
testCM("verticalScroll", function(cm) {
|
855
|
+
cm.setSize(100, 200);
|
856
|
+
cm.setValue("foo\nbar\nbaz\n");
|
857
|
+
var sc = cm.getScrollerElement(), baseWidth = sc.scrollWidth;
|
858
|
+
cm.setLine(0, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah");
|
859
|
+
is(sc.scrollWidth > baseWidth, "scrollbar present");
|
860
|
+
cm.setLine(0, "foo");
|
861
|
+
if (!phantom) eq(sc.scrollWidth, baseWidth, "scrollbar gone");
|
862
|
+
cm.setLine(0, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah");
|
863
|
+
cm.setLine(1, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbh");
|
864
|
+
is(sc.scrollWidth > baseWidth, "present again");
|
865
|
+
var curWidth = sc.scrollWidth;
|
866
|
+
cm.setLine(0, "foo");
|
867
|
+
is(sc.scrollWidth < curWidth, "scrollbar smaller");
|
868
|
+
is(sc.scrollWidth > baseWidth, "but still present");
|
869
|
+
});
|
870
|
+
|
871
|
+
testCM("extraKeys", function(cm) {
|
872
|
+
var outcome;
|
873
|
+
function fakeKey(expected, code, props) {
|
874
|
+
if (typeof code == "string") code = code.charCodeAt(0);
|
875
|
+
var e = {type: "keydown", keyCode: code, preventDefault: function(){}, stopPropagation: function(){}};
|
876
|
+
if (props) for (var n in props) e[n] = props[n];
|
877
|
+
outcome = null;
|
878
|
+
cm.triggerOnKeyDown(e);
|
879
|
+
eq(outcome, expected);
|
880
|
+
}
|
881
|
+
CodeMirror.commands.testCommand = function() {outcome = "tc";};
|
882
|
+
CodeMirror.commands.goTestCommand = function() {outcome = "gtc";};
|
883
|
+
cm.setOption("extraKeys", {"Shift-X": function() {outcome = "sx";},
|
884
|
+
"X": function() {outcome = "x";},
|
885
|
+
"Ctrl-Alt-U": function() {outcome = "cau";},
|
886
|
+
"End": "testCommand",
|
887
|
+
"Home": "goTestCommand",
|
888
|
+
"Tab": false});
|
889
|
+
fakeKey(null, "U");
|
890
|
+
fakeKey("cau", "U", {ctrlKey: true, altKey: true});
|
891
|
+
fakeKey(null, "U", {shiftKey: true, ctrlKey: true, altKey: true});
|
892
|
+
fakeKey("x", "X");
|
893
|
+
fakeKey("sx", "X", {shiftKey: true});
|
894
|
+
fakeKey("tc", 35);
|
895
|
+
fakeKey(null, 35, {shiftKey: true});
|
896
|
+
fakeKey("gtc", 36);
|
897
|
+
fakeKey("gtc", 36, {shiftKey: true});
|
898
|
+
fakeKey(null, 9);
|
899
|
+
}, null, window.opera && mac);
|
900
|
+
|
901
|
+
testCM("wordMovementCommands", function(cm) {
|
902
|
+
cm.execCommand("goWordLeft");
|
903
|
+
eqPos(cm.getCursor(), Pos(0, 0));
|
904
|
+
cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
|
905
|
+
eqPos(cm.getCursor(), Pos(0, 7));
|
906
|
+
cm.execCommand("goWordLeft");
|
907
|
+
eqPos(cm.getCursor(), Pos(0, 5));
|
908
|
+
cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
|
909
|
+
eqPos(cm.getCursor(), Pos(0, 12));
|
910
|
+
cm.execCommand("goWordLeft");
|
911
|
+
eqPos(cm.getCursor(), Pos(0, 9));
|
912
|
+
cm.execCommand("goWordRight"); cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
|
913
|
+
eqPos(cm.getCursor(), Pos(0, 24));
|
914
|
+
cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
|
915
|
+
eqPos(cm.getCursor(), Pos(1, 9));
|
916
|
+
cm.execCommand("goWordRight");
|
917
|
+
eqPos(cm.getCursor(), Pos(1, 13));
|
918
|
+
cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
|
919
|
+
eqPos(cm.getCursor(), Pos(2, 0));
|
920
|
+
}, {value: "this is (the) firstline.\na foo12\u00e9\u00f8\u00d7bar\n"});
|
921
|
+
|
922
|
+
testCM("groupMovementCommands", function(cm) {
|
923
|
+
cm.execCommand("goGroupLeft");
|
924
|
+
eqPos(cm.getCursor(), Pos(0, 0));
|
925
|
+
cm.execCommand("goGroupRight");
|
926
|
+
eqPos(cm.getCursor(), Pos(0, 4));
|
927
|
+
cm.execCommand("goGroupRight");
|
928
|
+
eqPos(cm.getCursor(), Pos(0, 7));
|
929
|
+
cm.execCommand("goGroupRight");
|
930
|
+
eqPos(cm.getCursor(), Pos(0, 10));
|
931
|
+
cm.execCommand("goGroupLeft");
|
932
|
+
eqPos(cm.getCursor(), Pos(0, 7));
|
933
|
+
cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight");
|
934
|
+
eqPos(cm.getCursor(), Pos(0, 15));
|
935
|
+
cm.setCursor(Pos(0, 17));
|
936
|
+
cm.execCommand("goGroupLeft");
|
937
|
+
eqPos(cm.getCursor(), Pos(0, 16));
|
938
|
+
cm.execCommand("goGroupLeft");
|
939
|
+
eqPos(cm.getCursor(), Pos(0, 14));
|
940
|
+
cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight");
|
941
|
+
eqPos(cm.getCursor(), Pos(0, 20));
|
942
|
+
cm.execCommand("goGroupRight");
|
943
|
+
eqPos(cm.getCursor(), Pos(1, 5));
|
944
|
+
cm.execCommand("goGroupLeft"); cm.execCommand("goGroupLeft");
|
945
|
+
eqPos(cm.getCursor(), Pos(1, 0));
|
946
|
+
cm.execCommand("goGroupLeft");
|
947
|
+
eqPos(cm.getCursor(), Pos(0, 16));
|
948
|
+
}, {value: "booo ba---quux. ffff\n abc d"});
|
949
|
+
|
950
|
+
testCM("charMovementCommands", function(cm) {
|
951
|
+
cm.execCommand("goCharLeft"); cm.execCommand("goColumnLeft");
|
952
|
+
eqPos(cm.getCursor(), Pos(0, 0));
|
953
|
+
cm.execCommand("goCharRight"); cm.execCommand("goCharRight");
|
954
|
+
eqPos(cm.getCursor(), Pos(0, 2));
|
955
|
+
cm.setCursor(Pos(1, 0));
|
956
|
+
cm.execCommand("goColumnLeft");
|
957
|
+
eqPos(cm.getCursor(), Pos(1, 0));
|
958
|
+
cm.execCommand("goCharLeft");
|
959
|
+
eqPos(cm.getCursor(), Pos(0, 5));
|
960
|
+
cm.execCommand("goColumnRight");
|
961
|
+
eqPos(cm.getCursor(), Pos(0, 5));
|
962
|
+
cm.execCommand("goCharRight");
|
963
|
+
eqPos(cm.getCursor(), Pos(1, 0));
|
964
|
+
cm.execCommand("goLineEnd");
|
965
|
+
eqPos(cm.getCursor(), Pos(1, 5));
|
966
|
+
cm.execCommand("goLineStartSmart");
|
967
|
+
eqPos(cm.getCursor(), Pos(1, 1));
|
968
|
+
cm.execCommand("goLineStartSmart");
|
969
|
+
eqPos(cm.getCursor(), Pos(1, 0));
|
970
|
+
cm.setCursor(Pos(2, 0));
|
971
|
+
cm.execCommand("goCharRight"); cm.execCommand("goColumnRight");
|
972
|
+
eqPos(cm.getCursor(), Pos(2, 0));
|
973
|
+
}, {value: "line1\n ine2\n"});
|
974
|
+
|
975
|
+
testCM("verticalMovementCommands", function(cm) {
|
976
|
+
cm.execCommand("goLineUp");
|
977
|
+
eqPos(cm.getCursor(), Pos(0, 0));
|
978
|
+
cm.execCommand("goLineDown");
|
979
|
+
if (!phantom) // This fails in PhantomJS, though not in a real Webkit
|
980
|
+
eqPos(cm.getCursor(), Pos(1, 0));
|
981
|
+
cm.setCursor(Pos(1, 12));
|
982
|
+
cm.execCommand("goLineDown");
|
983
|
+
eqPos(cm.getCursor(), Pos(2, 5));
|
984
|
+
cm.execCommand("goLineDown");
|
985
|
+
eqPos(cm.getCursor(), Pos(3, 0));
|
986
|
+
cm.execCommand("goLineUp");
|
987
|
+
eqPos(cm.getCursor(), Pos(2, 5));
|
988
|
+
cm.execCommand("goLineUp");
|
989
|
+
eqPos(cm.getCursor(), Pos(1, 12));
|
990
|
+
cm.execCommand("goPageDown");
|
991
|
+
eqPos(cm.getCursor(), Pos(5, 0));
|
992
|
+
cm.execCommand("goPageDown"); cm.execCommand("goLineDown");
|
993
|
+
eqPos(cm.getCursor(), Pos(5, 0));
|
994
|
+
cm.execCommand("goPageUp");
|
995
|
+
eqPos(cm.getCursor(), Pos(0, 0));
|
996
|
+
}, {value: "line1\nlong long line2\nline3\n\nline5\n"});
|
997
|
+
|
998
|
+
testCM("verticalMovementCommandsWrapping", function(cm) {
|
999
|
+
cm.setSize(120);
|
1000
|
+
cm.setCursor(Pos(0, 5));
|
1001
|
+
cm.execCommand("goLineDown");
|
1002
|
+
eq(cm.getCursor().line, 0);
|
1003
|
+
is(cm.getCursor().ch > 5, "moved beyond wrap");
|
1004
|
+
for (var i = 0; ; ++i) {
|
1005
|
+
is(i < 20, "no endless loop");
|
1006
|
+
cm.execCommand("goLineDown");
|
1007
|
+
var cur = cm.getCursor();
|
1008
|
+
if (cur.line == 1) eq(cur.ch, 5);
|
1009
|
+
if (cur.line == 2) { eq(cur.ch, 1); break; }
|
1010
|
+
}
|
1011
|
+
}, {value: "a very long line that wraps around somehow so that we can test cursor movement\nshortone\nk",
|
1012
|
+
lineWrapping: true});
|
1013
|
+
|
1014
|
+
testCM("rtlMovement", function(cm) {
|
1015
|
+
forEach(["خحج", "خحabcخحج", "abخحخحجcd", "abخde", "abخح2342خ1حج", "خ1ح2خح3حxج",
|
1016
|
+
"خحcd", "1خحcd", "abcdeح1ج", "خمرحبها مها!", "foobarر"], function(line) {
|
1017
|
+
var inv = line.charAt(0) == "خ";
|
1018
|
+
cm.setValue(line + "\n"); cm.execCommand(inv ? "goLineEnd" : "goLineStart");
|
1019
|
+
var cursor = byClassName(cm.getWrapperElement(), "CodeMirror-cursor")[0];
|
1020
|
+
var prevX = cursor.offsetLeft, prevY = cursor.offsetTop;
|
1021
|
+
for (var i = 0; i <= line.length; ++i) {
|
1022
|
+
cm.execCommand("goCharRight");
|
1023
|
+
if (i == line.length) is(cursor.offsetTop > prevY, "next line");
|
1024
|
+
else is(cursor.offsetLeft > prevX, "moved right");
|
1025
|
+
prevX = cursor.offsetLeft; prevY = cursor.offsetTop;
|
1026
|
+
}
|
1027
|
+
cm.setCursor(0, 0); cm.execCommand(inv ? "goLineStart" : "goLineEnd");
|
1028
|
+
prevX = cursor.offsetLeft;
|
1029
|
+
for (var i = 0; i < line.length; ++i) {
|
1030
|
+
cm.execCommand("goCharLeft");
|
1031
|
+
is(cursor.offsetLeft < prevX, "moved left");
|
1032
|
+
prevX = cursor.offsetLeft;
|
1033
|
+
}
|
1034
|
+
});
|
1035
|
+
}, {rtlMoveVisually: true});
|
1036
|
+
|
1037
|
+
// Verify that updating a line clears its bidi ordering
|
1038
|
+
testCM("bidiUpdate", function(cm) {
|
1039
|
+
cm.setCursor(Pos(0, 2));
|
1040
|
+
cm.replaceSelection("خحج", "start");
|
1041
|
+
cm.execCommand("goCharRight");
|
1042
|
+
eqPos(cm.getCursor(), Pos(0, 4));
|
1043
|
+
}, {value: "abcd\n"});
|
1044
|
+
|
1045
|
+
testCM("movebyTextUnit", function(cm) {
|
1046
|
+
cm.setValue("בְּרֵאשִ\ńéée\n");
|
1047
|
+
cm.execCommand("goLineEnd");
|
1048
|
+
for (var i = 0; i < 4; ++i) cm.execCommand("goCharRight");
|
1049
|
+
eqPos(cm.getCursor(), Pos(0, 0));
|
1050
|
+
cm.execCommand("goCharRight");
|
1051
|
+
eqPos(cm.getCursor(), Pos(1, 0));
|
1052
|
+
cm.execCommand("goCharRight");
|
1053
|
+
cm.execCommand("goCharRight");
|
1054
|
+
eqPos(cm.getCursor(), Pos(1, 3));
|
1055
|
+
cm.execCommand("goCharRight");
|
1056
|
+
cm.execCommand("goCharRight");
|
1057
|
+
eqPos(cm.getCursor(), Pos(1, 6));
|
1058
|
+
});
|
1059
|
+
|
1060
|
+
testCM("lineChangeEvents", function(cm) {
|
1061
|
+
addDoc(cm, 3, 5);
|
1062
|
+
var log = [], want = ["ch 0", "ch 1", "del 2", "ch 0", "ch 0", "del 1", "del 3", "del 4"];
|
1063
|
+
for (var i = 0; i < 5; ++i) {
|
1064
|
+
CodeMirror.on(cm.getLineHandle(i), "delete", function(i) {
|
1065
|
+
return function() {log.push("del " + i);};
|
1066
|
+
}(i));
|
1067
|
+
CodeMirror.on(cm.getLineHandle(i), "change", function(i) {
|
1068
|
+
return function() {log.push("ch " + i);};
|
1069
|
+
}(i));
|
1070
|
+
}
|
1071
|
+
cm.replaceRange("x", Pos(0, 1));
|
1072
|
+
cm.replaceRange("xy", Pos(1, 1), Pos(2));
|
1073
|
+
cm.replaceRange("foo\nbar", Pos(0, 1));
|
1074
|
+
cm.replaceRange("", Pos(0, 0), Pos(cm.lineCount()));
|
1075
|
+
eq(log.length, want.length, "same length");
|
1076
|
+
for (var i = 0; i < log.length; ++i)
|
1077
|
+
eq(log[i], want[i]);
|
1078
|
+
});
|
1079
|
+
|
1080
|
+
testCM("scrollEntirelyToRight", function(cm) {
|
1081
|
+
if (phantom) return;
|
1082
|
+
addDoc(cm, 500, 2);
|
1083
|
+
cm.setCursor(Pos(0, 500));
|
1084
|
+
var wrap = cm.getWrapperElement(), cur = byClassName(wrap, "CodeMirror-cursor")[0];
|
1085
|
+
is(wrap.getBoundingClientRect().right > cur.getBoundingClientRect().left);
|
1086
|
+
});
|
1087
|
+
|
1088
|
+
testCM("lineWidgets", function(cm) {
|
1089
|
+
addDoc(cm, 500, 3);
|
1090
|
+
var last = cm.charCoords(Pos(2, 0));
|
1091
|
+
var node = document.createElement("div");
|
1092
|
+
node.innerHTML = "hi";
|
1093
|
+
var widget = cm.addLineWidget(1, node);
|
1094
|
+
is(last.top < cm.charCoords(Pos(2, 0)).top, "took up space");
|
1095
|
+
cm.setCursor(Pos(1, 1));
|
1096
|
+
cm.execCommand("goLineDown");
|
1097
|
+
eqPos(cm.getCursor(), Pos(2, 1));
|
1098
|
+
cm.execCommand("goLineUp");
|
1099
|
+
eqPos(cm.getCursor(), Pos(1, 1));
|
1100
|
+
});
|
1101
|
+
|
1102
|
+
testCM("lineWidgetFocus", function(cm) {
|
1103
|
+
var place = document.getElementById("testground");
|
1104
|
+
place.className = "offscreen";
|
1105
|
+
try {
|
1106
|
+
addDoc(cm, 500, 10);
|
1107
|
+
var node = document.createElement("input");
|
1108
|
+
var widget = cm.addLineWidget(1, node);
|
1109
|
+
node.focus();
|
1110
|
+
eq(document.activeElement, node);
|
1111
|
+
cm.replaceRange("new stuff", Pos(1, 0));
|
1112
|
+
eq(document.activeElement, node);
|
1113
|
+
} finally {
|
1114
|
+
place.className = "";
|
1115
|
+
}
|
1116
|
+
});
|
1117
|
+
|
1118
|
+
testCM("getLineNumber", function(cm) {
|
1119
|
+
addDoc(cm, 2, 20);
|
1120
|
+
var h1 = cm.getLineHandle(1);
|
1121
|
+
eq(cm.getLineNumber(h1), 1);
|
1122
|
+
cm.replaceRange("hi\nbye\n", Pos(0, 0));
|
1123
|
+
eq(cm.getLineNumber(h1), 3);
|
1124
|
+
cm.setValue("");
|
1125
|
+
eq(cm.getLineNumber(h1), null);
|
1126
|
+
});
|
1127
|
+
|
1128
|
+
testCM("jumpTheGap", function(cm) {
|
1129
|
+
var longLine = "abcdef ghiklmnop qrstuvw xyz ";
|
1130
|
+
longLine += longLine; longLine += longLine; longLine += longLine;
|
1131
|
+
cm.setLine(2, longLine);
|
1132
|
+
cm.setSize("200px", null);
|
1133
|
+
cm.getWrapperElement().style.lineHeight = 2;
|
1134
|
+
cm.refresh();
|
1135
|
+
cm.setCursor(Pos(0, 1));
|
1136
|
+
cm.execCommand("goLineDown");
|
1137
|
+
eqPos(cm.getCursor(), Pos(1, 1));
|
1138
|
+
cm.execCommand("goLineDown");
|
1139
|
+
eqPos(cm.getCursor(), Pos(2, 1));
|
1140
|
+
cm.execCommand("goLineDown");
|
1141
|
+
eq(cm.getCursor().line, 2);
|
1142
|
+
is(cm.getCursor().ch > 1);
|
1143
|
+
cm.execCommand("goLineUp");
|
1144
|
+
eqPos(cm.getCursor(), Pos(2, 1));
|
1145
|
+
cm.execCommand("goLineUp");
|
1146
|
+
eqPos(cm.getCursor(), Pos(1, 1));
|
1147
|
+
var node = document.createElement("div");
|
1148
|
+
node.innerHTML = "hi"; node.style.height = "30px";
|
1149
|
+
cm.addLineWidget(0, node);
|
1150
|
+
cm.addLineWidget(1, node.cloneNode(true), {above: true});
|
1151
|
+
cm.setCursor(Pos(0, 2));
|
1152
|
+
cm.execCommand("goLineDown");
|
1153
|
+
eqPos(cm.getCursor(), Pos(1, 2));
|
1154
|
+
cm.execCommand("goLineUp");
|
1155
|
+
eqPos(cm.getCursor(), Pos(0, 2));
|
1156
|
+
}, {lineWrapping: true, value: "abc\ndef\nghi\njkl\n"});
|
1157
|
+
|
1158
|
+
testCM("addLineClass", function(cm) {
|
1159
|
+
function cls(line, text, bg, wrap) {
|
1160
|
+
var i = cm.lineInfo(line);
|
1161
|
+
eq(i.textClass, text);
|
1162
|
+
eq(i.bgClass, bg);
|
1163
|
+
eq(i.wrapClass, wrap);
|
1164
|
+
}
|
1165
|
+
cm.addLineClass(0, "text", "foo");
|
1166
|
+
cm.addLineClass(0, "text", "bar");
|
1167
|
+
cm.addLineClass(1, "background", "baz");
|
1168
|
+
cm.addLineClass(1, "wrap", "foo");
|
1169
|
+
cls(0, "foo bar", null, null);
|
1170
|
+
cls(1, null, "baz", "foo");
|
1171
|
+
var lines = cm.display.lineDiv;
|
1172
|
+
eq(byClassName(lines, "foo").length, 2);
|
1173
|
+
eq(byClassName(lines, "bar").length, 1);
|
1174
|
+
eq(byClassName(lines, "baz").length, 1);
|
1175
|
+
cm.removeLineClass(0, "text", "foo");
|
1176
|
+
cls(0, "bar", null, null);
|
1177
|
+
cm.removeLineClass(0, "text", "foo");
|
1178
|
+
cls(0, "bar", null, null);
|
1179
|
+
cm.removeLineClass(0, "text", "bar");
|
1180
|
+
cls(0, null, null, null);
|
1181
|
+
cm.addLineClass(1, "wrap", "quux");
|
1182
|
+
cls(1, null, "baz", "foo quux");
|
1183
|
+
cm.removeLineClass(1, "wrap");
|
1184
|
+
cls(1, null, "baz", null);
|
1185
|
+
}, {value: "hohoho\n"});
|
1186
|
+
|
1187
|
+
testCM("atomicMarker", function(cm) {
|
1188
|
+
addDoc(cm, 10, 10);
|
1189
|
+
function atom(ll, cl, lr, cr, li, ri) {
|
1190
|
+
return cm.markText(Pos(ll, cl), Pos(lr, cr),
|
1191
|
+
{atomic: true, inclusiveLeft: li, inclusiveRight: ri});
|
1192
|
+
}
|
1193
|
+
var m = atom(0, 1, 0, 5);
|
1194
|
+
cm.setCursor(Pos(0, 1));
|
1195
|
+
cm.execCommand("goCharRight");
|
1196
|
+
eqPos(cm.getCursor(), Pos(0, 5));
|
1197
|
+
cm.execCommand("goCharLeft");
|
1198
|
+
eqPos(cm.getCursor(), Pos(0, 1));
|
1199
|
+
m.clear();
|
1200
|
+
m = atom(0, 0, 0, 5, true);
|
1201
|
+
eqPos(cm.getCursor(), Pos(0, 5), "pushed out");
|
1202
|
+
cm.execCommand("goCharLeft");
|
1203
|
+
eqPos(cm.getCursor(), Pos(0, 5));
|
1204
|
+
m.clear();
|
1205
|
+
m = atom(8, 4, 9, 10, false, true);
|
1206
|
+
cm.setCursor(Pos(9, 8));
|
1207
|
+
eqPos(cm.getCursor(), Pos(8, 4), "set");
|
1208
|
+
cm.execCommand("goCharRight");
|
1209
|
+
eqPos(cm.getCursor(), Pos(8, 4), "char right");
|
1210
|
+
cm.execCommand("goLineDown");
|
1211
|
+
eqPos(cm.getCursor(), Pos(8, 4), "line down");
|
1212
|
+
cm.execCommand("goCharLeft");
|
1213
|
+
eqPos(cm.getCursor(), Pos(8, 3));
|
1214
|
+
m.clear();
|
1215
|
+
m = atom(1, 1, 3, 8);
|
1216
|
+
cm.setCursor(Pos(2, 0));
|
1217
|
+
eqPos(cm.getCursor(), Pos(3, 8));
|
1218
|
+
cm.execCommand("goCharLeft");
|
1219
|
+
eqPos(cm.getCursor(), Pos(1, 1));
|
1220
|
+
cm.execCommand("goCharRight");
|
1221
|
+
eqPos(cm.getCursor(), Pos(3, 8));
|
1222
|
+
cm.execCommand("goLineUp");
|
1223
|
+
eqPos(cm.getCursor(), Pos(1, 1));
|
1224
|
+
cm.execCommand("goLineDown");
|
1225
|
+
eqPos(cm.getCursor(), Pos(3, 8));
|
1226
|
+
cm.execCommand("delCharBefore");
|
1227
|
+
eq(cm.getValue().length, 80, "del chunk");
|
1228
|
+
m = atom(3, 0, 5, 5);
|
1229
|
+
cm.setCursor(Pos(3, 0));
|
1230
|
+
cm.execCommand("delWordAfter");
|
1231
|
+
eq(cm.getValue().length, 53, "del chunk");
|
1232
|
+
});
|
1233
|
+
|
1234
|
+
testCM("readOnlyMarker", function(cm) {
|
1235
|
+
function mark(ll, cl, lr, cr, at) {
|
1236
|
+
return cm.markText(Pos(ll, cl), Pos(lr, cr),
|
1237
|
+
{readOnly: true, atomic: at});
|
1238
|
+
}
|
1239
|
+
var m = mark(0, 1, 0, 4);
|
1240
|
+
cm.setCursor(Pos(0, 2));
|
1241
|
+
cm.replaceSelection("hi", "end");
|
1242
|
+
eqPos(cm.getCursor(), Pos(0, 2));
|
1243
|
+
eq(cm.getLine(0), "abcde");
|
1244
|
+
cm.execCommand("selectAll");
|
1245
|
+
cm.replaceSelection("oops");
|
1246
|
+
eq(cm.getValue(), "oopsbcd");
|
1247
|
+
cm.undo();
|
1248
|
+
eqPos(m.find().from, Pos(0, 1));
|
1249
|
+
eqPos(m.find().to, Pos(0, 4));
|
1250
|
+
m.clear();
|
1251
|
+
cm.setCursor(Pos(0, 2));
|
1252
|
+
cm.replaceSelection("hi");
|
1253
|
+
eq(cm.getLine(0), "abhicde");
|
1254
|
+
eqPos(cm.getCursor(), Pos(0, 4));
|
1255
|
+
m = mark(0, 2, 2, 2, true);
|
1256
|
+
cm.setSelection(Pos(1, 1), Pos(2, 4));
|
1257
|
+
cm.replaceSelection("t", "end");
|
1258
|
+
eqPos(cm.getCursor(), Pos(2, 3));
|
1259
|
+
eq(cm.getLine(2), "klto");
|
1260
|
+
cm.execCommand("goCharLeft");
|
1261
|
+
cm.execCommand("goCharLeft");
|
1262
|
+
eqPos(cm.getCursor(), Pos(0, 2));
|
1263
|
+
cm.setSelection(Pos(0, 1), Pos(0, 3));
|
1264
|
+
cm.replaceSelection("xx");
|
1265
|
+
eqPos(cm.getCursor(), Pos(0, 3));
|
1266
|
+
eq(cm.getLine(0), "axxhicde");
|
1267
|
+
}, {value: "abcde\nfghij\nklmno\n"});
|
1268
|
+
|
1269
|
+
testCM("dirtyBit", function(cm) {
|
1270
|
+
eq(cm.isClean(), true);
|
1271
|
+
cm.replaceSelection("boo");
|
1272
|
+
eq(cm.isClean(), false);
|
1273
|
+
cm.undo();
|
1274
|
+
eq(cm.isClean(), true);
|
1275
|
+
cm.replaceSelection("boo");
|
1276
|
+
cm.replaceSelection("baz");
|
1277
|
+
cm.undo();
|
1278
|
+
eq(cm.isClean(), false);
|
1279
|
+
cm.markClean();
|
1280
|
+
eq(cm.isClean(), true);
|
1281
|
+
cm.undo();
|
1282
|
+
eq(cm.isClean(), false);
|
1283
|
+
cm.redo();
|
1284
|
+
eq(cm.isClean(), true);
|
1285
|
+
});
|
1286
|
+
|
1287
|
+
testCM("addKeyMap", function(cm) {
|
1288
|
+
function sendKey(code) {
|
1289
|
+
cm.triggerOnKeyDown({type: "keydown", keyCode: code,
|
1290
|
+
preventDefault: function(){}, stopPropagation: function(){}});
|
1291
|
+
}
|
1292
|
+
|
1293
|
+
sendKey(39);
|
1294
|
+
eqPos(cm.getCursor(), Pos(0, 1));
|
1295
|
+
var test = 0;
|
1296
|
+
var map1 = {Right: function() { ++test; }}, map2 = {Right: function() { test += 10; }}
|
1297
|
+
cm.addKeyMap(map1);
|
1298
|
+
sendKey(39);
|
1299
|
+
eqPos(cm.getCursor(), Pos(0, 1));
|
1300
|
+
eq(test, 1);
|
1301
|
+
cm.addKeyMap(map2, true);
|
1302
|
+
sendKey(39);
|
1303
|
+
eq(test, 2);
|
1304
|
+
cm.removeKeyMap(map1);
|
1305
|
+
sendKey(39);
|
1306
|
+
eq(test, 12);
|
1307
|
+
cm.removeKeyMap(map2);
|
1308
|
+
sendKey(39);
|
1309
|
+
eq(test, 12);
|
1310
|
+
eqPos(cm.getCursor(), Pos(0, 2));
|
1311
|
+
cm.addKeyMap({Right: function() { test = 55; }, name: "mymap"});
|
1312
|
+
sendKey(39);
|
1313
|
+
eq(test, 55);
|
1314
|
+
cm.removeKeyMap("mymap");
|
1315
|
+
sendKey(39);
|
1316
|
+
eqPos(cm.getCursor(), Pos(0, 3));
|
1317
|
+
}, {value: "abc"});
|
1318
|
+
|
1319
|
+
testCM("findPosH", function(cm) {
|
1320
|
+
forEach([{from: Pos(0, 0), to: Pos(0, 1), by: 1},
|
1321
|
+
{from: Pos(0, 0), to: Pos(0, 0), by: -1, hitSide: true},
|
1322
|
+
{from: Pos(0, 0), to: Pos(0, 4), by: 1, unit: "word"},
|
1323
|
+
{from: Pos(0, 0), to: Pos(0, 8), by: 2, unit: "word"},
|
1324
|
+
{from: Pos(0, 0), to: Pos(2, 0), by: 20, unit: "word", hitSide: true},
|
1325
|
+
{from: Pos(0, 7), to: Pos(0, 5), by: -1, unit: "word"},
|
1326
|
+
{from: Pos(0, 4), to: Pos(0, 8), by: 1, unit: "word"},
|
1327
|
+
{from: Pos(1, 0), to: Pos(1, 18), by: 3, unit: "word"},
|
1328
|
+
{from: Pos(1, 22), to: Pos(1, 5), by: -3, unit: "word"},
|
1329
|
+
{from: Pos(1, 15), to: Pos(1, 10), by: -5},
|
1330
|
+
{from: Pos(1, 15), to: Pos(1, 10), by: -5, unit: "column"},
|
1331
|
+
{from: Pos(1, 15), to: Pos(1, 0), by: -50, unit: "column", hitSide: true},
|
1332
|
+
{from: Pos(1, 15), to: Pos(1, 24), by: 50, unit: "column", hitSide: true},
|
1333
|
+
{from: Pos(1, 15), to: Pos(2, 0), by: 50, hitSide: true}], function(t) {
|
1334
|
+
var r = cm.findPosH(t.from, t.by, t.unit || "char");
|
1335
|
+
eqPos(r, t.to);
|
1336
|
+
eq(!!r.hitSide, !!t.hitSide);
|
1337
|
+
});
|
1338
|
+
}, {value: "line one\nline two.something.other\n"});
|
1339
|
+
|
1340
|
+
testCM("beforeChange", function(cm) {
|
1341
|
+
cm.on("beforeChange", function(cm, change) {
|
1342
|
+
var text = [];
|
1343
|
+
for (var i = 0; i < change.text.length; ++i)
|
1344
|
+
text.push(change.text[i].replace(/\s/g, "_"));
|
1345
|
+
change.update(null, null, text);
|
1346
|
+
});
|
1347
|
+
cm.setValue("hello, i am a\nnew document\n");
|
1348
|
+
eq(cm.getValue(), "hello,_i_am_a\nnew_document\n");
|
1349
|
+
CodeMirror.on(cm.getDoc(), "beforeChange", function(doc, change) {
|
1350
|
+
if (change.from.line == 0) change.cancel();
|
1351
|
+
});
|
1352
|
+
cm.setValue("oops"); // Canceled
|
1353
|
+
eq(cm.getValue(), "hello,_i_am_a\nnew_document\n");
|
1354
|
+
cm.replaceRange("hey hey hey", Pos(1, 0), Pos(2, 0));
|
1355
|
+
eq(cm.getValue(), "hello,_i_am_a\nhey_hey_hey");
|
1356
|
+
}, {value: "abcdefghijk"});
|
1357
|
+
|
1358
|
+
testCM("beforeSelectionChange", function(cm) {
|
1359
|
+
function notAtEnd(cm, pos) {
|
1360
|
+
var len = cm.getLine(pos.line).length;
|
1361
|
+
if (!len || pos.ch == len) return Pos(pos.line, pos.ch - 1);
|
1362
|
+
return pos;
|
1363
|
+
}
|
1364
|
+
cm.on("beforeSelectionChange", function(cm, sel) {
|
1365
|
+
sel.head = notAtEnd(cm, sel.head);
|
1366
|
+
sel.anchor = notAtEnd(cm, sel.anchor);
|
1367
|
+
});
|
1368
|
+
|
1369
|
+
addDoc(cm, 10, 10);
|
1370
|
+
cm.execCommand("goLineEnd");
|
1371
|
+
eqPos(cm.getCursor(), Pos(0, 9));
|
1372
|
+
cm.execCommand("selectAll");
|
1373
|
+
eqPos(cm.getCursor("start"), Pos(0, 0));
|
1374
|
+
eqPos(cm.getCursor("end"), Pos(9, 9));
|
1375
|
+
});
|
1376
|
+
|
1377
|
+
testCM("change_removedText", function(cm) {
|
1378
|
+
cm.setValue("abc\ndef");
|
1379
|
+
|
1380
|
+
var removedText;
|
1381
|
+
cm.on("change", function(cm, change) {
|
1382
|
+
removedText = [change.removed, change.next && change.next.removed];
|
1383
|
+
});
|
1384
|
+
|
1385
|
+
cm.operation(function() {
|
1386
|
+
cm.replaceRange("xyz", Pos(0, 0), Pos(1,1));
|
1387
|
+
cm.replaceRange("123", Pos(0,0));
|
1388
|
+
});
|
1389
|
+
|
1390
|
+
eq(removedText[0].join("\n"), "abc\nd");
|
1391
|
+
eq(removedText[1].join("\n"), "");
|
1392
|
+
|
1393
|
+
cm.undo();
|
1394
|
+
eq(removedText[0].join("\n"), "123");
|
1395
|
+
eq(removedText[1].join("\n"), "xyz");
|
1396
|
+
|
1397
|
+
cm.redo();
|
1398
|
+
eq(removedText[0].join("\n"), "abc\nd");
|
1399
|
+
eq(removedText[1].join("\n"), "");
|
1400
|
+
});
|