Version Description
- 13-10-2022 =
- Improvement: Disable click for body content in Accordion widget
- Improvement: Remove unused file
- Improvement: Prevent adding script without enqueue wp functions
Download this release
Release Info
Developer | fauzanjegstudio |
Plugin | Jeg Elementor Kit |
Version | 2.5.2 |
Comparing to | |
See all releases |
Code changes from version 2.5.1 to 2.5.2
- assets/banner/gutenverse/index.html +0 -17
- assets/js/elements/accordion.js +1 -1
- assets/js/elements/elements.js +1 -1
- jeg-elementor-kit.php +2 -2
- lib/jeg-element/includes/class/elementor/control/class-dynamic-select-elementor.php +14 -14
- lib/jeg-element/includes/class/wpbakery/class-wpbakery-integration.php +29 -30
- lib/jeg-framework/assets/js/form/meta-box-container.js +3 -1
- lib/jeg-framework/assets/js/vendor/codemirror/AUTHORS +0 -510
- lib/jeg-framework/assets/js/vendor/codemirror/LICENSE +0 -19
- lib/jeg-framework/assets/js/vendor/codemirror/README.md +0 -28
- lib/jeg-framework/assets/js/vendor/codemirror/addon/comment/comment.js +0 -196
- lib/jeg-framework/assets/js/vendor/codemirror/addon/comment/continuecomment.js +0 -85
- lib/jeg-framework/assets/js/vendor/codemirror/addon/dialog/dialog.css +0 -32
- lib/jeg-framework/assets/js/vendor/codemirror/addon/dialog/dialog.js +0 -157
- lib/jeg-framework/assets/js/vendor/codemirror/addon/display/autorefresh.js +0 -47
- lib/jeg-framework/assets/js/vendor/codemirror/addon/display/fullscreen.css +0 -6
- lib/jeg-framework/assets/js/vendor/codemirror/addon/display/fullscreen.js +0 -41
- lib/jeg-framework/assets/js/vendor/codemirror/addon/display/panel.js +0 -112
- lib/jeg-framework/assets/js/vendor/codemirror/addon/display/placeholder.js +0 -60
- lib/jeg-framework/assets/js/vendor/codemirror/addon/display/rulers.js +0 -63
- lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/closebrackets.js +0 -195
- lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/closetag.js +0 -169
- lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/continuelist.js +0 -51
- lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/matchbrackets.js +0 -120
- lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/matchtags.js +0 -66
- lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/trailingspace.js +0 -27
- lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/brace-fold.js +0 -105
- lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/comment-fold.js +0 -59
- lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/foldcode.js +0 -149
- lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/foldgutter.css +0 -20
- lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/foldgutter.js +0 -146
- lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/indent-fold.js +0 -44
- lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/markdown-fold.js +0 -49
- lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/xml-fold.js +0 -182
- lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/anyword-hint.js +0 -41
- lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/css-hint.js +0 -60
- lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/html-hint.js +0 -348
- lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/javascript-hint.js +0 -146
- lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/show-hint.css +0 -38
- lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/show-hint.js +0 -447
- lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/sql-hint.js +0 -254
- lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/xml-hint.js +0 -110
- lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/coffeescript-lint.js +0 -41
- lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/css-lint.js +0 -35
- lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/html-lint.js +0 -46
- lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/javascript-lint.js +0 -136
- lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/json-lint.js +0 -31
- lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/lint.css +0 -73
- lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/lint.js +0 -231
- lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/yaml-lint.js +0 -28
- lib/jeg-framework/assets/js/vendor/codemirror/addon/merge/merge.css +0 -112
- lib/jeg-framework/assets/js/vendor/codemirror/addon/merge/merge.js +0 -772
- lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/loadmode.js +0 -64
- lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/multiplex.js +0 -123
- lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/multiplex_test.js +0 -33
- lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/overlay.js +0 -85
- lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/simple.js +0 -213
- lib/jeg-framework/assets/js/vendor/codemirror/addon/runmode/colorize.js +0 -40
- lib/jeg-framework/assets/js/vendor/codemirror/addon/runmode/runmode-standalone.js +0 -157
- lib/jeg-framework/assets/js/vendor/codemirror/addon/runmode/runmode.js +0 -72
- lib/jeg-framework/assets/js/vendor/codemirror/addon/runmode/runmode.node.js +0 -179
- lib/jeg-framework/assets/js/vendor/codemirror/addon/scroll/annotatescrollbar.js +0 -115
- lib/jeg-framework/assets/js/vendor/codemirror/addon/scroll/scrollpastend.js +0 -46
- lib/jeg-framework/assets/js/vendor/codemirror/addon/scroll/simplescrollbars.css +0 -66
- lib/jeg-framework/assets/js/vendor/codemirror/addon/scroll/simplescrollbars.js +0 -147
- lib/jeg-framework/assets/js/vendor/codemirror/addon/search/match-highlighter.js +0 -128
- lib/jeg-framework/assets/js/vendor/codemirror/addon/search/matchesonscrollbar.css +0 -8
- lib/jeg-framework/assets/js/vendor/codemirror/addon/search/matchesonscrollbar.js +0 -97
- lib/jeg-framework/assets/js/vendor/codemirror/addon/search/search.js +0 -228
- lib/jeg-framework/assets/js/vendor/codemirror/addon/search/searchcursor.js +0 -189
- lib/jeg-framework/assets/js/vendor/codemirror/addon/selection/active-line.js +0 -71
- lib/jeg-framework/assets/js/vendor/codemirror/addon/selection/mark-selection.js +0 -118
- lib/jeg-framework/assets/js/vendor/codemirror/addon/selection/selection-pointer.js +0 -98
- lib/jeg-framework/assets/js/vendor/codemirror/addon/tern/tern.css +0 -87
- lib/jeg-framework/assets/js/vendor/codemirror/addon/tern/tern.js +0 -701
- lib/jeg-framework/assets/js/vendor/codemirror/addon/tern/worker.js +0 -44
- lib/jeg-framework/assets/js/vendor/codemirror/addon/wrap/hardwrap.js +0 -142
- lib/jeg-framework/assets/js/vendor/codemirror/bin/authors.sh +0 -6
- lib/jeg-framework/assets/js/vendor/codemirror/bin/compress +0 -92
- lib/jeg-framework/assets/js/vendor/codemirror/bin/lint +0 -3
- lib/jeg-framework/assets/js/vendor/codemirror/bin/release +0 -45
- lib/jeg-framework/assets/js/vendor/codemirror/bin/source-highlight +0 -51
- lib/jeg-framework/assets/js/vendor/codemirror/keymap/emacs.js +0 -412
- lib/jeg-framework/assets/js/vendor/codemirror/keymap/sublime.js +0 -565
- lib/jeg-framework/assets/js/vendor/codemirror/keymap/vim.js +0 -5060
- lib/jeg-framework/assets/js/vendor/codemirror/lib/codemirror.css +0 -334
- lib/jeg-framework/assets/js/vendor/codemirror/lib/codemirror.js +0 -8872
- lib/jeg-framework/assets/js/vendor/codemirror/mode/coffeescript/coffeescript.js +0 -60
assets/banner/gutenverse/index.html
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<div class="gutenverse-banner">
|
2 |
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
|
3 |
-
<link rel="stylesheet" href="style.css">
|
4 |
-
<div class="banner-content">
|
5 |
-
<div class="logo-wrapper"><img class="logo" src="gutenverse-logo.svg" alt="Logo" /></div>
|
6 |
-
<div class="main-content">
|
7 |
-
Advanced Addons for Gutenberg Or Fullsite Editing (FSE)
|
8 |
-
</div>
|
9 |
-
<div class="buttons">
|
10 |
-
<div class="plugin-link">
|
11 |
-
<a href="https://wordpress.org/plugins/gutenverse/" target="_blank" rel="noreferrer">
|
12 |
-
Try Gutenverse
|
13 |
-
</a>
|
14 |
-
</div>
|
15 |
-
</div>
|
16 |
-
</div>
|
17 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/elements/accordion.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-accordion",cards:".card-wrapper"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$cards:this.$element.find(e.cards)}}bindEvents(){this.onClick()}onClick(){this.elements.$cards.each((function(){jQuery(this).on("click",(function(e){"A"===e.target.nodeName&&!jQuery(e.target).hasClass("card-header-button")||jQuery(e.target).hasClass("card-body")||(e.preventDefault(),jQuery(this).hasClass("expand")?(jQuery(this).find(".card-expand").slideUp(),jQuery(this).removeClass("expand")):(jQuery(this).parent().find(".card-expand").slideUp(),jQuery(this).parent().find(".card-wrapper").removeClass("expand"),jQuery(this).addClass("expand"),jQuery(this).find(".card-expand").slideDown()))}))}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_accordion.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))}]);
|
assets/js/elements/elements.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){var t={};function n(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(s,o,function(t){return e[t]}.bind(null,o));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1),n(2),n(3),n(4),n(5),n(6),n(7),n(8),n(9),n(10),n(11),n(12),n(13),n(14),n(15),n(16),n(17),n(18),n(19),e.exports=n(20)},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-accordion",cards:".card-wrapper"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$cards:this.$element.find(e.cards)}}bindEvents(){this.onClick()}onClick(){this.elements.$cards.each((function(){jQuery(this).on("click",(function(e){("A"!==e.target.nodeName||jQuery(e.target).hasClass("card-header-button"))&&(e.preventDefault(),jQuery(this).hasClass("expand")?(jQuery(this).find(".card-expand").slideUp(),jQuery(this).removeClass("expand")):(jQuery(this).parent().find(".card-expand").slideUp(),jQuery(this).parent().find(".card-wrapper").removeClass("expand"),jQuery(this).addClass("expand"),jQuery(this).find(".card-expand").slideDown()))}))}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_accordion.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-animated-text",dynamic:".dynamic-wrapper"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$dynamic:this.$element.find(e.dynamic)}}bindEvents(){this.onRenderElement()}onRenderElement(){if("rotating"==this.elements.$wrapper.data("style")){const e=this.elements.$wrapper.data("rotate"),t=this.elements.$dynamic.find(".dynamic-text");if(t.length>0){const n=t.first();["typing","swirl","blinds","wave"].includes(e)?this.animateText(n,this.getNextText(n)):this.showText(n,this.getNextText(n))}}}animateText(e,t){this.elements.$dynamic.removeClass("typing-delete"),e.addClass("show-text"),this.elements.$dynamic.removeClass("cursor-blink"),this.animateLetter(e.find(".dynamic-text-letter").first(),e,t)}animateLetter(e,t,n){const s=this,o=this.elements.$wrapper.data("letter-speed");e.addClass("show-letter"),setTimeout((function(){e.is(":last-child")?s.hideText(t,n):s.animateLetter(e.next(),t,n)}),o)}getNextText(e){return e.is(":last-child")?this.elements.$dynamic.find(".dynamic-text").first():e.next()}hideText(e,t){const n=this,s=n.elements.$wrapper.data("rotate"),o=n.elements.$wrapper.data("delay");this.elements.$dynamic.addClass("cursor-blink"),setTimeout((function(){if("typing"==s){const s=n.elements.$wrapper.data("delay-delete");n.elements.$dynamic.addClass("typing-delete"),setTimeout((function(){e.removeClass("show-text"),e.find(".dynamic-text-letter").removeClass("show-letter"),n.animateText(t,n.getNextText(t))}),s)}else e.removeClass("show-text"),e.find(".dynamic-text-letter").removeClass("show-letter"),n.animateText(t,n.getNextText(t))}),o)}showText(e,t){const n=this,s=n.elements.$wrapper.data("delay"),o=n.elements.$wrapper.data("rotate");if(e.addClass("show-text"),"clip"==o){const o=n.elements.$wrapper.data("clip-duration");n.elements.$dynamic.width(e.width()+10),n.elements.$dynamic.animate({width:0},o/2,(function(){e.removeClass("show-text"),t.addClass("show-text"),n.elements.$dynamic.animate({width:t.width()+10},o/2,(function(){setTimeout((function(){e.removeClass("show-text"),n.showText(t,n.getNextText(t))}),s)}))}))}else n.elements.$dynamic.width(e.width()),setTimeout((function(){e.removeClass("show-text"),n.showText(t,n.getNextText(t))}),s)}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_animated_text.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-client-logo",items:".client-track"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$items:this.$element.find(e.items)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.loadCarousel()}loadCarousel(){const e=this.elements.$wrapper.data("id"),t=this.elements.$wrapper.data("settings"),n=this.getSettings("selectors"),s=t.responsive,o={};let a;Object.entries(s).forEach((([e,t])=>{""===t.items&&""===t.margin||(o[t.breakpoint]={},a=t.breakpoint,""!==t.items&&(o[t.breakpoint].items=t.items),""!==t.margin&&(o[t.breakpoint].gutter=t.margin))})),void 0!==a&&0!==a&&(o[0]=o[a],delete o[a]);const i={container:n.wrapper+'[data-id="'+e+'"] '+n.items,loop:!0,mouseDrag:!0,autoplay:t.autoplay,autoplayTimeout:t.autoplay_speed,autoplayHoverPause:t.autoplay_hover_pause,navPosition:"bottom",controlsPosition:t.arrow_position,controlsText:[t.navigation_left,t.navigation_right],responsiveClass:!0,responsive:o};tns(i),this.elements.$wrapper.find("button[data-action]").remove(),t.show_navigation||this.elements.$wrapper.find(".tns-controls").remove(),t.show_dots||this.elements.$wrapper.find(".tns-nav").remove()}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_client_logo.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-countdown",days:".timer-container.timer-days",hours:".timer-container.timer-hours",minutes:".timer-container.timer-minutes",seconds:".timer-container.timer-seconds",counts:".timer-container .timer-count"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$days:this.$element.find(e.days),$hours:this.$element.find(e.hours),$minutes:this.$element.find(e.minutes),$seconds:this.$element.find(e.seconds),$counts:this.$element.find(e.counts)}}bindEvents(){this.onRender()}onRender(){const e=this,t=new Date(e.elements.$wrapper.data("due-date")).getTime(),n=setInterval((function(){const s=new Date,o=t-s,a=Math.floor(o/864e5),i=Math.floor(o%864e5/36e5),r=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3);e.elements.$counts.removeClass("timer-loading"),o>=0?(e.elements.$days&&e.elements.$days.find(".timer-count").text(a),e.elements.$hours&&e.elements.$hours.find(".timer-count").text(i),e.elements.$minutes&&e.elements.$minutes.find(".timer-count").text(r),e.elements.$seconds&&e.elements.$seconds.find(".timer-count").text(l)):(clearInterval(n),e.elements.$wrapper.addClass("countdown-expired"),e.onExpired())}),1e3)}onExpired(){const e=this.elements.$wrapper,t=e.data("expired-type");if("message"==t){const t=e.data("expired-title"),n=e.data("expired-content");e.html(`\n <div class="expire-message">\n <span class="expire-title">${t}</span>\n <span class="expire-content">${n}</span>\n </div>\n `)}else if("redirect"==t){const t=e.data("redirect-link");window.self!==window.top?e.html(`<div class="expire-message">\n <span class="expire-content">${iframe_content}</span>\n </div>\n `):location.href=t}else if("template"==t){const t=e.data("template");e.html(t)}}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_countdown.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-fun-fact",number:".number"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$number:this.$element.find(e.number)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.countNumber(),jQuery(window).on("scroll",this.countNumber.bind(this))}countNumber(){const e=this.elements.$number;this.onScreen()&&!e.hasClass("loaded")&&(e.prop("Counter",0).animate({Counter:e.data("value")},{duration:e.data("animation-duration"),easing:"swing",step:function(t){e.text(Math.ceil(t).toLocaleString())},complete:function(){e.text(e.data("value").toLocaleString())}}),e.addClass("loaded"))}onScreen(){const e=jQuery(window).scrollTop()+jQuery(window).height();return this.elements.$wrapper.offset().top<=e}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_fun_fact.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-gallery",grid:".gallery-items",active_label:".jkit-gallery-control.active",filter:".jkit-gallery-control",filter_button:"#search-filter-trigger",filter_label:"#search-filter-trigger span",filter_list:".search-filter-controls",filter_form:"#jkit-gallery-search-box-input",load_more:".jkit-gallery-load-more"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$grid:this.$element.find(e.grid),$active_label:this.$element.find(e.active_label),$filter:this.$element.find(e.filter),$filter_button:this.$element.find(e.filter_button),$filter_label:this.$element.find(e.filter_label),$filter_list:this.$element.find(e.filter_list),$filter_form:this.$element.find(e.filter_form),$load_more:this.$element.find(e.load_more)}}bindEvents(){const e=this,t="masonry"==e.elements.$wrapper.data("grid")?"masonry":"fitRows",n=parseFloat((e.elements.$wrapper.data("animation-duration")/1e3).toFixed(2)).toString()+"s";e.grid=e.elements.$grid.isotope({itemSelector:".gallery-item-wrap",layoutMode:t,transitionDuration:n}),e.grid.imagesLoaded().progress((function(){e.grid.isotope("layout")})),e.onInitGallery(),e.onClickFilterButton(),e.onClickLoadMoreButton(),e.onFormChange()}onInitGallery(){const e=this;e.elements.$filter.each((function(){jQuery(this).on("click",(function(t){t.preventDefault();const n=e.getSettings("selectors"),s=jQuery(this).data("filter"),o=e.elements.$filter_label,a=e.elements.$filter_list,i=e.elements.$filter_button,r=e.elements.$filter_form;e.elements.$filter.removeClass("active"),jQuery(this).addClass("active"),e.elements.$active_label=e.$element.find(n.active_label),e.grid.isotope({filter:function(){const e="*"!==s?s.substring(1):"*",t=jQuery(this).attr("class").split(/\s+/);let n=!1;if(i.length>0){const s=r.val(),o=jQuery(this).find(".item-title").text(),a=jQuery(this).find(".item-content").text();n="*"!=e?(o.toLowerCase().includes(s.toLowerCase())||a.toLowerCase().includes(s.toLowerCase()))&&t.includes(e):o.toLowerCase().includes(s.toLowerCase())||a.toLowerCase().includes(s.toLowerCase())}else n="*"==e||t.includes(e);return n}}),i.length>0&&(o.text(jQuery(this).text()),a.removeClass("open-controls"))}))}))}onClickFilterButton(){const e=this;e.elements.$filter_button.on("click",(function(t){t.preventDefault();const n=e.elements.$filter_list;n.hasClass("open-controls")?n.removeClass("open-controls"):n.addClass("open-controls")}))}onFormChange(){const e=this,t=e.elements.$filter_form;void 0!==t&&t.on("change paste keyup",(function(){const t=jQuery(this).val();e.grid.isotope({filter:function(){const n=jQuery(this).find(".item-title").text(),s=jQuery(this).find(".item-content").text(),o=jQuery(this).attr("class").split(/\s+/),a="*"!==e.elements.$active_label.data("filter")?e.elements.$active_label.data("filter").substring(1):"*";let i=!1;return i="*"==a?n.toLowerCase().includes(t.toLowerCase())||s.toLowerCase().includes(t.toLowerCase()):(n.toLowerCase().includes(t.toLowerCase())||s.toLowerCase().includes(t.toLowerCase()))&&o.includes(a),i}})}))}onClickLoadMoreButton(){const e=this,t=e.elements.$wrapper.data("items");e.elements.$load_more.on("click",(function(n){n.preventDefault();const s=parseInt(e.elements.$wrapper.attr("data-current-loaded")),o=parseInt(e.elements.$wrapper.attr("data-count-items")),a=parseInt(e.elements.$wrapper.attr("data-load-more")),i=e.elements.$wrapper.attr("data-no-more");if(o>s)if(o-a-s>0){const n=[...t].splice(s,a);e.grid.append(n).isotope("reloadItems").isotope(),e.grid.imagesLoaded().progress((function(){e.grid.isotope("layout")})),e.elements.$wrapper.attr("data-current-loaded",s+a)}else{const n=[...t].splice(s,o-s);e.grid.append(n).isotope("reloadItems").isotope(),e.grid.imagesLoaded().progress((function(){e.grid.isotope("layout")})),e.elements.$wrapper.attr("data-current-loaded",o),e.elements.$load_more.find(".load-more-text").text(i),setTimeout((function(){e.elements.$load_more.fadeOut("slow")}),600)}}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_gallery.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-mailchimp",form:".jkit-mailchimp-form"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$form:this.$element.find(e.form)}}bindEvents(){this.onSubmit()}onSubmit(){this.elements.$form.on("submit",(function(e){e.preventDefault();const t=jQuery(this).find(".jkit-mailchimp-message"),n=jQuery(this).data("error-message"),s=jQuery(this).data("success-message"),o={first_name:jQuery(this).find('input[name="first-name"]').val(),last_name:jQuery(this).find('input[name="last-name"]').val(),phone:jQuery(this).find('input[name="phone"]').val(),email:jQuery(this).find('input[name="email"]').val(),list:jQuery(this).data("listed")};t.removeClass("error success"),jQuery.ajax({type:"POST",url:jkit_ajax_url,data:{data:o,action:"jkit_element_ajax_jkit_mailchimp"},dataType:"json",encode:!0}).done((function(e){e.status_code>=400?(t.addClass("error"),t.text(e.message)):(t.addClass("success"),t.text(s))})).fail((function(){t.addClass("error"),t.text(n)}))}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_mailchimp.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-nav-menu",container:".jkit-menu-wrapper",open_toggle:".jkit-hamburger-menu",close_toggle:'.jkit-close-menu, .menu-item:not(.menu-item-has-children) a[href^="#"]',dropdown_toggle:"li.menu-item-has-children > a i",menu_dropdown:"li.menu-item-has-children > a"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$container:this.$element.find(e.container),$open_toggle:this.$element.find(e.open_toggle),$close_toggle:this.$element.find(e.close_toggle),$dropdown_toggle:this.$element.find(e.dropdown_toggle),$menu_dropdown:this.$element.find(e.menu_dropdown)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.addBodyClass(),this.addDropdownIcon(),this.onToogleClick()}addBodyClass(){this.elements.$wrapper.length>0&&jQuery("body").addClass("jkit-nav-menu-loaded")}addDropdownIcon(){const e=this.elements.$wrapper.data("item-indicator"),t=this.elements.$menu_dropdown,n=this.getSettings("selectors");t.each((function(){0==jQuery(this).find("i").length&&jQuery(this).append(e)})),this.elements.$dropdown_toggle=this.$element.find(n.dropdown_toggle)}onToogleClick(){const e=this,t=e.elements.$wrapper,n=e.elements.$menu_dropdown,s=e.elements.$open_toggle,o=e.elements.$close_toggle,a=e.elements.$dropdown_toggle;s.on("click",(function(t){t.preventDefault(),e.elements.$container.hasClass("active")?e.elements.$container.removeClass("active"):e.elements.$container.addClass("active")})),o.on("click",(function(t){t.preventDefault(),e.elements.$container.removeClass("active")})),t.hasClass("submenu-click-title")?n.each((function(){jQuery(this).on("click",(function(e){e.preventDefault();const t=jQuery(this).next();t.hasClass("dropdown-open")?t.removeClass("dropdown-open"):t.addClass("dropdown-open")}))})):a.each((function(){jQuery(this).on("click",(function(e){e.preventDefault();const t=jQuery(this).parents("a").next();t.hasClass("dropdown-open")?t.removeClass("dropdown-open"):t.addClass("dropdown-open")}))}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_nav_menu.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-off-canvas",sidebar:".offcanvas-sidebar",hamburger:".offcanvas-sidebar-button",close:".offcanvas-close-button",overlay:".bg-overlay"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$sidebar:this.$element.find(e.sidebar),$hamburger:this.$element.find(e.hamburger),$close:this.$element.find(e.close),$overlay:this.$element.find(e.overlay)}}bindEvents(){const e=this;e.elements.$hamburger.on("click",(function(t){t.preventDefault(),e.elements.$sidebar.hasClass("active")?e.elements.$sidebar.removeClass("active"):e.elements.$sidebar.addClass("active")})),e.elements.$close.on("click",(function(t){t.preventDefault(),e.elements.$sidebar.removeClass("active")})),e.elements.$overlay.on("click",(function(t){t.preventDefault(),e.elements.$sidebar.removeClass("active")}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_off_canvas.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-pie-chart",canvas_main:"canvas.main-canvas",canvas_bg:"canvas.background-canvas",number:".pie-chart-content"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$canvas_main:this.$element.find(e.canvas_main),$canvas_bg:this.$element.find(e.canvas_bg),$number:this.$element.find(e.number)}}bindEvents(){this.animateChart(),jQuery(window).on("scroll",this.animateChart.bind(this)),"percentage"==this.elements.$wrapper.data("content-type")&&(this.countNumber(),jQuery(window).on("scroll",this.countNumber.bind(this)))}animateChart(){const e=this,t=e.elements.$canvas_main,n=e.elements.$canvas_bg;if(this.onScreen()&&!t.hasClass("loaded")){const s=e.elements.$wrapper,o=t.get(0).getContext("2d"),a=n.get(0).getContext("2d"),i=s.data("percent"),r=s.data("cutout")+"%",l=s.data("color-type"),d=s.data("color"),m=s.data("bg-color"),c=s.data("gradient1"),u=s.data("gradient2"),p={datasets:[{data:[i,100-i],backgroundColor:["#80b1ff","transparent"],hoverBackgroundColor:["#80b1ff","transparent"],borderWidth:0}]},f={datasets:[{data:[100],backgroundColor:["#d1d1d1"],hoverBackgroundColor:["#d1d1d1"],borderWidth:0}]},h={animation:{duration:s.data("animation-duration")},responsive:!0,cutout:r,plugins:{title:{display:!1},legend:{display:!1},tooltip:{enabled:!1}}},g={animation:!1,responsive:!0,cutout:r,plugins:{title:{display:!1},legend:{display:!1},tooltip:{enabled:!1}}};if("normal"==l)""!==d&&(p.datasets[0].backgroundColor[0]=d,p.datasets[0].hoverBackgroundColor[0]=d);else if("gradient"==l&&(""!==c||""!==u)){const e=o.createLinearGradient(0,0,0,170);""!==c&&e.addColorStop(0,c),""!==u&&e.addColorStop(1,u),p.datasets[0].backgroundColor[0]=e,p.datasets[0].hoverBackgroundColor[0]=e}""!==m&&(f.datasets[0].backgroundColor[0]=m,f.datasets[0].hoverBackgroundColor[0]=m),new Chart(o,{type:"doughnut",data:p,options:h}),new Chart(a,{type:"doughnut",data:f,options:g}),t.addClass("loaded"),t.css("display",""),n.css("display","")}}countNumber(){const e=this.elements.$number,t=this.elements.$wrapper;this.onScreen()&&!e.hasClass("loaded")&&(e.prop("Counter",0).animate({Counter:t.data("percent")},{duration:t.data("animation-duration"),easing:"swing",step:function(t){e.text(Math.ceil(t).toString()+"%")}}),e.addClass("loaded"))}onScreen(){const e=jQuery(window).scrollTop()+jQuery(window).height();return this.elements.$wrapper.offset().top<=e}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_pie_chart.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-portfolio-gallery",row_items:".row-item",gallery_items:".gallery-items",image_items:".image-item"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$row_items:this.$element.find(e.row_items),$gallery_items:this.$element.find(e.gallery_items),$image_items:this.$element.find(e.image_items)}}bindEvents(){this.onRenderInit(),this.onClickHover()}onRenderInit(){const e=this.elements.$row_items,t=this.elements.$image_items;jQuery(e.get().reverse()).each((function(){jQuery(this).hasClass("current-item")&&(e.removeClass("current-item"),jQuery(this).addClass("current-item"))})),jQuery(t.get().reverse()).each((function(){jQuery(this).hasClass("current-item")&&(t.removeClass("current-item"),jQuery(this).addClass("current-item"))}))}onClickHover(){const e=this,t=e.elements.$wrapper,n=e.elements.$row_items;t.hasClass("on-click")&&n.each((function(){jQuery(this).on({click:function(){n.removeClass("current-item"),jQuery(this).addClass("current-item"),e.onShowImage(jQuery(this).data("tab"))}})})),t.hasClass("on-hover")&&n.each((function(){jQuery(this).on({mouseenter:function(){n.removeClass("current-item"),jQuery(this).addClass("current-item"),e.onShowImage(jQuery(this).data("tab"))}})}))}onShowImage(e){this.elements.$image_items.removeClass("current-item"),this.elements.$gallery_items.find("#"+e).addClass("current-item")}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_portfolio_gallery.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.post-element",pagination:".jkit-block-pagination"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$pagination:this.$element.find(e.pagination)}}bindEvents(){this.onInitPagination()}onInitPagination(){const e=this.elements.$wrapper,t=this.elements.$pagination,n=e.data("settings"),s=n.pagination_scroll_limit,o=n.pagination_mode,a=n.sg_content_sorting,i=e.find(".product-order select"),r={action:jkit_element_pagination_option.element_prefix+n.class,data:{current_page:1,attr:n,default_sortby:n.sort_by}},l={parameter:{number_post:r.data.attr.number_post.size,current_page:r.data.current_page}};let d=!1,m=[],c=0;const u=function(){d||t.hasClass("disabled")||window.self!=window.top||(s>=r.data.current_page||"0"==s)&&t.find(".jkit-block-scrollload").elementorWaypoint((function(){r.data.current_page=r.data.current_page+1,c++,g(),this.destroy()}),{offset:"100%",context:window}),Waypoint.refreshAll()},p=function(e){e.preventDefault(),d||t.find(this).hasClass("disabled")||("prev"===e.data?r.data.current_page=r.data.current_page-1:r.data.current_page=r.data.current_page+1,g())},f=function(e){e.content="<div>"+e.content+"</div>";const t=jQuery(e.content);return e.content=t.html(),e},h=function(n){["loadmore","scrollload"].includes(o)?function(n){const s=jQuery(n.content);let a=0;s.each((function(){(jQuery(this).hasClass("jkit-post")||jQuery(this).hasClass("jkit-product-block"))&&jQuery(this).addClass("jkit-ajax-loaded anim-"+a),a++})),e.removeClass("loading"),e.addClass("loaded"),1===r.data.current_page?(e.find(".jkit-ajax-flag").html(s),t.removeClass("disabled"),t.show()):e.find(".jkit-ajax-flag").append(s),n.next||(t.addClass("disabled"),t.hide()),y(),jQuery(window).trigger("resize"),"scrollload"===o&&setTimeout((function(){u()}),500)}(n):"nextprev"===o?function(n){const s=jQuery(n.content);let o=0;s.each((function(){(jQuery(this).hasClass("jkit-post")||jQuery(this).hasClass("jkit-product-block"))&&jQuery(this).addClass("jkit-ajax-loaded anim-"+o),o++})),e.removeClass("loading"),e.addClass("loaded"),e.find(".jkit-ajax-flag").html(s),n.next?t.find(".jkit-pagination-button.jkit-block-nextprev .next").removeClass("disabled"):t.find(".jkit-pagination-button.jkit-block-nextprev .next").addClass("disabled"),n.prev?t.find(".jkit-pagination-button.jkit-block-nextprev .prev").removeClass("disabled"):t.find(".jkit-pagination-button.jkit-block-nextprev .prev").addClass("disabled"),y(),jQuery(window).trigger("resize"),jQuery("html, body").animate({scrollTop:e.offset().top-100},1e3)}(n):function(t){const n=jQuery(t.content);let s=0;n.each((function(){(jQuery(this).hasClass("jkit-post")||jQuery(this).hasClass("jkit-product-block"))&&jQuery(this).addClass("jkit-ajax-loaded anim-"+s),s++})),e.removeClass("loading"),e.addClass("loaded"),e.find(".jkit-ajax-flag").html(n),y(),jQuery(window).trigger("resize")}(n)},g=function(){return new Promise((function(e,t){w();const n=function(e){const t=JSON.stringify(e);for(let e=0;e<m.length;e++)if(t===m[e].param)return f(m[e].result)}(r);n?(h(n),e()):jQuery.ajax({url:jkit_ajax_url,type:"post",dataType:"json",data:r,success:function(t){h(t),function(e,t){m.push({param:JSON.stringify(e),result:t})}(r,t),e()}})}))},w=function(){d=!0,t.addClass("loading"),e.addClass("loading"),"nextprev"===o?e.find(".jkit-preloader-overlay").show():["loadmore","scrollload"].includes(o)?t.find("a").text(t.find("a").data("loading")):e.find(".jkit-preloader-overlay").show()},y=function(){d=!1,t.removeClass("loading"),"nextprev"===o?e.find(".jkit-preloader-overlay").hide():["loadmore","scrollload"].includes(o)?t.find("a").text(t.find("a").data("load")):e.find(".jkit-preloader-overlay").hide()};["loadmore","scrollload"].includes(o)&&("scrollload"===o&&u(),t.find(".jkit-pagination-button.jkit-block-loadmore, .jkit-pagination-button.jkit-block-scrollload").on("click",(function(e){e.preventDefault(),r.data.current_page=r.data.current_page+1,c++,d||t.hasClass("disabled")||g()}))),"nextprev"===o&&(t.find(".jkit-pagination-button.jkit-block-nextprev .next").on("click",null,"next",p),t.find(".jkit-pagination-button.jkit-block-nextprev .prev").on("click",null,"prev",p)),"yes"===a&&i.length&&i.on("change",(function(){const t="default"!==this.value?this.value:r.data.default_sortby;if(r.data.attr.sort_by=t,["loadmore","scrollload"].includes(o))l.parameter.current_page=r.data.current_page,r.data.current_page=1,r.data.attr.number_post.size+=r.data.attr.pagination_number_post.size*c,g().then((function(){r.data.attr.number_post.size=l.parameter.number_post,r.data.current_page=l.parameter.current_page}));else if("disable"===o){const t=e.find(".jkit-products > .jkit-product-block > .button").map((function(e){return jQuery(this).data("product_id")})).get().join();r.data.attr.wc_include_post=t,g()}else g()}))}}jQuery(window).on("elementor/frontend/init",(()=>{const e=e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})};elementorFrontend.hooks.addAction("frontend/element_ready/jkit_post_block.default",e),elementorFrontend.hooks.addAction("frontend/element_ready/jkit_post_list.default",e),elementorFrontend.hooks.addAction("frontend/element_ready/jkit_product_grid.default",e)}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-product-carousel",items:".jkit-products"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$items:this.$element.find(e.items)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.elements.$wrapper.find(".jeg_empty_module").length||this.loadCarousel()}loadCarousel(){const e=this.elements.$wrapper.data("id"),t=this.getSettings("selectors"),n=this.elements.$wrapper.data("settings"),s=n.responsive,o={};let a;Object.entries(s).forEach((([e,t])=>{""===t.items&&""===t.margin||(o[t.breakpoint]={},a=t.breakpoint,""!==t.items&&(o[t.breakpoint].items=t.items),""!==t.margin&&(o[t.breakpoint].gutter=t.margin))})),void 0!==a&&0!==a&&(o[0]=o[a],delete o[a]);const i={container:t.wrapper+'[data-id="'+e+'"] '+t.items,loop:!0,mouseDrag:!0,autoplay:n.autoplay,autoplayTimeout:n.autoplay_speed,autoplayHoverPause:n.autoplay_hover_pause,navPosition:"bottom",controlsPosition:n.arrow_position,controlsText:[n.navigation_left,n.navigation_right],responsiveClass:!0,responsive:o};tns(i),this.elements.$wrapper.find("button[data-action]").remove(),n.show_navigation||this.elements.$wrapper.find(".tns-controls").remove(),n.show_dots||this.elements.$wrapper.find(".tns-nav").remove(),n.show_navigation&&(i.nav=!0,i.navText=['<i class="'+n.navigation_left+'" aria-hidden="true"></i>','<i class="'+n.navigation_right+'" aria-hidden="true"></i>'])}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_product_carousel.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-progress-bar",skill:".skill-track",number:".number-percentage"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$skill:this.$element.find(e.skill),$number:this.$element.find(e.number)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.countNumber(),jQuery(window).on("scroll",this.countNumber.bind(this))}countNumber(){const e=this.elements.$number,t=this.elements.$skill;this.onScreen()&&!e.hasClass("loaded")&&(e.prop("Counter",0).animate({Counter:e.data("value")},{duration:e.data("animation-duration"),easing:"swing",step:function(n){e.text(Math.ceil(n).toString()+"%"),t.css("width",n.toString()+"%")}}),e.addClass("loaded"))}onScreen(){const e=jQuery(window).scrollTop()+jQuery(window).height();return this.elements.$wrapper.offset().top<=e}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_progress_bar.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-search"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper)}}bindEvents(){const e=this.elements.$wrapper;e.magnificPopup({mainClass:"mfp-fade jkit-magnific-popup",delegate:"a.jkit-search-modal",removalDelay:500,midClick:!0,showCloseBtn:!0,closeBtnInside:!1,prependTo:e,type:"inline",fixedContentPos:!0,fixedBgPos:!0,overflowY:"auto"})}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_search.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{bindEvents(){this.$element.data("stickyTop",this.$element.offset().top),this.runSticky()}runSticky(){if(!this.$element.hasClass("jkit-sticky-element--enabled"))return;const e=jQuery,t=this.$element,n=this.getElementSettings(),s=t.hasClass("jkit-sticky-element-on--down")?"down":t.hasClass("jkit-sticky-element-on--up")?"up":"both",o=t.hasClass("jkit-sticky-position--fixed")?"fixed":"sticky";let a=t.data("stickyTop");"fixed"===o?t.wrap('<div class="wrapper-sticky-fixed" style="height: '+t.height()+'px"></div>'):t.parent().hasClass("wrapper-sticky-fixed")&&t.unwrap(),e(window).on("load resize scroll",t,(function(){const i=e("body").attr("data-elementor-device-mode");let r=!0;if(Object.values(n.jkit_sticky_device).forEach((function(e){i!==e||(r=!1)})),r)return t.css("position","relative"),t.removeClass("sticky-pinned"),void(t.hasClass("elementor-column")||t.css("width","unset"));const l="down"===s?e(this).scrollTop():e(this).scrollTop()+e(this).height(),d="down"===s?a:a+t.outerHeight(!0),m="fixed"===o?t.parent().width()+"px":"unset";t.hasClass("sticky-pinned")||(a=t.offset().top,void 0!==n&&(void 0!==n.jkit_sticky_top_position&&(a-=n.jkit_sticky_top_position.size),void 0!==n.jkit_sticky_bottom_position&&(a+=n.jkit_sticky_bottom_position.size))),t.hasClass("elementor-column")||t.css("width",m),"down"===s&&d<l||"up"===s&&d>l||"both"===s&&"sticky"===o?(t.css("position",o),t.addClass("sticky-pinned")):(t.css("position","relative"),t.removeClass("sticky-pinned"))}))}onElementChange(e){-1!==["jkit_sticky_section","jkit_sticky_device","jkit_sticky_trigger","jkit_sticky_position"].indexOf(e)&&(jQuery(window).off("load resize scroll",this.$element),this.runSticky())}}jQuery(window).on("elementor/frontend/init",(()=>{const e=e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})};elementorFrontend.hooks.addAction("frontend/element_ready/section",e),elementorFrontend.hooks.addAction("frontend/element_ready/column",e)}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-tabs",tab:"li.tab-nav",content:".tab-content-list"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$tab:this.$element.find(e.tab),$content:this.$element.find(e.content)}}bindEvents(){const e=this,t="yes"===e.$element.find(".tab-nav-list").data("toggle");t&&e.$element.find("li.tab-nav.active").find(".tab-content").slideDown(),e.elements.$tab.on("click",(function(){if(jQuery(this).hasClass("active"))return;const n=jQuery(this).data("tab");e.elements.$tab.removeClass("active"),t&&(e.elements.$tab.find(".tab-content").slideUp(),jQuery(this).find(".tab-content").slideDown()),jQuery(this).addClass("active"),e.elements.$content.find(".tab-content").removeClass("active"),e.elements.$content.find("."+n).addClass("active")}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_tabs.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-team",close_modal:".team-modal-close"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$close_modal:this.$element.find(e.close_modal)}}bindEvents(){this.onClick()}onClick(){const e=this.elements.$wrapper,t=this.elements.$close_modal;e.magnificPopup({delegate:"a.jkit-team-modal",removalDelay:500,callbacks:{beforeOpen:function(){this.st.mainClass=this.st.el.attr("data-effect")}},midClick:!0,showCloseBtn:!1,prependTo:e,type:"inline",fixedContentPos:!0,fixedBgPos:!0,overflowY:"auto"}),t.on("click",(function(e){e.preventDefault(),jQuery.magnificPopup.close()}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_team.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-testimonials",items:".testimonials-track"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$items:this.$element.find(e.items)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.loadCarousel()}loadCarousel(){const e=this.elements.$wrapper.data("id"),t=this.getSettings("selectors"),n=this.elements.$wrapper.data("settings"),s=n.responsive,o={0:{items:1,gutter:0},768:{items:2,gutter:0},1025:{items:3,gutter:10}},a={};Object.entries(s).forEach((([e,t])=>{a[t.breakpoint]={},""!==t.items?a[t.breakpoint].items=t.items:o[t.breakpoint]&&(a[t.breakpoint].items=o[t.breakpoint].items),""!==t.margin?a[t.breakpoint].gutter=t.margin:o[t.breakpoint]&&(a[t.breakpoint].gutter=o[t.breakpoint].gutter)}));const i={container:t.wrapper+'[data-id="'+e+'"] '+t.items,loop:!0,mouseDrag:!0,autoplay:n.autoplay,autoplayTimeout:n.autoplay_speed,autoplayHoverPause:n.autoplay_hover_pause,navPosition:"bottom",controlsPosition:n.arrow_position,controlsText:[n.navigation_left,n.navigation_right],responsiveClass:!0,responsive:a};tns(i),this.elements.$wrapper.find("button[data-action]").remove(),n.show_navigation||this.elements.$wrapper.find(".tns-controls").remove(),n.show_dots||this.elements.$wrapper.find(".tns-nav").remove(),n.show_navigation&&(i.nav=!0,i.navText=['<i class="'+n.navigation_left+'" aria-hidden="true"></i>','<i class="'+n.navigation_right+'" aria-hidden="true"></i>'])}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_testimonials.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-video-button",link:".jeg-elementor-kit.jkit-video-button .jkit-video-popup-btn"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$link:this.$element.find(e.link)}}bindEvents(){this.onClick()}onClick(){const e=this.elements.$wrapper,t=e.data("type"),n=e.data("autoplay"),s=e.data("mute"),o=e.data("loop"),a=e.data("controls"),i=e.data("unique-id");let r="//www.youtube.com/embed/";"self_hosted"===t?this.elements.$link.magnificPopup({type:"inline",src:"#jkit_video_button_"+i}):(r="youtube"==t?r+"?playlist=%id%&autoplay="+n+"&mute="+s+"&loop="+o+"&controls="+a+"&start="+e.data("start")+"&end="+e.data("end")+"&version=3":"//player.vimeo.com/video/%id%?autoplay="+n+"&muted="+s+"&loop="+o+"&controls="+a+"&title="+e.data("title")+"&portrait="+e.data("portrait")+"&byline="+e.data("byline"),this.elements.$link.magnificPopup({type:"iframe",iframe:{patterns:{youtube:{index:"youtube.com/",id:function(e){var t=e.match(/[\\?\\&]v=([^\\?\\&]+)/);return t&&t[1]?t[1]:null},src:r},vimeo:{index:"vimeo.com/",id:function(e){var t=e.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/);return t&&t[5]?t[5]:null},src:r}}},mainClass:"mfp-fade jkit-magnific-popup",removalDelay:160,preloader:!0,fixedContentPos:!1,showCloseBtn:!0}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_video_button.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))}]);
|
1 |
+
!function(e){var t={};function n(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(s,o,function(t){return e[t]}.bind(null,o));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1),n(2),n(3),n(4),n(5),n(6),n(7),n(8),n(9),n(10),n(11),n(12),n(13),n(14),n(15),n(16),n(17),n(18),n(19),e.exports=n(20)},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-accordion",cards:".card-wrapper"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$cards:this.$element.find(e.cards)}}bindEvents(){this.onClick()}onClick(){this.elements.$cards.each((function(){jQuery(this).on("click",(function(e){"A"===e.target.nodeName&&!jQuery(e.target).hasClass("card-header-button")||jQuery(e.target).hasClass("card-body")||(e.preventDefault(),jQuery(this).hasClass("expand")?(jQuery(this).find(".card-expand").slideUp(),jQuery(this).removeClass("expand")):(jQuery(this).parent().find(".card-expand").slideUp(),jQuery(this).parent().find(".card-wrapper").removeClass("expand"),jQuery(this).addClass("expand"),jQuery(this).find(".card-expand").slideDown()))}))}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_accordion.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-animated-text",dynamic:".dynamic-wrapper"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$dynamic:this.$element.find(e.dynamic)}}bindEvents(){this.onRenderElement()}onRenderElement(){if("rotating"==this.elements.$wrapper.data("style")){const e=this.elements.$wrapper.data("rotate"),t=this.elements.$dynamic.find(".dynamic-text");if(t.length>0){const n=t.first();["typing","swirl","blinds","wave"].includes(e)?this.animateText(n,this.getNextText(n)):this.showText(n,this.getNextText(n))}}}animateText(e,t){this.elements.$dynamic.removeClass("typing-delete"),e.addClass("show-text"),this.elements.$dynamic.removeClass("cursor-blink"),this.animateLetter(e.find(".dynamic-text-letter").first(),e,t)}animateLetter(e,t,n){const s=this,o=this.elements.$wrapper.data("letter-speed");e.addClass("show-letter"),setTimeout((function(){e.is(":last-child")?s.hideText(t,n):s.animateLetter(e.next(),t,n)}),o)}getNextText(e){return e.is(":last-child")?this.elements.$dynamic.find(".dynamic-text").first():e.next()}hideText(e,t){const n=this,s=n.elements.$wrapper.data("rotate"),o=n.elements.$wrapper.data("delay");this.elements.$dynamic.addClass("cursor-blink"),setTimeout((function(){if("typing"==s){const s=n.elements.$wrapper.data("delay-delete");n.elements.$dynamic.addClass("typing-delete"),setTimeout((function(){e.removeClass("show-text"),e.find(".dynamic-text-letter").removeClass("show-letter"),n.animateText(t,n.getNextText(t))}),s)}else e.removeClass("show-text"),e.find(".dynamic-text-letter").removeClass("show-letter"),n.animateText(t,n.getNextText(t))}),o)}showText(e,t){const n=this,s=n.elements.$wrapper.data("delay"),o=n.elements.$wrapper.data("rotate");if(e.addClass("show-text"),"clip"==o){const o=n.elements.$wrapper.data("clip-duration");n.elements.$dynamic.width(e.width()+10),n.elements.$dynamic.animate({width:0},o/2,(function(){e.removeClass("show-text"),t.addClass("show-text"),n.elements.$dynamic.animate({width:t.width()+10},o/2,(function(){setTimeout((function(){e.removeClass("show-text"),n.showText(t,n.getNextText(t))}),s)}))}))}else n.elements.$dynamic.width(e.width()),setTimeout((function(){e.removeClass("show-text"),n.showText(t,n.getNextText(t))}),s)}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_animated_text.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-client-logo",items:".client-track"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$items:this.$element.find(e.items)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.loadCarousel()}loadCarousel(){const e=this.elements.$wrapper.data("id"),t=this.elements.$wrapper.data("settings"),n=this.getSettings("selectors"),s=t.responsive,o={};let a;Object.entries(s).forEach((([e,t])=>{""===t.items&&""===t.margin||(o[t.breakpoint]={},a=t.breakpoint,""!==t.items&&(o[t.breakpoint].items=t.items),""!==t.margin&&(o[t.breakpoint].gutter=t.margin))})),void 0!==a&&0!==a&&(o[0]=o[a],delete o[a]);const i={container:n.wrapper+'[data-id="'+e+'"] '+n.items,loop:!0,mouseDrag:!0,autoplay:t.autoplay,autoplayTimeout:t.autoplay_speed,autoplayHoverPause:t.autoplay_hover_pause,navPosition:"bottom",controlsPosition:t.arrow_position,controlsText:[t.navigation_left,t.navigation_right],responsiveClass:!0,responsive:o};tns(i),this.elements.$wrapper.find("button[data-action]").remove(),t.show_navigation||this.elements.$wrapper.find(".tns-controls").remove(),t.show_dots||this.elements.$wrapper.find(".tns-nav").remove()}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_client_logo.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-countdown",days:".timer-container.timer-days",hours:".timer-container.timer-hours",minutes:".timer-container.timer-minutes",seconds:".timer-container.timer-seconds",counts:".timer-container .timer-count"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$days:this.$element.find(e.days),$hours:this.$element.find(e.hours),$minutes:this.$element.find(e.minutes),$seconds:this.$element.find(e.seconds),$counts:this.$element.find(e.counts)}}bindEvents(){this.onRender()}onRender(){const e=this,t=new Date(e.elements.$wrapper.data("due-date")).getTime(),n=setInterval((function(){const s=new Date,o=t-s,a=Math.floor(o/864e5),i=Math.floor(o%864e5/36e5),r=Math.floor(o%36e5/6e4),l=Math.floor(o%6e4/1e3);e.elements.$counts.removeClass("timer-loading"),o>=0?(e.elements.$days&&e.elements.$days.find(".timer-count").text(a),e.elements.$hours&&e.elements.$hours.find(".timer-count").text(i),e.elements.$minutes&&e.elements.$minutes.find(".timer-count").text(r),e.elements.$seconds&&e.elements.$seconds.find(".timer-count").text(l)):(clearInterval(n),e.elements.$wrapper.addClass("countdown-expired"),e.onExpired())}),1e3)}onExpired(){const e=this.elements.$wrapper,t=e.data("expired-type");if("message"==t){const t=e.data("expired-title"),n=e.data("expired-content");e.html(`\n <div class="expire-message">\n <span class="expire-title">${t}</span>\n <span class="expire-content">${n}</span>\n </div>\n `)}else if("redirect"==t){const t=e.data("redirect-link");window.self!==window.top?e.html(`<div class="expire-message">\n <span class="expire-content">${iframe_content}</span>\n </div>\n `):location.href=t}else if("template"==t){const t=e.data("template");e.html(t)}}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_countdown.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-fun-fact",number:".number"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$number:this.$element.find(e.number)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.countNumber(),jQuery(window).on("scroll",this.countNumber.bind(this))}countNumber(){const e=this.elements.$number;this.onScreen()&&!e.hasClass("loaded")&&(e.prop("Counter",0).animate({Counter:e.data("value")},{duration:e.data("animation-duration"),easing:"swing",step:function(t){e.text(Math.ceil(t).toLocaleString())},complete:function(){e.text(e.data("value").toLocaleString())}}),e.addClass("loaded"))}onScreen(){const e=jQuery(window).scrollTop()+jQuery(window).height();return this.elements.$wrapper.offset().top<=e}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_fun_fact.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-gallery",grid:".gallery-items",active_label:".jkit-gallery-control.active",filter:".jkit-gallery-control",filter_button:"#search-filter-trigger",filter_label:"#search-filter-trigger span",filter_list:".search-filter-controls",filter_form:"#jkit-gallery-search-box-input",load_more:".jkit-gallery-load-more"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$grid:this.$element.find(e.grid),$active_label:this.$element.find(e.active_label),$filter:this.$element.find(e.filter),$filter_button:this.$element.find(e.filter_button),$filter_label:this.$element.find(e.filter_label),$filter_list:this.$element.find(e.filter_list),$filter_form:this.$element.find(e.filter_form),$load_more:this.$element.find(e.load_more)}}bindEvents(){const e=this,t="masonry"==e.elements.$wrapper.data("grid")?"masonry":"fitRows",n=parseFloat((e.elements.$wrapper.data("animation-duration")/1e3).toFixed(2)).toString()+"s";e.grid=e.elements.$grid.isotope({itemSelector:".gallery-item-wrap",layoutMode:t,transitionDuration:n}),e.grid.imagesLoaded().progress((function(){e.grid.isotope("layout")})),e.onInitGallery(),e.onClickFilterButton(),e.onClickLoadMoreButton(),e.onFormChange()}onInitGallery(){const e=this;e.elements.$filter.each((function(){jQuery(this).on("click",(function(t){t.preventDefault();const n=e.getSettings("selectors"),s=jQuery(this).data("filter"),o=e.elements.$filter_label,a=e.elements.$filter_list,i=e.elements.$filter_button,r=e.elements.$filter_form;e.elements.$filter.removeClass("active"),jQuery(this).addClass("active"),e.elements.$active_label=e.$element.find(n.active_label),e.grid.isotope({filter:function(){const e="*"!==s?s.substring(1):"*",t=jQuery(this).attr("class").split(/\s+/);let n=!1;if(i.length>0){const s=r.val(),o=jQuery(this).find(".item-title").text(),a=jQuery(this).find(".item-content").text();n="*"!=e?(o.toLowerCase().includes(s.toLowerCase())||a.toLowerCase().includes(s.toLowerCase()))&&t.includes(e):o.toLowerCase().includes(s.toLowerCase())||a.toLowerCase().includes(s.toLowerCase())}else n="*"==e||t.includes(e);return n}}),i.length>0&&(o.text(jQuery(this).text()),a.removeClass("open-controls"))}))}))}onClickFilterButton(){const e=this;e.elements.$filter_button.on("click",(function(t){t.preventDefault();const n=e.elements.$filter_list;n.hasClass("open-controls")?n.removeClass("open-controls"):n.addClass("open-controls")}))}onFormChange(){const e=this,t=e.elements.$filter_form;void 0!==t&&t.on("change paste keyup",(function(){const t=jQuery(this).val();e.grid.isotope({filter:function(){const n=jQuery(this).find(".item-title").text(),s=jQuery(this).find(".item-content").text(),o=jQuery(this).attr("class").split(/\s+/),a="*"!==e.elements.$active_label.data("filter")?e.elements.$active_label.data("filter").substring(1):"*";let i=!1;return i="*"==a?n.toLowerCase().includes(t.toLowerCase())||s.toLowerCase().includes(t.toLowerCase()):(n.toLowerCase().includes(t.toLowerCase())||s.toLowerCase().includes(t.toLowerCase()))&&o.includes(a),i}})}))}onClickLoadMoreButton(){const e=this,t=e.elements.$wrapper.data("items");e.elements.$load_more.on("click",(function(n){n.preventDefault();const s=parseInt(e.elements.$wrapper.attr("data-current-loaded")),o=parseInt(e.elements.$wrapper.attr("data-count-items")),a=parseInt(e.elements.$wrapper.attr("data-load-more")),i=e.elements.$wrapper.attr("data-no-more");if(o>s)if(o-a-s>0){const n=[...t].splice(s,a);e.grid.append(n).isotope("reloadItems").isotope(),e.grid.imagesLoaded().progress((function(){e.grid.isotope("layout")})),e.elements.$wrapper.attr("data-current-loaded",s+a)}else{const n=[...t].splice(s,o-s);e.grid.append(n).isotope("reloadItems").isotope(),e.grid.imagesLoaded().progress((function(){e.grid.isotope("layout")})),e.elements.$wrapper.attr("data-current-loaded",o),e.elements.$load_more.find(".load-more-text").text(i),setTimeout((function(){e.elements.$load_more.fadeOut("slow")}),600)}}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_gallery.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-mailchimp",form:".jkit-mailchimp-form"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$form:this.$element.find(e.form)}}bindEvents(){this.onSubmit()}onSubmit(){this.elements.$form.on("submit",(function(e){e.preventDefault();const t=jQuery(this).find(".jkit-mailchimp-message"),n=jQuery(this).data("error-message"),s=jQuery(this).data("success-message"),o={first_name:jQuery(this).find('input[name="first-name"]').val(),last_name:jQuery(this).find('input[name="last-name"]').val(),phone:jQuery(this).find('input[name="phone"]').val(),email:jQuery(this).find('input[name="email"]').val(),list:jQuery(this).data("listed")};t.removeClass("error success"),jQuery.ajax({type:"POST",url:jkit_ajax_url,data:{data:o,action:"jkit_element_ajax_jkit_mailchimp"},dataType:"json",encode:!0}).done((function(e){e.status_code>=400?(t.addClass("error"),t.text(e.message)):(t.addClass("success"),t.text(s))})).fail((function(){t.addClass("error"),t.text(n)}))}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_mailchimp.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-nav-menu",container:".jkit-menu-wrapper",open_toggle:".jkit-hamburger-menu",close_toggle:'.jkit-close-menu, .menu-item:not(.menu-item-has-children) a[href^="#"]',dropdown_toggle:"li.menu-item-has-children > a i",menu_dropdown:"li.menu-item-has-children > a"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$container:this.$element.find(e.container),$open_toggle:this.$element.find(e.open_toggle),$close_toggle:this.$element.find(e.close_toggle),$dropdown_toggle:this.$element.find(e.dropdown_toggle),$menu_dropdown:this.$element.find(e.menu_dropdown)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.addBodyClass(),this.addDropdownIcon(),this.onToogleClick()}addBodyClass(){this.elements.$wrapper.length>0&&jQuery("body").addClass("jkit-nav-menu-loaded")}addDropdownIcon(){const e=this.elements.$wrapper.data("item-indicator"),t=this.elements.$menu_dropdown,n=this.getSettings("selectors");t.each((function(){0==jQuery(this).find("i").length&&jQuery(this).append(e)})),this.elements.$dropdown_toggle=this.$element.find(n.dropdown_toggle)}onToogleClick(){const e=this,t=e.elements.$wrapper,n=e.elements.$menu_dropdown,s=e.elements.$open_toggle,o=e.elements.$close_toggle,a=e.elements.$dropdown_toggle;s.on("click",(function(t){t.preventDefault(),e.elements.$container.hasClass("active")?e.elements.$container.removeClass("active"):e.elements.$container.addClass("active")})),o.on("click",(function(t){t.preventDefault(),e.elements.$container.removeClass("active")})),t.hasClass("submenu-click-title")?n.each((function(){jQuery(this).on("click",(function(e){e.preventDefault();const t=jQuery(this).next();t.hasClass("dropdown-open")?t.removeClass("dropdown-open"):t.addClass("dropdown-open")}))})):a.each((function(){jQuery(this).on("click",(function(e){e.preventDefault();const t=jQuery(this).parents("a").next();t.hasClass("dropdown-open")?t.removeClass("dropdown-open"):t.addClass("dropdown-open")}))}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_nav_menu.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-off-canvas",sidebar:".offcanvas-sidebar",hamburger:".offcanvas-sidebar-button",close:".offcanvas-close-button",overlay:".bg-overlay"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$sidebar:this.$element.find(e.sidebar),$hamburger:this.$element.find(e.hamburger),$close:this.$element.find(e.close),$overlay:this.$element.find(e.overlay)}}bindEvents(){const e=this;e.elements.$hamburger.on("click",(function(t){t.preventDefault(),e.elements.$sidebar.hasClass("active")?e.elements.$sidebar.removeClass("active"):e.elements.$sidebar.addClass("active")})),e.elements.$close.on("click",(function(t){t.preventDefault(),e.elements.$sidebar.removeClass("active")})),e.elements.$overlay.on("click",(function(t){t.preventDefault(),e.elements.$sidebar.removeClass("active")}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_off_canvas.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-pie-chart",canvas_main:"canvas.main-canvas",canvas_bg:"canvas.background-canvas",number:".pie-chart-content"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$canvas_main:this.$element.find(e.canvas_main),$canvas_bg:this.$element.find(e.canvas_bg),$number:this.$element.find(e.number)}}bindEvents(){this.animateChart(),jQuery(window).on("scroll",this.animateChart.bind(this)),"percentage"==this.elements.$wrapper.data("content-type")&&(this.countNumber(),jQuery(window).on("scroll",this.countNumber.bind(this)))}animateChart(){const e=this,t=e.elements.$canvas_main,n=e.elements.$canvas_bg;if(this.onScreen()&&!t.hasClass("loaded")){const s=e.elements.$wrapper,o=t.get(0).getContext("2d"),a=n.get(0).getContext("2d"),i=s.data("percent"),r=s.data("cutout")+"%",l=s.data("color-type"),d=s.data("color"),m=s.data("bg-color"),c=s.data("gradient1"),u=s.data("gradient2"),p={datasets:[{data:[i,100-i],backgroundColor:["#80b1ff","transparent"],hoverBackgroundColor:["#80b1ff","transparent"],borderWidth:0}]},f={datasets:[{data:[100],backgroundColor:["#d1d1d1"],hoverBackgroundColor:["#d1d1d1"],borderWidth:0}]},h={animation:{duration:s.data("animation-duration")},responsive:!0,cutout:r,plugins:{title:{display:!1},legend:{display:!1},tooltip:{enabled:!1}}},g={animation:!1,responsive:!0,cutout:r,plugins:{title:{display:!1},legend:{display:!1},tooltip:{enabled:!1}}};if("normal"==l)""!==d&&(p.datasets[0].backgroundColor[0]=d,p.datasets[0].hoverBackgroundColor[0]=d);else if("gradient"==l&&(""!==c||""!==u)){const e=o.createLinearGradient(0,0,0,170);""!==c&&e.addColorStop(0,c),""!==u&&e.addColorStop(1,u),p.datasets[0].backgroundColor[0]=e,p.datasets[0].hoverBackgroundColor[0]=e}""!==m&&(f.datasets[0].backgroundColor[0]=m,f.datasets[0].hoverBackgroundColor[0]=m),new Chart(o,{type:"doughnut",data:p,options:h}),new Chart(a,{type:"doughnut",data:f,options:g}),t.addClass("loaded"),t.css("display",""),n.css("display","")}}countNumber(){const e=this.elements.$number,t=this.elements.$wrapper;this.onScreen()&&!e.hasClass("loaded")&&(e.prop("Counter",0).animate({Counter:t.data("percent")},{duration:t.data("animation-duration"),easing:"swing",step:function(t){e.text(Math.ceil(t).toString()+"%")}}),e.addClass("loaded"))}onScreen(){const e=jQuery(window).scrollTop()+jQuery(window).height();return this.elements.$wrapper.offset().top<=e}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_pie_chart.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-portfolio-gallery",row_items:".row-item",gallery_items:".gallery-items",image_items:".image-item"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$row_items:this.$element.find(e.row_items),$gallery_items:this.$element.find(e.gallery_items),$image_items:this.$element.find(e.image_items)}}bindEvents(){this.onRenderInit(),this.onClickHover()}onRenderInit(){const e=this.elements.$row_items,t=this.elements.$image_items;jQuery(e.get().reverse()).each((function(){jQuery(this).hasClass("current-item")&&(e.removeClass("current-item"),jQuery(this).addClass("current-item"))})),jQuery(t.get().reverse()).each((function(){jQuery(this).hasClass("current-item")&&(t.removeClass("current-item"),jQuery(this).addClass("current-item"))}))}onClickHover(){const e=this,t=e.elements.$wrapper,n=e.elements.$row_items;t.hasClass("on-click")&&n.each((function(){jQuery(this).on({click:function(){n.removeClass("current-item"),jQuery(this).addClass("current-item"),e.onShowImage(jQuery(this).data("tab"))}})})),t.hasClass("on-hover")&&n.each((function(){jQuery(this).on({mouseenter:function(){n.removeClass("current-item"),jQuery(this).addClass("current-item"),e.onShowImage(jQuery(this).data("tab"))}})}))}onShowImage(e){this.elements.$image_items.removeClass("current-item"),this.elements.$gallery_items.find("#"+e).addClass("current-item")}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_portfolio_gallery.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.post-element",pagination:".jkit-block-pagination"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$pagination:this.$element.find(e.pagination)}}bindEvents(){this.onInitPagination()}onInitPagination(){const e=this.elements.$wrapper,t=this.elements.$pagination,n=e.data("settings"),s=n.pagination_scroll_limit,o=n.pagination_mode,a=n.sg_content_sorting,i=e.find(".product-order select"),r={action:jkit_element_pagination_option.element_prefix+n.class,data:{current_page:1,attr:n,default_sortby:n.sort_by}},l={parameter:{number_post:r.data.attr.number_post.size,current_page:r.data.current_page}};let d=!1,m=[],c=0;const u=function(){d||t.hasClass("disabled")||window.self!=window.top||(s>=r.data.current_page||"0"==s)&&t.find(".jkit-block-scrollload").elementorWaypoint((function(){r.data.current_page=r.data.current_page+1,c++,g(),this.destroy()}),{offset:"100%",context:window}),Waypoint.refreshAll()},p=function(e){e.preventDefault(),d||t.find(this).hasClass("disabled")||("prev"===e.data?r.data.current_page=r.data.current_page-1:r.data.current_page=r.data.current_page+1,g())},f=function(e){e.content="<div>"+e.content+"</div>";const t=jQuery(e.content);return e.content=t.html(),e},h=function(n){["loadmore","scrollload"].includes(o)?function(n){const s=jQuery(n.content);let a=0;s.each((function(){(jQuery(this).hasClass("jkit-post")||jQuery(this).hasClass("jkit-product-block"))&&jQuery(this).addClass("jkit-ajax-loaded anim-"+a),a++})),e.removeClass("loading"),e.addClass("loaded"),1===r.data.current_page?(e.find(".jkit-ajax-flag").html(s),t.removeClass("disabled"),t.show()):e.find(".jkit-ajax-flag").append(s),n.next||(t.addClass("disabled"),t.hide()),y(),jQuery(window).trigger("resize"),"scrollload"===o&&setTimeout((function(){u()}),500)}(n):"nextprev"===o?function(n){const s=jQuery(n.content);let o=0;s.each((function(){(jQuery(this).hasClass("jkit-post")||jQuery(this).hasClass("jkit-product-block"))&&jQuery(this).addClass("jkit-ajax-loaded anim-"+o),o++})),e.removeClass("loading"),e.addClass("loaded"),e.find(".jkit-ajax-flag").html(s),n.next?t.find(".jkit-pagination-button.jkit-block-nextprev .next").removeClass("disabled"):t.find(".jkit-pagination-button.jkit-block-nextprev .next").addClass("disabled"),n.prev?t.find(".jkit-pagination-button.jkit-block-nextprev .prev").removeClass("disabled"):t.find(".jkit-pagination-button.jkit-block-nextprev .prev").addClass("disabled"),y(),jQuery(window).trigger("resize"),jQuery("html, body").animate({scrollTop:e.offset().top-100},1e3)}(n):function(t){const n=jQuery(t.content);let s=0;n.each((function(){(jQuery(this).hasClass("jkit-post")||jQuery(this).hasClass("jkit-product-block"))&&jQuery(this).addClass("jkit-ajax-loaded anim-"+s),s++})),e.removeClass("loading"),e.addClass("loaded"),e.find(".jkit-ajax-flag").html(n),y(),jQuery(window).trigger("resize")}(n)},g=function(){return new Promise((function(e,t){w();const n=function(e){const t=JSON.stringify(e);for(let e=0;e<m.length;e++)if(t===m[e].param)return f(m[e].result)}(r);n?(h(n),e()):jQuery.ajax({url:jkit_ajax_url,type:"post",dataType:"json",data:r,success:function(t){h(t),function(e,t){m.push({param:JSON.stringify(e),result:t})}(r,t),e()}})}))},w=function(){d=!0,t.addClass("loading"),e.addClass("loading"),"nextprev"===o?e.find(".jkit-preloader-overlay").show():["loadmore","scrollload"].includes(o)?t.find("a").text(t.find("a").data("loading")):e.find(".jkit-preloader-overlay").show()},y=function(){d=!1,t.removeClass("loading"),"nextprev"===o?e.find(".jkit-preloader-overlay").hide():["loadmore","scrollload"].includes(o)?t.find("a").text(t.find("a").data("load")):e.find(".jkit-preloader-overlay").hide()};["loadmore","scrollload"].includes(o)&&("scrollload"===o&&u(),t.find(".jkit-pagination-button.jkit-block-loadmore, .jkit-pagination-button.jkit-block-scrollload").on("click",(function(e){e.preventDefault(),r.data.current_page=r.data.current_page+1,c++,d||t.hasClass("disabled")||g()}))),"nextprev"===o&&(t.find(".jkit-pagination-button.jkit-block-nextprev .next").on("click",null,"next",p),t.find(".jkit-pagination-button.jkit-block-nextprev .prev").on("click",null,"prev",p)),"yes"===a&&i.length&&i.on("change",(function(){const t="default"!==this.value?this.value:r.data.default_sortby;if(r.data.attr.sort_by=t,["loadmore","scrollload"].includes(o))l.parameter.current_page=r.data.current_page,r.data.current_page=1,r.data.attr.number_post.size+=r.data.attr.pagination_number_post.size*c,g().then((function(){r.data.attr.number_post.size=l.parameter.number_post,r.data.current_page=l.parameter.current_page}));else if("disable"===o){const t=e.find(".jkit-products > .jkit-product-block > .button").map((function(e){return jQuery(this).data("product_id")})).get().join();r.data.attr.wc_include_post=t,g()}else g()}))}}jQuery(window).on("elementor/frontend/init",(()=>{const e=e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})};elementorFrontend.hooks.addAction("frontend/element_ready/jkit_post_block.default",e),elementorFrontend.hooks.addAction("frontend/element_ready/jkit_post_list.default",e),elementorFrontend.hooks.addAction("frontend/element_ready/jkit_product_grid.default",e)}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-product-carousel",items:".jkit-products"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$items:this.$element.find(e.items)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.elements.$wrapper.find(".jeg_empty_module").length||this.loadCarousel()}loadCarousel(){const e=this.elements.$wrapper.data("id"),t=this.getSettings("selectors"),n=this.elements.$wrapper.data("settings"),s=n.responsive,o={};let a;Object.entries(s).forEach((([e,t])=>{""===t.items&&""===t.margin||(o[t.breakpoint]={},a=t.breakpoint,""!==t.items&&(o[t.breakpoint].items=t.items),""!==t.margin&&(o[t.breakpoint].gutter=t.margin))})),void 0!==a&&0!==a&&(o[0]=o[a],delete o[a]);const i={container:t.wrapper+'[data-id="'+e+'"] '+t.items,loop:!0,mouseDrag:!0,autoplay:n.autoplay,autoplayTimeout:n.autoplay_speed,autoplayHoverPause:n.autoplay_hover_pause,navPosition:"bottom",controlsPosition:n.arrow_position,controlsText:[n.navigation_left,n.navigation_right],responsiveClass:!0,responsive:o};tns(i),this.elements.$wrapper.find("button[data-action]").remove(),n.show_navigation||this.elements.$wrapper.find(".tns-controls").remove(),n.show_dots||this.elements.$wrapper.find(".tns-nav").remove(),n.show_navigation&&(i.nav=!0,i.navText=['<i class="'+n.navigation_left+'" aria-hidden="true"></i>','<i class="'+n.navigation_right+'" aria-hidden="true"></i>'])}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_product_carousel.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-progress-bar",skill:".skill-track",number:".number-percentage"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$skill:this.$element.find(e.skill),$number:this.$element.find(e.number)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.countNumber(),jQuery(window).on("scroll",this.countNumber.bind(this))}countNumber(){const e=this.elements.$number,t=this.elements.$skill;this.onScreen()&&!e.hasClass("loaded")&&(e.prop("Counter",0).animate({Counter:e.data("value")},{duration:e.data("animation-duration"),easing:"swing",step:function(n){e.text(Math.ceil(n).toString()+"%"),t.css("width",n.toString()+"%")}}),e.addClass("loaded"))}onScreen(){const e=jQuery(window).scrollTop()+jQuery(window).height();return this.elements.$wrapper.offset().top<=e}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_progress_bar.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-search"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper)}}bindEvents(){const e=this.elements.$wrapper;e.magnificPopup({mainClass:"mfp-fade jkit-magnific-popup",delegate:"a.jkit-search-modal",removalDelay:500,midClick:!0,showCloseBtn:!0,closeBtnInside:!1,prependTo:e,type:"inline",fixedContentPos:!0,fixedBgPos:!0,overflowY:"auto"})}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_search.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{bindEvents(){this.$element.data("stickyTop",this.$element.offset().top),this.runSticky()}runSticky(){if(!this.$element.hasClass("jkit-sticky-element--enabled"))return;const e=jQuery,t=this.$element,n=this.getElementSettings(),s=t.hasClass("jkit-sticky-element-on--down")?"down":t.hasClass("jkit-sticky-element-on--up")?"up":"both",o=t.hasClass("jkit-sticky-position--fixed")?"fixed":"sticky";let a=t.data("stickyTop");"fixed"===o?t.wrap('<div class="wrapper-sticky-fixed" style="height: '+t.height()+'px"></div>'):t.parent().hasClass("wrapper-sticky-fixed")&&t.unwrap(),e(window).on("load resize scroll",t,(function(){const i=e("body").attr("data-elementor-device-mode");let r=!0;if(Object.values(n.jkit_sticky_device).forEach((function(e){i!==e||(r=!1)})),r)return t.css("position","relative"),t.removeClass("sticky-pinned"),void(t.hasClass("elementor-column")||t.css("width","unset"));const l="down"===s?e(this).scrollTop():e(this).scrollTop()+e(this).height(),d="down"===s?a:a+t.outerHeight(!0),m="fixed"===o?t.parent().width()+"px":"unset";t.hasClass("sticky-pinned")||(a=t.offset().top,void 0!==n&&(void 0!==n.jkit_sticky_top_position&&(a-=n.jkit_sticky_top_position.size),void 0!==n.jkit_sticky_bottom_position&&(a+=n.jkit_sticky_bottom_position.size))),t.hasClass("elementor-column")||t.css("width",m),"down"===s&&d<l||"up"===s&&d>l||"both"===s&&"sticky"===o?(t.css("position",o),t.addClass("sticky-pinned")):(t.css("position","relative"),t.removeClass("sticky-pinned"))}))}onElementChange(e){-1!==["jkit_sticky_section","jkit_sticky_device","jkit_sticky_trigger","jkit_sticky_position"].indexOf(e)&&(jQuery(window).off("load resize scroll",this.$element),this.runSticky())}}jQuery(window).on("elementor/frontend/init",(()=>{const e=e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})};elementorFrontend.hooks.addAction("frontend/element_ready/section",e),elementorFrontend.hooks.addAction("frontend/element_ready/column",e)}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-tabs",tab:"li.tab-nav",content:".tab-content-list"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$tab:this.$element.find(e.tab),$content:this.$element.find(e.content)}}bindEvents(){const e=this,t="yes"===e.$element.find(".tab-nav-list").data("toggle");t&&e.$element.find("li.tab-nav.active").find(".tab-content").slideDown(),e.elements.$tab.on("click",(function(){if(jQuery(this).hasClass("active"))return;const n=jQuery(this).data("tab");e.elements.$tab.removeClass("active"),t&&(e.elements.$tab.find(".tab-content").slideUp(),jQuery(this).find(".tab-content").slideDown()),jQuery(this).addClass("active"),e.elements.$content.find(".tab-content").removeClass("active"),e.elements.$content.find("."+n).addClass("active")}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_tabs.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-team",close_modal:".team-modal-close"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$close_modal:this.$element.find(e.close_modal)}}bindEvents(){this.onClick()}onClick(){const e=this.elements.$wrapper,t=this.elements.$close_modal;e.magnificPopup({delegate:"a.jkit-team-modal",removalDelay:500,callbacks:{beforeOpen:function(){this.st.mainClass=this.st.el.attr("data-effect")}},midClick:!0,showCloseBtn:!1,prependTo:e,type:"inline",fixedContentPos:!0,fixedBgPos:!0,overflowY:"auto"}),t.on("click",(function(e){e.preventDefault(),jQuery.magnificPopup.close()}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_team.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-testimonials",items:".testimonials-track"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$items:this.$element.find(e.items)}}bindEvents(){this.onLoadElement()}onLoadElement(){this.loadCarousel()}loadCarousel(){const e=this.elements.$wrapper.data("id"),t=this.getSettings("selectors"),n=this.elements.$wrapper.data("settings"),s=n.responsive,o={0:{items:1,gutter:0},768:{items:2,gutter:0},1025:{items:3,gutter:10}},a={};Object.entries(s).forEach((([e,t])=>{a[t.breakpoint]={},""!==t.items?a[t.breakpoint].items=t.items:o[t.breakpoint]&&(a[t.breakpoint].items=o[t.breakpoint].items),""!==t.margin?a[t.breakpoint].gutter=t.margin:o[t.breakpoint]&&(a[t.breakpoint].gutter=o[t.breakpoint].gutter)}));const i={container:t.wrapper+'[data-id="'+e+'"] '+t.items,loop:!0,mouseDrag:!0,autoplay:n.autoplay,autoplayTimeout:n.autoplay_speed,autoplayHoverPause:n.autoplay_hover_pause,navPosition:"bottom",controlsPosition:n.arrow_position,controlsText:[n.navigation_left,n.navigation_right],responsiveClass:!0,responsive:a};tns(i),this.elements.$wrapper.find("button[data-action]").remove(),n.show_navigation||this.elements.$wrapper.find(".tns-controls").remove(),n.show_dots||this.elements.$wrapper.find(".tns-nav").remove(),n.show_navigation&&(i.nav=!0,i.navText=['<i class="'+n.navigation_left+'" aria-hidden="true"></i>','<i class="'+n.navigation_right+'" aria-hidden="true"></i>'])}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_testimonials.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))},function(e,t){class n extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{wrapper:".jeg-elementor-kit.jkit-video-button",link:".jeg-elementor-kit.jkit-video-button .jkit-video-popup-btn"}}}getDefaultElements(){const e=this.getSettings("selectors");return{$wrapper:this.$element.find(e.wrapper),$link:this.$element.find(e.link)}}bindEvents(){this.onClick()}onClick(){const e=this.elements.$wrapper,t=e.data("type"),n=e.data("autoplay"),s=e.data("mute"),o=e.data("loop"),a=e.data("controls"),i=e.data("unique-id");let r="//www.youtube.com/embed/";"self_hosted"===t?this.elements.$link.magnificPopup({type:"inline",src:"#jkit_video_button_"+i}):(r="youtube"==t?r+"?playlist=%id%&autoplay="+n+"&mute="+s+"&loop="+o+"&controls="+a+"&start="+e.data("start")+"&end="+e.data("end")+"&version=3":"//player.vimeo.com/video/%id%?autoplay="+n+"&muted="+s+"&loop="+o+"&controls="+a+"&title="+e.data("title")+"&portrait="+e.data("portrait")+"&byline="+e.data("byline"),this.elements.$link.magnificPopup({type:"iframe",iframe:{patterns:{youtube:{index:"youtube.com/",id:function(e){var t=e.match(/[\\?\\&]v=([^\\?\\&]+)/);return t&&t[1]?t[1]:null},src:r},vimeo:{index:"vimeo.com/",id:function(e){var t=e.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/);return t&&t[5]?t[5]:null},src:r}}},mainClass:"mfp-fade jkit-magnific-popup",removalDelay:160,preloader:!0,fixedContentPos:!1,showCloseBtn:!0}))}}jQuery(window).on("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/jkit_video_button.default",(e=>{elementorFrontend.elementsHandler.addHandler(n,{$element:e})}))}))}]);
|
jeg-elementor-kit.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Jeg Elementor Kit
|
4 |
* Plugin URI: http://jegtheme.com/
|
5 |
* Description: Additional highly customizable widgets for Elementor page builder
|
6 |
-
* Version: 2.5.
|
7 |
* Author: Jegstudio
|
8 |
* Author URI: http://jegtheme.com
|
9 |
* License: GPLv3
|
@@ -25,7 +25,7 @@ add_action(
|
|
25 |
function() {
|
26 |
defined( 'JEG_ELEMENTOR_KIT' ) || define( 'JEG_ELEMENTOR_KIT', 'jeg-elementor-kit' );
|
27 |
defined( 'JEG_ELEMENTOR_KIT_NAME' ) || define( 'JEG_ELEMENTOR_KIT_NAME', 'Jeg Elementor Kit' );
|
28 |
-
defined( 'JEG_ELEMENTOR_KIT_VERSION' ) || define( 'JEG_ELEMENTOR_KIT_VERSION', '2.5.
|
29 |
defined( 'JEG_ELEMENTOR_KIT_URL' ) || define( 'JEG_ELEMENTOR_KIT_URL', plugins_url( JEG_ELEMENTOR_KIT ) );
|
30 |
defined( 'JEG_ELEMENTOR_KIT_FILE' ) || define( 'JEG_ELEMENTOR_KIT_FILE', __FILE__ );
|
31 |
defined( 'JEG_ELEMENTOR_KIT_BASE' ) || define( 'JEG_ELEMENTOR_KIT_BASE', plugin_basename( __FILE__ ) );
|
3 |
* Plugin Name: Jeg Elementor Kit
|
4 |
* Plugin URI: http://jegtheme.com/
|
5 |
* Description: Additional highly customizable widgets for Elementor page builder
|
6 |
+
* Version: 2.5.2
|
7 |
* Author: Jegstudio
|
8 |
* Author URI: http://jegtheme.com
|
9 |
* License: GPLv3
|
25 |
function() {
|
26 |
defined( 'JEG_ELEMENTOR_KIT' ) || define( 'JEG_ELEMENTOR_KIT', 'jeg-elementor-kit' );
|
27 |
defined( 'JEG_ELEMENTOR_KIT_NAME' ) || define( 'JEG_ELEMENTOR_KIT_NAME', 'Jeg Elementor Kit' );
|
28 |
+
defined( 'JEG_ELEMENTOR_KIT_VERSION' ) || define( 'JEG_ELEMENTOR_KIT_VERSION', '2.5.2' );
|
29 |
defined( 'JEG_ELEMENTOR_KIT_URL' ) || define( 'JEG_ELEMENTOR_KIT_URL', plugins_url( JEG_ELEMENTOR_KIT ) );
|
30 |
defined( 'JEG_ELEMENTOR_KIT_FILE' ) || define( 'JEG_ELEMENTOR_KIT_FILE', __FILE__ );
|
31 |
defined( 'JEG_ELEMENTOR_KIT_BASE' ) || define( 'JEG_ELEMENTOR_KIT_BASE', plugin_basename( __FILE__ ) );
|
lib/jeg-element/includes/class/elementor/control/class-dynamic-select-elementor.php
CHANGED
@@ -39,15 +39,15 @@ class Dynamic_Select_Elementor extends Base_Data_Control {
|
|
39 |
<div class="elementor-control-input-wrapper type-select">
|
40 |
<# if ( 1 < data.multiple || 'no' === data.multiple ) { #>
|
41 |
<input id="<?php echo esc_attr( $control_uid ); ?>" type="text" class="tooltip-target input-sortable"
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
<div class="data-option" style="display: none;">{{ data.options }}</div>
|
52 |
<# } else { #>
|
53 |
<select id="<?php echo esc_attr( $control_uid ); ?>" class="widefat" data-setting="{{ data.name }}" data-ajax="{{ data.ajax }}" data-nonce="{{ data.nonce }}">
|
@@ -61,11 +61,11 @@ class Dynamic_Select_Elementor extends Base_Data_Control {
|
|
61 |
<# if ( data.description ) { #>
|
62 |
<div class="elementor-control-field-description">{{{ data.description }}}</div>
|
63 |
<# } #>
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
<?php
|
70 |
}
|
71 |
}
|
39 |
<div class="elementor-control-input-wrapper type-select">
|
40 |
<# if ( 1 < data.multiple || 'no' === data.multiple ) { #>
|
41 |
<input id="<?php echo esc_attr( $control_uid ); ?>" type="text" class="tooltip-target input-sortable"
|
42 |
+
title="{{ data.title }}"
|
43 |
+
placeholder="{{ data.placeholder }}"
|
44 |
+
data-retriever="{{ data.retriever }}"
|
45 |
+
data-setting="{{ data.name }}"
|
46 |
+
data-tooltip="{{ data.title }}"
|
47 |
+
data-ajax="{{ data.ajax }}"
|
48 |
+
data-slug="{{ data.slug }}"
|
49 |
+
data-multiple="{{ ('no' === data.multiple) ? 1 : data.multiple }}"
|
50 |
+
data-nonce="{{ data.nonce }}"/>
|
51 |
<div class="data-option" style="display: none;">{{ data.options }}</div>
|
52 |
<# } else { #>
|
53 |
<select id="<?php echo esc_attr( $control_uid ); ?>" class="widefat" data-setting="{{ data.name }}" data-ajax="{{ data.ajax }}" data-nonce="{{ data.nonce }}">
|
61 |
<# if ( data.description ) { #>
|
62 |
<div class="elementor-control-field-description">{{{ data.description }}}</div>
|
63 |
<# } #>
|
64 |
+
<#
|
65 |
+
(function ($) {
|
66 |
+
window.open_control($('#<?php echo esc_attr( str_replace( '{{{ data._cid }}}', '', $control_uid ) ); ?>' + data._cid));
|
67 |
+
})(jQuery);
|
68 |
+
#>
|
69 |
<?php
|
70 |
}
|
71 |
}
|
lib/jeg-element/includes/class/wpbakery/class-wpbakery-integration.php
CHANGED
@@ -37,8 +37,7 @@ class Wpbakery_Integration {
|
|
37 |
* @return bool
|
38 |
*/
|
39 |
public function flag_load_element_option( $flag ) {
|
40 |
-
if ( ( isset( $_GET['vc_editable'] ) && $_GET['vc_editable'] ) ||
|
41 |
-
( isset( $_GET['vc_action'] ) && $_GET['vc_action'] === 'vc_inline' ) ) {
|
42 |
return true;
|
43 |
}
|
44 |
|
@@ -49,7 +48,7 @@ class Wpbakery_Integration {
|
|
49 |
* Reset shortcode width
|
50 |
*
|
51 |
* @param boolean $flag Flag if we will reset the width.
|
52 |
-
* @param string
|
53 |
*
|
54 |
* @return boolean
|
55 |
*/
|
@@ -64,8 +63,8 @@ class Wpbakery_Integration {
|
|
64 |
/**
|
65 |
* Calculate width for every shortcode.
|
66 |
*
|
67 |
-
* @param int
|
68 |
-
* @param string
|
69 |
* @param array|string $attr Shortcode attributes array or empty string.
|
70 |
*
|
71 |
* @return integer
|
@@ -108,10 +107,10 @@ class Wpbakery_Integration {
|
|
108 |
/**
|
109 |
* Additional class for each element
|
110 |
*
|
111 |
-
* @param array
|
112 |
-
* @param string
|
113 |
* @param integer $post_id Post ID of current Page.
|
114 |
-
* @param array
|
115 |
*
|
116 |
* @return array
|
117 |
*/
|
@@ -162,7 +161,7 @@ class Wpbakery_Integration {
|
|
162 |
array(
|
163 |
'attach_file',
|
164 |
array( $this, 'vc_attach_file' ),
|
165 |
-
JEG_ELEMENT_URL . '/assets/js/vc/vc.script.js'
|
166 |
),
|
167 |
);
|
168 |
|
@@ -215,35 +214,35 @@ class Wpbakery_Integration {
|
|
215 |
}
|
216 |
|
217 |
?>
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
<?php if ( $settings['multiple'] > 1 ) { ?>
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
<?php } else { ?>
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
<?php
|
236 |
foreach ( $options as $option ) {
|
237 |
$select = ( $option['value'] === $value ) ? 'selected' : '';
|
238 |
?>
|
239 |
-
|
240 |
-
|
241 |
<?php
|
242 |
}
|
243 |
?>
|
244 |
-
|
245 |
<?php } ?>
|
246 |
-
|
247 |
<?php
|
248 |
return ob_get_clean();
|
249 |
}
|
@@ -283,7 +282,7 @@ class Wpbakery_Integration {
|
|
283 |
$option .= "<input name='" . $settings['param_name'] . "' class='wpb_vc_param_value wpb-input " . $settings['param_name'] . ' ' . $settings['type'] . "_field' type='hidden' value='" . $value . "' />";
|
284 |
foreach ( $settings['value'] as $key => $val ) {
|
285 |
$checked = in_array( $val, $valuearr, true ) ? 'checked="checked"' : '';
|
286 |
-
$option
|
287 |
}
|
288 |
|
289 |
return '<div class="wp-tab-panel vc_checkblock">
|
@@ -304,7 +303,7 @@ class Wpbakery_Integration {
|
|
304 |
$radio_input = "<input type='hidden' name='{$settings['param_name']}' value='{$value}' class='wpb_vc_param_value wpb-input{$settings['param_name']}'/>";
|
305 |
|
306 |
foreach ( $settings['value'] as $key => $val ) {
|
307 |
-
$checked
|
308 |
$radio_option .=
|
309 |
"<label>
|
310 |
<input {$checked} type='radio' name='{$settings['param_name']}_field' value='{$val}' class='{$settings['type']}_field'/>
|
37 |
* @return bool
|
38 |
*/
|
39 |
public function flag_load_element_option( $flag ) {
|
40 |
+
if ( ( isset( $_GET['vc_editable'] ) && $_GET['vc_editable'] ) || ( isset( $_GET['vc_action'] ) && $_GET['vc_action'] === 'vc_inline' ) ) {
|
|
|
41 |
return true;
|
42 |
}
|
43 |
|
48 |
* Reset shortcode width
|
49 |
*
|
50 |
* @param boolean $flag Flag if we will reset the width.
|
51 |
+
* @param string $tag Shortcode name.
|
52 |
*
|
53 |
* @return boolean
|
54 |
*/
|
63 |
/**
|
64 |
* Calculate width for every shortcode.
|
65 |
*
|
66 |
+
* @param int $width Current width for shortcode.
|
67 |
+
* @param string $tag Shortcode name.
|
68 |
* @param array|string $attr Shortcode attributes array or empty string.
|
69 |
*
|
70 |
* @return integer
|
107 |
/**
|
108 |
* Additional class for each element
|
109 |
*
|
110 |
+
* @param array $classes Collection of classes for element.
|
111 |
+
* @param string $id ID / Shortcode Element.
|
112 |
* @param integer $post_id Post ID of current Page.
|
113 |
+
* @param array $attribute Attribute.
|
114 |
*
|
115 |
* @return array
|
116 |
*/
|
161 |
array(
|
162 |
'attach_file',
|
163 |
array( $this, 'vc_attach_file' ),
|
164 |
+
JEG_ELEMENT_URL . '/assets/js/vc/vc.script.js',
|
165 |
),
|
166 |
);
|
167 |
|
214 |
}
|
215 |
|
216 |
?>
|
217 |
+
<div class="vc-select-wrapper" data-ajax="<?php echo esc_attr( $settings['ajax'] ); ?>"
|
218 |
+
data-multiple="<?php echo esc_attr( $settings['multiple'] ); ?>"
|
219 |
+
data-slug="<?php echo esc_attr( $slug ); ?>"
|
220 |
+
data-nonce="<?php echo esc_attr( $settings['nonce'] ); ?>">
|
221 |
<?php if ( $settings['multiple'] > 1 ) { ?>
|
222 |
+
<input
|
223 |
+
class='wpb_vc_param_value wpb-input input-sortable multiselect_field <?php echo esc_html( $settings['param_name'] ); ?> <?php echo esc_html( $settings['type'] ); ?>_field'
|
224 |
+
type="text" name="<?php echo esc_attr( $settings['param_name'] ); ?>"
|
225 |
+
value="<?php echo esc_attr( $value ); ?>"/>
|
226 |
+
<div class="data-option" style="display: none;">
|
227 |
+
<?php echo wp_json_encode( $options ); ?>
|
228 |
+
</div>
|
229 |
<?php } else { ?>
|
230 |
+
<select
|
231 |
+
class='wpb_vc_param_value wpb-input input-sortable <?php echo esc_html( $settings['param_name'] ); ?> <?php echo esc_html( $settings['type'] ); ?>_field'
|
232 |
+
name="<?php echo esc_attr( $settings['param_name'] ); ?>">
|
233 |
+
<option value=''></option>
|
234 |
<?php
|
235 |
foreach ( $options as $option ) {
|
236 |
$select = ( $option['value'] === $value ) ? 'selected' : '';
|
237 |
?>
|
238 |
+
<option
|
239 |
+
value='<?php echo esc_attr( $option['value'] ); ?>' <?php echo esc_attr( $select ); ?>><?php echo esc_html( $option['text'] ); ?></option>
|
240 |
<?php
|
241 |
}
|
242 |
?>
|
243 |
+
</select>
|
244 |
<?php } ?>
|
245 |
+
</div>
|
246 |
<?php
|
247 |
return ob_get_clean();
|
248 |
}
|
282 |
$option .= "<input name='" . $settings['param_name'] . "' class='wpb_vc_param_value wpb-input " . $settings['param_name'] . ' ' . $settings['type'] . "_field' type='hidden' value='" . $value . "' />";
|
283 |
foreach ( $settings['value'] as $key => $val ) {
|
284 |
$checked = in_array( $val, $valuearr, true ) ? 'checked="checked"' : '';
|
285 |
+
$option .= '<label><input ' . $checked . ' class="checkblock" value="' . $val . '" type="checkbox">' . $key . '</label>';
|
286 |
}
|
287 |
|
288 |
return '<div class="wp-tab-panel vc_checkblock">
|
303 |
$radio_input = "<input type='hidden' name='{$settings['param_name']}' value='{$value}' class='wpb_vc_param_value wpb-input{$settings['param_name']}'/>";
|
304 |
|
305 |
foreach ( $settings['value'] as $key => $val ) {
|
306 |
+
$checked = ( $value === $val ) ? 'checked' : '';
|
307 |
$radio_option .=
|
308 |
"<label>
|
309 |
<input {$checked} type='radio' name='{$settings['param_name']}_field' value='{$val}' class='{$settings['type']}_field'/>
|
lib/jeg-framework/assets/js/form/meta-box-container.js
CHANGED
@@ -83,7 +83,9 @@
|
|
83 |
}
|
84 |
};
|
85 |
|
86 |
-
$(document).on('ready', function() {
|
|
|
|
|
87 |
var metaboxData = JSON.parse(window.jegMetaboxData)
|
88 |
if (undefined !== jeg.metabox) {
|
89 |
jeg.metabox.build(metaboxData.id, metaboxData.type, metaboxData.data);
|
83 |
}
|
84 |
};
|
85 |
|
86 |
+
$(document).on('ready', function () {
|
87 |
+
if (typeof window.jegMetaboxData === 'undefined') return;
|
88 |
+
|
89 |
var metaboxData = JSON.parse(window.jegMetaboxData)
|
90 |
if (undefined !== jeg.metabox) {
|
91 |
jeg.metabox.build(metaboxData.id, metaboxData.type, metaboxData.data);
|
lib/jeg-framework/assets/js/vendor/codemirror/AUTHORS
DELETED
@@ -1,510 +0,0 @@
|
|
1 |
-
List of CodeMirror contributors. Updated before every release.
|
2 |
-
|
3 |
-
4r2r
|
4 |
-
Aaron Brooks
|
5 |
-
Abdelouahab
|
6 |
-
Abe Fettig
|
7 |
-
Adam Ahmed
|
8 |
-
Adam King
|
9 |
-
adanlobato
|
10 |
-
Adán Lobato
|
11 |
-
Adrian Aichner
|
12 |
-
aeroson
|
13 |
-
Ahmad Amireh
|
14 |
-
Ahmad M. Zawawi
|
15 |
-
ahoward
|
16 |
-
Akeksandr Motsjonov
|
17 |
-
Alberto González Palomo
|
18 |
-
Alberto Pose
|
19 |
-
Albert Xing
|
20 |
-
Alexander Pavlov
|
21 |
-
Alexander Schepanovski
|
22 |
-
Alexander Shvets
|
23 |
-
Alexander Solovyov
|
24 |
-
Alexandre Bique
|
25 |
-
alexey-k
|
26 |
-
Alex Piggott
|
27 |
-
Aliaksei Chapyzhenka
|
28 |
-
Allen Sarkisyan
|
29 |
-
Amin Shali
|
30 |
-
amshali@google.com
|
31 |
-
Amsul
|
32 |
-
amuntean
|
33 |
-
Amy
|
34 |
-
Ananya Sen
|
35 |
-
anaran
|
36 |
-
AndersMad
|
37 |
-
Anders Nawroth
|
38 |
-
Anderson Mesquita
|
39 |
-
Anders Wåglund
|
40 |
-
Andrea G
|
41 |
-
Andreas Reischuck
|
42 |
-
Andres Taylor
|
43 |
-
Andre von Houck
|
44 |
-
Andrey Fedorov
|
45 |
-
Andrey Klyuchnikov
|
46 |
-
Andrey Lushnikov
|
47 |
-
Andy Joslin
|
48 |
-
Andy Kimball
|
49 |
-
Andy Li
|
50 |
-
Angelo
|
51 |
-
angelozerr
|
52 |
-
angelo.zerr@gmail.com
|
53 |
-
Ankit
|
54 |
-
Ankit Ahuja
|
55 |
-
Ansel Santosa
|
56 |
-
Anthony Dugois
|
57 |
-
anthonygego
|
58 |
-
Anthony Gégo
|
59 |
-
Anthony Grimes
|
60 |
-
Anton Kovalyov
|
61 |
-
AQNOUCH Mohammed
|
62 |
-
areos
|
63 |
-
as3boyan
|
64 |
-
AtomicPages LLC
|
65 |
-
Atul Bhouraskar
|
66 |
-
Aurelian Oancea
|
67 |
-
Barret Rennie
|
68 |
-
Basarat Ali Syed
|
69 |
-
Bastian Müller
|
70 |
-
belhaj
|
71 |
-
Bem Jones-Bey
|
72 |
-
benbro
|
73 |
-
Beni Cherniavsky-Paskin
|
74 |
-
Benjamin DeCoste
|
75 |
-
Ben Keen
|
76 |
-
Bernhard Sirlinger
|
77 |
-
Bert Chang
|
78 |
-
Billy Moon
|
79 |
-
binny
|
80 |
-
B Krishna Chaitanya
|
81 |
-
Blaine G
|
82 |
-
blukat29
|
83 |
-
boomyjee
|
84 |
-
borawjm
|
85 |
-
Brad Metcalf
|
86 |
-
Brandon Frohs
|
87 |
-
Brandon Wamboldt
|
88 |
-
Brett Zamir
|
89 |
-
Brian Grinstead
|
90 |
-
Brian Sletten
|
91 |
-
Bruce Mitchener
|
92 |
-
Caitlin Potter
|
93 |
-
Calin Barbat
|
94 |
-
Chandra Sekhar Pydi
|
95 |
-
Charles Skelton
|
96 |
-
Cheah Chu Yeow
|
97 |
-
Chris Coyier
|
98 |
-
Chris Granger
|
99 |
-
Chris Houseknecht
|
100 |
-
Chris Lohfink
|
101 |
-
Chris Morgan
|
102 |
-
Christian Oyarzun
|
103 |
-
Christian Petrov
|
104 |
-
Christopher Brown
|
105 |
-
Christopher Mitchell
|
106 |
-
Christopher Pfohl
|
107 |
-
ciaranj
|
108 |
-
CodeAnimal
|
109 |
-
coderaiser
|
110 |
-
ComFreek
|
111 |
-
Curtis Gagliardi
|
112 |
-
dagsta
|
113 |
-
daines
|
114 |
-
Dale Jung
|
115 |
-
Dan Bentley
|
116 |
-
Dan Heberden
|
117 |
-
Daniel, Dao Quang Minh
|
118 |
-
Daniele Di Sarli
|
119 |
-
Daniel Faust
|
120 |
-
Daniel Huigens
|
121 |
-
Daniel KJ
|
122 |
-
Daniel Neel
|
123 |
-
Daniel Parnell
|
124 |
-
Danny Yoo
|
125 |
-
darealshinji
|
126 |
-
Darius Roberts
|
127 |
-
Dave Brondsema
|
128 |
-
Dave Myers
|
129 |
-
David Barnett
|
130 |
-
David Mignot
|
131 |
-
David Pathakjee
|
132 |
-
David Vázquez
|
133 |
-
deebugger
|
134 |
-
Deep Thought
|
135 |
-
Devon Carew
|
136 |
-
dignifiedquire
|
137 |
-
Dimage Sapelkin
|
138 |
-
Dmitry Kiselyov
|
139 |
-
domagoj412
|
140 |
-
Dominator008
|
141 |
-
Domizio Demichelis
|
142 |
-
Doug Wikle
|
143 |
-
Drew Bratcher
|
144 |
-
Drew Hintz
|
145 |
-
Drew Khoury
|
146 |
-
Dror BG
|
147 |
-
duralog
|
148 |
-
eborden
|
149 |
-
edsharp
|
150 |
-
ekhaled
|
151 |
-
Elisée
|
152 |
-
Enam Mijbah Noor
|
153 |
-
Eric Allam
|
154 |
-
eustas
|
155 |
-
Fabien O'Carroll
|
156 |
-
Fabio Zendhi Nagao
|
157 |
-
Faiza Alsaied
|
158 |
-
Fauntleroy
|
159 |
-
fbuchinger
|
160 |
-
feizhang365
|
161 |
-
Felipe Lalanne
|
162 |
-
Felix Raab
|
163 |
-
Filip Noetzel
|
164 |
-
flack
|
165 |
-
ForbesLindesay
|
166 |
-
Forbes Lindesay
|
167 |
-
Ford_Lawnmower
|
168 |
-
Forrest Oliphant
|
169 |
-
Frank Wiegand
|
170 |
-
Gabriel Gheorghian
|
171 |
-
Gabriel Horner
|
172 |
-
Gabriel Nahmias
|
173 |
-
galambalazs
|
174 |
-
Gautam Mehta
|
175 |
-
gekkoe
|
176 |
-
Gerard Braad
|
177 |
-
Gergely Hegykozi
|
178 |
-
Giovanni Calò
|
179 |
-
Glenn Jorde
|
180 |
-
Glenn Ruehle
|
181 |
-
Golevka
|
182 |
-
Gordon Smith
|
183 |
-
Grant Skinner
|
184 |
-
greengiant
|
185 |
-
Gregory Koberger
|
186 |
-
Guillaume Massé
|
187 |
-
Guillaume Massé
|
188 |
-
Gustavo Rodrigues
|
189 |
-
Hakan Tunc
|
190 |
-
Hans Engel
|
191 |
-
Hardest
|
192 |
-
Hasan Karahan
|
193 |
-
Hector Oswaldo Caballero
|
194 |
-
Herculano Campos
|
195 |
-
Hiroyuki Makino
|
196 |
-
hitsthings
|
197 |
-
Hocdoc
|
198 |
-
Ian Beck
|
199 |
-
Ian Dickinson
|
200 |
-
Ian Wehrman
|
201 |
-
Ian Wetherbee
|
202 |
-
Ice White
|
203 |
-
ICHIKAWA, Yuji
|
204 |
-
idleberg
|
205 |
-
ilvalle
|
206 |
-
Ingo Richter
|
207 |
-
Irakli Gozalishvili
|
208 |
-
Ivan Kurnosov
|
209 |
-
Ivoah
|
210 |
-
Jacob Lee
|
211 |
-
Jakob Miland
|
212 |
-
Jakub Vrana
|
213 |
-
Jakub Vrána
|
214 |
-
James Campos
|
215 |
-
James Thorne
|
216 |
-
Jamie Hill
|
217 |
-
Jan Jongboom
|
218 |
-
jankeromnes
|
219 |
-
Jan Keromnes
|
220 |
-
Jan Odvarko
|
221 |
-
Jan T. Sott
|
222 |
-
Jared Forsyth
|
223 |
-
Jason
|
224 |
-
Jason Barnabe
|
225 |
-
Jason Grout
|
226 |
-
Jason Johnston
|
227 |
-
Jason San Jose
|
228 |
-
Jason Siefken
|
229 |
-
Jaydeep Solanki
|
230 |
-
Jean Boussier
|
231 |
-
Jeff Blaisdell
|
232 |
-
jeffkenton
|
233 |
-
Jeff Pickhardt
|
234 |
-
jem (graphite)
|
235 |
-
Jeremy Parmenter
|
236 |
-
Jochen Berger
|
237 |
-
Johan Ask
|
238 |
-
John Connor
|
239 |
-
John Engler
|
240 |
-
John Lees-Miller
|
241 |
-
John Snelson
|
242 |
-
John Van Der Loo
|
243 |
-
Jonas Döbertin
|
244 |
-
Jonathan Malmaud
|
245 |
-
jongalloway
|
246 |
-
Jon Malmaud
|
247 |
-
Jon Sangster
|
248 |
-
Joost-Wim Boekesteijn
|
249 |
-
Joseph Pecoraro
|
250 |
-
Joshua Newman
|
251 |
-
Josh Watzman
|
252 |
-
jots
|
253 |
-
jsoojeon
|
254 |
-
ju1ius
|
255 |
-
Juan Benavides Romero
|
256 |
-
Jucovschi Constantin
|
257 |
-
Juho Vuori
|
258 |
-
Justin Hileman
|
259 |
-
jwallers@gmail.com
|
260 |
-
kaniga
|
261 |
-
karevn
|
262 |
-
Ken Newman
|
263 |
-
Ken Rockot
|
264 |
-
Kevin Earls
|
265 |
-
Kevin Sawicki
|
266 |
-
Kevin Ushey
|
267 |
-
Klaus Silveira
|
268 |
-
Koh Zi Han, Cliff
|
269 |
-
komakino
|
270 |
-
Konstantin Lopuhin
|
271 |
-
koops
|
272 |
-
ks-ifware
|
273 |
-
kubelsmieci
|
274 |
-
KwanEsq
|
275 |
-
Lanfei
|
276 |
-
Lanny
|
277 |
-
Laszlo Vidacs
|
278 |
-
leaf corcoran
|
279 |
-
Leonid Khachaturov
|
280 |
-
Leon Sorokin
|
281 |
-
Leonya Khachaturov
|
282 |
-
Liam Newman
|
283 |
-
Libo Cannici
|
284 |
-
LloydMilligan
|
285 |
-
LM
|
286 |
-
lochel
|
287 |
-
Lorenzo Stoakes
|
288 |
-
Luciano Longo
|
289 |
-
Luke Stagner
|
290 |
-
lynschinzer
|
291 |
-
M1cha
|
292 |
-
Madhura Jayaratne
|
293 |
-
Maksim Lin
|
294 |
-
Maksym Taran
|
295 |
-
Malay Majithia
|
296 |
-
Manuel Rego Casasnovas
|
297 |
-
Marat Dreizin
|
298 |
-
Marcel Gerber
|
299 |
-
Marco Aurélio
|
300 |
-
Marco Munizaga
|
301 |
-
Marcus Bointon
|
302 |
-
Marek Rudnicki
|
303 |
-
Marijn Haverbeke
|
304 |
-
Mário Gonçalves
|
305 |
-
Mario Pietsch
|
306 |
-
Mark Anderson
|
307 |
-
Mark Lentczner
|
308 |
-
Marko Bonaci
|
309 |
-
Markus Bordihn
|
310 |
-
Martin Balek
|
311 |
-
Martín Gaitán
|
312 |
-
Martin Hasoň
|
313 |
-
Martin Hunt
|
314 |
-
Martin Laine
|
315 |
-
Martin Zagora
|
316 |
-
Mason Malone
|
317 |
-
Mateusz Paprocki
|
318 |
-
Mathias Bynens
|
319 |
-
mats cronqvist
|
320 |
-
Matt Gaide
|
321 |
-
Matthew Bauer
|
322 |
-
Matthew Beale
|
323 |
-
Matthew Rathbone
|
324 |
-
Matthias Bussonnier
|
325 |
-
Matthias BUSSONNIER
|
326 |
-
Matt McDonald
|
327 |
-
Matt Pass
|
328 |
-
Matt Sacks
|
329 |
-
mauricio
|
330 |
-
Maximilian Hils
|
331 |
-
Maxim Kraev
|
332 |
-
Max Kirsch
|
333 |
-
Max Schaefer
|
334 |
-
Max Xiantu
|
335 |
-
mbarkhau
|
336 |
-
melpon
|
337 |
-
Metatheos
|
338 |
-
Micah Dubinko
|
339 |
-
Michael
|
340 |
-
Michael Goderbauer
|
341 |
-
Michael Grey
|
342 |
-
Michael Kaminsky
|
343 |
-
Michael Lehenbauer
|
344 |
-
Michael Zhou
|
345 |
-
Michal Dorner
|
346 |
-
Mighty Guava
|
347 |
-
Miguel Castillo
|
348 |
-
mihailik
|
349 |
-
Mike
|
350 |
-
Mike Brevoort
|
351 |
-
Mike Diaz
|
352 |
-
Mike Ivanov
|
353 |
-
Mike Kadin
|
354 |
-
MinRK
|
355 |
-
Miraculix87
|
356 |
-
misfo
|
357 |
-
mkaminsky11
|
358 |
-
mloginov
|
359 |
-
Moritz Schwörer
|
360 |
-
mps
|
361 |
-
ms
|
362 |
-
mtaran-google
|
363 |
-
Narciso Jaramillo
|
364 |
-
Nathan Williams
|
365 |
-
ndr
|
366 |
-
nerbert
|
367 |
-
nextrevision
|
368 |
-
ngn
|
369 |
-
nguillaumin
|
370 |
-
Ng Zhi An
|
371 |
-
Nicholas Bollweg
|
372 |
-
Nicholas Bollweg (Nick)
|
373 |
-
Nick Kreeger
|
374 |
-
Nick Small
|
375 |
-
Niels van Groningen
|
376 |
-
nightwing
|
377 |
-
Nikita Beloglazov
|
378 |
-
Nikita Vasilyev
|
379 |
-
Nikolay Kostov
|
380 |
-
nilp0inter
|
381 |
-
Nisarg Jhaveri
|
382 |
-
nlwillia
|
383 |
-
noragrossman
|
384 |
-
Norman Rzepka
|
385 |
-
Oreoluwa Onatemowo
|
386 |
-
pablo
|
387 |
-
Page
|
388 |
-
Panupong Pasupat
|
389 |
-
paris
|
390 |
-
Paris
|
391 |
-
Patil Arpith
|
392 |
-
Patrick Stoica
|
393 |
-
Patrick Strawderman
|
394 |
-
Paul Garvin
|
395 |
-
Paul Ivanov
|
396 |
-
Pavel Feldman
|
397 |
-
Pavel Strashkin
|
398 |
-
Paweł Bartkiewicz
|
399 |
-
peteguhl
|
400 |
-
peter
|
401 |
-
Peter Flynn
|
402 |
-
peterkroon
|
403 |
-
Peter Kroon
|
404 |
-
Philip Stadermann
|
405 |
-
prasanthj
|
406 |
-
Prasanth J
|
407 |
-
Radek Piórkowski
|
408 |
-
Rahul
|
409 |
-
ramwin1
|
410 |
-
Randall Mason
|
411 |
-
Randy Burden
|
412 |
-
Randy Edmunds
|
413 |
-
Rasmus Erik Voel Jensen
|
414 |
-
ray ratchup
|
415 |
-
Ray Ratchup
|
416 |
-
Richard Denton
|
417 |
-
Richard van der Meer
|
418 |
-
Richard Z.H. Wang
|
419 |
-
Robert Crossfield
|
420 |
-
Roberto Abdelkader Martínez Pérez
|
421 |
-
robertop23
|
422 |
-
Robert Plummer
|
423 |
-
Rrandom
|
424 |
-
Ruslan Osmanov
|
425 |
-
Ryan Prior
|
426 |
-
sabaca
|
427 |
-
Samuel Ainsworth
|
428 |
-
sandeepshetty
|
429 |
-
Sander AKA Redsandro
|
430 |
-
santec
|
431 |
-
Sascha Peilicke
|
432 |
-
satamas
|
433 |
-
satchmorun
|
434 |
-
sathyamoorthi
|
435 |
-
S. Chris Colbert
|
436 |
-
SCLINIC\jdecker
|
437 |
-
Scott Aikin
|
438 |
-
Scott Goodhew
|
439 |
-
Sebastian Zaha
|
440 |
-
Se-Won Kim
|
441 |
-
shaund
|
442 |
-
shaun gilchrist
|
443 |
-
Shawn A
|
444 |
-
Shea Bunge
|
445 |
-
sheopory
|
446 |
-
Shiv Deepak
|
447 |
-
Shmuel Englard
|
448 |
-
Shubham Jain
|
449 |
-
silverwind
|
450 |
-
snasa
|
451 |
-
soliton4
|
452 |
-
sonson
|
453 |
-
spastorelli
|
454 |
-
srajanpaliwal
|
455 |
-
Stanislav Oaserele
|
456 |
-
Stas Kobzar
|
457 |
-
Stefan Borsje
|
458 |
-
Steffen Beyer
|
459 |
-
Stephen Lavelle
|
460 |
-
Steve O'Hara
|
461 |
-
stoskov
|
462 |
-
Sungho Kim
|
463 |
-
sverweij
|
464 |
-
Taha Jahangir
|
465 |
-
Tako Schotanus
|
466 |
-
Takuji Shimokawa
|
467 |
-
Tarmil
|
468 |
-
tel
|
469 |
-
tfjgeorge
|
470 |
-
Thaddee Tyl
|
471 |
-
thanasis
|
472 |
-
TheHowl
|
473 |
-
think
|
474 |
-
Thomas Dvornik
|
475 |
-
Thomas Schmid
|
476 |
-
Tim Alby
|
477 |
-
Tim Baumann
|
478 |
-
Timothy Farrell
|
479 |
-
Timothy Hatcher
|
480 |
-
TobiasBg
|
481 |
-
Tomas-A
|
482 |
-
Tomas Varaneckas
|
483 |
-
Tom Erik Støwer
|
484 |
-
Tom MacWright
|
485 |
-
Tony Jian
|
486 |
-
Travis Heppe
|
487 |
-
Triangle717
|
488 |
-
twifkak
|
489 |
-
Vestimir Markov
|
490 |
-
vf
|
491 |
-
Victor Bocharsky
|
492 |
-
Vincent Woo
|
493 |
-
Volker Mische
|
494 |
-
wenli
|
495 |
-
Wes Cossick
|
496 |
-
Wesley Wiser
|
497 |
-
Will Binns-Smith
|
498 |
-
William Jamieson
|
499 |
-
William Stein
|
500 |
-
Willy
|
501 |
-
Wojtek Ptak
|
502 |
-
Xavier Mendez
|
503 |
-
Yassin N. Hassan
|
504 |
-
YNH Webdev
|
505 |
-
Yunchi Luo
|
506 |
-
Yuvi Panda
|
507 |
-
Zachary Dremann
|
508 |
-
Zhang Hao
|
509 |
-
zziuni
|
510 |
-
魏鹏刚
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
Copyright (C) 2015 by Marijn Haverbeke <marijnh@gmail.com> and others
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
-
of this software and associated documentation files (the "Software"), to deal
|
5 |
-
in the Software without restriction, including without limitation the rights
|
6 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
copies of the Software, and to permit persons to whom the Software is
|
8 |
-
furnished to do so, subject to the following conditions:
|
9 |
-
|
10 |
-
The above copyright notice and this permission notice shall be included in
|
11 |
-
all copies or substantial portions of the Software.
|
12 |
-
|
13 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/README.md
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
# CodeMirror
|
2 |
-
[![Build Status](https://travis-ci.org/codemirror/CodeMirror.svg)](https://travis-ci.org/codemirror/CodeMirror)
|
3 |
-
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
|
4 |
-
[![Join the chat at https://gitter.im/codemirror/CodeMirror](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/codemirror/CodeMirror)
|
5 |
-
[Funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png?again)](https://marijnhaverbeke.nl/fund/)
|
6 |
-
|
7 |
-
CodeMirror is a versatile text editor implemented in JavaScript for
|
8 |
-
the browser. It is specialized for editing code, and comes with over
|
9 |
-
100 language modes and various addons that implement more advanced
|
10 |
-
editing functionality.
|
11 |
-
|
12 |
-
A rich programming API and a CSS theming system are available for
|
13 |
-
customizing CodeMirror to fit your application, and extending it with
|
14 |
-
new functionality.
|
15 |
-
|
16 |
-
You can find more information (and the
|
17 |
-
[manual](http://codemirror.net/doc/manual.html)) on the [project
|
18 |
-
page](http://codemirror.net). For questions and discussion, use the
|
19 |
-
[discussion forum](http://discuss.codemirror.net/).
|
20 |
-
|
21 |
-
See
|
22 |
-
[CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
|
23 |
-
for contributing guidelines.
|
24 |
-
|
25 |
-
The CodeMirror community aims to be welcoming to everybody. We use the
|
26 |
-
[Contributor Covenant
|
27 |
-
(1.1)](http://contributor-covenant.org/version/1/1/0/) as our code of
|
28 |
-
conduct.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/comment/comment.js
DELETED
@@ -1,196 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var noOptions = {};
|
15 |
-
var nonWS = /[^\s\u00a0]/;
|
16 |
-
var Pos = CodeMirror.Pos;
|
17 |
-
|
18 |
-
function firstNonWS(str) {
|
19 |
-
var found = str.search(nonWS);
|
20 |
-
return found == -1 ? 0 : found;
|
21 |
-
}
|
22 |
-
|
23 |
-
CodeMirror.commands.toggleComment = function(cm) {
|
24 |
-
cm.toggleComment();
|
25 |
-
};
|
26 |
-
|
27 |
-
CodeMirror.defineExtension("toggleComment", function(options) {
|
28 |
-
if (!options) options = noOptions;
|
29 |
-
var cm = this;
|
30 |
-
var minLine = Infinity, ranges = this.listSelections(), mode = null;
|
31 |
-
for (var i = ranges.length - 1; i >= 0; i--) {
|
32 |
-
var from = ranges[i].from(), to = ranges[i].to();
|
33 |
-
if (from.line >= minLine) continue;
|
34 |
-
if (to.line >= minLine) to = Pos(minLine, 0);
|
35 |
-
minLine = from.line;
|
36 |
-
if (mode == null) {
|
37 |
-
if (cm.uncomment(from, to, options)) mode = "un";
|
38 |
-
else { cm.lineComment(from, to, options); mode = "line"; }
|
39 |
-
} else if (mode == "un") {
|
40 |
-
cm.uncomment(from, to, options);
|
41 |
-
} else {
|
42 |
-
cm.lineComment(from, to, options);
|
43 |
-
}
|
44 |
-
}
|
45 |
-
});
|
46 |
-
|
47 |
-
CodeMirror.defineExtension("lineComment", function(from, to, options) {
|
48 |
-
if (!options) options = noOptions;
|
49 |
-
var self = this, mode = self.getModeAt(from);
|
50 |
-
var commentString = options.lineComment || mode.lineComment;
|
51 |
-
if (!commentString) {
|
52 |
-
if (options.blockCommentStart || mode.blockCommentStart) {
|
53 |
-
options.fullLines = true;
|
54 |
-
self.blockComment(from, to, options);
|
55 |
-
}
|
56 |
-
return;
|
57 |
-
}
|
58 |
-
var firstLine = self.getLine(from.line);
|
59 |
-
if (firstLine == null) return;
|
60 |
-
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
|
61 |
-
var pad = options.padding == null ? " " : options.padding;
|
62 |
-
var blankLines = options.commentBlankLines || from.line == to.line;
|
63 |
-
|
64 |
-
self.operation(function() {
|
65 |
-
if (options.indent) {
|
66 |
-
var baseString = null;
|
67 |
-
for (var i = from.line; i < end; ++i) {
|
68 |
-
var line = self.getLine(i);
|
69 |
-
var whitespace = line.slice(0, firstNonWS(line));
|
70 |
-
if (baseString == null || baseString.length > whitespace.length) {
|
71 |
-
baseString = whitespace;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
for (var i = from.line; i < end; ++i) {
|
75 |
-
var line = self.getLine(i), cut = baseString.length;
|
76 |
-
if (!blankLines && !nonWS.test(line)) continue;
|
77 |
-
if (line.slice(0, cut) != baseString) cut = firstNonWS(line);
|
78 |
-
self.replaceRange(baseString + commentString + pad, Pos(i, 0), Pos(i, cut));
|
79 |
-
}
|
80 |
-
} else {
|
81 |
-
for (var i = from.line; i < end; ++i) {
|
82 |
-
if (blankLines || nonWS.test(self.getLine(i)))
|
83 |
-
self.replaceRange(commentString + pad, Pos(i, 0));
|
84 |
-
}
|
85 |
-
}
|
86 |
-
});
|
87 |
-
});
|
88 |
-
|
89 |
-
CodeMirror.defineExtension("blockComment", function(from, to, options) {
|
90 |
-
if (!options) options = noOptions;
|
91 |
-
var self = this, mode = self.getModeAt(from);
|
92 |
-
var startString = options.blockCommentStart || mode.blockCommentStart;
|
93 |
-
var endString = options.blockCommentEnd || mode.blockCommentEnd;
|
94 |
-
if (!startString || !endString) {
|
95 |
-
if ((options.lineComment || mode.lineComment) && options.fullLines != false)
|
96 |
-
self.lineComment(from, to, options);
|
97 |
-
return;
|
98 |
-
}
|
99 |
-
|
100 |
-
var end = Math.min(to.line, self.lastLine());
|
101 |
-
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
|
102 |
-
|
103 |
-
var pad = options.padding == null ? " " : options.padding;
|
104 |
-
if (from.line > end) return;
|
105 |
-
|
106 |
-
self.operation(function() {
|
107 |
-
if (options.fullLines != false) {
|
108 |
-
var lastLineHasText = nonWS.test(self.getLine(end));
|
109 |
-
self.replaceRange(pad + endString, Pos(end));
|
110 |
-
self.replaceRange(startString + pad, Pos(from.line, 0));
|
111 |
-
var lead = options.blockCommentLead || mode.blockCommentLead;
|
112 |
-
if (lead != null) for (var i = from.line + 1; i <= end; ++i)
|
113 |
-
if (i != end || lastLineHasText)
|
114 |
-
self.replaceRange(lead + pad, Pos(i, 0));
|
115 |
-
} else {
|
116 |
-
self.replaceRange(endString, to);
|
117 |
-
self.replaceRange(startString, from);
|
118 |
-
}
|
119 |
-
});
|
120 |
-
});
|
121 |
-
|
122 |
-
CodeMirror.defineExtension("uncomment", function(from, to, options) {
|
123 |
-
if (!options) options = noOptions;
|
124 |
-
var self = this, mode = self.getModeAt(from);
|
125 |
-
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end);
|
126 |
-
|
127 |
-
// Try finding line comments
|
128 |
-
var lineString = options.lineComment || mode.lineComment, lines = [];
|
129 |
-
var pad = options.padding == null ? " " : options.padding, didSomething;
|
130 |
-
lineComment: {
|
131 |
-
if (!lineString) break lineComment;
|
132 |
-
for (var i = start; i <= end; ++i) {
|
133 |
-
var line = self.getLine(i);
|
134 |
-
var found = line.indexOf(lineString);
|
135 |
-
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
|
136 |
-
if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
|
137 |
-
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
|
138 |
-
lines.push(line);
|
139 |
-
}
|
140 |
-
self.operation(function() {
|
141 |
-
for (var i = start; i <= end; ++i) {
|
142 |
-
var line = lines[i - start];
|
143 |
-
var pos = line.indexOf(lineString), endPos = pos + lineString.length;
|
144 |
-
if (pos < 0) continue;
|
145 |
-
if (line.slice(endPos, endPos + pad.length) == pad) endPos += pad.length;
|
146 |
-
didSomething = true;
|
147 |
-
self.replaceRange("", Pos(i, pos), Pos(i, endPos));
|
148 |
-
}
|
149 |
-
});
|
150 |
-
if (didSomething) return true;
|
151 |
-
}
|
152 |
-
|
153 |
-
// Try block comments
|
154 |
-
var startString = options.blockCommentStart || mode.blockCommentStart;
|
155 |
-
var endString = options.blockCommentEnd || mode.blockCommentEnd;
|
156 |
-
if (!startString || !endString) return false;
|
157 |
-
var lead = options.blockCommentLead || mode.blockCommentLead;
|
158 |
-
var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
|
159 |
-
var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
|
160 |
-
if (close == -1 && start != end) {
|
161 |
-
endLine = self.getLine(--end);
|
162 |
-
close = endLine.lastIndexOf(endString);
|
163 |
-
}
|
164 |
-
if (open == -1 || close == -1 ||
|
165 |
-
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
|
166 |
-
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
|
167 |
-
return false;
|
168 |
-
|
169 |
-
// Avoid killing block comments completely outside the selection.
|
170 |
-
// Positions of the last startString before the start of the selection, and the first endString after it.
|
171 |
-
var lastStart = startLine.lastIndexOf(startString, from.ch);
|
172 |
-
var firstEnd = lastStart == -1 ? -1 : startLine.slice(0, from.ch).indexOf(endString, lastStart + startString.length);
|
173 |
-
if (lastStart != -1 && firstEnd != -1 && firstEnd + endString.length != from.ch) return false;
|
174 |
-
// Positions of the first endString after the end of the selection, and the last startString before it.
|
175 |
-
firstEnd = endLine.indexOf(endString, to.ch);
|
176 |
-
var almostLastStart = endLine.slice(to.ch).lastIndexOf(startString, firstEnd - to.ch);
|
177 |
-
lastStart = (firstEnd == -1 || almostLastStart == -1) ? -1 : to.ch + almostLastStart;
|
178 |
-
if (firstEnd != -1 && lastStart != -1 && lastStart != to.ch) return false;
|
179 |
-
|
180 |
-
self.operation(function() {
|
181 |
-
self.replaceRange("", Pos(end, close - (pad && endLine.slice(close - pad.length, close) == pad ? pad.length : 0)),
|
182 |
-
Pos(end, close + endString.length));
|
183 |
-
var openEnd = open + startString.length;
|
184 |
-
if (pad && startLine.slice(openEnd, openEnd + pad.length) == pad) openEnd += pad.length;
|
185 |
-
self.replaceRange("", Pos(start, open), Pos(start, openEnd));
|
186 |
-
if (lead) for (var i = start + 1; i <= end; ++i) {
|
187 |
-
var line = self.getLine(i), found = line.indexOf(lead);
|
188 |
-
if (found == -1 || nonWS.test(line.slice(0, found))) continue;
|
189 |
-
var foundEnd = found + lead.length;
|
190 |
-
if (pad && line.slice(foundEnd, foundEnd + pad.length) == pad) foundEnd += pad.length;
|
191 |
-
self.replaceRange("", Pos(i, found), Pos(i, foundEnd));
|
192 |
-
}
|
193 |
-
});
|
194 |
-
return true;
|
195 |
-
});
|
196 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/comment/continuecomment.js
DELETED
@@ -1,85 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
var modes = ["clike", "css", "javascript"];
|
13 |
-
|
14 |
-
for (var i = 0; i < modes.length; ++i)
|
15 |
-
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});
|
16 |
-
|
17 |
-
function continueComment(cm) {
|
18 |
-
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
19 |
-
var ranges = cm.listSelections(), mode, inserts = [];
|
20 |
-
for (var i = 0; i < ranges.length; i++) {
|
21 |
-
var pos = ranges[i].head, token = cm.getTokenAt(pos);
|
22 |
-
if (token.type != "comment") return CodeMirror.Pass;
|
23 |
-
var modeHere = CodeMirror.innerMode(cm.getMode(), token.state).mode;
|
24 |
-
if (!mode) mode = modeHere;
|
25 |
-
else if (mode != modeHere) return CodeMirror.Pass;
|
26 |
-
|
27 |
-
var insert = null;
|
28 |
-
if (mode.blockCommentStart && mode.blockCommentContinue) {
|
29 |
-
var end = token.string.indexOf(mode.blockCommentEnd);
|
30 |
-
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
|
31 |
-
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) {
|
32 |
-
// Comment ended, don't continue it
|
33 |
-
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
|
34 |
-
insert = full.slice(0, token.start);
|
35 |
-
if (!/^\s*$/.test(insert)) {
|
36 |
-
insert = "";
|
37 |
-
for (var j = 0; j < token.start; ++j) insert += " ";
|
38 |
-
}
|
39 |
-
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
|
40 |
-
found + mode.blockCommentContinue.length > token.start &&
|
41 |
-
/^\s*$/.test(full.slice(0, found))) {
|
42 |
-
insert = full.slice(0, found);
|
43 |
-
}
|
44 |
-
if (insert != null) insert += mode.blockCommentContinue;
|
45 |
-
}
|
46 |
-
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) {
|
47 |
-
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
|
48 |
-
if (found > -1) {
|
49 |
-
insert = line.slice(0, found);
|
50 |
-
if (/\S/.test(insert)) insert = null;
|
51 |
-
else insert += mode.lineComment + line.slice(found + mode.lineComment.length).match(/^\s*/)[0];
|
52 |
-
}
|
53 |
-
}
|
54 |
-
if (insert == null) return CodeMirror.Pass;
|
55 |
-
inserts[i] = "\n" + insert;
|
56 |
-
}
|
57 |
-
|
58 |
-
cm.operation(function() {
|
59 |
-
for (var i = ranges.length - 1; i >= 0; i--)
|
60 |
-
cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+insert");
|
61 |
-
});
|
62 |
-
}
|
63 |
-
|
64 |
-
function continueLineCommentEnabled(cm) {
|
65 |
-
var opt = cm.getOption("continueComments");
|
66 |
-
if (opt && typeof opt == "object")
|
67 |
-
return opt.continueLineComment !== false;
|
68 |
-
return true;
|
69 |
-
}
|
70 |
-
|
71 |
-
CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
|
72 |
-
if (prev && prev != CodeMirror.Init)
|
73 |
-
cm.removeKeyMap("continueComment");
|
74 |
-
if (val) {
|
75 |
-
var key = "Enter";
|
76 |
-
if (typeof val == "string")
|
77 |
-
key = val;
|
78 |
-
else if (typeof val == "object" && val.key)
|
79 |
-
key = val.key;
|
80 |
-
var map = {name: "continueComment"};
|
81 |
-
map[key] = continueComment;
|
82 |
-
cm.addKeyMap(map);
|
83 |
-
}
|
84 |
-
});
|
85 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/dialog/dialog.css
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
.CodeMirror-dialog {
|
2 |
-
position: absolute;
|
3 |
-
left: 0; right: 0;
|
4 |
-
background: inherit;
|
5 |
-
z-index: 15;
|
6 |
-
padding: .1em .8em;
|
7 |
-
overflow: hidden;
|
8 |
-
color: inherit;
|
9 |
-
}
|
10 |
-
|
11 |
-
.CodeMirror-dialog-top {
|
12 |
-
border-bottom: 1px solid #eee;
|
13 |
-
top: 0;
|
14 |
-
}
|
15 |
-
|
16 |
-
.CodeMirror-dialog-bottom {
|
17 |
-
border-top: 1px solid #eee;
|
18 |
-
bottom: 0;
|
19 |
-
}
|
20 |
-
|
21 |
-
.CodeMirror-dialog input {
|
22 |
-
border: none;
|
23 |
-
outline: none;
|
24 |
-
background: transparent;
|
25 |
-
width: 20em;
|
26 |
-
color: inherit;
|
27 |
-
font-family: monospace;
|
28 |
-
}
|
29 |
-
|
30 |
-
.CodeMirror-dialog button {
|
31 |
-
font-size: 70%;
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/dialog/dialog.js
DELETED
@@ -1,157 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Open simple dialogs on top of an editor. Relies on dialog.css.
|
5 |
-
|
6 |
-
(function(mod) {
|
7 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
8 |
-
mod(require("../../lib/codemirror"));
|
9 |
-
else if (typeof define == "function" && define.amd) // AMD
|
10 |
-
define(["../../lib/codemirror"], mod);
|
11 |
-
else // Plain browser env
|
12 |
-
mod(CodeMirror);
|
13 |
-
})(function(CodeMirror) {
|
14 |
-
function dialogDiv(cm, template, bottom) {
|
15 |
-
var wrap = cm.getWrapperElement();
|
16 |
-
var dialog;
|
17 |
-
dialog = wrap.appendChild(document.createElement("div"));
|
18 |
-
if (bottom)
|
19 |
-
dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom";
|
20 |
-
else
|
21 |
-
dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
|
22 |
-
|
23 |
-
if (typeof template == "string") {
|
24 |
-
dialog.innerHTML = template;
|
25 |
-
} else { // Assuming it's a detached DOM element.
|
26 |
-
dialog.appendChild(template);
|
27 |
-
}
|
28 |
-
return dialog;
|
29 |
-
}
|
30 |
-
|
31 |
-
function closeNotification(cm, newVal) {
|
32 |
-
if (cm.state.currentNotificationClose)
|
33 |
-
cm.state.currentNotificationClose();
|
34 |
-
cm.state.currentNotificationClose = newVal;
|
35 |
-
}
|
36 |
-
|
37 |
-
CodeMirror.defineExtension("openDialog", function(template, callback, options) {
|
38 |
-
if (!options) options = {};
|
39 |
-
|
40 |
-
closeNotification(this, null);
|
41 |
-
|
42 |
-
var dialog = dialogDiv(this, template, options.bottom);
|
43 |
-
var closed = false, me = this;
|
44 |
-
function close(newVal) {
|
45 |
-
if (typeof newVal == 'string') {
|
46 |
-
inp.value = newVal;
|
47 |
-
} else {
|
48 |
-
if (closed) return;
|
49 |
-
closed = true;
|
50 |
-
dialog.parentNode.removeChild(dialog);
|
51 |
-
me.focus();
|
52 |
-
|
53 |
-
if (options.onClose) options.onClose(dialog);
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
var inp = dialog.getElementsByTagName("input")[0], button;
|
58 |
-
if (inp) {
|
59 |
-
if (options.value) {
|
60 |
-
inp.value = options.value;
|
61 |
-
if (options.selectValueOnOpen !== false) {
|
62 |
-
inp.select();
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
if (options.onInput)
|
67 |
-
CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);});
|
68 |
-
if (options.onKeyUp)
|
69 |
-
CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);});
|
70 |
-
|
71 |
-
CodeMirror.on(inp, "keydown", function(e) {
|
72 |
-
if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; }
|
73 |
-
if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) {
|
74 |
-
inp.blur();
|
75 |
-
CodeMirror.e_stop(e);
|
76 |
-
close();
|
77 |
-
}
|
78 |
-
if (e.keyCode == 13) callback(inp.value, e);
|
79 |
-
});
|
80 |
-
|
81 |
-
if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
|
82 |
-
|
83 |
-
inp.focus();
|
84 |
-
} else if (button = dialog.getElementsByTagName("button")[0]) {
|
85 |
-
CodeMirror.on(button, "click", function() {
|
86 |
-
close();
|
87 |
-
me.focus();
|
88 |
-
});
|
89 |
-
|
90 |
-
if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close);
|
91 |
-
|
92 |
-
button.focus();
|
93 |
-
}
|
94 |
-
return close;
|
95 |
-
});
|
96 |
-
|
97 |
-
CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) {
|
98 |
-
closeNotification(this, null);
|
99 |
-
var dialog = dialogDiv(this, template, options && options.bottom);
|
100 |
-
var buttons = dialog.getElementsByTagName("button");
|
101 |
-
var closed = false, me = this, blurring = 1;
|
102 |
-
function close() {
|
103 |
-
if (closed) return;
|
104 |
-
closed = true;
|
105 |
-
dialog.parentNode.removeChild(dialog);
|
106 |
-
me.focus();
|
107 |
-
}
|
108 |
-
buttons[0].focus();
|
109 |
-
for (var i = 0; i < buttons.length; ++i) {
|
110 |
-
var b = buttons[i];
|
111 |
-
(function(callback) {
|
112 |
-
CodeMirror.on(b, "click", function(e) {
|
113 |
-
CodeMirror.e_preventDefault(e);
|
114 |
-
close();
|
115 |
-
if (callback) callback(me);
|
116 |
-
});
|
117 |
-
})(callbacks[i]);
|
118 |
-
CodeMirror.on(b, "blur", function() {
|
119 |
-
--blurring;
|
120 |
-
setTimeout(function() { if (blurring <= 0) close(); }, 200);
|
121 |
-
});
|
122 |
-
CodeMirror.on(b, "focus", function() { ++blurring; });
|
123 |
-
}
|
124 |
-
});
|
125 |
-
|
126 |
-
/*
|
127 |
-
* openNotification
|
128 |
-
* Opens a notification, that can be closed with an optional timer
|
129 |
-
* (default 5000ms timer) and always closes on click.
|
130 |
-
*
|
131 |
-
* If a notification is opened while another is opened, it will close the
|
132 |
-
* currently opened one and open the new one immediately.
|
133 |
-
*/
|
134 |
-
CodeMirror.defineExtension("openNotification", function(template, options) {
|
135 |
-
closeNotification(this, close);
|
136 |
-
var dialog = dialogDiv(this, template, options && options.bottom);
|
137 |
-
var closed = false, doneTimer;
|
138 |
-
var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000;
|
139 |
-
|
140 |
-
function close() {
|
141 |
-
if (closed) return;
|
142 |
-
closed = true;
|
143 |
-
clearTimeout(doneTimer);
|
144 |
-
dialog.parentNode.removeChild(dialog);
|
145 |
-
}
|
146 |
-
|
147 |
-
CodeMirror.on(dialog, 'click', function(e) {
|
148 |
-
CodeMirror.e_preventDefault(e);
|
149 |
-
close();
|
150 |
-
});
|
151 |
-
|
152 |
-
if (duration)
|
153 |
-
doneTimer = setTimeout(close, duration);
|
154 |
-
|
155 |
-
return close;
|
156 |
-
});
|
157 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/display/autorefresh.js
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"))
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod)
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror)
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict"
|
13 |
-
|
14 |
-
CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
|
15 |
-
if (cm.state.autoRefresh) {
|
16 |
-
stopListening(cm, cm.state.autoRefresh)
|
17 |
-
cm.state.autoRefresh = null
|
18 |
-
}
|
19 |
-
if (val && cm.display.wrapper.offsetHeight == 0)
|
20 |
-
startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
|
21 |
-
})
|
22 |
-
|
23 |
-
function startListening(cm, state) {
|
24 |
-
function check() {
|
25 |
-
if (cm.display.wrapper.offsetHeight) {
|
26 |
-
stopListening(cm, state)
|
27 |
-
if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
|
28 |
-
cm.refresh()
|
29 |
-
} else {
|
30 |
-
state.timeout = setTimeout(check, state.delay)
|
31 |
-
}
|
32 |
-
}
|
33 |
-
state.timeout = setTimeout(check, state.delay)
|
34 |
-
state.hurry = function() {
|
35 |
-
clearTimeout(state.timeout)
|
36 |
-
state.timeout = setTimeout(check, 50)
|
37 |
-
}
|
38 |
-
CodeMirror.on(window, "mouseup", state.hurry)
|
39 |
-
CodeMirror.on(window, "keyup", state.hurry)
|
40 |
-
}
|
41 |
-
|
42 |
-
function stopListening(_cm, state) {
|
43 |
-
clearTimeout(state.timeout)
|
44 |
-
CodeMirror.off(window, "mouseup", state.hurry)
|
45 |
-
CodeMirror.off(window, "keyup", state.hurry)
|
46 |
-
}
|
47 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/display/fullscreen.css
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
.CodeMirror-fullscreen {
|
2 |
-
position: fixed;
|
3 |
-
top: 0; left: 0; right: 0; bottom: 0;
|
4 |
-
height: auto;
|
5 |
-
z-index: 9;
|
6 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/display/fullscreen.js
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
|
15 |
-
if (old == CodeMirror.Init) old = false;
|
16 |
-
if (!old == !val) return;
|
17 |
-
if (val) setFullscreen(cm);
|
18 |
-
else setNormal(cm);
|
19 |
-
});
|
20 |
-
|
21 |
-
function setFullscreen(cm) {
|
22 |
-
var wrap = cm.getWrapperElement();
|
23 |
-
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
|
24 |
-
width: wrap.style.width, height: wrap.style.height};
|
25 |
-
wrap.style.width = "";
|
26 |
-
wrap.style.height = "auto";
|
27 |
-
wrap.className += " CodeMirror-fullscreen";
|
28 |
-
document.documentElement.style.overflow = "hidden";
|
29 |
-
cm.refresh();
|
30 |
-
}
|
31 |
-
|
32 |
-
function setNormal(cm) {
|
33 |
-
var wrap = cm.getWrapperElement();
|
34 |
-
wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
|
35 |
-
document.documentElement.style.overflow = "";
|
36 |
-
var info = cm.state.fullScreenRestore;
|
37 |
-
wrap.style.width = info.width; wrap.style.height = info.height;
|
38 |
-
window.scrollTo(info.scrollLeft, info.scrollTop);
|
39 |
-
cm.refresh();
|
40 |
-
}
|
41 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/display/panel.js
DELETED
@@ -1,112 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
CodeMirror.defineExtension("addPanel", function(node, options) {
|
13 |
-
options = options || {};
|
14 |
-
|
15 |
-
if (!this.state.panels) initPanels(this);
|
16 |
-
|
17 |
-
var info = this.state.panels;
|
18 |
-
var wrapper = info.wrapper;
|
19 |
-
var cmWrapper = this.getWrapperElement();
|
20 |
-
|
21 |
-
if (options.after instanceof Panel && !options.after.cleared) {
|
22 |
-
wrapper.insertBefore(node, options.before.node.nextSibling);
|
23 |
-
} else if (options.before instanceof Panel && !options.before.cleared) {
|
24 |
-
wrapper.insertBefore(node, options.before.node);
|
25 |
-
} else if (options.replace instanceof Panel && !options.replace.cleared) {
|
26 |
-
wrapper.insertBefore(node, options.replace.node);
|
27 |
-
options.replace.clear();
|
28 |
-
} else if (options.position == "bottom") {
|
29 |
-
wrapper.appendChild(node);
|
30 |
-
} else if (options.position == "before-bottom") {
|
31 |
-
wrapper.insertBefore(node, cmWrapper.nextSibling);
|
32 |
-
} else if (options.position == "after-top") {
|
33 |
-
wrapper.insertBefore(node, cmWrapper);
|
34 |
-
} else {
|
35 |
-
wrapper.insertBefore(node, wrapper.firstChild);
|
36 |
-
}
|
37 |
-
|
38 |
-
var height = (options && options.height) || node.offsetHeight;
|
39 |
-
this._setSize(null, info.heightLeft -= height);
|
40 |
-
info.panels++;
|
41 |
-
return new Panel(this, node, options, height);
|
42 |
-
});
|
43 |
-
|
44 |
-
function Panel(cm, node, options, height) {
|
45 |
-
this.cm = cm;
|
46 |
-
this.node = node;
|
47 |
-
this.options = options;
|
48 |
-
this.height = height;
|
49 |
-
this.cleared = false;
|
50 |
-
}
|
51 |
-
|
52 |
-
Panel.prototype.clear = function() {
|
53 |
-
if (this.cleared) return;
|
54 |
-
this.cleared = true;
|
55 |
-
var info = this.cm.state.panels;
|
56 |
-
this.cm._setSize(null, info.heightLeft += this.height);
|
57 |
-
info.wrapper.removeChild(this.node);
|
58 |
-
if (--info.panels == 0) removePanels(this.cm);
|
59 |
-
};
|
60 |
-
|
61 |
-
Panel.prototype.changed = function(height) {
|
62 |
-
var newHeight = height == null ? this.node.offsetHeight : height;
|
63 |
-
var info = this.cm.state.panels;
|
64 |
-
this.cm._setSize(null, info.height += (newHeight - this.height));
|
65 |
-
this.height = newHeight;
|
66 |
-
};
|
67 |
-
|
68 |
-
function initPanels(cm) {
|
69 |
-
var wrap = cm.getWrapperElement();
|
70 |
-
var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle;
|
71 |
-
var height = parseInt(style.height);
|
72 |
-
var info = cm.state.panels = {
|
73 |
-
setHeight: wrap.style.height,
|
74 |
-
heightLeft: height,
|
75 |
-
panels: 0,
|
76 |
-
wrapper: document.createElement("div")
|
77 |
-
};
|
78 |
-
wrap.parentNode.insertBefore(info.wrapper, wrap);
|
79 |
-
var hasFocus = cm.hasFocus();
|
80 |
-
info.wrapper.appendChild(wrap);
|
81 |
-
if (hasFocus) cm.focus();
|
82 |
-
|
83 |
-
cm._setSize = cm.setSize;
|
84 |
-
if (height != null) cm.setSize = function(width, newHeight) {
|
85 |
-
if (newHeight == null) return this._setSize(width, newHeight);
|
86 |
-
info.setHeight = newHeight;
|
87 |
-
if (typeof newHeight != "number") {
|
88 |
-
var px = /^(\d+\.?\d*)px$/.exec(newHeight);
|
89 |
-
if (px) {
|
90 |
-
newHeight = Number(px[1]);
|
91 |
-
} else {
|
92 |
-
info.wrapper.style.height = newHeight;
|
93 |
-
newHeight = info.wrapper.offsetHeight;
|
94 |
-
info.wrapper.style.height = "";
|
95 |
-
}
|
96 |
-
}
|
97 |
-
cm._setSize(width, info.heightLeft += (newHeight - height));
|
98 |
-
height = newHeight;
|
99 |
-
};
|
100 |
-
}
|
101 |
-
|
102 |
-
function removePanels(cm) {
|
103 |
-
var info = cm.state.panels;
|
104 |
-
cm.state.panels = null;
|
105 |
-
|
106 |
-
var wrap = cm.getWrapperElement();
|
107 |
-
info.wrapper.parentNode.replaceChild(wrap, info.wrapper);
|
108 |
-
wrap.style.height = info.setHeight;
|
109 |
-
cm.setSize = cm._setSize;
|
110 |
-
cm.setSize();
|
111 |
-
}
|
112 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/display/placeholder.js
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
|
13 |
-
var prev = old && old != CodeMirror.Init;
|
14 |
-
if (val && !prev) {
|
15 |
-
cm.on("blur", onBlur);
|
16 |
-
cm.on("change", onChange);
|
17 |
-
onChange(cm);
|
18 |
-
} else if (!val && prev) {
|
19 |
-
cm.off("blur", onBlur);
|
20 |
-
cm.off("change", onChange);
|
21 |
-
clearPlaceholder(cm);
|
22 |
-
var wrapper = cm.getWrapperElement();
|
23 |
-
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
|
24 |
-
}
|
25 |
-
|
26 |
-
if (val && !cm.hasFocus()) onBlur(cm);
|
27 |
-
});
|
28 |
-
|
29 |
-
function clearPlaceholder(cm) {
|
30 |
-
if (cm.state.placeholder) {
|
31 |
-
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
|
32 |
-
cm.state.placeholder = null;
|
33 |
-
}
|
34 |
-
}
|
35 |
-
function setPlaceholder(cm) {
|
36 |
-
clearPlaceholder(cm);
|
37 |
-
var elt = cm.state.placeholder = document.createElement("pre");
|
38 |
-
elt.style.cssText = "height: 0; overflow: visible";
|
39 |
-
elt.className = "CodeMirror-placeholder";
|
40 |
-
var placeHolder = cm.getOption("placeholder")
|
41 |
-
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
|
42 |
-
elt.appendChild(placeHolder)
|
43 |
-
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
|
44 |
-
}
|
45 |
-
|
46 |
-
function onBlur(cm) {
|
47 |
-
if (isEmpty(cm)) setPlaceholder(cm);
|
48 |
-
}
|
49 |
-
function onChange(cm) {
|
50 |
-
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
|
51 |
-
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
|
52 |
-
|
53 |
-
if (empty) setPlaceholder(cm);
|
54 |
-
else clearPlaceholder(cm);
|
55 |
-
}
|
56 |
-
|
57 |
-
function isEmpty(cm) {
|
58 |
-
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
|
59 |
-
}
|
60 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/display/rulers.js
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineOption("rulers", false, function(cm, val, old) {
|
15 |
-
if (old && old != CodeMirror.Init) {
|
16 |
-
clearRulers(cm);
|
17 |
-
cm.off("refresh", refreshRulers);
|
18 |
-
}
|
19 |
-
if (val && val.length) {
|
20 |
-
setRulers(cm);
|
21 |
-
cm.on("refresh", refreshRulers);
|
22 |
-
}
|
23 |
-
});
|
24 |
-
|
25 |
-
function clearRulers(cm) {
|
26 |
-
for (var i = cm.display.lineSpace.childNodes.length - 1; i >= 0; i--) {
|
27 |
-
var node = cm.display.lineSpace.childNodes[i];
|
28 |
-
if (/(^|\s)CodeMirror-ruler($|\s)/.test(node.className))
|
29 |
-
node.parentNode.removeChild(node);
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
function setRulers(cm) {
|
34 |
-
var val = cm.getOption("rulers");
|
35 |
-
var cw = cm.defaultCharWidth();
|
36 |
-
var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
|
37 |
-
var minH = cm.display.scroller.offsetHeight + 30;
|
38 |
-
for (var i = 0; i < val.length; i++) {
|
39 |
-
var elt = document.createElement("div");
|
40 |
-
elt.className = "CodeMirror-ruler";
|
41 |
-
var col, conf = val[i];
|
42 |
-
if (typeof conf == "number") {
|
43 |
-
col = conf;
|
44 |
-
} else {
|
45 |
-
col = conf.column;
|
46 |
-
if (conf.className) elt.className += " " + conf.className;
|
47 |
-
if (conf.color) elt.style.borderColor = conf.color;
|
48 |
-
if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle;
|
49 |
-
if (conf.width) elt.style.borderLeftWidth = conf.width;
|
50 |
-
}
|
51 |
-
elt.style.left = (left + col * cw) + "px";
|
52 |
-
elt.style.top = "-50px";
|
53 |
-
elt.style.bottom = "-20px";
|
54 |
-
elt.style.minHeight = minH + "px";
|
55 |
-
cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv);
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
function refreshRulers(cm) {
|
60 |
-
clearRulers(cm);
|
61 |
-
setRulers(cm);
|
62 |
-
}
|
63 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/closebrackets.js
DELETED
@@ -1,195 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
var defaults = {
|
13 |
-
pairs: "()[]{}''\"\"",
|
14 |
-
triples: "",
|
15 |
-
explode: "[]{}"
|
16 |
-
};
|
17 |
-
|
18 |
-
var Pos = CodeMirror.Pos;
|
19 |
-
|
20 |
-
CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
|
21 |
-
if (old && old != CodeMirror.Init) {
|
22 |
-
cm.removeKeyMap(keyMap);
|
23 |
-
cm.state.closeBrackets = null;
|
24 |
-
}
|
25 |
-
if (val) {
|
26 |
-
cm.state.closeBrackets = val;
|
27 |
-
cm.addKeyMap(keyMap);
|
28 |
-
}
|
29 |
-
});
|
30 |
-
|
31 |
-
function getOption(conf, name) {
|
32 |
-
if (name == "pairs" && typeof conf == "string") return conf;
|
33 |
-
if (typeof conf == "object" && conf[name] != null) return conf[name];
|
34 |
-
return defaults[name];
|
35 |
-
}
|
36 |
-
|
37 |
-
var bind = defaults.pairs + "`";
|
38 |
-
var keyMap = {Backspace: handleBackspace, Enter: handleEnter};
|
39 |
-
for (var i = 0; i < bind.length; i++)
|
40 |
-
keyMap["'" + bind.charAt(i) + "'"] = handler(bind.charAt(i));
|
41 |
-
|
42 |
-
function handler(ch) {
|
43 |
-
return function(cm) { return handleChar(cm, ch); };
|
44 |
-
}
|
45 |
-
|
46 |
-
function getConfig(cm) {
|
47 |
-
var deflt = cm.state.closeBrackets;
|
48 |
-
if (!deflt) return null;
|
49 |
-
var mode = cm.getModeAt(cm.getCursor());
|
50 |
-
return mode.closeBrackets || deflt;
|
51 |
-
}
|
52 |
-
|
53 |
-
function handleBackspace(cm) {
|
54 |
-
var conf = getConfig(cm);
|
55 |
-
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
|
56 |
-
|
57 |
-
var pairs = getOption(conf, "pairs");
|
58 |
-
var ranges = cm.listSelections();
|
59 |
-
for (var i = 0; i < ranges.length; i++) {
|
60 |
-
if (!ranges[i].empty()) return CodeMirror.Pass;
|
61 |
-
var around = charsAround(cm, ranges[i].head);
|
62 |
-
if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
63 |
-
}
|
64 |
-
for (var i = ranges.length - 1; i >= 0; i--) {
|
65 |
-
var cur = ranges[i].head;
|
66 |
-
cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
function handleEnter(cm) {
|
71 |
-
var conf = getConfig(cm);
|
72 |
-
var explode = conf && getOption(conf, "explode");
|
73 |
-
if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass;
|
74 |
-
|
75 |
-
var ranges = cm.listSelections();
|
76 |
-
for (var i = 0; i < ranges.length; i++) {
|
77 |
-
if (!ranges[i].empty()) return CodeMirror.Pass;
|
78 |
-
var around = charsAround(cm, ranges[i].head);
|
79 |
-
if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
80 |
-
}
|
81 |
-
cm.operation(function() {
|
82 |
-
cm.replaceSelection("\n\n", null);
|
83 |
-
cm.execCommand("goCharLeft");
|
84 |
-
ranges = cm.listSelections();
|
85 |
-
for (var i = 0; i < ranges.length; i++) {
|
86 |
-
var line = ranges[i].head.line;
|
87 |
-
cm.indentLine(line, null, true);
|
88 |
-
cm.indentLine(line + 1, null, true);
|
89 |
-
}
|
90 |
-
});
|
91 |
-
}
|
92 |
-
|
93 |
-
function contractSelection(sel) {
|
94 |
-
var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
|
95 |
-
return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
|
96 |
-
head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))};
|
97 |
-
}
|
98 |
-
|
99 |
-
function handleChar(cm, ch) {
|
100 |
-
var conf = getConfig(cm);
|
101 |
-
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
|
102 |
-
|
103 |
-
var pairs = getOption(conf, "pairs");
|
104 |
-
var pos = pairs.indexOf(ch);
|
105 |
-
if (pos == -1) return CodeMirror.Pass;
|
106 |
-
var triples = getOption(conf, "triples");
|
107 |
-
|
108 |
-
var identical = pairs.charAt(pos + 1) == ch;
|
109 |
-
var ranges = cm.listSelections();
|
110 |
-
var opening = pos % 2 == 0;
|
111 |
-
|
112 |
-
var type, next;
|
113 |
-
for (var i = 0; i < ranges.length; i++) {
|
114 |
-
var range = ranges[i], cur = range.head, curType;
|
115 |
-
var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
|
116 |
-
if (opening && !range.empty()) {
|
117 |
-
curType = "surround";
|
118 |
-
} else if ((identical || !opening) && next == ch) {
|
119 |
-
if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch)
|
120 |
-
curType = "skipThree";
|
121 |
-
else
|
122 |
-
curType = "skip";
|
123 |
-
} else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 &&
|
124 |
-
cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch &&
|
125 |
-
(cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != ch)) {
|
126 |
-
curType = "addFour";
|
127 |
-
} else if (identical) {
|
128 |
-
if (!CodeMirror.isWordChar(next) && enteringString(cm, cur, ch)) curType = "both";
|
129 |
-
else return CodeMirror.Pass;
|
130 |
-
} else if (opening && (cm.getLine(cur.line).length == cur.ch ||
|
131 |
-
isClosingBracket(next, pairs) ||
|
132 |
-
/\s/.test(next))) {
|
133 |
-
curType = "both";
|
134 |
-
} else {
|
135 |
-
return CodeMirror.Pass;
|
136 |
-
}
|
137 |
-
if (!type) type = curType;
|
138 |
-
else if (type != curType) return CodeMirror.Pass;
|
139 |
-
}
|
140 |
-
|
141 |
-
var left = pos % 2 ? pairs.charAt(pos - 1) : ch;
|
142 |
-
var right = pos % 2 ? ch : pairs.charAt(pos + 1);
|
143 |
-
cm.operation(function() {
|
144 |
-
if (type == "skip") {
|
145 |
-
cm.execCommand("goCharRight");
|
146 |
-
} else if (type == "skipThree") {
|
147 |
-
for (var i = 0; i < 3; i++)
|
148 |
-
cm.execCommand("goCharRight");
|
149 |
-
} else if (type == "surround") {
|
150 |
-
var sels = cm.getSelections();
|
151 |
-
for (var i = 0; i < sels.length; i++)
|
152 |
-
sels[i] = left + sels[i] + right;
|
153 |
-
cm.replaceSelections(sels, "around");
|
154 |
-
sels = cm.listSelections().slice();
|
155 |
-
for (var i = 0; i < sels.length; i++)
|
156 |
-
sels[i] = contractSelection(sels[i]);
|
157 |
-
cm.setSelections(sels);
|
158 |
-
} else if (type == "both") {
|
159 |
-
cm.replaceSelection(left + right, null);
|
160 |
-
cm.triggerElectric(left + right);
|
161 |
-
cm.execCommand("goCharLeft");
|
162 |
-
} else if (type == "addFour") {
|
163 |
-
cm.replaceSelection(left + left + left + left, "before");
|
164 |
-
cm.execCommand("goCharRight");
|
165 |
-
}
|
166 |
-
});
|
167 |
-
}
|
168 |
-
|
169 |
-
function isClosingBracket(ch, pairs) {
|
170 |
-
var pos = pairs.lastIndexOf(ch);
|
171 |
-
return pos > -1 && pos % 2 == 1;
|
172 |
-
}
|
173 |
-
|
174 |
-
function charsAround(cm, pos) {
|
175 |
-
var str = cm.getRange(Pos(pos.line, pos.ch - 1),
|
176 |
-
Pos(pos.line, pos.ch + 1));
|
177 |
-
return str.length == 2 ? str : null;
|
178 |
-
}
|
179 |
-
|
180 |
-
// Project the token type that will exists after the given char is
|
181 |
-
// typed, and use it to determine whether it would cause the start
|
182 |
-
// of a string token.
|
183 |
-
function enteringString(cm, pos, ch) {
|
184 |
-
var line = cm.getLine(pos.line);
|
185 |
-
var token = cm.getTokenAt(pos);
|
186 |
-
if (/\bstring2?\b/.test(token.type)) return false;
|
187 |
-
var stream = new CodeMirror.StringStream(line.slice(0, pos.ch) + ch + line.slice(pos.ch), 4);
|
188 |
-
stream.pos = stream.start = token.start;
|
189 |
-
for (;;) {
|
190 |
-
var type1 = cm.getMode().token(stream, token.state);
|
191 |
-
if (stream.pos >= pos.ch + 1) return /\bstring2?\b/.test(type1);
|
192 |
-
stream.start = stream.pos;
|
193 |
-
}
|
194 |
-
}
|
195 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/closetag.js
DELETED
@@ -1,169 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Tag-closer extension for CodeMirror.
|
6 |
-
*
|
7 |
-
* This extension adds an "autoCloseTags" option that can be set to
|
8 |
-
* either true to get the default behavior, or an object to further
|
9 |
-
* configure its behavior.
|
10 |
-
*
|
11 |
-
* These are supported options:
|
12 |
-
*
|
13 |
-
* `whenClosing` (default true)
|
14 |
-
* Whether to autoclose when the '/' of a closing tag is typed.
|
15 |
-
* `whenOpening` (default true)
|
16 |
-
* Whether to autoclose the tag when the final '>' of an opening
|
17 |
-
* tag is typed.
|
18 |
-
* `dontCloseTags` (default is empty tags for HTML, none for XML)
|
19 |
-
* An array of tag names that should not be autoclosed.
|
20 |
-
* `indentTags` (default is block tags for HTML, none for XML)
|
21 |
-
* An array of tag names that should, when opened, cause a
|
22 |
-
* blank line to be added inside the tag, and the blank line and
|
23 |
-
* closing line to be indented.
|
24 |
-
*
|
25 |
-
* See demos/closetag.html for a usage example.
|
26 |
-
*/
|
27 |
-
|
28 |
-
(function(mod) {
|
29 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
30 |
-
mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
|
31 |
-
else if (typeof define == "function" && define.amd) // AMD
|
32 |
-
define(["../../lib/codemirror", "../fold/xml-fold"], mod);
|
33 |
-
else // Plain browser env
|
34 |
-
mod(CodeMirror);
|
35 |
-
})(function(CodeMirror) {
|
36 |
-
CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
|
37 |
-
if (old != CodeMirror.Init && old)
|
38 |
-
cm.removeKeyMap("autoCloseTags");
|
39 |
-
if (!val) return;
|
40 |
-
var map = {name: "autoCloseTags"};
|
41 |
-
if (typeof val != "object" || val.whenClosing)
|
42 |
-
map["'/'"] = function(cm) { return autoCloseSlash(cm); };
|
43 |
-
if (typeof val != "object" || val.whenOpening)
|
44 |
-
map["'>'"] = function(cm) { return autoCloseGT(cm); };
|
45 |
-
cm.addKeyMap(map);
|
46 |
-
});
|
47 |
-
|
48 |
-
var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param",
|
49 |
-
"source", "track", "wbr"];
|
50 |
-
var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
|
51 |
-
"h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];
|
52 |
-
|
53 |
-
function autoCloseGT(cm) {
|
54 |
-
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
55 |
-
var ranges = cm.listSelections(), replacements = [];
|
56 |
-
for (var i = 0; i < ranges.length; i++) {
|
57 |
-
if (!ranges[i].empty()) return CodeMirror.Pass;
|
58 |
-
var pos = ranges[i].head, tok = cm.getTokenAt(pos);
|
59 |
-
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
60 |
-
if (inner.mode.name != "xml" || !state.tagName) return CodeMirror.Pass;
|
61 |
-
|
62 |
-
var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html";
|
63 |
-
var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
|
64 |
-
var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
|
65 |
-
|
66 |
-
var tagName = state.tagName;
|
67 |
-
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
|
68 |
-
var lowerTagName = tagName.toLowerCase();
|
69 |
-
// Don't process the '>' at the end of an end-tag or self-closing tag
|
70 |
-
if (!tagName ||
|
71 |
-
tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) ||
|
72 |
-
tok.type == "tag" && state.type == "closeTag" ||
|
73 |
-
tok.string.indexOf("/") == (tok.string.length - 1) || // match something like <someTagName />
|
74 |
-
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 ||
|
75 |
-
closingTagExists(cm, tagName, pos, state, true))
|
76 |
-
return CodeMirror.Pass;
|
77 |
-
|
78 |
-
var indent = indentTags && indexOf(indentTags, lowerTagName) > -1;
|
79 |
-
replacements[i] = {indent: indent,
|
80 |
-
text: ">" + (indent ? "\n\n" : "") + "</" + tagName + ">",
|
81 |
-
newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)};
|
82 |
-
}
|
83 |
-
|
84 |
-
for (var i = ranges.length - 1; i >= 0; i--) {
|
85 |
-
var info = replacements[i];
|
86 |
-
cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert");
|
87 |
-
var sel = cm.listSelections().slice(0);
|
88 |
-
sel[i] = {head: info.newPos, anchor: info.newPos};
|
89 |
-
cm.setSelections(sel);
|
90 |
-
if (info.indent) {
|
91 |
-
cm.indentLine(info.newPos.line, null, true);
|
92 |
-
cm.indentLine(info.newPos.line + 1, null, true);
|
93 |
-
}
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
function autoCloseCurrent(cm, typingSlash) {
|
98 |
-
var ranges = cm.listSelections(), replacements = [];
|
99 |
-
var head = typingSlash ? "/" : "</";
|
100 |
-
for (var i = 0; i < ranges.length; i++) {
|
101 |
-
if (!ranges[i].empty()) return CodeMirror.Pass;
|
102 |
-
var pos = ranges[i].head, tok = cm.getTokenAt(pos);
|
103 |
-
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
104 |
-
if (typingSlash && (tok.type == "string" || tok.string.charAt(0) != "<" ||
|
105 |
-
tok.start != pos.ch - 1))
|
106 |
-
return CodeMirror.Pass;
|
107 |
-
// Kludge to get around the fact that we are not in XML mode
|
108 |
-
// when completing in JS/CSS snippet in htmlmixed mode. Does not
|
109 |
-
// work for other XML embedded languages (there is no general
|
110 |
-
// way to go from a mixed mode to its current XML state).
|
111 |
-
var replacement;
|
112 |
-
if (inner.mode.name != "xml") {
|
113 |
-
if (cm.getMode().name == "htmlmixed" && inner.mode.name == "javascript")
|
114 |
-
replacement = head + "script";
|
115 |
-
else if (cm.getMode().name == "htmlmixed" && inner.mode.name == "css")
|
116 |
-
replacement = head + "style";
|
117 |
-
else
|
118 |
-
return CodeMirror.Pass;
|
119 |
-
} else {
|
120 |
-
if (!state.context || !state.context.tagName ||
|
121 |
-
closingTagExists(cm, state.context.tagName, pos, state))
|
122 |
-
return CodeMirror.Pass;
|
123 |
-
replacement = head + state.context.tagName;
|
124 |
-
}
|
125 |
-
if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
|
126 |
-
replacements[i] = replacement;
|
127 |
-
}
|
128 |
-
cm.replaceSelections(replacements);
|
129 |
-
ranges = cm.listSelections();
|
130 |
-
for (var i = 0; i < ranges.length; i++)
|
131 |
-
if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line)
|
132 |
-
cm.indentLine(ranges[i].head.line);
|
133 |
-
}
|
134 |
-
|
135 |
-
function autoCloseSlash(cm) {
|
136 |
-
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
137 |
-
return autoCloseCurrent(cm, true);
|
138 |
-
}
|
139 |
-
|
140 |
-
CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); };
|
141 |
-
|
142 |
-
function indexOf(collection, elt) {
|
143 |
-
if (collection.indexOf) return collection.indexOf(elt);
|
144 |
-
for (var i = 0, e = collection.length; i < e; ++i)
|
145 |
-
if (collection[i] == elt) return i;
|
146 |
-
return -1;
|
147 |
-
}
|
148 |
-
|
149 |
-
// If xml-fold is loaded, we use its functionality to try and verify
|
150 |
-
// whether a given tag is actually unclosed.
|
151 |
-
function closingTagExists(cm, tagName, pos, state, newTag) {
|
152 |
-
if (!CodeMirror.scanForClosingTag) return false;
|
153 |
-
var end = Math.min(cm.lastLine() + 1, pos.line + 500);
|
154 |
-
var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end);
|
155 |
-
if (!nextClose || nextClose.tag != tagName) return false;
|
156 |
-
var cx = state.context;
|
157 |
-
// If the immediate wrapping context contains onCx instances of
|
158 |
-
// the same tag, a closing tag only exists if there are at least
|
159 |
-
// that many closing tags of that type following.
|
160 |
-
for (var onCx = newTag ? 1 : 0; cx && cx.tagName == tagName; cx = cx.prev) ++onCx;
|
161 |
-
pos = nextClose.to;
|
162 |
-
for (var i = 1; i < onCx; i++) {
|
163 |
-
var next = CodeMirror.scanForClosingTag(cm, pos, null, end);
|
164 |
-
if (!next || next.tag != tagName) return false;
|
165 |
-
pos = next.to;
|
166 |
-
}
|
167 |
-
return true;
|
168 |
-
}
|
169 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/continuelist.js
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,
|
15 |
-
emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,
|
16 |
-
unorderedListRE = /[*+-]\s/;
|
17 |
-
|
18 |
-
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
19 |
-
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
20 |
-
var ranges = cm.listSelections(), replacements = [];
|
21 |
-
for (var i = 0; i < ranges.length; i++) {
|
22 |
-
var pos = ranges[i].head;
|
23 |
-
var eolState = cm.getStateAfter(pos.line);
|
24 |
-
var inList = eolState.list !== false;
|
25 |
-
var inQuote = eolState.quote !== 0;
|
26 |
-
|
27 |
-
var line = cm.getLine(pos.line), match = listRE.exec(line);
|
28 |
-
if (!ranges[i].empty() || (!inList && !inQuote) || !match) {
|
29 |
-
cm.execCommand("newlineAndIndent");
|
30 |
-
return;
|
31 |
-
}
|
32 |
-
if (emptyListRE.test(line)) {
|
33 |
-
cm.replaceRange("", {
|
34 |
-
line: pos.line, ch: 0
|
35 |
-
}, {
|
36 |
-
line: pos.line, ch: pos.ch + 1
|
37 |
-
});
|
38 |
-
replacements[i] = "\n";
|
39 |
-
} else {
|
40 |
-
var indent = match[1], after = match[5];
|
41 |
-
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
|
42 |
-
? match[2]
|
43 |
-
: (parseInt(match[3], 10) + 1) + match[4];
|
44 |
-
|
45 |
-
replacements[i] = "\n" + indent + bullet + after;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
cm.replaceSelections(replacements);
|
50 |
-
};
|
51 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/matchbrackets.js
DELETED
@@ -1,120 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
|
13 |
-
(document.documentMode == null || document.documentMode < 8);
|
14 |
-
|
15 |
-
var Pos = CodeMirror.Pos;
|
16 |
-
|
17 |
-
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
|
18 |
-
|
19 |
-
function findMatchingBracket(cm, where, strict, config) {
|
20 |
-
var line = cm.getLineHandle(where.line), pos = where.ch - 1;
|
21 |
-
var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
|
22 |
-
if (!match) return null;
|
23 |
-
var dir = match.charAt(1) == ">" ? 1 : -1;
|
24 |
-
if (strict && (dir > 0) != (pos == where.ch)) return null;
|
25 |
-
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
|
26 |
-
|
27 |
-
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
|
28 |
-
if (found == null) return null;
|
29 |
-
return {from: Pos(where.line, pos), to: found && found.pos,
|
30 |
-
match: found && found.ch == match.charAt(0), forward: dir > 0};
|
31 |
-
}
|
32 |
-
|
33 |
-
// bracketRegex is used to specify which type of bracket to scan
|
34 |
-
// should be a regexp, e.g. /[[\]]/
|
35 |
-
//
|
36 |
-
// Note: If "where" is on an open bracket, then this bracket is ignored.
|
37 |
-
//
|
38 |
-
// Returns false when no bracket was found, null when it reached
|
39 |
-
// maxScanLines and gave up
|
40 |
-
function scanForBracket(cm, where, dir, style, config) {
|
41 |
-
var maxScanLen = (config && config.maxScanLineLength) || 10000;
|
42 |
-
var maxScanLines = (config && config.maxScanLines) || 1000;
|
43 |
-
|
44 |
-
var stack = [];
|
45 |
-
var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
|
46 |
-
var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
|
47 |
-
: Math.max(cm.firstLine() - 1, where.line - maxScanLines);
|
48 |
-
for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
|
49 |
-
var line = cm.getLine(lineNo);
|
50 |
-
if (!line) continue;
|
51 |
-
var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
|
52 |
-
if (line.length > maxScanLen) continue;
|
53 |
-
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
|
54 |
-
for (; pos != end; pos += dir) {
|
55 |
-
var ch = line.charAt(pos);
|
56 |
-
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
|
57 |
-
var match = matching[ch];
|
58 |
-
if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
|
59 |
-
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
|
60 |
-
else stack.pop();
|
61 |
-
}
|
62 |
-
}
|
63 |
-
}
|
64 |
-
return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
|
65 |
-
}
|
66 |
-
|
67 |
-
function matchBrackets(cm, autoclear, config) {
|
68 |
-
// Disable brace matching in long lines, since it'll cause hugely slow updates
|
69 |
-
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
|
70 |
-
var marks = [], ranges = cm.listSelections();
|
71 |
-
for (var i = 0; i < ranges.length; i++) {
|
72 |
-
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config);
|
73 |
-
if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
|
74 |
-
var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
|
75 |
-
marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
|
76 |
-
if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
|
77 |
-
marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
if (marks.length) {
|
82 |
-
// Kludge to work around the IE bug from issue #1193, where text
|
83 |
-
// input stops going to the textare whever this fires.
|
84 |
-
if (ie_lt8 && cm.state.focused) cm.focus();
|
85 |
-
|
86 |
-
var clear = function() {
|
87 |
-
cm.operation(function() {
|
88 |
-
for (var i = 0; i < marks.length; i++) marks[i].clear();
|
89 |
-
});
|
90 |
-
};
|
91 |
-
if (autoclear) setTimeout(clear, 800);
|
92 |
-
else return clear;
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
var currentlyHighlighted = null;
|
97 |
-
function doMatchBrackets(cm) {
|
98 |
-
cm.operation(function() {
|
99 |
-
if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
|
100 |
-
currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
|
101 |
-
});
|
102 |
-
}
|
103 |
-
|
104 |
-
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
|
105 |
-
if (old && old != CodeMirror.Init)
|
106 |
-
cm.off("cursorActivity", doMatchBrackets);
|
107 |
-
if (val) {
|
108 |
-
cm.state.matchBrackets = typeof val == "object" ? val : {};
|
109 |
-
cm.on("cursorActivity", doMatchBrackets);
|
110 |
-
}
|
111 |
-
});
|
112 |
-
|
113 |
-
CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
|
114 |
-
CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){
|
115 |
-
return findMatchingBracket(this, pos, strict, config);
|
116 |
-
});
|
117 |
-
CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
|
118 |
-
return scanForBracket(this, pos, dir, style, config);
|
119 |
-
});
|
120 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/matchtags.js
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror", "../fold/xml-fold"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineOption("matchTags", false, function(cm, val, old) {
|
15 |
-
if (old && old != CodeMirror.Init) {
|
16 |
-
cm.off("cursorActivity", doMatchTags);
|
17 |
-
cm.off("viewportChange", maybeUpdateMatch);
|
18 |
-
clear(cm);
|
19 |
-
}
|
20 |
-
if (val) {
|
21 |
-
cm.state.matchBothTags = typeof val == "object" && val.bothTags;
|
22 |
-
cm.on("cursorActivity", doMatchTags);
|
23 |
-
cm.on("viewportChange", maybeUpdateMatch);
|
24 |
-
doMatchTags(cm);
|
25 |
-
}
|
26 |
-
});
|
27 |
-
|
28 |
-
function clear(cm) {
|
29 |
-
if (cm.state.tagHit) cm.state.tagHit.clear();
|
30 |
-
if (cm.state.tagOther) cm.state.tagOther.clear();
|
31 |
-
cm.state.tagHit = cm.state.tagOther = null;
|
32 |
-
}
|
33 |
-
|
34 |
-
function doMatchTags(cm) {
|
35 |
-
cm.state.failedTagMatch = false;
|
36 |
-
cm.operation(function() {
|
37 |
-
clear(cm);
|
38 |
-
if (cm.somethingSelected()) return;
|
39 |
-
var cur = cm.getCursor(), range = cm.getViewport();
|
40 |
-
range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to);
|
41 |
-
var match = CodeMirror.findMatchingTag(cm, cur, range);
|
42 |
-
if (!match) return;
|
43 |
-
if (cm.state.matchBothTags) {
|
44 |
-
var hit = match.at == "open" ? match.open : match.close;
|
45 |
-
if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"});
|
46 |
-
}
|
47 |
-
var other = match.at == "close" ? match.open : match.close;
|
48 |
-
if (other)
|
49 |
-
cm.state.tagOther = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"});
|
50 |
-
else
|
51 |
-
cm.state.failedTagMatch = true;
|
52 |
-
});
|
53 |
-
}
|
54 |
-
|
55 |
-
function maybeUpdateMatch(cm) {
|
56 |
-
if (cm.state.failedTagMatch) doMatchTags(cm);
|
57 |
-
}
|
58 |
-
|
59 |
-
CodeMirror.commands.toMatchingTag = function(cm) {
|
60 |
-
var found = CodeMirror.findMatchingTag(cm, cm.getCursor());
|
61 |
-
if (found) {
|
62 |
-
var other = found.at == "close" ? found.open : found.close;
|
63 |
-
if (other) cm.extendSelection(other.to, other.from);
|
64 |
-
}
|
65 |
-
};
|
66 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/edit/trailingspace.js
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
|
13 |
-
if (prev == CodeMirror.Init) prev = false;
|
14 |
-
if (prev && !val)
|
15 |
-
cm.removeOverlay("trailingspace");
|
16 |
-
else if (!prev && val)
|
17 |
-
cm.addOverlay({
|
18 |
-
token: function(stream) {
|
19 |
-
for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
|
20 |
-
if (i > stream.pos) { stream.pos = i; return null; }
|
21 |
-
stream.pos = l;
|
22 |
-
return "trailingspace";
|
23 |
-
},
|
24 |
-
name: "trailingspace"
|
25 |
-
});
|
26 |
-
});
|
27 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/brace-fold.js
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.registerHelper("fold", "brace", function(cm, start) {
|
15 |
-
var line = start.line, lineText = cm.getLine(line);
|
16 |
-
var startCh, tokenType;
|
17 |
-
|
18 |
-
function findOpening(openCh) {
|
19 |
-
for (var at = start.ch, pass = 0;;) {
|
20 |
-
var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
|
21 |
-
if (found == -1) {
|
22 |
-
if (pass == 1) break;
|
23 |
-
pass = 1;
|
24 |
-
at = lineText.length;
|
25 |
-
continue;
|
26 |
-
}
|
27 |
-
if (pass == 1 && found < start.ch) break;
|
28 |
-
tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
|
29 |
-
if (!/^(comment|string)/.test(tokenType)) return found + 1;
|
30 |
-
at = found - 1;
|
31 |
-
}
|
32 |
-
}
|
33 |
-
|
34 |
-
var startToken = "{", endToken = "}", startCh = findOpening("{");
|
35 |
-
if (startCh == null) {
|
36 |
-
startToken = "[", endToken = "]";
|
37 |
-
startCh = findOpening("[");
|
38 |
-
}
|
39 |
-
|
40 |
-
if (startCh == null) return;
|
41 |
-
var count = 1, lastLine = cm.lastLine(), end, endCh;
|
42 |
-
outer: for (var i = line; i <= lastLine; ++i) {
|
43 |
-
var text = cm.getLine(i), pos = i == line ? startCh : 0;
|
44 |
-
for (;;) {
|
45 |
-
var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
|
46 |
-
if (nextOpen < 0) nextOpen = text.length;
|
47 |
-
if (nextClose < 0) nextClose = text.length;
|
48 |
-
pos = Math.min(nextOpen, nextClose);
|
49 |
-
if (pos == text.length) break;
|
50 |
-
if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
|
51 |
-
if (pos == nextOpen) ++count;
|
52 |
-
else if (!--count) { end = i; endCh = pos; break outer; }
|
53 |
-
}
|
54 |
-
++pos;
|
55 |
-
}
|
56 |
-
}
|
57 |
-
if (end == null || line == end && endCh == startCh) return;
|
58 |
-
return {from: CodeMirror.Pos(line, startCh),
|
59 |
-
to: CodeMirror.Pos(end, endCh)};
|
60 |
-
});
|
61 |
-
|
62 |
-
CodeMirror.registerHelper("fold", "import", function(cm, start) {
|
63 |
-
function hasImport(line) {
|
64 |
-
if (line < cm.firstLine() || line > cm.lastLine()) return null;
|
65 |
-
var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
|
66 |
-
if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
|
67 |
-
if (start.type != "keyword" || start.string != "import") return null;
|
68 |
-
// Now find closing semicolon, return its position
|
69 |
-
for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) {
|
70 |
-
var text = cm.getLine(i), semi = text.indexOf(";");
|
71 |
-
if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)};
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
var start = start.line, has = hasImport(start), prev;
|
76 |
-
if (!has || hasImport(start - 1) || ((prev = hasImport(start - 2)) && prev.end.line == start - 1))
|
77 |
-
return null;
|
78 |
-
for (var end = has.end;;) {
|
79 |
-
var next = hasImport(end.line + 1);
|
80 |
-
if (next == null) break;
|
81 |
-
end = next.end;
|
82 |
-
}
|
83 |
-
return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
|
84 |
-
});
|
85 |
-
|
86 |
-
CodeMirror.registerHelper("fold", "include", function(cm, start) {
|
87 |
-
function hasInclude(line) {
|
88 |
-
if (line < cm.firstLine() || line > cm.lastLine()) return null;
|
89 |
-
var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
|
90 |
-
if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
|
91 |
-
if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
|
92 |
-
}
|
93 |
-
|
94 |
-
var start = start.line, has = hasInclude(start);
|
95 |
-
if (has == null || hasInclude(start - 1) != null) return null;
|
96 |
-
for (var end = start;;) {
|
97 |
-
var next = hasInclude(end + 1);
|
98 |
-
if (next == null) break;
|
99 |
-
++end;
|
100 |
-
}
|
101 |
-
return {from: CodeMirror.Pos(start, has + 1),
|
102 |
-
to: cm.clipPos(CodeMirror.Pos(end))};
|
103 |
-
});
|
104 |
-
|
105 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/comment-fold.js
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
|
15 |
-
return mode.blockCommentStart && mode.blockCommentEnd;
|
16 |
-
}, function(cm, start) {
|
17 |
-
var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd;
|
18 |
-
if (!startToken || !endToken) return;
|
19 |
-
var line = start.line, lineText = cm.getLine(line);
|
20 |
-
|
21 |
-
var startCh;
|
22 |
-
for (var at = start.ch, pass = 0;;) {
|
23 |
-
var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1);
|
24 |
-
if (found == -1) {
|
25 |
-
if (pass == 1) return;
|
26 |
-
pass = 1;
|
27 |
-
at = lineText.length;
|
28 |
-
continue;
|
29 |
-
}
|
30 |
-
if (pass == 1 && found < start.ch) return;
|
31 |
-
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
|
32 |
-
(lineText.slice(found - endToken.length, found) == endToken ||
|
33 |
-
!/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
|
34 |
-
startCh = found + startToken.length;
|
35 |
-
break;
|
36 |
-
}
|
37 |
-
at = found - 1;
|
38 |
-
}
|
39 |
-
|
40 |
-
var depth = 1, lastLine = cm.lastLine(), end, endCh;
|
41 |
-
outer: for (var i = line; i <= lastLine; ++i) {
|
42 |
-
var text = cm.getLine(i), pos = i == line ? startCh : 0;
|
43 |
-
for (;;) {
|
44 |
-
var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
|
45 |
-
if (nextOpen < 0) nextOpen = text.length;
|
46 |
-
if (nextClose < 0) nextClose = text.length;
|
47 |
-
pos = Math.min(nextOpen, nextClose);
|
48 |
-
if (pos == text.length) break;
|
49 |
-
if (pos == nextOpen) ++depth;
|
50 |
-
else if (!--depth) { end = i; endCh = pos; break outer; }
|
51 |
-
++pos;
|
52 |
-
}
|
53 |
-
}
|
54 |
-
if (end == null || line == end && endCh == startCh) return;
|
55 |
-
return {from: CodeMirror.Pos(line, startCh),
|
56 |
-
to: CodeMirror.Pos(end, endCh)};
|
57 |
-
});
|
58 |
-
|
59 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/foldcode.js
DELETED
@@ -1,149 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
function doFold(cm, pos, options, force) {
|
15 |
-
if (options && options.call) {
|
16 |
-
var finder = options;
|
17 |
-
options = null;
|
18 |
-
} else {
|
19 |
-
var finder = getOption(cm, options, "rangeFinder");
|
20 |
-
}
|
21 |
-
if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
|
22 |
-
var minSize = getOption(cm, options, "minFoldSize");
|
23 |
-
|
24 |
-
function getRange(allowFolded) {
|
25 |
-
var range = finder(cm, pos);
|
26 |
-
if (!range || range.to.line - range.from.line < minSize) return null;
|
27 |
-
var marks = cm.findMarksAt(range.from);
|
28 |
-
for (var i = 0; i < marks.length; ++i) {
|
29 |
-
if (marks[i].__isFold && force !== "fold") {
|
30 |
-
if (!allowFolded) return null;
|
31 |
-
range.cleared = true;
|
32 |
-
marks[i].clear();
|
33 |
-
}
|
34 |
-
}
|
35 |
-
return range;
|
36 |
-
}
|
37 |
-
|
38 |
-
var range = getRange(true);
|
39 |
-
if (getOption(cm, options, "scanUp")) while (!range && pos.line > cm.firstLine()) {
|
40 |
-
pos = CodeMirror.Pos(pos.line - 1, 0);
|
41 |
-
range = getRange(false);
|
42 |
-
}
|
43 |
-
if (!range || range.cleared || force === "unfold") return;
|
44 |
-
|
45 |
-
var myWidget = makeWidget(cm, options);
|
46 |
-
CodeMirror.on(myWidget, "mousedown", function(e) {
|
47 |
-
myRange.clear();
|
48 |
-
CodeMirror.e_preventDefault(e);
|
49 |
-
});
|
50 |
-
var myRange = cm.markText(range.from, range.to, {
|
51 |
-
replacedWith: myWidget,
|
52 |
-
clearOnEnter: true,
|
53 |
-
__isFold: true
|
54 |
-
});
|
55 |
-
myRange.on("clear", function(from, to) {
|
56 |
-
CodeMirror.signal(cm, "unfold", cm, from, to);
|
57 |
-
});
|
58 |
-
CodeMirror.signal(cm, "fold", cm, range.from, range.to);
|
59 |
-
}
|
60 |
-
|
61 |
-
function makeWidget(cm, options) {
|
62 |
-
var widget = getOption(cm, options, "widget");
|
63 |
-
if (typeof widget == "string") {
|
64 |
-
var text = document.createTextNode(widget);
|
65 |
-
widget = document.createElement("span");
|
66 |
-
widget.appendChild(text);
|
67 |
-
widget.className = "CodeMirror-foldmarker";
|
68 |
-
}
|
69 |
-
return widget;
|
70 |
-
}
|
71 |
-
|
72 |
-
// Clumsy backwards-compatible interface
|
73 |
-
CodeMirror.newFoldFunction = function(rangeFinder, widget) {
|
74 |
-
return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); };
|
75 |
-
};
|
76 |
-
|
77 |
-
// New-style interface
|
78 |
-
CodeMirror.defineExtension("foldCode", function(pos, options, force) {
|
79 |
-
doFold(this, pos, options, force);
|
80 |
-
});
|
81 |
-
|
82 |
-
CodeMirror.defineExtension("isFolded", function(pos) {
|
83 |
-
var marks = this.findMarksAt(pos);
|
84 |
-
for (var i = 0; i < marks.length; ++i)
|
85 |
-
if (marks[i].__isFold) return true;
|
86 |
-
});
|
87 |
-
|
88 |
-
CodeMirror.commands.toggleFold = function(cm) {
|
89 |
-
cm.foldCode(cm.getCursor());
|
90 |
-
};
|
91 |
-
CodeMirror.commands.fold = function(cm) {
|
92 |
-
cm.foldCode(cm.getCursor(), null, "fold");
|
93 |
-
};
|
94 |
-
CodeMirror.commands.unfold = function(cm) {
|
95 |
-
cm.foldCode(cm.getCursor(), null, "unfold");
|
96 |
-
};
|
97 |
-
CodeMirror.commands.foldAll = function(cm) {
|
98 |
-
cm.operation(function() {
|
99 |
-
for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
|
100 |
-
cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
|
101 |
-
});
|
102 |
-
};
|
103 |
-
CodeMirror.commands.unfoldAll = function(cm) {
|
104 |
-
cm.operation(function() {
|
105 |
-
for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
|
106 |
-
cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
|
107 |
-
});
|
108 |
-
};
|
109 |
-
|
110 |
-
CodeMirror.registerHelper("fold", "combine", function() {
|
111 |
-
var funcs = Array.prototype.slice.call(arguments, 0);
|
112 |
-
return function(cm, start) {
|
113 |
-
for (var i = 0; i < funcs.length; ++i) {
|
114 |
-
var found = funcs[i](cm, start);
|
115 |
-
if (found) return found;
|
116 |
-
}
|
117 |
-
};
|
118 |
-
});
|
119 |
-
|
120 |
-
CodeMirror.registerHelper("fold", "auto", function(cm, start) {
|
121 |
-
var helpers = cm.getHelpers(start, "fold");
|
122 |
-
for (var i = 0; i < helpers.length; i++) {
|
123 |
-
var cur = helpers[i](cm, start);
|
124 |
-
if (cur) return cur;
|
125 |
-
}
|
126 |
-
});
|
127 |
-
|
128 |
-
var defaultOptions = {
|
129 |
-
rangeFinder: CodeMirror.fold.auto,
|
130 |
-
widget: "\u2194",
|
131 |
-
minFoldSize: 0,
|
132 |
-
scanUp: false
|
133 |
-
};
|
134 |
-
|
135 |
-
CodeMirror.defineOption("foldOptions", null);
|
136 |
-
|
137 |
-
function getOption(cm, options, name) {
|
138 |
-
if (options && options[name] !== undefined)
|
139 |
-
return options[name];
|
140 |
-
var editorOptions = cm.options.foldOptions;
|
141 |
-
if (editorOptions && editorOptions[name] !== undefined)
|
142 |
-
return editorOptions[name];
|
143 |
-
return defaultOptions[name];
|
144 |
-
}
|
145 |
-
|
146 |
-
CodeMirror.defineExtension("foldOption", function(options, name) {
|
147 |
-
return getOption(this, options, name);
|
148 |
-
});
|
149 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/foldgutter.css
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
.CodeMirror-foldmarker {
|
2 |
-
color: blue;
|
3 |
-
text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
|
4 |
-
font-family: arial;
|
5 |
-
line-height: .3;
|
6 |
-
cursor: pointer;
|
7 |
-
}
|
8 |
-
.CodeMirror-foldgutter {
|
9 |
-
width: .7em;
|
10 |
-
}
|
11 |
-
.CodeMirror-foldgutter-open,
|
12 |
-
.CodeMirror-foldgutter-folded {
|
13 |
-
cursor: pointer;
|
14 |
-
}
|
15 |
-
.CodeMirror-foldgutter-open:after {
|
16 |
-
content: "\25BE";
|
17 |
-
}
|
18 |
-
.CodeMirror-foldgutter-folded:after {
|
19 |
-
content: "\25B8";
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/foldgutter.js
DELETED
@@ -1,146 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"), require("./foldcode"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror", "./foldcode"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineOption("foldGutter", false, function(cm, val, old) {
|
15 |
-
if (old && old != CodeMirror.Init) {
|
16 |
-
cm.clearGutter(cm.state.foldGutter.options.gutter);
|
17 |
-
cm.state.foldGutter = null;
|
18 |
-
cm.off("gutterClick", onGutterClick);
|
19 |
-
cm.off("change", onChange);
|
20 |
-
cm.off("viewportChange", onViewportChange);
|
21 |
-
cm.off("fold", onFold);
|
22 |
-
cm.off("unfold", onFold);
|
23 |
-
cm.off("swapDoc", updateInViewport);
|
24 |
-
}
|
25 |
-
if (val) {
|
26 |
-
cm.state.foldGutter = new State(parseOptions(val));
|
27 |
-
updateInViewport(cm);
|
28 |
-
cm.on("gutterClick", onGutterClick);
|
29 |
-
cm.on("change", onChange);
|
30 |
-
cm.on("viewportChange", onViewportChange);
|
31 |
-
cm.on("fold", onFold);
|
32 |
-
cm.on("unfold", onFold);
|
33 |
-
cm.on("swapDoc", updateInViewport);
|
34 |
-
}
|
35 |
-
});
|
36 |
-
|
37 |
-
var Pos = CodeMirror.Pos;
|
38 |
-
|
39 |
-
function State(options) {
|
40 |
-
this.options = options;
|
41 |
-
this.from = this.to = 0;
|
42 |
-
}
|
43 |
-
|
44 |
-
function parseOptions(opts) {
|
45 |
-
if (opts === true) opts = {};
|
46 |
-
if (opts.gutter == null) opts.gutter = "CodeMirror-foldgutter";
|
47 |
-
if (opts.indicatorOpen == null) opts.indicatorOpen = "CodeMirror-foldgutter-open";
|
48 |
-
if (opts.indicatorFolded == null) opts.indicatorFolded = "CodeMirror-foldgutter-folded";
|
49 |
-
return opts;
|
50 |
-
}
|
51 |
-
|
52 |
-
function isFolded(cm, line) {
|
53 |
-
var marks = cm.findMarksAt(Pos(line));
|
54 |
-
for (var i = 0; i < marks.length; ++i)
|
55 |
-
if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i];
|
56 |
-
}
|
57 |
-
|
58 |
-
function marker(spec) {
|
59 |
-
if (typeof spec == "string") {
|
60 |
-
var elt = document.createElement("div");
|
61 |
-
elt.className = spec + " CodeMirror-guttermarker-subtle";
|
62 |
-
return elt;
|
63 |
-
} else {
|
64 |
-
return spec.cloneNode(true);
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
function updateFoldInfo(cm, from, to) {
|
69 |
-
var opts = cm.state.foldGutter.options, cur = from;
|
70 |
-
var minSize = cm.foldOption(opts, "minFoldSize");
|
71 |
-
var func = cm.foldOption(opts, "rangeFinder");
|
72 |
-
cm.eachLine(from, to, function(line) {
|
73 |
-
var mark = null;
|
74 |
-
if (isFolded(cm, cur)) {
|
75 |
-
mark = marker(opts.indicatorFolded);
|
76 |
-
} else {
|
77 |
-
var pos = Pos(cur, 0);
|
78 |
-
var range = func && func(cm, pos);
|
79 |
-
if (range && range.to.line - range.from.line >= minSize)
|
80 |
-
mark = marker(opts.indicatorOpen);
|
81 |
-
}
|
82 |
-
cm.setGutterMarker(line, opts.gutter, mark);
|
83 |
-
++cur;
|
84 |
-
});
|
85 |
-
}
|
86 |
-
|
87 |
-
function updateInViewport(cm) {
|
88 |
-
var vp = cm.getViewport(), state = cm.state.foldGutter;
|
89 |
-
if (!state) return;
|
90 |
-
cm.operation(function() {
|
91 |
-
updateFoldInfo(cm, vp.from, vp.to);
|
92 |
-
});
|
93 |
-
state.from = vp.from; state.to = vp.to;
|
94 |
-
}
|
95 |
-
|
96 |
-
function onGutterClick(cm, line, gutter) {
|
97 |
-
var state = cm.state.foldGutter;
|
98 |
-
if (!state) return;
|
99 |
-
var opts = state.options;
|
100 |
-
if (gutter != opts.gutter) return;
|
101 |
-
var folded = isFolded(cm, line);
|
102 |
-
if (folded) folded.clear();
|
103 |
-
else cm.foldCode(Pos(line, 0), opts.rangeFinder);
|
104 |
-
}
|
105 |
-
|
106 |
-
function onChange(cm) {
|
107 |
-
var state = cm.state.foldGutter;
|
108 |
-
if (!state) return;
|
109 |
-
var opts = state.options;
|
110 |
-
state.from = state.to = 0;
|
111 |
-
clearTimeout(state.changeUpdate);
|
112 |
-
state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600);
|
113 |
-
}
|
114 |
-
|
115 |
-
function onViewportChange(cm) {
|
116 |
-
var state = cm.state.foldGutter;
|
117 |
-
if (!state) return;
|
118 |
-
var opts = state.options;
|
119 |
-
clearTimeout(state.changeUpdate);
|
120 |
-
state.changeUpdate = setTimeout(function() {
|
121 |
-
var vp = cm.getViewport();
|
122 |
-
if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
|
123 |
-
updateInViewport(cm);
|
124 |
-
} else {
|
125 |
-
cm.operation(function() {
|
126 |
-
if (vp.from < state.from) {
|
127 |
-
updateFoldInfo(cm, vp.from, state.from);
|
128 |
-
state.from = vp.from;
|
129 |
-
}
|
130 |
-
if (vp.to > state.to) {
|
131 |
-
updateFoldInfo(cm, state.to, vp.to);
|
132 |
-
state.to = vp.to;
|
133 |
-
}
|
134 |
-
});
|
135 |
-
}
|
136 |
-
}, opts.updateViewportTimeSpan || 400);
|
137 |
-
}
|
138 |
-
|
139 |
-
function onFold(cm, from) {
|
140 |
-
var state = cm.state.foldGutter;
|
141 |
-
if (!state) return;
|
142 |
-
var line = from.line;
|
143 |
-
if (line >= state.from && line < state.to)
|
144 |
-
updateFoldInfo(cm, line, line + 1);
|
145 |
-
}
|
146 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/indent-fold.js
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
|
15 |
-
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
|
16 |
-
if (!/\S/.test(firstLine)) return;
|
17 |
-
var getIndent = function(line) {
|
18 |
-
return CodeMirror.countColumn(line, null, tabSize);
|
19 |
-
};
|
20 |
-
var myIndent = getIndent(firstLine);
|
21 |
-
var lastLineInFold = null;
|
22 |
-
// Go through lines until we find a line that definitely doesn't belong in
|
23 |
-
// the block we're folding, or to the end.
|
24 |
-
for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
|
25 |
-
var curLine = cm.getLine(i);
|
26 |
-
var curIndent = getIndent(curLine);
|
27 |
-
if (curIndent > myIndent) {
|
28 |
-
// Lines with a greater indent are considered part of the block.
|
29 |
-
lastLineInFold = i;
|
30 |
-
} else if (!/\S/.test(curLine)) {
|
31 |
-
// Empty lines might be breaks within the block we're trying to fold.
|
32 |
-
} else {
|
33 |
-
// A non-empty line at an indent equal to or less than ours marks the
|
34 |
-
// start of another block.
|
35 |
-
break;
|
36 |
-
}
|
37 |
-
}
|
38 |
-
if (lastLineInFold) return {
|
39 |
-
from: CodeMirror.Pos(start.line, firstLine.length),
|
40 |
-
to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
|
41 |
-
};
|
42 |
-
});
|
43 |
-
|
44 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/markdown-fold.js
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.registerHelper("fold", "markdown", function(cm, start) {
|
15 |
-
var maxDepth = 100;
|
16 |
-
|
17 |
-
function isHeader(lineNo) {
|
18 |
-
var tokentype = cm.getTokenTypeAt(CodeMirror.Pos(lineNo, 0));
|
19 |
-
return tokentype && /\bheader\b/.test(tokentype);
|
20 |
-
}
|
21 |
-
|
22 |
-
function headerLevel(lineNo, line, nextLine) {
|
23 |
-
var match = line && line.match(/^#+/);
|
24 |
-
if (match && isHeader(lineNo)) return match[0].length;
|
25 |
-
match = nextLine && nextLine.match(/^[=\-]+\s*$/);
|
26 |
-
if (match && isHeader(lineNo + 1)) return nextLine[0] == "=" ? 1 : 2;
|
27 |
-
return maxDepth;
|
28 |
-
}
|
29 |
-
|
30 |
-
var firstLine = cm.getLine(start.line), nextLine = cm.getLine(start.line + 1);
|
31 |
-
var level = headerLevel(start.line, firstLine, nextLine);
|
32 |
-
if (level === maxDepth) return undefined;
|
33 |
-
|
34 |
-
var lastLineNo = cm.lastLine();
|
35 |
-
var end = start.line, nextNextLine = cm.getLine(end + 2);
|
36 |
-
while (end < lastLineNo) {
|
37 |
-
if (headerLevel(end + 1, nextLine, nextNextLine) <= level) break;
|
38 |
-
++end;
|
39 |
-
nextLine = nextNextLine;
|
40 |
-
nextNextLine = cm.getLine(end + 2);
|
41 |
-
}
|
42 |
-
|
43 |
-
return {
|
44 |
-
from: CodeMirror.Pos(start.line, firstLine.length),
|
45 |
-
to: CodeMirror.Pos(end, cm.getLine(end).length)
|
46 |
-
};
|
47 |
-
});
|
48 |
-
|
49 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/fold/xml-fold.js
DELETED
@@ -1,182 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var Pos = CodeMirror.Pos;
|
15 |
-
function cmp(a, b) { return a.line - b.line || a.ch - b.ch; }
|
16 |
-
|
17 |
-
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
18 |
-
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
19 |
-
var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g");
|
20 |
-
|
21 |
-
function Iter(cm, line, ch, range) {
|
22 |
-
this.line = line; this.ch = ch;
|
23 |
-
this.cm = cm; this.text = cm.getLine(line);
|
24 |
-
this.min = range ? range.from : cm.firstLine();
|
25 |
-
this.max = range ? range.to - 1 : cm.lastLine();
|
26 |
-
}
|
27 |
-
|
28 |
-
function tagAt(iter, ch) {
|
29 |
-
var type = iter.cm.getTokenTypeAt(Pos(iter.line, ch));
|
30 |
-
return type && /\btag\b/.test(type);
|
31 |
-
}
|
32 |
-
|
33 |
-
function nextLine(iter) {
|
34 |
-
if (iter.line >= iter.max) return;
|
35 |
-
iter.ch = 0;
|
36 |
-
iter.text = iter.cm.getLine(++iter.line);
|
37 |
-
return true;
|
38 |
-
}
|
39 |
-
function prevLine(iter) {
|
40 |
-
if (iter.line <= iter.min) return;
|
41 |
-
iter.text = iter.cm.getLine(--iter.line);
|
42 |
-
iter.ch = iter.text.length;
|
43 |
-
return true;
|
44 |
-
}
|
45 |
-
|
46 |
-
function toTagEnd(iter) {
|
47 |
-
for (;;) {
|
48 |
-
var gt = iter.text.indexOf(">", iter.ch);
|
49 |
-
if (gt == -1) { if (nextLine(iter)) continue; else return; }
|
50 |
-
if (!tagAt(iter, gt + 1)) { iter.ch = gt + 1; continue; }
|
51 |
-
var lastSlash = iter.text.lastIndexOf("/", gt);
|
52 |
-
var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
|
53 |
-
iter.ch = gt + 1;
|
54 |
-
return selfClose ? "selfClose" : "regular";
|
55 |
-
}
|
56 |
-
}
|
57 |
-
function toTagStart(iter) {
|
58 |
-
for (;;) {
|
59 |
-
var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1;
|
60 |
-
if (lt == -1) { if (prevLine(iter)) continue; else return; }
|
61 |
-
if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; }
|
62 |
-
xmlTagStart.lastIndex = lt;
|
63 |
-
iter.ch = lt;
|
64 |
-
var match = xmlTagStart.exec(iter.text);
|
65 |
-
if (match && match.index == lt) return match;
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
function toNextTag(iter) {
|
70 |
-
for (;;) {
|
71 |
-
xmlTagStart.lastIndex = iter.ch;
|
72 |
-
var found = xmlTagStart.exec(iter.text);
|
73 |
-
if (!found) { if (nextLine(iter)) continue; else return; }
|
74 |
-
if (!tagAt(iter, found.index + 1)) { iter.ch = found.index + 1; continue; }
|
75 |
-
iter.ch = found.index + found[0].length;
|
76 |
-
return found;
|
77 |
-
}
|
78 |
-
}
|
79 |
-
function toPrevTag(iter) {
|
80 |
-
for (;;) {
|
81 |
-
var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1;
|
82 |
-
if (gt == -1) { if (prevLine(iter)) continue; else return; }
|
83 |
-
if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; }
|
84 |
-
var lastSlash = iter.text.lastIndexOf("/", gt);
|
85 |
-
var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
|
86 |
-
iter.ch = gt + 1;
|
87 |
-
return selfClose ? "selfClose" : "regular";
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
function findMatchingClose(iter, tag) {
|
92 |
-
var stack = [];
|
93 |
-
for (;;) {
|
94 |
-
var next = toNextTag(iter), end, startLine = iter.line, startCh = iter.ch - (next ? next[0].length : 0);
|
95 |
-
if (!next || !(end = toTagEnd(iter))) return;
|
96 |
-
if (end == "selfClose") continue;
|
97 |
-
if (next[1]) { // closing tag
|
98 |
-
for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == next[2]) {
|
99 |
-
stack.length = i;
|
100 |
-
break;
|
101 |
-
}
|
102 |
-
if (i < 0 && (!tag || tag == next[2])) return {
|
103 |
-
tag: next[2],
|
104 |
-
from: Pos(startLine, startCh),
|
105 |
-
to: Pos(iter.line, iter.ch)
|
106 |
-
};
|
107 |
-
} else { // opening tag
|
108 |
-
stack.push(next[2]);
|
109 |
-
}
|
110 |
-
}
|
111 |
-
}
|
112 |
-
function findMatchingOpen(iter, tag) {
|
113 |
-
var stack = [];
|
114 |
-
for (;;) {
|
115 |
-
var prev = toPrevTag(iter);
|
116 |
-
if (!prev) return;
|
117 |
-
if (prev == "selfClose") { toTagStart(iter); continue; }
|
118 |
-
var endLine = iter.line, endCh = iter.ch;
|
119 |
-
var start = toTagStart(iter);
|
120 |
-
if (!start) return;
|
121 |
-
if (start[1]) { // closing tag
|
122 |
-
stack.push(start[2]);
|
123 |
-
} else { // opening tag
|
124 |
-
for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == start[2]) {
|
125 |
-
stack.length = i;
|
126 |
-
break;
|
127 |
-
}
|
128 |
-
if (i < 0 && (!tag || tag == start[2])) return {
|
129 |
-
tag: start[2],
|
130 |
-
from: Pos(iter.line, iter.ch),
|
131 |
-
to: Pos(endLine, endCh)
|
132 |
-
};
|
133 |
-
}
|
134 |
-
}
|
135 |
-
}
|
136 |
-
|
137 |
-
CodeMirror.registerHelper("fold", "xml", function(cm, start) {
|
138 |
-
var iter = new Iter(cm, start.line, 0);
|
139 |
-
for (;;) {
|
140 |
-
var openTag = toNextTag(iter), end;
|
141 |
-
if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return;
|
142 |
-
if (!openTag[1] && end != "selfClose") {
|
143 |
-
var start = Pos(iter.line, iter.ch);
|
144 |
-
var close = findMatchingClose(iter, openTag[2]);
|
145 |
-
return close && {from: start, to: close.from};
|
146 |
-
}
|
147 |
-
}
|
148 |
-
});
|
149 |
-
CodeMirror.findMatchingTag = function(cm, pos, range) {
|
150 |
-
var iter = new Iter(cm, pos.line, pos.ch, range);
|
151 |
-
if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
|
152 |
-
var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch);
|
153 |
-
var start = end && toTagStart(iter);
|
154 |
-
if (!end || !start || cmp(iter, pos) > 0) return;
|
155 |
-
var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]};
|
156 |
-
if (end == "selfClose") return {open: here, close: null, at: "open"};
|
157 |
-
|
158 |
-
if (start[1]) { // closing tag
|
159 |
-
return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"};
|
160 |
-
} else { // opening tag
|
161 |
-
iter = new Iter(cm, to.line, to.ch, range);
|
162 |
-
return {open: here, close: findMatchingClose(iter, start[2]), at: "open"};
|
163 |
-
}
|
164 |
-
};
|
165 |
-
|
166 |
-
CodeMirror.findEnclosingTag = function(cm, pos, range) {
|
167 |
-
var iter = new Iter(cm, pos.line, pos.ch, range);
|
168 |
-
for (;;) {
|
169 |
-
var open = findMatchingOpen(iter);
|
170 |
-
if (!open) break;
|
171 |
-
var forward = new Iter(cm, pos.line, pos.ch, range);
|
172 |
-
var close = findMatchingClose(forward, open.tag);
|
173 |
-
if (close) return {open: open, close: close};
|
174 |
-
}
|
175 |
-
};
|
176 |
-
|
177 |
-
// Used by addon/edit/closetag.js
|
178 |
-
CodeMirror.scanForClosingTag = function(cm, pos, name, end) {
|
179 |
-
var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null);
|
180 |
-
return findMatchingClose(iter, name);
|
181 |
-
};
|
182 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/anyword-hint.js
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var WORD = /[\w$]+/, RANGE = 500;
|
15 |
-
|
16 |
-
CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
|
17 |
-
var word = options && options.word || WORD;
|
18 |
-
var range = options && options.range || RANGE;
|
19 |
-
var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
|
20 |
-
var end = cur.ch, start = end;
|
21 |
-
while (start && word.test(curLine.charAt(start - 1))) --start;
|
22 |
-
var curWord = start != end && curLine.slice(start, end);
|
23 |
-
|
24 |
-
var list = options && options.list || [], seen = {};
|
25 |
-
var re = new RegExp(word.source, "g");
|
26 |
-
for (var dir = -1; dir <= 1; dir += 2) {
|
27 |
-
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
|
28 |
-
for (; line != endLine; line += dir) {
|
29 |
-
var text = editor.getLine(line), m;
|
30 |
-
while (m = re.exec(text)) {
|
31 |
-
if (line == cur.line && m[0] === curWord) continue;
|
32 |
-
if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) {
|
33 |
-
seen[m[0]] = true;
|
34 |
-
list.push(m[0]);
|
35 |
-
}
|
36 |
-
}
|
37 |
-
}
|
38 |
-
}
|
39 |
-
return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
|
40 |
-
});
|
41 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/css-hint.js
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"), require("../../mode/css/css"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror", "../../mode/css/css"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var pseudoClasses = {link: 1, visited: 1, active: 1, hover: 1, focus: 1,
|
15 |
-
"first-letter": 1, "first-line": 1, "first-child": 1,
|
16 |
-
before: 1, after: 1, lang: 1};
|
17 |
-
|
18 |
-
CodeMirror.registerHelper("hint", "css", function(cm) {
|
19 |
-
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
20 |
-
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
21 |
-
if (inner.mode.name != "css") return;
|
22 |
-
|
23 |
-
if (token.type == "keyword" && "!important".indexOf(token.string) == 0)
|
24 |
-
return {list: ["!important"], from: CodeMirror.Pos(cur.line, token.start),
|
25 |
-
to: CodeMirror.Pos(cur.line, token.end)};
|
26 |
-
|
27 |
-
var start = token.start, end = cur.ch, word = token.string.slice(0, end - start);
|
28 |
-
if (/[^\w$_-]/.test(word)) {
|
29 |
-
word = ""; start = end = cur.ch;
|
30 |
-
}
|
31 |
-
|
32 |
-
var spec = CodeMirror.resolveMode("text/css");
|
33 |
-
|
34 |
-
var result = [];
|
35 |
-
function add(keywords) {
|
36 |
-
for (var name in keywords)
|
37 |
-
if (!word || name.lastIndexOf(word, 0) == 0)
|
38 |
-
result.push(name);
|
39 |
-
}
|
40 |
-
|
41 |
-
var st = inner.state.state;
|
42 |
-
if (st == "pseudo" || token.type == "variable-3") {
|
43 |
-
add(pseudoClasses);
|
44 |
-
} else if (st == "block" || st == "maybeprop") {
|
45 |
-
add(spec.propertyKeywords);
|
46 |
-
} else if (st == "prop" || st == "parens" || st == "at" || st == "params") {
|
47 |
-
add(spec.valueKeywords);
|
48 |
-
add(spec.colorKeywords);
|
49 |
-
} else if (st == "media" || st == "media_parens") {
|
50 |
-
add(spec.mediaTypes);
|
51 |
-
add(spec.mediaFeatures);
|
52 |
-
}
|
53 |
-
|
54 |
-
if (result.length) return {
|
55 |
-
list: result,
|
56 |
-
from: CodeMirror.Pos(cur.line, start),
|
57 |
-
to: CodeMirror.Pos(cur.line, end)
|
58 |
-
};
|
59 |
-
});
|
60 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/html-hint.js
DELETED
@@ -1,348 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"), require("./xml-hint"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror", "./xml-hint"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" ");
|
15 |
-
var targets = ["_blank", "_self", "_top", "_parent"];
|
16 |
-
var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
|
17 |
-
var methods = ["get", "post", "put", "delete"];
|
18 |
-
var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"];
|
19 |
-
var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech",
|
20 |
-
"3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait",
|
21 |
-
"orientation:landscape", "device-height: [X]", "device-width: [X]"];
|
22 |
-
var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags
|
23 |
-
|
24 |
-
var data = {
|
25 |
-
a: {
|
26 |
-
attrs: {
|
27 |
-
href: null, ping: null, type: null,
|
28 |
-
media: media,
|
29 |
-
target: targets,
|
30 |
-
hreflang: langs
|
31 |
-
}
|
32 |
-
},
|
33 |
-
abbr: s,
|
34 |
-
acronym: s,
|
35 |
-
address: s,
|
36 |
-
applet: s,
|
37 |
-
area: {
|
38 |
-
attrs: {
|
39 |
-
alt: null, coords: null, href: null, target: null, ping: null,
|
40 |
-
media: media, hreflang: langs, type: null,
|
41 |
-
shape: ["default", "rect", "circle", "poly"]
|
42 |
-
}
|
43 |
-
},
|
44 |
-
article: s,
|
45 |
-
aside: s,
|
46 |
-
audio: {
|
47 |
-
attrs: {
|
48 |
-
src: null, mediagroup: null,
|
49 |
-
crossorigin: ["anonymous", "use-credentials"],
|
50 |
-
preload: ["none", "metadata", "auto"],
|
51 |
-
autoplay: ["", "autoplay"],
|
52 |
-
loop: ["", "loop"],
|
53 |
-
controls: ["", "controls"]
|
54 |
-
}
|
55 |
-
},
|
56 |
-
b: s,
|
57 |
-
base: { attrs: { href: null, target: targets } },
|
58 |
-
basefont: s,
|
59 |
-
bdi: s,
|
60 |
-
bdo: s,
|
61 |
-
big: s,
|
62 |
-
blockquote: { attrs: { cite: null } },
|
63 |
-
body: s,
|
64 |
-
br: s,
|
65 |
-
button: {
|
66 |
-
attrs: {
|
67 |
-
form: null, formaction: null, name: null, value: null,
|
68 |
-
autofocus: ["", "autofocus"],
|
69 |
-
disabled: ["", "autofocus"],
|
70 |
-
formenctype: encs,
|
71 |
-
formmethod: methods,
|
72 |
-
formnovalidate: ["", "novalidate"],
|
73 |
-
formtarget: targets,
|
74 |
-
type: ["submit", "reset", "button"]
|
75 |
-
}
|
76 |
-
},
|
77 |
-
canvas: { attrs: { width: null, height: null } },
|
78 |
-
caption: s,
|
79 |
-
center: s,
|
80 |
-
cite: s,
|
81 |
-
code: s,
|
82 |
-
col: { attrs: { span: null } },
|
83 |
-
colgroup: { attrs: { span: null } },
|
84 |
-
command: {
|
85 |
-
attrs: {
|
86 |
-
type: ["command", "checkbox", "radio"],
|
87 |
-
label: null, icon: null, radiogroup: null, command: null, title: null,
|
88 |
-
disabled: ["", "disabled"],
|
89 |
-
checked: ["", "checked"]
|
90 |
-
}
|
91 |
-
},
|
92 |
-
data: { attrs: { value: null } },
|
93 |
-
datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } },
|
94 |
-
datalist: { attrs: { data: null } },
|
95 |
-
dd: s,
|
96 |
-
del: { attrs: { cite: null, datetime: null } },
|
97 |
-
details: { attrs: { open: ["", "open"] } },
|
98 |
-
dfn: s,
|
99 |
-
dir: s,
|
100 |
-
div: s,
|
101 |
-
dl: s,
|
102 |
-
dt: s,
|
103 |
-
em: s,
|
104 |
-
embed: { attrs: { src: null, type: null, width: null, height: null } },
|
105 |
-
eventsource: { attrs: { src: null } },
|
106 |
-
fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } },
|
107 |
-
figcaption: s,
|
108 |
-
figure: s,
|
109 |
-
font: s,
|
110 |
-
footer: s,
|
111 |
-
form: {
|
112 |
-
attrs: {
|
113 |
-
action: null, name: null,
|
114 |
-
"accept-charset": charsets,
|
115 |
-
autocomplete: ["on", "off"],
|
116 |
-
enctype: encs,
|
117 |
-
method: methods,
|
118 |
-
novalidate: ["", "novalidate"],
|
119 |
-
target: targets
|
120 |
-
}
|
121 |
-
},
|
122 |
-
frame: s,
|
123 |
-
frameset: s,
|
124 |
-
h1: s, h2: s, h3: s, h4: s, h5: s, h6: s,
|
125 |
-
head: {
|
126 |
-
attrs: {},
|
127 |
-
children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
|
128 |
-
},
|
129 |
-
header: s,
|
130 |
-
hgroup: s,
|
131 |
-
hr: s,
|
132 |
-
html: {
|
133 |
-
attrs: { manifest: null },
|
134 |
-
children: ["head", "body"]
|
135 |
-
},
|
136 |
-
i: s,
|
137 |
-
iframe: {
|
138 |
-
attrs: {
|
139 |
-
src: null, srcdoc: null, name: null, width: null, height: null,
|
140 |
-
sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
|
141 |
-
seamless: ["", "seamless"]
|
142 |
-
}
|
143 |
-
},
|
144 |
-
img: {
|
145 |
-
attrs: {
|
146 |
-
alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
|
147 |
-
crossorigin: ["anonymous", "use-credentials"]
|
148 |
-
}
|
149 |
-
},
|
150 |
-
input: {
|
151 |
-
attrs: {
|
152 |
-
alt: null, dirname: null, form: null, formaction: null,
|
153 |
-
height: null, list: null, max: null, maxlength: null, min: null,
|
154 |
-
name: null, pattern: null, placeholder: null, size: null, src: null,
|
155 |
-
step: null, value: null, width: null,
|
156 |
-
accept: ["audio/*", "video/*", "image/*"],
|
157 |
-
autocomplete: ["on", "off"],
|
158 |
-
autofocus: ["", "autofocus"],
|
159 |
-
checked: ["", "checked"],
|
160 |
-
disabled: ["", "disabled"],
|
161 |
-
formenctype: encs,
|
162 |
-
formmethod: methods,
|
163 |
-
formnovalidate: ["", "novalidate"],
|
164 |
-
formtarget: targets,
|
165 |
-
multiple: ["", "multiple"],
|
166 |
-
readonly: ["", "readonly"],
|
167 |
-
required: ["", "required"],
|
168 |
-
type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
|
169 |
-
"week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
|
170 |
-
"file", "submit", "image", "reset", "button"]
|
171 |
-
}
|
172 |
-
},
|
173 |
-
ins: { attrs: { cite: null, datetime: null } },
|
174 |
-
kbd: s,
|
175 |
-
keygen: {
|
176 |
-
attrs: {
|
177 |
-
challenge: null, form: null, name: null,
|
178 |
-
autofocus: ["", "autofocus"],
|
179 |
-
disabled: ["", "disabled"],
|
180 |
-
keytype: ["RSA"]
|
181 |
-
}
|
182 |
-
},
|
183 |
-
label: { attrs: { "for": null, form: null } },
|
184 |
-
legend: s,
|
185 |
-
li: { attrs: { value: null } },
|
186 |
-
link: {
|
187 |
-
attrs: {
|
188 |
-
href: null, type: null,
|
189 |
-
hreflang: langs,
|
190 |
-
media: media,
|
191 |
-
sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
|
192 |
-
}
|
193 |
-
},
|
194 |
-
map: { attrs: { name: null } },
|
195 |
-
mark: s,
|
196 |
-
menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
|
197 |
-
meta: {
|
198 |
-
attrs: {
|
199 |
-
content: null,
|
200 |
-
charset: charsets,
|
201 |
-
name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
|
202 |
-
"http-equiv": ["content-language", "content-type", "default-style", "refresh"]
|
203 |
-
}
|
204 |
-
},
|
205 |
-
meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
|
206 |
-
nav: s,
|
207 |
-
noframes: s,
|
208 |
-
noscript: s,
|
209 |
-
object: {
|
210 |
-
attrs: {
|
211 |
-
data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
|
212 |
-
typemustmatch: ["", "typemustmatch"]
|
213 |
-
}
|
214 |
-
},
|
215 |
-
ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } },
|
216 |
-
optgroup: { attrs: { disabled: ["", "disabled"], label: null } },
|
217 |
-
option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } },
|
218 |
-
output: { attrs: { "for": null, form: null, name: null } },
|
219 |
-
p: s,
|
220 |
-
param: { attrs: { name: null, value: null } },
|
221 |
-
pre: s,
|
222 |
-
progress: { attrs: { value: null, max: null } },
|
223 |
-
q: { attrs: { cite: null } },
|
224 |
-
rp: s,
|
225 |
-
rt: s,
|
226 |
-
ruby: s,
|
227 |
-
s: s,
|
228 |
-
samp: s,
|
229 |
-
script: {
|
230 |
-
attrs: {
|
231 |
-
type: ["text/javascript"],
|
232 |
-
src: null,
|
233 |
-
async: ["", "async"],
|
234 |
-
defer: ["", "defer"],
|
235 |
-
charset: charsets
|
236 |
-
}
|
237 |
-
},
|
238 |
-
section: s,
|
239 |
-
select: {
|
240 |
-
attrs: {
|
241 |
-
form: null, name: null, size: null,
|
242 |
-
autofocus: ["", "autofocus"],
|
243 |
-
disabled: ["", "disabled"],
|
244 |
-
multiple: ["", "multiple"]
|
245 |
-
}
|
246 |
-
},
|
247 |
-
small: s,
|
248 |
-
source: { attrs: { src: null, type: null, media: null } },
|
249 |
-
span: s,
|
250 |
-
strike: s,
|
251 |
-
strong: s,
|
252 |
-
style: {
|
253 |
-
attrs: {
|
254 |
-
type: ["text/css"],
|
255 |
-
media: media,
|
256 |
-
scoped: null
|
257 |
-
}
|
258 |
-
},
|
259 |
-
sub: s,
|
260 |
-
summary: s,
|
261 |
-
sup: s,
|
262 |
-
table: s,
|
263 |
-
tbody: s,
|
264 |
-
td: { attrs: { colspan: null, rowspan: null, headers: null } },
|
265 |
-
textarea: {
|
266 |
-
attrs: {
|
267 |
-
dirname: null, form: null, maxlength: null, name: null, placeholder: null,
|
268 |
-
rows: null, cols: null,
|
269 |
-
autofocus: ["", "autofocus"],
|
270 |
-
disabled: ["", "disabled"],
|
271 |
-
readonly: ["", "readonly"],
|
272 |
-
required: ["", "required"],
|
273 |
-
wrap: ["soft", "hard"]
|
274 |
-
}
|
275 |
-
},
|
276 |
-
tfoot: s,
|
277 |
-
th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
|
278 |
-
thead: s,
|
279 |
-
time: { attrs: { datetime: null } },
|
280 |
-
title: s,
|
281 |
-
tr: s,
|
282 |
-
track: {
|
283 |
-
attrs: {
|
284 |
-
src: null, label: null, "default": null,
|
285 |
-
kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
|
286 |
-
srclang: langs
|
287 |
-
}
|
288 |
-
},
|
289 |
-
tt: s,
|
290 |
-
u: s,
|
291 |
-
ul: s,
|
292 |
-
"var": s,
|
293 |
-
video: {
|
294 |
-
attrs: {
|
295 |
-
src: null, poster: null, width: null, height: null,
|
296 |
-
crossorigin: ["anonymous", "use-credentials"],
|
297 |
-
preload: ["auto", "metadata", "none"],
|
298 |
-
autoplay: ["", "autoplay"],
|
299 |
-
mediagroup: ["movie"],
|
300 |
-
muted: ["", "muted"],
|
301 |
-
controls: ["", "controls"]
|
302 |
-
}
|
303 |
-
},
|
304 |
-
wbr: s
|
305 |
-
};
|
306 |
-
|
307 |
-
var globalAttrs = {
|
308 |
-
accesskey: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
|
309 |
-
"class": null,
|
310 |
-
contenteditable: ["true", "false"],
|
311 |
-
contextmenu: null,
|
312 |
-
dir: ["ltr", "rtl", "auto"],
|
313 |
-
draggable: ["true", "false", "auto"],
|
314 |
-
dropzone: ["copy", "move", "link", "string:", "file:"],
|
315 |
-
hidden: ["hidden"],
|
316 |
-
id: null,
|
317 |
-
inert: ["inert"],
|
318 |
-
itemid: null,
|
319 |
-
itemprop: null,
|
320 |
-
itemref: null,
|
321 |
-
itemscope: ["itemscope"],
|
322 |
-
itemtype: null,
|
323 |
-
lang: ["en", "es"],
|
324 |
-
spellcheck: ["true", "false"],
|
325 |
-
style: null,
|
326 |
-
tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
|
327 |
-
title: null,
|
328 |
-
translate: ["yes", "no"],
|
329 |
-
onclick: null,
|
330 |
-
rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"]
|
331 |
-
};
|
332 |
-
function populate(obj) {
|
333 |
-
for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr))
|
334 |
-
obj.attrs[attr] = globalAttrs[attr];
|
335 |
-
}
|
336 |
-
|
337 |
-
populate(s);
|
338 |
-
for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s)
|
339 |
-
populate(data[tag]);
|
340 |
-
|
341 |
-
CodeMirror.htmlSchema = data;
|
342 |
-
function htmlHint(cm, options) {
|
343 |
-
var local = {schemaInfo: data};
|
344 |
-
if (options) for (var opt in options) local[opt] = options[opt];
|
345 |
-
return CodeMirror.hint.xml(cm, local);
|
346 |
-
}
|
347 |
-
CodeMirror.registerHelper("hint", "html", htmlHint);
|
348 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/javascript-hint.js
DELETED
@@ -1,146 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
var Pos = CodeMirror.Pos;
|
13 |
-
|
14 |
-
function forEach(arr, f) {
|
15 |
-
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
16 |
-
}
|
17 |
-
|
18 |
-
function arrayContains(arr, item) {
|
19 |
-
if (!Array.prototype.indexOf) {
|
20 |
-
var i = arr.length;
|
21 |
-
while (i--) {
|
22 |
-
if (arr[i] === item) {
|
23 |
-
return true;
|
24 |
-
}
|
25 |
-
}
|
26 |
-
return false;
|
27 |
-
}
|
28 |
-
return arr.indexOf(item) != -1;
|
29 |
-
}
|
30 |
-
|
31 |
-
function scriptHint(editor, keywords, getToken, options) {
|
32 |
-
// Find the token at the cursor
|
33 |
-
var cur = editor.getCursor(), token = getToken(editor, cur);
|
34 |
-
if (/\b(?:string|comment)\b/.test(token.type)) return;
|
35 |
-
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
|
36 |
-
|
37 |
-
// If it's not a 'word-style' token, ignore the token.
|
38 |
-
if (!/^[\w$_]*$/.test(token.string)) {
|
39 |
-
token = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
40 |
-
type: token.string == "." ? "property" : null};
|
41 |
-
} else if (token.end > cur.ch) {
|
42 |
-
token.end = cur.ch;
|
43 |
-
token.string = token.string.slice(0, cur.ch - token.start);
|
44 |
-
}
|
45 |
-
|
46 |
-
var tprop = token;
|
47 |
-
// If it is a property, find out what it is a property of.
|
48 |
-
while (tprop.type == "property") {
|
49 |
-
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
50 |
-
if (tprop.string != ".") return;
|
51 |
-
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
52 |
-
if (!context) var context = [];
|
53 |
-
context.push(tprop);
|
54 |
-
}
|
55 |
-
return {list: getCompletions(token, context, keywords, options),
|
56 |
-
from: Pos(cur.line, token.start),
|
57 |
-
to: Pos(cur.line, token.end)};
|
58 |
-
}
|
59 |
-
|
60 |
-
function javascriptHint(editor, options) {
|
61 |
-
return scriptHint(editor, javascriptKeywords,
|
62 |
-
function (e, cur) {return e.getTokenAt(cur);},
|
63 |
-
options);
|
64 |
-
};
|
65 |
-
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
|
66 |
-
|
67 |
-
function getCoffeeScriptToken(editor, cur) {
|
68 |
-
// This getToken, it is for coffeescript, imitates the behavior of
|
69 |
-
// getTokenAt method in javascript.js, that is, returning "property"
|
70 |
-
// type and treat "." as indepenent token.
|
71 |
-
var token = editor.getTokenAt(cur);
|
72 |
-
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
73 |
-
token.end = token.start;
|
74 |
-
token.string = '.';
|
75 |
-
token.type = "property";
|
76 |
-
}
|
77 |
-
else if (/^\.[\w$_]*$/.test(token.string)) {
|
78 |
-
token.type = "property";
|
79 |
-
token.start++;
|
80 |
-
token.string = token.string.replace(/\./, '');
|
81 |
-
}
|
82 |
-
return token;
|
83 |
-
}
|
84 |
-
|
85 |
-
function coffeescriptHint(editor, options) {
|
86 |
-
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
|
87 |
-
}
|
88 |
-
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
|
89 |
-
|
90 |
-
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
91 |
-
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
92 |
-
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
93 |
-
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
94 |
-
var funcProps = "prototype apply call bind".split(" ");
|
95 |
-
var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
|
96 |
-
"if in instanceof new null return switch throw true try typeof var void while with").split(" ");
|
97 |
-
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
98 |
-
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
99 |
-
|
100 |
-
function getCompletions(token, context, keywords, options) {
|
101 |
-
var found = [], start = token.string, global = options && options.globalScope || window;
|
102 |
-
function maybeAdd(str) {
|
103 |
-
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
|
104 |
-
}
|
105 |
-
function gatherCompletions(obj) {
|
106 |
-
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
107 |
-
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
108 |
-
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
109 |
-
for (var name in obj) maybeAdd(name);
|
110 |
-
}
|
111 |
-
|
112 |
-
if (context && context.length) {
|
113 |
-
// If this is a property, see if it belongs to some object we can
|
114 |
-
// find in the current environment.
|
115 |
-
var obj = context.pop(), base;
|
116 |
-
if (obj.type && obj.type.indexOf("variable") === 0) {
|
117 |
-
if (options && options.additionalContext)
|
118 |
-
base = options.additionalContext[obj.string];
|
119 |
-
if (!options || options.useGlobalScope !== false)
|
120 |
-
base = base || global[obj.string];
|
121 |
-
} else if (obj.type == "string") {
|
122 |
-
base = "";
|
123 |
-
} else if (obj.type == "atom") {
|
124 |
-
base = 1;
|
125 |
-
} else if (obj.type == "function") {
|
126 |
-
if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
127 |
-
(typeof global.jQuery == 'function'))
|
128 |
-
base = global.jQuery();
|
129 |
-
else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
|
130 |
-
base = global._();
|
131 |
-
}
|
132 |
-
while (base != null && context.length)
|
133 |
-
base = base[context.pop().string];
|
134 |
-
if (base != null) gatherCompletions(base);
|
135 |
-
} else {
|
136 |
-
// If not, just look in the global object and any local scope
|
137 |
-
// (reading into JS mode internals to get at the local and global variables)
|
138 |
-
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
139 |
-
for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
|
140 |
-
if (!options || options.useGlobalScope !== false)
|
141 |
-
gatherCompletions(global);
|
142 |
-
forEach(keywords, maybeAdd);
|
143 |
-
}
|
144 |
-
return found;
|
145 |
-
}
|
146 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/show-hint.css
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
.CodeMirror-hints {
|
2 |
-
position: absolute;
|
3 |
-
z-index: 10;
|
4 |
-
overflow: hidden;
|
5 |
-
list-style: none;
|
6 |
-
|
7 |
-
margin: 0;
|
8 |
-
padding: 2px;
|
9 |
-
|
10 |
-
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
11 |
-
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
12 |
-
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
13 |
-
border-radius: 3px;
|
14 |
-
border: 1px solid silver;
|
15 |
-
|
16 |
-
background: white;
|
17 |
-
font-size: 90%;
|
18 |
-
font-family: monospace;
|
19 |
-
|
20 |
-
max-height: 20em;
|
21 |
-
overflow-y: auto;
|
22 |
-
}
|
23 |
-
|
24 |
-
.CodeMirror-hint {
|
25 |
-
margin: 0;
|
26 |
-
padding: 0 4px;
|
27 |
-
border-radius: 2px;
|
28 |
-
max-width: 19em;
|
29 |
-
overflow: hidden;
|
30 |
-
white-space: pre;
|
31 |
-
color: black;
|
32 |
-
cursor: pointer;
|
33 |
-
}
|
34 |
-
|
35 |
-
li.CodeMirror-hint-active {
|
36 |
-
background: #08f;
|
37 |
-
color: white;
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/show-hint.js
DELETED
@@ -1,447 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
|
15 |
-
var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
|
16 |
-
|
17 |
-
// This is the old interface, kept around for now to stay
|
18 |
-
// backwards-compatible.
|
19 |
-
CodeMirror.showHint = function(cm, getHints, options) {
|
20 |
-
if (!getHints) return cm.showHint(options);
|
21 |
-
if (options && options.async) getHints.async = true;
|
22 |
-
var newOpts = {hint: getHints};
|
23 |
-
if (options) for (var prop in options) newOpts[prop] = options[prop];
|
24 |
-
return cm.showHint(newOpts);
|
25 |
-
};
|
26 |
-
|
27 |
-
CodeMirror.defineExtension("showHint", function(options) {
|
28 |
-
options = parseOptions(this, this.getCursor("start"), options);
|
29 |
-
var selections = this.listSelections()
|
30 |
-
if (selections.length > 1) return;
|
31 |
-
// By default, don't allow completion when something is selected.
|
32 |
-
// A hint function can have a `supportsSelection` property to
|
33 |
-
// indicate that it can handle selections.
|
34 |
-
if (this.somethingSelected()) {
|
35 |
-
if (!options.hint.supportsSelection) return;
|
36 |
-
// Don't try with cross-line selections
|
37 |
-
for (var i = 0; i < selections.length; i++)
|
38 |
-
if (selections[i].head.line != selections[i].anchor.line) return;
|
39 |
-
}
|
40 |
-
|
41 |
-
if (this.state.completionActive) this.state.completionActive.close();
|
42 |
-
var completion = this.state.completionActive = new Completion(this, options);
|
43 |
-
if (!completion.options.hint) return;
|
44 |
-
|
45 |
-
CodeMirror.signal(this, "startCompletion", this);
|
46 |
-
completion.update(true);
|
47 |
-
});
|
48 |
-
|
49 |
-
function Completion(cm, options) {
|
50 |
-
this.cm = cm;
|
51 |
-
this.options = options;
|
52 |
-
this.widget = null;
|
53 |
-
this.debounce = 0;
|
54 |
-
this.tick = 0;
|
55 |
-
this.startPos = this.cm.getCursor("start");
|
56 |
-
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
57 |
-
|
58 |
-
var self = this;
|
59 |
-
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
60 |
-
}
|
61 |
-
|
62 |
-
var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
|
63 |
-
return setTimeout(fn, 1000/60);
|
64 |
-
};
|
65 |
-
var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
66 |
-
|
67 |
-
Completion.prototype = {
|
68 |
-
close: function() {
|
69 |
-
if (!this.active()) return;
|
70 |
-
this.cm.state.completionActive = null;
|
71 |
-
this.tick = null;
|
72 |
-
this.cm.off("cursorActivity", this.activityFunc);
|
73 |
-
|
74 |
-
if (this.widget && this.data) CodeMirror.signal(this.data, "close");
|
75 |
-
if (this.widget) this.widget.close();
|
76 |
-
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
77 |
-
},
|
78 |
-
|
79 |
-
active: function() {
|
80 |
-
return this.cm.state.completionActive == this;
|
81 |
-
},
|
82 |
-
|
83 |
-
pick: function(data, i) {
|
84 |
-
var completion = data.list[i];
|
85 |
-
if (completion.hint) completion.hint(this.cm, data, completion);
|
86 |
-
else this.cm.replaceRange(getText(completion), completion.from || data.from,
|
87 |
-
completion.to || data.to, "complete");
|
88 |
-
CodeMirror.signal(data, "pick", completion);
|
89 |
-
this.close();
|
90 |
-
},
|
91 |
-
|
92 |
-
cursorActivity: function() {
|
93 |
-
if (this.debounce) {
|
94 |
-
cancelAnimationFrame(this.debounce);
|
95 |
-
this.debounce = 0;
|
96 |
-
}
|
97 |
-
|
98 |
-
var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
|
99 |
-
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
|
100 |
-
pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
|
101 |
-
(pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
|
102 |
-
this.close();
|
103 |
-
} else {
|
104 |
-
var self = this;
|
105 |
-
this.debounce = requestAnimationFrame(function() {self.update();});
|
106 |
-
if (this.widget) this.widget.disable();
|
107 |
-
}
|
108 |
-
},
|
109 |
-
|
110 |
-
update: function(first) {
|
111 |
-
if (this.tick == null) return;
|
112 |
-
if (!this.options.hint.async) {
|
113 |
-
this.finishUpdate(this.options.hint(this.cm, this.options), first);
|
114 |
-
} else {
|
115 |
-
var myTick = ++this.tick, self = this;
|
116 |
-
this.options.hint(this.cm, function(data) {
|
117 |
-
if (self.tick == myTick) self.finishUpdate(data, first);
|
118 |
-
}, this.options);
|
119 |
-
}
|
120 |
-
},
|
121 |
-
|
122 |
-
finishUpdate: function(data, first) {
|
123 |
-
if (this.data) CodeMirror.signal(this.data, "update");
|
124 |
-
if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
|
125 |
-
this.data = data;
|
126 |
-
|
127 |
-
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
|
128 |
-
if (this.widget) this.widget.close();
|
129 |
-
if (data && data.list.length) {
|
130 |
-
if (picked && data.list.length == 1) {
|
131 |
-
this.pick(data, 0);
|
132 |
-
} else {
|
133 |
-
this.widget = new Widget(this, data);
|
134 |
-
CodeMirror.signal(data, "shown");
|
135 |
-
}
|
136 |
-
}
|
137 |
-
}
|
138 |
-
};
|
139 |
-
|
140 |
-
function parseOptions(cm, pos, options) {
|
141 |
-
var editor = cm.options.hintOptions;
|
142 |
-
var out = {};
|
143 |
-
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
144 |
-
if (editor) for (var prop in editor)
|
145 |
-
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
146 |
-
if (options) for (var prop in options)
|
147 |
-
if (options[prop] !== undefined) out[prop] = options[prop];
|
148 |
-
if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
|
149 |
-
return out;
|
150 |
-
}
|
151 |
-
|
152 |
-
function getText(completion) {
|
153 |
-
if (typeof completion == "string") return completion;
|
154 |
-
else return completion.text;
|
155 |
-
}
|
156 |
-
|
157 |
-
function buildKeyMap(completion, handle) {
|
158 |
-
var baseMap = {
|
159 |
-
Up: function() {handle.moveFocus(-1);},
|
160 |
-
Down: function() {handle.moveFocus(1);},
|
161 |
-
PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
|
162 |
-
PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
|
163 |
-
Home: function() {handle.setFocus(0);},
|
164 |
-
End: function() {handle.setFocus(handle.length - 1);},
|
165 |
-
Enter: handle.pick,
|
166 |
-
Tab: handle.pick,
|
167 |
-
Esc: handle.close
|
168 |
-
};
|
169 |
-
var custom = completion.options.customKeys;
|
170 |
-
var ourMap = custom ? {} : baseMap;
|
171 |
-
function addBinding(key, val) {
|
172 |
-
var bound;
|
173 |
-
if (typeof val != "string")
|
174 |
-
bound = function(cm) { return val(cm, handle); };
|
175 |
-
// This mechanism is deprecated
|
176 |
-
else if (baseMap.hasOwnProperty(val))
|
177 |
-
bound = baseMap[val];
|
178 |
-
else
|
179 |
-
bound = val;
|
180 |
-
ourMap[key] = bound;
|
181 |
-
}
|
182 |
-
if (custom)
|
183 |
-
for (var key in custom) if (custom.hasOwnProperty(key))
|
184 |
-
addBinding(key, custom[key]);
|
185 |
-
var extra = completion.options.extraKeys;
|
186 |
-
if (extra)
|
187 |
-
for (var key in extra) if (extra.hasOwnProperty(key))
|
188 |
-
addBinding(key, extra[key]);
|
189 |
-
return ourMap;
|
190 |
-
}
|
191 |
-
|
192 |
-
function getHintElement(hintsElement, el) {
|
193 |
-
while (el && el != hintsElement) {
|
194 |
-
if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
|
195 |
-
el = el.parentNode;
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
-
function Widget(completion, data) {
|
200 |
-
this.completion = completion;
|
201 |
-
this.data = data;
|
202 |
-
this.picked = false;
|
203 |
-
var widget = this, cm = completion.cm;
|
204 |
-
|
205 |
-
var hints = this.hints = document.createElement("ul");
|
206 |
-
hints.className = "CodeMirror-hints";
|
207 |
-
this.selectedHint = data.selectedHint || 0;
|
208 |
-
|
209 |
-
var completions = data.list;
|
210 |
-
for (var i = 0; i < completions.length; ++i) {
|
211 |
-
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
|
212 |
-
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
|
213 |
-
if (cur.className != null) className = cur.className + " " + className;
|
214 |
-
elt.className = className;
|
215 |
-
if (cur.render) cur.render(elt, data, cur);
|
216 |
-
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
|
217 |
-
elt.hintId = i;
|
218 |
-
}
|
219 |
-
|
220 |
-
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
|
221 |
-
var left = pos.left, top = pos.bottom, below = true;
|
222 |
-
hints.style.left = left + "px";
|
223 |
-
hints.style.top = top + "px";
|
224 |
-
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
225 |
-
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
226 |
-
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
|
227 |
-
(completion.options.container || document.body).appendChild(hints);
|
228 |
-
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
|
229 |
-
if (overlapY > 0) {
|
230 |
-
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
|
231 |
-
if (curTop - height > 0) { // Fits above cursor
|
232 |
-
hints.style.top = (top = pos.top - height) + "px";
|
233 |
-
below = false;
|
234 |
-
} else if (height > winH) {
|
235 |
-
hints.style.height = (winH - 5) + "px";
|
236 |
-
hints.style.top = (top = pos.bottom - box.top) + "px";
|
237 |
-
var cursor = cm.getCursor();
|
238 |
-
if (data.from.ch != cursor.ch) {
|
239 |
-
pos = cm.cursorCoords(cursor);
|
240 |
-
hints.style.left = (left = pos.left) + "px";
|
241 |
-
box = hints.getBoundingClientRect();
|
242 |
-
}
|
243 |
-
}
|
244 |
-
}
|
245 |
-
var overlapX = box.right - winW;
|
246 |
-
if (overlapX > 0) {
|
247 |
-
if (box.right - box.left > winW) {
|
248 |
-
hints.style.width = (winW - 5) + "px";
|
249 |
-
overlapX -= (box.right - box.left) - winW;
|
250 |
-
}
|
251 |
-
hints.style.left = (left = pos.left - overlapX) + "px";
|
252 |
-
}
|
253 |
-
|
254 |
-
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
|
255 |
-
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
|
256 |
-
setFocus: function(n) { widget.changeActive(n); },
|
257 |
-
menuSize: function() { return widget.screenAmount(); },
|
258 |
-
length: completions.length,
|
259 |
-
close: function() { completion.close(); },
|
260 |
-
pick: function() { widget.pick(); },
|
261 |
-
data: data
|
262 |
-
}));
|
263 |
-
|
264 |
-
if (completion.options.closeOnUnfocus) {
|
265 |
-
var closingOnBlur;
|
266 |
-
cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
|
267 |
-
cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
|
268 |
-
}
|
269 |
-
|
270 |
-
var startScroll = cm.getScrollInfo();
|
271 |
-
cm.on("scroll", this.onScroll = function() {
|
272 |
-
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
273 |
-
var newTop = top + startScroll.top - curScroll.top;
|
274 |
-
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
|
275 |
-
if (!below) point += hints.offsetHeight;
|
276 |
-
if (point <= editor.top || point >= editor.bottom) return completion.close();
|
277 |
-
hints.style.top = newTop + "px";
|
278 |
-
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
|
279 |
-
});
|
280 |
-
|
281 |
-
CodeMirror.on(hints, "dblclick", function(e) {
|
282 |
-
var t = getHintElement(hints, e.target || e.srcElement);
|
283 |
-
if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
|
284 |
-
});
|
285 |
-
|
286 |
-
CodeMirror.on(hints, "click", function(e) {
|
287 |
-
var t = getHintElement(hints, e.target || e.srcElement);
|
288 |
-
if (t && t.hintId != null) {
|
289 |
-
widget.changeActive(t.hintId);
|
290 |
-
if (completion.options.completeOnSingleClick) widget.pick();
|
291 |
-
}
|
292 |
-
});
|
293 |
-
|
294 |
-
CodeMirror.on(hints, "mousedown", function() {
|
295 |
-
setTimeout(function(){cm.focus();}, 20);
|
296 |
-
});
|
297 |
-
|
298 |
-
if (completion.options.completeOnSingleClick)
|
299 |
-
CodeMirror.on(hints, "mousemove", function(e) {
|
300 |
-
var elt = getHintElement(hints, e.target || e.srcElement);
|
301 |
-
if (elt && elt.hintId != null)
|
302 |
-
widget.changeActive(elt.hintId);
|
303 |
-
});
|
304 |
-
|
305 |
-
CodeMirror.signal(data, "select", completions[0], hints.firstChild);
|
306 |
-
return true;
|
307 |
-
}
|
308 |
-
|
309 |
-
Widget.prototype = {
|
310 |
-
close: function() {
|
311 |
-
if (this.completion.widget != this) return;
|
312 |
-
this.completion.widget = null;
|
313 |
-
this.hints.parentNode.removeChild(this.hints);
|
314 |
-
this.completion.cm.removeKeyMap(this.keyMap);
|
315 |
-
|
316 |
-
var cm = this.completion.cm;
|
317 |
-
if (this.completion.options.closeOnUnfocus) {
|
318 |
-
cm.off("blur", this.onBlur);
|
319 |
-
cm.off("focus", this.onFocus);
|
320 |
-
}
|
321 |
-
cm.off("scroll", this.onScroll);
|
322 |
-
},
|
323 |
-
|
324 |
-
disable: function() {
|
325 |
-
this.completion.cm.removeKeyMap(this.keyMap);
|
326 |
-
var widget = this;
|
327 |
-
this.keyMap = {Enter: function() { widget.picked = true; }};
|
328 |
-
this.completion.cm.addKeyMap(this.keyMap);
|
329 |
-
},
|
330 |
-
|
331 |
-
pick: function() {
|
332 |
-
this.completion.pick(this.data, this.selectedHint);
|
333 |
-
},
|
334 |
-
|
335 |
-
changeActive: function(i, avoidWrap) {
|
336 |
-
if (i >= this.data.list.length)
|
337 |
-
i = avoidWrap ? this.data.list.length - 1 : 0;
|
338 |
-
else if (i < 0)
|
339 |
-
i = avoidWrap ? 0 : this.data.list.length - 1;
|
340 |
-
if (this.selectedHint == i) return;
|
341 |
-
var node = this.hints.childNodes[this.selectedHint];
|
342 |
-
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
|
343 |
-
node = this.hints.childNodes[this.selectedHint = i];
|
344 |
-
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
|
345 |
-
if (node.offsetTop < this.hints.scrollTop)
|
346 |
-
this.hints.scrollTop = node.offsetTop - 3;
|
347 |
-
else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
|
348 |
-
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
|
349 |
-
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
|
350 |
-
},
|
351 |
-
|
352 |
-
screenAmount: function() {
|
353 |
-
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
|
354 |
-
}
|
355 |
-
};
|
356 |
-
|
357 |
-
function applicableHelpers(cm, helpers) {
|
358 |
-
if (!cm.somethingSelected()) return helpers
|
359 |
-
var result = []
|
360 |
-
for (var i = 0; i < helpers.length; i++)
|
361 |
-
if (helpers[i].supportsSelection) result.push(helpers[i])
|
362 |
-
return result
|
363 |
-
}
|
364 |
-
|
365 |
-
function resolveAutoHints(cm, pos) {
|
366 |
-
var helpers = cm.getHelpers(pos, "hint"), words
|
367 |
-
if (helpers.length) {
|
368 |
-
var async = false, resolved
|
369 |
-
for (var i = 0; i < helpers.length; i++) if (helpers[i].async) async = true
|
370 |
-
if (async) {
|
371 |
-
resolved = function(cm, callback, options) {
|
372 |
-
var app = applicableHelpers(cm, helpers)
|
373 |
-
function run(i, result) {
|
374 |
-
if (i == app.length) return callback(null)
|
375 |
-
var helper = app[i]
|
376 |
-
if (helper.async) {
|
377 |
-
helper(cm, function(result) {
|
378 |
-
if (result) callback(result)
|
379 |
-
else run(i + 1)
|
380 |
-
}, options)
|
381 |
-
} else {
|
382 |
-
var result = helper(cm, options)
|
383 |
-
if (result) callback(result)
|
384 |
-
else run(i + 1)
|
385 |
-
}
|
386 |
-
}
|
387 |
-
run(0)
|
388 |
-
}
|
389 |
-
resolved.async = true
|
390 |
-
} else {
|
391 |
-
resolved = function(cm, options) {
|
392 |
-
var app = applicableHelpers(cm, helpers)
|
393 |
-
for (var i = 0; i < app.length; i++) {
|
394 |
-
var cur = app[i](cm, options)
|
395 |
-
if (cur && cur.list.length) return cur
|
396 |
-
}
|
397 |
-
}
|
398 |
-
}
|
399 |
-
resolved.supportsSelection = true
|
400 |
-
return resolved
|
401 |
-
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
402 |
-
return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
|
403 |
-
} else if (CodeMirror.hint.anyword) {
|
404 |
-
return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
|
405 |
-
} else {
|
406 |
-
return function() {}
|
407 |
-
}
|
408 |
-
}
|
409 |
-
|
410 |
-
CodeMirror.registerHelper("hint", "auto", {
|
411 |
-
resolve: resolveAutoHints
|
412 |
-
});
|
413 |
-
|
414 |
-
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
415 |
-
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
416 |
-
var to = CodeMirror.Pos(cur.line, token.end);
|
417 |
-
if (token.string && /\w/.test(token.string[token.string.length - 1])) {
|
418 |
-
var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
|
419 |
-
} else {
|
420 |
-
var term = "", from = to;
|
421 |
-
}
|
422 |
-
var found = [];
|
423 |
-
for (var i = 0; i < options.words.length; i++) {
|
424 |
-
var word = options.words[i];
|
425 |
-
if (word.slice(0, term.length) == term)
|
426 |
-
found.push(word);
|
427 |
-
}
|
428 |
-
|
429 |
-
if (found.length) return {list: found, from: from, to: to};
|
430 |
-
});
|
431 |
-
|
432 |
-
CodeMirror.commands.autocomplete = CodeMirror.showHint;
|
433 |
-
|
434 |
-
var defaultOptions = {
|
435 |
-
hint: CodeMirror.hint.auto,
|
436 |
-
completeSingle: true,
|
437 |
-
alignWithWord: true,
|
438 |
-
closeCharacters: /[\s()\[\]{};:>,]/,
|
439 |
-
closeOnUnfocus: true,
|
440 |
-
completeOnSingleClick: true,
|
441 |
-
container: null,
|
442 |
-
customKeys: null,
|
443 |
-
extraKeys: null
|
444 |
-
};
|
445 |
-
|
446 |
-
CodeMirror.defineOption("hintOptions", null);
|
447 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/sql-hint.js
DELETED
@@ -1,254 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"), require("../../mode/sql/sql"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror", "../../mode/sql/sql"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var tables;
|
15 |
-
var defaultTable;
|
16 |
-
var keywords;
|
17 |
-
var CONS = {
|
18 |
-
QUERY_DIV: ";",
|
19 |
-
ALIAS_KEYWORD: "AS"
|
20 |
-
};
|
21 |
-
var Pos = CodeMirror.Pos;
|
22 |
-
|
23 |
-
function getKeywords(editor) {
|
24 |
-
var mode = editor.doc.modeOption;
|
25 |
-
if (mode === "sql") mode = "text/x-sql";
|
26 |
-
return CodeMirror.resolveMode(mode).keywords;
|
27 |
-
}
|
28 |
-
|
29 |
-
function getText(item) {
|
30 |
-
return typeof item == "string" ? item : item.text;
|
31 |
-
}
|
32 |
-
|
33 |
-
function getItem(list, item) {
|
34 |
-
if (!list.slice) return list[item];
|
35 |
-
for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
|
36 |
-
return list[i];
|
37 |
-
}
|
38 |
-
|
39 |
-
function shallowClone(object) {
|
40 |
-
var result = {};
|
41 |
-
for (var key in object) if (object.hasOwnProperty(key))
|
42 |
-
result[key] = object[key];
|
43 |
-
return result;
|
44 |
-
}
|
45 |
-
|
46 |
-
function match(string, word) {
|
47 |
-
var len = string.length;
|
48 |
-
var sub = getText(word).substr(0, len);
|
49 |
-
return string.toUpperCase() === sub.toUpperCase();
|
50 |
-
}
|
51 |
-
|
52 |
-
function addMatches(result, search, wordlist, formatter) {
|
53 |
-
for (var word in wordlist) {
|
54 |
-
if (!wordlist.hasOwnProperty(word)) continue;
|
55 |
-
if (wordlist.slice) word = wordlist[word];
|
56 |
-
|
57 |
-
if (match(search, word)) result.push(formatter(word));
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
function cleanName(name) {
|
62 |
-
// Get rid name from backticks(`) and preceding dot(.)
|
63 |
-
if (name.charAt(0) == ".") {
|
64 |
-
name = name.substr(1);
|
65 |
-
}
|
66 |
-
return name.replace(/`/g, "");
|
67 |
-
}
|
68 |
-
|
69 |
-
function insertBackticks(name) {
|
70 |
-
var nameParts = getText(name).split(".");
|
71 |
-
for (var i = 0; i < nameParts.length; i++)
|
72 |
-
nameParts[i] = "`" + nameParts[i] + "`";
|
73 |
-
var escaped = nameParts.join(".");
|
74 |
-
if (typeof name == "string") return escaped;
|
75 |
-
name = shallowClone(name);
|
76 |
-
name.text = escaped;
|
77 |
-
return name;
|
78 |
-
}
|
79 |
-
|
80 |
-
function nameCompletion(cur, token, result, editor) {
|
81 |
-
// Try to complete table, colunm names and return start position of completion
|
82 |
-
var useBacktick = false;
|
83 |
-
var nameParts = [];
|
84 |
-
var start = token.start;
|
85 |
-
var cont = true;
|
86 |
-
while (cont) {
|
87 |
-
cont = (token.string.charAt(0) == ".");
|
88 |
-
useBacktick = useBacktick || (token.string.charAt(0) == "`");
|
89 |
-
|
90 |
-
start = token.start;
|
91 |
-
nameParts.unshift(cleanName(token.string));
|
92 |
-
|
93 |
-
token = editor.getTokenAt(Pos(cur.line, token.start));
|
94 |
-
if (token.string == ".") {
|
95 |
-
cont = true;
|
96 |
-
token = editor.getTokenAt(Pos(cur.line, token.start));
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
// Try to complete table names
|
101 |
-
var string = nameParts.join(".");
|
102 |
-
addMatches(result, string, tables, function(w) {
|
103 |
-
return useBacktick ? insertBackticks(w) : w;
|
104 |
-
});
|
105 |
-
|
106 |
-
// Try to complete columns from defaultTable
|
107 |
-
addMatches(result, string, defaultTable, function(w) {
|
108 |
-
return useBacktick ? insertBackticks(w) : w;
|
109 |
-
});
|
110 |
-
|
111 |
-
// Try to complete columns
|
112 |
-
string = nameParts.pop();
|
113 |
-
var table = nameParts.join(".");
|
114 |
-
|
115 |
-
var alias = false;
|
116 |
-
var aliasTable = table;
|
117 |
-
// Check if table is available. If not, find table by Alias
|
118 |
-
if (!getItem(tables, table)) {
|
119 |
-
var oldTable = table;
|
120 |
-
table = findTableByAlias(table, editor);
|
121 |
-
if (table !== oldTable) alias = true;
|
122 |
-
}
|
123 |
-
|
124 |
-
var columns = getItem(tables, table);
|
125 |
-
if (columns && columns.columns)
|
126 |
-
columns = columns.columns;
|
127 |
-
|
128 |
-
if (columns) {
|
129 |
-
addMatches(result, string, columns, function(w) {
|
130 |
-
var tableInsert = table;
|
131 |
-
if (alias == true) tableInsert = aliasTable;
|
132 |
-
if (typeof w == "string") {
|
133 |
-
w = tableInsert + "." + w;
|
134 |
-
} else {
|
135 |
-
w = shallowClone(w);
|
136 |
-
w.text = tableInsert + "." + w.text;
|
137 |
-
}
|
138 |
-
return useBacktick ? insertBackticks(w) : w;
|
139 |
-
});
|
140 |
-
}
|
141 |
-
|
142 |
-
return start;
|
143 |
-
}
|
144 |
-
|
145 |
-
function eachWord(lineText, f) {
|
146 |
-
if (!lineText) return;
|
147 |
-
var excepted = /[,;]/g;
|
148 |
-
var words = lineText.split(" ");
|
149 |
-
for (var i = 0; i < words.length; i++) {
|
150 |
-
f(words[i]?words[i].replace(excepted, '') : '');
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
function convertCurToNumber(cur) {
|
155 |
-
// max characters of a line is 999,999.
|
156 |
-
return cur.line + cur.ch / Math.pow(10, 6);
|
157 |
-
}
|
158 |
-
|
159 |
-
function convertNumberToCur(num) {
|
160 |
-
return Pos(Math.floor(num), +num.toString().split('.').pop());
|
161 |
-
}
|
162 |
-
|
163 |
-
function findTableByAlias(alias, editor) {
|
164 |
-
var doc = editor.doc;
|
165 |
-
var fullQuery = doc.getValue();
|
166 |
-
var aliasUpperCase = alias.toUpperCase();
|
167 |
-
var previousWord = "";
|
168 |
-
var table = "";
|
169 |
-
var separator = [];
|
170 |
-
var validRange = {
|
171 |
-
start: Pos(0, 0),
|
172 |
-
end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length)
|
173 |
-
};
|
174 |
-
|
175 |
-
//add separator
|
176 |
-
var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV);
|
177 |
-
while(indexOfSeparator != -1) {
|
178 |
-
separator.push(doc.posFromIndex(indexOfSeparator));
|
179 |
-
indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1);
|
180 |
-
}
|
181 |
-
separator.unshift(Pos(0, 0));
|
182 |
-
separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
|
183 |
-
|
184 |
-
//find valid range
|
185 |
-
var prevItem = 0;
|
186 |
-
var current = convertCurToNumber(editor.getCursor());
|
187 |
-
for (var i=0; i< separator.length; i++) {
|
188 |
-
var _v = convertCurToNumber(separator[i]);
|
189 |
-
if (current > prevItem && current <= _v) {
|
190 |
-
validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
|
191 |
-
break;
|
192 |
-
}
|
193 |
-
prevItem = _v;
|
194 |
-
}
|
195 |
-
|
196 |
-
var query = doc.getRange(validRange.start, validRange.end, false);
|
197 |
-
|
198 |
-
for (var i = 0; i < query.length; i++) {
|
199 |
-
var lineText = query[i];
|
200 |
-
eachWord(lineText, function(word) {
|
201 |
-
var wordUpperCase = word.toUpperCase();
|
202 |
-
if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
|
203 |
-
table = previousWord;
|
204 |
-
if (wordUpperCase !== CONS.ALIAS_KEYWORD)
|
205 |
-
previousWord = word;
|
206 |
-
});
|
207 |
-
if (table) break;
|
208 |
-
}
|
209 |
-
return table;
|
210 |
-
}
|
211 |
-
|
212 |
-
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
213 |
-
tables = (options && options.tables) || {};
|
214 |
-
var defaultTableName = options && options.defaultTable;
|
215 |
-
var disableKeywords = options && options.disableKeywords;
|
216 |
-
defaultTable = defaultTableName && getItem(tables, defaultTableName);
|
217 |
-
keywords = keywords || getKeywords(editor);
|
218 |
-
|
219 |
-
if (defaultTableName && !defaultTable)
|
220 |
-
defaultTable = findTableByAlias(defaultTableName, editor);
|
221 |
-
|
222 |
-
defaultTable = defaultTable || [];
|
223 |
-
|
224 |
-
if (defaultTable.columns)
|
225 |
-
defaultTable = defaultTable.columns;
|
226 |
-
|
227 |
-
var cur = editor.getCursor();
|
228 |
-
var result = [];
|
229 |
-
var token = editor.getTokenAt(cur), start, end, search;
|
230 |
-
if (token.end > cur.ch) {
|
231 |
-
token.end = cur.ch;
|
232 |
-
token.string = token.string.slice(0, cur.ch - token.start);
|
233 |
-
}
|
234 |
-
|
235 |
-
if (token.string.match(/^[.`\w@]\w*$/)) {
|
236 |
-
search = token.string;
|
237 |
-
start = token.start;
|
238 |
-
end = token.end;
|
239 |
-
} else {
|
240 |
-
start = end = cur.ch;
|
241 |
-
search = "";
|
242 |
-
}
|
243 |
-
if (search.charAt(0) == "." || search.charAt(0) == "`") {
|
244 |
-
start = nameCompletion(cur, token, result, editor);
|
245 |
-
} else {
|
246 |
-
addMatches(result, search, tables, function(w) {return w;});
|
247 |
-
addMatches(result, search, defaultTable, function(w) {return w;});
|
248 |
-
if (!disableKeywords)
|
249 |
-
addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
|
250 |
-
}
|
251 |
-
|
252 |
-
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
|
253 |
-
});
|
254 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/hint/xml-hint.js
DELETED
@@ -1,110 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var Pos = CodeMirror.Pos;
|
15 |
-
|
16 |
-
function getHints(cm, options) {
|
17 |
-
var tags = options && options.schemaInfo;
|
18 |
-
var quote = (options && options.quoteChar) || '"';
|
19 |
-
if (!tags) return;
|
20 |
-
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
21 |
-
if (token.end > cur.ch) {
|
22 |
-
token.end = cur.ch;
|
23 |
-
token.string = token.string.slice(0, cur.ch - token.start);
|
24 |
-
}
|
25 |
-
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
26 |
-
if (inner.mode.name != "xml") return;
|
27 |
-
var result = [], replaceToken = false, prefix;
|
28 |
-
var tag = /\btag\b/.test(token.type) && !/>$/.test(token.string);
|
29 |
-
var tagName = tag && /^\w/.test(token.string), tagStart;
|
30 |
-
|
31 |
-
if (tagName) {
|
32 |
-
var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start);
|
33 |
-
var tagType = /<\/$/.test(before) ? "close" : /<$/.test(before) ? "open" : null;
|
34 |
-
if (tagType) tagStart = token.start - (tagType == "close" ? 2 : 1);
|
35 |
-
} else if (tag && token.string == "<") {
|
36 |
-
tagType = "open";
|
37 |
-
} else if (tag && token.string == "</") {
|
38 |
-
tagType = "close";
|
39 |
-
}
|
40 |
-
|
41 |
-
if (!tag && !inner.state.tagName || tagType) {
|
42 |
-
if (tagName)
|
43 |
-
prefix = token.string;
|
44 |
-
replaceToken = tagType;
|
45 |
-
var cx = inner.state.context, curTag = cx && tags[cx.tagName];
|
46 |
-
var childList = cx ? curTag && curTag.children : tags["!top"];
|
47 |
-
if (childList && tagType != "close") {
|
48 |
-
for (var i = 0; i < childList.length; ++i) if (!prefix || childList[i].lastIndexOf(prefix, 0) == 0)
|
49 |
-
result.push("<" + childList[i]);
|
50 |
-
} else if (tagType != "close") {
|
51 |
-
for (var name in tags)
|
52 |
-
if (tags.hasOwnProperty(name) && name != "!top" && name != "!attrs" && (!prefix || name.lastIndexOf(prefix, 0) == 0))
|
53 |
-
result.push("<" + name);
|
54 |
-
}
|
55 |
-
if (cx && (!prefix || tagType == "close" && cx.tagName.lastIndexOf(prefix, 0) == 0))
|
56 |
-
result.push("</" + cx.tagName + ">");
|
57 |
-
} else {
|
58 |
-
// Attribute completion
|
59 |
-
var curTag = tags[inner.state.tagName], attrs = curTag && curTag.attrs;
|
60 |
-
var globalAttrs = tags["!attrs"];
|
61 |
-
if (!attrs && !globalAttrs) return;
|
62 |
-
if (!attrs) {
|
63 |
-
attrs = globalAttrs;
|
64 |
-
} else if (globalAttrs) { // Combine tag-local and global attributes
|
65 |
-
var set = {};
|
66 |
-
for (var nm in globalAttrs) if (globalAttrs.hasOwnProperty(nm)) set[nm] = globalAttrs[nm];
|
67 |
-
for (var nm in attrs) if (attrs.hasOwnProperty(nm)) set[nm] = attrs[nm];
|
68 |
-
attrs = set;
|
69 |
-
}
|
70 |
-
if (token.type == "string" || token.string == "=") { // A value
|
71 |
-
var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)),
|
72 |
-
Pos(cur.line, token.type == "string" ? token.start : token.end));
|
73 |
-
var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues;
|
74 |
-
if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return;
|
75 |
-
if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget
|
76 |
-
if (token.type == "string") {
|
77 |
-
prefix = token.string;
|
78 |
-
var n = 0;
|
79 |
-
if (/['"]/.test(token.string.charAt(0))) {
|
80 |
-
quote = token.string.charAt(0);
|
81 |
-
prefix = token.string.slice(1);
|
82 |
-
n++;
|
83 |
-
}
|
84 |
-
var len = token.string.length;
|
85 |
-
if (/['"]/.test(token.string.charAt(len - 1))) {
|
86 |
-
quote = token.string.charAt(len - 1);
|
87 |
-
prefix = token.string.substr(n, len - 2);
|
88 |
-
}
|
89 |
-
replaceToken = true;
|
90 |
-
}
|
91 |
-
for (var i = 0; i < atValues.length; ++i) if (!prefix || atValues[i].lastIndexOf(prefix, 0) == 0)
|
92 |
-
result.push(quote + atValues[i] + quote);
|
93 |
-
} else { // An attribute name
|
94 |
-
if (token.type == "attribute") {
|
95 |
-
prefix = token.string;
|
96 |
-
replaceToken = true;
|
97 |
-
}
|
98 |
-
for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || attr.lastIndexOf(prefix, 0) == 0))
|
99 |
-
result.push(attr);
|
100 |
-
}
|
101 |
-
}
|
102 |
-
return {
|
103 |
-
list: result,
|
104 |
-
from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur,
|
105 |
-
to: replaceToken ? Pos(cur.line, token.end) : cur
|
106 |
-
};
|
107 |
-
}
|
108 |
-
|
109 |
-
CodeMirror.registerHelper("hint", "xml", getHints);
|
110 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/coffeescript-lint.js
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
|
5 |
-
|
6 |
-
// declare global: coffeelint
|
7 |
-
|
8 |
-
(function(mod) {
|
9 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
-
mod(require("../../lib/codemirror"));
|
11 |
-
else if (typeof define == "function" && define.amd) // AMD
|
12 |
-
define(["../../lib/codemirror"], mod);
|
13 |
-
else // Plain browser env
|
14 |
-
mod(CodeMirror);
|
15 |
-
})(function(CodeMirror) {
|
16 |
-
"use strict";
|
17 |
-
|
18 |
-
CodeMirror.registerHelper("lint", "coffeescript", function(text) {
|
19 |
-
var found = [];
|
20 |
-
var parseError = function(err) {
|
21 |
-
var loc = err.lineNumber;
|
22 |
-
found.push({from: CodeMirror.Pos(loc-1, 0),
|
23 |
-
to: CodeMirror.Pos(loc, 0),
|
24 |
-
severity: err.level,
|
25 |
-
message: err.message});
|
26 |
-
};
|
27 |
-
try {
|
28 |
-
var res = coffeelint.lint(text);
|
29 |
-
for(var i = 0; i < res.length; i++) {
|
30 |
-
parseError(res[i]);
|
31 |
-
}
|
32 |
-
} catch(e) {
|
33 |
-
found.push({from: CodeMirror.Pos(e.location.first_line, 0),
|
34 |
-
to: CodeMirror.Pos(e.location.last_line, e.location.last_column),
|
35 |
-
severity: 'error',
|
36 |
-
message: e.message});
|
37 |
-
}
|
38 |
-
return found;
|
39 |
-
});
|
40 |
-
|
41 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/css-lint.js
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Depends on csslint.js from https://github.com/stubbornella/csslint
|
5 |
-
|
6 |
-
// declare global: CSSLint
|
7 |
-
|
8 |
-
(function(mod) {
|
9 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
-
mod(require("../../lib/codemirror"));
|
11 |
-
else if (typeof define == "function" && define.amd) // AMD
|
12 |
-
define(["../../lib/codemirror"], mod);
|
13 |
-
else // Plain browser env
|
14 |
-
mod(CodeMirror);
|
15 |
-
})(function(CodeMirror) {
|
16 |
-
"use strict";
|
17 |
-
|
18 |
-
CodeMirror.registerHelper("lint", "css", function(text) {
|
19 |
-
var found = [];
|
20 |
-
if (!window.CSSLint) return found;
|
21 |
-
var results = CSSLint.verify(text), messages = results.messages, message = null;
|
22 |
-
for ( var i = 0; i < messages.length; i++) {
|
23 |
-
message = messages[i];
|
24 |
-
var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
|
25 |
-
found.push({
|
26 |
-
from: CodeMirror.Pos(startLine, startCol),
|
27 |
-
to: CodeMirror.Pos(endLine, endCol),
|
28 |
-
message: message.message,
|
29 |
-
severity : message.type
|
30 |
-
});
|
31 |
-
}
|
32 |
-
return found;
|
33 |
-
});
|
34 |
-
|
35 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/html-lint.js
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
|
5 |
-
|
6 |
-
// declare global: HTMLHint
|
7 |
-
|
8 |
-
(function(mod) {
|
9 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
-
mod(require("../../lib/codemirror"), require("htmlhint"));
|
11 |
-
else if (typeof define == "function" && define.amd) // AMD
|
12 |
-
define(["../../lib/codemirror", "htmlhint"], mod);
|
13 |
-
else // Plain browser env
|
14 |
-
mod(CodeMirror);
|
15 |
-
})(function(CodeMirror) {
|
16 |
-
"use strict";
|
17 |
-
|
18 |
-
var defaultRules = {
|
19 |
-
"tagname-lowercase": true,
|
20 |
-
"attr-lowercase": true,
|
21 |
-
"attr-value-double-quotes": true,
|
22 |
-
"doctype-first": false,
|
23 |
-
"tag-pair": true,
|
24 |
-
"spec-char-escape": true,
|
25 |
-
"id-unique": true,
|
26 |
-
"src-not-empty": true,
|
27 |
-
"attr-no-duplication": true
|
28 |
-
};
|
29 |
-
|
30 |
-
CodeMirror.registerHelper("lint", "html", function(text, options) {
|
31 |
-
var found = [];
|
32 |
-
if (!window.HTMLHint) return found;
|
33 |
-
var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
|
34 |
-
for (var i = 0; i < messages.length; i++) {
|
35 |
-
var message = messages[i];
|
36 |
-
var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
|
37 |
-
found.push({
|
38 |
-
from: CodeMirror.Pos(startLine, startCol),
|
39 |
-
to: CodeMirror.Pos(endLine, endCol),
|
40 |
-
message: message.message,
|
41 |
-
severity : message.type
|
42 |
-
});
|
43 |
-
}
|
44 |
-
return found;
|
45 |
-
});
|
46 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/javascript-lint.js
DELETED
@@ -1,136 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
// declare global: JSHINT
|
14 |
-
|
15 |
-
var bogus = [ "Dangerous comment" ];
|
16 |
-
|
17 |
-
var warnings = [ [ "Expected '{'",
|
18 |
-
"Statement body should be inside '{ }' braces." ] ];
|
19 |
-
|
20 |
-
var errors = [ "Missing semicolon", "Extra comma", "Missing property name",
|
21 |
-
"Unmatched ", " and instead saw", " is not defined",
|
22 |
-
"Unclosed string", "Stopping, unable to continue" ];
|
23 |
-
|
24 |
-
function validator(text, options) {
|
25 |
-
if (!window.JSHINT) return [];
|
26 |
-
JSHINT(text, options, options.globals);
|
27 |
-
var errors = JSHINT.data().errors, result = [];
|
28 |
-
if (errors) parseErrors(errors, result);
|
29 |
-
return result;
|
30 |
-
}
|
31 |
-
|
32 |
-
CodeMirror.registerHelper("lint", "javascript", validator);
|
33 |
-
|
34 |
-
function cleanup(error) {
|
35 |
-
// All problems are warnings by default
|
36 |
-
fixWith(error, warnings, "warning", true);
|
37 |
-
fixWith(error, errors, "error");
|
38 |
-
|
39 |
-
return isBogus(error) ? null : error;
|
40 |
-
}
|
41 |
-
|
42 |
-
function fixWith(error, fixes, severity, force) {
|
43 |
-
var description, fix, find, replace, found;
|
44 |
-
|
45 |
-
description = error.description;
|
46 |
-
|
47 |
-
for ( var i = 0; i < fixes.length; i++) {
|
48 |
-
fix = fixes[i];
|
49 |
-
find = (typeof fix === "string" ? fix : fix[0]);
|
50 |
-
replace = (typeof fix === "string" ? null : fix[1]);
|
51 |
-
found = description.indexOf(find) !== -1;
|
52 |
-
|
53 |
-
if (force || found) {
|
54 |
-
error.severity = severity;
|
55 |
-
}
|
56 |
-
if (found && replace) {
|
57 |
-
error.description = replace;
|
58 |
-
}
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
function isBogus(error) {
|
63 |
-
var description = error.description;
|
64 |
-
for ( var i = 0; i < bogus.length; i++) {
|
65 |
-
if (description.indexOf(bogus[i]) !== -1) {
|
66 |
-
return true;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
return false;
|
70 |
-
}
|
71 |
-
|
72 |
-
function parseErrors(errors, output) {
|
73 |
-
for ( var i = 0; i < errors.length; i++) {
|
74 |
-
var error = errors[i];
|
75 |
-
if (error) {
|
76 |
-
var linetabpositions, index;
|
77 |
-
|
78 |
-
linetabpositions = [];
|
79 |
-
|
80 |
-
// This next block is to fix a problem in jshint. Jshint
|
81 |
-
// replaces
|
82 |
-
// all tabs with spaces then performs some checks. The error
|
83 |
-
// positions (character/space) are then reported incorrectly,
|
84 |
-
// not taking the replacement step into account. Here we look
|
85 |
-
// at the evidence line and try to adjust the character position
|
86 |
-
// to the correct value.
|
87 |
-
if (error.evidence) {
|
88 |
-
// Tab positions are computed once per line and cached
|
89 |
-
var tabpositions = linetabpositions[error.line];
|
90 |
-
if (!tabpositions) {
|
91 |
-
var evidence = error.evidence;
|
92 |
-
tabpositions = [];
|
93 |
-
// ugggh phantomjs does not like this
|
94 |
-
// forEachChar(evidence, function(item, index) {
|
95 |
-
Array.prototype.forEach.call(evidence, function(item,
|
96 |
-
index) {
|
97 |
-
if (item === '\t') {
|
98 |
-
// First col is 1 (not 0) to match error
|
99 |
-
// positions
|
100 |
-
tabpositions.push(index + 1);
|
101 |
-
}
|
102 |
-
});
|
103 |
-
linetabpositions[error.line] = tabpositions;
|
104 |
-
}
|
105 |
-
if (tabpositions.length > 0) {
|
106 |
-
var pos = error.character;
|
107 |
-
tabpositions.forEach(function(tabposition) {
|
108 |
-
if (pos > tabposition) pos -= 1;
|
109 |
-
});
|
110 |
-
error.character = pos;
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
var start = error.character - 1, end = start + 1;
|
115 |
-
if (error.evidence) {
|
116 |
-
index = error.evidence.substring(start).search(/.\b/);
|
117 |
-
if (index > -1) {
|
118 |
-
end += index;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
// Convert to format expected by validation service
|
123 |
-
error.description = error.reason;// + "(jshint)";
|
124 |
-
error.start = error.character;
|
125 |
-
error.end = end;
|
126 |
-
error = cleanup(error);
|
127 |
-
|
128 |
-
if (error)
|
129 |
-
output.push({message: error.description,
|
130 |
-
severity: error.severity,
|
131 |
-
from: CodeMirror.Pos(error.line - 1, start),
|
132 |
-
to: CodeMirror.Pos(error.line - 1, end)});
|
133 |
-
}
|
134 |
-
}
|
135 |
-
}
|
136 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/json-lint.js
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
|
5 |
-
|
6 |
-
// declare global: jsonlint
|
7 |
-
|
8 |
-
(function(mod) {
|
9 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
-
mod(require("../../lib/codemirror"));
|
11 |
-
else if (typeof define == "function" && define.amd) // AMD
|
12 |
-
define(["../../lib/codemirror"], mod);
|
13 |
-
else // Plain browser env
|
14 |
-
mod(CodeMirror);
|
15 |
-
})(function(CodeMirror) {
|
16 |
-
"use strict";
|
17 |
-
|
18 |
-
CodeMirror.registerHelper("lint", "json", function(text) {
|
19 |
-
var found = [];
|
20 |
-
jsonlint.parseError = function(str, hash) {
|
21 |
-
var loc = hash.loc;
|
22 |
-
found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
|
23 |
-
to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
|
24 |
-
message: str});
|
25 |
-
};
|
26 |
-
try { jsonlint.parse(text); }
|
27 |
-
catch(e) {}
|
28 |
-
return found;
|
29 |
-
});
|
30 |
-
|
31 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/lint.css
DELETED
@@ -1,73 +0,0 @@
|
|
1 |
-
/* The lint marker gutter */
|
2 |
-
.CodeMirror-lint-markers {
|
3 |
-
width: 16px;
|
4 |
-
}
|
5 |
-
|
6 |
-
.CodeMirror-lint-tooltip {
|
7 |
-
background-color: infobackground;
|
8 |
-
border: 1px solid black;
|
9 |
-
border-radius: 4px 4px 4px 4px;
|
10 |
-
color: infotext;
|
11 |
-
font-family: monospace;
|
12 |
-
font-size: 10pt;
|
13 |
-
overflow: hidden;
|
14 |
-
padding: 2px 5px;
|
15 |
-
position: fixed;
|
16 |
-
white-space: pre;
|
17 |
-
white-space: pre-wrap;
|
18 |
-
z-index: 100;
|
19 |
-
max-width: 600px;
|
20 |
-
opacity: 0;
|
21 |
-
transition: opacity .4s;
|
22 |
-
-moz-transition: opacity .4s;
|
23 |
-
-webkit-transition: opacity .4s;
|
24 |
-
-o-transition: opacity .4s;
|
25 |
-
-ms-transition: opacity .4s;
|
26 |
-
}
|
27 |
-
|
28 |
-
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning {
|
29 |
-
background-position: left bottom;
|
30 |
-
background-repeat: repeat-x;
|
31 |
-
}
|
32 |
-
|
33 |
-
.CodeMirror-lint-mark-error {
|
34 |
-
background-image:
|
35 |
-
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==")
|
36 |
-
;
|
37 |
-
}
|
38 |
-
|
39 |
-
.CodeMirror-lint-mark-warning {
|
40 |
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
41 |
-
}
|
42 |
-
|
43 |
-
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning {
|
44 |
-
background-position: center center;
|
45 |
-
background-repeat: no-repeat;
|
46 |
-
cursor: pointer;
|
47 |
-
display: inline-block;
|
48 |
-
height: 16px;
|
49 |
-
width: 16px;
|
50 |
-
vertical-align: middle;
|
51 |
-
position: relative;
|
52 |
-
}
|
53 |
-
|
54 |
-
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning {
|
55 |
-
padding-left: 18px;
|
56 |
-
background-position: top left;
|
57 |
-
background-repeat: no-repeat;
|
58 |
-
}
|
59 |
-
|
60 |
-
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
|
61 |
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
|
62 |
-
}
|
63 |
-
|
64 |
-
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
|
65 |
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
|
66 |
-
}
|
67 |
-
|
68 |
-
.CodeMirror-lint-marker-multiple {
|
69 |
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
|
70 |
-
background-repeat: no-repeat;
|
71 |
-
background-position: right bottom;
|
72 |
-
width: 100%; height: 100%;
|
73 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/lint.js
DELETED
@@ -1,231 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
var GUTTER_ID = "CodeMirror-lint-markers";
|
14 |
-
|
15 |
-
function showTooltip(e, content) {
|
16 |
-
var tt = document.createElement("div");
|
17 |
-
tt.className = "CodeMirror-lint-tooltip";
|
18 |
-
tt.appendChild(content.cloneNode(true));
|
19 |
-
document.body.appendChild(tt);
|
20 |
-
|
21 |
-
function position(e) {
|
22 |
-
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
|
23 |
-
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
|
24 |
-
tt.style.left = (e.clientX + 5) + "px";
|
25 |
-
}
|
26 |
-
CodeMirror.on(document, "mousemove", position);
|
27 |
-
position(e);
|
28 |
-
if (tt.style.opacity != null) tt.style.opacity = 1;
|
29 |
-
return tt;
|
30 |
-
}
|
31 |
-
function rm(elt) {
|
32 |
-
if (elt.parentNode) elt.parentNode.removeChild(elt);
|
33 |
-
}
|
34 |
-
function hideTooltip(tt) {
|
35 |
-
if (!tt.parentNode) return;
|
36 |
-
if (tt.style.opacity == null) rm(tt);
|
37 |
-
tt.style.opacity = 0;
|
38 |
-
setTimeout(function() { rm(tt); }, 600);
|
39 |
-
}
|
40 |
-
|
41 |
-
function showTooltipFor(e, content, node) {
|
42 |
-
var tooltip = showTooltip(e, content);
|
43 |
-
function hide() {
|
44 |
-
CodeMirror.off(node, "mouseout", hide);
|
45 |
-
if (tooltip) { hideTooltip(tooltip); tooltip = null; }
|
46 |
-
}
|
47 |
-
var poll = setInterval(function() {
|
48 |
-
if (tooltip) for (var n = node;; n = n.parentNode) {
|
49 |
-
if (n && n.nodeType == 11) n = n.host;
|
50 |
-
if (n == document.body) return;
|
51 |
-
if (!n) { hide(); break; }
|
52 |
-
}
|
53 |
-
if (!tooltip) return clearInterval(poll);
|
54 |
-
}, 400);
|
55 |
-
CodeMirror.on(node, "mouseout", hide);
|
56 |
-
}
|
57 |
-
|
58 |
-
function LintState(cm, options, hasGutter) {
|
59 |
-
this.marked = [];
|
60 |
-
this.options = options;
|
61 |
-
this.timeout = null;
|
62 |
-
this.hasGutter = hasGutter;
|
63 |
-
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
64 |
-
this.waitingFor = 0
|
65 |
-
}
|
66 |
-
|
67 |
-
function parseOptions(_cm, options) {
|
68 |
-
if (options instanceof Function) return {getAnnotations: options};
|
69 |
-
if (!options || options === true) options = {};
|
70 |
-
return options;
|
71 |
-
}
|
72 |
-
|
73 |
-
function clearMarks(cm) {
|
74 |
-
var state = cm.state.lint;
|
75 |
-
if (state.hasGutter) cm.clearGutter(GUTTER_ID);
|
76 |
-
for (var i = 0; i < state.marked.length; ++i)
|
77 |
-
state.marked[i].clear();
|
78 |
-
state.marked.length = 0;
|
79 |
-
}
|
80 |
-
|
81 |
-
function makeMarker(labels, severity, multiple, tooltips) {
|
82 |
-
var marker = document.createElement("div"), inner = marker;
|
83 |
-
marker.className = "CodeMirror-lint-marker-" + severity;
|
84 |
-
if (multiple) {
|
85 |
-
inner = marker.appendChild(document.createElement("div"));
|
86 |
-
inner.className = "CodeMirror-lint-marker-multiple";
|
87 |
-
}
|
88 |
-
|
89 |
-
if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
|
90 |
-
showTooltipFor(e, labels, inner);
|
91 |
-
});
|
92 |
-
|
93 |
-
return marker;
|
94 |
-
}
|
95 |
-
|
96 |
-
function getMaxSeverity(a, b) {
|
97 |
-
if (a == "error") return a;
|
98 |
-
else return b;
|
99 |
-
}
|
100 |
-
|
101 |
-
function groupByLine(annotations) {
|
102 |
-
var lines = [];
|
103 |
-
for (var i = 0; i < annotations.length; ++i) {
|
104 |
-
var ann = annotations[i], line = ann.from.line;
|
105 |
-
(lines[line] || (lines[line] = [])).push(ann);
|
106 |
-
}
|
107 |
-
return lines;
|
108 |
-
}
|
109 |
-
|
110 |
-
function annotationTooltip(ann) {
|
111 |
-
var severity = ann.severity;
|
112 |
-
if (!severity) severity = "error";
|
113 |
-
var tip = document.createElement("div");
|
114 |
-
tip.className = "CodeMirror-lint-message-" + severity;
|
115 |
-
tip.appendChild(document.createTextNode(ann.message));
|
116 |
-
return tip;
|
117 |
-
}
|
118 |
-
|
119 |
-
function lintAsync(cm, getAnnotations, passOptions) {
|
120 |
-
var state = cm.state.lint
|
121 |
-
var id = ++state.waitingFor
|
122 |
-
function abort() {
|
123 |
-
id = -1
|
124 |
-
cm.off("change", abort)
|
125 |
-
}
|
126 |
-
cm.on("change", abort)
|
127 |
-
getAnnotations(cm.getValue(), function(annotations, arg2) {
|
128 |
-
cm.off("change", abort)
|
129 |
-
if (state.waitingFor != id) return
|
130 |
-
if (arg2 && annotations instanceof CodeMirror) annotations = arg2
|
131 |
-
updateLinting(cm, annotations)
|
132 |
-
}, passOptions, cm);
|
133 |
-
}
|
134 |
-
|
135 |
-
function startLinting(cm) {
|
136 |
-
var state = cm.state.lint, options = state.options;
|
137 |
-
var passOptions = options.options || options; // Support deprecated passing of `options` property in options
|
138 |
-
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
139 |
-
if (!getAnnotations) return;
|
140 |
-
if (options.async || getAnnotations.async) {
|
141 |
-
lintAsync(cm, getAnnotations, passOptions)
|
142 |
-
} else {
|
143 |
-
updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm));
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
function updateLinting(cm, annotationsNotSorted) {
|
148 |
-
clearMarks(cm);
|
149 |
-
var state = cm.state.lint, options = state.options;
|
150 |
-
|
151 |
-
var annotations = groupByLine(annotationsNotSorted);
|
152 |
-
|
153 |
-
for (var line = 0; line < annotations.length; ++line) {
|
154 |
-
var anns = annotations[line];
|
155 |
-
if (!anns) continue;
|
156 |
-
|
157 |
-
var maxSeverity = null;
|
158 |
-
var tipLabel = state.hasGutter && document.createDocumentFragment();
|
159 |
-
|
160 |
-
for (var i = 0; i < anns.length; ++i) {
|
161 |
-
var ann = anns[i];
|
162 |
-
var severity = ann.severity;
|
163 |
-
if (!severity) severity = "error";
|
164 |
-
maxSeverity = getMaxSeverity(maxSeverity, severity);
|
165 |
-
|
166 |
-
if (options.formatAnnotation) ann = options.formatAnnotation(ann);
|
167 |
-
if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
|
168 |
-
|
169 |
-
if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
|
170 |
-
className: "CodeMirror-lint-mark-" + severity,
|
171 |
-
__annotation: ann
|
172 |
-
}));
|
173 |
-
}
|
174 |
-
|
175 |
-
if (state.hasGutter)
|
176 |
-
cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1,
|
177 |
-
state.options.tooltips));
|
178 |
-
}
|
179 |
-
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
|
180 |
-
}
|
181 |
-
|
182 |
-
function onChange(cm) {
|
183 |
-
var state = cm.state.lint;
|
184 |
-
if (!state) return;
|
185 |
-
clearTimeout(state.timeout);
|
186 |
-
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
|
187 |
-
}
|
188 |
-
|
189 |
-
function popupSpanTooltip(ann, e) {
|
190 |
-
var target = e.target || e.srcElement;
|
191 |
-
showTooltipFor(e, annotationTooltip(ann), target);
|
192 |
-
}
|
193 |
-
|
194 |
-
function onMouseOver(cm, e) {
|
195 |
-
var target = e.target || e.srcElement;
|
196 |
-
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
|
197 |
-
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
|
198 |
-
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
|
199 |
-
for (var i = 0; i < spans.length; ++i) {
|
200 |
-
var ann = spans[i].__annotation;
|
201 |
-
if (ann) return popupSpanTooltip(ann, e);
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
-
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
206 |
-
if (old && old != CodeMirror.Init) {
|
207 |
-
clearMarks(cm);
|
208 |
-
if (cm.state.lint.options.lintOnChange !== false)
|
209 |
-
cm.off("change", onChange);
|
210 |
-
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
211 |
-
clearTimeout(cm.state.lint.timeout);
|
212 |
-
delete cm.state.lint;
|
213 |
-
}
|
214 |
-
|
215 |
-
if (val) {
|
216 |
-
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
217 |
-
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
218 |
-
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
|
219 |
-
if (state.options.lintOnChange !== false)
|
220 |
-
cm.on("change", onChange);
|
221 |
-
if (state.options.tooltips != false)
|
222 |
-
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
223 |
-
|
224 |
-
startLinting(cm);
|
225 |
-
}
|
226 |
-
});
|
227 |
-
|
228 |
-
CodeMirror.defineExtension("performLint", function() {
|
229 |
-
if (this.state.lint) startLinting(this);
|
230 |
-
});
|
231 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/lint/yaml-lint.js
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
// Depends on js-yaml.js from https://github.com/nodeca/js-yaml
|
15 |
-
|
16 |
-
// declare global: jsyaml
|
17 |
-
|
18 |
-
CodeMirror.registerHelper("lint", "yaml", function(text) {
|
19 |
-
var found = [];
|
20 |
-
try { jsyaml.load(text); }
|
21 |
-
catch(e) {
|
22 |
-
var loc = e.mark;
|
23 |
-
found.push({ from: CodeMirror.Pos(loc.line, loc.column), to: CodeMirror.Pos(loc.line, loc.column), message: e.message });
|
24 |
-
}
|
25 |
-
return found;
|
26 |
-
});
|
27 |
-
|
28 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/merge/merge.css
DELETED
@@ -1,112 +0,0 @@
|
|
1 |
-
.CodeMirror-merge {
|
2 |
-
position: relative;
|
3 |
-
border: 1px solid #ddd;
|
4 |
-
white-space: pre;
|
5 |
-
}
|
6 |
-
|
7 |
-
.CodeMirror-merge, .CodeMirror-merge .CodeMirror {
|
8 |
-
height: 350px;
|
9 |
-
}
|
10 |
-
|
11 |
-
.CodeMirror-merge-2pane .CodeMirror-merge-pane { width: 47%; }
|
12 |
-
.CodeMirror-merge-2pane .CodeMirror-merge-gap { width: 6%; }
|
13 |
-
.CodeMirror-merge-3pane .CodeMirror-merge-pane { width: 31%; }
|
14 |
-
.CodeMirror-merge-3pane .CodeMirror-merge-gap { width: 3.5%; }
|
15 |
-
|
16 |
-
.CodeMirror-merge-pane {
|
17 |
-
display: inline-block;
|
18 |
-
white-space: normal;
|
19 |
-
vertical-align: top;
|
20 |
-
}
|
21 |
-
.CodeMirror-merge-pane-rightmost {
|
22 |
-
position: absolute;
|
23 |
-
right: 0px;
|
24 |
-
z-index: 1;
|
25 |
-
}
|
26 |
-
|
27 |
-
.CodeMirror-merge-gap {
|
28 |
-
z-index: 2;
|
29 |
-
display: inline-block;
|
30 |
-
height: 100%;
|
31 |
-
-moz-box-sizing: border-box;
|
32 |
-
box-sizing: border-box;
|
33 |
-
overflow: hidden;
|
34 |
-
border-left: 1px solid #ddd;
|
35 |
-
border-right: 1px solid #ddd;
|
36 |
-
position: relative;
|
37 |
-
background: #f8f8f8;
|
38 |
-
}
|
39 |
-
|
40 |
-
.CodeMirror-merge-scrolllock-wrap {
|
41 |
-
position: absolute;
|
42 |
-
bottom: 0; left: 50%;
|
43 |
-
}
|
44 |
-
.CodeMirror-merge-scrolllock {
|
45 |
-
position: relative;
|
46 |
-
left: -50%;
|
47 |
-
cursor: pointer;
|
48 |
-
color: #555;
|
49 |
-
line-height: 1;
|
50 |
-
}
|
51 |
-
|
52 |
-
.CodeMirror-merge-copybuttons-left, .CodeMirror-merge-copybuttons-right {
|
53 |
-
position: absolute;
|
54 |
-
left: 0; top: 0;
|
55 |
-
right: 0; bottom: 0;
|
56 |
-
line-height: 1;
|
57 |
-
}
|
58 |
-
|
59 |
-
.CodeMirror-merge-copy {
|
60 |
-
position: absolute;
|
61 |
-
cursor: pointer;
|
62 |
-
color: #44c;
|
63 |
-
}
|
64 |
-
|
65 |
-
.CodeMirror-merge-copy-reverse {
|
66 |
-
position: absolute;
|
67 |
-
cursor: pointer;
|
68 |
-
color: #44c;
|
69 |
-
}
|
70 |
-
|
71 |
-
.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy { left: 2px; }
|
72 |
-
.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy { right: 2px; }
|
73 |
-
|
74 |
-
.CodeMirror-merge-r-inserted, .CodeMirror-merge-l-inserted {
|
75 |
-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==);
|
76 |
-
background-position: bottom left;
|
77 |
-
background-repeat: repeat-x;
|
78 |
-
}
|
79 |
-
|
80 |
-
.CodeMirror-merge-r-deleted, .CodeMirror-merge-l-deleted {
|
81 |
-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==);
|
82 |
-
background-position: bottom left;
|
83 |
-
background-repeat: repeat-x;
|
84 |
-
}
|
85 |
-
|
86 |
-
.CodeMirror-merge-r-chunk { background: #ffffe0; }
|
87 |
-
.CodeMirror-merge-r-chunk-start { border-top: 1px solid #ee8; }
|
88 |
-
.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #ee8; }
|
89 |
-
.CodeMirror-merge-r-connect { fill: #ffffe0; stroke: #ee8; stroke-width: 1px; }
|
90 |
-
|
91 |
-
.CodeMirror-merge-l-chunk { background: #eef; }
|
92 |
-
.CodeMirror-merge-l-chunk-start { border-top: 1px solid #88e; }
|
93 |
-
.CodeMirror-merge-l-chunk-end { border-bottom: 1px solid #88e; }
|
94 |
-
.CodeMirror-merge-l-connect { fill: #eef; stroke: #88e; stroke-width: 1px; }
|
95 |
-
|
96 |
-
.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk { background: #dfd; }
|
97 |
-
.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start { border-top: 1px solid #4e4; }
|
98 |
-
.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #4e4; }
|
99 |
-
|
100 |
-
.CodeMirror-merge-collapsed-widget:before {
|
101 |
-
content: "(...)";
|
102 |
-
}
|
103 |
-
.CodeMirror-merge-collapsed-widget {
|
104 |
-
cursor: pointer;
|
105 |
-
color: #88b;
|
106 |
-
background: #eef;
|
107 |
-
border: 1px solid #ddf;
|
108 |
-
font-size: 90%;
|
109 |
-
padding: 0 3px;
|
110 |
-
border-radius: 4px;
|
111 |
-
}
|
112 |
-
.CodeMirror-merge-collapsed-line .CodeMirror-gutter-elt { display: none; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/merge/merge.js
DELETED
@@ -1,772 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
|
5 |
-
|
6 |
-
(function(mod) {
|
7 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
8 |
-
mod(require("../../lib/codemirror")); // Note non-packaged dependency diff_match_patch
|
9 |
-
else if (typeof define == "function" && define.amd) // AMD
|
10 |
-
define(["../../lib/codemirror", "diff_match_patch"], mod);
|
11 |
-
else // Plain browser env
|
12 |
-
mod(CodeMirror);
|
13 |
-
})(function(CodeMirror) {
|
14 |
-
"use strict";
|
15 |
-
var Pos = CodeMirror.Pos;
|
16 |
-
var svgNS = "http://www.w3.org/2000/svg";
|
17 |
-
|
18 |
-
function DiffView(mv, type) {
|
19 |
-
this.mv = mv;
|
20 |
-
this.type = type;
|
21 |
-
this.classes = type == "left"
|
22 |
-
? {chunk: "CodeMirror-merge-l-chunk",
|
23 |
-
start: "CodeMirror-merge-l-chunk-start",
|
24 |
-
end: "CodeMirror-merge-l-chunk-end",
|
25 |
-
insert: "CodeMirror-merge-l-inserted",
|
26 |
-
del: "CodeMirror-merge-l-deleted",
|
27 |
-
connect: "CodeMirror-merge-l-connect"}
|
28 |
-
: {chunk: "CodeMirror-merge-r-chunk",
|
29 |
-
start: "CodeMirror-merge-r-chunk-start",
|
30 |
-
end: "CodeMirror-merge-r-chunk-end",
|
31 |
-
insert: "CodeMirror-merge-r-inserted",
|
32 |
-
del: "CodeMirror-merge-r-deleted",
|
33 |
-
connect: "CodeMirror-merge-r-connect"};
|
34 |
-
}
|
35 |
-
|
36 |
-
DiffView.prototype = {
|
37 |
-
constructor: DiffView,
|
38 |
-
init: function(pane, orig, options) {
|
39 |
-
this.edit = this.mv.edit;
|
40 |
-
(this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this);
|
41 |
-
this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
|
42 |
-
this.orig.state.diffViews = [this];
|
43 |
-
|
44 |
-
this.diff = getDiff(asString(orig), asString(options.value));
|
45 |
-
this.chunks = getChunks(this.diff);
|
46 |
-
this.diffOutOfDate = this.dealigned = false;
|
47 |
-
|
48 |
-
this.showDifferences = options.showDifferences !== false;
|
49 |
-
this.forceUpdate = registerUpdate(this);
|
50 |
-
setScrollLock(this, true, false);
|
51 |
-
registerScroll(this);
|
52 |
-
},
|
53 |
-
setShowDifferences: function(val) {
|
54 |
-
val = val !== false;
|
55 |
-
if (val != this.showDifferences) {
|
56 |
-
this.showDifferences = val;
|
57 |
-
this.forceUpdate("full");
|
58 |
-
}
|
59 |
-
}
|
60 |
-
};
|
61 |
-
|
62 |
-
function ensureDiff(dv) {
|
63 |
-
if (dv.diffOutOfDate) {
|
64 |
-
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
|
65 |
-
dv.chunks = getChunks(dv.diff);
|
66 |
-
dv.diffOutOfDate = false;
|
67 |
-
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
var updating = false;
|
72 |
-
function registerUpdate(dv) {
|
73 |
-
var edit = {from: 0, to: 0, marked: []};
|
74 |
-
var orig = {from: 0, to: 0, marked: []};
|
75 |
-
var debounceChange, updatingFast = false;
|
76 |
-
function update(mode) {
|
77 |
-
updating = true;
|
78 |
-
updatingFast = false;
|
79 |
-
if (mode == "full") {
|
80 |
-
if (dv.svg) clear(dv.svg);
|
81 |
-
if (dv.copyButtons) clear(dv.copyButtons);
|
82 |
-
clearMarks(dv.edit, edit.marked, dv.classes);
|
83 |
-
clearMarks(dv.orig, orig.marked, dv.classes);
|
84 |
-
edit.from = edit.to = orig.from = orig.to = 0;
|
85 |
-
}
|
86 |
-
ensureDiff(dv);
|
87 |
-
if (dv.showDifferences) {
|
88 |
-
updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
|
89 |
-
updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
|
90 |
-
}
|
91 |
-
makeConnections(dv);
|
92 |
-
|
93 |
-
if (dv.mv.options.connect == "align")
|
94 |
-
alignChunks(dv);
|
95 |
-
updating = false;
|
96 |
-
}
|
97 |
-
function setDealign(fast) {
|
98 |
-
if (updating) return;
|
99 |
-
dv.dealigned = true;
|
100 |
-
set(fast);
|
101 |
-
}
|
102 |
-
function set(fast) {
|
103 |
-
if (updating || updatingFast) return;
|
104 |
-
clearTimeout(debounceChange);
|
105 |
-
if (fast === true) updatingFast = true;
|
106 |
-
debounceChange = setTimeout(update, fast === true ? 20 : 250);
|
107 |
-
}
|
108 |
-
function change(_cm, change) {
|
109 |
-
if (!dv.diffOutOfDate) {
|
110 |
-
dv.diffOutOfDate = true;
|
111 |
-
edit.from = edit.to = orig.from = orig.to = 0;
|
112 |
-
}
|
113 |
-
// Update faster when a line was added/removed
|
114 |
-
setDealign(change.text.length - 1 != change.to.line - change.from.line);
|
115 |
-
}
|
116 |
-
dv.edit.on("change", change);
|
117 |
-
dv.orig.on("change", change);
|
118 |
-
dv.edit.on("markerAdded", setDealign);
|
119 |
-
dv.edit.on("markerCleared", setDealign);
|
120 |
-
dv.orig.on("markerAdded", setDealign);
|
121 |
-
dv.orig.on("markerCleared", setDealign);
|
122 |
-
dv.edit.on("viewportChange", function() { set(false); });
|
123 |
-
dv.orig.on("viewportChange", function() { set(false); });
|
124 |
-
update();
|
125 |
-
return update;
|
126 |
-
}
|
127 |
-
|
128 |
-
function registerScroll(dv) {
|
129 |
-
dv.edit.on("scroll", function() {
|
130 |
-
syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
|
131 |
-
});
|
132 |
-
dv.orig.on("scroll", function() {
|
133 |
-
syncScroll(dv, DIFF_DELETE) && makeConnections(dv);
|
134 |
-
});
|
135 |
-
}
|
136 |
-
|
137 |
-
function syncScroll(dv, type) {
|
138 |
-
// Change handler will do a refresh after a timeout when diff is out of date
|
139 |
-
if (dv.diffOutOfDate) return false;
|
140 |
-
if (!dv.lockScroll) return true;
|
141 |
-
var editor, other, now = +new Date;
|
142 |
-
if (type == DIFF_INSERT) { editor = dv.edit; other = dv.orig; }
|
143 |
-
else { editor = dv.orig; other = dv.edit; }
|
144 |
-
// Don't take action if the position of this editor was recently set
|
145 |
-
// (to prevent feedback loops)
|
146 |
-
if (editor.state.scrollSetBy == dv && (editor.state.scrollSetAt || 0) + 50 > now) return false;
|
147 |
-
|
148 |
-
var sInfo = editor.getScrollInfo();
|
149 |
-
if (dv.mv.options.connect == "align") {
|
150 |
-
targetPos = sInfo.top;
|
151 |
-
} else {
|
152 |
-
var halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen;
|
153 |
-
var mid = editor.lineAtHeight(midY, "local");
|
154 |
-
var around = chunkBoundariesAround(dv.chunks, mid, type == DIFF_INSERT);
|
155 |
-
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig);
|
156 |
-
var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit);
|
157 |
-
var ratio = (midY - off.top) / (off.bot - off.top);
|
158 |
-
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
|
159 |
-
|
160 |
-
var botDist, mix;
|
161 |
-
// Some careful tweaking to make sure no space is left out of view
|
162 |
-
// when scrolling to top or bottom.
|
163 |
-
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) {
|
164 |
-
targetPos = targetPos * mix + sInfo.top * (1 - mix);
|
165 |
-
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) {
|
166 |
-
var otherInfo = other.getScrollInfo();
|
167 |
-
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos;
|
168 |
-
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1)
|
169 |
-
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix);
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
other.scrollTo(sInfo.left, targetPos);
|
174 |
-
other.state.scrollSetAt = now;
|
175 |
-
other.state.scrollSetBy = dv;
|
176 |
-
return true;
|
177 |
-
}
|
178 |
-
|
179 |
-
function getOffsets(editor, around) {
|
180 |
-
var bot = around.after;
|
181 |
-
if (bot == null) bot = editor.lastLine() + 1;
|
182 |
-
return {top: editor.heightAtLine(around.before || 0, "local"),
|
183 |
-
bot: editor.heightAtLine(bot, "local")};
|
184 |
-
}
|
185 |
-
|
186 |
-
function setScrollLock(dv, val, action) {
|
187 |
-
dv.lockScroll = val;
|
188 |
-
if (val && action != false) syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
|
189 |
-
dv.lockButton.innerHTML = val ? "\u21db\u21da" : "\u21db \u21da";
|
190 |
-
}
|
191 |
-
|
192 |
-
// Updating the marks for editor content
|
193 |
-
|
194 |
-
function clearMarks(editor, arr, classes) {
|
195 |
-
for (var i = 0; i < arr.length; ++i) {
|
196 |
-
var mark = arr[i];
|
197 |
-
if (mark instanceof CodeMirror.TextMarker) {
|
198 |
-
mark.clear();
|
199 |
-
} else if (mark.parent) {
|
200 |
-
editor.removeLineClass(mark, "background", classes.chunk);
|
201 |
-
editor.removeLineClass(mark, "background", classes.start);
|
202 |
-
editor.removeLineClass(mark, "background", classes.end);
|
203 |
-
}
|
204 |
-
}
|
205 |
-
arr.length = 0;
|
206 |
-
}
|
207 |
-
|
208 |
-
// FIXME maybe add a margin around viewport to prevent too many updates
|
209 |
-
function updateMarks(editor, diff, state, type, classes) {
|
210 |
-
var vp = editor.getViewport();
|
211 |
-
editor.operation(function() {
|
212 |
-
if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
|
213 |
-
clearMarks(editor, state.marked, classes);
|
214 |
-
markChanges(editor, diff, type, state.marked, vp.from, vp.to, classes);
|
215 |
-
state.from = vp.from; state.to = vp.to;
|
216 |
-
} else {
|
217 |
-
if (vp.from < state.from) {
|
218 |
-
markChanges(editor, diff, type, state.marked, vp.from, state.from, classes);
|
219 |
-
state.from = vp.from;
|
220 |
-
}
|
221 |
-
if (vp.to > state.to) {
|
222 |
-
markChanges(editor, diff, type, state.marked, state.to, vp.to, classes);
|
223 |
-
state.to = vp.to;
|
224 |
-
}
|
225 |
-
}
|
226 |
-
});
|
227 |
-
}
|
228 |
-
|
229 |
-
function markChanges(editor, diff, type, marks, from, to, classes) {
|
230 |
-
var pos = Pos(0, 0);
|
231 |
-
var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1));
|
232 |
-
var cls = type == DIFF_DELETE ? classes.del : classes.insert;
|
233 |
-
function markChunk(start, end) {
|
234 |
-
var bfrom = Math.max(from, start), bto = Math.min(to, end);
|
235 |
-
for (var i = bfrom; i < bto; ++i) {
|
236 |
-
var line = editor.addLineClass(i, "background", classes.chunk);
|
237 |
-
if (i == start) editor.addLineClass(line, "background", classes.start);
|
238 |
-
if (i == end - 1) editor.addLineClass(line, "background", classes.end);
|
239 |
-
marks.push(line);
|
240 |
-
}
|
241 |
-
// When the chunk is empty, make sure a horizontal line shows up
|
242 |
-
if (start == end && bfrom == end && bto == end) {
|
243 |
-
if (bfrom)
|
244 |
-
marks.push(editor.addLineClass(bfrom - 1, "background", classes.end));
|
245 |
-
else
|
246 |
-
marks.push(editor.addLineClass(bfrom, "background", classes.start));
|
247 |
-
}
|
248 |
-
}
|
249 |
-
|
250 |
-
var chunkStart = 0;
|
251 |
-
for (var i = 0; i < diff.length; ++i) {
|
252 |
-
var part = diff[i], tp = part[0], str = part[1];
|
253 |
-
if (tp == DIFF_EQUAL) {
|
254 |
-
var cleanFrom = pos.line + (startOfLineClean(diff, i) ? 0 : 1);
|
255 |
-
moveOver(pos, str);
|
256 |
-
var cleanTo = pos.line + (endOfLineClean(diff, i) ? 1 : 0);
|
257 |
-
if (cleanTo > cleanFrom) {
|
258 |
-
if (i) markChunk(chunkStart, cleanFrom);
|
259 |
-
chunkStart = cleanTo;
|
260 |
-
}
|
261 |
-
} else {
|
262 |
-
if (tp == type) {
|
263 |
-
var end = moveOver(pos, str, true);
|
264 |
-
var a = posMax(top, pos), b = posMin(bot, end);
|
265 |
-
if (!posEq(a, b))
|
266 |
-
marks.push(editor.markText(a, b, {className: cls}));
|
267 |
-
pos = end;
|
268 |
-
}
|
269 |
-
}
|
270 |
-
}
|
271 |
-
if (chunkStart <= pos.line) markChunk(chunkStart, pos.line + 1);
|
272 |
-
}
|
273 |
-
|
274 |
-
// Updating the gap between editor and original
|
275 |
-
|
276 |
-
function makeConnections(dv) {
|
277 |
-
if (!dv.showDifferences) return;
|
278 |
-
|
279 |
-
if (dv.svg) {
|
280 |
-
clear(dv.svg);
|
281 |
-
var w = dv.gap.offsetWidth;
|
282 |
-
attrs(dv.svg, "width", w, "height", dv.gap.offsetHeight);
|
283 |
-
}
|
284 |
-
if (dv.copyButtons) clear(dv.copyButtons);
|
285 |
-
|
286 |
-
var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
|
287 |
-
var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top;
|
288 |
-
for (var i = 0; i < dv.chunks.length; i++) {
|
289 |
-
var ch = dv.chunks[i];
|
290 |
-
if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from &&
|
291 |
-
ch.origFrom <= vpOrig.to && ch.origTo >= vpOrig.from)
|
292 |
-
drawConnectorsForChunk(dv, ch, sTopOrig, sTopEdit, w);
|
293 |
-
}
|
294 |
-
}
|
295 |
-
|
296 |
-
function getMatchingOrigLine(editLine, chunks) {
|
297 |
-
var editStart = 0, origStart = 0;
|
298 |
-
for (var i = 0; i < chunks.length; i++) {
|
299 |
-
var chunk = chunks[i];
|
300 |
-
if (chunk.editTo > editLine && chunk.editFrom <= editLine) return null;
|
301 |
-
if (chunk.editFrom > editLine) break;
|
302 |
-
editStart = chunk.editTo;
|
303 |
-
origStart = chunk.origTo;
|
304 |
-
}
|
305 |
-
return origStart + (editLine - editStart);
|
306 |
-
}
|
307 |
-
|
308 |
-
function findAlignedLines(dv, other) {
|
309 |
-
var linesToAlign = [];
|
310 |
-
for (var i = 0; i < dv.chunks.length; i++) {
|
311 |
-
var chunk = dv.chunks[i];
|
312 |
-
linesToAlign.push([chunk.origTo, chunk.editTo, other ? getMatchingOrigLine(chunk.editTo, other.chunks) : null]);
|
313 |
-
}
|
314 |
-
if (other) {
|
315 |
-
for (var i = 0; i < other.chunks.length; i++) {
|
316 |
-
var chunk = other.chunks[i];
|
317 |
-
for (var j = 0; j < linesToAlign.length; j++) {
|
318 |
-
var align = linesToAlign[j];
|
319 |
-
if (align[1] == chunk.editTo) {
|
320 |
-
j = -1;
|
321 |
-
break;
|
322 |
-
} else if (align[1] > chunk.editTo) {
|
323 |
-
break;
|
324 |
-
}
|
325 |
-
}
|
326 |
-
if (j > -1)
|
327 |
-
linesToAlign.splice(j - 1, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]);
|
328 |
-
}
|
329 |
-
}
|
330 |
-
return linesToAlign;
|
331 |
-
}
|
332 |
-
|
333 |
-
function alignChunks(dv, force) {
|
334 |
-
if (!dv.dealigned && !force) return;
|
335 |
-
if (!dv.orig.curOp) return dv.orig.operation(function() {
|
336 |
-
alignChunks(dv, force);
|
337 |
-
});
|
338 |
-
|
339 |
-
dv.dealigned = false;
|
340 |
-
var other = dv.mv.left == dv ? dv.mv.right : dv.mv.left;
|
341 |
-
if (other) {
|
342 |
-
ensureDiff(other);
|
343 |
-
other.dealigned = false;
|
344 |
-
}
|
345 |
-
var linesToAlign = findAlignedLines(dv, other);
|
346 |
-
|
347 |
-
// Clear old aligners
|
348 |
-
var aligners = dv.mv.aligners;
|
349 |
-
for (var i = 0; i < aligners.length; i++)
|
350 |
-
aligners[i].clear();
|
351 |
-
aligners.length = 0;
|
352 |
-
|
353 |
-
var cm = [dv.orig, dv.edit], scroll = [];
|
354 |
-
if (other) cm.push(other.orig);
|
355 |
-
for (var i = 0; i < cm.length; i++)
|
356 |
-
scroll.push(cm[i].getScrollInfo().top);
|
357 |
-
|
358 |
-
for (var ln = 0; ln < linesToAlign.length; ln++)
|
359 |
-
alignLines(cm, linesToAlign[ln], aligners);
|
360 |
-
|
361 |
-
for (var i = 0; i < cm.length; i++)
|
362 |
-
cm[i].scrollTo(null, scroll[i]);
|
363 |
-
}
|
364 |
-
|
365 |
-
function alignLines(cm, lines, aligners) {
|
366 |
-
var maxOffset = 0, offset = [];
|
367 |
-
for (var i = 0; i < cm.length; i++) if (lines[i] != null) {
|
368 |
-
var off = cm[i].heightAtLine(lines[i], "local");
|
369 |
-
offset[i] = off;
|
370 |
-
maxOffset = Math.max(maxOffset, off);
|
371 |
-
}
|
372 |
-
for (var i = 0; i < cm.length; i++) if (lines[i] != null) {
|
373 |
-
var diff = maxOffset - offset[i];
|
374 |
-
if (diff > 1)
|
375 |
-
aligners.push(padAbove(cm[i], lines[i], diff));
|
376 |
-
}
|
377 |
-
}
|
378 |
-
|
379 |
-
function padAbove(cm, line, size) {
|
380 |
-
var above = true;
|
381 |
-
if (line > cm.lastLine()) {
|
382 |
-
line--;
|
383 |
-
above = false;
|
384 |
-
}
|
385 |
-
var elt = document.createElement("div");
|
386 |
-
elt.className = "CodeMirror-merge-spacer";
|
387 |
-
elt.style.height = size + "px"; elt.style.minWidth = "1px";
|
388 |
-
return cm.addLineWidget(line, elt, {height: size, above: above});
|
389 |
-
}
|
390 |
-
|
391 |
-
function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
|
392 |
-
var flip = dv.type == "left";
|
393 |
-
var top = dv.orig.heightAtLine(chunk.origFrom, "local") - sTopOrig;
|
394 |
-
if (dv.svg) {
|
395 |
-
var topLpx = top;
|
396 |
-
var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit;
|
397 |
-
if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; }
|
398 |
-
var botLpx = dv.orig.heightAtLine(chunk.origTo, "local") - sTopOrig;
|
399 |
-
var botRpx = dv.edit.heightAtLine(chunk.editTo, "local") - sTopEdit;
|
400 |
-
if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; }
|
401 |
-
var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx;
|
402 |
-
var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx;
|
403 |
-
attrs(dv.svg.appendChild(document.createElementNS(svgNS, "path")),
|
404 |
-
"d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z",
|
405 |
-
"class", dv.classes.connect);
|
406 |
-
}
|
407 |
-
if (dv.copyButtons) {
|
408 |
-
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc",
|
409 |
-
"CodeMirror-merge-copy"));
|
410 |
-
var editOriginals = dv.mv.options.allowEditingOriginals;
|
411 |
-
copy.title = editOriginals ? "Push to left" : "Revert chunk";
|
412 |
-
copy.chunk = chunk;
|
413 |
-
copy.style.top = top + "px";
|
414 |
-
|
415 |
-
if (editOriginals) {
|
416 |
-
var topReverse = dv.orig.heightAtLine(chunk.editFrom, "local") - sTopEdit;
|
417 |
-
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
|
418 |
-
"CodeMirror-merge-copy-reverse"));
|
419 |
-
copyReverse.title = "Push to right";
|
420 |
-
copyReverse.chunk = {editFrom: chunk.origFrom, editTo: chunk.origTo,
|
421 |
-
origFrom: chunk.editFrom, origTo: chunk.editTo};
|
422 |
-
copyReverse.style.top = topReverse + "px";
|
423 |
-
dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px";
|
424 |
-
}
|
425 |
-
}
|
426 |
-
}
|
427 |
-
|
428 |
-
function copyChunk(dv, to, from, chunk) {
|
429 |
-
if (dv.diffOutOfDate) return;
|
430 |
-
to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
|
431 |
-
Pos(chunk.editFrom, 0), Pos(chunk.editTo, 0));
|
432 |
-
}
|
433 |
-
|
434 |
-
// Merge view, containing 0, 1, or 2 diff views.
|
435 |
-
|
436 |
-
var MergeView = CodeMirror.MergeView = function(node, options) {
|
437 |
-
if (!(this instanceof MergeView)) return new MergeView(node, options);
|
438 |
-
|
439 |
-
this.options = options;
|
440 |
-
var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight;
|
441 |
-
|
442 |
-
var hasLeft = origLeft != null, hasRight = origRight != null;
|
443 |
-
var panes = 1 + (hasLeft ? 1 : 0) + (hasRight ? 1 : 0);
|
444 |
-
var wrap = [], left = this.left = null, right = this.right = null;
|
445 |
-
var self = this;
|
446 |
-
|
447 |
-
if (hasLeft) {
|
448 |
-
left = this.left = new DiffView(this, "left");
|
449 |
-
var leftPane = elt("div", null, "CodeMirror-merge-pane");
|
450 |
-
wrap.push(leftPane);
|
451 |
-
wrap.push(buildGap(left));
|
452 |
-
}
|
453 |
-
|
454 |
-
var editPane = elt("div", null, "CodeMirror-merge-pane");
|
455 |
-
wrap.push(editPane);
|
456 |
-
|
457 |
-
if (hasRight) {
|
458 |
-
right = this.right = new DiffView(this, "right");
|
459 |
-
wrap.push(buildGap(right));
|
460 |
-
var rightPane = elt("div", null, "CodeMirror-merge-pane");
|
461 |
-
wrap.push(rightPane);
|
462 |
-
}
|
463 |
-
|
464 |
-
(hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost";
|
465 |
-
|
466 |
-
wrap.push(elt("div", null, null, "height: 0; clear: both;"));
|
467 |
-
|
468 |
-
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane"));
|
469 |
-
this.edit = CodeMirror(editPane, copyObj(options));
|
470 |
-
|
471 |
-
if (left) left.init(leftPane, origLeft, options);
|
472 |
-
if (right) right.init(rightPane, origRight, options);
|
473 |
-
|
474 |
-
if (options.collapseIdentical)
|
475 |
-
this.editor().operation(function() {
|
476 |
-
collapseIdenticalStretches(self, options.collapseIdentical);
|
477 |
-
});
|
478 |
-
if (options.connect == "align") {
|
479 |
-
this.aligners = [];
|
480 |
-
alignChunks(this.left || this.right, true);
|
481 |
-
}
|
482 |
-
|
483 |
-
var onResize = function() {
|
484 |
-
if (left) makeConnections(left);
|
485 |
-
if (right) makeConnections(right);
|
486 |
-
};
|
487 |
-
CodeMirror.on(window, "resize", onResize);
|
488 |
-
var resizeInterval = setInterval(function() {
|
489 |
-
for (var p = wrapElt.parentNode; p && p != document.body; p = p.parentNode) {}
|
490 |
-
if (!p) { clearInterval(resizeInterval); CodeMirror.off(window, "resize", onResize); }
|
491 |
-
}, 5000);
|
492 |
-
};
|
493 |
-
|
494 |
-
function buildGap(dv) {
|
495 |
-
var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock");
|
496 |
-
lock.title = "Toggle locked scrolling";
|
497 |
-
var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap");
|
498 |
-
CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); });
|
499 |
-
var gapElts = [lockWrap];
|
500 |
-
if (dv.mv.options.revertButtons !== false) {
|
501 |
-
dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type);
|
502 |
-
CodeMirror.on(dv.copyButtons, "click", function(e) {
|
503 |
-
var node = e.target || e.srcElement;
|
504 |
-
if (!node.chunk) return;
|
505 |
-
if (node.className == "CodeMirror-merge-copy-reverse") {
|
506 |
-
copyChunk(dv, dv.orig, dv.edit, node.chunk);
|
507 |
-
return;
|
508 |
-
}
|
509 |
-
copyChunk(dv, dv.edit, dv.orig, node.chunk);
|
510 |
-
});
|
511 |
-
gapElts.unshift(dv.copyButtons);
|
512 |
-
}
|
513 |
-
if (dv.mv.options.connect != "align") {
|
514 |
-
var svg = document.createElementNS && document.createElementNS(svgNS, "svg");
|
515 |
-
if (svg && !svg.createSVGRect) svg = null;
|
516 |
-
dv.svg = svg;
|
517 |
-
if (svg) gapElts.push(svg);
|
518 |
-
}
|
519 |
-
|
520 |
-
return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap");
|
521 |
-
}
|
522 |
-
|
523 |
-
MergeView.prototype = {
|
524 |
-
constuctor: MergeView,
|
525 |
-
editor: function() { return this.edit; },
|
526 |
-
rightOriginal: function() { return this.right && this.right.orig; },
|
527 |
-
leftOriginal: function() { return this.left && this.left.orig; },
|
528 |
-
setShowDifferences: function(val) {
|
529 |
-
if (this.right) this.right.setShowDifferences(val);
|
530 |
-
if (this.left) this.left.setShowDifferences(val);
|
531 |
-
},
|
532 |
-
rightChunks: function() {
|
533 |
-
if (this.right) { ensureDiff(this.right); return this.right.chunks; }
|
534 |
-
},
|
535 |
-
leftChunks: function() {
|
536 |
-
if (this.left) { ensureDiff(this.left); return this.left.chunks; }
|
537 |
-
}
|
538 |
-
};
|
539 |
-
|
540 |
-
function asString(obj) {
|
541 |
-
if (typeof obj == "string") return obj;
|
542 |
-
else return obj.getValue();
|
543 |
-
}
|
544 |
-
|
545 |
-
// Operations on diffs
|
546 |
-
|
547 |
-
var dmp = new diff_match_patch();
|
548 |
-
function getDiff(a, b) {
|
549 |
-
var diff = dmp.diff_main(a, b);
|
550 |
-
dmp.diff_cleanupSemantic(diff);
|
551 |
-
// The library sometimes leaves in empty parts, which confuse the algorithm
|
552 |
-
for (var i = 0; i < diff.length; ++i) {
|
553 |
-
var part = diff[i];
|
554 |
-
if (!part[1]) {
|
555 |
-
diff.splice(i--, 1);
|
556 |
-
} else if (i && diff[i - 1][0] == part[0]) {
|
557 |
-
diff.splice(i--, 1);
|
558 |
-
diff[i][1] += part[1];
|
559 |
-
}
|
560 |
-
}
|
561 |
-
return diff;
|
562 |
-
}
|
563 |
-
|
564 |
-
function getChunks(diff) {
|
565 |
-
var chunks = [];
|
566 |
-
var startEdit = 0, startOrig = 0;
|
567 |
-
var edit = Pos(0, 0), orig = Pos(0, 0);
|
568 |
-
for (var i = 0; i < diff.length; ++i) {
|
569 |
-
var part = diff[i], tp = part[0];
|
570 |
-
if (tp == DIFF_EQUAL) {
|
571 |
-
var startOff = startOfLineClean(diff, i) ? 0 : 1;
|
572 |
-
var cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff;
|
573 |
-
moveOver(edit, part[1], null, orig);
|
574 |
-
var endOff = endOfLineClean(diff, i) ? 1 : 0;
|
575 |
-
var cleanToEdit = edit.line + endOff, cleanToOrig = orig.line + endOff;
|
576 |
-
if (cleanToEdit > cleanFromEdit) {
|
577 |
-
if (i) chunks.push({origFrom: startOrig, origTo: cleanFromOrig,
|
578 |
-
editFrom: startEdit, editTo: cleanFromEdit});
|
579 |
-
startEdit = cleanToEdit; startOrig = cleanToOrig;
|
580 |
-
}
|
581 |
-
} else {
|
582 |
-
moveOver(tp == DIFF_INSERT ? edit : orig, part[1]);
|
583 |
-
}
|
584 |
-
}
|
585 |
-
if (startEdit <= edit.line || startOrig <= orig.line)
|
586 |
-
chunks.push({origFrom: startOrig, origTo: orig.line + 1,
|
587 |
-
editFrom: startEdit, editTo: edit.line + 1});
|
588 |
-
return chunks;
|
589 |
-
}
|
590 |
-
|
591 |
-
function endOfLineClean(diff, i) {
|
592 |
-
if (i == diff.length - 1) return true;
|
593 |
-
var next = diff[i + 1][1];
|
594 |
-
if (next.length == 1 || next.charCodeAt(0) != 10) return false;
|
595 |
-
if (i == diff.length - 2) return true;
|
596 |
-
next = diff[i + 2][1];
|
597 |
-
return next.length > 1 && next.charCodeAt(0) == 10;
|
598 |
-
}
|
599 |
-
|
600 |
-
function startOfLineClean(diff, i) {
|
601 |
-
if (i == 0) return true;
|
602 |
-
var last = diff[i - 1][1];
|
603 |
-
if (last.charCodeAt(last.length - 1) != 10) return false;
|
604 |
-
if (i == 1) return true;
|
605 |
-
last = diff[i - 2][1];
|
606 |
-
return last.charCodeAt(last.length - 1) == 10;
|
607 |
-
}
|
608 |
-
|
609 |
-
function chunkBoundariesAround(chunks, n, nInEdit) {
|
610 |
-
var beforeE, afterE, beforeO, afterO;
|
611 |
-
for (var i = 0; i < chunks.length; i++) {
|
612 |
-
var chunk = chunks[i];
|
613 |
-
var fromLocal = nInEdit ? chunk.editFrom : chunk.origFrom;
|
614 |
-
var toLocal = nInEdit ? chunk.editTo : chunk.origTo;
|
615 |
-
if (afterE == null) {
|
616 |
-
if (fromLocal > n) { afterE = chunk.editFrom; afterO = chunk.origFrom; }
|
617 |
-
else if (toLocal > n) { afterE = chunk.editTo; afterO = chunk.origTo; }
|
618 |
-
}
|
619 |
-
if (toLocal <= n) { beforeE = chunk.editTo; beforeO = chunk.origTo; }
|
620 |
-
else if (fromLocal <= n) { beforeE = chunk.editFrom; beforeO = chunk.origFrom; }
|
621 |
-
}
|
622 |
-
return {edit: {before: beforeE, after: afterE}, orig: {before: beforeO, after: afterO}};
|
623 |
-
}
|
624 |
-
|
625 |
-
function collapseSingle(cm, from, to) {
|
626 |
-
cm.addLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
627 |
-
var widget = document.createElement("span");
|
628 |
-
widget.className = "CodeMirror-merge-collapsed-widget";
|
629 |
-
widget.title = "Identical text collapsed. Click to expand.";
|
630 |
-
var mark = cm.markText(Pos(from, 0), Pos(to - 1), {
|
631 |
-
inclusiveLeft: true,
|
632 |
-
inclusiveRight: true,
|
633 |
-
replacedWith: widget,
|
634 |
-
clearOnEnter: true
|
635 |
-
});
|
636 |
-
function clear() {
|
637 |
-
mark.clear();
|
638 |
-
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
639 |
-
}
|
640 |
-
CodeMirror.on(widget, "click", clear);
|
641 |
-
return {mark: mark, clear: clear};
|
642 |
-
}
|
643 |
-
|
644 |
-
function collapseStretch(size, editors) {
|
645 |
-
var marks = [];
|
646 |
-
function clear() {
|
647 |
-
for (var i = 0; i < marks.length; i++) marks[i].clear();
|
648 |
-
}
|
649 |
-
for (var i = 0; i < editors.length; i++) {
|
650 |
-
var editor = editors[i];
|
651 |
-
var mark = collapseSingle(editor.cm, editor.line, editor.line + size);
|
652 |
-
marks.push(mark);
|
653 |
-
mark.mark.on("clear", clear);
|
654 |
-
}
|
655 |
-
return marks[0].mark;
|
656 |
-
}
|
657 |
-
|
658 |
-
function unclearNearChunks(dv, margin, off, clear) {
|
659 |
-
for (var i = 0; i < dv.chunks.length; i++) {
|
660 |
-
var chunk = dv.chunks[i];
|
661 |
-
for (var l = chunk.editFrom - margin; l < chunk.editTo + margin; l++) {
|
662 |
-
var pos = l + off;
|
663 |
-
if (pos >= 0 && pos < clear.length) clear[pos] = false;
|
664 |
-
}
|
665 |
-
}
|
666 |
-
}
|
667 |
-
|
668 |
-
function collapseIdenticalStretches(mv, margin) {
|
669 |
-
if (typeof margin != "number") margin = 2;
|
670 |
-
var clear = [], edit = mv.editor(), off = edit.firstLine();
|
671 |
-
for (var l = off, e = edit.lastLine(); l <= e; l++) clear.push(true);
|
672 |
-
if (mv.left) unclearNearChunks(mv.left, margin, off, clear);
|
673 |
-
if (mv.right) unclearNearChunks(mv.right, margin, off, clear);
|
674 |
-
|
675 |
-
for (var i = 0; i < clear.length; i++) {
|
676 |
-
if (clear[i]) {
|
677 |
-
var line = i + off;
|
678 |
-
for (var size = 1; i < clear.length - 1 && clear[i + 1]; i++, size++) {}
|
679 |
-
if (size > margin) {
|
680 |
-
var editors = [{line: line, cm: edit}];
|
681 |
-
if (mv.left) editors.push({line: getMatchingOrigLine(line, mv.left.chunks), cm: mv.left.orig});
|
682 |
-
if (mv.right) editors.push({line: getMatchingOrigLine(line, mv.right.chunks), cm: mv.right.orig});
|
683 |
-
var mark = collapseStretch(size, editors);
|
684 |
-
if (mv.options.onCollapse) mv.options.onCollapse(mv, line, size, mark);
|
685 |
-
}
|
686 |
-
}
|
687 |
-
}
|
688 |
-
}
|
689 |
-
|
690 |
-
// General utilities
|
691 |
-
|
692 |
-
function elt(tag, content, className, style) {
|
693 |
-
var e = document.createElement(tag);
|
694 |
-
if (className) e.className = className;
|
695 |
-
if (style) e.style.cssText = style;
|
696 |
-
if (typeof content == "string") e.appendChild(document.createTextNode(content));
|
697 |
-
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
|
698 |
-
return e;
|
699 |
-
}
|
700 |
-
|
701 |
-
function clear(node) {
|
702 |
-
for (var count = node.childNodes.length; count > 0; --count)
|
703 |
-
node.removeChild(node.firstChild);
|
704 |
-
}
|
705 |
-
|
706 |
-
function attrs(elt) {
|
707 |
-
for (var i = 1; i < arguments.length; i += 2)
|
708 |
-
elt.setAttribute(arguments[i], arguments[i+1]);
|
709 |
-
}
|
710 |
-
|
711 |
-
function copyObj(obj, target) {
|
712 |
-
if (!target) target = {};
|
713 |
-
for (var prop in obj) if (obj.hasOwnProperty(prop)) target[prop] = obj[prop];
|
714 |
-
return target;
|
715 |
-
}
|
716 |
-
|
717 |
-
function moveOver(pos, str, copy, other) {
|
718 |
-
var out = copy ? Pos(pos.line, pos.ch) : pos, at = 0;
|
719 |
-
for (;;) {
|
720 |
-
var nl = str.indexOf("\n", at);
|
721 |
-
if (nl == -1) break;
|
722 |
-
++out.line;
|
723 |
-
if (other) ++other.line;
|
724 |
-
at = nl + 1;
|
725 |
-
}
|
726 |
-
out.ch = (at ? 0 : out.ch) + (str.length - at);
|
727 |
-
if (other) other.ch = (at ? 0 : other.ch) + (str.length - at);
|
728 |
-
return out;
|
729 |
-
}
|
730 |
-
|
731 |
-
function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; }
|
732 |
-
function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; }
|
733 |
-
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
734 |
-
|
735 |
-
function findPrevDiff(chunks, start, isOrig) {
|
736 |
-
for (var i = chunks.length - 1; i >= 0; i--) {
|
737 |
-
var chunk = chunks[i];
|
738 |
-
var to = (isOrig ? chunk.origTo : chunk.editTo) - 1;
|
739 |
-
if (to < start) return to;
|
740 |
-
}
|
741 |
-
}
|
742 |
-
|
743 |
-
function findNextDiff(chunks, start, isOrig) {
|
744 |
-
for (var i = 0; i < chunks.length; i++) {
|
745 |
-
var chunk = chunks[i];
|
746 |
-
var from = (isOrig ? chunk.origFrom : chunk.editFrom);
|
747 |
-
if (from > start) return from;
|
748 |
-
}
|
749 |
-
}
|
750 |
-
|
751 |
-
function goNearbyDiff(cm, dir) {
|
752 |
-
var found = null, views = cm.state.diffViews, line = cm.getCursor().line;
|
753 |
-
if (views) for (var i = 0; i < views.length; i++) {
|
754 |
-
var dv = views[i], isOrig = cm == dv.orig;
|
755 |
-
ensureDiff(dv);
|
756 |
-
var pos = dir < 0 ? findPrevDiff(dv.chunks, line, isOrig) : findNextDiff(dv.chunks, line, isOrig);
|
757 |
-
if (pos != null && (found == null || (dir < 0 ? pos > found : pos < found)))
|
758 |
-
found = pos;
|
759 |
-
}
|
760 |
-
if (found != null)
|
761 |
-
cm.setCursor(found, 0);
|
762 |
-
else
|
763 |
-
return CodeMirror.Pass;
|
764 |
-
}
|
765 |
-
|
766 |
-
CodeMirror.commands.goNextDiff = function(cm) {
|
767 |
-
return goNearbyDiff(cm, 1);
|
768 |
-
};
|
769 |
-
CodeMirror.commands.goPrevDiff = function(cm) {
|
770 |
-
return goNearbyDiff(cm, -1);
|
771 |
-
};
|
772 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/loadmode.js
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"), "cjs");
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], function(CM) { mod(CM, "amd"); });
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror, "plain");
|
11 |
-
})(function(CodeMirror, env) {
|
12 |
-
if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
|
13 |
-
|
14 |
-
var loading = {};
|
15 |
-
function splitCallback(cont, n) {
|
16 |
-
var countDown = n;
|
17 |
-
return function() { if (--countDown == 0) cont(); };
|
18 |
-
}
|
19 |
-
function ensureDeps(mode, cont) {
|
20 |
-
var deps = CodeMirror.modes[mode].dependencies;
|
21 |
-
if (!deps) return cont();
|
22 |
-
var missing = [];
|
23 |
-
for (var i = 0; i < deps.length; ++i) {
|
24 |
-
if (!CodeMirror.modes.hasOwnProperty(deps[i]))
|
25 |
-
missing.push(deps[i]);
|
26 |
-
}
|
27 |
-
if (!missing.length) return cont();
|
28 |
-
var split = splitCallback(cont, missing.length);
|
29 |
-
for (var i = 0; i < missing.length; ++i)
|
30 |
-
CodeMirror.requireMode(missing[i], split);
|
31 |
-
}
|
32 |
-
|
33 |
-
CodeMirror.requireMode = function(mode, cont) {
|
34 |
-
if (typeof mode != "string") mode = mode.name;
|
35 |
-
if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont);
|
36 |
-
if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
|
37 |
-
|
38 |
-
var file = CodeMirror.modeURL.replace(/%N/g, mode);
|
39 |
-
if (env == "plain") {
|
40 |
-
var script = document.createElement("script");
|
41 |
-
script.src = file;
|
42 |
-
var others = document.getElementsByTagName("script")[0];
|
43 |
-
var list = loading[mode] = [cont];
|
44 |
-
CodeMirror.on(script, "load", function() {
|
45 |
-
ensureDeps(mode, function() {
|
46 |
-
for (var i = 0; i < list.length; ++i) list[i]();
|
47 |
-
});
|
48 |
-
});
|
49 |
-
others.parentNode.insertBefore(script, others);
|
50 |
-
} else if (env == "cjs") {
|
51 |
-
require(file);
|
52 |
-
cont();
|
53 |
-
} else if (env == "amd") {
|
54 |
-
requirejs([file], cont);
|
55 |
-
}
|
56 |
-
};
|
57 |
-
|
58 |
-
CodeMirror.autoLoadMode = function(instance, mode) {
|
59 |
-
if (!CodeMirror.modes.hasOwnProperty(mode))
|
60 |
-
CodeMirror.requireMode(mode, function() {
|
61 |
-
instance.setOption("mode", instance.getOption("mode"));
|
62 |
-
});
|
63 |
-
};
|
64 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/multiplex.js
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.multiplexingMode = function(outer /*, others */) {
|
15 |
-
// Others should be {open, close, mode [, delimStyle] [, innerStyle]} objects
|
16 |
-
var others = Array.prototype.slice.call(arguments, 1);
|
17 |
-
|
18 |
-
function indexOf(string, pattern, from, returnEnd) {
|
19 |
-
if (typeof pattern == "string") {
|
20 |
-
var found = string.indexOf(pattern, from);
|
21 |
-
return returnEnd && found > -1 ? found + pattern.length : found;
|
22 |
-
}
|
23 |
-
var m = pattern.exec(from ? string.slice(from) : string);
|
24 |
-
return m ? m.index + from + (returnEnd ? m[0].length : 0) : -1;
|
25 |
-
}
|
26 |
-
|
27 |
-
return {
|
28 |
-
startState: function() {
|
29 |
-
return {
|
30 |
-
outer: CodeMirror.startState(outer),
|
31 |
-
innerActive: null,
|
32 |
-
inner: null
|
33 |
-
};
|
34 |
-
},
|
35 |
-
|
36 |
-
copyState: function(state) {
|
37 |
-
return {
|
38 |
-
outer: CodeMirror.copyState(outer, state.outer),
|
39 |
-
innerActive: state.innerActive,
|
40 |
-
inner: state.innerActive && CodeMirror.copyState(state.innerActive.mode, state.inner)
|
41 |
-
};
|
42 |
-
},
|
43 |
-
|
44 |
-
token: function(stream, state) {
|
45 |
-
if (!state.innerActive) {
|
46 |
-
var cutOff = Infinity, oldContent = stream.string;
|
47 |
-
for (var i = 0; i < others.length; ++i) {
|
48 |
-
var other = others[i];
|
49 |
-
var found = indexOf(oldContent, other.open, stream.pos);
|
50 |
-
if (found == stream.pos) {
|
51 |
-
if (!other.parseDelimiters) stream.match(other.open);
|
52 |
-
state.innerActive = other;
|
53 |
-
state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);
|
54 |
-
return other.delimStyle && (other.delimStyle + " " + other.delimStyle + "-open");
|
55 |
-
} else if (found != -1 && found < cutOff) {
|
56 |
-
cutOff = found;
|
57 |
-
}
|
58 |
-
}
|
59 |
-
if (cutOff != Infinity) stream.string = oldContent.slice(0, cutOff);
|
60 |
-
var outerToken = outer.token(stream, state.outer);
|
61 |
-
if (cutOff != Infinity) stream.string = oldContent;
|
62 |
-
return outerToken;
|
63 |
-
} else {
|
64 |
-
var curInner = state.innerActive, oldContent = stream.string;
|
65 |
-
if (!curInner.close && stream.sol()) {
|
66 |
-
state.innerActive = state.inner = null;
|
67 |
-
return this.token(stream, state);
|
68 |
-
}
|
69 |
-
var found = curInner.close ? indexOf(oldContent, curInner.close, stream.pos, curInner.parseDelimiters) : -1;
|
70 |
-
if (found == stream.pos && !curInner.parseDelimiters) {
|
71 |
-
stream.match(curInner.close);
|
72 |
-
state.innerActive = state.inner = null;
|
73 |
-
return curInner.delimStyle && (curInner.delimStyle + " " + curInner.delimStyle + "-close");
|
74 |
-
}
|
75 |
-
if (found > -1) stream.string = oldContent.slice(0, found);
|
76 |
-
var innerToken = curInner.mode.token(stream, state.inner);
|
77 |
-
if (found > -1) stream.string = oldContent;
|
78 |
-
|
79 |
-
if (found == stream.pos && curInner.parseDelimiters)
|
80 |
-
state.innerActive = state.inner = null;
|
81 |
-
|
82 |
-
if (curInner.innerStyle) {
|
83 |
-
if (innerToken) innerToken = innerToken + " " + curInner.innerStyle;
|
84 |
-
else innerToken = curInner.innerStyle;
|
85 |
-
}
|
86 |
-
|
87 |
-
return innerToken;
|
88 |
-
}
|
89 |
-
},
|
90 |
-
|
91 |
-
indent: function(state, textAfter) {
|
92 |
-
var mode = state.innerActive ? state.innerActive.mode : outer;
|
93 |
-
if (!mode.indent) return CodeMirror.Pass;
|
94 |
-
return mode.indent(state.innerActive ? state.inner : state.outer, textAfter);
|
95 |
-
},
|
96 |
-
|
97 |
-
blankLine: function(state) {
|
98 |
-
var mode = state.innerActive ? state.innerActive.mode : outer;
|
99 |
-
if (mode.blankLine) {
|
100 |
-
mode.blankLine(state.innerActive ? state.inner : state.outer);
|
101 |
-
}
|
102 |
-
if (!state.innerActive) {
|
103 |
-
for (var i = 0; i < others.length; ++i) {
|
104 |
-
var other = others[i];
|
105 |
-
if (other.open === "\n") {
|
106 |
-
state.innerActive = other;
|
107 |
-
state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "") : 0);
|
108 |
-
}
|
109 |
-
}
|
110 |
-
} else if (state.innerActive.close === "\n") {
|
111 |
-
state.innerActive = state.inner = null;
|
112 |
-
}
|
113 |
-
},
|
114 |
-
|
115 |
-
electricChars: outer.electricChars,
|
116 |
-
|
117 |
-
innerMode: function(state) {
|
118 |
-
return state.inner ? {state: state.inner, mode: state.innerActive.mode} : {state: state.outer, mode: outer};
|
119 |
-
}
|
120 |
-
};
|
121 |
-
};
|
122 |
-
|
123 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/multiplex_test.js
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function() {
|
5 |
-
CodeMirror.defineMode("markdown_with_stex", function(){
|
6 |
-
var inner = CodeMirror.getMode({}, "stex");
|
7 |
-
var outer = CodeMirror.getMode({}, "markdown");
|
8 |
-
|
9 |
-
var innerOptions = {
|
10 |
-
open: '$',
|
11 |
-
close: '$',
|
12 |
-
mode: inner,
|
13 |
-
delimStyle: 'delim',
|
14 |
-
innerStyle: 'inner'
|
15 |
-
};
|
16 |
-
|
17 |
-
return CodeMirror.multiplexingMode(outer, innerOptions);
|
18 |
-
});
|
19 |
-
|
20 |
-
var mode = CodeMirror.getMode({}, "markdown_with_stex");
|
21 |
-
|
22 |
-
function MT(name) {
|
23 |
-
test.mode(
|
24 |
-
name,
|
25 |
-
mode,
|
26 |
-
Array.prototype.slice.call(arguments, 1),
|
27 |
-
'multiplexing');
|
28 |
-
}
|
29 |
-
|
30 |
-
MT(
|
31 |
-
"stexInsideMarkdown",
|
32 |
-
"[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]");
|
33 |
-
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/overlay.js
DELETED
@@ -1,85 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Utility function that allows modes to be combined. The mode given
|
5 |
-
// as the base argument takes care of most of the normal mode
|
6 |
-
// functionality, but a second (typically simple) mode is used, which
|
7 |
-
// can override the style of text. Both modes get to parse all of the
|
8 |
-
// text, but when both assign a non-null style to a piece of code, the
|
9 |
-
// overlay wins, unless the combine argument was true and not overridden,
|
10 |
-
// or state.overlay.combineTokens was true, in which case the styles are
|
11 |
-
// combined.
|
12 |
-
|
13 |
-
(function(mod) {
|
14 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
15 |
-
mod(require("../../lib/codemirror"));
|
16 |
-
else if (typeof define == "function" && define.amd) // AMD
|
17 |
-
define(["../../lib/codemirror"], mod);
|
18 |
-
else // Plain browser env
|
19 |
-
mod(CodeMirror);
|
20 |
-
})(function(CodeMirror) {
|
21 |
-
"use strict";
|
22 |
-
|
23 |
-
CodeMirror.overlayMode = function(base, overlay, combine) {
|
24 |
-
return {
|
25 |
-
startState: function() {
|
26 |
-
return {
|
27 |
-
base: CodeMirror.startState(base),
|
28 |
-
overlay: CodeMirror.startState(overlay),
|
29 |
-
basePos: 0, baseCur: null,
|
30 |
-
overlayPos: 0, overlayCur: null,
|
31 |
-
streamSeen: null
|
32 |
-
};
|
33 |
-
},
|
34 |
-
copyState: function(state) {
|
35 |
-
return {
|
36 |
-
base: CodeMirror.copyState(base, state.base),
|
37 |
-
overlay: CodeMirror.copyState(overlay, state.overlay),
|
38 |
-
basePos: state.basePos, baseCur: null,
|
39 |
-
overlayPos: state.overlayPos, overlayCur: null
|
40 |
-
};
|
41 |
-
},
|
42 |
-
|
43 |
-
token: function(stream, state) {
|
44 |
-
if (stream != state.streamSeen ||
|
45 |
-
Math.min(state.basePos, state.overlayPos) < stream.start) {
|
46 |
-
state.streamSeen = stream;
|
47 |
-
state.basePos = state.overlayPos = stream.start;
|
48 |
-
}
|
49 |
-
|
50 |
-
if (stream.start == state.basePos) {
|
51 |
-
state.baseCur = base.token(stream, state.base);
|
52 |
-
state.basePos = stream.pos;
|
53 |
-
}
|
54 |
-
if (stream.start == state.overlayPos) {
|
55 |
-
stream.pos = stream.start;
|
56 |
-
state.overlayCur = overlay.token(stream, state.overlay);
|
57 |
-
state.overlayPos = stream.pos;
|
58 |
-
}
|
59 |
-
stream.pos = Math.min(state.basePos, state.overlayPos);
|
60 |
-
|
61 |
-
// state.overlay.combineTokens always takes precedence over combine,
|
62 |
-
// unless set to null
|
63 |
-
if (state.overlayCur == null) return state.baseCur;
|
64 |
-
else if (state.baseCur != null &&
|
65 |
-
state.overlay.combineTokens ||
|
66 |
-
combine && state.overlay.combineTokens == null)
|
67 |
-
return state.baseCur + " " + state.overlayCur;
|
68 |
-
else return state.overlayCur;
|
69 |
-
},
|
70 |
-
|
71 |
-
indent: base.indent && function(state, textAfter) {
|
72 |
-
return base.indent(state.base, textAfter);
|
73 |
-
},
|
74 |
-
electricChars: base.electricChars,
|
75 |
-
|
76 |
-
innerMode: function(state) { return {state: state.base, mode: base}; },
|
77 |
-
|
78 |
-
blankLine: function(state) {
|
79 |
-
if (base.blankLine) base.blankLine(state.base);
|
80 |
-
if (overlay.blankLine) overlay.blankLine(state.overlay);
|
81 |
-
}
|
82 |
-
};
|
83 |
-
};
|
84 |
-
|
85 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/mode/simple.js
DELETED
@@ -1,213 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineSimpleMode = function(name, states) {
|
15 |
-
CodeMirror.defineMode(name, function(config) {
|
16 |
-
return CodeMirror.simpleMode(config, states);
|
17 |
-
});
|
18 |
-
};
|
19 |
-
|
20 |
-
CodeMirror.simpleMode = function(config, states) {
|
21 |
-
ensureState(states, "start");
|
22 |
-
var states_ = {}, meta = states.meta || {}, hasIndentation = false;
|
23 |
-
for (var state in states) if (state != meta && states.hasOwnProperty(state)) {
|
24 |
-
var list = states_[state] = [], orig = states[state];
|
25 |
-
for (var i = 0; i < orig.length; i++) {
|
26 |
-
var data = orig[i];
|
27 |
-
list.push(new Rule(data, states));
|
28 |
-
if (data.indent || data.dedent) hasIndentation = true;
|
29 |
-
}
|
30 |
-
}
|
31 |
-
var mode = {
|
32 |
-
startState: function() {
|
33 |
-
return {state: "start", pending: null,
|
34 |
-
local: null, localState: null,
|
35 |
-
indent: hasIndentation ? [] : null};
|
36 |
-
},
|
37 |
-
copyState: function(state) {
|
38 |
-
var s = {state: state.state, pending: state.pending,
|
39 |
-
local: state.local, localState: null,
|
40 |
-
indent: state.indent && state.indent.slice(0)};
|
41 |
-
if (state.localState)
|
42 |
-
s.localState = CodeMirror.copyState(state.local.mode, state.localState);
|
43 |
-
if (state.stack)
|
44 |
-
s.stack = state.stack.slice(0);
|
45 |
-
for (var pers = state.persistentStates; pers; pers = pers.next)
|
46 |
-
s.persistentStates = {mode: pers.mode,
|
47 |
-
spec: pers.spec,
|
48 |
-
state: pers.state == state.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state),
|
49 |
-
next: s.persistentStates};
|
50 |
-
return s;
|
51 |
-
},
|
52 |
-
token: tokenFunction(states_, config),
|
53 |
-
innerMode: function(state) { return state.local && {mode: state.local.mode, state: state.localState}; },
|
54 |
-
indent: indentFunction(states_, meta)
|
55 |
-
};
|
56 |
-
if (meta) for (var prop in meta) if (meta.hasOwnProperty(prop))
|
57 |
-
mode[prop] = meta[prop];
|
58 |
-
return mode;
|
59 |
-
};
|
60 |
-
|
61 |
-
function ensureState(states, name) {
|
62 |
-
if (!states.hasOwnProperty(name))
|
63 |
-
throw new Error("Undefined state " + name + "in simple mode");
|
64 |
-
}
|
65 |
-
|
66 |
-
function toRegex(val, caret) {
|
67 |
-
if (!val) return /(?:)/;
|
68 |
-
var flags = "";
|
69 |
-
if (val instanceof RegExp) {
|
70 |
-
if (val.ignoreCase) flags = "i";
|
71 |
-
val = val.source;
|
72 |
-
} else {
|
73 |
-
val = String(val);
|
74 |
-
}
|
75 |
-
return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
|
76 |
-
}
|
77 |
-
|
78 |
-
function asToken(val) {
|
79 |
-
if (!val) return null;
|
80 |
-
if (typeof val == "string") return val.replace(/\./g, " ");
|
81 |
-
var result = [];
|
82 |
-
for (var i = 0; i < val.length; i++)
|
83 |
-
result.push(val[i] && val[i].replace(/\./g, " "));
|
84 |
-
return result;
|
85 |
-
}
|
86 |
-
|
87 |
-
function Rule(data, states) {
|
88 |
-
if (data.next || data.push) ensureState(states, data.next || data.push);
|
89 |
-
this.regex = toRegex(data.regex);
|
90 |
-
this.token = asToken(data.token);
|
91 |
-
this.data = data;
|
92 |
-
}
|
93 |
-
|
94 |
-
function tokenFunction(states, config) {
|
95 |
-
return function(stream, state) {
|
96 |
-
if (state.pending) {
|
97 |
-
var pend = state.pending.shift();
|
98 |
-
if (state.pending.length == 0) state.pending = null;
|
99 |
-
stream.pos += pend.text.length;
|
100 |
-
return pend.token;
|
101 |
-
}
|
102 |
-
|
103 |
-
if (state.local) {
|
104 |
-
if (state.local.end && stream.match(state.local.end)) {
|
105 |
-
var tok = state.local.endToken || null;
|
106 |
-
state.local = state.localState = null;
|
107 |
-
return tok;
|
108 |
-
} else {
|
109 |
-
var tok = state.local.mode.token(stream, state.localState), m;
|
110 |
-
if (state.local.endScan && (m = state.local.endScan.exec(stream.current())))
|
111 |
-
stream.pos = stream.start + m.index;
|
112 |
-
return tok;
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
var curState = states[state.state];
|
117 |
-
for (var i = 0; i < curState.length; i++) {
|
118 |
-
var rule = curState[i];
|
119 |
-
var matches = (!rule.data.sol || stream.sol()) && stream.match(rule.regex);
|
120 |
-
if (matches) {
|
121 |
-
if (rule.data.next) {
|
122 |
-
state.state = rule.data.next;
|
123 |
-
} else if (rule.data.push) {
|
124 |
-
(state.stack || (state.stack = [])).push(state.state);
|
125 |
-
state.state = rule.data.push;
|
126 |
-
} else if (rule.data.pop && state.stack && state.stack.length) {
|
127 |
-
state.state = state.stack.pop();
|
128 |
-
}
|
129 |
-
|
130 |
-
if (rule.data.mode)
|
131 |
-
enterLocalMode(config, state, rule.data.mode, rule.token);
|
132 |
-
if (rule.data.indent)
|
133 |
-
state.indent.push(stream.indentation() + config.indentUnit);
|
134 |
-
if (rule.data.dedent)
|
135 |
-
state.indent.pop();
|
136 |
-
if (matches.length > 2) {
|
137 |
-
state.pending = [];
|
138 |
-
for (var j = 2; j < matches.length; j++)
|
139 |
-
if (matches[j])
|
140 |
-
state.pending.push({text: matches[j], token: rule.token[j - 1]});
|
141 |
-
stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
|
142 |
-
return rule.token[0];
|
143 |
-
} else if (rule.token && rule.token.join) {
|
144 |
-
return rule.token[0];
|
145 |
-
} else {
|
146 |
-
return rule.token;
|
147 |
-
}
|
148 |
-
}
|
149 |
-
}
|
150 |
-
stream.next();
|
151 |
-
return null;
|
152 |
-
};
|
153 |
-
}
|
154 |
-
|
155 |
-
function cmp(a, b) {
|
156 |
-
if (a === b) return true;
|
157 |
-
if (!a || typeof a != "object" || !b || typeof b != "object") return false;
|
158 |
-
var props = 0;
|
159 |
-
for (var prop in a) if (a.hasOwnProperty(prop)) {
|
160 |
-
if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false;
|
161 |
-
props++;
|
162 |
-
}
|
163 |
-
for (var prop in b) if (b.hasOwnProperty(prop)) props--;
|
164 |
-
return props == 0;
|
165 |
-
}
|
166 |
-
|
167 |
-
function enterLocalMode(config, state, spec, token) {
|
168 |
-
var pers;
|
169 |
-
if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next)
|
170 |
-
if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p;
|
171 |
-
var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec);
|
172 |
-
var lState = pers ? pers.state : CodeMirror.startState(mode);
|
173 |
-
if (spec.persistent && !pers)
|
174 |
-
state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates};
|
175 |
-
|
176 |
-
state.localState = lState;
|
177 |
-
state.local = {mode: mode,
|
178 |
-
end: spec.end && toRegex(spec.end),
|
179 |
-
endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
|
180 |
-
endToken: token && token.join ? token[token.length - 1] : token};
|
181 |
-
}
|
182 |
-
|
183 |
-
function indexOf(val, arr) {
|
184 |
-
for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true;
|
185 |
-
}
|
186 |
-
|
187 |
-
function indentFunction(states, meta) {
|
188 |
-
return function(state, textAfter, line) {
|
189 |
-
if (state.local && state.local.mode.indent)
|
190 |
-
return state.local.mode.indent(state.localState, textAfter, line);
|
191 |
-
if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1)
|
192 |
-
return CodeMirror.Pass;
|
193 |
-
|
194 |
-
var pos = state.indent.length - 1, rules = states[state.state];
|
195 |
-
scan: for (;;) {
|
196 |
-
for (var i = 0; i < rules.length; i++) {
|
197 |
-
var rule = rules[i];
|
198 |
-
if (rule.data.dedent && rule.data.dedentIfLineStart !== false) {
|
199 |
-
var m = rule.regex.exec(textAfter);
|
200 |
-
if (m && m[0]) {
|
201 |
-
pos--;
|
202 |
-
if (rule.next || rule.push) rules = states[rule.next || rule.push];
|
203 |
-
textAfter = textAfter.slice(m[0].length);
|
204 |
-
continue scan;
|
205 |
-
}
|
206 |
-
}
|
207 |
-
}
|
208 |
-
break;
|
209 |
-
}
|
210 |
-
return pos < 0 ? 0 : state.indent[pos];
|
211 |
-
};
|
212 |
-
}
|
213 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/runmode/colorize.js
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"), require("./runmode"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror", "./runmode"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var isBlock = /^(p|li|div|h\\d|pre|blockquote|td)$/;
|
15 |
-
|
16 |
-
function textContent(node, out) {
|
17 |
-
if (node.nodeType == 3) return out.push(node.nodeValue);
|
18 |
-
for (var ch = node.firstChild; ch; ch = ch.nextSibling) {
|
19 |
-
textContent(ch, out);
|
20 |
-
if (isBlock.test(node.nodeType)) out.push("\n");
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
CodeMirror.colorize = function(collection, defaultMode) {
|
25 |
-
if (!collection) collection = document.body.getElementsByTagName("pre");
|
26 |
-
|
27 |
-
for (var i = 0; i < collection.length; ++i) {
|
28 |
-
var node = collection[i];
|
29 |
-
var mode = node.getAttribute("data-lang") || defaultMode;
|
30 |
-
if (!mode) continue;
|
31 |
-
|
32 |
-
var text = [];
|
33 |
-
textContent(node, text);
|
34 |
-
node.innerHTML = "";
|
35 |
-
CodeMirror.runMode(text.join(""), mode, node);
|
36 |
-
|
37 |
-
node.className += " cm-s-default";
|
38 |
-
}
|
39 |
-
};
|
40 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/runmode/runmode-standalone.js
DELETED
@@ -1,157 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
window.CodeMirror = {};
|
5 |
-
|
6 |
-
(function() {
|
7 |
-
"use strict";
|
8 |
-
|
9 |
-
function splitLines(string){ return string.split(/\r?\n|\r/); };
|
10 |
-
|
11 |
-
function StringStream(string) {
|
12 |
-
this.pos = this.start = 0;
|
13 |
-
this.string = string;
|
14 |
-
this.lineStart = 0;
|
15 |
-
}
|
16 |
-
StringStream.prototype = {
|
17 |
-
eol: function() {return this.pos >= this.string.length;},
|
18 |
-
sol: function() {return this.pos == 0;},
|
19 |
-
peek: function() {return this.string.charAt(this.pos) || null;},
|
20 |
-
next: function() {
|
21 |
-
if (this.pos < this.string.length)
|
22 |
-
return this.string.charAt(this.pos++);
|
23 |
-
},
|
24 |
-
eat: function(match) {
|
25 |
-
var ch = this.string.charAt(this.pos);
|
26 |
-
if (typeof match == "string") var ok = ch == match;
|
27 |
-
else var ok = ch && (match.test ? match.test(ch) : match(ch));
|
28 |
-
if (ok) {++this.pos; return ch;}
|
29 |
-
},
|
30 |
-
eatWhile: function(match) {
|
31 |
-
var start = this.pos;
|
32 |
-
while (this.eat(match)){}
|
33 |
-
return this.pos > start;
|
34 |
-
},
|
35 |
-
eatSpace: function() {
|
36 |
-
var start = this.pos;
|
37 |
-
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
|
38 |
-
return this.pos > start;
|
39 |
-
},
|
40 |
-
skipToEnd: function() {this.pos = this.string.length;},
|
41 |
-
skipTo: function(ch) {
|
42 |
-
var found = this.string.indexOf(ch, this.pos);
|
43 |
-
if (found > -1) {this.pos = found; return true;}
|
44 |
-
},
|
45 |
-
backUp: function(n) {this.pos -= n;},
|
46 |
-
column: function() {return this.start - this.lineStart;},
|
47 |
-
indentation: function() {return 0;},
|
48 |
-
match: function(pattern, consume, caseInsensitive) {
|
49 |
-
if (typeof pattern == "string") {
|
50 |
-
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
51 |
-
var substr = this.string.substr(this.pos, pattern.length);
|
52 |
-
if (cased(substr) == cased(pattern)) {
|
53 |
-
if (consume !== false) this.pos += pattern.length;
|
54 |
-
return true;
|
55 |
-
}
|
56 |
-
} else {
|
57 |
-
var match = this.string.slice(this.pos).match(pattern);
|
58 |
-
if (match && match.index > 0) return null;
|
59 |
-
if (match && consume !== false) this.pos += match[0].length;
|
60 |
-
return match;
|
61 |
-
}
|
62 |
-
},
|
63 |
-
current: function(){return this.string.slice(this.start, this.pos);},
|
64 |
-
hideFirstChars: function(n, inner) {
|
65 |
-
this.lineStart += n;
|
66 |
-
try { return inner(); }
|
67 |
-
finally { this.lineStart -= n; }
|
68 |
-
}
|
69 |
-
};
|
70 |
-
CodeMirror.StringStream = StringStream;
|
71 |
-
|
72 |
-
CodeMirror.startState = function (mode, a1, a2) {
|
73 |
-
return mode.startState ? mode.startState(a1, a2) : true;
|
74 |
-
};
|
75 |
-
|
76 |
-
var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
|
77 |
-
CodeMirror.defineMode = function (name, mode) {
|
78 |
-
if (arguments.length > 2)
|
79 |
-
mode.dependencies = Array.prototype.slice.call(arguments, 2);
|
80 |
-
modes[name] = mode;
|
81 |
-
};
|
82 |
-
CodeMirror.defineMIME = function (mime, spec) { mimeModes[mime] = spec; };
|
83 |
-
CodeMirror.resolveMode = function(spec) {
|
84 |
-
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
|
85 |
-
spec = mimeModes[spec];
|
86 |
-
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
|
87 |
-
spec = mimeModes[spec.name];
|
88 |
-
}
|
89 |
-
if (typeof spec == "string") return {name: spec};
|
90 |
-
else return spec || {name: "null"};
|
91 |
-
};
|
92 |
-
CodeMirror.getMode = function (options, spec) {
|
93 |
-
spec = CodeMirror.resolveMode(spec);
|
94 |
-
var mfactory = modes[spec.name];
|
95 |
-
if (!mfactory) throw new Error("Unknown mode: " + spec);
|
96 |
-
return mfactory(options, spec);
|
97 |
-
};
|
98 |
-
CodeMirror.registerHelper = CodeMirror.registerGlobalHelper = Math.min;
|
99 |
-
CodeMirror.defineMode("null", function() {
|
100 |
-
return {token: function(stream) {stream.skipToEnd();}};
|
101 |
-
});
|
102 |
-
CodeMirror.defineMIME("text/plain", "null");
|
103 |
-
|
104 |
-
CodeMirror.runMode = function (string, modespec, callback, options) {
|
105 |
-
var mode = CodeMirror.getMode({ indentUnit: 2 }, modespec);
|
106 |
-
|
107 |
-
if (callback.nodeType == 1) {
|
108 |
-
var tabSize = (options && options.tabSize) || 4;
|
109 |
-
var node = callback, col = 0;
|
110 |
-
node.innerHTML = "";
|
111 |
-
callback = function (text, style) {
|
112 |
-
if (text == "\n") {
|
113 |
-
node.appendChild(document.createElement("br"));
|
114 |
-
col = 0;
|
115 |
-
return;
|
116 |
-
}
|
117 |
-
var content = "";
|
118 |
-
// replace tabs
|
119 |
-
for (var pos = 0; ;) {
|
120 |
-
var idx = text.indexOf("\t", pos);
|
121 |
-
if (idx == -1) {
|
122 |
-
content += text.slice(pos);
|
123 |
-
col += text.length - pos;
|
124 |
-
break;
|
125 |
-
} else {
|
126 |
-
col += idx - pos;
|
127 |
-
content += text.slice(pos, idx);
|
128 |
-
var size = tabSize - col % tabSize;
|
129 |
-
col += size;
|
130 |
-
for (var i = 0; i < size; ++i) content += " ";
|
131 |
-
pos = idx + 1;
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
if (style) {
|
136 |
-
var sp = node.appendChild(document.createElement("span"));
|
137 |
-
sp.className = "cm-" + style.replace(/ +/g, " cm-");
|
138 |
-
sp.appendChild(document.createTextNode(content));
|
139 |
-
} else {
|
140 |
-
node.appendChild(document.createTextNode(content));
|
141 |
-
}
|
142 |
-
};
|
143 |
-
}
|
144 |
-
|
145 |
-
var lines = splitLines(string), state = (options && options.state) || CodeMirror.startState(mode);
|
146 |
-
for (var i = 0, e = lines.length; i < e; ++i) {
|
147 |
-
if (i) callback("\n");
|
148 |
-
var stream = new CodeMirror.StringStream(lines[i]);
|
149 |
-
if (!stream.string && mode.blankLine) mode.blankLine(state);
|
150 |
-
while (!stream.eol()) {
|
151 |
-
var style = mode.token(stream, state);
|
152 |
-
callback(stream.current(), style, i, stream.start, state);
|
153 |
-
stream.start = stream.pos;
|
154 |
-
}
|
155 |
-
}
|
156 |
-
};
|
157 |
-
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/runmode/runmode.js
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.runMode = function(string, modespec, callback, options) {
|
15 |
-
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
|
16 |
-
var ie = /MSIE \d/.test(navigator.userAgent);
|
17 |
-
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
|
18 |
-
|
19 |
-
if (callback.nodeType == 1) {
|
20 |
-
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
|
21 |
-
var node = callback, col = 0;
|
22 |
-
node.innerHTML = "";
|
23 |
-
callback = function(text, style) {
|
24 |
-
if (text == "\n") {
|
25 |
-
// Emitting LF or CRLF on IE8 or earlier results in an incorrect display.
|
26 |
-
// Emitting a carriage return makes everything ok.
|
27 |
-
node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text));
|
28 |
-
col = 0;
|
29 |
-
return;
|
30 |
-
}
|
31 |
-
var content = "";
|
32 |
-
// replace tabs
|
33 |
-
for (var pos = 0;;) {
|
34 |
-
var idx = text.indexOf("\t", pos);
|
35 |
-
if (idx == -1) {
|
36 |
-
content += text.slice(pos);
|
37 |
-
col += text.length - pos;
|
38 |
-
break;
|
39 |
-
} else {
|
40 |
-
col += idx - pos;
|
41 |
-
content += text.slice(pos, idx);
|
42 |
-
var size = tabSize - col % tabSize;
|
43 |
-
col += size;
|
44 |
-
for (var i = 0; i < size; ++i) content += " ";
|
45 |
-
pos = idx + 1;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
if (style) {
|
50 |
-
var sp = node.appendChild(document.createElement("span"));
|
51 |
-
sp.className = "cm-" + style.replace(/ +/g, " cm-");
|
52 |
-
sp.appendChild(document.createTextNode(content));
|
53 |
-
} else {
|
54 |
-
node.appendChild(document.createTextNode(content));
|
55 |
-
}
|
56 |
-
};
|
57 |
-
}
|
58 |
-
|
59 |
-
var lines = CodeMirror.splitLines(string), state = (options && options.state) || CodeMirror.startState(mode);
|
60 |
-
for (var i = 0, e = lines.length; i < e; ++i) {
|
61 |
-
if (i) callback("\n");
|
62 |
-
var stream = new CodeMirror.StringStream(lines[i]);
|
63 |
-
if (!stream.string && mode.blankLine) mode.blankLine(state);
|
64 |
-
while (!stream.eol()) {
|
65 |
-
var style = mode.token(stream, state);
|
66 |
-
callback(stream.current(), style, i, stream.start, state);
|
67 |
-
stream.start = stream.pos;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
};
|
71 |
-
|
72 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/runmode/runmode.node.js
DELETED
@@ -1,179 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
/* Just enough of CodeMirror to run runMode under node.js */
|
5 |
-
|
6 |
-
function splitLines(string){return string.split(/\r\n?|\n/);};
|
7 |
-
|
8 |
-
// Counts the column offset in a string, taking tabs into account.
|
9 |
-
// Used mostly to find indentation.
|
10 |
-
var countColumn = function(string, end, tabSize, startIndex, startValue) {
|
11 |
-
if (end == null) {
|
12 |
-
end = string.search(/[^\s\u00a0]/);
|
13 |
-
if (end == -1) end = string.length;
|
14 |
-
}
|
15 |
-
for (var i = startIndex || 0, n = startValue || 0;;) {
|
16 |
-
var nextTab = string.indexOf("\t", i);
|
17 |
-
if (nextTab < 0 || nextTab >= end)
|
18 |
-
return n + (end - i);
|
19 |
-
n += nextTab - i;
|
20 |
-
n += tabSize - (n % tabSize);
|
21 |
-
i = nextTab + 1;
|
22 |
-
}
|
23 |
-
};
|
24 |
-
|
25 |
-
function StringStream(string, tabSize) {
|
26 |
-
this.pos = this.start = 0;
|
27 |
-
this.string = string;
|
28 |
-
this.tabSize = tabSize || 8;
|
29 |
-
this.lastColumnPos = this.lastColumnValue = 0;
|
30 |
-
this.lineStart = 0;
|
31 |
-
};
|
32 |
-
|
33 |
-
StringStream.prototype = {
|
34 |
-
eol: function() {return this.pos >= this.string.length;},
|
35 |
-
sol: function() {return this.pos == this.lineStart;},
|
36 |
-
peek: function() {return this.string.charAt(this.pos) || undefined;},
|
37 |
-
next: function() {
|
38 |
-
if (this.pos < this.string.length)
|
39 |
-
return this.string.charAt(this.pos++);
|
40 |
-
},
|
41 |
-
eat: function(match) {
|
42 |
-
var ch = this.string.charAt(this.pos);
|
43 |
-
if (typeof match == "string") var ok = ch == match;
|
44 |
-
else var ok = ch && (match.test ? match.test(ch) : match(ch));
|
45 |
-
if (ok) {++this.pos; return ch;}
|
46 |
-
},
|
47 |
-
eatWhile: function(match) {
|
48 |
-
var start = this.pos;
|
49 |
-
while (this.eat(match)){}
|
50 |
-
return this.pos > start;
|
51 |
-
},
|
52 |
-
eatSpace: function() {
|
53 |
-
var start = this.pos;
|
54 |
-
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
|
55 |
-
return this.pos > start;
|
56 |
-
},
|
57 |
-
skipToEnd: function() {this.pos = this.string.length;},
|
58 |
-
skipTo: function(ch) {
|
59 |
-
var found = this.string.indexOf(ch, this.pos);
|
60 |
-
if (found > -1) {this.pos = found; return true;}
|
61 |
-
},
|
62 |
-
backUp: function(n) {this.pos -= n;},
|
63 |
-
column: function() {
|
64 |
-
if (this.lastColumnPos < this.start) {
|
65 |
-
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
|
66 |
-
this.lastColumnPos = this.start;
|
67 |
-
}
|
68 |
-
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
69 |
-
},
|
70 |
-
indentation: function() {
|
71 |
-
return countColumn(this.string, null, this.tabSize) -
|
72 |
-
(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
73 |
-
},
|
74 |
-
match: function(pattern, consume, caseInsensitive) {
|
75 |
-
if (typeof pattern == "string") {
|
76 |
-
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
77 |
-
var substr = this.string.substr(this.pos, pattern.length);
|
78 |
-
if (cased(substr) == cased(pattern)) {
|
79 |
-
if (consume !== false) this.pos += pattern.length;
|
80 |
-
return true;
|
81 |
-
}
|
82 |
-
} else {
|
83 |
-
var match = this.string.slice(this.pos).match(pattern);
|
84 |
-
if (match && match.index > 0) return null;
|
85 |
-
if (match && consume !== false) this.pos += match[0].length;
|
86 |
-
return match;
|
87 |
-
}
|
88 |
-
},
|
89 |
-
current: function(){return this.string.slice(this.start, this.pos);},
|
90 |
-
hideFirstChars: function(n, inner) {
|
91 |
-
this.lineStart += n;
|
92 |
-
try { return inner(); }
|
93 |
-
finally { this.lineStart -= n; }
|
94 |
-
}
|
95 |
-
};
|
96 |
-
exports.StringStream = StringStream;
|
97 |
-
|
98 |
-
exports.startState = function(mode, a1, a2) {
|
99 |
-
return mode.startState ? mode.startState(a1, a2) : true;
|
100 |
-
};
|
101 |
-
|
102 |
-
var modes = exports.modes = {}, mimeModes = exports.mimeModes = {};
|
103 |
-
exports.defineMode = function(name, mode) {
|
104 |
-
if (arguments.length > 2)
|
105 |
-
mode.dependencies = Array.prototype.slice.call(arguments, 2);
|
106 |
-
modes[name] = mode;
|
107 |
-
};
|
108 |
-
exports.defineMIME = function(mime, spec) { mimeModes[mime] = spec; };
|
109 |
-
|
110 |
-
exports.defineMode("null", function() {
|
111 |
-
return {token: function(stream) {stream.skipToEnd();}};
|
112 |
-
});
|
113 |
-
exports.defineMIME("text/plain", "null");
|
114 |
-
|
115 |
-
exports.resolveMode = function(spec) {
|
116 |
-
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
|
117 |
-
spec = mimeModes[spec];
|
118 |
-
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
|
119 |
-
spec = mimeModes[spec.name];
|
120 |
-
}
|
121 |
-
if (typeof spec == "string") return {name: spec};
|
122 |
-
else return spec || {name: "null"};
|
123 |
-
};
|
124 |
-
|
125 |
-
function copyObj(obj, target, overwrite) {
|
126 |
-
if (!target) target = {};
|
127 |
-
for (var prop in obj)
|
128 |
-
if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
|
129 |
-
target[prop] = obj[prop];
|
130 |
-
return target;
|
131 |
-
}
|
132 |
-
|
133 |
-
// This can be used to attach properties to mode objects from
|
134 |
-
// outside the actual mode definition.
|
135 |
-
var modeExtensions = exports.modeExtensions = {};
|
136 |
-
exports.extendMode = function(mode, properties) {
|
137 |
-
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
|
138 |
-
copyObj(properties, exts);
|
139 |
-
};
|
140 |
-
|
141 |
-
exports.getMode = function(options, spec) {
|
142 |
-
var spec = exports.resolveMode(spec);
|
143 |
-
var mfactory = modes[spec.name];
|
144 |
-
if (!mfactory) return exports.getMode(options, "text/plain");
|
145 |
-
var modeObj = mfactory(options, spec);
|
146 |
-
if (modeExtensions.hasOwnProperty(spec.name)) {
|
147 |
-
var exts = modeExtensions[spec.name];
|
148 |
-
for (var prop in exts) {
|
149 |
-
if (!exts.hasOwnProperty(prop)) continue;
|
150 |
-
if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
|
151 |
-
modeObj[prop] = exts[prop];
|
152 |
-
}
|
153 |
-
}
|
154 |
-
modeObj.name = spec.name;
|
155 |
-
if (spec.helperType) modeObj.helperType = spec.helperType;
|
156 |
-
if (spec.modeProps) for (var prop in spec.modeProps)
|
157 |
-
modeObj[prop] = spec.modeProps[prop];
|
158 |
-
|
159 |
-
return modeObj;
|
160 |
-
};
|
161 |
-
exports.registerHelper = exports.registerGlobalHelper = Math.min;
|
162 |
-
|
163 |
-
exports.runMode = function(string, modespec, callback, options) {
|
164 |
-
var mode = exports.getMode({indentUnit: 2}, modespec);
|
165 |
-
var lines = splitLines(string), state = (options && options.state) || exports.startState(mode);
|
166 |
-
for (var i = 0, e = lines.length; i < e; ++i) {
|
167 |
-
if (i) callback("\n");
|
168 |
-
var stream = new exports.StringStream(lines[i]);
|
169 |
-
if (!stream.string && mode.blankLine) mode.blankLine(state);
|
170 |
-
while (!stream.eol()) {
|
171 |
-
var style = mode.token(stream, state);
|
172 |
-
callback(stream.current(), style, i, stream.start, state);
|
173 |
-
stream.start = stream.pos;
|
174 |
-
}
|
175 |
-
}
|
176 |
-
};
|
177 |
-
|
178 |
-
require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")];
|
179 |
-
require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/scroll/annotatescrollbar.js
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineExtension("annotateScrollbar", function(options) {
|
15 |
-
if (typeof options == "string") options = {className: options};
|
16 |
-
return new Annotation(this, options);
|
17 |
-
});
|
18 |
-
|
19 |
-
CodeMirror.defineOption("scrollButtonHeight", 0);
|
20 |
-
|
21 |
-
function Annotation(cm, options) {
|
22 |
-
this.cm = cm;
|
23 |
-
this.options = options;
|
24 |
-
this.buttonHeight = options.scrollButtonHeight || cm.getOption("scrollButtonHeight");
|
25 |
-
this.annotations = [];
|
26 |
-
this.doRedraw = this.doUpdate = null;
|
27 |
-
this.div = cm.getWrapperElement().appendChild(document.createElement("div"));
|
28 |
-
this.div.style.cssText = "position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none";
|
29 |
-
this.computeScale();
|
30 |
-
|
31 |
-
function scheduleRedraw(delay) {
|
32 |
-
clearTimeout(self.doRedraw);
|
33 |
-
self.doRedraw = setTimeout(function() { self.redraw(); }, delay);
|
34 |
-
}
|
35 |
-
|
36 |
-
var self = this;
|
37 |
-
cm.on("refresh", this.resizeHandler = function() {
|
38 |
-
clearTimeout(self.doUpdate);
|
39 |
-
self.doUpdate = setTimeout(function() {
|
40 |
-
if (self.computeScale()) scheduleRedraw(20);
|
41 |
-
}, 100);
|
42 |
-
});
|
43 |
-
cm.on("markerAdded", this.resizeHandler);
|
44 |
-
cm.on("markerCleared", this.resizeHandler);
|
45 |
-
if (options.listenForChanges !== false)
|
46 |
-
cm.on("change", this.changeHandler = function() {
|
47 |
-
scheduleRedraw(250);
|
48 |
-
});
|
49 |
-
}
|
50 |
-
|
51 |
-
Annotation.prototype.computeScale = function() {
|
52 |
-
var cm = this.cm;
|
53 |
-
var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
|
54 |
-
cm.getScrollerElement().scrollHeight
|
55 |
-
if (hScale != this.hScale) {
|
56 |
-
this.hScale = hScale;
|
57 |
-
return true;
|
58 |
-
}
|
59 |
-
};
|
60 |
-
|
61 |
-
Annotation.prototype.update = function(annotations) {
|
62 |
-
this.annotations = annotations;
|
63 |
-
this.redraw();
|
64 |
-
};
|
65 |
-
|
66 |
-
Annotation.prototype.redraw = function(compute) {
|
67 |
-
if (compute !== false) this.computeScale();
|
68 |
-
var cm = this.cm, hScale = this.hScale;
|
69 |
-
|
70 |
-
var frag = document.createDocumentFragment(), anns = this.annotations;
|
71 |
-
|
72 |
-
var wrapping = cm.getOption("lineWrapping");
|
73 |
-
var singleLineH = wrapping && cm.defaultTextHeight() * 1.5;
|
74 |
-
var curLine = null, curLineObj = null;
|
75 |
-
function getY(pos, top) {
|
76 |
-
if (curLine != pos.line) {
|
77 |
-
curLine = pos.line;
|
78 |
-
curLineObj = cm.getLineHandle(curLine);
|
79 |
-
}
|
80 |
-
if (wrapping && curLineObj.height > singleLineH)
|
81 |
-
return cm.charCoords(pos, "local")[top ? "top" : "bottom"];
|
82 |
-
var topY = cm.heightAtLine(curLineObj, "local");
|
83 |
-
return topY + (top ? 0 : curLineObj.height);
|
84 |
-
}
|
85 |
-
|
86 |
-
if (cm.display.barWidth) for (var i = 0, nextTop; i < anns.length; i++) {
|
87 |
-
var ann = anns[i];
|
88 |
-
var top = nextTop || getY(ann.from, true) * hScale;
|
89 |
-
var bottom = getY(ann.to, false) * hScale;
|
90 |
-
while (i < anns.length - 1) {
|
91 |
-
nextTop = getY(anns[i + 1].from, true) * hScale;
|
92 |
-
if (nextTop > bottom + .9) break;
|
93 |
-
ann = anns[++i];
|
94 |
-
bottom = getY(ann.to, false) * hScale;
|
95 |
-
}
|
96 |
-
if (bottom == top) continue;
|
97 |
-
var height = Math.max(bottom - top, 3);
|
98 |
-
|
99 |
-
var elt = frag.appendChild(document.createElement("div"));
|
100 |
-
elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
|
101 |
-
+ (top + this.buttonHeight) + "px; height: " + height + "px";
|
102 |
-
elt.className = this.options.className;
|
103 |
-
}
|
104 |
-
this.div.textContent = "";
|
105 |
-
this.div.appendChild(frag);
|
106 |
-
};
|
107 |
-
|
108 |
-
Annotation.prototype.clear = function() {
|
109 |
-
this.cm.off("refresh", this.resizeHandler);
|
110 |
-
this.cm.off("markerAdded", this.resizeHandler);
|
111 |
-
this.cm.off("markerCleared", this.resizeHandler);
|
112 |
-
if (this.changeHandler) this.cm.off("change", this.changeHandler);
|
113 |
-
this.div.parentNode.removeChild(this.div);
|
114 |
-
};
|
115 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/scroll/scrollpastend.js
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) {
|
15 |
-
if (old && old != CodeMirror.Init) {
|
16 |
-
cm.off("change", onChange);
|
17 |
-
cm.off("refresh", updateBottomMargin);
|
18 |
-
cm.display.lineSpace.parentNode.style.paddingBottom = "";
|
19 |
-
cm.state.scrollPastEndPadding = null;
|
20 |
-
}
|
21 |
-
if (val) {
|
22 |
-
cm.on("change", onChange);
|
23 |
-
cm.on("refresh", updateBottomMargin);
|
24 |
-
updateBottomMargin(cm);
|
25 |
-
}
|
26 |
-
});
|
27 |
-
|
28 |
-
function onChange(cm, change) {
|
29 |
-
if (CodeMirror.changeEnd(change).line == cm.lastLine())
|
30 |
-
updateBottomMargin(cm);
|
31 |
-
}
|
32 |
-
|
33 |
-
function updateBottomMargin(cm) {
|
34 |
-
var padding = "";
|
35 |
-
if (cm.lineCount() > 1) {
|
36 |
-
var totalH = cm.display.scroller.clientHeight - 30,
|
37 |
-
lastLineH = cm.getLineHandle(cm.lastLine()).height;
|
38 |
-
padding = (totalH - lastLineH) + "px";
|
39 |
-
}
|
40 |
-
if (cm.state.scrollPastEndPadding != padding) {
|
41 |
-
cm.state.scrollPastEndPadding = padding;
|
42 |
-
cm.display.lineSpace.parentNode.style.paddingBottom = padding;
|
43 |
-
cm.setSize();
|
44 |
-
}
|
45 |
-
}
|
46 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/scroll/simplescrollbars.css
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
|
2 |
-
position: absolute;
|
3 |
-
background: #ccc;
|
4 |
-
-moz-box-sizing: border-box;
|
5 |
-
box-sizing: border-box;
|
6 |
-
border: 1px solid #bbb;
|
7 |
-
border-radius: 2px;
|
8 |
-
}
|
9 |
-
|
10 |
-
.CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
|
11 |
-
position: absolute;
|
12 |
-
z-index: 6;
|
13 |
-
background: #eee;
|
14 |
-
}
|
15 |
-
|
16 |
-
.CodeMirror-simplescroll-horizontal {
|
17 |
-
bottom: 0; left: 0;
|
18 |
-
height: 8px;
|
19 |
-
}
|
20 |
-
.CodeMirror-simplescroll-horizontal div {
|
21 |
-
bottom: 0;
|
22 |
-
height: 100%;
|
23 |
-
}
|
24 |
-
|
25 |
-
.CodeMirror-simplescroll-vertical {
|
26 |
-
right: 0; top: 0;
|
27 |
-
width: 8px;
|
28 |
-
}
|
29 |
-
.CodeMirror-simplescroll-vertical div {
|
30 |
-
right: 0;
|
31 |
-
width: 100%;
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler {
|
36 |
-
display: none;
|
37 |
-
}
|
38 |
-
|
39 |
-
.CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div {
|
40 |
-
position: absolute;
|
41 |
-
background: #bcd;
|
42 |
-
border-radius: 3px;
|
43 |
-
}
|
44 |
-
|
45 |
-
.CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical {
|
46 |
-
position: absolute;
|
47 |
-
z-index: 6;
|
48 |
-
}
|
49 |
-
|
50 |
-
.CodeMirror-overlayscroll-horizontal {
|
51 |
-
bottom: 0; left: 0;
|
52 |
-
height: 6px;
|
53 |
-
}
|
54 |
-
.CodeMirror-overlayscroll-horizontal div {
|
55 |
-
bottom: 0;
|
56 |
-
height: 100%;
|
57 |
-
}
|
58 |
-
|
59 |
-
.CodeMirror-overlayscroll-vertical {
|
60 |
-
right: 0; top: 0;
|
61 |
-
width: 6px;
|
62 |
-
}
|
63 |
-
.CodeMirror-overlayscroll-vertical div {
|
64 |
-
right: 0;
|
65 |
-
width: 100%;
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/scroll/simplescrollbars.js
DELETED
@@ -1,147 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
function Bar(cls, orientation, scroll) {
|
15 |
-
this.orientation = orientation;
|
16 |
-
this.scroll = scroll;
|
17 |
-
this.screen = this.total = this.size = 1;
|
18 |
-
this.pos = 0;
|
19 |
-
|
20 |
-
this.node = document.createElement("div");
|
21 |
-
this.node.className = cls + "-" + orientation;
|
22 |
-
this.inner = this.node.appendChild(document.createElement("div"));
|
23 |
-
|
24 |
-
var self = this;
|
25 |
-
CodeMirror.on(this.inner, "mousedown", function(e) {
|
26 |
-
if (e.which != 1) return;
|
27 |
-
CodeMirror.e_preventDefault(e);
|
28 |
-
var axis = self.orientation == "horizontal" ? "pageX" : "pageY";
|
29 |
-
var start = e[axis], startpos = self.pos;
|
30 |
-
function done() {
|
31 |
-
CodeMirror.off(document, "mousemove", move);
|
32 |
-
CodeMirror.off(document, "mouseup", done);
|
33 |
-
}
|
34 |
-
function move(e) {
|
35 |
-
if (e.which != 1) return done();
|
36 |
-
self.moveTo(startpos + (e[axis] - start) * (self.total / self.size));
|
37 |
-
}
|
38 |
-
CodeMirror.on(document, "mousemove", move);
|
39 |
-
CodeMirror.on(document, "mouseup", done);
|
40 |
-
});
|
41 |
-
|
42 |
-
CodeMirror.on(this.node, "click", function(e) {
|
43 |
-
CodeMirror.e_preventDefault(e);
|
44 |
-
var innerBox = self.inner.getBoundingClientRect(), where;
|
45 |
-
if (self.orientation == "horizontal")
|
46 |
-
where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0;
|
47 |
-
else
|
48 |
-
where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0;
|
49 |
-
self.moveTo(self.pos + where * self.screen);
|
50 |
-
});
|
51 |
-
|
52 |
-
function onWheel(e) {
|
53 |
-
var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"];
|
54 |
-
var oldPos = self.pos;
|
55 |
-
self.moveTo(self.pos + moved);
|
56 |
-
if (self.pos != oldPos) CodeMirror.e_preventDefault(e);
|
57 |
-
}
|
58 |
-
CodeMirror.on(this.node, "mousewheel", onWheel);
|
59 |
-
CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
|
60 |
-
}
|
61 |
-
|
62 |
-
Bar.prototype.moveTo = function(pos, update) {
|
63 |
-
if (pos < 0) pos = 0;
|
64 |
-
if (pos > this.total - this.screen) pos = this.total - this.screen;
|
65 |
-
if (pos == this.pos) return;
|
66 |
-
this.pos = pos;
|
67 |
-
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
|
68 |
-
(pos * (this.size / this.total)) + "px";
|
69 |
-
if (update !== false) this.scroll(pos, this.orientation);
|
70 |
-
};
|
71 |
-
|
72 |
-
var minButtonSize = 10;
|
73 |
-
|
74 |
-
Bar.prototype.update = function(scrollSize, clientSize, barSize) {
|
75 |
-
this.screen = clientSize;
|
76 |
-
this.total = scrollSize;
|
77 |
-
this.size = barSize;
|
78 |
-
|
79 |
-
var buttonSize = this.screen * (this.size / this.total);
|
80 |
-
if (buttonSize < minButtonSize) {
|
81 |
-
this.size -= minButtonSize - buttonSize;
|
82 |
-
buttonSize = minButtonSize;
|
83 |
-
}
|
84 |
-
this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
|
85 |
-
buttonSize + "px";
|
86 |
-
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
|
87 |
-
this.pos * (this.size / this.total) + "px";
|
88 |
-
};
|
89 |
-
|
90 |
-
function SimpleScrollbars(cls, place, scroll) {
|
91 |
-
this.addClass = cls;
|
92 |
-
this.horiz = new Bar(cls, "horizontal", scroll);
|
93 |
-
place(this.horiz.node);
|
94 |
-
this.vert = new Bar(cls, "vertical", scroll);
|
95 |
-
place(this.vert.node);
|
96 |
-
this.width = null;
|
97 |
-
}
|
98 |
-
|
99 |
-
SimpleScrollbars.prototype.update = function(measure) {
|
100 |
-
if (this.width == null) {
|
101 |
-
var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle;
|
102 |
-
if (style) this.width = parseInt(style.height);
|
103 |
-
}
|
104 |
-
var width = this.width || 0;
|
105 |
-
|
106 |
-
var needsH = measure.scrollWidth > measure.clientWidth + 1;
|
107 |
-
var needsV = measure.scrollHeight > measure.clientHeight + 1;
|
108 |
-
this.vert.node.style.display = needsV ? "block" : "none";
|
109 |
-
this.horiz.node.style.display = needsH ? "block" : "none";
|
110 |
-
|
111 |
-
if (needsV) {
|
112 |
-
this.vert.update(measure.scrollHeight, measure.clientHeight,
|
113 |
-
measure.viewHeight - (needsH ? width : 0));
|
114 |
-
this.vert.node.style.display = "block";
|
115 |
-
this.vert.node.style.bottom = needsH ? width + "px" : "0";
|
116 |
-
}
|
117 |
-
if (needsH) {
|
118 |
-
this.horiz.update(measure.scrollWidth, measure.clientWidth,
|
119 |
-
measure.viewWidth - (needsV ? width : 0) - measure.barLeft);
|
120 |
-
this.horiz.node.style.right = needsV ? width + "px" : "0";
|
121 |
-
this.horiz.node.style.left = measure.barLeft + "px";
|
122 |
-
}
|
123 |
-
|
124 |
-
return {right: needsV ? width : 0, bottom: needsH ? width : 0};
|
125 |
-
};
|
126 |
-
|
127 |
-
SimpleScrollbars.prototype.setScrollTop = function(pos) {
|
128 |
-
this.vert.moveTo(pos, false);
|
129 |
-
};
|
130 |
-
|
131 |
-
SimpleScrollbars.prototype.setScrollLeft = function(pos) {
|
132 |
-
this.horiz.moveTo(pos, false);
|
133 |
-
};
|
134 |
-
|
135 |
-
SimpleScrollbars.prototype.clear = function() {
|
136 |
-
var parent = this.horiz.node.parentNode;
|
137 |
-
parent.removeChild(this.horiz.node);
|
138 |
-
parent.removeChild(this.vert.node);
|
139 |
-
};
|
140 |
-
|
141 |
-
CodeMirror.scrollbarModel.simple = function(place, scroll) {
|
142 |
-
return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll);
|
143 |
-
};
|
144 |
-
CodeMirror.scrollbarModel.overlay = function(place, scroll) {
|
145 |
-
return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll);
|
146 |
-
};
|
147 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/search/match-highlighter.js
DELETED
@@ -1,128 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Highlighting text that matches the selection
|
5 |
-
//
|
6 |
-
// Defines an option highlightSelectionMatches, which, when enabled,
|
7 |
-
// will style strings that match the selection throughout the
|
8 |
-
// document.
|
9 |
-
//
|
10 |
-
// The option can be set to true to simply enable it, or to a
|
11 |
-
// {minChars, style, wordsOnly, showToken, delay} object to explicitly
|
12 |
-
// configure it. minChars is the minimum amount of characters that should be
|
13 |
-
// selected for the behavior to occur, and style is the token style to
|
14 |
-
// apply to the matches. This will be prefixed by "cm-" to create an
|
15 |
-
// actual CSS class name. If wordsOnly is enabled, the matches will be
|
16 |
-
// highlighted only if the selected text is a word. showToken, when enabled,
|
17 |
-
// will cause the current token to be highlighted when nothing is selected.
|
18 |
-
// delay is used to specify how much time to wait, in milliseconds, before
|
19 |
-
// highlighting the matches.
|
20 |
-
|
21 |
-
(function(mod) {
|
22 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
23 |
-
mod(require("../../lib/codemirror"));
|
24 |
-
else if (typeof define == "function" && define.amd) // AMD
|
25 |
-
define(["../../lib/codemirror"], mod);
|
26 |
-
else // Plain browser env
|
27 |
-
mod(CodeMirror);
|
28 |
-
})(function(CodeMirror) {
|
29 |
-
"use strict";
|
30 |
-
|
31 |
-
var DEFAULT_MIN_CHARS = 2;
|
32 |
-
var DEFAULT_TOKEN_STYLE = "matchhighlight";
|
33 |
-
var DEFAULT_DELAY = 100;
|
34 |
-
var DEFAULT_WORDS_ONLY = false;
|
35 |
-
|
36 |
-
function State(options) {
|
37 |
-
if (typeof options == "object") {
|
38 |
-
this.minChars = options.minChars;
|
39 |
-
this.style = options.style;
|
40 |
-
this.showToken = options.showToken;
|
41 |
-
this.delay = options.delay;
|
42 |
-
this.wordsOnly = options.wordsOnly;
|
43 |
-
}
|
44 |
-
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
|
45 |
-
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
|
46 |
-
if (this.delay == null) this.delay = DEFAULT_DELAY;
|
47 |
-
if (this.wordsOnly == null) this.wordsOnly = DEFAULT_WORDS_ONLY;
|
48 |
-
this.overlay = this.timeout = null;
|
49 |
-
}
|
50 |
-
|
51 |
-
CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
|
52 |
-
if (old && old != CodeMirror.Init) {
|
53 |
-
var over = cm.state.matchHighlighter.overlay;
|
54 |
-
if (over) cm.removeOverlay(over);
|
55 |
-
clearTimeout(cm.state.matchHighlighter.timeout);
|
56 |
-
cm.state.matchHighlighter = null;
|
57 |
-
cm.off("cursorActivity", cursorActivity);
|
58 |
-
}
|
59 |
-
if (val) {
|
60 |
-
cm.state.matchHighlighter = new State(val);
|
61 |
-
highlightMatches(cm);
|
62 |
-
cm.on("cursorActivity", cursorActivity);
|
63 |
-
}
|
64 |
-
});
|
65 |
-
|
66 |
-
function cursorActivity(cm) {
|
67 |
-
var state = cm.state.matchHighlighter;
|
68 |
-
clearTimeout(state.timeout);
|
69 |
-
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay);
|
70 |
-
}
|
71 |
-
|
72 |
-
function highlightMatches(cm) {
|
73 |
-
cm.operation(function() {
|
74 |
-
var state = cm.state.matchHighlighter;
|
75 |
-
if (state.overlay) {
|
76 |
-
cm.removeOverlay(state.overlay);
|
77 |
-
state.overlay = null;
|
78 |
-
}
|
79 |
-
if (!cm.somethingSelected() && state.showToken) {
|
80 |
-
var re = state.showToken === true ? /[\w$]/ : state.showToken;
|
81 |
-
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
|
82 |
-
while (start && re.test(line.charAt(start - 1))) --start;
|
83 |
-
while (end < line.length && re.test(line.charAt(end))) ++end;
|
84 |
-
if (start < end)
|
85 |
-
cm.addOverlay(state.overlay = makeOverlay(line.slice(start, end), re, state.style));
|
86 |
-
return;
|
87 |
-
}
|
88 |
-
var from = cm.getCursor("from"), to = cm.getCursor("to");
|
89 |
-
if (from.line != to.line) return;
|
90 |
-
if (state.wordsOnly && !isWord(cm, from, to)) return;
|
91 |
-
var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
|
92 |
-
if (selection.length >= state.minChars)
|
93 |
-
cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style));
|
94 |
-
});
|
95 |
-
}
|
96 |
-
|
97 |
-
function isWord(cm, from, to) {
|
98 |
-
var str = cm.getRange(from, to);
|
99 |
-
if (str.match(/^\w+$/) !== null) {
|
100 |
-
if (from.ch > 0) {
|
101 |
-
var pos = {line: from.line, ch: from.ch - 1};
|
102 |
-
var chr = cm.getRange(pos, from);
|
103 |
-
if (chr.match(/\W/) === null) return false;
|
104 |
-
}
|
105 |
-
if (to.ch < cm.getLine(from.line).length) {
|
106 |
-
var pos = {line: to.line, ch: to.ch + 1};
|
107 |
-
var chr = cm.getRange(to, pos);
|
108 |
-
if (chr.match(/\W/) === null) return false;
|
109 |
-
}
|
110 |
-
return true;
|
111 |
-
} else return false;
|
112 |
-
}
|
113 |
-
|
114 |
-
function boundariesAround(stream, re) {
|
115 |
-
return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) &&
|
116 |
-
(stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos)));
|
117 |
-
}
|
118 |
-
|
119 |
-
function makeOverlay(query, hasBoundary, style) {
|
120 |
-
return {token: function(stream) {
|
121 |
-
if (stream.match(query) &&
|
122 |
-
(!hasBoundary || boundariesAround(stream, hasBoundary)))
|
123 |
-
return style;
|
124 |
-
stream.next();
|
125 |
-
stream.skipTo(query.charAt(0)) || stream.skipToEnd();
|
126 |
-
}};
|
127 |
-
}
|
128 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/search/matchesonscrollbar.css
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
.CodeMirror-search-match {
|
2 |
-
background: gold;
|
3 |
-
border-top: 1px solid orange;
|
4 |
-
border-bottom: 1px solid orange;
|
5 |
-
-moz-box-sizing: border-box;
|
6 |
-
box-sizing: border-box;
|
7 |
-
opacity: .5;
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/search/matchesonscrollbar.js
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"), require("./searchcursor"), require("../scroll/annotatescrollbar"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror", "./searchcursor", "../scroll/annotatescrollbar"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, options) {
|
15 |
-
if (typeof options == "string") options = {className: options};
|
16 |
-
if (!options) options = {};
|
17 |
-
return new SearchAnnotation(this, query, caseFold, options);
|
18 |
-
});
|
19 |
-
|
20 |
-
function SearchAnnotation(cm, query, caseFold, options) {
|
21 |
-
this.cm = cm;
|
22 |
-
this.options = options;
|
23 |
-
var annotateOptions = {listenForChanges: false};
|
24 |
-
for (var prop in options) annotateOptions[prop] = options[prop];
|
25 |
-
if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match";
|
26 |
-
this.annotation = cm.annotateScrollbar(annotateOptions);
|
27 |
-
this.query = query;
|
28 |
-
this.caseFold = caseFold;
|
29 |
-
this.gap = {from: cm.firstLine(), to: cm.lastLine() + 1};
|
30 |
-
this.matches = [];
|
31 |
-
this.update = null;
|
32 |
-
|
33 |
-
this.findMatches();
|
34 |
-
this.annotation.update(this.matches);
|
35 |
-
|
36 |
-
var self = this;
|
37 |
-
cm.on("change", this.changeHandler = function(_cm, change) { self.onChange(change); });
|
38 |
-
}
|
39 |
-
|
40 |
-
var MAX_MATCHES = 1000;
|
41 |
-
|
42 |
-
SearchAnnotation.prototype.findMatches = function() {
|
43 |
-
if (!this.gap) return;
|
44 |
-
for (var i = 0; i < this.matches.length; i++) {
|
45 |
-
var match = this.matches[i];
|
46 |
-
if (match.from.line >= this.gap.to) break;
|
47 |
-
if (match.to.line >= this.gap.from) this.matches.splice(i--, 1);
|
48 |
-
}
|
49 |
-
var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), this.caseFold);
|
50 |
-
var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES;
|
51 |
-
while (cursor.findNext()) {
|
52 |
-
var match = {from: cursor.from(), to: cursor.to()};
|
53 |
-
if (match.from.line >= this.gap.to) break;
|
54 |
-
this.matches.splice(i++, 0, match);
|
55 |
-
if (this.matches.length > maxMatches) break;
|
56 |
-
}
|
57 |
-
this.gap = null;
|
58 |
-
};
|
59 |
-
|
60 |
-
function offsetLine(line, changeStart, sizeChange) {
|
61 |
-
if (line <= changeStart) return line;
|
62 |
-
return Math.max(changeStart, line + sizeChange);
|
63 |
-
}
|
64 |
-
|
65 |
-
SearchAnnotation.prototype.onChange = function(change) {
|
66 |
-
var startLine = change.from.line;
|
67 |
-
var endLine = CodeMirror.changeEnd(change).line;
|
68 |
-
var sizeChange = endLine - change.to.line;
|
69 |
-
if (this.gap) {
|
70 |
-
this.gap.from = Math.min(offsetLine(this.gap.from, startLine, sizeChange), change.from.line);
|
71 |
-
this.gap.to = Math.max(offsetLine(this.gap.to, startLine, sizeChange), change.from.line);
|
72 |
-
} else {
|
73 |
-
this.gap = {from: change.from.line, to: endLine + 1};
|
74 |
-
}
|
75 |
-
|
76 |
-
if (sizeChange) for (var i = 0; i < this.matches.length; i++) {
|
77 |
-
var match = this.matches[i];
|
78 |
-
var newFrom = offsetLine(match.from.line, startLine, sizeChange);
|
79 |
-
if (newFrom != match.from.line) match.from = CodeMirror.Pos(newFrom, match.from.ch);
|
80 |
-
var newTo = offsetLine(match.to.line, startLine, sizeChange);
|
81 |
-
if (newTo != match.to.line) match.to = CodeMirror.Pos(newTo, match.to.ch);
|
82 |
-
}
|
83 |
-
clearTimeout(this.update);
|
84 |
-
var self = this;
|
85 |
-
this.update = setTimeout(function() { self.updateAfterChange(); }, 250);
|
86 |
-
};
|
87 |
-
|
88 |
-
SearchAnnotation.prototype.updateAfterChange = function() {
|
89 |
-
this.findMatches();
|
90 |
-
this.annotation.update(this.matches);
|
91 |
-
};
|
92 |
-
|
93 |
-
SearchAnnotation.prototype.clear = function() {
|
94 |
-
this.cm.off("change", this.changeHandler);
|
95 |
-
this.annotation.clear();
|
96 |
-
};
|
97 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/search/search.js
DELETED
@@ -1,228 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Define search commands. Depends on dialog.js or another
|
5 |
-
// implementation of the openDialog method.
|
6 |
-
|
7 |
-
// Replace works a little oddly -- it will do the replace on the next
|
8 |
-
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
|
9 |
-
// replace by making sure the match is no longer selected when hitting
|
10 |
-
// Ctrl-G.
|
11 |
-
|
12 |
-
(function(mod) {
|
13 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
14 |
-
mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog"));
|
15 |
-
else if (typeof define == "function" && define.amd) // AMD
|
16 |
-
define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod);
|
17 |
-
else // Plain browser env
|
18 |
-
mod(CodeMirror);
|
19 |
-
})(function(CodeMirror) {
|
20 |
-
"use strict";
|
21 |
-
|
22 |
-
function searchOverlay(query, caseInsensitive) {
|
23 |
-
if (typeof query == "string")
|
24 |
-
query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
|
25 |
-
else if (!query.global)
|
26 |
-
query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
|
27 |
-
|
28 |
-
return {token: function(stream) {
|
29 |
-
query.lastIndex = stream.pos;
|
30 |
-
var match = query.exec(stream.string);
|
31 |
-
if (match && match.index == stream.pos) {
|
32 |
-
stream.pos += match[0].length || 1;
|
33 |
-
return "searching";
|
34 |
-
} else if (match) {
|
35 |
-
stream.pos = match.index;
|
36 |
-
} else {
|
37 |
-
stream.skipToEnd();
|
38 |
-
}
|
39 |
-
}};
|
40 |
-
}
|
41 |
-
|
42 |
-
function SearchState() {
|
43 |
-
this.posFrom = this.posTo = this.lastQuery = this.query = null;
|
44 |
-
this.overlay = null;
|
45 |
-
}
|
46 |
-
|
47 |
-
function getSearchState(cm) {
|
48 |
-
return cm.state.search || (cm.state.search = new SearchState());
|
49 |
-
}
|
50 |
-
|
51 |
-
function queryCaseInsensitive(query) {
|
52 |
-
return typeof query == "string" && query == query.toLowerCase();
|
53 |
-
}
|
54 |
-
|
55 |
-
function getSearchCursor(cm, query, pos) {
|
56 |
-
// Heuristic: if the query string is all lowercase, do a case insensitive search.
|
57 |
-
return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
|
58 |
-
}
|
59 |
-
|
60 |
-
function persistentDialog(cm, text, deflt, f) {
|
61 |
-
cm.openDialog(text, f, {
|
62 |
-
value: deflt,
|
63 |
-
selectValueOnOpen: true,
|
64 |
-
closeOnEnter: false,
|
65 |
-
onClose: function() { clearSearch(cm); }
|
66 |
-
});
|
67 |
-
}
|
68 |
-
|
69 |
-
function dialog(cm, text, shortText, deflt, f) {
|
70 |
-
if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
|
71 |
-
else f(prompt(shortText, deflt));
|
72 |
-
}
|
73 |
-
|
74 |
-
function confirmDialog(cm, text, shortText, fs) {
|
75 |
-
if (cm.openConfirm) cm.openConfirm(text, fs);
|
76 |
-
else if (confirm(shortText)) fs[0]();
|
77 |
-
}
|
78 |
-
|
79 |
-
function parseString(string) {
|
80 |
-
return string.replace(/\\(.)/g, function(_, ch) {
|
81 |
-
if (ch == "n") return "\n"
|
82 |
-
if (ch == "r") return "\r"
|
83 |
-
return ch
|
84 |
-
})
|
85 |
-
}
|
86 |
-
|
87 |
-
function parseQuery(query) {
|
88 |
-
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
|
89 |
-
if (isRE) {
|
90 |
-
try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
|
91 |
-
catch(e) {} // Not a regular expression after all, do a string search
|
92 |
-
} else {
|
93 |
-
query = parseString(query)
|
94 |
-
}
|
95 |
-
if (typeof query == "string" ? query == "" : query.test(""))
|
96 |
-
query = /x^/;
|
97 |
-
return query;
|
98 |
-
}
|
99 |
-
|
100 |
-
var queryDialog =
|
101 |
-
'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
102 |
-
|
103 |
-
function startSearch(cm, state, query) {
|
104 |
-
state.queryText = query;
|
105 |
-
state.query = parseQuery(query);
|
106 |
-
cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
|
107 |
-
state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
|
108 |
-
cm.addOverlay(state.overlay);
|
109 |
-
if (cm.showMatchesOnScrollbar) {
|
110 |
-
if (state.annotate) { state.annotate.clear(); state.annotate = null; }
|
111 |
-
state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
function doSearch(cm, rev, persistent) {
|
116 |
-
var state = getSearchState(cm);
|
117 |
-
if (state.query) return findNext(cm, rev);
|
118 |
-
var q = cm.getSelection() || state.lastQuery;
|
119 |
-
if (persistent && cm.openDialog) {
|
120 |
-
var hiding = null
|
121 |
-
persistentDialog(cm, queryDialog, q, function(query, event) {
|
122 |
-
CodeMirror.e_stop(event);
|
123 |
-
if (!query) return;
|
124 |
-
if (query != state.queryText) startSearch(cm, state, query);
|
125 |
-
if (hiding) hiding.style.opacity = 1
|
126 |
-
findNext(cm, event.shiftKey, function(_, to) {
|
127 |
-
var dialog
|
128 |
-
if (to.line < 3 && document.querySelector &&
|
129 |
-
(dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
|
130 |
-
dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
|
131 |
-
(hiding = dialog).style.opacity = .4
|
132 |
-
})
|
133 |
-
});
|
134 |
-
} else {
|
135 |
-
dialog(cm, queryDialog, "Search for:", q, function(query) {
|
136 |
-
if (query && !state.query) cm.operation(function() {
|
137 |
-
startSearch(cm, state, query);
|
138 |
-
state.posFrom = state.posTo = cm.getCursor();
|
139 |
-
findNext(cm, rev);
|
140 |
-
});
|
141 |
-
});
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
function findNext(cm, rev, callback) {cm.operation(function() {
|
146 |
-
var state = getSearchState(cm);
|
147 |
-
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
|
148 |
-
if (!cursor.find(rev)) {
|
149 |
-
cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
|
150 |
-
if (!cursor.find(rev)) return;
|
151 |
-
}
|
152 |
-
cm.setSelection(cursor.from(), cursor.to());
|
153 |
-
cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20);
|
154 |
-
state.posFrom = cursor.from(); state.posTo = cursor.to();
|
155 |
-
if (callback) callback(cursor.from(), cursor.to())
|
156 |
-
});}
|
157 |
-
|
158 |
-
function clearSearch(cm) {cm.operation(function() {
|
159 |
-
var state = getSearchState(cm);
|
160 |
-
state.lastQuery = state.query;
|
161 |
-
if (!state.query) return;
|
162 |
-
state.query = state.queryText = null;
|
163 |
-
cm.removeOverlay(state.overlay);
|
164 |
-
if (state.annotate) { state.annotate.clear(); state.annotate = null; }
|
165 |
-
});}
|
166 |
-
|
167 |
-
var replaceQueryDialog =
|
168 |
-
' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
169 |
-
var replacementQueryDialog = 'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
|
170 |
-
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>All</button> <button>Stop</button>";
|
171 |
-
|
172 |
-
function replaceAll(cm, query, text) {
|
173 |
-
cm.operation(function() {
|
174 |
-
for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
|
175 |
-
if (typeof query != "string") {
|
176 |
-
var match = cm.getRange(cursor.from(), cursor.to()).match(query);
|
177 |
-
cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
178 |
-
} else cursor.replace(text);
|
179 |
-
}
|
180 |
-
});
|
181 |
-
}
|
182 |
-
|
183 |
-
function replace(cm, all) {
|
184 |
-
if (cm.getOption("readOnly")) return;
|
185 |
-
var query = cm.getSelection() || getSearchState(cm).lastQuery;
|
186 |
-
var dialogText = all ? "Replace all:" : "Replace:"
|
187 |
-
dialog(cm, dialogText + replaceQueryDialog, dialogText, query, function(query) {
|
188 |
-
if (!query) return;
|
189 |
-
query = parseQuery(query);
|
190 |
-
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
|
191 |
-
text = parseString(text)
|
192 |
-
if (all) {
|
193 |
-
replaceAll(cm, query, text)
|
194 |
-
} else {
|
195 |
-
clearSearch(cm);
|
196 |
-
var cursor = getSearchCursor(cm, query, cm.getCursor());
|
197 |
-
var advance = function() {
|
198 |
-
var start = cursor.from(), match;
|
199 |
-
if (!(match = cursor.findNext())) {
|
200 |
-
cursor = getSearchCursor(cm, query);
|
201 |
-
if (!(match = cursor.findNext()) ||
|
202 |
-
(start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
|
203 |
-
}
|
204 |
-
cm.setSelection(cursor.from(), cursor.to());
|
205 |
-
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
|
206 |
-
confirmDialog(cm, doReplaceConfirm, "Replace?",
|
207 |
-
[function() {doReplace(match);}, advance,
|
208 |
-
function() {replaceAll(cm, query, text)}]);
|
209 |
-
};
|
210 |
-
var doReplace = function(match) {
|
211 |
-
cursor.replace(typeof query == "string" ? text :
|
212 |
-
text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
213 |
-
advance();
|
214 |
-
};
|
215 |
-
advance();
|
216 |
-
}
|
217 |
-
});
|
218 |
-
});
|
219 |
-
}
|
220 |
-
|
221 |
-
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
|
222 |
-
CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
|
223 |
-
CodeMirror.commands.findNext = doSearch;
|
224 |
-
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
|
225 |
-
CodeMirror.commands.clearSearch = clearSearch;
|
226 |
-
CodeMirror.commands.replace = replace;
|
227 |
-
CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
|
228 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/search/searchcursor.js
DELETED
@@ -1,189 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
var Pos = CodeMirror.Pos;
|
14 |
-
|
15 |
-
function SearchCursor(doc, query, pos, caseFold) {
|
16 |
-
this.atOccurrence = false; this.doc = doc;
|
17 |
-
if (caseFold == null && typeof query == "string") caseFold = false;
|
18 |
-
|
19 |
-
pos = pos ? doc.clipPos(pos) : Pos(0, 0);
|
20 |
-
this.pos = {from: pos, to: pos};
|
21 |
-
|
22 |
-
// The matches method is filled in based on the type of query.
|
23 |
-
// It takes a position and a direction, and returns an object
|
24 |
-
// describing the next occurrence of the query, or null if no
|
25 |
-
// more matches were found.
|
26 |
-
if (typeof query != "string") { // Regexp match
|
27 |
-
if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g");
|
28 |
-
this.matches = function(reverse, pos) {
|
29 |
-
if (reverse) {
|
30 |
-
query.lastIndex = 0;
|
31 |
-
var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start;
|
32 |
-
for (;;) {
|
33 |
-
query.lastIndex = cutOff;
|
34 |
-
var newMatch = query.exec(line);
|
35 |
-
if (!newMatch) break;
|
36 |
-
match = newMatch;
|
37 |
-
start = match.index;
|
38 |
-
cutOff = match.index + (match[0].length || 1);
|
39 |
-
if (cutOff == line.length) break;
|
40 |
-
}
|
41 |
-
var matchLen = (match && match[0].length) || 0;
|
42 |
-
if (!matchLen) {
|
43 |
-
if (start == 0 && line.length == 0) {match = undefined;}
|
44 |
-
else if (start != doc.getLine(pos.line).length) {
|
45 |
-
matchLen++;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
} else {
|
49 |
-
query.lastIndex = pos.ch;
|
50 |
-
var line = doc.getLine(pos.line), match = query.exec(line);
|
51 |
-
var matchLen = (match && match[0].length) || 0;
|
52 |
-
var start = match && match.index;
|
53 |
-
if (start + matchLen != line.length && !matchLen) matchLen = 1;
|
54 |
-
}
|
55 |
-
if (match && matchLen)
|
56 |
-
return {from: Pos(pos.line, start),
|
57 |
-
to: Pos(pos.line, start + matchLen),
|
58 |
-
match: match};
|
59 |
-
};
|
60 |
-
} else { // String query
|
61 |
-
var origQuery = query;
|
62 |
-
if (caseFold) query = query.toLowerCase();
|
63 |
-
var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
|
64 |
-
var target = query.split("\n");
|
65 |
-
// Different methods for single-line and multi-line queries
|
66 |
-
if (target.length == 1) {
|
67 |
-
if (!query.length) {
|
68 |
-
// Empty string would match anything and never progress, so
|
69 |
-
// we define it to match nothing instead.
|
70 |
-
this.matches = function() {};
|
71 |
-
} else {
|
72 |
-
this.matches = function(reverse, pos) {
|
73 |
-
if (reverse) {
|
74 |
-
var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig);
|
75 |
-
var match = line.lastIndexOf(query);
|
76 |
-
if (match > -1) {
|
77 |
-
match = adjustPos(orig, line, match);
|
78 |
-
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
79 |
-
}
|
80 |
-
} else {
|
81 |
-
var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig);
|
82 |
-
var match = line.indexOf(query);
|
83 |
-
if (match > -1) {
|
84 |
-
match = adjustPos(orig, line, match) + pos.ch;
|
85 |
-
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
86 |
-
}
|
87 |
-
}
|
88 |
-
};
|
89 |
-
}
|
90 |
-
} else {
|
91 |
-
var origTarget = origQuery.split("\n");
|
92 |
-
this.matches = function(reverse, pos) {
|
93 |
-
var last = target.length - 1;
|
94 |
-
if (reverse) {
|
95 |
-
if (pos.line - (target.length - 1) < doc.firstLine()) return;
|
96 |
-
if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return;
|
97 |
-
var to = Pos(pos.line, origTarget[last].length);
|
98 |
-
for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln)
|
99 |
-
if (target[i] != fold(doc.getLine(ln))) return;
|
100 |
-
var line = doc.getLine(ln), cut = line.length - origTarget[0].length;
|
101 |
-
if (fold(line.slice(cut)) != target[0]) return;
|
102 |
-
return {from: Pos(ln, cut), to: to};
|
103 |
-
} else {
|
104 |
-
if (pos.line + (target.length - 1) > doc.lastLine()) return;
|
105 |
-
var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length;
|
106 |
-
if (fold(line.slice(cut)) != target[0]) return;
|
107 |
-
var from = Pos(pos.line, cut);
|
108 |
-
for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln)
|
109 |
-
if (target[i] != fold(doc.getLine(ln))) return;
|
110 |
-
if (fold(doc.getLine(ln).slice(0, origTarget[last].length)) != target[last]) return;
|
111 |
-
return {from: from, to: Pos(ln, origTarget[last].length)};
|
112 |
-
}
|
113 |
-
};
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
SearchCursor.prototype = {
|
119 |
-
findNext: function() {return this.find(false);},
|
120 |
-
findPrevious: function() {return this.find(true);},
|
121 |
-
|
122 |
-
find: function(reverse) {
|
123 |
-
var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
|
124 |
-
function savePosAndFail(line) {
|
125 |
-
var pos = Pos(line, 0);
|
126 |
-
self.pos = {from: pos, to: pos};
|
127 |
-
self.atOccurrence = false;
|
128 |
-
return false;
|
129 |
-
}
|
130 |
-
|
131 |
-
for (;;) {
|
132 |
-
if (this.pos = this.matches(reverse, pos)) {
|
133 |
-
this.atOccurrence = true;
|
134 |
-
return this.pos.match || true;
|
135 |
-
}
|
136 |
-
if (reverse) {
|
137 |
-
if (!pos.line) return savePosAndFail(0);
|
138 |
-
pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length);
|
139 |
-
}
|
140 |
-
else {
|
141 |
-
var maxLine = this.doc.lineCount();
|
142 |
-
if (pos.line == maxLine - 1) return savePosAndFail(maxLine);
|
143 |
-
pos = Pos(pos.line + 1, 0);
|
144 |
-
}
|
145 |
-
}
|
146 |
-
},
|
147 |
-
|
148 |
-
from: function() {if (this.atOccurrence) return this.pos.from;},
|
149 |
-
to: function() {if (this.atOccurrence) return this.pos.to;},
|
150 |
-
|
151 |
-
replace: function(newText, origin) {
|
152 |
-
if (!this.atOccurrence) return;
|
153 |
-
var lines = CodeMirror.splitLines(newText);
|
154 |
-
this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin);
|
155 |
-
this.pos.to = Pos(this.pos.from.line + lines.length - 1,
|
156 |
-
lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
|
157 |
-
}
|
158 |
-
};
|
159 |
-
|
160 |
-
// Maps a position in a case-folded line back to a position in the original line
|
161 |
-
// (compensating for codepoints increasing in number during folding)
|
162 |
-
function adjustPos(orig, folded, pos) {
|
163 |
-
if (orig.length == folded.length) return pos;
|
164 |
-
for (var pos1 = Math.min(pos, orig.length);;) {
|
165 |
-
var len1 = orig.slice(0, pos1).toLowerCase().length;
|
166 |
-
if (len1 < pos) ++pos1;
|
167 |
-
else if (len1 > pos) --pos1;
|
168 |
-
else return pos1;
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
|
173 |
-
return new SearchCursor(this.doc, query, pos, caseFold);
|
174 |
-
});
|
175 |
-
CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
|
176 |
-
return new SearchCursor(this, query, pos, caseFold);
|
177 |
-
});
|
178 |
-
|
179 |
-
CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
|
180 |
-
var ranges = [];
|
181 |
-
var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
|
182 |
-
while (cur.findNext()) {
|
183 |
-
if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break;
|
184 |
-
ranges.push({anchor: cur.from(), head: cur.to()});
|
185 |
-
}
|
186 |
-
if (ranges.length)
|
187 |
-
this.setSelections(ranges, 0);
|
188 |
-
});
|
189 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/selection/active-line.js
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Because sometimes you need to style the cursor's line.
|
5 |
-
//
|
6 |
-
// Adds an option 'styleActiveLine' which, when enabled, gives the
|
7 |
-
// active line's wrapping <div> the CSS class "CodeMirror-activeline",
|
8 |
-
// and gives its background <div> the class "CodeMirror-activeline-background".
|
9 |
-
|
10 |
-
(function(mod) {
|
11 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12 |
-
mod(require("../../lib/codemirror"));
|
13 |
-
else if (typeof define == "function" && define.amd) // AMD
|
14 |
-
define(["../../lib/codemirror"], mod);
|
15 |
-
else // Plain browser env
|
16 |
-
mod(CodeMirror);
|
17 |
-
})(function(CodeMirror) {
|
18 |
-
"use strict";
|
19 |
-
var WRAP_CLASS = "CodeMirror-activeline";
|
20 |
-
var BACK_CLASS = "CodeMirror-activeline-background";
|
21 |
-
|
22 |
-
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
|
23 |
-
var prev = old && old != CodeMirror.Init;
|
24 |
-
if (val && !prev) {
|
25 |
-
cm.state.activeLines = [];
|
26 |
-
updateActiveLines(cm, cm.listSelections());
|
27 |
-
cm.on("beforeSelectionChange", selectionChange);
|
28 |
-
} else if (!val && prev) {
|
29 |
-
cm.off("beforeSelectionChange", selectionChange);
|
30 |
-
clearActiveLines(cm);
|
31 |
-
delete cm.state.activeLines;
|
32 |
-
}
|
33 |
-
});
|
34 |
-
|
35 |
-
function clearActiveLines(cm) {
|
36 |
-
for (var i = 0; i < cm.state.activeLines.length; i++) {
|
37 |
-
cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
|
38 |
-
cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
function sameArray(a, b) {
|
43 |
-
if (a.length != b.length) return false;
|
44 |
-
for (var i = 0; i < a.length; i++)
|
45 |
-
if (a[i] != b[i]) return false;
|
46 |
-
return true;
|
47 |
-
}
|
48 |
-
|
49 |
-
function updateActiveLines(cm, ranges) {
|
50 |
-
var active = [];
|
51 |
-
for (var i = 0; i < ranges.length; i++) {
|
52 |
-
var range = ranges[i];
|
53 |
-
if (!range.empty()) continue;
|
54 |
-
var line = cm.getLineHandleVisualStart(range.head.line);
|
55 |
-
if (active[active.length - 1] != line) active.push(line);
|
56 |
-
}
|
57 |
-
if (sameArray(cm.state.activeLines, active)) return;
|
58 |
-
cm.operation(function() {
|
59 |
-
clearActiveLines(cm);
|
60 |
-
for (var i = 0; i < active.length; i++) {
|
61 |
-
cm.addLineClass(active[i], "wrap", WRAP_CLASS);
|
62 |
-
cm.addLineClass(active[i], "background", BACK_CLASS);
|
63 |
-
}
|
64 |
-
cm.state.activeLines = active;
|
65 |
-
});
|
66 |
-
}
|
67 |
-
|
68 |
-
function selectionChange(cm, sel) {
|
69 |
-
updateActiveLines(cm, sel.ranges);
|
70 |
-
}
|
71 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/selection/mark-selection.js
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Because sometimes you need to mark the selected *text*.
|
5 |
-
//
|
6 |
-
// Adds an option 'styleSelectedText' which, when enabled, gives
|
7 |
-
// selected text the CSS class given as option value, or
|
8 |
-
// "CodeMirror-selectedtext" when the value is not a string.
|
9 |
-
|
10 |
-
(function(mod) {
|
11 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12 |
-
mod(require("../../lib/codemirror"));
|
13 |
-
else if (typeof define == "function" && define.amd) // AMD
|
14 |
-
define(["../../lib/codemirror"], mod);
|
15 |
-
else // Plain browser env
|
16 |
-
mod(CodeMirror);
|
17 |
-
})(function(CodeMirror) {
|
18 |
-
"use strict";
|
19 |
-
|
20 |
-
CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
|
21 |
-
var prev = old && old != CodeMirror.Init;
|
22 |
-
if (val && !prev) {
|
23 |
-
cm.state.markedSelection = [];
|
24 |
-
cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
|
25 |
-
reset(cm);
|
26 |
-
cm.on("cursorActivity", onCursorActivity);
|
27 |
-
cm.on("change", onChange);
|
28 |
-
} else if (!val && prev) {
|
29 |
-
cm.off("cursorActivity", onCursorActivity);
|
30 |
-
cm.off("change", onChange);
|
31 |
-
clear(cm);
|
32 |
-
cm.state.markedSelection = cm.state.markedSelectionStyle = null;
|
33 |
-
}
|
34 |
-
});
|
35 |
-
|
36 |
-
function onCursorActivity(cm) {
|
37 |
-
cm.operation(function() { update(cm); });
|
38 |
-
}
|
39 |
-
|
40 |
-
function onChange(cm) {
|
41 |
-
if (cm.state.markedSelection.length)
|
42 |
-
cm.operation(function() { clear(cm); });
|
43 |
-
}
|
44 |
-
|
45 |
-
var CHUNK_SIZE = 8;
|
46 |
-
var Pos = CodeMirror.Pos;
|
47 |
-
var cmp = CodeMirror.cmpPos;
|
48 |
-
|
49 |
-
function coverRange(cm, from, to, addAt) {
|
50 |
-
if (cmp(from, to) == 0) return;
|
51 |
-
var array = cm.state.markedSelection;
|
52 |
-
var cls = cm.state.markedSelectionStyle;
|
53 |
-
for (var line = from.line;;) {
|
54 |
-
var start = line == from.line ? from : Pos(line, 0);
|
55 |
-
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
|
56 |
-
var end = atEnd ? to : Pos(endLine, 0);
|
57 |
-
var mark = cm.markText(start, end, {className: cls});
|
58 |
-
if (addAt == null) array.push(mark);
|
59 |
-
else array.splice(addAt++, 0, mark);
|
60 |
-
if (atEnd) break;
|
61 |
-
line = endLine;
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
function clear(cm) {
|
66 |
-
var array = cm.state.markedSelection;
|
67 |
-
for (var i = 0; i < array.length; ++i) array[i].clear();
|
68 |
-
array.length = 0;
|
69 |
-
}
|
70 |
-
|
71 |
-
function reset(cm) {
|
72 |
-
clear(cm);
|
73 |
-
var ranges = cm.listSelections();
|
74 |
-
for (var i = 0; i < ranges.length; i++)
|
75 |
-
coverRange(cm, ranges[i].from(), ranges[i].to());
|
76 |
-
}
|
77 |
-
|
78 |
-
function update(cm) {
|
79 |
-
if (!cm.somethingSelected()) return clear(cm);
|
80 |
-
if (cm.listSelections().length > 1) return reset(cm);
|
81 |
-
|
82 |
-
var from = cm.getCursor("start"), to = cm.getCursor("end");
|
83 |
-
|
84 |
-
var array = cm.state.markedSelection;
|
85 |
-
if (!array.length) return coverRange(cm, from, to);
|
86 |
-
|
87 |
-
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
|
88 |
-
if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
|
89 |
-
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
|
90 |
-
return reset(cm);
|
91 |
-
|
92 |
-
while (cmp(from, coverStart.from) > 0) {
|
93 |
-
array.shift().clear();
|
94 |
-
coverStart = array[0].find();
|
95 |
-
}
|
96 |
-
if (cmp(from, coverStart.from) < 0) {
|
97 |
-
if (coverStart.to.line - from.line < CHUNK_SIZE) {
|
98 |
-
array.shift().clear();
|
99 |
-
coverRange(cm, from, coverStart.to, 0);
|
100 |
-
} else {
|
101 |
-
coverRange(cm, from, coverStart.from, 0);
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
while (cmp(to, coverEnd.to) < 0) {
|
106 |
-
array.pop().clear();
|
107 |
-
coverEnd = array[array.length - 1].find();
|
108 |
-
}
|
109 |
-
if (cmp(to, coverEnd.to) > 0) {
|
110 |
-
if (to.line - coverEnd.from.line < CHUNK_SIZE) {
|
111 |
-
array.pop().clear();
|
112 |
-
coverRange(cm, coverEnd.from, to);
|
113 |
-
} else {
|
114 |
-
coverRange(cm, coverEnd.to, to);
|
115 |
-
}
|
116 |
-
}
|
117 |
-
}
|
118 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/selection/selection-pointer.js
DELETED
@@ -1,98 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
CodeMirror.defineOption("selectionPointer", false, function(cm, val) {
|
15 |
-
var data = cm.state.selectionPointer;
|
16 |
-
if (data) {
|
17 |
-
CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove);
|
18 |
-
CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout);
|
19 |
-
CodeMirror.off(window, "scroll", data.windowScroll);
|
20 |
-
cm.off("cursorActivity", reset);
|
21 |
-
cm.off("scroll", reset);
|
22 |
-
cm.state.selectionPointer = null;
|
23 |
-
cm.display.lineDiv.style.cursor = "";
|
24 |
-
}
|
25 |
-
if (val) {
|
26 |
-
data = cm.state.selectionPointer = {
|
27 |
-
value: typeof val == "string" ? val : "default",
|
28 |
-
mousemove: function(event) { mousemove(cm, event); },
|
29 |
-
mouseout: function(event) { mouseout(cm, event); },
|
30 |
-
windowScroll: function() { reset(cm); },
|
31 |
-
rects: null,
|
32 |
-
mouseX: null, mouseY: null,
|
33 |
-
willUpdate: false
|
34 |
-
};
|
35 |
-
CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove);
|
36 |
-
CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout);
|
37 |
-
CodeMirror.on(window, "scroll", data.windowScroll);
|
38 |
-
cm.on("cursorActivity", reset);
|
39 |
-
cm.on("scroll", reset);
|
40 |
-
}
|
41 |
-
});
|
42 |
-
|
43 |
-
function mousemove(cm, event) {
|
44 |
-
var data = cm.state.selectionPointer;
|
45 |
-
if (event.buttons == null ? event.which : event.buttons) {
|
46 |
-
data.mouseX = data.mouseY = null;
|
47 |
-
} else {
|
48 |
-
data.mouseX = event.clientX;
|
49 |
-
data.mouseY = event.clientY;
|
50 |
-
}
|
51 |
-
scheduleUpdate(cm);
|
52 |
-
}
|
53 |
-
|
54 |
-
function mouseout(cm, event) {
|
55 |
-
if (!cm.getWrapperElement().contains(event.relatedTarget)) {
|
56 |
-
var data = cm.state.selectionPointer;
|
57 |
-
data.mouseX = data.mouseY = null;
|
58 |
-
scheduleUpdate(cm);
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
function reset(cm) {
|
63 |
-
cm.state.selectionPointer.rects = null;
|
64 |
-
scheduleUpdate(cm);
|
65 |
-
}
|
66 |
-
|
67 |
-
function scheduleUpdate(cm) {
|
68 |
-
if (!cm.state.selectionPointer.willUpdate) {
|
69 |
-
cm.state.selectionPointer.willUpdate = true;
|
70 |
-
setTimeout(function() {
|
71 |
-
update(cm);
|
72 |
-
cm.state.selectionPointer.willUpdate = false;
|
73 |
-
}, 50);
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
function update(cm) {
|
78 |
-
var data = cm.state.selectionPointer;
|
79 |
-
if (!data) return;
|
80 |
-
if (data.rects == null && data.mouseX != null) {
|
81 |
-
data.rects = [];
|
82 |
-
if (cm.somethingSelected()) {
|
83 |
-
for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling)
|
84 |
-
data.rects.push(sel.getBoundingClientRect());
|
85 |
-
}
|
86 |
-
}
|
87 |
-
var inside = false;
|
88 |
-
if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) {
|
89 |
-
var rect = data.rects[i];
|
90 |
-
if (rect.left <= data.mouseX && rect.right >= data.mouseX &&
|
91 |
-
rect.top <= data.mouseY && rect.bottom >= data.mouseY)
|
92 |
-
inside = true;
|
93 |
-
}
|
94 |
-
var cursor = inside ? data.value : "";
|
95 |
-
if (cm.display.lineDiv.style.cursor != cursor)
|
96 |
-
cm.display.lineDiv.style.cursor = cursor;
|
97 |
-
}
|
98 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/tern/tern.css
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
.CodeMirror-Tern-completion {
|
2 |
-
padding-left: 22px;
|
3 |
-
position: relative;
|
4 |
-
line-height: 1.5;
|
5 |
-
}
|
6 |
-
.CodeMirror-Tern-completion:before {
|
7 |
-
position: absolute;
|
8 |
-
left: 2px;
|
9 |
-
bottom: 2px;
|
10 |
-
border-radius: 50%;
|
11 |
-
font-size: 12px;
|
12 |
-
font-weight: bold;
|
13 |
-
height: 15px;
|
14 |
-
width: 15px;
|
15 |
-
line-height: 16px;
|
16 |
-
text-align: center;
|
17 |
-
color: white;
|
18 |
-
-moz-box-sizing: border-box;
|
19 |
-
box-sizing: border-box;
|
20 |
-
}
|
21 |
-
.CodeMirror-Tern-completion-unknown:before {
|
22 |
-
content: "?";
|
23 |
-
background: #4bb;
|
24 |
-
}
|
25 |
-
.CodeMirror-Tern-completion-object:before {
|
26 |
-
content: "O";
|
27 |
-
background: #77c;
|
28 |
-
}
|
29 |
-
.CodeMirror-Tern-completion-fn:before {
|
30 |
-
content: "F";
|
31 |
-
background: #7c7;
|
32 |
-
}
|
33 |
-
.CodeMirror-Tern-completion-array:before {
|
34 |
-
content: "A";
|
35 |
-
background: #c66;
|
36 |
-
}
|
37 |
-
.CodeMirror-Tern-completion-number:before {
|
38 |
-
content: "1";
|
39 |
-
background: #999;
|
40 |
-
}
|
41 |
-
.CodeMirror-Tern-completion-string:before {
|
42 |
-
content: "S";
|
43 |
-
background: #999;
|
44 |
-
}
|
45 |
-
.CodeMirror-Tern-completion-bool:before {
|
46 |
-
content: "B";
|
47 |
-
background: #999;
|
48 |
-
}
|
49 |
-
|
50 |
-
.CodeMirror-Tern-completion-guess {
|
51 |
-
color: #999;
|
52 |
-
}
|
53 |
-
|
54 |
-
.CodeMirror-Tern-tooltip {
|
55 |
-
border: 1px solid silver;
|
56 |
-
border-radius: 3px;
|
57 |
-
color: #444;
|
58 |
-
padding: 2px 5px;
|
59 |
-
font-size: 90%;
|
60 |
-
font-family: monospace;
|
61 |
-
background-color: white;
|
62 |
-
white-space: pre-wrap;
|
63 |
-
|
64 |
-
max-width: 40em;
|
65 |
-
position: absolute;
|
66 |
-
z-index: 10;
|
67 |
-
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
68 |
-
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
69 |
-
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
70 |
-
|
71 |
-
transition: opacity 1s;
|
72 |
-
-moz-transition: opacity 1s;
|
73 |
-
-webkit-transition: opacity 1s;
|
74 |
-
-o-transition: opacity 1s;
|
75 |
-
-ms-transition: opacity 1s;
|
76 |
-
}
|
77 |
-
|
78 |
-
.CodeMirror-Tern-hint-doc {
|
79 |
-
max-width: 25em;
|
80 |
-
margin-top: -3px;
|
81 |
-
}
|
82 |
-
|
83 |
-
.CodeMirror-Tern-fname { color: black; }
|
84 |
-
.CodeMirror-Tern-farg { color: #70a; }
|
85 |
-
.CodeMirror-Tern-farg-current { text-decoration: underline; }
|
86 |
-
.CodeMirror-Tern-type { color: #07c; }
|
87 |
-
.CodeMirror-Tern-fhint-guess { opacity: .7; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/tern/tern.js
DELETED
@@ -1,701 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// Glue code between CodeMirror and Tern.
|
5 |
-
//
|
6 |
-
// Create a CodeMirror.TernServer to wrap an actual Tern server,
|
7 |
-
// register open documents (CodeMirror.Doc instances) with it, and
|
8 |
-
// call its methods to activate the assisting functions that Tern
|
9 |
-
// provides.
|
10 |
-
//
|
11 |
-
// Options supported (all optional):
|
12 |
-
// * defs: An array of JSON definition data structures.
|
13 |
-
// * plugins: An object mapping plugin names to configuration
|
14 |
-
// options.
|
15 |
-
// * getFile: A function(name, c) that can be used to access files in
|
16 |
-
// the project that haven't been loaded yet. Simply do c(null) to
|
17 |
-
// indicate that a file is not available.
|
18 |
-
// * fileFilter: A function(value, docName, doc) that will be applied
|
19 |
-
// to documents before passing them on to Tern.
|
20 |
-
// * switchToDoc: A function(name, doc) that should, when providing a
|
21 |
-
// multi-file view, switch the view or focus to the named file.
|
22 |
-
// * showError: A function(editor, message) that can be used to
|
23 |
-
// override the way errors are displayed.
|
24 |
-
// * completionTip: Customize the content in tooltips for completions.
|
25 |
-
// Is passed a single argument—the completion's data as returned by
|
26 |
-
// Tern—and may return a string, DOM node, or null to indicate that
|
27 |
-
// no tip should be shown. By default the docstring is shown.
|
28 |
-
// * typeTip: Like completionTip, but for the tooltips shown for type
|
29 |
-
// queries.
|
30 |
-
// * responseFilter: A function(doc, query, request, error, data) that
|
31 |
-
// will be applied to the Tern responses before treating them
|
32 |
-
//
|
33 |
-
//
|
34 |
-
// It is possible to run the Tern server in a web worker by specifying
|
35 |
-
// these additional options:
|
36 |
-
// * useWorker: Set to true to enable web worker mode. You'll probably
|
37 |
-
// want to feature detect the actual value you use here, for example
|
38 |
-
// !!window.Worker.
|
39 |
-
// * workerScript: The main script of the worker. Point this to
|
40 |
-
// wherever you are hosting worker.js from this directory.
|
41 |
-
// * workerDeps: An array of paths pointing (relative to workerScript)
|
42 |
-
// to the Acorn and Tern libraries and any Tern plugins you want to
|
43 |
-
// load. Or, if you minified those into a single script and included
|
44 |
-
// them in the workerScript, simply leave this undefined.
|
45 |
-
|
46 |
-
(function(mod) {
|
47 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
48 |
-
mod(require("../../lib/codemirror"));
|
49 |
-
else if (typeof define == "function" && define.amd) // AMD
|
50 |
-
define(["../../lib/codemirror"], mod);
|
51 |
-
else // Plain browser env
|
52 |
-
mod(CodeMirror);
|
53 |
-
})(function(CodeMirror) {
|
54 |
-
"use strict";
|
55 |
-
// declare global: tern
|
56 |
-
|
57 |
-
CodeMirror.TernServer = function(options) {
|
58 |
-
var self = this;
|
59 |
-
this.options = options || {};
|
60 |
-
var plugins = this.options.plugins || (this.options.plugins = {});
|
61 |
-
if (!plugins.doc_comment) plugins.doc_comment = true;
|
62 |
-
this.docs = Object.create(null);
|
63 |
-
if (this.options.useWorker) {
|
64 |
-
this.server = new WorkerServer(this);
|
65 |
-
} else {
|
66 |
-
this.server = new tern.Server({
|
67 |
-
getFile: function(name, c) { return getFile(self, name, c); },
|
68 |
-
async: true,
|
69 |
-
defs: this.options.defs || [],
|
70 |
-
plugins: plugins
|
71 |
-
});
|
72 |
-
}
|
73 |
-
this.trackChange = function(doc, change) { trackChange(self, doc, change); };
|
74 |
-
|
75 |
-
this.cachedArgHints = null;
|
76 |
-
this.activeArgHints = null;
|
77 |
-
this.jumpStack = [];
|
78 |
-
|
79 |
-
this.getHint = function(cm, c) { return hint(self, cm, c); };
|
80 |
-
this.getHint.async = true;
|
81 |
-
};
|
82 |
-
|
83 |
-
CodeMirror.TernServer.prototype = {
|
84 |
-
addDoc: function(name, doc) {
|
85 |
-
var data = {doc: doc, name: name, changed: null};
|
86 |
-
this.server.addFile(name, docValue(this, data));
|
87 |
-
CodeMirror.on(doc, "change", this.trackChange);
|
88 |
-
return this.docs[name] = data;
|
89 |
-
},
|
90 |
-
|
91 |
-
delDoc: function(id) {
|
92 |
-
var found = resolveDoc(this, id);
|
93 |
-
if (!found) return;
|
94 |
-
CodeMirror.off(found.doc, "change", this.trackChange);
|
95 |
-
delete this.docs[found.name];
|
96 |
-
this.server.delFile(found.name);
|
97 |
-
},
|
98 |
-
|
99 |
-
hideDoc: function(id) {
|
100 |
-
closeArgHints(this);
|
101 |
-
var found = resolveDoc(this, id);
|
102 |
-
if (found && found.changed) sendDoc(this, found);
|
103 |
-
},
|
104 |
-
|
105 |
-
complete: function(cm) {
|
106 |
-
cm.showHint({hint: this.getHint});
|
107 |
-
},
|
108 |
-
|
109 |
-
showType: function(cm, pos, c) { showContextInfo(this, cm, pos, "type", c); },
|
110 |
-
|
111 |
-
showDocs: function(cm, pos, c) { showContextInfo(this, cm, pos, "documentation", c); },
|
112 |
-
|
113 |
-
updateArgHints: function(cm) { updateArgHints(this, cm); },
|
114 |
-
|
115 |
-
jumpToDef: function(cm) { jumpToDef(this, cm); },
|
116 |
-
|
117 |
-
jumpBack: function(cm) { jumpBack(this, cm); },
|
118 |
-
|
119 |
-
rename: function(cm) { rename(this, cm); },
|
120 |
-
|
121 |
-
selectName: function(cm) { selectName(this, cm); },
|
122 |
-
|
123 |
-
request: function (cm, query, c, pos) {
|
124 |
-
var self = this;
|
125 |
-
var doc = findDoc(this, cm.getDoc());
|
126 |
-
var request = buildRequest(this, doc, query, pos);
|
127 |
-
var extraOptions = request.query && this.options.queryOptions && this.options.queryOptions[request.query.type]
|
128 |
-
if (extraOptions) for (var prop in extraOptions) request.query[prop] = extraOptions[prop];
|
129 |
-
|
130 |
-
this.server.request(request, function (error, data) {
|
131 |
-
if (!error && self.options.responseFilter)
|
132 |
-
data = self.options.responseFilter(doc, query, request, error, data);
|
133 |
-
c(error, data);
|
134 |
-
});
|
135 |
-
},
|
136 |
-
|
137 |
-
destroy: function () {
|
138 |
-
closeArgHints(this)
|
139 |
-
if (this.worker) {
|
140 |
-
this.worker.terminate();
|
141 |
-
this.worker = null;
|
142 |
-
}
|
143 |
-
}
|
144 |
-
};
|
145 |
-
|
146 |
-
var Pos = CodeMirror.Pos;
|
147 |
-
var cls = "CodeMirror-Tern-";
|
148 |
-
var bigDoc = 250;
|
149 |
-
|
150 |
-
function getFile(ts, name, c) {
|
151 |
-
var buf = ts.docs[name];
|
152 |
-
if (buf)
|
153 |
-
c(docValue(ts, buf));
|
154 |
-
else if (ts.options.getFile)
|
155 |
-
ts.options.getFile(name, c);
|
156 |
-
else
|
157 |
-
c(null);
|
158 |
-
}
|
159 |
-
|
160 |
-
function findDoc(ts, doc, name) {
|
161 |
-
for (var n in ts.docs) {
|
162 |
-
var cur = ts.docs[n];
|
163 |
-
if (cur.doc == doc) return cur;
|
164 |
-
}
|
165 |
-
if (!name) for (var i = 0;; ++i) {
|
166 |
-
n = "[doc" + (i || "") + "]";
|
167 |
-
if (!ts.docs[n]) { name = n; break; }
|
168 |
-
}
|
169 |
-
return ts.addDoc(name, doc);
|
170 |
-
}
|
171 |
-
|
172 |
-
function resolveDoc(ts, id) {
|
173 |
-
if (typeof id == "string") return ts.docs[id];
|
174 |
-
if (id instanceof CodeMirror) id = id.getDoc();
|
175 |
-
if (id instanceof CodeMirror.Doc) return findDoc(ts, id);
|
176 |
-
}
|
177 |
-
|
178 |
-
function trackChange(ts, doc, change) {
|
179 |
-
var data = findDoc(ts, doc);
|
180 |
-
|
181 |
-
var argHints = ts.cachedArgHints;
|
182 |
-
if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) <= 0)
|
183 |
-
ts.cachedArgHints = null;
|
184 |
-
|
185 |
-
var changed = data.changed;
|
186 |
-
if (changed == null)
|
187 |
-
data.changed = changed = {from: change.from.line, to: change.from.line};
|
188 |
-
var end = change.from.line + (change.text.length - 1);
|
189 |
-
if (change.from.line < changed.to) changed.to = changed.to - (change.to.line - end);
|
190 |
-
if (end >= changed.to) changed.to = end + 1;
|
191 |
-
if (changed.from > change.from.line) changed.from = change.from.line;
|
192 |
-
|
193 |
-
if (doc.lineCount() > bigDoc && change.to - changed.from > 100) setTimeout(function() {
|
194 |
-
if (data.changed && data.changed.to - data.changed.from > 100) sendDoc(ts, data);
|
195 |
-
}, 200);
|
196 |
-
}
|
197 |
-
|
198 |
-
function sendDoc(ts, doc) {
|
199 |
-
ts.server.request({files: [{type: "full", name: doc.name, text: docValue(ts, doc)}]}, function(error) {
|
200 |
-
if (error) window.console.error(error);
|
201 |
-
else doc.changed = null;
|
202 |
-
});
|
203 |
-
}
|
204 |
-
|
205 |
-
// Completion
|
206 |
-
|
207 |
-
function hint(ts, cm, c) {
|
208 |
-
ts.request(cm, {type: "completions", types: true, docs: true, urls: true}, function(error, data) {
|
209 |
-
if (error) return showError(ts, cm, error);
|
210 |
-
var completions = [], after = "";
|
211 |
-
var from = data.start, to = data.end;
|
212 |
-
if (cm.getRange(Pos(from.line, from.ch - 2), from) == "[\"" &&
|
213 |
-
cm.getRange(to, Pos(to.line, to.ch + 2)) != "\"]")
|
214 |
-
after = "\"]";
|
215 |
-
|
216 |
-
for (var i = 0; i < data.completions.length; ++i) {
|
217 |
-
var completion = data.completions[i], className = typeToIcon(completion.type);
|
218 |
-
if (data.guess) className += " " + cls + "guess";
|
219 |
-
completions.push({text: completion.name + after,
|
220 |
-
displayText: completion.displayName || completion.name,
|
221 |
-
className: className,
|
222 |
-
data: completion});
|
223 |
-
}
|
224 |
-
|
225 |
-
var obj = {from: from, to: to, list: completions};
|
226 |
-
var tooltip = null;
|
227 |
-
CodeMirror.on(obj, "close", function() { remove(tooltip); });
|
228 |
-
CodeMirror.on(obj, "update", function() { remove(tooltip); });
|
229 |
-
CodeMirror.on(obj, "select", function(cur, node) {
|
230 |
-
remove(tooltip);
|
231 |
-
var content = ts.options.completionTip ? ts.options.completionTip(cur.data) : cur.data.doc;
|
232 |
-
if (content) {
|
233 |
-
tooltip = makeTooltip(node.parentNode.getBoundingClientRect().right + window.pageXOffset,
|
234 |
-
node.getBoundingClientRect().top + window.pageYOffset, content);
|
235 |
-
tooltip.className += " " + cls + "hint-doc";
|
236 |
-
}
|
237 |
-
});
|
238 |
-
c(obj);
|
239 |
-
});
|
240 |
-
}
|
241 |
-
|
242 |
-
function typeToIcon(type) {
|
243 |
-
var suffix;
|
244 |
-
if (type == "?") suffix = "unknown";
|
245 |
-
else if (type == "number" || type == "string" || type == "bool") suffix = type;
|
246 |
-
else if (/^fn\(/.test(type)) suffix = "fn";
|
247 |
-
else if (/^\[/.test(type)) suffix = "array";
|
248 |
-
else suffix = "object";
|
249 |
-
return cls + "completion " + cls + "completion-" + suffix;
|
250 |
-
}
|
251 |
-
|
252 |
-
// Type queries
|
253 |
-
|
254 |
-
function showContextInfo(ts, cm, pos, queryName, c) {
|
255 |
-
ts.request(cm, queryName, function(error, data) {
|
256 |
-
if (error) return showError(ts, cm, error);
|
257 |
-
if (ts.options.typeTip) {
|
258 |
-
var tip = ts.options.typeTip(data);
|
259 |
-
} else {
|
260 |
-
var tip = elt("span", null, elt("strong", null, data.type || "not found"));
|
261 |
-
if (data.doc)
|
262 |
-
tip.appendChild(document.createTextNode(" — " + data.doc));
|
263 |
-
if (data.url) {
|
264 |
-
tip.appendChild(document.createTextNode(" "));
|
265 |
-
var child = tip.appendChild(elt("a", null, "[docs]"));
|
266 |
-
child.href = data.url;
|
267 |
-
child.target = "_blank";
|
268 |
-
}
|
269 |
-
}
|
270 |
-
tempTooltip(cm, tip, ts);
|
271 |
-
if (c) c();
|
272 |
-
}, pos);
|
273 |
-
}
|
274 |
-
|
275 |
-
// Maintaining argument hints
|
276 |
-
|
277 |
-
function updateArgHints(ts, cm) {
|
278 |
-
closeArgHints(ts);
|
279 |
-
|
280 |
-
if (cm.somethingSelected()) return;
|
281 |
-
var state = cm.getTokenAt(cm.getCursor()).state;
|
282 |
-
var inner = CodeMirror.innerMode(cm.getMode(), state);
|
283 |
-
if (inner.mode.name != "javascript") return;
|
284 |
-
var lex = inner.state.lexical;
|
285 |
-
if (lex.info != "call") return;
|
286 |
-
|
287 |
-
var ch, argPos = lex.pos || 0, tabSize = cm.getOption("tabSize");
|
288 |
-
for (var line = cm.getCursor().line, e = Math.max(0, line - 9), found = false; line >= e; --line) {
|
289 |
-
var str = cm.getLine(line), extra = 0;
|
290 |
-
for (var pos = 0;;) {
|
291 |
-
var tab = str.indexOf("\t", pos);
|
292 |
-
if (tab == -1) break;
|
293 |
-
extra += tabSize - (tab + extra) % tabSize - 1;
|
294 |
-
pos = tab + 1;
|
295 |
-
}
|
296 |
-
ch = lex.column - extra;
|
297 |
-
if (str.charAt(ch) == "(") {found = true; break;}
|
298 |
-
}
|
299 |
-
if (!found) return;
|
300 |
-
|
301 |
-
var start = Pos(line, ch);
|
302 |
-
var cache = ts.cachedArgHints;
|
303 |
-
if (cache && cache.doc == cm.getDoc() && cmpPos(start, cache.start) == 0)
|
304 |
-
return showArgHints(ts, cm, argPos);
|
305 |
-
|
306 |
-
ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) {
|
307 |
-
if (error || !data.type || !(/^fn\(/).test(data.type)) return;
|
308 |
-
ts.cachedArgHints = {
|
309 |
-
start: pos,
|
310 |
-
type: parseFnType(data.type),
|
311 |
-
name: data.exprName || data.name || "fn",
|
312 |
-
guess: data.guess,
|
313 |
-
doc: cm.getDoc()
|
314 |
-
};
|
315 |
-
showArgHints(ts, cm, argPos);
|
316 |
-
});
|
317 |
-
}
|
318 |
-
|
319 |
-
function showArgHints(ts, cm, pos) {
|
320 |
-
closeArgHints(ts);
|
321 |
-
|
322 |
-
var cache = ts.cachedArgHints, tp = cache.type;
|
323 |
-
var tip = elt("span", cache.guess ? cls + "fhint-guess" : null,
|
324 |
-
elt("span", cls + "fname", cache.name), "(");
|
325 |
-
for (var i = 0; i < tp.args.length; ++i) {
|
326 |
-
if (i) tip.appendChild(document.createTextNode(", "));
|
327 |
-
var arg = tp.args[i];
|
328 |
-
tip.appendChild(elt("span", cls + "farg" + (i == pos ? " " + cls + "farg-current" : ""), arg.name || "?"));
|
329 |
-
if (arg.type != "?") {
|
330 |
-
tip.appendChild(document.createTextNode(":\u00a0"));
|
331 |
-
tip.appendChild(elt("span", cls + "type", arg.type));
|
332 |
-
}
|
333 |
-
}
|
334 |
-
tip.appendChild(document.createTextNode(tp.rettype ? ") ->\u00a0" : ")"));
|
335 |
-
if (tp.rettype) tip.appendChild(elt("span", cls + "type", tp.rettype));
|
336 |
-
var place = cm.cursorCoords(null, "page");
|
337 |
-
ts.activeArgHints = makeTooltip(place.right + 1, place.bottom, tip);
|
338 |
-
}
|
339 |
-
|
340 |
-
function parseFnType(text) {
|
341 |
-
var args = [], pos = 3;
|
342 |
-
|
343 |
-
function skipMatching(upto) {
|
344 |
-
var depth = 0, start = pos;
|
345 |
-
for (;;) {
|
346 |
-
var next = text.charAt(pos);
|
347 |
-
if (upto.test(next) && !depth) return text.slice(start, pos);
|
348 |
-
if (/[{\[\(]/.test(next)) ++depth;
|
349 |
-
else if (/[}\]\)]/.test(next)) --depth;
|
350 |
-
++pos;
|
351 |
-
}
|
352 |
-
}
|
353 |
-
|
354 |
-
// Parse arguments
|
355 |
-
if (text.charAt(pos) != ")") for (;;) {
|
356 |
-
var name = text.slice(pos).match(/^([^, \(\[\{]+): /);
|
357 |
-
if (name) {
|
358 |
-
pos += name[0].length;
|
359 |
-
name = name[1];
|
360 |
-
}
|
361 |
-
args.push({name: name, type: skipMatching(/[\),]/)});
|
362 |
-
if (text.charAt(pos) == ")") break;
|
363 |
-
pos += 2;
|
364 |
-
}
|
365 |
-
|
366 |
-
var rettype = text.slice(pos).match(/^\) -> (.*)$/);
|
367 |
-
|
368 |
-
return {args: args, rettype: rettype && rettype[1]};
|
369 |
-
}
|
370 |
-
|
371 |
-
// Moving to the definition of something
|
372 |
-
|
373 |
-
function jumpToDef(ts, cm) {
|
374 |
-
function inner(varName) {
|
375 |
-
var req = {type: "definition", variable: varName || null};
|
376 |
-
var doc = findDoc(ts, cm.getDoc());
|
377 |
-
ts.server.request(buildRequest(ts, doc, req), function(error, data) {
|
378 |
-
if (error) return showError(ts, cm, error);
|
379 |
-
if (!data.file && data.url) { window.open(data.url); return; }
|
380 |
-
|
381 |
-
if (data.file) {
|
382 |
-
var localDoc = ts.docs[data.file], found;
|
383 |
-
if (localDoc && (found = findContext(localDoc.doc, data))) {
|
384 |
-
ts.jumpStack.push({file: doc.name,
|
385 |
-
start: cm.getCursor("from"),
|
386 |
-
end: cm.getCursor("to")});
|
387 |
-
moveTo(ts, doc, localDoc, found.start, found.end);
|
388 |
-
return;
|
389 |
-
}
|
390 |
-
}
|
391 |
-
showError(ts, cm, "Could not find a definition.");
|
392 |
-
});
|
393 |
-
}
|
394 |
-
|
395 |
-
if (!atInterestingExpression(cm))
|
396 |
-
dialog(cm, "Jump to variable", function(name) { if (name) inner(name); });
|
397 |
-
else
|
398 |
-
inner();
|
399 |
-
}
|
400 |
-
|
401 |
-
function jumpBack(ts, cm) {
|
402 |
-
var pos = ts.jumpStack.pop(), doc = pos && ts.docs[pos.file];
|
403 |
-
if (!doc) return;
|
404 |
-
moveTo(ts, findDoc(ts, cm.getDoc()), doc, pos.start, pos.end);
|
405 |
-
}
|
406 |
-
|
407 |
-
function moveTo(ts, curDoc, doc, start, end) {
|
408 |
-
doc.doc.setSelection(start, end);
|
409 |
-
if (curDoc != doc && ts.options.switchToDoc) {
|
410 |
-
closeArgHints(ts);
|
411 |
-
ts.options.switchToDoc(doc.name, doc.doc);
|
412 |
-
}
|
413 |
-
}
|
414 |
-
|
415 |
-
// The {line,ch} representation of positions makes this rather awkward.
|
416 |
-
function findContext(doc, data) {
|
417 |
-
var before = data.context.slice(0, data.contextOffset).split("\n");
|
418 |
-
var startLine = data.start.line - (before.length - 1);
|
419 |
-
var start = Pos(startLine, (before.length == 1 ? data.start.ch : doc.getLine(startLine).length) - before[0].length);
|
420 |
-
|
421 |
-
var text = doc.getLine(startLine).slice(start.ch);
|
422 |
-
for (var cur = startLine + 1; cur < doc.lineCount() && text.length < data.context.length; ++cur)
|
423 |
-
text += "\n" + doc.getLine(cur);
|
424 |
-
if (text.slice(0, data.context.length) == data.context) return data;
|
425 |
-
|
426 |
-
var cursor = doc.getSearchCursor(data.context, 0, false);
|
427 |
-
var nearest, nearestDist = Infinity;
|
428 |
-
while (cursor.findNext()) {
|
429 |
-
var from = cursor.from(), dist = Math.abs(from.line - start.line) * 10000;
|
430 |
-
if (!dist) dist = Math.abs(from.ch - start.ch);
|
431 |
-
if (dist < nearestDist) { nearest = from; nearestDist = dist; }
|
432 |
-
}
|
433 |
-
if (!nearest) return null;
|
434 |
-
|
435 |
-
if (before.length == 1)
|
436 |
-
nearest.ch += before[0].length;
|
437 |
-
else
|
438 |
-
nearest = Pos(nearest.line + (before.length - 1), before[before.length - 1].length);
|
439 |
-
if (data.start.line == data.end.line)
|
440 |
-
var end = Pos(nearest.line, nearest.ch + (data.end.ch - data.start.ch));
|
441 |
-
else
|
442 |
-
var end = Pos(nearest.line + (data.end.line - data.start.line), data.end.ch);
|
443 |
-
return {start: nearest, end: end};
|
444 |
-
}
|
445 |
-
|
446 |
-
function atInterestingExpression(cm) {
|
447 |
-
var pos = cm.getCursor("end"), tok = cm.getTokenAt(pos);
|
448 |
-
if (tok.start < pos.ch && tok.type == "comment") return false;
|
449 |
-
return /[\w)\]]/.test(cm.getLine(pos.line).slice(Math.max(pos.ch - 1, 0), pos.ch + 1));
|
450 |
-
}
|
451 |
-
|
452 |
-
// Variable renaming
|
453 |
-
|
454 |
-
function rename(ts, cm) {
|
455 |
-
var token = cm.getTokenAt(cm.getCursor());
|
456 |
-
if (!/\w/.test(token.string)) return showError(ts, cm, "Not at a variable");
|
457 |
-
dialog(cm, "New name for " + token.string, function(newName) {
|
458 |
-
ts.request(cm, {type: "rename", newName: newName, fullDocs: true}, function(error, data) {
|
459 |
-
if (error) return showError(ts, cm, error);
|
460 |
-
applyChanges(ts, data.changes);
|
461 |
-
});
|
462 |
-
});
|
463 |
-
}
|
464 |
-
|
465 |
-
function selectName(ts, cm) {
|
466 |
-
var name = findDoc(ts, cm.doc).name;
|
467 |
-
ts.request(cm, {type: "refs"}, function(error, data) {
|
468 |
-
if (error) return showError(ts, cm, error);
|
469 |
-
var ranges = [], cur = 0;
|
470 |
-
var curPos = cm.getCursor();
|
471 |
-
for (var i = 0; i < data.refs.length; i++) {
|
472 |
-
var ref = data.refs[i];
|
473 |
-
if (ref.file == name) {
|
474 |
-
ranges.push({anchor: ref.start, head: ref.end});
|
475 |
-
if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0)
|
476 |
-
cur = ranges.length - 1;
|
477 |
-
}
|
478 |
-
}
|
479 |
-
cm.setSelections(ranges, cur);
|
480 |
-
});
|
481 |
-
}
|
482 |
-
|
483 |
-
var nextChangeOrig = 0;
|
484 |
-
function applyChanges(ts, changes) {
|
485 |
-
var perFile = Object.create(null);
|
486 |
-
for (var i = 0; i < changes.length; ++i) {
|
487 |
-
var ch = changes[i];
|
488 |
-
(perFile[ch.file] || (perFile[ch.file] = [])).push(ch);
|
489 |
-
}
|
490 |
-
for (var file in perFile) {
|
491 |
-
var known = ts.docs[file], chs = perFile[file];;
|
492 |
-
if (!known) continue;
|
493 |
-
chs.sort(function(a, b) { return cmpPos(b.start, a.start); });
|
494 |
-
var origin = "*rename" + (++nextChangeOrig);
|
495 |
-
for (var i = 0; i < chs.length; ++i) {
|
496 |
-
var ch = chs[i];
|
497 |
-
known.doc.replaceRange(ch.text, ch.start, ch.end, origin);
|
498 |
-
}
|
499 |
-
}
|
500 |
-
}
|
501 |
-
|
502 |
-
// Generic request-building helper
|
503 |
-
|
504 |
-
function buildRequest(ts, doc, query, pos) {
|
505 |
-
var files = [], offsetLines = 0, allowFragments = !query.fullDocs;
|
506 |
-
if (!allowFragments) delete query.fullDocs;
|
507 |
-
if (typeof query == "string") query = {type: query};
|
508 |
-
query.lineCharPositions = true;
|
509 |
-
if (query.end == null) {
|
510 |
-
query.end = pos || doc.doc.getCursor("end");
|
511 |
-
if (doc.doc.somethingSelected())
|
512 |
-
query.start = doc.doc.getCursor("start");
|
513 |
-
}
|
514 |
-
var startPos = query.start || query.end;
|
515 |
-
|
516 |
-
if (doc.changed) {
|
517 |
-
if (doc.doc.lineCount() > bigDoc && allowFragments !== false &&
|
518 |
-
doc.changed.to - doc.changed.from < 100 &&
|
519 |
-
doc.changed.from <= startPos.line && doc.changed.to > query.end.line) {
|
520 |
-
files.push(getFragmentAround(doc, startPos, query.end));
|
521 |
-
query.file = "#0";
|
522 |
-
var offsetLines = files[0].offsetLines;
|
523 |
-
if (query.start != null) query.start = Pos(query.start.line - -offsetLines, query.start.ch);
|
524 |
-
query.end = Pos(query.end.line - offsetLines, query.end.ch);
|
525 |
-
} else {
|
526 |
-
files.push({type: "full",
|
527 |
-
name: doc.name,
|
528 |
-
text: docValue(ts, doc)});
|
529 |
-
query.file = doc.name;
|
530 |
-
doc.changed = null;
|
531 |
-
}
|
532 |
-
} else {
|
533 |
-
query.file = doc.name;
|
534 |
-
}
|
535 |
-
for (var name in ts.docs) {
|
536 |
-
var cur = ts.docs[name];
|
537 |
-
if (cur.changed && cur != doc) {
|
538 |
-
files.push({type: "full", name: cur.name, text: docValue(ts, cur)});
|
539 |
-
cur.changed = null;
|
540 |
-
}
|
541 |
-
}
|
542 |
-
|
543 |
-
return {query: query, files: files};
|
544 |
-
}
|
545 |
-
|
546 |
-
function getFragmentAround(data, start, end) {
|
547 |
-
var doc = data.doc;
|
548 |
-
var minIndent = null, minLine = null, endLine, tabSize = 4;
|
549 |
-
for (var p = start.line - 1, min = Math.max(0, p - 50); p >= min; --p) {
|
550 |
-
var line = doc.getLine(p), fn = line.search(/\bfunction\b/);
|
551 |
-
if (fn < 0) continue;
|
552 |
-
var indent = CodeMirror.countColumn(line, null, tabSize);
|
553 |
-
if (minIndent != null && minIndent <= indent) continue;
|
554 |
-
minIndent = indent;
|
555 |
-
minLine = p;
|
556 |
-
}
|
557 |
-
if (minLine == null) minLine = min;
|
558 |
-
var max = Math.min(doc.lastLine(), end.line + 20);
|
559 |
-
if (minIndent == null || minIndent == CodeMirror.countColumn(doc.getLine(start.line), null, tabSize))
|
560 |
-
endLine = max;
|
561 |
-
else for (endLine = end.line + 1; endLine < max; ++endLine) {
|
562 |
-
var indent = CodeMirror.countColumn(doc.getLine(endLine), null, tabSize);
|
563 |
-
if (indent <= minIndent) break;
|
564 |
-
}
|
565 |
-
var from = Pos(minLine, 0);
|
566 |
-
|
567 |
-
return {type: "part",
|
568 |
-
name: data.name,
|
569 |
-
offsetLines: from.line,
|
570 |
-
text: doc.getRange(from, Pos(endLine, 0))};
|
571 |
-
}
|
572 |
-
|
573 |
-
// Generic utilities
|
574 |
-
|
575 |
-
var cmpPos = CodeMirror.cmpPos;
|
576 |
-
|
577 |
-
function elt(tagname, cls /*, ... elts*/) {
|
578 |
-
var e = document.createElement(tagname);
|
579 |
-
if (cls) e.className = cls;
|
580 |
-
for (var i = 2; i < arguments.length; ++i) {
|
581 |
-
var elt = arguments[i];
|
582 |
-
if (typeof elt == "string") elt = document.createTextNode(elt);
|
583 |
-
e.appendChild(elt);
|
584 |
-
}
|
585 |
-
return e;
|
586 |
-
}
|
587 |
-
|
588 |
-
function dialog(cm, text, f) {
|
589 |
-
if (cm.openDialog)
|
590 |
-
cm.openDialog(text + ": <input type=text>", f);
|
591 |
-
else
|
592 |
-
f(prompt(text, ""));
|
593 |
-
}
|
594 |
-
|
595 |
-
// Tooltips
|
596 |
-
|
597 |
-
function tempTooltip(cm, content, ts) {
|
598 |
-
if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
|
599 |
-
var where = cm.cursorCoords();
|
600 |
-
var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
|
601 |
-
function maybeClear() {
|
602 |
-
old = true;
|
603 |
-
if (!mouseOnTip) clear();
|
604 |
-
}
|
605 |
-
function clear() {
|
606 |
-
cm.state.ternTooltip = null;
|
607 |
-
if (!tip.parentNode) return;
|
608 |
-
cm.off("cursorActivity", clear);
|
609 |
-
cm.off('blur', clear);
|
610 |
-
cm.off('scroll', clear);
|
611 |
-
fadeOut(tip);
|
612 |
-
}
|
613 |
-
var mouseOnTip = false, old = false;
|
614 |
-
CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; });
|
615 |
-
CodeMirror.on(tip, "mouseout", function(e) {
|
616 |
-
if (!CodeMirror.contains(tip, e.relatedTarget || e.toElement)) {
|
617 |
-
if (old) clear();
|
618 |
-
else mouseOnTip = false;
|
619 |
-
}
|
620 |
-
});
|
621 |
-
setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700);
|
622 |
-
cm.on("cursorActivity", clear);
|
623 |
-
cm.on('blur', clear);
|
624 |
-
cm.on('scroll', clear);
|
625 |
-
}
|
626 |
-
|
627 |
-
function makeTooltip(x, y, content) {
|
628 |
-
var node = elt("div", cls + "tooltip", content);
|
629 |
-
node.style.left = x + "px";
|
630 |
-
node.style.top = y + "px";
|
631 |
-
document.body.appendChild(node);
|
632 |
-
return node;
|
633 |
-
}
|
634 |
-
|
635 |
-
function remove(node) {
|
636 |
-
var p = node && node.parentNode;
|
637 |
-
if (p) p.removeChild(node);
|
638 |
-
}
|
639 |
-
|
640 |
-
function fadeOut(tooltip) {
|
641 |
-
tooltip.style.opacity = "0";
|
642 |
-
setTimeout(function() { remove(tooltip); }, 1100);
|
643 |
-
}
|
644 |
-
|
645 |
-
function showError(ts, cm, msg) {
|
646 |
-
if (ts.options.showError)
|
647 |
-
ts.options.showError(cm, msg);
|
648 |
-
else
|
649 |
-
tempTooltip(cm, String(msg), ts);
|
650 |
-
}
|
651 |
-
|
652 |
-
function closeArgHints(ts) {
|
653 |
-
if (ts.activeArgHints) { remove(ts.activeArgHints); ts.activeArgHints = null; }
|
654 |
-
}
|
655 |
-
|
656 |
-
function docValue(ts, doc) {
|
657 |
-
var val = doc.doc.getValue();
|
658 |
-
if (ts.options.fileFilter) val = ts.options.fileFilter(val, doc.name, doc.doc);
|
659 |
-
return val;
|
660 |
-
}
|
661 |
-
|
662 |
-
// Worker wrapper
|
663 |
-
|
664 |
-
function WorkerServer(ts) {
|
665 |
-
var worker = ts.worker = new Worker(ts.options.workerScript);
|
666 |
-
worker.postMessage({type: "init",
|
667 |
-
defs: ts.options.defs,
|
668 |
-
plugins: ts.options.plugins,
|
669 |
-
scripts: ts.options.workerDeps});
|
670 |
-
var msgId = 0, pending = {};
|
671 |
-
|
672 |
-
function send(data, c) {
|
673 |
-
if (c) {
|
674 |
-
data.id = ++msgId;
|
675 |
-
pending[msgId] = c;
|
676 |
-
}
|
677 |
-
worker.postMessage(data);
|
678 |
-
}
|
679 |
-
worker.onmessage = function(e) {
|
680 |
-
var data = e.data;
|
681 |
-
if (data.type == "getFile") {
|
682 |
-
getFile(ts, data.name, function(err, text) {
|
683 |
-
send({type: "getFile", err: String(err), text: text, id: data.id});
|
684 |
-
});
|
685 |
-
} else if (data.type == "debug") {
|
686 |
-
window.console.log(data.message);
|
687 |
-
} else if (data.id && pending[data.id]) {
|
688 |
-
pending[data.id](data.err, data.body);
|
689 |
-
delete pending[data.id];
|
690 |
-
}
|
691 |
-
};
|
692 |
-
worker.onerror = function(e) {
|
693 |
-
for (var id in pending) pending[id](e);
|
694 |
-
pending = {};
|
695 |
-
};
|
696 |
-
|
697 |
-
this.addFile = function(name, text) { send({type: "add", name: name, text: text}); };
|
698 |
-
this.delFile = function(name) { send({type: "del", name: name}); };
|
699 |
-
this.request = function(body, c) { send({type: "req", body: body}, c); };
|
700 |
-
}
|
701 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/tern/worker.js
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// declare global: tern, server
|
5 |
-
|
6 |
-
var server;
|
7 |
-
|
8 |
-
this.onmessage = function(e) {
|
9 |
-
var data = e.data;
|
10 |
-
switch (data.type) {
|
11 |
-
case "init": return startServer(data.defs, data.plugins, data.scripts);
|
12 |
-
case "add": return server.addFile(data.name, data.text);
|
13 |
-
case "del": return server.delFile(data.name);
|
14 |
-
case "req": return server.request(data.body, function(err, reqData) {
|
15 |
-
postMessage({id: data.id, body: reqData, err: err && String(err)});
|
16 |
-
});
|
17 |
-
case "getFile":
|
18 |
-
var c = pending[data.id];
|
19 |
-
delete pending[data.id];
|
20 |
-
return c(data.err, data.text);
|
21 |
-
default: throw new Error("Unknown message type: " + data.type);
|
22 |
-
}
|
23 |
-
};
|
24 |
-
|
25 |
-
var nextId = 0, pending = {};
|
26 |
-
function getFile(file, c) {
|
27 |
-
postMessage({type: "getFile", name: file, id: ++nextId});
|
28 |
-
pending[nextId] = c;
|
29 |
-
}
|
30 |
-
|
31 |
-
function startServer(defs, plugins, scripts) {
|
32 |
-
if (scripts) importScripts.apply(null, scripts);
|
33 |
-
|
34 |
-
server = new tern.Server({
|
35 |
-
getFile: getFile,
|
36 |
-
async: true,
|
37 |
-
defs: defs,
|
38 |
-
plugins: plugins
|
39 |
-
});
|
40 |
-
}
|
41 |
-
|
42 |
-
this.console = {
|
43 |
-
log: function(v) { postMessage({type: "debug", message: v}); }
|
44 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/addon/wrap/hardwrap.js
DELETED
@@ -1,142 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var Pos = CodeMirror.Pos;
|
15 |
-
|
16 |
-
function findParagraph(cm, pos, options) {
|
17 |
-
var startRE = options.paragraphStart || cm.getHelper(pos, "paragraphStart");
|
18 |
-
for (var start = pos.line, first = cm.firstLine(); start > first; --start) {
|
19 |
-
var line = cm.getLine(start);
|
20 |
-
if (startRE && startRE.test(line)) break;
|
21 |
-
if (!/\S/.test(line)) { ++start; break; }
|
22 |
-
}
|
23 |
-
var endRE = options.paragraphEnd || cm.getHelper(pos, "paragraphEnd");
|
24 |
-
for (var end = pos.line + 1, last = cm.lastLine(); end <= last; ++end) {
|
25 |
-
var line = cm.getLine(end);
|
26 |
-
if (endRE && endRE.test(line)) { ++end; break; }
|
27 |
-
if (!/\S/.test(line)) break;
|
28 |
-
}
|
29 |
-
return {from: start, to: end};
|
30 |
-
}
|
31 |
-
|
32 |
-
function findBreakPoint(text, column, wrapOn, killTrailingSpace) {
|
33 |
-
for (var at = column; at > 0; --at)
|
34 |
-
if (wrapOn.test(text.slice(at - 1, at + 1))) break;
|
35 |
-
for (var first = true;; first = false) {
|
36 |
-
var endOfText = at;
|
37 |
-
if (killTrailingSpace)
|
38 |
-
while (text.charAt(endOfText - 1) == " ") --endOfText;
|
39 |
-
if (endOfText == 0 && first) at = column;
|
40 |
-
else return {from: endOfText, to: at};
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
function wrapRange(cm, from, to, options) {
|
45 |
-
from = cm.clipPos(from); to = cm.clipPos(to);
|
46 |
-
var column = options.column || 80;
|
47 |
-
var wrapOn = options.wrapOn || /\s\S|-[^\.\d]/;
|
48 |
-
var killTrailing = options.killTrailingSpace !== false;
|
49 |
-
var changes = [], curLine = "", curNo = from.line;
|
50 |
-
var lines = cm.getRange(from, to, false);
|
51 |
-
if (!lines.length) return null;
|
52 |
-
var leadingSpace = lines[0].match(/^[ \t]*/)[0];
|
53 |
-
|
54 |
-
for (var i = 0; i < lines.length; ++i) {
|
55 |
-
var text = lines[i], oldLen = curLine.length, spaceInserted = 0;
|
56 |
-
if (curLine && text && !wrapOn.test(curLine.charAt(curLine.length - 1) + text.charAt(0))) {
|
57 |
-
curLine += " ";
|
58 |
-
spaceInserted = 1;
|
59 |
-
}
|
60 |
-
var spaceTrimmed = "";
|
61 |
-
if (i) {
|
62 |
-
spaceTrimmed = text.match(/^\s*/)[0];
|
63 |
-
text = text.slice(spaceTrimmed.length);
|
64 |
-
}
|
65 |
-
curLine += text;
|
66 |
-
if (i) {
|
67 |
-
var firstBreak = curLine.length > column && leadingSpace == spaceTrimmed &&
|
68 |
-
findBreakPoint(curLine, column, wrapOn, killTrailing);
|
69 |
-
// If this isn't broken, or is broken at a different point, remove old break
|
70 |
-
if (!firstBreak || firstBreak.from != oldLen || firstBreak.to != oldLen + spaceInserted) {
|
71 |
-
changes.push({text: [spaceInserted ? " " : ""],
|
72 |
-
from: Pos(curNo, oldLen),
|
73 |
-
to: Pos(curNo + 1, spaceTrimmed.length)});
|
74 |
-
} else {
|
75 |
-
curLine = leadingSpace + text;
|
76 |
-
++curNo;
|
77 |
-
}
|
78 |
-
}
|
79 |
-
while (curLine.length > column) {
|
80 |
-
var bp = findBreakPoint(curLine, column, wrapOn, killTrailing);
|
81 |
-
changes.push({text: ["", leadingSpace],
|
82 |
-
from: Pos(curNo, bp.from),
|
83 |
-
to: Pos(curNo, bp.to)});
|
84 |
-
curLine = leadingSpace + curLine.slice(bp.to);
|
85 |
-
++curNo;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
if (changes.length) cm.operation(function() {
|
89 |
-
for (var i = 0; i < changes.length; ++i) {
|
90 |
-
var change = changes[i];
|
91 |
-
if (change.text || CodeMirror.cmpPos(change.from, change.to))
|
92 |
-
cm.replaceRange(change.text, change.from, change.to);
|
93 |
-
}
|
94 |
-
});
|
95 |
-
return changes.length ? {from: changes[0].from, to: CodeMirror.changeEnd(changes[changes.length - 1])} : null;
|
96 |
-
}
|
97 |
-
|
98 |
-
CodeMirror.defineExtension("wrapParagraph", function(pos, options) {
|
99 |
-
options = options || {};
|
100 |
-
if (!pos) pos = this.getCursor();
|
101 |
-
var para = findParagraph(this, pos, options);
|
102 |
-
return wrapRange(this, Pos(para.from, 0), Pos(para.to - 1), options);
|
103 |
-
});
|
104 |
-
|
105 |
-
CodeMirror.commands.wrapLines = function(cm) {
|
106 |
-
cm.operation(function() {
|
107 |
-
var ranges = cm.listSelections(), at = cm.lastLine() + 1;
|
108 |
-
for (var i = ranges.length - 1; i >= 0; i--) {
|
109 |
-
var range = ranges[i], span;
|
110 |
-
if (range.empty()) {
|
111 |
-
var para = findParagraph(cm, range.head, {});
|
112 |
-
span = {from: Pos(para.from, 0), to: Pos(para.to - 1)};
|
113 |
-
} else {
|
114 |
-
span = {from: range.from(), to: range.to()};
|
115 |
-
}
|
116 |
-
if (span.to.line >= at) continue;
|
117 |
-
at = span.from.line;
|
118 |
-
wrapRange(cm, span.from, span.to, {});
|
119 |
-
}
|
120 |
-
});
|
121 |
-
};
|
122 |
-
|
123 |
-
CodeMirror.defineExtension("wrapRange", function(from, to, options) {
|
124 |
-
return wrapRange(this, from, to, options || {});
|
125 |
-
});
|
126 |
-
|
127 |
-
CodeMirror.defineExtension("wrapParagraphsInRange", function(from, to, options) {
|
128 |
-
options = options || {};
|
129 |
-
var cm = this, paras = [];
|
130 |
-
for (var line = from.line; line <= to.line;) {
|
131 |
-
var para = findParagraph(cm, Pos(line, 0), options);
|
132 |
-
paras.push(para);
|
133 |
-
line = para.to;
|
134 |
-
}
|
135 |
-
var madeChange = false;
|
136 |
-
if (paras.length) cm.operation(function() {
|
137 |
-
for (var i = paras.length - 1; i >= 0; --i)
|
138 |
-
madeChange = madeChange || wrapRange(cm, Pos(paras[i].from, 0), Pos(paras[i].to - 1), options);
|
139 |
-
});
|
140 |
-
return madeChange;
|
141 |
-
});
|
142 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/bin/authors.sh
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
# Combine existing list of authors with everyone known in git, sort, add header.
|
2 |
-
tail --lines=+3 AUTHORS > AUTHORS.tmp
|
3 |
-
git log --format='%aN' >> AUTHORS.tmp
|
4 |
-
echo -e "List of CodeMirror contributors. Updated before every release.\n" > AUTHORS
|
5 |
-
sort -u AUTHORS.tmp >> AUTHORS
|
6 |
-
rm -f AUTHORS.tmp
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/bin/compress
DELETED
@@ -1,92 +0,0 @@
|
|
1 |
-
#!/usr/bin/env node
|
2 |
-
|
3 |
-
// Compression helper for CodeMirror
|
4 |
-
//
|
5 |
-
// Example:
|
6 |
-
//
|
7 |
-
// bin/compress codemirror runmode javascript xml
|
8 |
-
//
|
9 |
-
// Will take lib/codemirror.js, addon/runmode/runmode.js,
|
10 |
-
// mode/javascript/javascript.js, and mode/xml/xml.js, run them though
|
11 |
-
// the online minifier at http://marijnhaverbeke.nl/uglifyjs, and spit
|
12 |
-
// out the result.
|
13 |
-
//
|
14 |
-
// bin/compress codemirror --local /path/to/bin/UglifyJS
|
15 |
-
//
|
16 |
-
// Will use a local minifier instead of the online default one.
|
17 |
-
//
|
18 |
-
// Script files are specified without .js ending. Prefixing them with
|
19 |
-
// their full (local) path is optional. So you may say lib/codemirror
|
20 |
-
// or mode/xml/xml to be more precise. In fact, even the .js suffix
|
21 |
-
// may be speficied, if wanted.
|
22 |
-
|
23 |
-
"use strict";
|
24 |
-
|
25 |
-
var fs = require("fs");
|
26 |
-
|
27 |
-
function help(ok) {
|
28 |
-
console.log("usage: " + process.argv[1] + " [--local /path/to/uglifyjs] files...");
|
29 |
-
process.exit(ok ? 0 : 1);
|
30 |
-
}
|
31 |
-
|
32 |
-
var local = null, args = [], extraArgs = null, files = [], blob = "";
|
33 |
-
|
34 |
-
for (var i = 2; i < process.argv.length; ++i) {
|
35 |
-
var arg = process.argv[i];
|
36 |
-
if (arg == "--local" && i + 1 < process.argv.length) {
|
37 |
-
var parts = process.argv[++i].split(/\s+/);
|
38 |
-
local = parts[0];
|
39 |
-
extraArgs = parts.slice(1);
|
40 |
-
if (!extraArgs.length) extraArgs = ["-c", "-m"];
|
41 |
-
} else if (arg == "--help") {
|
42 |
-
help(true);
|
43 |
-
} else if (arg[0] != "-") {
|
44 |
-
files.push({name: arg, re: new RegExp("(?:\\/|^)" + arg + (/\.js$/.test(arg) ? "$" : "\\.js$"))});
|
45 |
-
} else help(false);
|
46 |
-
}
|
47 |
-
|
48 |
-
function walk(dir) {
|
49 |
-
fs.readdirSync(dir).forEach(function(fname) {
|
50 |
-
if (/^[_\.]/.test(fname)) return;
|
51 |
-
var file = dir + fname;
|
52 |
-
if (fs.statSync(file).isDirectory()) return walk(file + "/");
|
53 |
-
if (files.some(function(spec, i) {
|
54 |
-
var match = spec.re.test(file);
|
55 |
-
if (match) files.splice(i, 1);
|
56 |
-
return match;
|
57 |
-
})) {
|
58 |
-
if (local) args.push(file);
|
59 |
-
else blob += fs.readFileSync(file, "utf8");
|
60 |
-
}
|
61 |
-
});
|
62 |
-
}
|
63 |
-
|
64 |
-
walk("lib/");
|
65 |
-
walk("addon/");
|
66 |
-
walk("mode/");
|
67 |
-
|
68 |
-
if (!local && !blob) help(false);
|
69 |
-
|
70 |
-
if (files.length) {
|
71 |
-
console.log("Some speficied files were not found: " +
|
72 |
-
files.map(function(a){return a.name;}).join(", "));
|
73 |
-
process.exit(1);
|
74 |
-
}
|
75 |
-
|
76 |
-
if (local) {
|
77 |
-
require("child_process").spawn(local, args.concat(extraArgs), {stdio: ["ignore", process.stdout, process.stderr]});
|
78 |
-
} else {
|
79 |
-
var data = new Buffer("js_code=" + require("querystring").escape(blob), "utf8");
|
80 |
-
var req = require("http").request({
|
81 |
-
host: "marijnhaverbeke.nl",
|
82 |
-
port: 80,
|
83 |
-
method: "POST",
|
84 |
-
path: "/uglifyjs",
|
85 |
-
headers: {"content-type": "application/x-www-form-urlencoded",
|
86 |
-
"content-length": data.length}
|
87 |
-
});
|
88 |
-
req.on("response", function(resp) {
|
89 |
-
resp.on("data", function (chunk) { process.stdout.write(chunk); });
|
90 |
-
});
|
91 |
-
req.end(data);
|
92 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/bin/lint
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
#!/usr/bin/env node
|
2 |
-
|
3 |
-
process.exit(require("../test/lint").ok ? 0 : 1);
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/bin/release
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
#!/usr/bin/env node
|
2 |
-
|
3 |
-
var fs = require("fs"), child = require("child_process");
|
4 |
-
|
5 |
-
var number, bumpOnly;
|
6 |
-
|
7 |
-
for (var i = 2; i < process.argv.length; i++) {
|
8 |
-
if (process.argv[i] == "-bump") bumpOnly = true;
|
9 |
-
else if (/^\d+\.\d+\.\d+$/.test(process.argv[i])) number = process.argv[i];
|
10 |
-
else { console.log("Bogus command line arg: " + process.argv[i]); process.exit(1); }
|
11 |
-
}
|
12 |
-
|
13 |
-
if (!number) { console.log("Must give a version"); process.exit(1); }
|
14 |
-
|
15 |
-
function rewrite(file, f) {
|
16 |
-
fs.writeFileSync(file, f(fs.readFileSync(file, "utf8")), "utf8");
|
17 |
-
}
|
18 |
-
|
19 |
-
rewrite("lib/codemirror.js", function(lib) {
|
20 |
-
return lib.replace(/CodeMirror\.version = "\d+\.\d+\.\d+"/,
|
21 |
-
"CodeMirror.version = \"" + number + "\"");
|
22 |
-
});
|
23 |
-
function rewriteJSON(pack) {
|
24 |
-
return pack.replace(/"version":"\d+\.\d+\.\d+"/, "\"version\":\"" + number + "\"");
|
25 |
-
}
|
26 |
-
rewrite("package.json", rewriteJSON);
|
27 |
-
rewrite("doc/manual.html", function(manual) {
|
28 |
-
return manual.replace(/>version \d+\.\d+\.\d+<\/span>/, ">version " + number + "</span>");
|
29 |
-
});
|
30 |
-
|
31 |
-
if (bumpOnly) process.exit(0);
|
32 |
-
|
33 |
-
child.exec("bash bin/authors.sh", function(){});
|
34 |
-
|
35 |
-
var simple = number.slice(0, number.lastIndexOf("."));
|
36 |
-
|
37 |
-
rewrite("doc/compress.html", function(cmp) {
|
38 |
-
return cmp.replace(/<option value="http:\/\/codemirror.net\/">HEAD<\/option>/,
|
39 |
-
"<option value=\"http://codemirror.net/\">HEAD</option>\n <option value=\"http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=" + number + ";f=\">" + simple + "</option>");
|
40 |
-
});
|
41 |
-
|
42 |
-
rewrite("index.html", function(index) {
|
43 |
-
return index.replace(/\.zip">\d+\.\d+<\/a>/,
|
44 |
-
".zip\">" + simple + "</a>");
|
45 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/bin/source-highlight
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
#!/usr/bin/env node
|
2 |
-
|
3 |
-
// Simple command-line code highlighting tool. Reads code from stdin,
|
4 |
-
// spits html to stdout. For example:
|
5 |
-
//
|
6 |
-
// echo 'function foo(a) { return a; }' | bin/source-highlight -s javascript
|
7 |
-
// bin/source-highlight -s
|
8 |
-
|
9 |
-
var fs = require("fs");
|
10 |
-
|
11 |
-
var CodeMirror = require("../addon/runmode/runmode.node.js");
|
12 |
-
require("../mode/meta.js");
|
13 |
-
|
14 |
-
var sPos = process.argv.indexOf("-s");
|
15 |
-
if (sPos == -1 || sPos == process.argv.length - 1) {
|
16 |
-
console.error("Usage: source-highlight -s language");
|
17 |
-
process.exit(1);
|
18 |
-
}
|
19 |
-
var lang = process.argv[sPos + 1].toLowerCase(), modeName = lang;
|
20 |
-
CodeMirror.modeInfo.forEach(function(info) {
|
21 |
-
if (info.mime == lang) {
|
22 |
-
modeName = info.mode;
|
23 |
-
} else if (info.name.toLowerCase() == lang) {
|
24 |
-
modeName = info.mode;
|
25 |
-
lang = info.mime;
|
26 |
-
}
|
27 |
-
});
|
28 |
-
|
29 |
-
if (!CodeMirror.modes[modeName])
|
30 |
-
require("../mode/" + modeName + "/" + modeName + ".js");
|
31 |
-
|
32 |
-
function esc(str) {
|
33 |
-
return str.replace(/[<&]/g, function(ch) { return ch == "&" ? "&" : "<"; });
|
34 |
-
}
|
35 |
-
|
36 |
-
var code = fs.readFileSync("/dev/stdin", "utf8");
|
37 |
-
var curStyle = null, accum = "";
|
38 |
-
function flush() {
|
39 |
-
if (curStyle) process.stdout.write("<span class=\"" + curStyle.replace(/(^|\s+)/g, "$1cm-") + "\">" + esc(accum) + "</span>");
|
40 |
-
else process.stdout.write(esc(accum));
|
41 |
-
}
|
42 |
-
|
43 |
-
CodeMirror.runMode(code, lang, function(text, style) {
|
44 |
-
if (style != curStyle) {
|
45 |
-
flush();
|
46 |
-
curStyle = style; accum = text;
|
47 |
-
} else {
|
48 |
-
accum += text;
|
49 |
-
}
|
50 |
-
});
|
51 |
-
flush();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/keymap/emacs.js
DELETED
@@ -1,412 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
(function(mod) {
|
5 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../lib/codemirror"));
|
7 |
-
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../lib/codemirror"], mod);
|
9 |
-
else // Plain browser env
|
10 |
-
mod(CodeMirror);
|
11 |
-
})(function(CodeMirror) {
|
12 |
-
"use strict";
|
13 |
-
|
14 |
-
var Pos = CodeMirror.Pos;
|
15 |
-
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
16 |
-
|
17 |
-
// Kill 'ring'
|
18 |
-
|
19 |
-
var killRing = [];
|
20 |
-
function addToRing(str) {
|
21 |
-
killRing.push(str);
|
22 |
-
if (killRing.length > 50) killRing.shift();
|
23 |
-
}
|
24 |
-
function growRingTop(str) {
|
25 |
-
if (!killRing.length) return addToRing(str);
|
26 |
-
killRing[killRing.length - 1] += str;
|
27 |
-
}
|
28 |
-
function getFromRing(n) { return killRing[killRing.length - (n ? Math.min(n, 1) : 1)] || ""; }
|
29 |
-
function popFromRing() { if (killRing.length > 1) killRing.pop(); return getFromRing(); }
|
30 |
-
|
31 |
-
var lastKill = null;
|
32 |
-
|
33 |
-
function kill(cm, from, to, mayGrow, text) {
|
34 |
-
if (text == null) text = cm.getRange(from, to);
|
35 |
-
|
36 |
-
if (mayGrow && lastKill && lastKill.cm == cm && posEq(from, lastKill.pos) && cm.isClean(lastKill.gen))
|
37 |
-
growRingTop(text);
|
38 |
-
else
|
39 |
-
addToRing(text);
|
40 |
-
cm.replaceRange("", from, to, "+delete");
|
41 |
-
|
42 |
-
if (mayGrow) lastKill = {cm: cm, pos: from, gen: cm.changeGeneration()};
|
43 |
-
else lastKill = null;
|
44 |
-
}
|
45 |
-
|
46 |
-
// Boundaries of various units
|
47 |
-
|
48 |
-
function byChar(cm, pos, dir) {
|
49 |
-
return cm.findPosH(pos, dir, "char", true);
|
50 |
-
}
|
51 |
-
|
52 |
-
function byWord(cm, pos, dir) {
|
53 |
-
return cm.findPosH(pos, dir, "word", true);
|
54 |
-
}
|
55 |
-
|
56 |
-
function byLine(cm, pos, dir) {
|
57 |
-
return cm.findPosV(pos, dir, "line", cm.doc.sel.goalColumn);
|
58 |
-
}
|
59 |
-
|
60 |
-
function byPage(cm, pos, dir) {
|
61 |
-
return cm.findPosV(pos, dir, "page", cm.doc.sel.goalColumn);
|
62 |
-
}
|
63 |
-
|
64 |
-
function byParagraph(cm, pos, dir) {
|
65 |
-
var no = pos.line, line = cm.getLine(no);
|
66 |
-
var sawText = /\S/.test(dir < 0 ? line.slice(0, pos.ch) : line.slice(pos.ch));
|
67 |
-
var fst = cm.firstLine(), lst = cm.lastLine();
|
68 |
-
for (;;) {
|
69 |
-
no += dir;
|
70 |
-
if (no < fst || no > lst)
|
71 |
-
return cm.clipPos(Pos(no - dir, dir < 0 ? 0 : null));
|
72 |
-
line = cm.getLine(no);
|
73 |
-
var hasText = /\S/.test(line);
|
74 |
-
if (hasText) sawText = true;
|
75 |
-
else if (sawText) return Pos(no, 0);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
function bySentence(cm, pos, dir) {
|
80 |
-
var line = pos.line, ch = pos.ch;
|
81 |
-
var text = cm.getLine(pos.line), sawWord = false;
|
82 |
-
for (;;) {
|
83 |
-
var next = text.charAt(ch + (dir < 0 ? -1 : 0));
|
84 |
-
if (!next) { // End/beginning of line reached
|
85 |
-
if (line == (dir < 0 ? cm.firstLine() : cm.lastLine())) return Pos(line, ch);
|
86 |
-
text = cm.getLine(line + dir);
|
87 |
-
if (!/\S/.test(text)) return Pos(line, ch);
|
88 |
-
line += dir;
|
89 |
-
ch = dir < 0 ? text.length : 0;
|
90 |
-
continue;
|
91 |
-
}
|
92 |
-
if (sawWord && /[!?.]/.test(next)) return Pos(line, ch + (dir > 0 ? 1 : 0));
|
93 |
-
if (!sawWord) sawWord = /\w/.test(next);
|
94 |
-
ch += dir;
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
function byExpr(cm, pos, dir) {
|
99 |
-
var wrap;
|
100 |
-
if (cm.findMatchingBracket && (wrap = cm.findMatchingBracket(pos, true))
|
101 |
-
&& wrap.match && (wrap.forward ? 1 : -1) == dir)
|
102 |
-
return dir > 0 ? Pos(wrap.to.line, wrap.to.ch + 1) : wrap.to;
|
103 |
-
|
104 |
-
for (var first = true;; first = false) {
|
105 |
-
var token = cm.getTokenAt(pos);
|
106 |
-
var after = Pos(pos.line, dir < 0 ? token.start : token.end);
|
107 |
-
if (first && dir > 0 && token.end == pos.ch || !/\w/.test(token.string)) {
|
108 |
-
var newPos = cm.findPosH(after, dir, "char");
|
109 |
-
if (posEq(after, newPos)) return pos;
|
110 |
-
else pos = newPos;
|
111 |
-
} else {
|
112 |
-
return after;
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
// Prefixes (only crudely supported)
|
118 |
-
|
119 |
-
function getPrefix(cm, precise) {
|
120 |
-
var digits = cm.state.emacsPrefix;
|
121 |
-
if (!digits) return precise ? null : 1;
|
122 |
-
clearPrefix(cm);
|
123 |
-
return digits == "-" ? -1 : Number(digits);
|
124 |
-
}
|
125 |
-
|
126 |
-
function repeated(cmd) {
|
127 |
-
var f = typeof cmd == "string" ? function(cm) { cm.execCommand(cmd); } : cmd;
|
128 |
-
return function(cm) {
|
129 |
-
var prefix = getPrefix(cm);
|
130 |
-
f(cm);
|
131 |
-
for (var i = 1; i < prefix; ++i) f(cm);
|
132 |
-
};
|
133 |
-
}
|
134 |
-
|
135 |
-
function findEnd(cm, pos, by, dir) {
|
136 |
-
var prefix = getPrefix(cm);
|
137 |
-
if (prefix < 0) { dir = -dir; prefix = -prefix; }
|
138 |
-
for (var i = 0; i < prefix; ++i) {
|
139 |
-
var newPos = by(cm, pos, dir);
|
140 |
-
if (posEq(newPos, pos)) break;
|
141 |
-
pos = newPos;
|
142 |
-
}
|
143 |
-
return pos;
|
144 |
-
}
|
145 |
-
|
146 |
-
function move(by, dir) {
|
147 |
-
var f = function(cm) {
|
148 |
-
cm.extendSelection(findEnd(cm, cm.getCursor(), by, dir));
|
149 |
-
};
|
150 |
-
f.motion = true;
|
151 |
-
return f;
|
152 |
-
}
|
153 |
-
|
154 |
-
function killTo(cm, by, dir) {
|
155 |
-
var selections = cm.listSelections(), cursor;
|
156 |
-
var i = selections.length;
|
157 |
-
while (i--) {
|
158 |
-
cursor = selections[i].head;
|
159 |
-
kill(cm, cursor, findEnd(cm, cursor, by, dir), true);
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
function killRegion(cm) {
|
164 |
-
if (cm.somethingSelected()) {
|
165 |
-
var selections = cm.listSelections(), selection;
|
166 |
-
var i = selections.length;
|
167 |
-
while (i--) {
|
168 |
-
selection = selections[i];
|
169 |
-
kill(cm, selection.anchor, selection.head);
|
170 |
-
}
|
171 |
-
return true;
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
function addPrefix(cm, digit) {
|
176 |
-
if (cm.state.emacsPrefix) {
|
177 |
-
if (digit != "-") cm.state.emacsPrefix += digit;
|
178 |
-
return;
|
179 |
-
}
|
180 |
-
// Not active yet
|
181 |
-
cm.state.emacsPrefix = digit;
|
182 |
-
cm.on("keyHandled", maybeClearPrefix);
|
183 |
-
cm.on("inputRead", maybeDuplicateInput);
|
184 |
-
}
|
185 |
-
|
186 |
-
var prefixPreservingKeys = {"Alt-G": true, "Ctrl-X": true, "Ctrl-Q": true, "Ctrl-U": true};
|
187 |
-
|
188 |
-
function maybeClearPrefix(cm, arg) {
|
189 |
-
if (!cm.state.emacsPrefixMap && !prefixPreservingKeys.hasOwnProperty(arg))
|
190 |
-
clearPrefix(cm);
|
191 |
-
}
|
192 |
-
|
193 |
-
function clearPrefix(cm) {
|
194 |
-
cm.state.emacsPrefix = null;
|
195 |
-
cm.off("keyHandled", maybeClearPrefix);
|
196 |
-
cm.off("inputRead", maybeDuplicateInput);
|
197 |
-
}
|
198 |
-
|
199 |
-
function maybeDuplicateInput(cm, event) {
|
200 |
-
var dup = getPrefix(cm);
|
201 |
-
if (dup > 1 && event.origin == "+input") {
|
202 |
-
var one = event.text.join("\n"), txt = "";
|
203 |
-
for (var i = 1; i < dup; ++i) txt += one;
|
204 |
-
cm.replaceSelection(txt);
|
205 |
-
}
|
206 |
-
}
|
207 |
-
|
208 |
-
function addPrefixMap(cm) {
|
209 |
-
cm.state.emacsPrefixMap = true;
|
210 |
-
cm.addKeyMap(prefixMap);
|
211 |
-
cm.on("keyHandled", maybeRemovePrefixMap);
|
212 |
-
cm.on("inputRead", maybeRemovePrefixMap);
|
213 |
-
}
|
214 |
-
|
215 |
-
function maybeRemovePrefixMap(cm, arg) {
|
216 |
-
if (typeof arg == "string" && (/^\d$/.test(arg) || arg == "Ctrl-U")) return;
|
217 |
-
cm.removeKeyMap(prefixMap);
|
218 |
-
cm.state.emacsPrefixMap = false;
|
219 |
-
cm.off("keyHandled", maybeRemovePrefixMap);
|
220 |
-
cm.off("inputRead", maybeRemovePrefixMap);
|
221 |
-
}
|
222 |
-
|
223 |
-
// Utilities
|
224 |
-
|
225 |
-
function setMark(cm) {
|
226 |
-
cm.setCursor(cm.getCursor());
|
227 |
-
cm.setExtending(!cm.getExtending());
|
228 |
-
cm.on("change", function() { cm.setExtending(false); });
|
229 |
-
}
|
230 |
-
|
231 |
-
function clearMark(cm) {
|
232 |
-
cm.setExtending(false);
|
233 |
-
cm.setCursor(cm.getCursor());
|
234 |
-
}
|
235 |
-
|
236 |
-
function getInput(cm, msg, f) {
|
237 |
-
if (cm.openDialog)
|
238 |
-
cm.openDialog(msg + ": <input type=\"text\" style=\"width: 10em\"/>", f, {bottom: true});
|
239 |
-
else
|
240 |
-
f(prompt(msg, ""));
|
241 |
-
}
|
242 |
-
|
243 |
-
function operateOnWord(cm, op) {
|
244 |
-
var start = cm.getCursor(), end = cm.findPosH(start, 1, "word");
|
245 |
-
cm.replaceRange(op(cm.getRange(start, end)), start, end);
|
246 |
-
cm.setCursor(end);
|
247 |
-
}
|
248 |
-
|
249 |
-
function toEnclosingExpr(cm) {
|
250 |
-
var pos = cm.getCursor(), line = pos.line, ch = pos.ch;
|
251 |
-
var stack = [];
|
252 |
-
while (line >= cm.firstLine()) {
|
253 |
-
var text = cm.getLine(line);
|
254 |
-
for (var i = ch == null ? text.length : ch; i > 0;) {
|
255 |
-
var ch = text.charAt(--i);
|
256 |
-
if (ch == ")")
|
257 |
-
stack.push("(");
|
258 |
-
else if (ch == "]")
|
259 |
-
stack.push("[");
|
260 |
-
else if (ch == "}")
|
261 |
-
stack.push("{");
|
262 |
-
else if (/[\(\{\[]/.test(ch) && (!stack.length || stack.pop() != ch))
|
263 |
-
return cm.extendSelection(Pos(line, i));
|
264 |
-
}
|
265 |
-
--line; ch = null;
|
266 |
-
}
|
267 |
-
}
|
268 |
-
|
269 |
-
function quit(cm) {
|
270 |
-
cm.execCommand("clearSearch");
|
271 |
-
clearMark(cm);
|
272 |
-
}
|
273 |
-
|
274 |
-
// Actual keymap
|
275 |
-
|
276 |
-
var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({
|
277 |
-
"Ctrl-W": function(cm) {kill(cm, cm.getCursor("start"), cm.getCursor("end"));},
|
278 |
-
"Ctrl-K": repeated(function(cm) {
|
279 |
-
var start = cm.getCursor(), end = cm.clipPos(Pos(start.line));
|
280 |
-
var text = cm.getRange(start, end);
|
281 |
-
if (!/\S/.test(text)) {
|
282 |
-
text += "\n";
|
283 |
-
end = Pos(start.line + 1, 0);
|
284 |
-
}
|
285 |
-
kill(cm, start, end, true, text);
|
286 |
-
}),
|
287 |
-
"Alt-W": function(cm) {
|
288 |
-
addToRing(cm.getSelection());
|
289 |
-
clearMark(cm);
|
290 |
-
},
|
291 |
-
"Ctrl-Y": function(cm) {
|
292 |
-
var start = cm.getCursor();
|
293 |
-
cm.replaceRange(getFromRing(getPrefix(cm)), start, start, "paste");
|
294 |
-
cm.setSelection(start, cm.getCursor());
|
295 |
-
},
|
296 |
-
"Alt-Y": function(cm) {cm.replaceSelection(popFromRing(), "around", "paste");},
|
297 |
-
|
298 |
-
"Ctrl-Space": setMark, "Ctrl-Shift-2": setMark,
|
299 |
-
|
300 |
-
"Ctrl-F": move(byChar, 1), "Ctrl-B": move(byChar, -1),
|
301 |
-
"Right": move(byChar, 1), "Left": move(byChar, -1),
|
302 |
-
"Ctrl-D": function(cm) { killTo(cm, byChar, 1); },
|
303 |
-
"Delete": function(cm) { killRegion(cm) || killTo(cm, byChar, 1); },
|
304 |
-
"Ctrl-H": function(cm) { killTo(cm, byChar, -1); },
|
305 |
-
"Backspace": function(cm) { killRegion(cm) || killTo(cm, byChar, -1); },
|
306 |
-
|
307 |
-
"Alt-F": move(byWord, 1), "Alt-B": move(byWord, -1),
|
308 |
-
"Alt-D": function(cm) { killTo(cm, byWord, 1); },
|
309 |
-
"Alt-Backspace": function(cm) { killTo(cm, byWord, -1); },
|
310 |
-
|
311 |
-
"Ctrl-N": move(byLine, 1), "Ctrl-P": move(byLine, -1),
|
312 |
-
"Down": move(byLine, 1), "Up": move(byLine, -1),
|
313 |
-
"Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
|
314 |
-
"End": "goLineEnd", "Home": "goLineStart",
|
315 |
-
|
316 |
-
"Alt-V": move(byPage, -1), "Ctrl-V": move(byPage, 1),
|
317 |
-
"PageUp": move(byPage, -1), "PageDown": move(byPage, 1),
|
318 |
-
|
319 |
-
"Ctrl-Up": move(byParagraph, -1), "Ctrl-Down": move(byParagraph, 1),
|
320 |
-
|
321 |
-
"Alt-A": move(bySentence, -1), "Alt-E": move(bySentence, 1),
|
322 |
-
"Alt-K": function(cm) { killTo(cm, bySentence, 1); },
|
323 |
-
|
324 |
-
"Ctrl-Alt-K": function(cm) { killTo(cm, byExpr, 1); },
|
325 |
-
"Ctrl-Alt-Backspace": function(cm) { killTo(cm, byExpr, -1); },
|
326 |
-
"Ctrl-Alt-F": move(byExpr, 1), "Ctrl-Alt-B": move(byExpr, -1),
|
327 |
-
|
328 |
-
"Shift-Ctrl-Alt-2": function(cm) {
|
329 |
-
var cursor = cm.getCursor();
|
330 |
-
cm.setSelection(findEnd(cm, cursor, byExpr, 1), cursor);
|
331 |
-
},
|
332 |
-
"Ctrl-Alt-T": function(cm) {
|
333 |
-
var leftStart = byExpr(cm, cm.getCursor(), -1), leftEnd = byExpr(cm, leftStart, 1);
|
334 |
-
var rightEnd = byExpr(cm, leftEnd, 1), rightStart = byExpr(cm, rightEnd, -1);
|
335 |
-
cm.replaceRange(cm.getRange(rightStart, rightEnd) + cm.getRange(leftEnd, rightStart) +
|
336 |
-
cm.getRange(leftStart, leftEnd), leftStart, rightEnd);
|
337 |
-
},
|
338 |
-
"Ctrl-Alt-U": repeated(toEnclosingExpr),
|
339 |
-
|
340 |
-
"Alt-Space": function(cm) {
|
341 |
-
var pos = cm.getCursor(), from = pos.ch, to = pos.ch, text = cm.getLine(pos.line);
|
342 |
-
while (from && /\s/.test(text.charAt(from - 1))) --from;
|
343 |
-
while (to < text.length && /\s/.test(text.charAt(to))) ++to;
|
344 |
-
cm.replaceRange(" ", Pos(pos.line, from), Pos(pos.line, to));
|
345 |
-
},
|
346 |
-
"Ctrl-O": repeated(function(cm) { cm.replaceSelection("\n", "start"); }),
|
347 |
-
"Ctrl-T": repeated(function(cm) {
|
348 |
-
cm.execCommand("transposeChars");
|
349 |
-
}),
|
350 |
-
|
351 |
-
"Alt-C": repeated(function(cm) {
|
352 |
-
operateOnWord(cm, function(w) {
|
353 |
-
var letter = w.search(/\w/);
|
354 |
-
if (letter == -1) return w;
|
355 |
-
return w.slice(0, letter) + w.charAt(letter).toUpperCase() + w.slice(letter + 1).toLowerCase();
|
356 |
-
});
|
357 |
-
}),
|
358 |
-
"Alt-U": repeated(function(cm) {
|
359 |
-
operateOnWord(cm, function(w) { return w.toUpperCase(); });
|
360 |
-
}),
|
361 |
-
"Alt-L": repeated(function(cm) {
|
362 |
-
operateOnWord(cm, function(w) { return w.toLowerCase(); });
|
363 |
-
}),
|
364 |
-
|
365 |
-
"Alt-;": "toggleComment",
|
366 |
-
|
367 |
-
"Ctrl-/": repeated("undo"), "Shift-Ctrl--": repeated("undo"),
|
368 |
-
"Ctrl-Z": repeated("undo"), "Cmd-Z": repeated("undo"),
|
369 |
-
"Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",
|
370 |
-
"Ctrl-S": "findNext", "Ctrl-R": "findPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",
|
371 |
-
"Alt-/": "autocomplete",
|
372 |
-
"Ctrl-J": "newlineAndIndent", "Enter": false, "Tab": "indentAuto",
|
373 |
-
|
374 |
-
"Alt-G G": function(cm) {
|
375 |
-
var prefix = getPrefix(cm, true);
|
376 |
-
if (prefix != null && prefix > 0) return cm.setCursor(prefix - 1);
|
377 |
-
|
378 |
-
getInput(cm, "Goto line", function(str) {
|
379 |
-
var num;
|
380 |
-
if (str && !isNaN(num = Number(str)) && num == (num|0) && num > 0)
|
381 |
-
cm.setCursor(num - 1);
|
382 |
-
});
|
383 |
-
},
|
384 |
-
|
385 |
-
"Ctrl-X Tab": function(cm) {
|
386 |
-
cm.indentSelection(getPrefix(cm, true) || cm.getOption("indentUnit"));
|
387 |
-
},
|
388 |
-
"Ctrl-X Ctrl-X": function(cm) {
|
389 |
-
cm.setSelection(cm.getCursor("head"), cm.getCursor("anchor"));
|
390 |
-
},
|
391 |
-
"Ctrl-X Ctrl-S": "save",
|
392 |
-
"Ctrl-X Ctrl-W": "save",
|
393 |
-
"Ctrl-X S": "saveAll",
|
394 |
-
"Ctrl-X F": "open",
|
395 |
-
"Ctrl-X U": repeated("undo"),
|
396 |
-
"Ctrl-X K": "close",
|
397 |
-
"Ctrl-X Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), true); },
|
398 |
-
"Ctrl-X H": "selectAll",
|
399 |
-
|
400 |
-
"Ctrl-Q Tab": repeated("insertTab"),
|
401 |
-
"Ctrl-U": addPrefixMap
|
402 |
-
});
|
403 |
-
|
404 |
-
var prefixMap = {"Ctrl-G": clearPrefix};
|
405 |
-
function regPrefix(d) {
|
406 |
-
prefixMap[d] = function(cm) { addPrefix(cm, d); };
|
407 |
-
keyMap["Ctrl-" + d] = function(cm) { addPrefix(cm, d); };
|
408 |
-
prefixPreservingKeys["Ctrl-" + d] = true;
|
409 |
-
}
|
410 |
-
for (var i = 0; i < 10; ++i) regPrefix(String(i));
|
411 |
-
regPrefix("-");
|
412 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/keymap/sublime.js
DELETED
@@ -1,565 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// A rough approximation of Sublime Text's keybindings
|
5 |
-
// Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js
|
6 |
-
|
7 |
-
(function(mod) {
|
8 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
9 |
-
mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/edit/matchbrackets"));
|
10 |
-
else if (typeof define == "function" && define.amd) // AMD
|
11 |
-
define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/edit/matchbrackets"], mod);
|
12 |
-
else // Plain browser env
|
13 |
-
mod(CodeMirror);
|
14 |
-
})(function(CodeMirror) {
|
15 |
-
"use strict";
|
16 |
-
|
17 |
-
var map = CodeMirror.keyMap.sublime = {fallthrough: "default"};
|
18 |
-
var cmds = CodeMirror.commands;
|
19 |
-
var Pos = CodeMirror.Pos;
|
20 |
-
var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
|
21 |
-
var ctrl = mac ? "Cmd-" : "Ctrl-";
|
22 |
-
|
23 |
-
// This is not exactly Sublime's algorithm. I couldn't make heads or tails of that.
|
24 |
-
function findPosSubword(doc, start, dir) {
|
25 |
-
if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1));
|
26 |
-
var line = doc.getLine(start.line);
|
27 |
-
if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0));
|
28 |
-
var state = "start", type;
|
29 |
-
for (var pos = start.ch, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) {
|
30 |
-
var next = line.charAt(dir < 0 ? pos - 1 : pos);
|
31 |
-
var cat = next != "_" && CodeMirror.isWordChar(next) ? "w" : "o";
|
32 |
-
if (cat == "w" && next.toUpperCase() == next) cat = "W";
|
33 |
-
if (state == "start") {
|
34 |
-
if (cat != "o") { state = "in"; type = cat; }
|
35 |
-
} else if (state == "in") {
|
36 |
-
if (type != cat) {
|
37 |
-
if (type == "w" && cat == "W" && dir < 0) pos--;
|
38 |
-
if (type == "W" && cat == "w" && dir > 0) { type = "w"; continue; }
|
39 |
-
break;
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
43 |
-
return Pos(start.line, pos);
|
44 |
-
}
|
45 |
-
|
46 |
-
function moveSubword(cm, dir) {
|
47 |
-
cm.extendSelectionsBy(function(range) {
|
48 |
-
if (cm.display.shift || cm.doc.extend || range.empty())
|
49 |
-
return findPosSubword(cm.doc, range.head, dir);
|
50 |
-
else
|
51 |
-
return dir < 0 ? range.from() : range.to();
|
52 |
-
});
|
53 |
-
}
|
54 |
-
|
55 |
-
cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
|
56 |
-
cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
|
57 |
-
|
58 |
-
var scrollLineCombo = mac ? "Ctrl-Alt-" : "Ctrl-";
|
59 |
-
|
60 |
-
cmds[map[scrollLineCombo + "Up"] = "scrollLineUp"] = function(cm) {
|
61 |
-
var info = cm.getScrollInfo();
|
62 |
-
if (!cm.somethingSelected()) {
|
63 |
-
var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local");
|
64 |
-
if (cm.getCursor().line >= visibleBottomLine)
|
65 |
-
cm.execCommand("goLineUp");
|
66 |
-
}
|
67 |
-
cm.scrollTo(null, info.top - cm.defaultTextHeight());
|
68 |
-
};
|
69 |
-
cmds[map[scrollLineCombo + "Down"] = "scrollLineDown"] = function(cm) {
|
70 |
-
var info = cm.getScrollInfo();
|
71 |
-
if (!cm.somethingSelected()) {
|
72 |
-
var visibleTopLine = cm.lineAtHeight(info.top, "local")+1;
|
73 |
-
if (cm.getCursor().line <= visibleTopLine)
|
74 |
-
cm.execCommand("goLineDown");
|
75 |
-
}
|
76 |
-
cm.scrollTo(null, info.top + cm.defaultTextHeight());
|
77 |
-
};
|
78 |
-
|
79 |
-
cmds[map["Shift-" + ctrl + "L"] = "splitSelectionByLine"] = function(cm) {
|
80 |
-
var ranges = cm.listSelections(), lineRanges = [];
|
81 |
-
for (var i = 0; i < ranges.length; i++) {
|
82 |
-
var from = ranges[i].from(), to = ranges[i].to();
|
83 |
-
for (var line = from.line; line <= to.line; ++line)
|
84 |
-
if (!(to.line > from.line && line == to.line && to.ch == 0))
|
85 |
-
lineRanges.push({anchor: line == from.line ? from : Pos(line, 0),
|
86 |
-
head: line == to.line ? to : Pos(line)});
|
87 |
-
}
|
88 |
-
cm.setSelections(lineRanges, 0);
|
89 |
-
};
|
90 |
-
|
91 |
-
map["Shift-Tab"] = "indentLess";
|
92 |
-
|
93 |
-
cmds[map["Esc"] = "singleSelectionTop"] = function(cm) {
|
94 |
-
var range = cm.listSelections()[0];
|
95 |
-
cm.setSelection(range.anchor, range.head, {scroll: false});
|
96 |
-
};
|
97 |
-
|
98 |
-
cmds[map[ctrl + "L"] = "selectLine"] = function(cm) {
|
99 |
-
var ranges = cm.listSelections(), extended = [];
|
100 |
-
for (var i = 0; i < ranges.length; i++) {
|
101 |
-
var range = ranges[i];
|
102 |
-
extended.push({anchor: Pos(range.from().line, 0),
|
103 |
-
head: Pos(range.to().line + 1, 0)});
|
104 |
-
}
|
105 |
-
cm.setSelections(extended);
|
106 |
-
};
|
107 |
-
|
108 |
-
map["Shift-" + ctrl + "K"] = "deleteLine";
|
109 |
-
|
110 |
-
function insertLine(cm, above) {
|
111 |
-
cm.operation(function() {
|
112 |
-
var len = cm.listSelections().length, newSelection = [], last = -1;
|
113 |
-
for (var i = 0; i < len; i++) {
|
114 |
-
var head = cm.listSelections()[i].head;
|
115 |
-
if (head.line <= last) continue;
|
116 |
-
var at = Pos(head.line + (above ? 0 : 1), 0);
|
117 |
-
cm.replaceRange("\n", at, null, "+insertLine");
|
118 |
-
cm.indentLine(at.line, null, true);
|
119 |
-
newSelection.push({head: at, anchor: at});
|
120 |
-
last = head.line + 1;
|
121 |
-
}
|
122 |
-
cm.setSelections(newSelection);
|
123 |
-
});
|
124 |
-
}
|
125 |
-
|
126 |
-
cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { insertLine(cm, false); };
|
127 |
-
|
128 |
-
cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { insertLine(cm, true); };
|
129 |
-
|
130 |
-
function wordAt(cm, pos) {
|
131 |
-
var start = pos.ch, end = start, line = cm.getLine(pos.line);
|
132 |
-
while (start && CodeMirror.isWordChar(line.charAt(start - 1))) --start;
|
133 |
-
while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) ++end;
|
134 |
-
return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)};
|
135 |
-
}
|
136 |
-
|
137 |
-
cmds[map[ctrl + "D"] = "selectNextOccurrence"] = function(cm) {
|
138 |
-
var from = cm.getCursor("from"), to = cm.getCursor("to");
|
139 |
-
var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel;
|
140 |
-
if (CodeMirror.cmpPos(from, to) == 0) {
|
141 |
-
var word = wordAt(cm, from);
|
142 |
-
if (!word.word) return;
|
143 |
-
cm.setSelection(word.from, word.to);
|
144 |
-
fullWord = true;
|
145 |
-
} else {
|
146 |
-
var text = cm.getRange(from, to);
|
147 |
-
var query = fullWord ? new RegExp("\\b" + text + "\\b") : text;
|
148 |
-
var cur = cm.getSearchCursor(query, to);
|
149 |
-
if (cur.findNext()) {
|
150 |
-
cm.addSelection(cur.from(), cur.to());
|
151 |
-
} else {
|
152 |
-
cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0));
|
153 |
-
if (cur.findNext())
|
154 |
-
cm.addSelection(cur.from(), cur.to());
|
155 |
-
}
|
156 |
-
}
|
157 |
-
if (fullWord)
|
158 |
-
cm.state.sublimeFindFullWord = cm.doc.sel;
|
159 |
-
};
|
160 |
-
|
161 |
-
var mirror = "(){}[]";
|
162 |
-
function selectBetweenBrackets(cm) {
|
163 |
-
var pos = cm.getCursor(), opening = cm.scanForBracket(pos, -1);
|
164 |
-
if (!opening) return;
|
165 |
-
for (;;) {
|
166 |
-
var closing = cm.scanForBracket(pos, 1);
|
167 |
-
if (!closing) return;
|
168 |
-
if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) {
|
169 |
-
cm.setSelection(Pos(opening.pos.line, opening.pos.ch + 1), closing.pos, false);
|
170 |
-
return true;
|
171 |
-
}
|
172 |
-
pos = Pos(closing.pos.line, closing.pos.ch + 1);
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
cmds[map["Shift-" + ctrl + "Space"] = "selectScope"] = function(cm) {
|
177 |
-
selectBetweenBrackets(cm) || cm.execCommand("selectAll");
|
178 |
-
};
|
179 |
-
cmds[map["Shift-" + ctrl + "M"] = "selectBetweenBrackets"] = function(cm) {
|
180 |
-
if (!selectBetweenBrackets(cm)) return CodeMirror.Pass;
|
181 |
-
};
|
182 |
-
|
183 |
-
cmds[map[ctrl + "M"] = "goToBracket"] = function(cm) {
|
184 |
-
cm.extendSelectionsBy(function(range) {
|
185 |
-
var next = cm.scanForBracket(range.head, 1);
|
186 |
-
if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos;
|
187 |
-
var prev = cm.scanForBracket(range.head, -1);
|
188 |
-
return prev && Pos(prev.pos.line, prev.pos.ch + 1) || range.head;
|
189 |
-
});
|
190 |
-
};
|
191 |
-
|
192 |
-
var swapLineCombo = mac ? "Cmd-Ctrl-" : "Shift-Ctrl-";
|
193 |
-
|
194 |
-
cmds[map[swapLineCombo + "Up"] = "swapLineUp"] = function(cm) {
|
195 |
-
var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = [];
|
196 |
-
for (var i = 0; i < ranges.length; i++) {
|
197 |
-
var range = ranges[i], from = range.from().line - 1, to = range.to().line;
|
198 |
-
newSels.push({anchor: Pos(range.anchor.line - 1, range.anchor.ch),
|
199 |
-
head: Pos(range.head.line - 1, range.head.ch)});
|
200 |
-
if (range.to().ch == 0 && !range.empty()) --to;
|
201 |
-
if (from > at) linesToMove.push(from, to);
|
202 |
-
else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;
|
203 |
-
at = to;
|
204 |
-
}
|
205 |
-
cm.operation(function() {
|
206 |
-
for (var i = 0; i < linesToMove.length; i += 2) {
|
207 |
-
var from = linesToMove[i], to = linesToMove[i + 1];
|
208 |
-
var line = cm.getLine(from);
|
209 |
-
cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine");
|
210 |
-
if (to > cm.lastLine())
|
211 |
-
cm.replaceRange("\n" + line, Pos(cm.lastLine()), null, "+swapLine");
|
212 |
-
else
|
213 |
-
cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine");
|
214 |
-
}
|
215 |
-
cm.setSelections(newSels);
|
216 |
-
cm.scrollIntoView();
|
217 |
-
});
|
218 |
-
};
|
219 |
-
|
220 |
-
cmds[map[swapLineCombo + "Down"] = "swapLineDown"] = function(cm) {
|
221 |
-
var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;
|
222 |
-
for (var i = ranges.length - 1; i >= 0; i--) {
|
223 |
-
var range = ranges[i], from = range.to().line + 1, to = range.from().line;
|
224 |
-
if (range.to().ch == 0 && !range.empty()) from--;
|
225 |
-
if (from < at) linesToMove.push(from, to);
|
226 |
-
else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;
|
227 |
-
at = to;
|
228 |
-
}
|
229 |
-
cm.operation(function() {
|
230 |
-
for (var i = linesToMove.length - 2; i >= 0; i -= 2) {
|
231 |
-
var from = linesToMove[i], to = linesToMove[i + 1];
|
232 |
-
var line = cm.getLine(from);
|
233 |
-
if (from == cm.lastLine())
|
234 |
-
cm.replaceRange("", Pos(from - 1), Pos(from), "+swapLine");
|
235 |
-
else
|
236 |
-
cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine");
|
237 |
-
cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine");
|
238 |
-
}
|
239 |
-
cm.scrollIntoView();
|
240 |
-
});
|
241 |
-
};
|
242 |
-
|
243 |
-
map[ctrl + "/"] = function(cm) {
|
244 |
-
cm.toggleComment({ indent: true });
|
245 |
-
}
|
246 |
-
|
247 |
-
cmds[map[ctrl + "J"] = "joinLines"] = function(cm) {
|
248 |
-
var ranges = cm.listSelections(), joined = [];
|
249 |
-
for (var i = 0; i < ranges.length; i++) {
|
250 |
-
var range = ranges[i], from = range.from();
|
251 |
-
var start = from.line, end = range.to().line;
|
252 |
-
while (i < ranges.length - 1 && ranges[i + 1].from().line == end)
|
253 |
-
end = ranges[++i].to().line;
|
254 |
-
joined.push({start: start, end: end, anchor: !range.empty() && from});
|
255 |
-
}
|
256 |
-
cm.operation(function() {
|
257 |
-
var offset = 0, ranges = [];
|
258 |
-
for (var i = 0; i < joined.length; i++) {
|
259 |
-
var obj = joined[i];
|
260 |
-
var anchor = obj.anchor && Pos(obj.anchor.line - offset, obj.anchor.ch), head;
|
261 |
-
for (var line = obj.start; line <= obj.end; line++) {
|
262 |
-
var actual = line - offset;
|
263 |
-
if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1);
|
264 |
-
if (actual < cm.lastLine()) {
|
265 |
-
cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length));
|
266 |
-
++offset;
|
267 |
-
}
|
268 |
-
}
|
269 |
-
ranges.push({anchor: anchor || head, head: head});
|
270 |
-
}
|
271 |
-
cm.setSelections(ranges, 0);
|
272 |
-
});
|
273 |
-
};
|
274 |
-
|
275 |
-
cmds[map["Shift-" + ctrl + "D"] = "duplicateLine"] = function(cm) {
|
276 |
-
cm.operation(function() {
|
277 |
-
var rangeCount = cm.listSelections().length;
|
278 |
-
for (var i = 0; i < rangeCount; i++) {
|
279 |
-
var range = cm.listSelections()[i];
|
280 |
-
if (range.empty())
|
281 |
-
cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0));
|
282 |
-
else
|
283 |
-
cm.replaceRange(cm.getRange(range.from(), range.to()), range.from());
|
284 |
-
}
|
285 |
-
cm.scrollIntoView();
|
286 |
-
});
|
287 |
-
};
|
288 |
-
|
289 |
-
map[ctrl + "T"] = "transposeChars";
|
290 |
-
|
291 |
-
function sortLines(cm, caseSensitive) {
|
292 |
-
var ranges = cm.listSelections(), toSort = [], selected;
|
293 |
-
for (var i = 0; i < ranges.length; i++) {
|
294 |
-
var range = ranges[i];
|
295 |
-
if (range.empty()) continue;
|
296 |
-
var from = range.from().line, to = range.to().line;
|
297 |
-
while (i < ranges.length - 1 && ranges[i + 1].from().line == to)
|
298 |
-
to = range[++i].to().line;
|
299 |
-
toSort.push(from, to);
|
300 |
-
}
|
301 |
-
if (toSort.length) selected = true;
|
302 |
-
else toSort.push(cm.firstLine(), cm.lastLine());
|
303 |
-
|
304 |
-
cm.operation(function() {
|
305 |
-
var ranges = [];
|
306 |
-
for (var i = 0; i < toSort.length; i += 2) {
|
307 |
-
var from = toSort[i], to = toSort[i + 1];
|
308 |
-
var start = Pos(from, 0), end = Pos(to);
|
309 |
-
var lines = cm.getRange(start, end, false);
|
310 |
-
if (caseSensitive)
|
311 |
-
lines.sort();
|
312 |
-
else
|
313 |
-
lines.sort(function(a, b) {
|
314 |
-
var au = a.toUpperCase(), bu = b.toUpperCase();
|
315 |
-
if (au != bu) { a = au; b = bu; }
|
316 |
-
return a < b ? -1 : a == b ? 0 : 1;
|
317 |
-
});
|
318 |
-
cm.replaceRange(lines, start, end);
|
319 |
-
if (selected) ranges.push({anchor: start, head: end});
|
320 |
-
}
|
321 |
-
if (selected) cm.setSelections(ranges, 0);
|
322 |
-
});
|
323 |
-
}
|
324 |
-
|
325 |
-
cmds[map["F9"] = "sortLines"] = function(cm) { sortLines(cm, true); };
|
326 |
-
cmds[map[ctrl + "F9"] = "sortLinesInsensitive"] = function(cm) { sortLines(cm, false); };
|
327 |
-
|
328 |
-
cmds[map["F2"] = "nextBookmark"] = function(cm) {
|
329 |
-
var marks = cm.state.sublimeBookmarks;
|
330 |
-
if (marks) while (marks.length) {
|
331 |
-
var current = marks.shift();
|
332 |
-
var found = current.find();
|
333 |
-
if (found) {
|
334 |
-
marks.push(current);
|
335 |
-
return cm.setSelection(found.from, found.to);
|
336 |
-
}
|
337 |
-
}
|
338 |
-
};
|
339 |
-
|
340 |
-
cmds[map["Shift-F2"] = "prevBookmark"] = function(cm) {
|
341 |
-
var marks = cm.state.sublimeBookmarks;
|
342 |
-
if (marks) while (marks.length) {
|
343 |
-
marks.unshift(marks.pop());
|
344 |
-
var found = marks[marks.length - 1].find();
|
345 |
-
if (!found)
|
346 |
-
marks.pop();
|
347 |
-
else
|
348 |
-
return cm.setSelection(found.from, found.to);
|
349 |
-
}
|
350 |
-
};
|
351 |
-
|
352 |
-
cmds[map[ctrl + "F2"] = "toggleBookmark"] = function(cm) {
|
353 |
-
var ranges = cm.listSelections();
|
354 |
-
var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []);
|
355 |
-
for (var i = 0; i < ranges.length; i++) {
|
356 |
-
var from = ranges[i].from(), to = ranges[i].to();
|
357 |
-
var found = cm.findMarks(from, to);
|
358 |
-
for (var j = 0; j < found.length; j++) {
|
359 |
-
if (found[j].sublimeBookmark) {
|
360 |
-
found[j].clear();
|
361 |
-
for (var k = 0; k < marks.length; k++)
|
362 |
-
if (marks[k] == found[j])
|
363 |
-
marks.splice(k--, 1);
|
364 |
-
break;
|
365 |
-
}
|
366 |
-
}
|
367 |
-
if (j == found.length)
|
368 |
-
marks.push(cm.markText(from, to, {sublimeBookmark: true, clearWhenEmpty: false}));
|
369 |
-
}
|
370 |
-
};
|
371 |
-
|
372 |
-
cmds[map["Shift-" + ctrl + "F2"] = "clearBookmarks"] = function(cm) {
|
373 |
-
var marks = cm.state.sublimeBookmarks;
|
374 |
-
if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear();
|
375 |
-
marks.length = 0;
|
376 |
-
};
|
377 |
-
|
378 |
-
cmds[map["Alt-F2"] = "selectBookmarks"] = function(cm) {
|
379 |
-
var marks = cm.state.sublimeBookmarks, ranges = [];
|
380 |
-
if (marks) for (var i = 0; i < marks.length; i++) {
|
381 |
-
var found = marks[i].find();
|
382 |
-
if (!found)
|
383 |
-
marks.splice(i--, 0);
|
384 |
-
else
|
385 |
-
ranges.push({anchor: found.from, head: found.to});
|
386 |
-
}
|
387 |
-
if (ranges.length)
|
388 |
-
cm.setSelections(ranges, 0);
|
389 |
-
};
|
390 |
-
|
391 |
-
map["Alt-Q"] = "wrapLines";
|
392 |
-
|
393 |
-
var cK = ctrl + "K ";
|
394 |
-
|
395 |
-
function modifyWordOrSelection(cm, mod) {
|
396 |
-
cm.operation(function() {
|
397 |
-
var ranges = cm.listSelections(), indices = [], replacements = [];
|
398 |
-
for (var i = 0; i < ranges.length; i++) {
|
399 |
-
var range = ranges[i];
|
400 |
-
if (range.empty()) { indices.push(i); replacements.push(""); }
|
401 |
-
else replacements.push(mod(cm.getRange(range.from(), range.to())));
|
402 |
-
}
|
403 |
-
cm.replaceSelections(replacements, "around", "case");
|
404 |
-
for (var i = indices.length - 1, at; i >= 0; i--) {
|
405 |
-
var range = ranges[indices[i]];
|
406 |
-
if (at && CodeMirror.cmpPos(range.head, at) > 0) continue;
|
407 |
-
var word = wordAt(cm, range.head);
|
408 |
-
at = word.from;
|
409 |
-
cm.replaceRange(mod(word.word), word.from, word.to);
|
410 |
-
}
|
411 |
-
});
|
412 |
-
}
|
413 |
-
|
414 |
-
map[cK + ctrl + "Backspace"] = "delLineLeft";
|
415 |
-
|
416 |
-
cmds[map["Backspace"] = "smartBackspace"] = function(cm) {
|
417 |
-
if (cm.somethingSelected()) return CodeMirror.Pass;
|
418 |
-
|
419 |
-
var cursor = cm.getCursor();
|
420 |
-
var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
|
421 |
-
var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
|
422 |
-
var indentUnit = cm.getOption("indentUnit");
|
423 |
-
|
424 |
-
if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) {
|
425 |
-
var prevIndent = new Pos(cursor.line,
|
426 |
-
CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit));
|
427 |
-
|
428 |
-
// If no smart delete is happening (due to tab sizing) just do a regular delete
|
429 |
-
if (prevIndent.ch == cursor.ch) return CodeMirror.Pass;
|
430 |
-
|
431 |
-
return cm.replaceRange("", prevIndent, cursor, "+delete");
|
432 |
-
} else {
|
433 |
-
return CodeMirror.Pass;
|
434 |
-
}
|
435 |
-
};
|
436 |
-
|
437 |
-
cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) {
|
438 |
-
cm.operation(function() {
|
439 |
-
var ranges = cm.listSelections();
|
440 |
-
for (var i = ranges.length - 1; i >= 0; i--)
|
441 |
-
cm.replaceRange("", ranges[i].anchor, Pos(ranges[i].to().line), "+delete");
|
442 |
-
cm.scrollIntoView();
|
443 |
-
});
|
444 |
-
};
|
445 |
-
|
446 |
-
cmds[map[cK + ctrl + "U"] = "upcaseAtCursor"] = function(cm) {
|
447 |
-
modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); });
|
448 |
-
};
|
449 |
-
cmds[map[cK + ctrl + "L"] = "downcaseAtCursor"] = function(cm) {
|
450 |
-
modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); });
|
451 |
-
};
|
452 |
-
|
453 |
-
cmds[map[cK + ctrl + "Space"] = "setSublimeMark"] = function(cm) {
|
454 |
-
if (cm.state.sublimeMark) cm.state.sublimeMark.clear();
|
455 |
-
cm.state.sublimeMark = cm.setBookmark(cm.getCursor());
|
456 |
-
};
|
457 |
-
cmds[map[cK + ctrl + "A"] = "selectToSublimeMark"] = function(cm) {
|
458 |
-
var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
|
459 |
-
if (found) cm.setSelection(cm.getCursor(), found);
|
460 |
-
};
|
461 |
-
cmds[map[cK + ctrl + "W"] = "deleteToSublimeMark"] = function(cm) {
|
462 |
-
var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
|
463 |
-
if (found) {
|
464 |
-
var from = cm.getCursor(), to = found;
|
465 |
-
if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; }
|
466 |
-
cm.state.sublimeKilled = cm.getRange(from, to);
|
467 |
-
cm.replaceRange("", from, to);
|
468 |
-
}
|
469 |
-
};
|
470 |
-
cmds[map[cK + ctrl + "X"] = "swapWithSublimeMark"] = function(cm) {
|
471 |
-
var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
|
472 |
-
if (found) {
|
473 |
-
cm.state.sublimeMark.clear();
|
474 |
-
cm.state.sublimeMark = cm.setBookmark(cm.getCursor());
|
475 |
-
cm.setCursor(found);
|
476 |
-
}
|
477 |
-
};
|
478 |
-
cmds[map[cK + ctrl + "Y"] = "sublimeYank"] = function(cm) {
|
479 |
-
if (cm.state.sublimeKilled != null)
|
480 |
-
cm.replaceSelection(cm.state.sublimeKilled, null, "paste");
|
481 |
-
};
|
482 |
-
|
483 |
-
map[cK + ctrl + "G"] = "clearBookmarks";
|
484 |
-
cmds[map[cK + ctrl + "C"] = "showInCenter"] = function(cm) {
|
485 |
-
var pos = cm.cursorCoords(null, "local");
|
486 |
-
cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2);
|
487 |
-
};
|
488 |
-
|
489 |
-
cmds[map["Shift-Alt-Up"] = "selectLinesUpward"] = function(cm) {
|
490 |
-
cm.operation(function() {
|
491 |
-
var ranges = cm.listSelections();
|
492 |
-
for (var i = 0; i < ranges.length; i++) {
|
493 |
-
var range = ranges[i];
|
494 |
-
if (range.head.line > cm.firstLine())
|
495 |
-
cm.addSelection(Pos(range.head.line - 1, range.head.ch));
|
496 |
-
}
|
497 |
-
});
|
498 |
-
};
|
499 |
-
cmds[map["Shift-Alt-Down"] = "selectLinesDownward"] = function(cm) {
|
500 |
-
cm.operation(function() {
|
501 |
-
var ranges = cm.listSelections();
|
502 |
-
for (var i = 0; i < ranges.length; i++) {
|
503 |
-
var range = ranges[i];
|
504 |
-
if (range.head.line < cm.lastLine())
|
505 |
-
cm.addSelection(Pos(range.head.line + 1, range.head.ch));
|
506 |
-
}
|
507 |
-
});
|
508 |
-
};
|
509 |
-
|
510 |
-
function getTarget(cm) {
|
511 |
-
var from = cm.getCursor("from"), to = cm.getCursor("to");
|
512 |
-
if (CodeMirror.cmpPos(from, to) == 0) {
|
513 |
-
var word = wordAt(cm, from);
|
514 |
-
if (!word.word) return;
|
515 |
-
from = word.from;
|
516 |
-
to = word.to;
|
517 |
-
}
|
518 |
-
return {from: from, to: to, query: cm.getRange(from, to), word: word};
|
519 |
-
}
|
520 |
-
|
521 |
-
function findAndGoTo(cm, forward) {
|
522 |
-
var target = getTarget(cm);
|
523 |
-
if (!target) return;
|
524 |
-
var query = target.query;
|
525 |
-
var cur = cm.getSearchCursor(query, forward ? target.to : target.from);
|
526 |
-
|
527 |
-
if (forward ? cur.findNext() : cur.findPrevious()) {
|
528 |
-
cm.setSelection(cur.from(), cur.to());
|
529 |
-
} else {
|
530 |
-
cur = cm.getSearchCursor(query, forward ? Pos(cm.firstLine(), 0)
|
531 |
-
: cm.clipPos(Pos(cm.lastLine())));
|
532 |
-
if (forward ? cur.findNext() : cur.findPrevious())
|
533 |
-
cm.setSelection(cur.from(), cur.to());
|
534 |
-
else if (target.word)
|
535 |
-
cm.setSelection(target.from, target.to);
|
536 |
-
}
|
537 |
-
};
|
538 |
-
cmds[map[ctrl + "F3"] = "findUnder"] = function(cm) { findAndGoTo(cm, true); };
|
539 |
-
cmds[map["Shift-" + ctrl + "F3"] = "findUnderPrevious"] = function(cm) { findAndGoTo(cm,false); };
|
540 |
-
cmds[map["Alt-F3"] = "findAllUnder"] = function(cm) {
|
541 |
-
var target = getTarget(cm);
|
542 |
-
if (!target) return;
|
543 |
-
var cur = cm.getSearchCursor(target.query);
|
544 |
-
var matches = [];
|
545 |
-
var primaryIndex = -1;
|
546 |
-
while (cur.findNext()) {
|
547 |
-
matches.push({anchor: cur.from(), head: cur.to()});
|
548 |
-
if (cur.from().line <= target.from.line && cur.from().ch <= target.from.ch)
|
549 |
-
primaryIndex++;
|
550 |
-
}
|
551 |
-
cm.setSelections(matches, primaryIndex);
|
552 |
-
};
|
553 |
-
|
554 |
-
map["Shift-" + ctrl + "["] = "fold";
|
555 |
-
map["Shift-" + ctrl + "]"] = "unfold";
|
556 |
-
map[cK + ctrl + "0"] = map[cK + ctrl + "j"] = "unfoldAll";
|
557 |
-
|
558 |
-
map[ctrl + "I"] = "findIncremental";
|
559 |
-
map["Shift-" + ctrl + "I"] = "findIncrementalReverse";
|
560 |
-
map[ctrl + "H"] = "replace";
|
561 |
-
map["F3"] = "findNext";
|
562 |
-
map["Shift-F3"] = "findPrev";
|
563 |
-
|
564 |
-
CodeMirror.normalizeKeyMap(map);
|
565 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/keymap/vim.js
DELETED
@@ -1,5060 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Supported keybindings:
|
6 |
-
* Too many to list. Refer to defaultKeyMap below.
|
7 |
-
*
|
8 |
-
* Supported Ex commands:
|
9 |
-
* Refer to defaultExCommandMap below.
|
10 |
-
*
|
11 |
-
* Registers: unnamed, -, a-z, A-Z, 0-9
|
12 |
-
* (Does not respect the special case for number registers when delete
|
13 |
-
* operator is made with these commands: %, (, ), , /, ?, n, N, {, } )
|
14 |
-
* TODO: Implement the remaining registers.
|
15 |
-
*
|
16 |
-
* Marks: a-z, A-Z, and 0-9
|
17 |
-
* TODO: Implement the remaining special marks. They have more complex
|
18 |
-
* behavior.
|
19 |
-
*
|
20 |
-
* Events:
|
21 |
-
* 'vim-mode-change' - raised on the editor anytime the current mode changes,
|
22 |
-
* Event object: {mode: "visual", subMode: "linewise"}
|
23 |
-
*
|
24 |
-
* Code structure:
|
25 |
-
* 1. Default keymap
|
26 |
-
* 2. Variable declarations and short basic helpers
|
27 |
-
* 3. Instance (External API) implementation
|
28 |
-
* 4. Internal state tracking objects (input state, counter) implementation
|
29 |
-
* and instanstiation
|
30 |
-
* 5. Key handler (the main command dispatcher) implementation
|
31 |
-
* 6. Motion, operator, and action implementations
|
32 |
-
* 7. Helper functions for the key handler, motions, operators, and actions
|
33 |
-
* 8. Set up Vim to work as a keymap for CodeMirror.
|
34 |
-
* 9. Ex command implementations.
|
35 |
-
*/
|
36 |
-
|
37 |
-
(function(mod) {
|
38 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
39 |
-
mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/dialog/dialog"), require("../addon/edit/matchbrackets.js"));
|
40 |
-
else if (typeof define == "function" && define.amd) // AMD
|
41 |
-
define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/dialog/dialog", "../addon/edit/matchbrackets"], mod);
|
42 |
-
else // Plain browser env
|
43 |
-
mod(CodeMirror);
|
44 |
-
})(function(CodeMirror) {
|
45 |
-
'use strict';
|
46 |
-
|
47 |
-
var defaultKeymap = [
|
48 |
-
// Key to key mapping. This goes first to make it possible to override
|
49 |
-
// existing mappings.
|
50 |
-
{ keys: '<Left>', type: 'keyToKey', toKeys: 'h' },
|
51 |
-
{ keys: '<Right>', type: 'keyToKey', toKeys: 'l' },
|
52 |
-
{ keys: '<Up>', type: 'keyToKey', toKeys: 'k' },
|
53 |
-
{ keys: '<Down>', type: 'keyToKey', toKeys: 'j' },
|
54 |
-
{ keys: '<Space>', type: 'keyToKey', toKeys: 'l' },
|
55 |
-
{ keys: '<BS>', type: 'keyToKey', toKeys: 'h', context: 'normal'},
|
56 |
-
{ keys: '<C-Space>', type: 'keyToKey', toKeys: 'W' },
|
57 |
-
{ keys: '<C-BS>', type: 'keyToKey', toKeys: 'B', context: 'normal' },
|
58 |
-
{ keys: '<S-Space>', type: 'keyToKey', toKeys: 'w' },
|
59 |
-
{ keys: '<S-BS>', type: 'keyToKey', toKeys: 'b', context: 'normal' },
|
60 |
-
{ keys: '<C-n>', type: 'keyToKey', toKeys: 'j' },
|
61 |
-
{ keys: '<C-p>', type: 'keyToKey', toKeys: 'k' },
|
62 |
-
{ keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>' },
|
63 |
-
{ keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>' },
|
64 |
-
{ keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
|
65 |
-
{ keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
|
66 |
-
{ keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' },
|
67 |
-
{ keys: 's', type: 'keyToKey', toKeys: 'xi', context: 'visual'},
|
68 |
-
{ keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' },
|
69 |
-
{ keys: 'S', type: 'keyToKey', toKeys: 'dcc', context: 'visual' },
|
70 |
-
{ keys: '<Home>', type: 'keyToKey', toKeys: '0' },
|
71 |
-
{ keys: '<End>', type: 'keyToKey', toKeys: '$' },
|
72 |
-
{ keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' },
|
73 |
-
{ keys: '<PageDown>', type: 'keyToKey', toKeys: '<C-f>' },
|
74 |
-
{ keys: '<CR>', type: 'keyToKey', toKeys: 'j^', context: 'normal' },
|
75 |
-
// Motions
|
76 |
-
{ keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }},
|
77 |
-
{ keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }},
|
78 |
-
{ keys: 'L', type: 'motion', motion: 'moveToBottomLine', motionArgs: { linewise: true, toJumplist: true }},
|
79 |
-
{ keys: 'h', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: false }},
|
80 |
-
{ keys: 'l', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: true }},
|
81 |
-
{ keys: 'j', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, linewise: true }},
|
82 |
-
{ keys: 'k', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, linewise: true }},
|
83 |
-
{ keys: 'gj', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: true }},
|
84 |
-
{ keys: 'gk', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: false }},
|
85 |
-
{ keys: 'w', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false }},
|
86 |
-
{ keys: 'W', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false, bigWord: true }},
|
87 |
-
{ keys: 'e', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, inclusive: true }},
|
88 |
-
{ keys: 'E', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, bigWord: true, inclusive: true }},
|
89 |
-
{ keys: 'b', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }},
|
90 |
-
{ keys: 'B', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false, bigWord: true }},
|
91 |
-
{ keys: 'ge', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, inclusive: true }},
|
92 |
-
{ keys: 'gE', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, bigWord: true, inclusive: true }},
|
93 |
-
{ keys: '{', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: false, toJumplist: true }},
|
94 |
-
{ keys: '}', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: true, toJumplist: true }},
|
95 |
-
{ keys: '<C-f>', type: 'motion', motion: 'moveByPage', motionArgs: { forward: true }},
|
96 |
-
{ keys: '<C-b>', type: 'motion', motion: 'moveByPage', motionArgs: { forward: false }},
|
97 |
-
{ keys: '<C-d>', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: true, explicitRepeat: true }},
|
98 |
-
{ keys: '<C-u>', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: false, explicitRepeat: true }},
|
99 |
-
{ keys: 'gg', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }},
|
100 |
-
{ keys: 'G', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }},
|
101 |
-
{ keys: '0', type: 'motion', motion: 'moveToStartOfLine' },
|
102 |
-
{ keys: '^', type: 'motion', motion: 'moveToFirstNonWhiteSpaceCharacter' },
|
103 |
-
{ keys: '+', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true }},
|
104 |
-
{ keys: '-', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, toFirstChar:true }},
|
105 |
-
{ keys: '_', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true, repeatOffset:-1 }},
|
106 |
-
{ keys: '$', type: 'motion', motion: 'moveToEol', motionArgs: { inclusive: true }},
|
107 |
-
{ keys: '%', type: 'motion', motion: 'moveToMatchedSymbol', motionArgs: { inclusive: true, toJumplist: true }},
|
108 |
-
{ keys: 'f<character>', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: true , inclusive: true }},
|
109 |
-
{ keys: 'F<character>', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: false }},
|
110 |
-
{ keys: 't<character>', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: true, inclusive: true }},
|
111 |
-
{ keys: 'T<character>', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: false }},
|
112 |
-
{ keys: ';', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: true }},
|
113 |
-
{ keys: ',', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: false }},
|
114 |
-
{ keys: '\'<character>', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true, linewise: true}},
|
115 |
-
{ keys: '`<character>', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true}},
|
116 |
-
{ keys: ']`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } },
|
117 |
-
{ keys: '[`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } },
|
118 |
-
{ keys: ']\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } },
|
119 |
-
{ keys: '[\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false, linewise: true } },
|
120 |
-
// the next two aren't motions but must come before more general motion declarations
|
121 |
-
{ keys: ']p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true, matchIndent: true}},
|
122 |
-
{ keys: '[p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true, matchIndent: true}},
|
123 |
-
{ keys: ']<character>', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: true, toJumplist: true}},
|
124 |
-
{ keys: '[<character>', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: false, toJumplist: true}},
|
125 |
-
{ keys: '|', type: 'motion', motion: 'moveToColumn'},
|
126 |
-
{ keys: 'o', type: 'motion', motion: 'moveToOtherHighlightedEnd', context:'visual'},
|
127 |
-
{ keys: 'O', type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: {sameLine: true}, context:'visual'},
|
128 |
-
// Operators
|
129 |
-
{ keys: 'd', type: 'operator', operator: 'delete' },
|
130 |
-
{ keys: 'y', type: 'operator', operator: 'yank' },
|
131 |
-
{ keys: 'c', type: 'operator', operator: 'change' },
|
132 |
-
{ keys: '>', type: 'operator', operator: 'indent', operatorArgs: { indentRight: true }},
|
133 |
-
{ keys: '<', type: 'operator', operator: 'indent', operatorArgs: { indentRight: false }},
|
134 |
-
{ keys: 'g~', type: 'operator', operator: 'changeCase' },
|
135 |
-
{ keys: 'gu', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: true}, isEdit: true },
|
136 |
-
{ keys: 'gU', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: false}, isEdit: true },
|
137 |
-
{ keys: 'n', type: 'motion', motion: 'findNext', motionArgs: { forward: true, toJumplist: true }},
|
138 |
-
{ keys: 'N', type: 'motion', motion: 'findNext', motionArgs: { forward: false, toJumplist: true }},
|
139 |
-
// Operator-Motion dual commands
|
140 |
-
{ keys: 'x', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorMotionArgs: { visualLine: false }},
|
141 |
-
{ keys: 'X', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: false }, operatorMotionArgs: { visualLine: true }},
|
142 |
-
{ keys: 'D', type: 'operatorMotion', operator: 'delete', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'},
|
143 |
-
{ keys: 'D', type: 'operator', operator: 'delete', operatorArgs: { linewise: true }, context: 'visual'},
|
144 |
-
{ keys: 'Y', type: 'operatorMotion', operator: 'yank', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'},
|
145 |
-
{ keys: 'Y', type: 'operator', operator: 'yank', operatorArgs: { linewise: true }, context: 'visual'},
|
146 |
-
{ keys: 'C', type: 'operatorMotion', operator: 'change', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'},
|
147 |
-
{ keys: 'C', type: 'operator', operator: 'change', operatorArgs: { linewise: true }, context: 'visual'},
|
148 |
-
{ keys: '~', type: 'operatorMotion', operator: 'changeCase', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorArgs: { shouldMoveCursor: true }, context: 'normal'},
|
149 |
-
{ keys: '~', type: 'operator', operator: 'changeCase', context: 'visual'},
|
150 |
-
{ keys: '<C-w>', type: 'operatorMotion', operator: 'delete', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }, context: 'insert' },
|
151 |
-
// Actions
|
152 |
-
{ keys: '<C-i>', type: 'action', action: 'jumpListWalk', actionArgs: { forward: true }},
|
153 |
-
{ keys: '<C-o>', type: 'action', action: 'jumpListWalk', actionArgs: { forward: false }},
|
154 |
-
{ keys: '<C-e>', type: 'action', action: 'scroll', actionArgs: { forward: true, linewise: true }},
|
155 |
-
{ keys: '<C-y>', type: 'action', action: 'scroll', actionArgs: { forward: false, linewise: true }},
|
156 |
-
{ keys: 'a', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'charAfter' }, context: 'normal' },
|
157 |
-
{ keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'eol' }, context: 'normal' },
|
158 |
-
{ keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'endOfSelectedArea' }, context: 'visual' },
|
159 |
-
{ keys: 'i', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'inplace' }, context: 'normal' },
|
160 |
-
{ keys: 'I', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'firstNonBlank'}, context: 'normal' },
|
161 |
-
{ keys: 'I', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'startOfSelectedArea' }, context: 'visual' },
|
162 |
-
{ keys: 'o', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: true }, context: 'normal' },
|
163 |
-
{ keys: 'O', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: false }, context: 'normal' },
|
164 |
-
{ keys: 'v', type: 'action', action: 'toggleVisualMode' },
|
165 |
-
{ keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }},
|
166 |
-
{ keys: '<C-v>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
|
167 |
-
{ keys: 'gv', type: 'action', action: 'reselectLastSelection' },
|
168 |
-
{ keys: 'J', type: 'action', action: 'joinLines', isEdit: true },
|
169 |
-
{ keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }},
|
170 |
-
{ keys: 'P', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true }},
|
171 |
-
{ keys: 'r<character>', type: 'action', action: 'replace', isEdit: true },
|
172 |
-
{ keys: '@<character>', type: 'action', action: 'replayMacro' },
|
173 |
-
{ keys: 'q<character>', type: 'action', action: 'enterMacroRecordMode' },
|
174 |
-
// Handle Replace-mode as a special case of insert mode.
|
175 |
-
{ keys: 'R', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { replace: true }},
|
176 |
-
{ keys: 'u', type: 'action', action: 'undo', context: 'normal' },
|
177 |
-
{ keys: 'u', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: true}, context: 'visual', isEdit: true },
|
178 |
-
{ keys: 'U', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: false}, context: 'visual', isEdit: true },
|
179 |
-
{ keys: '<C-r>', type: 'action', action: 'redo' },
|
180 |
-
{ keys: 'm<character>', type: 'action', action: 'setMark' },
|
181 |
-
{ keys: '"<character>', type: 'action', action: 'setRegister' },
|
182 |
-
{ keys: 'zz', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }},
|
183 |
-
{ keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' },
|
184 |
-
{ keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }},
|
185 |
-
{ keys: 'z<CR>', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }, motion: 'moveToFirstNonWhiteSpaceCharacter' },
|
186 |
-
{ keys: 'z-', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }},
|
187 |
-
{ keys: 'zb', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }, motion: 'moveToFirstNonWhiteSpaceCharacter' },
|
188 |
-
{ keys: '.', type: 'action', action: 'repeatLastEdit' },
|
189 |
-
{ keys: '<C-a>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}},
|
190 |
-
{ keys: '<C-x>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}},
|
191 |
-
// Text object motions
|
192 |
-
{ keys: 'a<character>', type: 'motion', motion: 'textObjectManipulation' },
|
193 |
-
{ keys: 'i<character>', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }},
|
194 |
-
// Search
|
195 |
-
{ keys: '/', type: 'search', searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true }},
|
196 |
-
{ keys: '?', type: 'search', searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }},
|
197 |
-
{ keys: '*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }},
|
198 |
-
{ keys: '#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }},
|
199 |
-
{ keys: 'g*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }},
|
200 |
-
{ keys: 'g#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }},
|
201 |
-
// Ex command
|
202 |
-
{ keys: ':', type: 'ex' }
|
203 |
-
];
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Ex commands
|
207 |
-
* Care must be taken when adding to the default Ex command map. For any
|
208 |
-
* pair of commands that have a shared prefix, at least one of their
|
209 |
-
* shortNames must not match the prefix of the other command.
|
210 |
-
*/
|
211 |
-
var defaultExCommandMap = [
|
212 |
-
{ name: 'colorscheme', shortName: 'colo' },
|
213 |
-
{ name: 'map' },
|
214 |
-
{ name: 'imap', shortName: 'im' },
|
215 |
-
{ name: 'nmap', shortName: 'nm' },
|
216 |
-
{ name: 'vmap', shortName: 'vm' },
|
217 |
-
{ name: 'unmap' },
|
218 |
-
{ name: 'write', shortName: 'w' },
|
219 |
-
{ name: 'undo', shortName: 'u' },
|
220 |
-
{ name: 'redo', shortName: 'red' },
|
221 |
-
{ name: 'set', shortName: 'se' },
|
222 |
-
{ name: 'set', shortName: 'se' },
|
223 |
-
{ name: 'setlocal', shortName: 'setl' },
|
224 |
-
{ name: 'setglobal', shortName: 'setg' },
|
225 |
-
{ name: 'sort', shortName: 'sor' },
|
226 |
-
{ name: 'substitute', shortName: 's', possiblyAsync: true },
|
227 |
-
{ name: 'nohlsearch', shortName: 'noh' },
|
228 |
-
{ name: 'delmarks', shortName: 'delm' },
|
229 |
-
{ name: 'registers', shortName: 'reg', excludeFromCommandHistory: true },
|
230 |
-
{ name: 'global', shortName: 'g' }
|
231 |
-
];
|
232 |
-
|
233 |
-
var Pos = CodeMirror.Pos;
|
234 |
-
|
235 |
-
var Vim = function() {
|
236 |
-
function enterVimMode(cm) {
|
237 |
-
cm.setOption('disableInput', true);
|
238 |
-
cm.setOption('showCursorWhenSelecting', false);
|
239 |
-
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
|
240 |
-
cm.on('cursorActivity', onCursorActivity);
|
241 |
-
maybeInitVimState(cm);
|
242 |
-
CodeMirror.on(cm.getInputField(), 'paste', getOnPasteFn(cm));
|
243 |
-
}
|
244 |
-
|
245 |
-
function leaveVimMode(cm) {
|
246 |
-
cm.setOption('disableInput', false);
|
247 |
-
cm.off('cursorActivity', onCursorActivity);
|
248 |
-
CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm));
|
249 |
-
cm.state.vim = null;
|
250 |
-
}
|
251 |
-
|
252 |
-
function detachVimMap(cm, next) {
|
253 |
-
if (this == CodeMirror.keyMap.vim)
|
254 |
-
CodeMirror.rmClass(cm.getWrapperElement(), "cm-fat-cursor");
|
255 |
-
|
256 |
-
if (!next || next.attach != attachVimMap)
|
257 |
-
leaveVimMode(cm, false);
|
258 |
-
}
|
259 |
-
function attachVimMap(cm, prev) {
|
260 |
-
if (this == CodeMirror.keyMap.vim)
|
261 |
-
CodeMirror.addClass(cm.getWrapperElement(), "cm-fat-cursor");
|
262 |
-
|
263 |
-
if (!prev || prev.attach != attachVimMap)
|
264 |
-
enterVimMode(cm);
|
265 |
-
}
|
266 |
-
|
267 |
-
// Deprecated, simply setting the keymap works again.
|
268 |
-
CodeMirror.defineOption('vimMode', false, function(cm, val, prev) {
|
269 |
-
if (val && cm.getOption("keyMap") != "vim")
|
270 |
-
cm.setOption("keyMap", "vim");
|
271 |
-
else if (!val && prev != CodeMirror.Init && /^vim/.test(cm.getOption("keyMap")))
|
272 |
-
cm.setOption("keyMap", "default");
|
273 |
-
});
|
274 |
-
|
275 |
-
function cmKey(key, cm) {
|
276 |
-
if (!cm) { return undefined; }
|
277 |
-
var vimKey = cmKeyToVimKey(key);
|
278 |
-
if (!vimKey) {
|
279 |
-
return false;
|
280 |
-
}
|
281 |
-
var cmd = CodeMirror.Vim.findKey(cm, vimKey);
|
282 |
-
if (typeof cmd == 'function') {
|
283 |
-
CodeMirror.signal(cm, 'vim-keypress', vimKey);
|
284 |
-
}
|
285 |
-
return cmd;
|
286 |
-
}
|
287 |
-
|
288 |
-
var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'};
|
289 |
-
var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del'};
|
290 |
-
function cmKeyToVimKey(key) {
|
291 |
-
if (key.charAt(0) == '\'') {
|
292 |
-
// Keypress character binding of format "'a'"
|
293 |
-
return key.charAt(1);
|
294 |
-
}
|
295 |
-
var pieces = key.split('-');
|
296 |
-
if (/-$/.test(key)) {
|
297 |
-
// If the - key was typed, split will result in 2 extra empty strings
|
298 |
-
// in the array. Replace them with 1 '-'.
|
299 |
-
pieces.splice(-2, 2, '-');
|
300 |
-
}
|
301 |
-
var lastPiece = pieces[pieces.length - 1];
|
302 |
-
if (pieces.length == 1 && pieces[0].length == 1) {
|
303 |
-
// No-modifier bindings use literal character bindings above. Skip.
|
304 |
-
return false;
|
305 |
-
} else if (pieces.length == 2 && pieces[0] == 'Shift' && lastPiece.length == 1) {
|
306 |
-
// Ignore Shift+char bindings as they should be handled by literal character.
|
307 |
-
return false;
|
308 |
-
}
|
309 |
-
var hasCharacter = false;
|
310 |
-
for (var i = 0; i < pieces.length; i++) {
|
311 |
-
var piece = pieces[i];
|
312 |
-
if (piece in modifiers) { pieces[i] = modifiers[piece]; }
|
313 |
-
else { hasCharacter = true; }
|
314 |
-
if (piece in specialKeys) { pieces[i] = specialKeys[piece]; }
|
315 |
-
}
|
316 |
-
if (!hasCharacter) {
|
317 |
-
// Vim does not support modifier only keys.
|
318 |
-
return false;
|
319 |
-
}
|
320 |
-
// TODO: Current bindings expect the character to be lower case, but
|
321 |
-
// it looks like vim key notation uses upper case.
|
322 |
-
if (isUpperCase(lastPiece)) {
|
323 |
-
pieces[pieces.length - 1] = lastPiece.toLowerCase();
|
324 |
-
}
|
325 |
-
return '<' + pieces.join('-') + '>';
|
326 |
-
}
|
327 |
-
|
328 |
-
function getOnPasteFn(cm) {
|
329 |
-
var vim = cm.state.vim;
|
330 |
-
if (!vim.onPasteFn) {
|
331 |
-
vim.onPasteFn = function() {
|
332 |
-
if (!vim.insertMode) {
|
333 |
-
cm.setCursor(offsetCursor(cm.getCursor(), 0, 1));
|
334 |
-
actions.enterInsertMode(cm, {}, vim);
|
335 |
-
}
|
336 |
-
};
|
337 |
-
}
|
338 |
-
return vim.onPasteFn;
|
339 |
-
}
|
340 |
-
|
341 |
-
var numberRegex = /[\d]/;
|
342 |
-
var wordCharTest = [CodeMirror.isWordChar, function(ch) {
|
343 |
-
return ch && !CodeMirror.isWordChar(ch) && !/\s/.test(ch);
|
344 |
-
}], bigWordCharTest = [function(ch) {
|
345 |
-
return /\S/.test(ch);
|
346 |
-
}];
|
347 |
-
function makeKeyRange(start, size) {
|
348 |
-
var keys = [];
|
349 |
-
for (var i = start; i < start + size; i++) {
|
350 |
-
keys.push(String.fromCharCode(i));
|
351 |
-
}
|
352 |
-
return keys;
|
353 |
-
}
|
354 |
-
var upperCaseAlphabet = makeKeyRange(65, 26);
|
355 |
-
var lowerCaseAlphabet = makeKeyRange(97, 26);
|
356 |
-
var numbers = makeKeyRange(48, 10);
|
357 |
-
var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']);
|
358 |
-
var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '/']);
|
359 |
-
|
360 |
-
function isLine(cm, line) {
|
361 |
-
return line >= cm.firstLine() && line <= cm.lastLine();
|
362 |
-
}
|
363 |
-
function isLowerCase(k) {
|
364 |
-
return (/^[a-z]$/).test(k);
|
365 |
-
}
|
366 |
-
function isMatchableSymbol(k) {
|
367 |
-
return '()[]{}'.indexOf(k) != -1;
|
368 |
-
}
|
369 |
-
function isNumber(k) {
|
370 |
-
return numberRegex.test(k);
|
371 |
-
}
|
372 |
-
function isUpperCase(k) {
|
373 |
-
return (/^[A-Z]$/).test(k);
|
374 |
-
}
|
375 |
-
function isWhiteSpaceString(k) {
|
376 |
-
return (/^\s*$/).test(k);
|
377 |
-
}
|
378 |
-
function inArray(val, arr) {
|
379 |
-
for (var i = 0; i < arr.length; i++) {
|
380 |
-
if (arr[i] == val) {
|
381 |
-
return true;
|
382 |
-
}
|
383 |
-
}
|
384 |
-
return false;
|
385 |
-
}
|
386 |
-
|
387 |
-
var options = {};
|
388 |
-
function defineOption(name, defaultValue, type, aliases, callback) {
|
389 |
-
if (defaultValue === undefined && !callback) {
|
390 |
-
throw Error('defaultValue is required unless callback is provided');
|
391 |
-
}
|
392 |
-
if (!type) { type = 'string'; }
|
393 |
-
options[name] = {
|
394 |
-
type: type,
|
395 |
-
defaultValue: defaultValue,
|
396 |
-
callback: callback
|
397 |
-
};
|
398 |
-
if (aliases) {
|
399 |
-
for (var i = 0; i < aliases.length; i++) {
|
400 |
-
options[aliases[i]] = options[name];
|
401 |
-
}
|
402 |
-
}
|
403 |
-
if (defaultValue) {
|
404 |
-
setOption(name, defaultValue);
|
405 |
-
}
|
406 |
-
}
|
407 |
-
|
408 |
-
function setOption(name, value, cm, cfg) {
|
409 |
-
var option = options[name];
|
410 |
-
cfg = cfg || {};
|
411 |
-
var scope = cfg.scope;
|
412 |
-
if (!option) {
|
413 |
-
throw Error('Unknown option: ' + name);
|
414 |
-
}
|
415 |
-
if (option.type == 'boolean') {
|
416 |
-
if (value && value !== true) {
|
417 |
-
throw Error('Invalid argument: ' + name + '=' + value);
|
418 |
-
} else if (value !== false) {
|
419 |
-
// Boolean options are set to true if value is not defined.
|
420 |
-
value = true;
|
421 |
-
}
|
422 |
-
}
|
423 |
-
if (option.callback) {
|
424 |
-
if (scope !== 'local') {
|
425 |
-
option.callback(value, undefined);
|
426 |
-
}
|
427 |
-
if (scope !== 'global' && cm) {
|
428 |
-
option.callback(value, cm);
|
429 |
-
}
|
430 |
-
} else {
|
431 |
-
if (scope !== 'local') {
|
432 |
-
option.value = option.type == 'boolean' ? !!value : value;
|
433 |
-
}
|
434 |
-
if (scope !== 'global' && cm) {
|
435 |
-
cm.state.vim.options[name] = {value: value};
|
436 |
-
}
|
437 |
-
}
|
438 |
-
}
|
439 |
-
|
440 |
-
function getOption(name, cm, cfg) {
|
441 |
-
var option = options[name];
|
442 |
-
cfg = cfg || {};
|
443 |
-
var scope = cfg.scope;
|
444 |
-
if (!option) {
|
445 |
-
throw Error('Unknown option: ' + name);
|
446 |
-
}
|
447 |
-
if (option.callback) {
|
448 |
-
var local = cm && option.callback(undefined, cm);
|
449 |
-
if (scope !== 'global' && local !== undefined) {
|
450 |
-
return local;
|
451 |
-
}
|
452 |
-
if (scope !== 'local') {
|
453 |
-
return option.callback();
|
454 |
-
}
|
455 |
-
return;
|
456 |
-
} else {
|
457 |
-
var local = (scope !== 'global') && (cm && cm.state.vim.options[name]);
|
458 |
-
return (local || (scope !== 'local') && option || {}).value;
|
459 |
-
}
|
460 |
-
}
|
461 |
-
|
462 |
-
defineOption('filetype', undefined, 'string', ['ft'], function(name, cm) {
|
463 |
-
// Option is local. Do nothing for global.
|
464 |
-
if (cm === undefined) {
|
465 |
-
return;
|
466 |
-
}
|
467 |
-
// The 'filetype' option proxies to the CodeMirror 'mode' option.
|
468 |
-
if (name === undefined) {
|
469 |
-
var mode = cm.getOption('mode');
|
470 |
-
return mode == 'null' ? '' : mode;
|
471 |
-
} else {
|
472 |
-
var mode = name == '' ? 'null' : name;
|
473 |
-
cm.setOption('mode', mode);
|
474 |
-
}
|
475 |
-
});
|
476 |
-
|
477 |
-
var createCircularJumpList = function() {
|
478 |
-
var size = 100;
|
479 |
-
var pointer = -1;
|
480 |
-
var head = 0;
|
481 |
-
var tail = 0;
|
482 |
-
var buffer = new Array(size);
|
483 |
-
function add(cm, oldCur, newCur) {
|
484 |
-
var current = pointer % size;
|
485 |
-
var curMark = buffer[current];
|
486 |
-
function useNextSlot(cursor) {
|
487 |
-
var next = ++pointer % size;
|
488 |
-
var trashMark = buffer[next];
|
489 |
-
if (trashMark) {
|
490 |
-
trashMark.clear();
|
491 |
-
}
|
492 |
-
buffer[next] = cm.setBookmark(cursor);
|
493 |
-
}
|
494 |
-
if (curMark) {
|
495 |
-
var markPos = curMark.find();
|
496 |
-
// avoid recording redundant cursor position
|
497 |
-
if (markPos && !cursorEqual(markPos, oldCur)) {
|
498 |
-
useNextSlot(oldCur);
|
499 |
-
}
|
500 |
-
} else {
|
501 |
-
useNextSlot(oldCur);
|
502 |
-
}
|
503 |
-
useNextSlot(newCur);
|
504 |
-
head = pointer;
|
505 |
-
tail = pointer - size + 1;
|
506 |
-
if (tail < 0) {
|
507 |
-
tail = 0;
|
508 |
-
}
|
509 |
-
}
|
510 |
-
function move(cm, offset) {
|
511 |
-
pointer += offset;
|
512 |
-
if (pointer > head) {
|
513 |
-
pointer = head;
|
514 |
-
} else if (pointer < tail) {
|
515 |
-
pointer = tail;
|
516 |
-
}
|
517 |
-
var mark = buffer[(size + pointer) % size];
|
518 |
-
// skip marks that are temporarily removed from text buffer
|
519 |
-
if (mark && !mark.find()) {
|
520 |
-
var inc = offset > 0 ? 1 : -1;
|
521 |
-
var newCur;
|
522 |
-
var oldCur = cm.getCursor();
|
523 |
-
do {
|
524 |
-
pointer += inc;
|
525 |
-
mark = buffer[(size + pointer) % size];
|
526 |
-
// skip marks that are the same as current position
|
527 |
-
if (mark &&
|
528 |
-
(newCur = mark.find()) &&
|
529 |
-
!cursorEqual(oldCur, newCur)) {
|
530 |
-
break;
|
531 |
-
}
|
532 |
-
} while (pointer < head && pointer > tail);
|
533 |
-
}
|
534 |
-
return mark;
|
535 |
-
}
|
536 |
-
return {
|
537 |
-
cachedCursor: undefined, //used for # and * jumps
|
538 |
-
add: add,
|
539 |
-
move: move
|
540 |
-
};
|
541 |
-
};
|
542 |
-
|
543 |
-
// Returns an object to track the changes associated insert mode. It
|
544 |
-
// clones the object that is passed in, or creates an empty object one if
|
545 |
-
// none is provided.
|
546 |
-
var createInsertModeChanges = function(c) {
|
547 |
-
if (c) {
|
548 |
-
// Copy construction
|
549 |
-
return {
|
550 |
-
changes: c.changes,
|
551 |
-
expectCursorActivityForChange: c.expectCursorActivityForChange
|
552 |
-
};
|
553 |
-
}
|
554 |
-
return {
|
555 |
-
// Change list
|
556 |
-
changes: [],
|
557 |
-
// Set to true on change, false on cursorActivity.
|
558 |
-
expectCursorActivityForChange: false
|
559 |
-
};
|
560 |
-
};
|
561 |
-
|
562 |
-
function MacroModeState() {
|
563 |
-
this.latestRegister = undefined;
|
564 |
-
this.isPlaying = false;
|
565 |
-
this.isRecording = false;
|
566 |
-
this.replaySearchQueries = [];
|
567 |
-
this.onRecordingDone = undefined;
|
568 |
-
this.lastInsertModeChanges = createInsertModeChanges();
|
569 |
-
}
|
570 |
-
MacroModeState.prototype = {
|
571 |
-
exitMacroRecordMode: function() {
|
572 |
-
var macroModeState = vimGlobalState.macroModeState;
|
573 |
-
if (macroModeState.onRecordingDone) {
|
574 |
-
macroModeState.onRecordingDone(); // close dialog
|
575 |
-
}
|
576 |
-
macroModeState.onRecordingDone = undefined;
|
577 |
-
macroModeState.isRecording = false;
|
578 |
-
},
|
579 |
-
enterMacroRecordMode: function(cm, registerName) {
|
580 |
-
var register =
|
581 |
-
vimGlobalState.registerController.getRegister(registerName);
|
582 |
-
if (register) {
|
583 |
-
register.clear();
|
584 |
-
this.latestRegister = registerName;
|
585 |
-
if (cm.openDialog) {
|
586 |
-
this.onRecordingDone = cm.openDialog(
|
587 |
-
'(recording)['+registerName+']', null, {bottom:true});
|
588 |
-
}
|
589 |
-
this.isRecording = true;
|
590 |
-
}
|
591 |
-
}
|
592 |
-
};
|
593 |
-
|
594 |
-
function maybeInitVimState(cm) {
|
595 |
-
if (!cm.state.vim) {
|
596 |
-
// Store instance state in the CodeMirror object.
|
597 |
-
cm.state.vim = {
|
598 |
-
inputState: new InputState(),
|
599 |
-
// Vim's input state that triggered the last edit, used to repeat
|
600 |
-
// motions and operators with '.'.
|
601 |
-
lastEditInputState: undefined,
|
602 |
-
// Vim's action command before the last edit, used to repeat actions
|
603 |
-
// with '.' and insert mode repeat.
|
604 |
-
lastEditActionCommand: undefined,
|
605 |
-
// When using jk for navigation, if you move from a longer line to a
|
606 |
-
// shorter line, the cursor may clip to the end of the shorter line.
|
607 |
-
// If j is pressed again and cursor goes to the next line, the
|
608 |
-
// cursor should go back to its horizontal position on the longer
|
609 |
-
// line if it can. This is to keep track of the horizontal position.
|
610 |
-
lastHPos: -1,
|
611 |
-
// Doing the same with screen-position for gj/gk
|
612 |
-
lastHSPos: -1,
|
613 |
-
// The last motion command run. Cleared if a non-motion command gets
|
614 |
-
// executed in between.
|
615 |
-
lastMotion: null,
|
616 |
-
marks: {},
|
617 |
-
// Mark for rendering fake cursor for visual mode.
|
618 |
-
fakeCursor: null,
|
619 |
-
insertMode: false,
|
620 |
-
// Repeat count for changes made in insert mode, triggered by key
|
621 |
-
// sequences like 3,i. Only exists when insertMode is true.
|
622 |
-
insertModeRepeat: undefined,
|
623 |
-
visualMode: false,
|
624 |
-
// If we are in visual line mode. No effect if visualMode is false.
|
625 |
-
visualLine: false,
|
626 |
-
visualBlock: false,
|
627 |
-
lastSelection: null,
|
628 |
-
lastPastedText: null,
|
629 |
-
sel: {},
|
630 |
-
// Buffer-local/window-local values of vim options.
|
631 |
-
options: {}
|
632 |
-
};
|
633 |
-
}
|
634 |
-
return cm.state.vim;
|
635 |
-
}
|
636 |
-
var vimGlobalState;
|
637 |
-
function resetVimGlobalState() {
|
638 |
-
vimGlobalState = {
|
639 |
-
// The current search query.
|
640 |
-
searchQuery: null,
|
641 |
-
// Whether we are searching backwards.
|
642 |
-
searchIsReversed: false,
|
643 |
-
// Replace part of the last substituted pattern
|
644 |
-
lastSubstituteReplacePart: undefined,
|
645 |
-
jumpList: createCircularJumpList(),
|
646 |
-
macroModeState: new MacroModeState,
|
647 |
-
// Recording latest f, t, F or T motion command.
|
648 |
-
lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''},
|
649 |
-
registerController: new RegisterController({}),
|
650 |
-
// search history buffer
|
651 |
-
searchHistoryController: new HistoryController({}),
|
652 |
-
// ex Command history buffer
|
653 |
-
exCommandHistoryController : new HistoryController({})
|
654 |
-
};
|
655 |
-
for (var optionName in options) {
|
656 |
-
var option = options[optionName];
|
657 |
-
option.value = option.defaultValue;
|
658 |
-
}
|
659 |
-
}
|
660 |
-
|
661 |
-
var lastInsertModeKeyTimer;
|
662 |
-
var vimApi= {
|
663 |
-
buildKeyMap: function() {
|
664 |
-
// TODO: Convert keymap into dictionary format for fast lookup.
|
665 |
-
},
|
666 |
-
// Testing hook, though it might be useful to expose the register
|
667 |
-
// controller anyways.
|
668 |
-
getRegisterController: function() {
|
669 |
-
return vimGlobalState.registerController;
|
670 |
-
},
|
671 |
-
// Testing hook.
|
672 |
-
resetVimGlobalState_: resetVimGlobalState,
|
673 |
-
|
674 |
-
// Testing hook.
|
675 |
-
getVimGlobalState_: function() {
|
676 |
-
return vimGlobalState;
|
677 |
-
},
|
678 |
-
|
679 |
-
// Testing hook.
|
680 |
-
maybeInitVimState_: maybeInitVimState,
|
681 |
-
|
682 |
-
suppressErrorLogging: false,
|
683 |
-
|
684 |
-
InsertModeKey: InsertModeKey,
|
685 |
-
map: function(lhs, rhs, ctx) {
|
686 |
-
// Add user defined key bindings.
|
687 |
-
exCommandDispatcher.map(lhs, rhs, ctx);
|
688 |
-
},
|
689 |
-
// TODO: Expose setOption and getOption as instance methods. Need to decide how to namespace
|
690 |
-
// them, or somehow make them work with the existing CodeMirror setOption/getOption API.
|
691 |
-
setOption: setOption,
|
692 |
-
getOption: getOption,
|
693 |
-
defineOption: defineOption,
|
694 |
-
defineEx: function(name, prefix, func){
|
695 |
-
if (!prefix) {
|
696 |
-
prefix = name;
|
697 |
-
} else if (name.indexOf(prefix) !== 0) {
|
698 |
-
throw new Error('(Vim.defineEx) "'+prefix+'" is not a prefix of "'+name+'", command not registered');
|
699 |
-
}
|
700 |
-
exCommands[name]=func;
|
701 |
-
exCommandDispatcher.commandMap_[prefix]={name:name, shortName:prefix, type:'api'};
|
702 |
-
},
|
703 |
-
handleKey: function (cm, key, origin) {
|
704 |
-
var command = this.findKey(cm, key, origin);
|
705 |
-
if (typeof command === 'function') {
|
706 |
-
return command();
|
707 |
-
}
|
708 |
-
},
|
709 |
-
/**
|
710 |
-
* This is the outermost function called by CodeMirror, after keys have
|
711 |
-
* been mapped to their Vim equivalents.
|
712 |
-
*
|
713 |
-
* Finds a command based on the key (and cached keys if there is a
|
714 |
-
* multi-key sequence). Returns `undefined` if no key is matched, a noop
|
715 |
-
* function if a partial match is found (multi-key), and a function to
|
716 |
-
* execute the bound command if a a key is matched. The function always
|
717 |
-
* returns true.
|
718 |
-
*/
|
719 |
-
findKey: function(cm, key, origin) {
|
720 |
-
var vim = maybeInitVimState(cm);
|
721 |
-
function handleMacroRecording() {
|
722 |
-
var macroModeState = vimGlobalState.macroModeState;
|
723 |
-
if (macroModeState.isRecording) {
|
724 |
-
if (key == 'q') {
|
725 |
-
macroModeState.exitMacroRecordMode();
|
726 |
-
clearInputState(cm);
|
727 |
-
return true;
|
728 |
-
}
|
729 |
-
if (origin != 'mapping') {
|
730 |
-
logKey(macroModeState, key);
|
731 |
-
}
|
732 |
-
}
|
733 |
-
}
|
734 |
-
function handleEsc() {
|
735 |
-
if (key == '<Esc>') {
|
736 |
-
// Clear input state and get back to normal mode.
|
737 |
-
clearInputState(cm);
|
738 |
-
if (vim.visualMode) {
|
739 |
-
exitVisualMode(cm);
|
740 |
-
} else if (vim.insertMode) {
|
741 |
-
exitInsertMode(cm);
|
742 |
-
}
|
743 |
-
return true;
|
744 |
-
}
|
745 |
-
}
|
746 |
-
function doKeyToKey(keys) {
|
747 |
-
// TODO: prevent infinite recursion.
|
748 |
-
var match;
|
749 |
-
while (keys) {
|
750 |
-
// Pull off one command key, which is either a single character
|
751 |
-
// or a special sequence wrapped in '<' and '>', e.g. '<Space>'.
|
752 |
-
match = (/<\w+-.+?>|<\w+>|./).exec(keys);
|
753 |
-
key = match[0];
|
754 |
-
keys = keys.substring(match.index + key.length);
|
755 |
-
CodeMirror.Vim.handleKey(cm, key, 'mapping');
|
756 |
-
}
|
757 |
-
}
|
758 |
-
|
759 |
-
function handleKeyInsertMode() {
|
760 |
-
if (handleEsc()) { return true; }
|
761 |
-
var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key;
|
762 |
-
var keysAreChars = key.length == 1;
|
763 |
-
var match = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert');
|
764 |
-
// Need to check all key substrings in insert mode.
|
765 |
-
while (keys.length > 1 && match.type != 'full') {
|
766 |
-
var keys = vim.inputState.keyBuffer = keys.slice(1);
|
767 |
-
var thisMatch = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert');
|
768 |
-
if (thisMatch.type != 'none') { match = thisMatch; }
|
769 |
-
}
|
770 |
-
if (match.type == 'none') { clearInputState(cm); return false; }
|
771 |
-
else if (match.type == 'partial') {
|
772 |
-
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
|
773 |
-
lastInsertModeKeyTimer = window.setTimeout(
|
774 |
-
function() { if (vim.insertMode && vim.inputState.keyBuffer) { clearInputState(cm); } },
|
775 |
-
getOption('insertModeEscKeysTimeout'));
|
776 |
-
return !keysAreChars;
|
777 |
-
}
|
778 |
-
|
779 |
-
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
|
780 |
-
if (keysAreChars) {
|
781 |
-
var here = cm.getCursor();
|
782 |
-
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
|
783 |
-
}
|
784 |
-
clearInputState(cm);
|
785 |
-
return match.command;
|
786 |
-
}
|
787 |
-
|
788 |
-
function handleKeyNonInsertMode() {
|
789 |
-
if (handleMacroRecording() || handleEsc()) { return true; };
|
790 |
-
|
791 |
-
var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key;
|
792 |
-
if (/^[1-9]\d*$/.test(keys)) { return true; }
|
793 |
-
|
794 |
-
var keysMatcher = /^(\d*)(.*)$/.exec(keys);
|
795 |
-
if (!keysMatcher) { clearInputState(cm); return false; }
|
796 |
-
var context = vim.visualMode ? 'visual' :
|
797 |
-
'normal';
|
798 |
-
var match = commandDispatcher.matchCommand(keysMatcher[2] || keysMatcher[1], defaultKeymap, vim.inputState, context);
|
799 |
-
if (match.type == 'none') { clearInputState(cm); return false; }
|
800 |
-
else if (match.type == 'partial') { return true; }
|
801 |
-
|
802 |
-
vim.inputState.keyBuffer = '';
|
803 |
-
var keysMatcher = /^(\d*)(.*)$/.exec(keys);
|
804 |
-
if (keysMatcher[1] && keysMatcher[1] != '0') {
|
805 |
-
vim.inputState.pushRepeatDigit(keysMatcher[1]);
|
806 |
-
}
|
807 |
-
return match.command;
|
808 |
-
}
|
809 |
-
|
810 |
-
var command;
|
811 |
-
if (vim.insertMode) { command = handleKeyInsertMode(); }
|
812 |
-
else { command = handleKeyNonInsertMode(); }
|
813 |
-
if (command === false) {
|
814 |
-
return undefined;
|
815 |
-
} else if (command === true) {
|
816 |
-
// TODO: Look into using CodeMirror's multi-key handling.
|
817 |
-
// Return no-op since we are caching the key. Counts as handled, but
|
818 |
-
// don't want act on it just yet.
|
819 |
-
return function() {};
|
820 |
-
} else {
|
821 |
-
return function() {
|
822 |
-
return cm.operation(function() {
|
823 |
-
cm.curOp.isVimOp = true;
|
824 |
-
try {
|
825 |
-
if (command.type == 'keyToKey') {
|
826 |
-
doKeyToKey(command.toKeys);
|
827 |
-
} else {
|
828 |
-
commandDispatcher.processCommand(cm, vim, command);
|
829 |
-
}
|
830 |
-
} catch (e) {
|
831 |
-
// clear VIM state in case it's in a bad state.
|
832 |
-
cm.state.vim = undefined;
|
833 |
-
maybeInitVimState(cm);
|
834 |
-
if (!CodeMirror.Vim.suppressErrorLogging) {
|
835 |
-
console['log'](e);
|
836 |
-
}
|
837 |
-
throw e;
|
838 |
-
}
|
839 |
-
return true;
|
840 |
-
});
|
841 |
-
};
|
842 |
-
}
|
843 |
-
},
|
844 |
-
handleEx: function(cm, input) {
|
845 |
-
exCommandDispatcher.processCommand(cm, input);
|
846 |
-
},
|
847 |
-
|
848 |
-
defineMotion: defineMotion,
|
849 |
-
defineAction: defineAction,
|
850 |
-
defineOperator: defineOperator,
|
851 |
-
mapCommand: mapCommand,
|
852 |
-
_mapCommand: _mapCommand,
|
853 |
-
|
854 |
-
defineRegister: defineRegister,
|
855 |
-
|
856 |
-
exitVisualMode: exitVisualMode,
|
857 |
-
exitInsertMode: exitInsertMode
|
858 |
-
};
|
859 |
-
|
860 |
-
// Represents the current input state.
|
861 |
-
function InputState() {
|
862 |
-
this.prefixRepeat = [];
|
863 |
-
this.motionRepeat = [];
|
864 |
-
|
865 |
-
this.operator = null;
|
866 |
-
this.operatorArgs = null;
|
867 |
-
this.motion = null;
|
868 |
-
this.motionArgs = null;
|
869 |
-
this.keyBuffer = []; // For matching multi-key commands.
|
870 |
-
this.registerName = null; // Defaults to the unnamed register.
|
871 |
-
}
|
872 |
-
InputState.prototype.pushRepeatDigit = function(n) {
|
873 |
-
if (!this.operator) {
|
874 |
-
this.prefixRepeat = this.prefixRepeat.concat(n);
|
875 |
-
} else {
|
876 |
-
this.motionRepeat = this.motionRepeat.concat(n);
|
877 |
-
}
|
878 |
-
};
|
879 |
-
InputState.prototype.getRepeat = function() {
|
880 |
-
var repeat = 0;
|
881 |
-
if (this.prefixRepeat.length > 0 || this.motionRepeat.length > 0) {
|
882 |
-
repeat = 1;
|
883 |
-
if (this.prefixRepeat.length > 0) {
|
884 |
-
repeat *= parseInt(this.prefixRepeat.join(''), 10);
|
885 |
-
}
|
886 |
-
if (this.motionRepeat.length > 0) {
|
887 |
-
repeat *= parseInt(this.motionRepeat.join(''), 10);
|
888 |
-
}
|
889 |
-
}
|
890 |
-
return repeat;
|
891 |
-
};
|
892 |
-
|
893 |
-
function clearInputState(cm, reason) {
|
894 |
-
cm.state.vim.inputState = new InputState();
|
895 |
-
CodeMirror.signal(cm, 'vim-command-done', reason);
|
896 |
-
}
|
897 |
-
|
898 |
-
/*
|
899 |
-
* Register stores information about copy and paste registers. Besides
|
900 |
-
* text, a register must store whether it is linewise (i.e., when it is
|
901 |
-
* pasted, should it insert itself into a new line, or should the text be
|
902 |
-
* inserted at the cursor position.)
|
903 |
-
*/
|
904 |
-
function Register(text, linewise, blockwise) {
|
905 |
-
this.clear();
|
906 |
-
this.keyBuffer = [text || ''];
|
907 |
-
this.insertModeChanges = [];
|
908 |
-
this.searchQueries = [];
|
909 |
-
this.linewise = !!linewise;
|
910 |
-
this.blockwise = !!blockwise;
|
911 |
-
}
|
912 |
-
Register.prototype = {
|
913 |
-
setText: function(text, linewise, blockwise) {
|
914 |
-
this.keyBuffer = [text || ''];
|
915 |
-
this.linewise = !!linewise;
|
916 |
-
this.blockwise = !!blockwise;
|
917 |
-
},
|
918 |
-
pushText: function(text, linewise) {
|
919 |
-
// if this register has ever been set to linewise, use linewise.
|
920 |
-
if (linewise) {
|
921 |
-
if (!this.linewise) {
|
922 |
-
this.keyBuffer.push('\n');
|
923 |
-
}
|
924 |
-
this.linewise = true;
|
925 |
-
}
|
926 |
-
this.keyBuffer.push(text);
|
927 |
-
},
|
928 |
-
pushInsertModeChanges: function(changes) {
|
929 |
-
this.insertModeChanges.push(createInsertModeChanges(changes));
|
930 |
-
},
|
931 |
-
pushSearchQuery: function(query) {
|
932 |
-
this.searchQueries.push(query);
|
933 |
-
},
|
934 |
-
clear: function() {
|
935 |
-
this.keyBuffer = [];
|
936 |
-
this.insertModeChanges = [];
|
937 |
-
this.searchQueries = [];
|
938 |
-
this.linewise = false;
|
939 |
-
},
|
940 |
-
toString: function() {
|
941 |
-
return this.keyBuffer.join('');
|
942 |
-
}
|
943 |
-
};
|
944 |
-
|
945 |
-
/**
|
946 |
-
* Defines an external register.
|
947 |
-
*
|
948 |
-
* The name should be a single character that will be used to reference the register.
|
949 |
-
* The register should support setText, pushText, clear, and toString(). See Register
|
950 |
-
* for a reference implementation.
|
951 |
-
*/
|
952 |
-
function defineRegister(name, register) {
|
953 |
-
var registers = vimGlobalState.registerController.registers[name];
|
954 |
-
if (!name || name.length != 1) {
|
955 |
-
throw Error('Register name must be 1 character');
|
956 |
-
}
|
957 |
-
if (registers[name]) {
|
958 |
-
throw Error('Register already defined ' + name);
|
959 |
-
}
|
960 |
-
registers[name] = register;
|
961 |
-
validRegisters.push(name);
|
962 |
-
}
|
963 |
-
|
964 |
-
/*
|
965 |
-
* vim registers allow you to keep many independent copy and paste buffers.
|
966 |
-
* See http://usevim.com/2012/04/13/registers/ for an introduction.
|
967 |
-
*
|
968 |
-
* RegisterController keeps the state of all the registers. An initial
|
969 |
-
* state may be passed in. The unnamed register '"' will always be
|
970 |
-
* overridden.
|
971 |
-
*/
|
972 |
-
function RegisterController(registers) {
|
973 |
-
this.registers = registers;
|
974 |
-
this.unnamedRegister = registers['"'] = new Register();
|
975 |
-
registers['.'] = new Register();
|
976 |
-
registers[':'] = new Register();
|
977 |
-
registers['/'] = new Register();
|
978 |
-
}
|
979 |
-
RegisterController.prototype = {
|
980 |
-
pushText: function(registerName, operator, text, linewise, blockwise) {
|
981 |
-
if (linewise && text.charAt(0) == '\n') {
|
982 |
-
text = text.slice(1) + '\n';
|
983 |
-
}
|
984 |
-
if (linewise && text.charAt(text.length - 1) !== '\n'){
|
985 |
-
text += '\n';
|
986 |
-
}
|
987 |
-
// Lowercase and uppercase registers refer to the same register.
|
988 |
-
// Uppercase just means append.
|
989 |
-
var register = this.isValidRegister(registerName) ?
|
990 |
-
this.getRegister(registerName) : null;
|
991 |
-
// if no register/an invalid register was specified, things go to the
|
992 |
-
// default registers
|
993 |
-
if (!register) {
|
994 |
-
switch (operator) {
|
995 |
-
case 'yank':
|
996 |
-
// The 0 register contains the text from the most recent yank.
|
997 |
-
this.registers['0'] = new Register(text, linewise, blockwise);
|
998 |
-
break;
|
999 |
-
case 'delete':
|
1000 |
-
case 'change':
|
1001 |
-
if (text.indexOf('\n') == -1) {
|
1002 |
-
// Delete less than 1 line. Update the small delete register.
|
1003 |
-
this.registers['-'] = new Register(text, linewise);
|
1004 |
-
} else {
|
1005 |
-
// Shift down the contents of the numbered registers and put the
|
1006 |
-
// deleted text into register 1.
|
1007 |
-
this.shiftNumericRegisters_();
|
1008 |
-
this.registers['1'] = new Register(text, linewise);
|
1009 |
-
}
|
1010 |
-
break;
|
1011 |
-
}
|
1012 |
-
// Make sure the unnamed register is set to what just happened
|
1013 |
-
this.unnamedRegister.setText(text, linewise, blockwise);
|
1014 |
-
return;
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
// If we've gotten to this point, we've actually specified a register
|
1018 |
-
var append = isUpperCase(registerName);
|
1019 |
-
if (append) {
|
1020 |
-
register.pushText(text, linewise);
|
1021 |
-
} else {
|
1022 |
-
register.setText(text, linewise, blockwise);
|
1023 |
-
}
|
1024 |
-
// The unnamed register always has the same value as the last used
|
1025 |
-
// register.
|
1026 |
-
this.unnamedRegister.setText(register.toString(), linewise);
|
1027 |
-
},
|
1028 |
-
// Gets the register named @name. If one of @name doesn't already exist,
|
1029 |
-
// create it. If @name is invalid, return the unnamedRegister.
|
1030 |
-
getRegister: function(name) {
|
1031 |
-
if (!this.isValidRegister(name)) {
|
1032 |
-
return this.unnamedRegister;
|
1033 |
-
}
|
1034 |
-
name = name.toLowerCase();
|
1035 |
-
if (!this.registers[name]) {
|
1036 |
-
this.registers[name] = new Register();
|
1037 |
-
}
|
1038 |
-
return this.registers[name];
|
1039 |
-
},
|
1040 |
-
isValidRegister: function(name) {
|
1041 |
-
return name && inArray(name, validRegisters);
|
1042 |
-
},
|
1043 |
-
shiftNumericRegisters_: function() {
|
1044 |
-
for (var i = 9; i >= 2; i--) {
|
1045 |
-
this.registers[i] = this.getRegister('' + (i - 1));
|
1046 |
-
}
|
1047 |
-
}
|
1048 |
-
};
|
1049 |
-
function HistoryController() {
|
1050 |
-
this.historyBuffer = [];
|
1051 |
-
this.iterator;
|
1052 |
-
this.initialPrefix = null;
|
1053 |
-
}
|
1054 |
-
HistoryController.prototype = {
|
1055 |
-
// the input argument here acts a user entered prefix for a small time
|
1056 |
-
// until we start autocompletion in which case it is the autocompleted.
|
1057 |
-
nextMatch: function (input, up) {
|
1058 |
-
var historyBuffer = this.historyBuffer;
|
1059 |
-
var dir = up ? -1 : 1;
|
1060 |
-
if (this.initialPrefix === null) this.initialPrefix = input;
|
1061 |
-
for (var i = this.iterator + dir; up ? i >= 0 : i < historyBuffer.length; i+= dir) {
|
1062 |
-
var element = historyBuffer[i];
|
1063 |
-
for (var j = 0; j <= element.length; j++) {
|
1064 |
-
if (this.initialPrefix == element.substring(0, j)) {
|
1065 |
-
this.iterator = i;
|
1066 |
-
return element;
|
1067 |
-
}
|
1068 |
-
}
|
1069 |
-
}
|
1070 |
-
// should return the user input in case we reach the end of buffer.
|
1071 |
-
if (i >= historyBuffer.length) {
|
1072 |
-
this.iterator = historyBuffer.length;
|
1073 |
-
return this.initialPrefix;
|
1074 |
-
}
|
1075 |
-
// return the last autocompleted query or exCommand as it is.
|
1076 |
-
if (i < 0 ) return input;
|
1077 |
-
},
|
1078 |
-
pushInput: function(input) {
|
1079 |
-
var index = this.historyBuffer.indexOf(input);
|
1080 |
-
if (index > -1) this.historyBuffer.splice(index, 1);
|
1081 |
-
if (input.length) this.historyBuffer.push(input);
|
1082 |
-
},
|
1083 |
-
reset: function() {
|
1084 |
-
this.initialPrefix = null;
|
1085 |
-
this.iterator = this.historyBuffer.length;
|
1086 |
-
}
|
1087 |
-
};
|
1088 |
-
var commandDispatcher = {
|
1089 |
-
matchCommand: function(keys, keyMap, inputState, context) {
|
1090 |
-
var matches = commandMatches(keys, keyMap, context, inputState);
|
1091 |
-
if (!matches.full && !matches.partial) {
|
1092 |
-
return {type: 'none'};
|
1093 |
-
} else if (!matches.full && matches.partial) {
|
1094 |
-
return {type: 'partial'};
|
1095 |
-
}
|
1096 |
-
|
1097 |
-
var bestMatch;
|
1098 |
-
for (var i = 0; i < matches.full.length; i++) {
|
1099 |
-
var match = matches.full[i];
|
1100 |
-
if (!bestMatch) {
|
1101 |
-
bestMatch = match;
|
1102 |
-
}
|
1103 |
-
}
|
1104 |
-
if (bestMatch.keys.slice(-11) == '<character>') {
|
1105 |
-
inputState.selectedCharacter = lastChar(keys);
|
1106 |
-
}
|
1107 |
-
return {type: 'full', command: bestMatch};
|
1108 |
-
},
|
1109 |
-
processCommand: function(cm, vim, command) {
|
1110 |
-
vim.inputState.repeatOverride = command.repeatOverride;
|
1111 |
-
switch (command.type) {
|
1112 |
-
case 'motion':
|
1113 |
-
this.processMotion(cm, vim, command);
|
1114 |
-
break;
|
1115 |
-
case 'operator':
|
1116 |
-
this.processOperator(cm, vim, command);
|
1117 |
-
break;
|
1118 |
-
case 'operatorMotion':
|
1119 |
-
this.processOperatorMotion(cm, vim, command);
|
1120 |
-
break;
|
1121 |
-
case 'action':
|
1122 |
-
this.processAction(cm, vim, command);
|
1123 |
-
break;
|
1124 |
-
case 'search':
|
1125 |
-
this.processSearch(cm, vim, command);
|
1126 |
-
break;
|
1127 |
-
case 'ex':
|
1128 |
-
case 'keyToEx':
|
1129 |
-
this.processEx(cm, vim, command);
|
1130 |
-
break;
|
1131 |
-
default:
|
1132 |
-
break;
|
1133 |
-
}
|
1134 |
-
},
|
1135 |
-
processMotion: function(cm, vim, command) {
|
1136 |
-
vim.inputState.motion = command.motion;
|
1137 |
-
vim.inputState.motionArgs = copyArgs(command.motionArgs);
|
1138 |
-
this.evalInput(cm, vim);
|
1139 |
-
},
|
1140 |
-
processOperator: function(cm, vim, command) {
|
1141 |
-
var inputState = vim.inputState;
|
1142 |
-
if (inputState.operator) {
|
1143 |
-
if (inputState.operator == command.operator) {
|
1144 |
-
// Typing an operator twice like 'dd' makes the operator operate
|
1145 |
-
// linewise
|
1146 |
-
inputState.motion = 'expandToLine';
|
1147 |
-
inputState.motionArgs = { linewise: true };
|
1148 |
-
this.evalInput(cm, vim);
|
1149 |
-
return;
|
1150 |
-
} else {
|
1151 |
-
// 2 different operators in a row doesn't make sense.
|
1152 |
-
clearInputState(cm);
|
1153 |
-
}
|
1154 |
-
}
|
1155 |
-
inputState.operator = command.operator;
|
1156 |
-
inputState.operatorArgs = copyArgs(command.operatorArgs);
|
1157 |
-
if (vim.visualMode) {
|
1158 |
-
// Operating on a selection in visual mode. We don't need a motion.
|
1159 |
-
this.evalInput(cm, vim);
|
1160 |
-
}
|
1161 |
-
},
|
1162 |
-
processOperatorMotion: function(cm, vim, command) {
|
1163 |
-
var visualMode = vim.visualMode;
|
1164 |
-
var operatorMotionArgs = copyArgs(command.operatorMotionArgs);
|
1165 |
-
if (operatorMotionArgs) {
|
1166 |
-
// Operator motions may have special behavior in visual mode.
|
1167 |
-
if (visualMode && operatorMotionArgs.visualLine) {
|
1168 |
-
vim.visualLine = true;
|
1169 |
-
}
|
1170 |
-
}
|
1171 |
-
this.processOperator(cm, vim, command);
|
1172 |
-
if (!visualMode) {
|
1173 |
-
this.processMotion(cm, vim, command);
|
1174 |
-
}
|
1175 |
-
},
|
1176 |
-
processAction: function(cm, vim, command) {
|
1177 |
-
var inputState = vim.inputState;
|
1178 |
-
var repeat = inputState.getRepeat();
|
1179 |
-
var repeatIsExplicit = !!repeat;
|
1180 |
-
var actionArgs = copyArgs(command.actionArgs) || {};
|
1181 |
-
if (inputState.selectedCharacter) {
|
1182 |
-
actionArgs.selectedCharacter = inputState.selectedCharacter;
|
1183 |
-
}
|
1184 |
-
// Actions may or may not have motions and operators. Do these first.
|
1185 |
-
if (command.operator) {
|
1186 |
-
this.processOperator(cm, vim, command);
|
1187 |
-
}
|
1188 |
-
if (command.motion) {
|
1189 |
-
this.processMotion(cm, vim, command);
|
1190 |
-
}
|
1191 |
-
if (command.motion || command.operator) {
|
1192 |
-
this.evalInput(cm, vim);
|
1193 |
-
}
|
1194 |
-
actionArgs.repeat = repeat || 1;
|
1195 |
-
actionArgs.repeatIsExplicit = repeatIsExplicit;
|
1196 |
-
actionArgs.registerName = inputState.registerName;
|
1197 |
-
clearInputState(cm);
|
1198 |
-
vim.lastMotion = null;
|
1199 |
-
if (command.isEdit) {
|
1200 |
-
this.recordLastEdit(vim, inputState, command);
|
1201 |
-
}
|
1202 |
-
actions[command.action](cm, actionArgs, vim);
|
1203 |
-
},
|
1204 |
-
processSearch: function(cm, vim, command) {
|
1205 |
-
if (!cm.getSearchCursor) {
|
1206 |
-
// Search depends on SearchCursor.
|
1207 |
-
return;
|
1208 |
-
}
|
1209 |
-
var forward = command.searchArgs.forward;
|
1210 |
-
var wholeWordOnly = command.searchArgs.wholeWordOnly;
|
1211 |
-
getSearchState(cm).setReversed(!forward);
|
1212 |
-
var promptPrefix = (forward) ? '/' : '?';
|
1213 |
-
var originalQuery = getSearchState(cm).getQuery();
|
1214 |
-
var originalScrollPos = cm.getScrollInfo();
|
1215 |
-
function handleQuery(query, ignoreCase, smartCase) {
|
1216 |
-
vimGlobalState.searchHistoryController.pushInput(query);
|
1217 |
-
vimGlobalState.searchHistoryController.reset();
|
1218 |
-
try {
|
1219 |
-
updateSearchQuery(cm, query, ignoreCase, smartCase);
|
1220 |
-
} catch (e) {
|
1221 |
-
showConfirm(cm, 'Invalid regex: ' + query);
|
1222 |
-
clearInputState(cm);
|
1223 |
-
return;
|
1224 |
-
}
|
1225 |
-
commandDispatcher.processMotion(cm, vim, {
|
1226 |
-
type: 'motion',
|
1227 |
-
motion: 'findNext',
|
1228 |
-
motionArgs: { forward: true, toJumplist: command.searchArgs.toJumplist }
|
1229 |
-
});
|
1230 |
-
}
|
1231 |
-
function onPromptClose(query) {
|
1232 |
-
cm.scrollTo(originalScrollPos.left, originalScrollPos.top);
|
1233 |
-
handleQuery(query, true /** ignoreCase */, true /** smartCase */);
|
1234 |
-
var macroModeState = vimGlobalState.macroModeState;
|
1235 |
-
if (macroModeState.isRecording) {
|
1236 |
-
logSearchQuery(macroModeState, query);
|
1237 |
-
}
|
1238 |
-
}
|
1239 |
-
function onPromptKeyUp(e, query, close) {
|
1240 |
-
var keyName = CodeMirror.keyName(e), up;
|
1241 |
-
if (keyName == 'Up' || keyName == 'Down') {
|
1242 |
-
up = keyName == 'Up' ? true : false;
|
1243 |
-
query = vimGlobalState.searchHistoryController.nextMatch(query, up) || '';
|
1244 |
-
close(query);
|
1245 |
-
} else {
|
1246 |
-
if ( keyName != 'Left' && keyName != 'Right' && keyName != 'Ctrl' && keyName != 'Alt' && keyName != 'Shift')
|
1247 |
-
vimGlobalState.searchHistoryController.reset();
|
1248 |
-
}
|
1249 |
-
var parsedQuery;
|
1250 |
-
try {
|
1251 |
-
parsedQuery = updateSearchQuery(cm, query,
|
1252 |
-
true /** ignoreCase */, true /** smartCase */);
|
1253 |
-
} catch (e) {
|
1254 |
-
// Swallow bad regexes for incremental search.
|
1255 |
-
}
|
1256 |
-
if (parsedQuery) {
|
1257 |
-
cm.scrollIntoView(findNext(cm, !forward, parsedQuery), 30);
|
1258 |
-
} else {
|
1259 |
-
clearSearchHighlight(cm);
|
1260 |
-
cm.scrollTo(originalScrollPos.left, originalScrollPos.top);
|
1261 |
-
}
|
1262 |
-
}
|
1263 |
-
function onPromptKeyDown(e, query, close) {
|
1264 |
-
var keyName = CodeMirror.keyName(e);
|
1265 |
-
if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[' ||
|
1266 |
-
(keyName == 'Backspace' && query == '')) {
|
1267 |
-
vimGlobalState.searchHistoryController.pushInput(query);
|
1268 |
-
vimGlobalState.searchHistoryController.reset();
|
1269 |
-
updateSearchQuery(cm, originalQuery);
|
1270 |
-
clearSearchHighlight(cm);
|
1271 |
-
cm.scrollTo(originalScrollPos.left, originalScrollPos.top);
|
1272 |
-
CodeMirror.e_stop(e);
|
1273 |
-
clearInputState(cm);
|
1274 |
-
close();
|
1275 |
-
cm.focus();
|
1276 |
-
} else if (keyName == 'Ctrl-U') {
|
1277 |
-
// Ctrl-U clears input.
|
1278 |
-
CodeMirror.e_stop(e);
|
1279 |
-
close('');
|
1280 |
-
}
|
1281 |
-
}
|
1282 |
-
switch (command.searchArgs.querySrc) {
|
1283 |
-
case 'prompt':
|
1284 |
-
var macroModeState = vimGlobalState.macroModeState;
|
1285 |
-
if (macroModeState.isPlaying) {
|
1286 |
-
var query = macroModeState.replaySearchQueries.shift();
|
1287 |
-
handleQuery(query, true /** ignoreCase */, false /** smartCase */);
|
1288 |
-
} else {
|
1289 |
-
showPrompt(cm, {
|
1290 |
-
onClose: onPromptClose,
|
1291 |
-
prefix: promptPrefix,
|
1292 |
-
desc: searchPromptDesc,
|
1293 |
-
onKeyUp: onPromptKeyUp,
|
1294 |
-
onKeyDown: onPromptKeyDown
|
1295 |
-
});
|
1296 |
-
}
|
1297 |
-
break;
|
1298 |
-
case 'wordUnderCursor':
|
1299 |
-
var word = expandWordUnderCursor(cm, false /** inclusive */,
|
1300 |
-
true /** forward */, false /** bigWord */,
|
1301 |
-
true /** noSymbol */);
|
1302 |
-
var isKeyword = true;
|
1303 |
-
if (!word) {
|
1304 |
-
word = expandWordUnderCursor(cm, false /** inclusive */,
|
1305 |
-
true /** forward */, false /** bigWord */,
|
1306 |
-
false /** noSymbol */);
|
1307 |
-
isKeyword = false;
|
1308 |
-
}
|
1309 |
-
if (!word) {
|
1310 |
-
return;
|
1311 |
-
}
|
1312 |
-
var query = cm.getLine(word.start.line).substring(word.start.ch,
|
1313 |
-
word.end.ch);
|
1314 |
-
if (isKeyword && wholeWordOnly) {
|
1315 |
-
query = '\\b' + query + '\\b';
|
1316 |
-
} else {
|
1317 |
-
query = escapeRegex(query);
|
1318 |
-
}
|
1319 |
-
|
1320 |
-
// cachedCursor is used to save the old position of the cursor
|
1321 |
-
// when * or # causes vim to seek for the nearest word and shift
|
1322 |
-
// the cursor before entering the motion.
|
1323 |
-
vimGlobalState.jumpList.cachedCursor = cm.getCursor();
|
1324 |
-
cm.setCursor(word.start);
|
1325 |
-
|
1326 |
-
handleQuery(query, true /** ignoreCase */, false /** smartCase */);
|
1327 |
-
break;
|
1328 |
-
}
|
1329 |
-
},
|
1330 |
-
processEx: function(cm, vim, command) {
|
1331 |
-
function onPromptClose(input) {
|
1332 |
-
// Give the prompt some time to close so that if processCommand shows
|
1333 |
-
// an error, the elements don't overlap.
|
1334 |
-
vimGlobalState.exCommandHistoryController.pushInput(input);
|
1335 |
-
vimGlobalState.exCommandHistoryController.reset();
|
1336 |
-
exCommandDispatcher.processCommand(cm, input);
|
1337 |
-
}
|
1338 |
-
function onPromptKeyDown(e, input, close) {
|
1339 |
-
var keyName = CodeMirror.keyName(e), up;
|
1340 |
-
if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[' ||
|
1341 |
-
(keyName == 'Backspace' && input == '')) {
|
1342 |
-
vimGlobalState.exCommandHistoryController.pushInput(input);
|
1343 |
-
vimGlobalState.exCommandHistoryController.reset();
|
1344 |
-
CodeMirror.e_stop(e);
|
1345 |
-
clearInputState(cm);
|
1346 |
-
close();
|
1347 |
-
cm.focus();
|
1348 |
-
}
|
1349 |
-
if (keyName == 'Up' || keyName == 'Down') {
|
1350 |
-
up = keyName == 'Up' ? true : false;
|
1351 |
-
input = vimGlobalState.exCommandHistoryController.nextMatch(input, up) || '';
|
1352 |
-
close(input);
|
1353 |
-
} else if (keyName == 'Ctrl-U') {
|
1354 |
-
// Ctrl-U clears input.
|
1355 |
-
CodeMirror.e_stop(e);
|
1356 |
-
close('');
|
1357 |
-
} else {
|
1358 |
-
if ( keyName != 'Left' && keyName != 'Right' && keyName != 'Ctrl' && keyName != 'Alt' && keyName != 'Shift')
|
1359 |
-
vimGlobalState.exCommandHistoryController.reset();
|
1360 |
-
}
|
1361 |
-
}
|
1362 |
-
if (command.type == 'keyToEx') {
|
1363 |
-
// Handle user defined Ex to Ex mappings
|
1364 |
-
exCommandDispatcher.processCommand(cm, command.exArgs.input);
|
1365 |
-
} else {
|
1366 |
-
if (vim.visualMode) {
|
1367 |
-
showPrompt(cm, { onClose: onPromptClose, prefix: ':', value: '\'<,\'>',
|
1368 |
-
onKeyDown: onPromptKeyDown});
|
1369 |
-
} else {
|
1370 |
-
showPrompt(cm, { onClose: onPromptClose, prefix: ':',
|
1371 |
-
onKeyDown: onPromptKeyDown});
|
1372 |
-
}
|
1373 |
-
}
|
1374 |
-
},
|
1375 |
-
evalInput: function(cm, vim) {
|
1376 |
-
// If the motion comand is set, execute both the operator and motion.
|
1377 |
-
// Otherwise return.
|
1378 |
-
var inputState = vim.inputState;
|
1379 |
-
var motion = inputState.motion;
|
1380 |
-
var motionArgs = inputState.motionArgs || {};
|
1381 |
-
var operator = inputState.operator;
|
1382 |
-
var operatorArgs = inputState.operatorArgs || {};
|
1383 |
-
var registerName = inputState.registerName;
|
1384 |
-
var sel = vim.sel;
|
1385 |
-
// TODO: Make sure cm and vim selections are identical outside visual mode.
|
1386 |
-
var origHead = copyCursor(vim.visualMode ? clipCursorToContent(cm, sel.head): cm.getCursor('head'));
|
1387 |
-
var origAnchor = copyCursor(vim.visualMode ? clipCursorToContent(cm, sel.anchor) : cm.getCursor('anchor'));
|
1388 |
-
var oldHead = copyCursor(origHead);
|
1389 |
-
var oldAnchor = copyCursor(origAnchor);
|
1390 |
-
var newHead, newAnchor;
|
1391 |
-
var repeat;
|
1392 |
-
if (operator) {
|
1393 |
-
this.recordLastEdit(vim, inputState);
|
1394 |
-
}
|
1395 |
-
if (inputState.repeatOverride !== undefined) {
|
1396 |
-
// If repeatOverride is specified, that takes precedence over the
|
1397 |
-
// input state's repeat. Used by Ex mode and can be user defined.
|
1398 |
-
repeat = inputState.repeatOverride;
|
1399 |
-
} else {
|
1400 |
-
repeat = inputState.getRepeat();
|
1401 |
-
}
|
1402 |
-
if (repeat > 0 && motionArgs.explicitRepeat) {
|
1403 |
-
motionArgs.repeatIsExplicit = true;
|
1404 |
-
} else if (motionArgs.noRepeat ||
|
1405 |
-
(!motionArgs.explicitRepeat && repeat === 0)) {
|
1406 |
-
repeat = 1;
|
1407 |
-
motionArgs.repeatIsExplicit = false;
|
1408 |
-
}
|
1409 |
-
if (inputState.selectedCharacter) {
|
1410 |
-
// If there is a character input, stick it in all of the arg arrays.
|
1411 |
-
motionArgs.selectedCharacter = operatorArgs.selectedCharacter =
|
1412 |
-
inputState.selectedCharacter;
|
1413 |
-
}
|
1414 |
-
motionArgs.repeat = repeat;
|
1415 |
-
clearInputState(cm);
|
1416 |
-
if (motion) {
|
1417 |
-
var motionResult = motions[motion](cm, origHead, motionArgs, vim);
|
1418 |
-
vim.lastMotion = motions[motion];
|
1419 |
-
if (!motionResult) {
|
1420 |
-
return;
|
1421 |
-
}
|
1422 |
-
if (motionArgs.toJumplist) {
|
1423 |
-
var jumpList = vimGlobalState.jumpList;
|
1424 |
-
// if the current motion is # or *, use cachedCursor
|
1425 |
-
var cachedCursor = jumpList.cachedCursor;
|
1426 |
-
if (cachedCursor) {
|
1427 |
-
recordJumpPosition(cm, cachedCursor, motionResult);
|
1428 |
-
delete jumpList.cachedCursor;
|
1429 |
-
} else {
|
1430 |
-
recordJumpPosition(cm, origHead, motionResult);
|
1431 |
-
}
|
1432 |
-
}
|
1433 |
-
if (motionResult instanceof Array) {
|
1434 |
-
newAnchor = motionResult[0];
|
1435 |
-
newHead = motionResult[1];
|
1436 |
-
} else {
|
1437 |
-
newHead = motionResult;
|
1438 |
-
}
|
1439 |
-
// TODO: Handle null returns from motion commands better.
|
1440 |
-
if (!newHead) {
|
1441 |
-
newHead = copyCursor(origHead);
|
1442 |
-
}
|
1443 |
-
if (vim.visualMode) {
|
1444 |
-
if (!(vim.visualBlock && newHead.ch === Infinity)) {
|
1445 |
-
newHead = clipCursorToContent(cm, newHead, vim.visualBlock);
|
1446 |
-
}
|
1447 |
-
if (newAnchor) {
|
1448 |
-
newAnchor = clipCursorToContent(cm, newAnchor, true);
|
1449 |
-
}
|
1450 |
-
newAnchor = newAnchor || oldAnchor;
|
1451 |
-
sel.anchor = newAnchor;
|
1452 |
-
sel.head = newHead;
|
1453 |
-
updateCmSelection(cm);
|
1454 |
-
updateMark(cm, vim, '<',
|
1455 |
-
cursorIsBefore(newAnchor, newHead) ? newAnchor
|
1456 |
-
: newHead);
|
1457 |
-
updateMark(cm, vim, '>',
|
1458 |
-
cursorIsBefore(newAnchor, newHead) ? newHead
|
1459 |
-
: newAnchor);
|
1460 |
-
} else if (!operator) {
|
1461 |
-
newHead = clipCursorToContent(cm, newHead);
|
1462 |
-
cm.setCursor(newHead.line, newHead.ch);
|
1463 |
-
}
|
1464 |
-
}
|
1465 |
-
if (operator) {
|
1466 |
-
if (operatorArgs.lastSel) {
|
1467 |
-
// Replaying a visual mode operation
|
1468 |
-
newAnchor = oldAnchor;
|
1469 |
-
var lastSel = operatorArgs.lastSel;
|
1470 |
-
var lineOffset = Math.abs(lastSel.head.line - lastSel.anchor.line);
|
1471 |
-
var chOffset = Math.abs(lastSel.head.ch - lastSel.anchor.ch);
|
1472 |
-
if (lastSel.visualLine) {
|
1473 |
-
// Linewise Visual mode: The same number of lines.
|
1474 |
-
newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch);
|
1475 |
-
} else if (lastSel.visualBlock) {
|
1476 |
-
// Blockwise Visual mode: The same number of lines and columns.
|
1477 |
-
newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch + chOffset);
|
1478 |
-
} else if (lastSel.head.line == lastSel.anchor.line) {
|
1479 |
-
// Normal Visual mode within one line: The same number of characters.
|
1480 |
-
newHead = Pos(oldAnchor.line, oldAnchor.ch + chOffset);
|
1481 |
-
} else {
|
1482 |
-
// Normal Visual mode with several lines: The same number of lines, in the
|
1483 |
-
// last line the same number of characters as in the last line the last time.
|
1484 |
-
newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch);
|
1485 |
-
}
|
1486 |
-
vim.visualMode = true;
|
1487 |
-
vim.visualLine = lastSel.visualLine;
|
1488 |
-
vim.visualBlock = lastSel.visualBlock;
|
1489 |
-
sel = vim.sel = {
|
1490 |
-
anchor: newAnchor,
|
1491 |
-
head: newHead
|
1492 |
-
};
|
1493 |
-
updateCmSelection(cm);
|
1494 |
-
} else if (vim.visualMode) {
|
1495 |
-
operatorArgs.lastSel = {
|
1496 |
-
anchor: copyCursor(sel.anchor),
|
1497 |
-
head: copyCursor(sel.head),
|
1498 |
-
visualBlock: vim.visualBlock,
|
1499 |
-
visualLine: vim.visualLine
|
1500 |
-
};
|
1501 |
-
}
|
1502 |
-
var curStart, curEnd, linewise, mode;
|
1503 |
-
var cmSel;
|
1504 |
-
if (vim.visualMode) {
|
1505 |
-
// Init visual op
|
1506 |
-
curStart = cursorMin(sel.head, sel.anchor);
|
1507 |
-
curEnd = cursorMax(sel.head, sel.anchor);
|
1508 |
-
linewise = vim.visualLine || operatorArgs.linewise;
|
1509 |
-
mode = vim.visualBlock ? 'block' :
|
1510 |
-
linewise ? 'line' :
|
1511 |
-
'char';
|
1512 |
-
cmSel = makeCmSelection(cm, {
|
1513 |
-
anchor: curStart,
|
1514 |
-
head: curEnd
|
1515 |
-
}, mode);
|
1516 |
-
if (linewise) {
|
1517 |
-
var ranges = cmSel.ranges;
|
1518 |
-
if (mode == 'block') {
|
1519 |
-
// Linewise operators in visual block mode extend to end of line
|
1520 |
-
for (var i = 0; i < ranges.length; i++) {
|
1521 |
-
ranges[i].head.ch = lineLength(cm, ranges[i].head.line);
|
1522 |
-
}
|
1523 |
-
} else if (mode == 'line') {
|
1524 |
-
ranges[0].head = Pos(ranges[0].head.line + 1, 0);
|
1525 |
-
}
|
1526 |
-
}
|
1527 |
-
} else {
|
1528 |
-
// Init motion op
|
1529 |
-
curStart = copyCursor(newAnchor || oldAnchor);
|
1530 |
-
curEnd = copyCursor(newHead || oldHead);
|
1531 |
-
if (cursorIsBefore(curEnd, curStart)) {
|
1532 |
-
var tmp = curStart;
|
1533 |
-
curStart = curEnd;
|
1534 |
-
curEnd = tmp;
|
1535 |
-
}
|
1536 |
-
linewise = motionArgs.linewise || operatorArgs.linewise;
|
1537 |
-
if (linewise) {
|
1538 |
-
// Expand selection to entire line.
|
1539 |
-
expandSelectionToLine(cm, curStart, curEnd);
|
1540 |
-
} else if (motionArgs.forward) {
|
1541 |
-
// Clip to trailing newlines only if the motion goes forward.
|
1542 |
-
clipToLine(cm, curStart, curEnd);
|
1543 |
-
}
|
1544 |
-
mode = 'char';
|
1545 |
-
var exclusive = !motionArgs.inclusive || linewise;
|
1546 |
-
cmSel = makeCmSelection(cm, {
|
1547 |
-
anchor: curStart,
|
1548 |
-
head: curEnd
|
1549 |
-
}, mode, exclusive);
|
1550 |
-
}
|
1551 |
-
cm.setSelections(cmSel.ranges, cmSel.primary);
|
1552 |
-
vim.lastMotion = null;
|
1553 |
-
operatorArgs.repeat = repeat; // For indent in visual mode.
|
1554 |
-
operatorArgs.registerName = registerName;
|
1555 |
-
// Keep track of linewise as it affects how paste and change behave.
|
1556 |
-
operatorArgs.linewise = linewise;
|
1557 |
-
var operatorMoveTo = operators[operator](
|
1558 |
-
cm, operatorArgs, cmSel.ranges, oldAnchor, newHead);
|
1559 |
-
if (vim.visualMode) {
|
1560 |
-
exitVisualMode(cm, operatorMoveTo != null);
|
1561 |
-
}
|
1562 |
-
if (operatorMoveTo) {
|
1563 |
-
cm.setCursor(operatorMoveTo);
|
1564 |
-
}
|
1565 |
-
}
|
1566 |
-
},
|
1567 |
-
recordLastEdit: function(vim, inputState, actionCommand) {
|
1568 |
-
var macroModeState = vimGlobalState.macroModeState;
|
1569 |
-
if (macroModeState.isPlaying) { return; }
|
1570 |
-
vim.lastEditInputState = inputState;
|
1571 |
-
vim.lastEditActionCommand = actionCommand;
|
1572 |
-
macroModeState.lastInsertModeChanges.changes = [];
|
1573 |
-
macroModeState.lastInsertModeChanges.expectCursorActivityForChange = false;
|
1574 |
-
}
|
1575 |
-
};
|
1576 |
-
|
1577 |
-
/**
|
1578 |
-
* typedef {Object{line:number,ch:number}} Cursor An object containing the
|
1579 |
-
* position of the cursor.
|
1580 |
-
*/
|
1581 |
-
// All of the functions below return Cursor objects.
|
1582 |
-
var motions = {
|
1583 |
-
moveToTopLine: function(cm, _head, motionArgs) {
|
1584 |
-
var line = getUserVisibleLines(cm).top + motionArgs.repeat -1;
|
1585 |
-
return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));
|
1586 |
-
},
|
1587 |
-
moveToMiddleLine: function(cm) {
|
1588 |
-
var range = getUserVisibleLines(cm);
|
1589 |
-
var line = Math.floor((range.top + range.bottom) * 0.5);
|
1590 |
-
return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));
|
1591 |
-
},
|
1592 |
-
moveToBottomLine: function(cm, _head, motionArgs) {
|
1593 |
-
var line = getUserVisibleLines(cm).bottom - motionArgs.repeat +1;
|
1594 |
-
return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));
|
1595 |
-
},
|
1596 |
-
expandToLine: function(_cm, head, motionArgs) {
|
1597 |
-
// Expands forward to end of line, and then to next line if repeat is
|
1598 |
-
// >1. Does not handle backward motion!
|
1599 |
-
var cur = head;
|
1600 |
-
return Pos(cur.line + motionArgs.repeat - 1, Infinity);
|
1601 |
-
},
|
1602 |
-
findNext: function(cm, _head, motionArgs) {
|
1603 |
-
var state = getSearchState(cm);
|
1604 |
-
var query = state.getQuery();
|
1605 |
-
if (!query) {
|
1606 |
-
return;
|
1607 |
-
}
|
1608 |
-
var prev = !motionArgs.forward;
|
1609 |
-
// If search is initiated with ? instead of /, negate direction.
|
1610 |
-
prev = (state.isReversed()) ? !prev : prev;
|
1611 |
-
highlightSearchMatches(cm, query);
|
1612 |
-
return findNext(cm, prev/** prev */, query, motionArgs.repeat);
|
1613 |
-
},
|
1614 |
-
goToMark: function(cm, _head, motionArgs, vim) {
|
1615 |
-
var mark = vim.marks[motionArgs.selectedCharacter];
|
1616 |
-
if (mark) {
|
1617 |
-
var pos = mark.find();
|
1618 |
-
return motionArgs.linewise ? { line: pos.line, ch: findFirstNonWhiteSpaceCharacter(cm.getLine(pos.line)) } : pos;
|
1619 |
-
}
|
1620 |
-
return null;
|
1621 |
-
},
|
1622 |
-
moveToOtherHighlightedEnd: function(cm, _head, motionArgs, vim) {
|
1623 |
-
if (vim.visualBlock && motionArgs.sameLine) {
|
1624 |
-
var sel = vim.sel;
|
1625 |
-
return [
|
1626 |
-
clipCursorToContent(cm, Pos(sel.anchor.line, sel.head.ch)),
|
1627 |
-
clipCursorToContent(cm, Pos(sel.head.line, sel.anchor.ch))
|
1628 |
-
];
|
1629 |
-
} else {
|
1630 |
-
return ([vim.sel.head, vim.sel.anchor]);
|
1631 |
-
}
|
1632 |
-
},
|
1633 |
-
jumpToMark: function(cm, head, motionArgs, vim) {
|
1634 |
-
var best = head;
|
1635 |
-
for (var i = 0; i < motionArgs.repeat; i++) {
|
1636 |
-
var cursor = best;
|
1637 |
-
for (var key in vim.marks) {
|
1638 |
-
if (!isLowerCase(key)) {
|
1639 |
-
continue;
|
1640 |
-
}
|
1641 |
-
var mark = vim.marks[key].find();
|
1642 |
-
var isWrongDirection = (motionArgs.forward) ?
|
1643 |
-
cursorIsBefore(mark, cursor) : cursorIsBefore(cursor, mark);
|
1644 |
-
|
1645 |
-
if (isWrongDirection) {
|
1646 |
-
continue;
|
1647 |
-
}
|
1648 |
-
if (motionArgs.linewise && (mark.line == cursor.line)) {
|
1649 |
-
continue;
|
1650 |
-
}
|
1651 |
-
|
1652 |
-
var equal = cursorEqual(cursor, best);
|
1653 |
-
var between = (motionArgs.forward) ?
|
1654 |
-
cursorIsBetween(cursor, mark, best) :
|
1655 |
-
cursorIsBetween(best, mark, cursor);
|
1656 |
-
|
1657 |
-
if (equal || between) {
|
1658 |
-
best = mark;
|
1659 |
-
}
|
1660 |
-
}
|
1661 |
-
}
|
1662 |
-
|
1663 |
-
if (motionArgs.linewise) {
|
1664 |
-
// Vim places the cursor on the first non-whitespace character of
|
1665 |
-
// the line if there is one, else it places the cursor at the end
|
1666 |
-
// of the line, regardless of whether a mark was found.
|
1667 |
-
best = Pos(best.line, findFirstNonWhiteSpaceCharacter(cm.getLine(best.line)));
|
1668 |
-
}
|
1669 |
-
return best;
|
1670 |
-
},
|
1671 |
-
moveByCharacters: function(_cm, head, motionArgs) {
|
1672 |
-
var cur = head;
|
1673 |
-
var repeat = motionArgs.repeat;
|
1674 |
-
var ch = motionArgs.forward ? cur.ch + repeat : cur.ch - repeat;
|
1675 |
-
return Pos(cur.line, ch);
|
1676 |
-
},
|
1677 |
-
moveByLines: function(cm, head, motionArgs, vim) {
|
1678 |
-
var cur = head;
|
1679 |
-
var endCh = cur.ch;
|
1680 |
-
// Depending what our last motion was, we may want to do different
|
1681 |
-
// things. If our last motion was moving vertically, we want to
|
1682 |
-
// preserve the HPos from our last horizontal move. If our last motion
|
1683 |
-
// was going to the end of a line, moving vertically we should go to
|
1684 |
-
// the end of the line, etc.
|
1685 |
-
switch (vim.lastMotion) {
|
1686 |
-
case this.moveByLines:
|
1687 |
-
case this.moveByDisplayLines:
|
1688 |
-
case this.moveByScroll:
|
1689 |
-
case this.moveToColumn:
|
1690 |
-
case this.moveToEol:
|
1691 |
-
endCh = vim.lastHPos;
|
1692 |
-
break;
|
1693 |
-
default:
|
1694 |
-
vim.lastHPos = endCh;
|
1695 |
-
}
|
1696 |
-
var repeat = motionArgs.repeat+(motionArgs.repeatOffset||0);
|
1697 |
-
var line = motionArgs.forward ? cur.line + repeat : cur.line - repeat;
|
1698 |
-
var first = cm.firstLine();
|
1699 |
-
var last = cm.lastLine();
|
1700 |
-
// Vim cancels linewise motions that start on an edge and move beyond
|
1701 |
-
// that edge. It does not cancel motions that do not start on an edge.
|
1702 |
-
if ((line < first && cur.line == first) ||
|
1703 |
-
(line > last && cur.line == last)) {
|
1704 |
-
return;
|
1705 |
-
}
|
1706 |
-
if (motionArgs.toFirstChar){
|
1707 |
-
endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));
|
1708 |
-
vim.lastHPos = endCh;
|
1709 |
-
}
|
1710 |
-
vim.lastHSPos = cm.charCoords(Pos(line, endCh),'div').left;
|
1711 |
-
return Pos(line, endCh);
|
1712 |
-
},
|
1713 |
-
moveByDisplayLines: function(cm, head, motionArgs, vim) {
|
1714 |
-
var cur = head;
|
1715 |
-
switch (vim.lastMotion) {
|
1716 |
-
case this.moveByDisplayLines:
|
1717 |
-
case this.moveByScroll:
|
1718 |
-
case this.moveByLines:
|
1719 |
-
case this.moveToColumn:
|
1720 |
-
case this.moveToEol:
|
1721 |
-
break;
|
1722 |
-
default:
|
1723 |
-
vim.lastHSPos = cm.charCoords(cur,'div').left;
|
1724 |
-
}
|
1725 |
-
var repeat = motionArgs.repeat;
|
1726 |
-
var res=cm.findPosV(cur,(motionArgs.forward ? repeat : -repeat),'line',vim.lastHSPos);
|
1727 |
-
if (res.hitSide) {
|
1728 |
-
if (motionArgs.forward) {
|
1729 |
-
var lastCharCoords = cm.charCoords(res, 'div');
|
1730 |
-
var goalCoords = { top: lastCharCoords.top + 8, left: vim.lastHSPos };
|
1731 |
-
var res = cm.coordsChar(goalCoords, 'div');
|
1732 |
-
} else {
|
1733 |
-
var resCoords = cm.charCoords(Pos(cm.firstLine(), 0), 'div');
|
1734 |
-
resCoords.left = vim.lastHSPos;
|
1735 |
-
res = cm.coordsChar(resCoords, 'div');
|
1736 |
-
}
|
1737 |
-
}
|
1738 |
-
vim.lastHPos = res.ch;
|
1739 |
-
return res;
|
1740 |
-
},
|
1741 |
-
moveByPage: function(cm, head, motionArgs) {
|
1742 |
-
// CodeMirror only exposes functions that move the cursor page down, so
|
1743 |
-
// doing this bad hack to move the cursor and move it back. evalInput
|
1744 |
-
// will move the cursor to where it should be in the end.
|
1745 |
-
var curStart = head;
|
1746 |
-
var repeat = motionArgs.repeat;
|
1747 |
-
return cm.findPosV(curStart, (motionArgs.forward ? repeat : -repeat), 'page');
|
1748 |
-
},
|
1749 |
-
moveByParagraph: function(cm, head, motionArgs) {
|
1750 |
-
var dir = motionArgs.forward ? 1 : -1;
|
1751 |
-
return findParagraph(cm, head, motionArgs.repeat, dir);
|
1752 |
-
},
|
1753 |
-
moveByScroll: function(cm, head, motionArgs, vim) {
|
1754 |
-
var scrollbox = cm.getScrollInfo();
|
1755 |
-
var curEnd = null;
|
1756 |
-
var repeat = motionArgs.repeat;
|
1757 |
-
if (!repeat) {
|
1758 |
-
repeat = scrollbox.clientHeight / (2 * cm.defaultTextHeight());
|
1759 |
-
}
|
1760 |
-
var orig = cm.charCoords(head, 'local');
|
1761 |
-
motionArgs.repeat = repeat;
|
1762 |
-
var curEnd = motions.moveByDisplayLines(cm, head, motionArgs, vim);
|
1763 |
-
if (!curEnd) {
|
1764 |
-
return null;
|
1765 |
-
}
|
1766 |
-
var dest = cm.charCoords(curEnd, 'local');
|
1767 |
-
cm.scrollTo(null, scrollbox.top + dest.top - orig.top);
|
1768 |
-
return curEnd;
|
1769 |
-
},
|
1770 |
-
moveByWords: function(cm, head, motionArgs) {
|
1771 |
-
return moveToWord(cm, head, motionArgs.repeat, !!motionArgs.forward,
|
1772 |
-
!!motionArgs.wordEnd, !!motionArgs.bigWord);
|
1773 |
-
},
|
1774 |
-
moveTillCharacter: function(cm, _head, motionArgs) {
|
1775 |
-
var repeat = motionArgs.repeat;
|
1776 |
-
var curEnd = moveToCharacter(cm, repeat, motionArgs.forward,
|
1777 |
-
motionArgs.selectedCharacter);
|
1778 |
-
var increment = motionArgs.forward ? -1 : 1;
|
1779 |
-
recordLastCharacterSearch(increment, motionArgs);
|
1780 |
-
if (!curEnd) return null;
|
1781 |
-
curEnd.ch += increment;
|
1782 |
-
return curEnd;
|
1783 |
-
},
|
1784 |
-
moveToCharacter: function(cm, head, motionArgs) {
|
1785 |
-
var repeat = motionArgs.repeat;
|
1786 |
-
recordLastCharacterSearch(0, motionArgs);
|
1787 |
-
return moveToCharacter(cm, repeat, motionArgs.forward,
|
1788 |
-
motionArgs.selectedCharacter) || head;
|
1789 |
-
},
|
1790 |
-
moveToSymbol: function(cm, head, motionArgs) {
|
1791 |
-
var repeat = motionArgs.repeat;
|
1792 |
-
return findSymbol(cm, repeat, motionArgs.forward,
|
1793 |
-
motionArgs.selectedCharacter) || head;
|
1794 |
-
},
|
1795 |
-
moveToColumn: function(cm, head, motionArgs, vim) {
|
1796 |
-
var repeat = motionArgs.repeat;
|
1797 |
-
// repeat is equivalent to which column we want to move to!
|
1798 |
-
vim.lastHPos = repeat - 1;
|
1799 |
-
vim.lastHSPos = cm.charCoords(head,'div').left;
|
1800 |
-
return moveToColumn(cm, repeat);
|
1801 |
-
},
|
1802 |
-
moveToEol: function(cm, head, motionArgs, vim) {
|
1803 |
-
var cur = head;
|
1804 |
-
vim.lastHPos = Infinity;
|
1805 |
-
var retval= Pos(cur.line + motionArgs.repeat - 1, Infinity);
|
1806 |
-
var end=cm.clipPos(retval);
|
1807 |
-
end.ch--;
|
1808 |
-
vim.lastHSPos = cm.charCoords(end,'div').left;
|
1809 |
-
return retval;
|
1810 |
-
},
|
1811 |
-
moveToFirstNonWhiteSpaceCharacter: function(cm, head) {
|
1812 |
-
// Go to the start of the line where the text begins, or the end for
|
1813 |
-
// whitespace-only lines
|
1814 |
-
var cursor = head;
|
1815 |
-
return Pos(cursor.line,
|
1816 |
-
findFirstNonWhiteSpaceCharacter(cm.getLine(cursor.line)));
|
1817 |
-
},
|
1818 |
-
moveToMatchedSymbol: function(cm, head) {
|
1819 |
-
var cursor = head;
|
1820 |
-
var line = cursor.line;
|
1821 |
-
var ch = cursor.ch;
|
1822 |
-
var lineText = cm.getLine(line);
|
1823 |
-
var symbol;
|
1824 |
-
do {
|
1825 |
-
symbol = lineText.charAt(ch++);
|
1826 |
-
if (symbol && isMatchableSymbol(symbol)) {
|
1827 |
-
var style = cm.getTokenTypeAt(Pos(line, ch));
|
1828 |
-
if (style !== "string" && style !== "comment") {
|
1829 |
-
break;
|
1830 |
-
}
|
1831 |
-
}
|
1832 |
-
} while (symbol);
|
1833 |
-
if (symbol) {
|
1834 |
-
var matched = cm.findMatchingBracket(Pos(line, ch));
|
1835 |
-
return matched.to;
|
1836 |
-
} else {
|
1837 |
-
return cursor;
|
1838 |
-
}
|
1839 |
-
},
|
1840 |
-
moveToStartOfLine: function(_cm, head) {
|
1841 |
-
return Pos(head.line, 0);
|
1842 |
-
},
|
1843 |
-
moveToLineOrEdgeOfDocument: function(cm, _head, motionArgs) {
|
1844 |
-
var lineNum = motionArgs.forward ? cm.lastLine() : cm.firstLine();
|
1845 |
-
if (motionArgs.repeatIsExplicit) {
|
1846 |
-
lineNum = motionArgs.repeat - cm.getOption('firstLineNumber');
|
1847 |
-
}
|
1848 |
-
return Pos(lineNum,
|
1849 |
-
findFirstNonWhiteSpaceCharacter(cm.getLine(lineNum)));
|
1850 |
-
},
|
1851 |
-
textObjectManipulation: function(cm, head, motionArgs, vim) {
|
1852 |
-
// TODO: lots of possible exceptions that can be thrown here. Try da(
|
1853 |
-
// outside of a () block.
|
1854 |
-
|
1855 |
-
// TODO: adding <> >< to this map doesn't work, presumably because
|
1856 |
-
// they're operators
|
1857 |
-
var mirroredPairs = {'(': ')', ')': '(',
|
1858 |
-
'{': '}', '}': '{',
|
1859 |
-
'[': ']', ']': '['};
|
1860 |
-
var selfPaired = {'\'': true, '"': true};
|
1861 |
-
|
1862 |
-
var character = motionArgs.selectedCharacter;
|
1863 |
-
// 'b' refers to '()' block.
|
1864 |
-
// 'B' refers to '{}' block.
|
1865 |
-
if (character == 'b') {
|
1866 |
-
character = '(';
|
1867 |
-
} else if (character == 'B') {
|
1868 |
-
character = '{';
|
1869 |
-
}
|
1870 |
-
|
1871 |
-
// Inclusive is the difference between a and i
|
1872 |
-
// TODO: Instead of using the additional text object map to perform text
|
1873 |
-
// object operations, merge the map into the defaultKeyMap and use
|
1874 |
-
// motionArgs to define behavior. Define separate entries for 'aw',
|
1875 |
-
// 'iw', 'a[', 'i[', etc.
|
1876 |
-
var inclusive = !motionArgs.textObjectInner;
|
1877 |
-
|
1878 |
-
var tmp;
|
1879 |
-
if (mirroredPairs[character]) {
|
1880 |
-
tmp = selectCompanionObject(cm, head, character, inclusive);
|
1881 |
-
} else if (selfPaired[character]) {
|
1882 |
-
tmp = findBeginningAndEnd(cm, head, character, inclusive);
|
1883 |
-
} else if (character === 'W') {
|
1884 |
-
tmp = expandWordUnderCursor(cm, inclusive, true /** forward */,
|
1885 |
-
true /** bigWord */);
|
1886 |
-
} else if (character === 'w') {
|
1887 |
-
tmp = expandWordUnderCursor(cm, inclusive, true /** forward */,
|
1888 |
-
false /** bigWord */);
|
1889 |
-
} else if (character === 'p') {
|
1890 |
-
tmp = findParagraph(cm, head, motionArgs.repeat, 0, inclusive);
|
1891 |
-
motionArgs.linewise = true;
|
1892 |
-
if (vim.visualMode) {
|
1893 |
-
if (!vim.visualLine) { vim.visualLine = true; }
|
1894 |
-
} else {
|
1895 |
-
var operatorArgs = vim.inputState.operatorArgs;
|
1896 |
-
if (operatorArgs) { operatorArgs.linewise = true; }
|
1897 |
-
tmp.end.line--;
|
1898 |
-
}
|
1899 |
-
} else {
|
1900 |
-
// No text object defined for this, don't move.
|
1901 |
-
return null;
|
1902 |
-
}
|
1903 |
-
|
1904 |
-
if (!cm.state.vim.visualMode) {
|
1905 |
-
return [tmp.start, tmp.end];
|
1906 |
-
} else {
|
1907 |
-
return expandSelection(cm, tmp.start, tmp.end);
|
1908 |
-
}
|
1909 |
-
},
|
1910 |
-
|
1911 |
-
repeatLastCharacterSearch: function(cm, head, motionArgs) {
|
1912 |
-
var lastSearch = vimGlobalState.lastChararacterSearch;
|
1913 |
-
var repeat = motionArgs.repeat;
|
1914 |
-
var forward = motionArgs.forward === lastSearch.forward;
|
1915 |
-
var increment = (lastSearch.increment ? 1 : 0) * (forward ? -1 : 1);
|
1916 |
-
cm.moveH(-increment, 'char');
|
1917 |
-
motionArgs.inclusive = forward ? true : false;
|
1918 |
-
var curEnd = moveToCharacter(cm, repeat, forward, lastSearch.selectedCharacter);
|
1919 |
-
if (!curEnd) {
|
1920 |
-
cm.moveH(increment, 'char');
|
1921 |
-
return head;
|
1922 |
-
}
|
1923 |
-
curEnd.ch += increment;
|
1924 |
-
return curEnd;
|
1925 |
-
}
|
1926 |
-
};
|
1927 |
-
|
1928 |
-
function defineMotion(name, fn) {
|
1929 |
-
motions[name] = fn;
|
1930 |
-
}
|
1931 |
-
|
1932 |
-
function fillArray(val, times) {
|
1933 |
-
var arr = [];
|
1934 |
-
for (var i = 0; i < times; i++) {
|
1935 |
-
arr.push(val);
|
1936 |
-
}
|
1937 |
-
return arr;
|
1938 |
-
}
|
1939 |
-
/**
|
1940 |
-
* An operator acts on a text selection. It receives the list of selections
|
1941 |
-
* as input. The corresponding CodeMirror selection is guaranteed to
|
1942 |
-
* match the input selection.
|
1943 |
-
*/
|
1944 |
-
var operators = {
|
1945 |
-
change: function(cm, args, ranges) {
|
1946 |
-
var finalHead, text;
|
1947 |
-
var vim = cm.state.vim;
|
1948 |
-
vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock = vim.visualBlock;
|
1949 |
-
if (!vim.visualMode) {
|
1950 |
-
var anchor = ranges[0].anchor,
|
1951 |
-
head = ranges[0].head;
|
1952 |
-
text = cm.getRange(anchor, head);
|
1953 |
-
var lastState = vim.lastEditInputState || {};
|
1954 |
-
if (lastState.motion == "moveByWords" && !isWhiteSpaceString(text)) {
|
1955 |
-
// Exclude trailing whitespace if the range is not all whitespace.
|
1956 |
-
var match = (/\s+$/).exec(text);
|
1957 |
-
if (match && lastState.motionArgs && lastState.motionArgs.forward) {
|
1958 |
-
head = offsetCursor(head, 0, - match[0].length);
|
1959 |
-
text = text.slice(0, - match[0].length);
|
1960 |
-
}
|
1961 |
-
}
|
1962 |
-
var wasLastLine = head.line - 1 == cm.lastLine();
|
1963 |
-
cm.replaceRange('', anchor, head);
|
1964 |
-
if (args.linewise && !wasLastLine) {
|
1965 |
-
// Push the next line back down, if there is a next line.
|
1966 |
-
CodeMirror.commands.newlineAndIndent(cm);
|
1967 |
-
// null ch so setCursor moves to end of line.
|
1968 |
-
anchor.ch = null;
|
1969 |
-
}
|
1970 |
-
finalHead = anchor;
|
1971 |
-
} else {
|
1972 |
-
text = cm.getSelection();
|
1973 |
-
var replacement = fillArray('', ranges.length);
|
1974 |
-
cm.replaceSelections(replacement);
|
1975 |
-
finalHead = cursorMin(ranges[0].head, ranges[0].anchor);
|
1976 |
-
}
|
1977 |
-
vimGlobalState.registerController.pushText(
|
1978 |
-
args.registerName, 'change', text,
|
1979 |
-
args.linewise, ranges.length > 1);
|
1980 |
-
actions.enterInsertMode(cm, {head: finalHead}, cm.state.vim);
|
1981 |
-
},
|
1982 |
-
// delete is a javascript keyword.
|
1983 |
-
'delete': function(cm, args, ranges) {
|
1984 |
-
var finalHead, text;
|
1985 |
-
var vim = cm.state.vim;
|
1986 |
-
if (!vim.visualBlock) {
|
1987 |
-
var anchor = ranges[0].anchor,
|
1988 |
-
head = ranges[0].head;
|
1989 |
-
if (args.linewise &&
|
1990 |
-
head.line != cm.firstLine() &&
|
1991 |
-
anchor.line == cm.lastLine() &&
|
1992 |
-
anchor.line == head.line - 1) {
|
1993 |
-
// Special case for dd on last line (and first line).
|
1994 |
-
if (anchor.line == cm.firstLine()) {
|
1995 |
-
anchor.ch = 0;
|
1996 |
-
} else {
|
1997 |
-
anchor = Pos(anchor.line - 1, lineLength(cm, anchor.line - 1));
|
1998 |
-
}
|
1999 |
-
}
|
2000 |
-
text = cm.getRange(anchor, head);
|
2001 |
-
cm.replaceRange('', anchor, head);
|
2002 |
-
finalHead = anchor;
|
2003 |
-
if (args.linewise) {
|
2004 |
-
finalHead = motions.moveToFirstNonWhiteSpaceCharacter(cm, anchor);
|
2005 |
-
}
|
2006 |
-
} else {
|
2007 |
-
text = cm.getSelection();
|
2008 |
-
var replacement = fillArray('', ranges.length);
|
2009 |
-
cm.replaceSelections(replacement);
|
2010 |
-
finalHead = ranges[0].anchor;
|
2011 |
-
}
|
2012 |
-
vimGlobalState.registerController.pushText(
|
2013 |
-
args.registerName, 'delete', text,
|
2014 |
-
args.linewise, vim.visualBlock);
|
2015 |
-
return clipCursorToContent(cm, finalHead);
|
2016 |
-
},
|
2017 |
-
indent: function(cm, args, ranges) {
|
2018 |
-
var vim = cm.state.vim;
|
2019 |
-
var startLine = ranges[0].anchor.line;
|
2020 |
-
var endLine = vim.visualBlock ?
|
2021 |
-
ranges[ranges.length - 1].anchor.line :
|
2022 |
-
ranges[0].head.line;
|
2023 |
-
// In visual mode, n> shifts the selection right n times, instead of
|
2024 |
-
// shifting n lines right once.
|
2025 |
-
var repeat = (vim.visualMode) ? args.repeat : 1;
|
2026 |
-
if (args.linewise) {
|
2027 |
-
// The only way to delete a newline is to delete until the start of
|
2028 |
-
// the next line, so in linewise mode evalInput will include the next
|
2029 |
-
// line. We don't want this in indent, so we go back a line.
|
2030 |
-
endLine--;
|
2031 |
-
}
|
2032 |
-
for (var i = startLine; i <= endLine; i++) {
|
2033 |
-
for (var j = 0; j < repeat; j++) {
|
2034 |
-
cm.indentLine(i, args.indentRight);
|
2035 |
-
}
|
2036 |
-
}
|
2037 |
-
return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor);
|
2038 |
-
},
|
2039 |
-
changeCase: function(cm, args, ranges, oldAnchor, newHead) {
|
2040 |
-
var selections = cm.getSelections();
|
2041 |
-
var swapped = [];
|
2042 |
-
var toLower = args.toLower;
|
2043 |
-
for (var j = 0; j < selections.length; j++) {
|
2044 |
-
var toSwap = selections[j];
|
2045 |
-
var text = '';
|
2046 |
-
if (toLower === true) {
|
2047 |
-
text = toSwap.toLowerCase();
|
2048 |
-
} else if (toLower === false) {
|
2049 |
-
text = toSwap.toUpperCase();
|
2050 |
-
} else {
|
2051 |
-
for (var i = 0; i < toSwap.length; i++) {
|
2052 |
-
var character = toSwap.charAt(i);
|
2053 |
-
text += isUpperCase(character) ? character.toLowerCase() :
|
2054 |
-
character.toUpperCase();
|
2055 |
-
}
|
2056 |
-
}
|
2057 |
-
swapped.push(text);
|
2058 |
-
}
|
2059 |
-
cm.replaceSelections(swapped);
|
2060 |
-
if (args.shouldMoveCursor){
|
2061 |
-
return newHead;
|
2062 |
-
} else if (!cm.state.vim.visualMode && args.linewise && ranges[0].anchor.line + 1 == ranges[0].head.line) {
|
2063 |
-
return motions.moveToFirstNonWhiteSpaceCharacter(cm, oldAnchor);
|
2064 |
-
} else if (args.linewise){
|
2065 |
-
return oldAnchor;
|
2066 |
-
} else {
|
2067 |
-
return cursorMin(ranges[0].anchor, ranges[0].head);
|
2068 |
-
}
|
2069 |
-
},
|
2070 |
-
yank: function(cm, args, ranges, oldAnchor) {
|
2071 |
-
var vim = cm.state.vim;
|
2072 |
-
var text = cm.getSelection();
|
2073 |
-
var endPos = vim.visualMode
|
2074 |
-
? cursorMin(vim.sel.anchor, vim.sel.head, ranges[0].head, ranges[0].anchor)
|
2075 |
-
: oldAnchor;
|
2076 |
-
vimGlobalState.registerController.pushText(
|
2077 |
-
args.registerName, 'yank',
|
2078 |
-
text, args.linewise, vim.visualBlock);
|
2079 |
-
return endPos;
|
2080 |
-
}
|
2081 |
-
};
|
2082 |
-
|
2083 |
-
function defineOperator(name, fn) {
|
2084 |
-
operators[name] = fn;
|
2085 |
-
}
|
2086 |
-
|
2087 |
-
var actions = {
|
2088 |
-
jumpListWalk: function(cm, actionArgs, vim) {
|
2089 |
-
if (vim.visualMode) {
|
2090 |
-
return;
|
2091 |
-
}
|
2092 |
-
var repeat = actionArgs.repeat;
|
2093 |
-
var forward = actionArgs.forward;
|
2094 |
-
var jumpList = vimGlobalState.jumpList;
|
2095 |
-
|
2096 |
-
var mark = jumpList.move(cm, forward ? repeat : -repeat);
|
2097 |
-
var markPos = mark ? mark.find() : undefined;
|
2098 |
-
markPos = markPos ? markPos : cm.getCursor();
|
2099 |
-
cm.setCursor(markPos);
|
2100 |
-
},
|
2101 |
-
scroll: function(cm, actionArgs, vim) {
|
2102 |
-
if (vim.visualMode) {
|
2103 |
-
return;
|
2104 |
-
}
|
2105 |
-
var repeat = actionArgs.repeat || 1;
|
2106 |
-
var lineHeight = cm.defaultTextHeight();
|
2107 |
-
var top = cm.getScrollInfo().top;
|
2108 |
-
var delta = lineHeight * repeat;
|
2109 |
-
var newPos = actionArgs.forward ? top + delta : top - delta;
|
2110 |
-
var cursor = copyCursor(cm.getCursor());
|
2111 |
-
var cursorCoords = cm.charCoords(cursor, 'local');
|
2112 |
-
if (actionArgs.forward) {
|
2113 |
-
if (newPos > cursorCoords.top) {
|
2114 |
-
cursor.line += (newPos - cursorCoords.top) / lineHeight;
|
2115 |
-
cursor.line = Math.ceil(cursor.line);
|
2116 |
-
cm.setCursor(cursor);
|
2117 |
-
cursorCoords = cm.charCoords(cursor, 'local');
|
2118 |
-
cm.scrollTo(null, cursorCoords.top);
|
2119 |
-
} else {
|
2120 |
-
// Cursor stays within bounds. Just reposition the scroll window.
|
2121 |
-
cm.scrollTo(null, newPos);
|
2122 |
-
}
|
2123 |
-
} else {
|
2124 |
-
var newBottom = newPos + cm.getScrollInfo().clientHeight;
|
2125 |
-
if (newBottom < cursorCoords.bottom) {
|
2126 |
-
cursor.line -= (cursorCoords.bottom - newBottom) / lineHeight;
|
2127 |
-
cursor.line = Math.floor(cursor.line);
|
2128 |
-
cm.setCursor(cursor);
|
2129 |
-
cursorCoords = cm.charCoords(cursor, 'local');
|
2130 |
-
cm.scrollTo(
|
2131 |
-
null, cursorCoords.bottom - cm.getScrollInfo().clientHeight);
|
2132 |
-
} else {
|
2133 |
-
// Cursor stays within bounds. Just reposition the scroll window.
|
2134 |
-
cm.scrollTo(null, newPos);
|
2135 |
-
}
|
2136 |
-
}
|
2137 |
-
},
|
2138 |
-
scrollToCursor: function(cm, actionArgs) {
|
2139 |
-
var lineNum = cm.getCursor().line;
|
2140 |
-
var charCoords = cm.charCoords(Pos(lineNum, 0), 'local');
|
2141 |
-
var height = cm.getScrollInfo().clientHeight;
|
2142 |
-
var y = charCoords.top;
|
2143 |
-
var lineHeight = charCoords.bottom - y;
|
2144 |
-
switch (actionArgs.position) {
|
2145 |
-
case 'center': y = y - (height / 2) + lineHeight;
|
2146 |
-
break;
|
2147 |
-
case 'bottom': y = y - height + lineHeight*1.4;
|
2148 |
-
break;
|
2149 |
-
case 'top': y = y + lineHeight*0.4;
|
2150 |
-
break;
|
2151 |
-
}
|
2152 |
-
cm.scrollTo(null, y);
|
2153 |
-
},
|
2154 |
-
replayMacro: function(cm, actionArgs, vim) {
|
2155 |
-
var registerName = actionArgs.selectedCharacter;
|
2156 |
-
var repeat = actionArgs.repeat;
|
2157 |
-
var macroModeState = vimGlobalState.macroModeState;
|
2158 |
-
if (registerName == '@') {
|
2159 |
-
registerName = macroModeState.latestRegister;
|
2160 |
-
}
|
2161 |
-
while(repeat--){
|
2162 |
-
executeMacroRegister(cm, vim, macroModeState, registerName);
|
2163 |
-
}
|
2164 |
-
},
|
2165 |
-
enterMacroRecordMode: function(cm, actionArgs) {
|
2166 |
-
var macroModeState = vimGlobalState.macroModeState;
|
2167 |
-
var registerName = actionArgs.selectedCharacter;
|
2168 |
-
macroModeState.enterMacroRecordMode(cm, registerName);
|
2169 |
-
},
|
2170 |
-
enterInsertMode: function(cm, actionArgs, vim) {
|
2171 |
-
if (cm.getOption('readOnly')) { return; }
|
2172 |
-
vim.insertMode = true;
|
2173 |
-
vim.insertModeRepeat = actionArgs && actionArgs.repeat || 1;
|
2174 |
-
var insertAt = (actionArgs) ? actionArgs.insertAt : null;
|
2175 |
-
var sel = vim.sel;
|
2176 |
-
var head = actionArgs.head || cm.getCursor('head');
|
2177 |
-
var height = cm.listSelections().length;
|
2178 |
-
if (insertAt == 'eol') {
|
2179 |
-
head = Pos(head.line, lineLength(cm, head.line));
|
2180 |
-
} else if (insertAt == 'charAfter') {
|
2181 |
-
head = offsetCursor(head, 0, 1);
|
2182 |
-
} else if (insertAt == 'firstNonBlank') {
|
2183 |
-
head = motions.moveToFirstNonWhiteSpaceCharacter(cm, head);
|
2184 |
-
} else if (insertAt == 'startOfSelectedArea') {
|
2185 |
-
if (!vim.visualBlock) {
|
2186 |
-
if (sel.head.line < sel.anchor.line) {
|
2187 |
-
head = sel.head;
|
2188 |
-
} else {
|
2189 |
-
head = Pos(sel.anchor.line, 0);
|
2190 |
-
}
|
2191 |
-
} else {
|
2192 |
-
head = Pos(
|
2193 |
-
Math.min(sel.head.line, sel.anchor.line),
|
2194 |
-
Math.min(sel.head.ch, sel.anchor.ch));
|
2195 |
-
height = Math.abs(sel.head.line - sel.anchor.line) + 1;
|
2196 |
-
}
|
2197 |
-
} else if (insertAt == 'endOfSelectedArea') {
|
2198 |
-
if (!vim.visualBlock) {
|
2199 |
-
if (sel.head.line >= sel.anchor.line) {
|
2200 |
-
head = offsetCursor(sel.head, 0, 1);
|
2201 |
-
} else {
|
2202 |
-
head = Pos(sel.anchor.line, 0);
|
2203 |
-
}
|
2204 |
-
} else {
|
2205 |
-
head = Pos(
|
2206 |
-
Math.min(sel.head.line, sel.anchor.line),
|
2207 |
-
Math.max(sel.head.ch + 1, sel.anchor.ch));
|
2208 |
-
height = Math.abs(sel.head.line - sel.anchor.line) + 1;
|
2209 |
-
}
|
2210 |
-
} else if (insertAt == 'inplace') {
|
2211 |
-
if (vim.visualMode){
|
2212 |
-
return;
|
2213 |
-
}
|
2214 |
-
}
|
2215 |
-
cm.setOption('keyMap', 'vim-insert');
|
2216 |
-
cm.setOption('disableInput', false);
|
2217 |
-
if (actionArgs && actionArgs.replace) {
|
2218 |
-
// Handle Replace-mode as a special case of insert mode.
|
2219 |
-
cm.toggleOverwrite(true);
|
2220 |
-
cm.setOption('keyMap', 'vim-replace');
|
2221 |
-
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
|
2222 |
-
} else {
|
2223 |
-
cm.setOption('keyMap', 'vim-insert');
|
2224 |
-
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
|
2225 |
-
}
|
2226 |
-
if (!vimGlobalState.macroModeState.isPlaying) {
|
2227 |
-
// Only record if not replaying.
|
2228 |
-
cm.on('change', onChange);
|
2229 |
-
CodeMirror.on(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown);
|
2230 |
-
}
|
2231 |
-
if (vim.visualMode) {
|
2232 |
-
exitVisualMode(cm);
|
2233 |
-
}
|
2234 |
-
selectForInsert(cm, head, height);
|
2235 |
-
},
|
2236 |
-
toggleVisualMode: function(cm, actionArgs, vim) {
|
2237 |
-
var repeat = actionArgs.repeat;
|
2238 |
-
var anchor = cm.getCursor();
|
2239 |
-
var head;
|
2240 |
-
// TODO: The repeat should actually select number of characters/lines
|
2241 |
-
// equal to the repeat times the size of the previous visual
|
2242 |
-
// operation.
|
2243 |
-
if (!vim.visualMode) {
|
2244 |
-
// Entering visual mode
|
2245 |
-
vim.visualMode = true;
|
2246 |
-
vim.visualLine = !!actionArgs.linewise;
|
2247 |
-
vim.visualBlock = !!actionArgs.blockwise;
|
2248 |
-
head = clipCursorToContent(
|
2249 |
-
cm, Pos(anchor.line, anchor.ch + repeat - 1),
|
2250 |
-
true /** includeLineBreak */);
|
2251 |
-
vim.sel = {
|
2252 |
-
anchor: anchor,
|
2253 |
-
head: head
|
2254 |
-
};
|
2255 |
-
CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: vim.visualLine ? "linewise" : vim.visualBlock ? "blockwise" : ""});
|
2256 |
-
updateCmSelection(cm);
|
2257 |
-
updateMark(cm, vim, '<', cursorMin(anchor, head));
|
2258 |
-
updateMark(cm, vim, '>', cursorMax(anchor, head));
|
2259 |
-
} else if (vim.visualLine ^ actionArgs.linewise ||
|
2260 |
-
vim.visualBlock ^ actionArgs.blockwise) {
|
2261 |
-
// Toggling between modes
|
2262 |
-
vim.visualLine = !!actionArgs.linewise;
|
2263 |
-
vim.visualBlock = !!actionArgs.blockwise;
|
2264 |
-
CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: vim.visualLine ? "linewise" : vim.visualBlock ? "blockwise" : ""});
|
2265 |
-
updateCmSelection(cm);
|
2266 |
-
} else {
|
2267 |
-
exitVisualMode(cm);
|
2268 |
-
}
|
2269 |
-
},
|
2270 |
-
reselectLastSelection: function(cm, _actionArgs, vim) {
|
2271 |
-
var lastSelection = vim.lastSelection;
|
2272 |
-
if (vim.visualMode) {
|
2273 |
-
updateLastSelection(cm, vim);
|
2274 |
-
}
|
2275 |
-
if (lastSelection) {
|
2276 |
-
var anchor = lastSelection.anchorMark.find();
|
2277 |
-
var head = lastSelection.headMark.find();
|
2278 |
-
if (!anchor || !head) {
|
2279 |
-
// If the marks have been destroyed due to edits, do nothing.
|
2280 |
-
return;
|
2281 |
-
}
|
2282 |
-
vim.sel = {
|
2283 |
-
anchor: anchor,
|
2284 |
-
head: head
|
2285 |
-
};
|
2286 |
-
vim.visualMode = true;
|
2287 |
-
vim.visualLine = lastSelection.visualLine;
|
2288 |
-
vim.visualBlock = lastSelection.visualBlock;
|
2289 |
-
updateCmSelection(cm);
|
2290 |
-
updateMark(cm, vim, '<', cursorMin(anchor, head));
|
2291 |
-
updateMark(cm, vim, '>', cursorMax(anchor, head));
|
2292 |
-
CodeMirror.signal(cm, 'vim-mode-change', {
|
2293 |
-
mode: 'visual',
|
2294 |
-
subMode: vim.visualLine ? 'linewise' :
|
2295 |
-
vim.visualBlock ? 'blockwise' : ''});
|
2296 |
-
}
|
2297 |
-
},
|
2298 |
-
joinLines: function(cm, actionArgs, vim) {
|
2299 |
-
var curStart, curEnd;
|
2300 |
-
if (vim.visualMode) {
|
2301 |
-
curStart = cm.getCursor('anchor');
|
2302 |
-
curEnd = cm.getCursor('head');
|
2303 |
-
if (cursorIsBefore(curEnd, curStart)) {
|
2304 |
-
var tmp = curEnd;
|
2305 |
-
curEnd = curStart;
|
2306 |
-
curStart = tmp;
|
2307 |
-
}
|
2308 |
-
curEnd.ch = lineLength(cm, curEnd.line) - 1;
|
2309 |
-
} else {
|
2310 |
-
// Repeat is the number of lines to join. Minimum 2 lines.
|
2311 |
-
var repeat = Math.max(actionArgs.repeat, 2);
|
2312 |
-
curStart = cm.getCursor();
|
2313 |
-
curEnd = clipCursorToContent(cm, Pos(curStart.line + repeat - 1,
|
2314 |
-
Infinity));
|
2315 |
-
}
|
2316 |
-
var finalCh = 0;
|
2317 |
-
for (var i = curStart.line; i < curEnd.line; i++) {
|
2318 |
-
finalCh = lineLength(cm, curStart.line);
|
2319 |
-
var tmp = Pos(curStart.line + 1,
|
2320 |
-
lineLength(cm, curStart.line + 1));
|
2321 |
-
var text = cm.getRange(curStart, tmp);
|
2322 |
-
text = text.replace(/\n\s*/g, ' ');
|
2323 |
-
cm.replaceRange(text, curStart, tmp);
|
2324 |
-
}
|
2325 |
-
var curFinalPos = Pos(curStart.line, finalCh);
|
2326 |
-
if (vim.visualMode) {
|
2327 |
-
exitVisualMode(cm, false);
|
2328 |
-
}
|
2329 |
-
cm.setCursor(curFinalPos);
|
2330 |
-
},
|
2331 |
-
newLineAndEnterInsertMode: function(cm, actionArgs, vim) {
|
2332 |
-
vim.insertMode = true;
|
2333 |
-
var insertAt = copyCursor(cm.getCursor());
|
2334 |
-
if (insertAt.line === cm.firstLine() && !actionArgs.after) {
|
2335 |
-
// Special case for inserting newline before start of document.
|
2336 |
-
cm.replaceRange('\n', Pos(cm.firstLine(), 0));
|
2337 |
-
cm.setCursor(cm.firstLine(), 0);
|
2338 |
-
} else {
|
2339 |
-
insertAt.line = (actionArgs.after) ? insertAt.line :
|
2340 |
-
insertAt.line - 1;
|
2341 |
-
insertAt.ch = lineLength(cm, insertAt.line);
|
2342 |
-
cm.setCursor(insertAt);
|
2343 |
-
var newlineFn = CodeMirror.commands.newlineAndIndentContinueComment ||
|
2344 |
-
CodeMirror.commands.newlineAndIndent;
|
2345 |
-
newlineFn(cm);
|
2346 |
-
}
|
2347 |
-
this.enterInsertMode(cm, { repeat: actionArgs.repeat }, vim);
|
2348 |
-
},
|
2349 |
-
paste: function(cm, actionArgs, vim) {
|
2350 |
-
var cur = copyCursor(cm.getCursor());
|
2351 |
-
var register = vimGlobalState.registerController.getRegister(
|
2352 |
-
actionArgs.registerName);
|
2353 |
-
var text = register.toString();
|
2354 |
-
if (!text) {
|
2355 |
-
return;
|
2356 |
-
}
|
2357 |
-
if (actionArgs.matchIndent) {
|
2358 |
-
var tabSize = cm.getOption("tabSize");
|
2359 |
-
// length that considers tabs and tabSize
|
2360 |
-
var whitespaceLength = function(str) {
|
2361 |
-
var tabs = (str.split("\t").length - 1);
|
2362 |
-
var spaces = (str.split(" ").length - 1);
|
2363 |
-
return tabs * tabSize + spaces * 1;
|
2364 |
-
};
|
2365 |
-
var currentLine = cm.getLine(cm.getCursor().line);
|
2366 |
-
var indent = whitespaceLength(currentLine.match(/^\s*/)[0]);
|
2367 |
-
// chomp last newline b/c don't want it to match /^\s*/gm
|
2368 |
-
var chompedText = text.replace(/\n$/, '');
|
2369 |
-
var wasChomped = text !== chompedText;
|
2370 |
-
var firstIndent = whitespaceLength(text.match(/^\s*/)[0]);
|
2371 |
-
var text = chompedText.replace(/^\s*/gm, function(wspace) {
|
2372 |
-
var newIndent = indent + (whitespaceLength(wspace) - firstIndent);
|
2373 |
-
if (newIndent < 0) {
|
2374 |
-
return "";
|
2375 |
-
}
|
2376 |
-
else if (cm.getOption("indentWithTabs")) {
|
2377 |
-
var quotient = Math.floor(newIndent / tabSize);
|
2378 |
-
return Array(quotient + 1).join('\t');
|
2379 |
-
}
|
2380 |
-
else {
|
2381 |
-
return Array(newIndent + 1).join(' ');
|
2382 |
-
}
|
2383 |
-
});
|
2384 |
-
text += wasChomped ? "\n" : "";
|
2385 |
-
}
|
2386 |
-
if (actionArgs.repeat > 1) {
|
2387 |
-
var text = Array(actionArgs.repeat + 1).join(text);
|
2388 |
-
}
|
2389 |
-
var linewise = register.linewise;
|
2390 |
-
var blockwise = register.blockwise;
|
2391 |
-
if (linewise) {
|
2392 |
-
if(vim.visualMode) {
|
2393 |
-
text = vim.visualLine ? text.slice(0, -1) : '\n' + text.slice(0, text.length - 1) + '\n';
|
2394 |
-
} else if (actionArgs.after) {
|
2395 |
-
// Move the newline at the end to the start instead, and paste just
|
2396 |
-
// before the newline character of the line we are on right now.
|
2397 |
-
text = '\n' + text.slice(0, text.length - 1);
|
2398 |
-
cur.ch = lineLength(cm, cur.line);
|
2399 |
-
} else {
|
2400 |
-
cur.ch = 0;
|
2401 |
-
}
|
2402 |
-
} else {
|
2403 |
-
if (blockwise) {
|
2404 |
-
text = text.split('\n');
|
2405 |
-
for (var i = 0; i < text.length; i++) {
|
2406 |
-
text[i] = (text[i] == '') ? ' ' : text[i];
|
2407 |
-
}
|
2408 |
-
}
|
2409 |
-
cur.ch += actionArgs.after ? 1 : 0;
|
2410 |
-
}
|
2411 |
-
var curPosFinal;
|
2412 |
-
var idx;
|
2413 |
-
if (vim.visualMode) {
|
2414 |
-
// save the pasted text for reselection if the need arises
|
2415 |
-
vim.lastPastedText = text;
|
2416 |
-
var lastSelectionCurEnd;
|
2417 |
-
var selectedArea = getSelectedAreaRange(cm, vim);
|
2418 |
-
var selectionStart = selectedArea[0];
|
2419 |
-
var selectionEnd = selectedArea[1];
|
2420 |
-
var selectedText = cm.getSelection();
|
2421 |
-
var selections = cm.listSelections();
|
2422 |
-
var emptyStrings = new Array(selections.length).join('1').split('1');
|
2423 |
-
// save the curEnd marker before it get cleared due to cm.replaceRange.
|
2424 |
-
if (vim.lastSelection) {
|
2425 |
-
lastSelectionCurEnd = vim.lastSelection.headMark.find();
|
2426 |
-
}
|
2427 |
-
// push the previously selected text to unnamed register
|
2428 |
-
vimGlobalState.registerController.unnamedRegister.setText(selectedText);
|
2429 |
-
if (blockwise) {
|
2430 |
-
// first delete the selected text
|
2431 |
-
cm.replaceSelections(emptyStrings);
|
2432 |
-
// Set new selections as per the block length of the yanked text
|
2433 |
-
selectionEnd = Pos(selectionStart.line + text.length-1, selectionStart.ch);
|
2434 |
-
cm.setCursor(selectionStart);
|
2435 |
-
selectBlock(cm, selectionEnd);
|
2436 |
-
cm.replaceSelections(text);
|
2437 |
-
curPosFinal = selectionStart;
|
2438 |
-
} else if (vim.visualBlock) {
|
2439 |
-
cm.replaceSelections(emptyStrings);
|
2440 |
-
cm.setCursor(selectionStart);
|
2441 |
-
cm.replaceRange(text, selectionStart, selectionStart);
|
2442 |
-
curPosFinal = selectionStart;
|
2443 |
-
} else {
|
2444 |
-
cm.replaceRange(text, selectionStart, selectionEnd);
|
2445 |
-
curPosFinal = cm.posFromIndex(cm.indexFromPos(selectionStart) + text.length - 1);
|
2446 |
-
}
|
2447 |
-
// restore the the curEnd marker
|
2448 |
-
if(lastSelectionCurEnd) {
|
2449 |
-
vim.lastSelection.headMark = cm.setBookmark(lastSelectionCurEnd);
|
2450 |
-
}
|
2451 |
-
if (linewise) {
|
2452 |
-
curPosFinal.ch=0;
|
2453 |
-
}
|
2454 |
-
} else {
|
2455 |
-
if (blockwise) {
|
2456 |
-
cm.setCursor(cur);
|
2457 |
-
for (var i = 0; i < text.length; i++) {
|
2458 |
-
var line = cur.line+i;
|
2459 |
-
if (line > cm.lastLine()) {
|
2460 |
-
cm.replaceRange('\n', Pos(line, 0));
|
2461 |
-
}
|
2462 |
-
var lastCh = lineLength(cm, line);
|
2463 |
-
if (lastCh < cur.ch) {
|
2464 |
-
extendLineToColumn(cm, line, cur.ch);
|
2465 |
-
}
|
2466 |
-
}
|
2467 |
-
cm.setCursor(cur);
|
2468 |
-
selectBlock(cm, Pos(cur.line + text.length-1, cur.ch));
|
2469 |
-
cm.replaceSelections(text);
|
2470 |
-
curPosFinal = cur;
|
2471 |
-
} else {
|
2472 |
-
cm.replaceRange(text, cur);
|
2473 |
-
// Now fine tune the cursor to where we want it.
|
2474 |
-
if (linewise && actionArgs.after) {
|
2475 |
-
curPosFinal = Pos(
|
2476 |
-
cur.line + 1,
|
2477 |
-
findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line + 1)));
|
2478 |
-
} else if (linewise && !actionArgs.after) {
|
2479 |
-
curPosFinal = Pos(
|
2480 |
-
cur.line,
|
2481 |
-
findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line)));
|
2482 |
-
} else if (!linewise && actionArgs.after) {
|
2483 |
-
idx = cm.indexFromPos(cur);
|
2484 |
-
curPosFinal = cm.posFromIndex(idx + text.length - 1);
|
2485 |
-
} else {
|
2486 |
-
idx = cm.indexFromPos(cur);
|
2487 |
-
curPosFinal = cm.posFromIndex(idx + text.length);
|
2488 |
-
}
|
2489 |
-
}
|
2490 |
-
}
|
2491 |
-
if (vim.visualMode) {
|
2492 |
-
exitVisualMode(cm, false);
|
2493 |
-
}
|
2494 |
-
cm.setCursor(curPosFinal);
|
2495 |
-
},
|
2496 |
-
undo: function(cm, actionArgs) {
|
2497 |
-
cm.operation(function() {
|
2498 |
-
repeatFn(cm, CodeMirror.commands.undo, actionArgs.repeat)();
|
2499 |
-
cm.setCursor(cm.getCursor('anchor'));
|
2500 |
-
});
|
2501 |
-
},
|
2502 |
-
redo: function(cm, actionArgs) {
|
2503 |
-
repeatFn(cm, CodeMirror.commands.redo, actionArgs.repeat)();
|
2504 |
-
},
|
2505 |
-
setRegister: function(_cm, actionArgs, vim) {
|
2506 |
-
vim.inputState.registerName = actionArgs.selectedCharacter;
|
2507 |
-
},
|
2508 |
-
setMark: function(cm, actionArgs, vim) {
|
2509 |
-
var markName = actionArgs.selectedCharacter;
|
2510 |
-
updateMark(cm, vim, markName, cm.getCursor());
|
2511 |
-
},
|
2512 |
-
replace: function(cm, actionArgs, vim) {
|
2513 |
-
var replaceWith = actionArgs.selectedCharacter;
|
2514 |
-
var curStart = cm.getCursor();
|
2515 |
-
var replaceTo;
|
2516 |
-
var curEnd;
|
2517 |
-
var selections = cm.listSelections();
|
2518 |
-
if (vim.visualMode) {
|
2519 |
-
curStart = cm.getCursor('start');
|
2520 |
-
curEnd = cm.getCursor('end');
|
2521 |
-
} else {
|
2522 |
-
var line = cm.getLine(curStart.line);
|
2523 |
-
replaceTo = curStart.ch + actionArgs.repeat;
|
2524 |
-
if (replaceTo > line.length) {
|
2525 |
-
replaceTo=line.length;
|
2526 |
-
}
|
2527 |
-
curEnd = Pos(curStart.line, replaceTo);
|
2528 |
-
}
|
2529 |
-
if (replaceWith=='\n') {
|
2530 |
-
if (!vim.visualMode) cm.replaceRange('', curStart, curEnd);
|
2531 |
-
// special case, where vim help says to replace by just one line-break
|
2532 |
-
(CodeMirror.commands.newlineAndIndentContinueComment || CodeMirror.commands.newlineAndIndent)(cm);
|
2533 |
-
} else {
|
2534 |
-
var replaceWithStr = cm.getRange(curStart, curEnd);
|
2535 |
-
//replace all characters in range by selected, but keep linebreaks
|
2536 |
-
replaceWithStr = replaceWithStr.replace(/[^\n]/g, replaceWith);
|
2537 |
-
if (vim.visualBlock) {
|
2538 |
-
// Tabs are split in visua block before replacing
|
2539 |
-
var spaces = new Array(cm.getOption("tabSize")+1).join(' ');
|
2540 |
-
replaceWithStr = cm.getSelection();
|
2541 |
-
replaceWithStr = replaceWithStr.replace(/\t/g, spaces).replace(/[^\n]/g, replaceWith).split('\n');
|
2542 |
-
cm.replaceSelections(replaceWithStr);
|
2543 |
-
} else {
|
2544 |
-
cm.replaceRange(replaceWithStr, curStart, curEnd);
|
2545 |
-
}
|
2546 |
-
if (vim.visualMode) {
|
2547 |
-
curStart = cursorIsBefore(selections[0].anchor, selections[0].head) ?
|
2548 |
-
selections[0].anchor : selections[0].head;
|
2549 |
-
cm.setCursor(curStart);
|
2550 |
-
exitVisualMode(cm, false);
|
2551 |
-
} else {
|
2552 |
-
cm.setCursor(offsetCursor(curEnd, 0, -1));
|
2553 |
-
}
|
2554 |
-
}
|
2555 |
-
},
|
2556 |
-
incrementNumberToken: function(cm, actionArgs) {
|
2557 |
-
var cur = cm.getCursor();
|
2558 |
-
var lineStr = cm.getLine(cur.line);
|
2559 |
-
var re = /-?\d+/g;
|
2560 |
-
var match;
|
2561 |
-
var start;
|
2562 |
-
var end;
|
2563 |
-
var numberStr;
|
2564 |
-
var token;
|
2565 |
-
while ((match = re.exec(lineStr)) !== null) {
|
2566 |
-
token = match[0];
|
2567 |
-
start = match.index;
|
2568 |
-
end = start + token.length;
|
2569 |
-
if (cur.ch < end)break;
|
2570 |
-
}
|
2571 |
-
if (!actionArgs.backtrack && (end <= cur.ch))return;
|
2572 |
-
if (token) {
|
2573 |
-
var increment = actionArgs.increase ? 1 : -1;
|
2574 |
-
var number = parseInt(token) + (increment * actionArgs.repeat);
|
2575 |
-
var from = Pos(cur.line, start);
|
2576 |
-
var to = Pos(cur.line, end);
|
2577 |
-
numberStr = number.toString();
|
2578 |
-
cm.replaceRange(numberStr, from, to);
|
2579 |
-
} else {
|
2580 |
-
return;
|
2581 |
-
}
|
2582 |
-
cm.setCursor(Pos(cur.line, start + numberStr.length - 1));
|
2583 |
-
},
|
2584 |
-
repeatLastEdit: function(cm, actionArgs, vim) {
|
2585 |
-
var lastEditInputState = vim.lastEditInputState;
|
2586 |
-
if (!lastEditInputState) { return; }
|
2587 |
-
var repeat = actionArgs.repeat;
|
2588 |
-
if (repeat && actionArgs.repeatIsExplicit) {
|
2589 |
-
vim.lastEditInputState.repeatOverride = repeat;
|
2590 |
-
} else {
|
2591 |
-
repeat = vim.lastEditInputState.repeatOverride || repeat;
|
2592 |
-
}
|
2593 |
-
repeatLastEdit(cm, vim, repeat, false /** repeatForInsert */);
|
2594 |
-
},
|
2595 |
-
exitInsertMode: exitInsertMode
|
2596 |
-
};
|
2597 |
-
|
2598 |
-
function defineAction(name, fn) {
|
2599 |
-
actions[name] = fn;
|
2600 |
-
}
|
2601 |
-
|
2602 |
-
/*
|
2603 |
-
* Below are miscellaneous utility functions used by vim.js
|
2604 |
-
*/
|
2605 |
-
|
2606 |
-
/**
|
2607 |
-
* Clips cursor to ensure that line is within the buffer's range
|
2608 |
-
* If includeLineBreak is true, then allow cur.ch == lineLength.
|
2609 |
-
*/
|
2610 |
-
function clipCursorToContent(cm, cur, includeLineBreak) {
|
2611 |
-
var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() );
|
2612 |
-
var maxCh = lineLength(cm, line) - 1;
|
2613 |
-
maxCh = (includeLineBreak) ? maxCh + 1 : maxCh;
|
2614 |
-
var ch = Math.min(Math.max(0, cur.ch), maxCh);
|
2615 |
-
return Pos(line, ch);
|
2616 |
-
}
|
2617 |
-
function copyArgs(args) {
|
2618 |
-
var ret = {};
|
2619 |
-
for (var prop in args) {
|
2620 |
-
if (args.hasOwnProperty(prop)) {
|
2621 |
-
ret[prop] = args[prop];
|
2622 |
-
}
|
2623 |
-
}
|
2624 |
-
return ret;
|
2625 |
-
}
|
2626 |
-
function offsetCursor(cur, offsetLine, offsetCh) {
|
2627 |
-
if (typeof offsetLine === 'object') {
|
2628 |
-
offsetCh = offsetLine.ch;
|
2629 |
-
offsetLine = offsetLine.line;
|
2630 |
-
}
|
2631 |
-
return Pos(cur.line + offsetLine, cur.ch + offsetCh);
|
2632 |
-
}
|
2633 |
-
function getOffset(anchor, head) {
|
2634 |
-
return {
|
2635 |
-
line: head.line - anchor.line,
|
2636 |
-
ch: head.line - anchor.line
|
2637 |
-
};
|
2638 |
-
}
|
2639 |
-
function commandMatches(keys, keyMap, context, inputState) {
|
2640 |
-
// Partial matches are not applied. They inform the key handler
|
2641 |
-
// that the current key sequence is a subsequence of a valid key
|
2642 |
-
// sequence, so that the key buffer is not cleared.
|
2643 |
-
var match, partial = [], full = [];
|
2644 |
-
for (var i = 0; i < keyMap.length; i++) {
|
2645 |
-
var command = keyMap[i];
|
2646 |
-
if (context == 'insert' && command.context != 'insert' ||
|
2647 |
-
command.context && command.context != context ||
|
2648 |
-
inputState.operator && command.type == 'action' ||
|
2649 |
-
!(match = commandMatch(keys, command.keys))) { continue; }
|
2650 |
-
if (match == 'partial') { partial.push(command); }
|
2651 |
-
if (match == 'full') { full.push(command); }
|
2652 |
-
}
|
2653 |
-
return {
|
2654 |
-
partial: partial.length && partial,
|
2655 |
-
full: full.length && full
|
2656 |
-
};
|
2657 |
-
}
|
2658 |
-
function commandMatch(pressed, mapped) {
|
2659 |
-
if (mapped.slice(-11) == '<character>') {
|
2660 |
-
// Last character matches anything.
|
2661 |
-
var prefixLen = mapped.length - 11;
|
2662 |
-
var pressedPrefix = pressed.slice(0, prefixLen);
|
2663 |
-
var mappedPrefix = mapped.slice(0, prefixLen);
|
2664 |
-
return pressedPrefix == mappedPrefix && pressed.length > prefixLen ? 'full' :
|
2665 |
-
mappedPrefix.indexOf(pressedPrefix) == 0 ? 'partial' : false;
|
2666 |
-
} else {
|
2667 |
-
return pressed == mapped ? 'full' :
|
2668 |
-
mapped.indexOf(pressed) == 0 ? 'partial' : false;
|
2669 |
-
}
|
2670 |
-
}
|
2671 |
-
function lastChar(keys) {
|
2672 |
-
var match = /^.*(<[\w\-]+>)$/.exec(keys);
|
2673 |
-
var selectedCharacter = match ? match[1] : keys.slice(-1);
|
2674 |
-
if (selectedCharacter.length > 1){
|
2675 |
-
switch(selectedCharacter){
|
2676 |
-
case '<CR>':
|
2677 |
-
selectedCharacter='\n';
|
2678 |
-
break;
|
2679 |
-
case '<Space>':
|
2680 |
-
selectedCharacter=' ';
|
2681 |
-
break;
|
2682 |
-
default:
|
2683 |
-
break;
|
2684 |
-
}
|
2685 |
-
}
|
2686 |
-
return selectedCharacter;
|
2687 |
-
}
|
2688 |
-
function repeatFn(cm, fn, repeat) {
|
2689 |
-
return function() {
|
2690 |
-
for (var i = 0; i < repeat; i++) {
|
2691 |
-
fn(cm);
|
2692 |
-
}
|
2693 |
-
};
|
2694 |
-
}
|
2695 |
-
function copyCursor(cur) {
|
2696 |
-
return Pos(cur.line, cur.ch);
|
2697 |
-
}
|
2698 |
-
function cursorEqual(cur1, cur2) {
|
2699 |
-
return cur1.ch == cur2.ch && cur1.line == cur2.line;
|
2700 |
-
}
|
2701 |
-
function cursorIsBefore(cur1, cur2) {
|
2702 |
-
if (cur1.line < cur2.line) {
|
2703 |
-
return true;
|
2704 |
-
}
|
2705 |
-
if (cur1.line == cur2.line && cur1.ch < cur2.ch) {
|
2706 |
-
return true;
|
2707 |
-
}
|
2708 |
-
return false;
|
2709 |
-
}
|
2710 |
-
function cursorMin(cur1, cur2) {
|
2711 |
-
if (arguments.length > 2) {
|
2712 |
-
cur2 = cursorMin.apply(undefined, Array.prototype.slice.call(arguments, 1));
|
2713 |
-
}
|
2714 |
-
return cursorIsBefore(cur1, cur2) ? cur1 : cur2;
|
2715 |
-
}
|
2716 |
-
function cursorMax(cur1, cur2) {
|
2717 |
-
if (arguments.length > 2) {
|
2718 |
-
cur2 = cursorMax.apply(undefined, Array.prototype.slice.call(arguments, 1));
|
2719 |
-
}
|
2720 |
-
return cursorIsBefore(cur1, cur2) ? cur2 : cur1;
|
2721 |
-
}
|
2722 |
-
function cursorIsBetween(cur1, cur2, cur3) {
|
2723 |
-
// returns true if cur2 is between cur1 and cur3.
|
2724 |
-
var cur1before2 = cursorIsBefore(cur1, cur2);
|
2725 |
-
var cur2before3 = cursorIsBefore(cur2, cur3);
|
2726 |
-
return cur1before2 && cur2before3;
|
2727 |
-
}
|
2728 |
-
function lineLength(cm, lineNum) {
|
2729 |
-
return cm.getLine(lineNum).length;
|
2730 |
-
}
|
2731 |
-
function trim(s) {
|
2732 |
-
if (s.trim) {
|
2733 |
-
return s.trim();
|
2734 |
-
}
|
2735 |
-
return s.replace(/^\s+|\s+$/g, '');
|
2736 |
-
}
|
2737 |
-
function escapeRegex(s) {
|
2738 |
-
return s.replace(/([.?*+$\[\]\/\\(){}|\-])/g, '\\$1');
|
2739 |
-
}
|
2740 |
-
function extendLineToColumn(cm, lineNum, column) {
|
2741 |
-
var endCh = lineLength(cm, lineNum);
|
2742 |
-
var spaces = new Array(column-endCh+1).join(' ');
|
2743 |
-
cm.setCursor(Pos(lineNum, endCh));
|
2744 |
-
cm.replaceRange(spaces, cm.getCursor());
|
2745 |
-
}
|
2746 |
-
// This functions selects a rectangular block
|
2747 |
-
// of text with selectionEnd as any of its corner
|
2748 |
-
// Height of block:
|
2749 |
-
// Difference in selectionEnd.line and first/last selection.line
|
2750 |
-
// Width of the block:
|
2751 |
-
// Distance between selectionEnd.ch and any(first considered here) selection.ch
|
2752 |
-
function selectBlock(cm, selectionEnd) {
|
2753 |
-
var selections = [], ranges = cm.listSelections();
|
2754 |
-
var head = copyCursor(cm.clipPos(selectionEnd));
|
2755 |
-
var isClipped = !cursorEqual(selectionEnd, head);
|
2756 |
-
var curHead = cm.getCursor('head');
|
2757 |
-
var primIndex = getIndex(ranges, curHead);
|
2758 |
-
var wasClipped = cursorEqual(ranges[primIndex].head, ranges[primIndex].anchor);
|
2759 |
-
var max = ranges.length - 1;
|
2760 |
-
var index = max - primIndex > primIndex ? max : 0;
|
2761 |
-
var base = ranges[index].anchor;
|
2762 |
-
|
2763 |
-
var firstLine = Math.min(base.line, head.line);
|
2764 |
-
var lastLine = Math.max(base.line, head.line);
|
2765 |
-
var baseCh = base.ch, headCh = head.ch;
|
2766 |
-
|
2767 |
-
var dir = ranges[index].head.ch - baseCh;
|
2768 |
-
var newDir = headCh - baseCh;
|
2769 |
-
if (dir > 0 && newDir <= 0) {
|
2770 |
-
baseCh++;
|
2771 |
-
if (!isClipped) { headCh--; }
|
2772 |
-
} else if (dir < 0 && newDir >= 0) {
|
2773 |
-
baseCh--;
|
2774 |
-
if (!wasClipped) { headCh++; }
|
2775 |
-
} else if (dir < 0 && newDir == -1) {
|
2776 |
-
baseCh--;
|
2777 |
-
headCh++;
|
2778 |
-
}
|
2779 |
-
for (var line = firstLine; line <= lastLine; line++) {
|
2780 |
-
var range = {anchor: new Pos(line, baseCh), head: new Pos(line, headCh)};
|
2781 |
-
selections.push(range);
|
2782 |
-
}
|
2783 |
-
primIndex = head.line == lastLine ? selections.length - 1 : 0;
|
2784 |
-
cm.setSelections(selections);
|
2785 |
-
selectionEnd.ch = headCh;
|
2786 |
-
base.ch = baseCh;
|
2787 |
-
return base;
|
2788 |
-
}
|
2789 |
-
function selectForInsert(cm, head, height) {
|
2790 |
-
var sel = [];
|
2791 |
-
for (var i = 0; i < height; i++) {
|
2792 |
-
var lineHead = offsetCursor(head, i, 0);
|
2793 |
-
sel.push({anchor: lineHead, head: lineHead});
|
2794 |
-
}
|
2795 |
-
cm.setSelections(sel, 0);
|
2796 |
-
}
|
2797 |
-
// getIndex returns the index of the cursor in the selections.
|
2798 |
-
function getIndex(ranges, cursor, end) {
|
2799 |
-
for (var i = 0; i < ranges.length; i++) {
|
2800 |
-
var atAnchor = end != 'head' && cursorEqual(ranges[i].anchor, cursor);
|
2801 |
-
var atHead = end != 'anchor' && cursorEqual(ranges[i].head, cursor);
|
2802 |
-
if (atAnchor || atHead) {
|
2803 |
-
return i;
|
2804 |
-
}
|
2805 |
-
}
|
2806 |
-
return -1;
|
2807 |
-
}
|
2808 |
-
function getSelectedAreaRange(cm, vim) {
|
2809 |
-
var lastSelection = vim.lastSelection;
|
2810 |
-
var getCurrentSelectedAreaRange = function() {
|
2811 |
-
var selections = cm.listSelections();
|
2812 |
-
var start = selections[0];
|
2813 |
-
var end = selections[selections.length-1];
|
2814 |
-
var selectionStart = cursorIsBefore(start.anchor, start.head) ? start.anchor : start.head;
|
2815 |
-
var selectionEnd = cursorIsBefore(end.anchor, end.head) ? end.head : end.anchor;
|
2816 |
-
return [selectionStart, selectionEnd];
|
2817 |
-
};
|
2818 |
-
var getLastSelectedAreaRange = function() {
|
2819 |
-
var selectionStart = cm.getCursor();
|
2820 |
-
var selectionEnd = cm.getCursor();
|
2821 |
-
var block = lastSelection.visualBlock;
|
2822 |
-
if (block) {
|
2823 |
-
var width = block.width;
|
2824 |
-
var height = block.height;
|
2825 |
-
selectionEnd = Pos(selectionStart.line + height, selectionStart.ch + width);
|
2826 |
-
var selections = [];
|
2827 |
-
// selectBlock creates a 'proper' rectangular block.
|
2828 |
-
// We do not want that in all cases, so we manually set selections.
|
2829 |
-
for (var i = selectionStart.line; i < selectionEnd.line; i++) {
|
2830 |
-
var anchor = Pos(i, selectionStart.ch);
|
2831 |
-
var head = Pos(i, selectionEnd.ch);
|
2832 |
-
var range = {anchor: anchor, head: head};
|
2833 |
-
selections.push(range);
|
2834 |
-
}
|
2835 |
-
cm.setSelections(selections);
|
2836 |
-
} else {
|
2837 |
-
var start = lastSelection.anchorMark.find();
|
2838 |
-
var end = lastSelection.headMark.find();
|
2839 |
-
var line = end.line - start.line;
|
2840 |
-
var ch = end.ch - start.ch;
|
2841 |
-
selectionEnd = {line: selectionEnd.line + line, ch: line ? selectionEnd.ch : ch + selectionEnd.ch};
|
2842 |
-
if (lastSelection.visualLine) {
|
2843 |
-
selectionStart = Pos(selectionStart.line, 0);
|
2844 |
-
selectionEnd = Pos(selectionEnd.line, lineLength(cm, selectionEnd.line));
|
2845 |
-
}
|
2846 |
-
cm.setSelection(selectionStart, selectionEnd);
|
2847 |
-
}
|
2848 |
-
return [selectionStart, selectionEnd];
|
2849 |
-
};
|
2850 |
-
if (!vim.visualMode) {
|
2851 |
-
// In case of replaying the action.
|
2852 |
-
return getLastSelectedAreaRange();
|
2853 |
-
} else {
|
2854 |
-
return getCurrentSelectedAreaRange();
|
2855 |
-
}
|
2856 |
-
}
|
2857 |
-
// Updates the previous selection with the current selection's values. This
|
2858 |
-
// should only be called in visual mode.
|
2859 |
-
function updateLastSelection(cm, vim) {
|
2860 |
-
var anchor = vim.sel.anchor;
|
2861 |
-
var head = vim.sel.head;
|
2862 |
-
// To accommodate the effect of lastPastedText in the last selection
|
2863 |
-
if (vim.lastPastedText) {
|
2864 |
-
head = cm.posFromIndex(cm.indexFromPos(anchor) + vim.lastPastedText.length);
|
2865 |
-
vim.lastPastedText = null;
|
2866 |
-
}
|
2867 |
-
vim.lastSelection = {'anchorMark': cm.setBookmark(anchor),
|
2868 |
-
'headMark': cm.setBookmark(head),
|
2869 |
-
'anchor': copyCursor(anchor),
|
2870 |
-
'head': copyCursor(head),
|
2871 |
-
'visualMode': vim.visualMode,
|
2872 |
-
'visualLine': vim.visualLine,
|
2873 |
-
'visualBlock': vim.visualBlock};
|
2874 |
-
}
|
2875 |
-
function expandSelection(cm, start, end) {
|
2876 |
-
var sel = cm.state.vim.sel;
|
2877 |
-
var head = sel.head;
|
2878 |
-
var anchor = sel.anchor;
|
2879 |
-
var tmp;
|
2880 |
-
if (cursorIsBefore(end, start)) {
|
2881 |
-
tmp = end;
|
2882 |
-
end = start;
|
2883 |
-
start = tmp;
|
2884 |
-
}
|
2885 |
-
if (cursorIsBefore(head, anchor)) {
|
2886 |
-
head = cursorMin(start, head);
|
2887 |
-
anchor = cursorMax(anchor, end);
|
2888 |
-
} else {
|
2889 |
-
anchor = cursorMin(start, anchor);
|
2890 |
-
head = cursorMax(head, end);
|
2891 |
-
head = offsetCursor(head, 0, -1);
|
2892 |
-
if (head.ch == -1 && head.line != cm.firstLine()) {
|
2893 |
-
head = Pos(head.line - 1, lineLength(cm, head.line - 1));
|
2894 |
-
}
|
2895 |
-
}
|
2896 |
-
return [anchor, head];
|
2897 |
-
}
|
2898 |
-
/**
|
2899 |
-
* Updates the CodeMirror selection to match the provided vim selection.
|
2900 |
-
* If no arguments are given, it uses the current vim selection state.
|
2901 |
-
*/
|
2902 |
-
function updateCmSelection(cm, sel, mode) {
|
2903 |
-
var vim = cm.state.vim;
|
2904 |
-
sel = sel || vim.sel;
|
2905 |
-
var mode = mode ||
|
2906 |
-
vim.visualLine ? 'line' : vim.visualBlock ? 'block' : 'char';
|
2907 |
-
var cmSel = makeCmSelection(cm, sel, mode);
|
2908 |
-
cm.setSelections(cmSel.ranges, cmSel.primary);
|
2909 |
-
updateFakeCursor(cm);
|
2910 |
-
}
|
2911 |
-
function makeCmSelection(cm, sel, mode, exclusive) {
|
2912 |
-
var head = copyCursor(sel.head);
|
2913 |
-
var anchor = copyCursor(sel.anchor);
|
2914 |
-
if (mode == 'char') {
|
2915 |
-
var headOffset = !exclusive && !cursorIsBefore(sel.head, sel.anchor) ? 1 : 0;
|
2916 |
-
var anchorOffset = cursorIsBefore(sel.head, sel.anchor) ? 1 : 0;
|
2917 |
-
head = offsetCursor(sel.head, 0, headOffset);
|
2918 |
-
anchor = offsetCursor(sel.anchor, 0, anchorOffset);
|
2919 |
-
return {
|
2920 |
-
ranges: [{anchor: anchor, head: head}],
|
2921 |
-
primary: 0
|
2922 |
-
};
|
2923 |
-
} else if (mode == 'line') {
|
2924 |
-
if (!cursorIsBefore(sel.head, sel.anchor)) {
|
2925 |
-
anchor.ch = 0;
|
2926 |
-
|
2927 |
-
var lastLine = cm.lastLine();
|
2928 |
-
if (head.line > lastLine) {
|
2929 |
-
head.line = lastLine;
|
2930 |
-
}
|
2931 |
-
head.ch = lineLength(cm, head.line);
|
2932 |
-
} else {
|
2933 |
-
head.ch = 0;
|
2934 |
-
anchor.ch = lineLength(cm, anchor.line);
|
2935 |
-
}
|
2936 |
-
return {
|
2937 |
-
ranges: [{anchor: anchor, head: head}],
|
2938 |
-
primary: 0
|
2939 |
-
};
|
2940 |
-
} else if (mode == 'block') {
|
2941 |
-
var top = Math.min(anchor.line, head.line),
|
2942 |
-
left = Math.min(anchor.ch, head.ch),
|
2943 |
-
bottom = Math.max(anchor.line, head.line),
|
2944 |
-
right = Math.max(anchor.ch, head.ch) + 1;
|
2945 |
-
var height = bottom - top + 1;
|
2946 |
-
var primary = head.line == top ? 0 : height - 1;
|
2947 |
-
var ranges = [];
|
2948 |
-
for (var i = 0; i < height; i++) {
|
2949 |
-
ranges.push({
|
2950 |
-
anchor: Pos(top + i, left),
|
2951 |
-
head: Pos(top + i, right)
|
2952 |
-
});
|
2953 |
-
}
|
2954 |
-
return {
|
2955 |
-
ranges: ranges,
|
2956 |
-
primary: primary
|
2957 |
-
};
|
2958 |
-
}
|
2959 |
-
}
|
2960 |
-
function getHead(cm) {
|
2961 |
-
var cur = cm.getCursor('head');
|
2962 |
-
if (cm.getSelection().length == 1) {
|
2963 |
-
// Small corner case when only 1 character is selected. The "real"
|
2964 |
-
// head is the left of head and anchor.
|
2965 |
-
cur = cursorMin(cur, cm.getCursor('anchor'));
|
2966 |
-
}
|
2967 |
-
return cur;
|
2968 |
-
}
|
2969 |
-
|
2970 |
-
/**
|
2971 |
-
* If moveHead is set to false, the CodeMirror selection will not be
|
2972 |
-
* touched. The caller assumes the responsibility of putting the cursor
|
2973 |
-
* in the right place.
|
2974 |
-
*/
|
2975 |
-
function exitVisualMode(cm, moveHead) {
|
2976 |
-
var vim = cm.state.vim;
|
2977 |
-
if (moveHead !== false) {
|
2978 |
-
cm.setCursor(clipCursorToContent(cm, vim.sel.head));
|
2979 |
-
}
|
2980 |
-
updateLastSelection(cm, vim);
|
2981 |
-
vim.visualMode = false;
|
2982 |
-
vim.visualLine = false;
|
2983 |
-
vim.visualBlock = false;
|
2984 |
-
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
|
2985 |
-
if (vim.fakeCursor) {
|
2986 |
-
vim.fakeCursor.clear();
|
2987 |
-
}
|
2988 |
-
}
|
2989 |
-
|
2990 |
-
// Remove any trailing newlines from the selection. For
|
2991 |
-
// example, with the caret at the start of the last word on the line,
|
2992 |
-
// 'dw' should word, but not the newline, while 'w' should advance the
|
2993 |
-
// caret to the first character of the next line.
|
2994 |
-
function clipToLine(cm, curStart, curEnd) {
|
2995 |
-
var selection = cm.getRange(curStart, curEnd);
|
2996 |
-
// Only clip if the selection ends with trailing newline + whitespace
|
2997 |
-
if (/\n\s*$/.test(selection)) {
|
2998 |
-
var lines = selection.split('\n');
|
2999 |
-
// We know this is all whitepsace.
|
3000 |
-
lines.pop();
|
3001 |
-
|
3002 |
-
// Cases:
|
3003 |
-
// 1. Last word is an empty line - do not clip the trailing '\n'
|
3004 |
-
// 2. Last word is not an empty line - clip the trailing '\n'
|
3005 |
-
var line;
|
3006 |
-
// Find the line containing the last word, and clip all whitespace up
|
3007 |
-
// to it.
|
3008 |
-
for (var line = lines.pop(); lines.length > 0 && line && isWhiteSpaceString(line); line = lines.pop()) {
|
3009 |
-
curEnd.line--;
|
3010 |
-
curEnd.ch = 0;
|
3011 |
-
}
|
3012 |
-
// If the last word is not an empty line, clip an additional newline
|
3013 |
-
if (line) {
|
3014 |
-
curEnd.line--;
|
3015 |
-
curEnd.ch = lineLength(cm, curEnd.line);
|
3016 |
-
} else {
|
3017 |
-
curEnd.ch = 0;
|
3018 |
-
}
|
3019 |
-
}
|
3020 |
-
}
|
3021 |
-
|
3022 |
-
// Expand the selection to line ends.
|
3023 |
-
function expandSelectionToLine(_cm, curStart, curEnd) {
|
3024 |
-
curStart.ch = 0;
|
3025 |
-
curEnd.ch = 0;
|
3026 |
-
curEnd.line++;
|
3027 |
-
}
|
3028 |
-
|
3029 |
-
function findFirstNonWhiteSpaceCharacter(text) {
|
3030 |
-
if (!text) {
|
3031 |
-
return 0;
|
3032 |
-
}
|
3033 |
-
var firstNonWS = text.search(/\S/);
|
3034 |
-
return firstNonWS == -1 ? text.length : firstNonWS;
|
3035 |
-
}
|
3036 |
-
|
3037 |
-
function expandWordUnderCursor(cm, inclusive, _forward, bigWord, noSymbol) {
|
3038 |
-
var cur = getHead(cm);
|
3039 |
-
var line = cm.getLine(cur.line);
|
3040 |
-
var idx = cur.ch;
|
3041 |
-
|
3042 |
-
// Seek to first word or non-whitespace character, depending on if
|
3043 |
-
// noSymbol is true.
|
3044 |
-
var test = noSymbol ? wordCharTest[0] : bigWordCharTest [0];
|
3045 |
-
while (!test(line.charAt(idx))) {
|
3046 |
-
idx++;
|
3047 |
-
if (idx >= line.length) { return null; }
|
3048 |
-
}
|
3049 |
-
|
3050 |
-
if (bigWord) {
|
3051 |
-
test = bigWordCharTest[0];
|
3052 |
-
} else {
|
3053 |
-
test = wordCharTest[0];
|
3054 |
-
if (!test(line.charAt(idx))) {
|
3055 |
-
test = wordCharTest[1];
|
3056 |
-
}
|
3057 |
-
}
|
3058 |
-
|
3059 |
-
var end = idx, start = idx;
|
3060 |
-
while (test(line.charAt(end)) && end < line.length) { end++; }
|
3061 |
-
while (test(line.charAt(start)) && start >= 0) { start--; }
|
3062 |
-
start++;
|
3063 |
-
|
3064 |
-
if (inclusive) {
|
3065 |
-
// If present, include all whitespace after word.
|
3066 |
-
// Otherwise, include all whitespace before word, except indentation.
|
3067 |
-
var wordEnd = end;
|
3068 |
-
while (/\s/.test(line.charAt(end)) && end < line.length) { end++; }
|
3069 |
-
if (wordEnd == end) {
|
3070 |
-
var wordStart = start;
|
3071 |
-
while (/\s/.test(line.charAt(start - 1)) && start > 0) { start--; }
|
3072 |
-
if (!start) { start = wordStart; }
|
3073 |
-
}
|
3074 |
-
}
|
3075 |
-
return { start: Pos(cur.line, start), end: Pos(cur.line, end) };
|
3076 |
-
}
|
3077 |
-
|
3078 |
-
function recordJumpPosition(cm, oldCur, newCur) {
|
3079 |
-
if (!cursorEqual(oldCur, newCur)) {
|
3080 |
-
vimGlobalState.jumpList.add(cm, oldCur, newCur);
|
3081 |
-
}
|
3082 |
-
}
|
3083 |
-
|
3084 |
-
function recordLastCharacterSearch(increment, args) {
|
3085 |
-
vimGlobalState.lastChararacterSearch.increment = increment;
|
3086 |
-
vimGlobalState.lastChararacterSearch.forward = args.forward;
|
3087 |
-
vimGlobalState.lastChararacterSearch.selectedCharacter = args.selectedCharacter;
|
3088 |
-
}
|
3089 |
-
|
3090 |
-
var symbolToMode = {
|
3091 |
-
'(': 'bracket', ')': 'bracket', '{': 'bracket', '}': 'bracket',
|
3092 |
-
'[': 'section', ']': 'section',
|
3093 |
-
'*': 'comment', '/': 'comment',
|
3094 |
-
'm': 'method', 'M': 'method',
|
3095 |
-
'#': 'preprocess'
|
3096 |
-
};
|
3097 |
-
var findSymbolModes = {
|
3098 |
-
bracket: {
|
3099 |
-
isComplete: function(state) {
|
3100 |
-
if (state.nextCh === state.symb) {
|
3101 |
-
state.depth++;
|
3102 |
-
if (state.depth >= 1)return true;
|
3103 |
-
} else if (state.nextCh === state.reverseSymb) {
|
3104 |
-
state.depth--;
|
3105 |
-
}
|
3106 |
-
return false;
|
3107 |
-
}
|
3108 |
-
},
|
3109 |
-
section: {
|
3110 |
-
init: function(state) {
|
3111 |
-
state.curMoveThrough = true;
|
3112 |
-
state.symb = (state.forward ? ']' : '[') === state.symb ? '{' : '}';
|
3113 |
-
},
|
3114 |
-
isComplete: function(state) {
|
3115 |
-
return state.index === 0 && state.nextCh === state.symb;
|
3116 |
-
}
|
3117 |
-
},
|
3118 |
-
comment: {
|
3119 |
-
isComplete: function(state) {
|
3120 |
-
var found = state.lastCh === '*' && state.nextCh === '/';
|
3121 |
-
state.lastCh = state.nextCh;
|
3122 |
-
return found;
|
3123 |
-
}
|
3124 |
-
},
|
3125 |
-
// TODO: The original Vim implementation only operates on level 1 and 2.
|
3126 |
-
// The current implementation doesn't check for code block level and
|
3127 |
-
// therefore it operates on any levels.
|
3128 |
-
method: {
|
3129 |
-
init: function(state) {
|
3130 |
-
state.symb = (state.symb === 'm' ? '{' : '}');
|
3131 |
-
state.reverseSymb = state.symb === '{' ? '}' : '{';
|
3132 |
-
},
|
3133 |
-
isComplete: function(state) {
|
3134 |
-
if (state.nextCh === state.symb)return true;
|
3135 |
-
return false;
|
3136 |
-
}
|
3137 |
-
},
|
3138 |
-
preprocess: {
|
3139 |
-
init: function(state) {
|
3140 |
-
state.index = 0;
|
3141 |
-
},
|
3142 |
-
isComplete: function(state) {
|
3143 |
-
if (state.nextCh === '#') {
|
3144 |
-
var token = state.lineText.match(/#(\w+)/)[1];
|
3145 |
-
if (token === 'endif') {
|
3146 |
-
if (state.forward && state.depth === 0) {
|
3147 |
-
return true;
|
3148 |
-
}
|
3149 |
-
state.depth++;
|
3150 |
-
} else if (token === 'if') {
|
3151 |
-
if (!state.forward && state.depth === 0) {
|
3152 |
-
return true;
|
3153 |
-
}
|
3154 |
-
state.depth--;
|
3155 |
-
}
|
3156 |
-
if (token === 'else' && state.depth === 0)return true;
|
3157 |
-
}
|
3158 |
-
return false;
|
3159 |
-
}
|
3160 |
-
}
|
3161 |
-
};
|
3162 |
-
function findSymbol(cm, repeat, forward, symb) {
|
3163 |
-
var cur = copyCursor(cm.getCursor());
|
3164 |
-
var increment = forward ? 1 : -1;
|
3165 |
-
var endLine = forward ? cm.lineCount() : -1;
|
3166 |
-
var curCh = cur.ch;
|
3167 |
-
var line = cur.line;
|
3168 |
-
var lineText = cm.getLine(line);
|
3169 |
-
var state = {
|
3170 |
-
lineText: lineText,
|
3171 |
-
nextCh: lineText.charAt(curCh),
|
3172 |
-
lastCh: null,
|
3173 |
-
index: curCh,
|
3174 |
-
symb: symb,
|
3175 |
-
reverseSymb: (forward ? { ')': '(', '}': '{' } : { '(': ')', '{': '}' })[symb],
|
3176 |
-
forward: forward,
|
3177 |
-
depth: 0,
|
3178 |
-
curMoveThrough: false
|
3179 |
-
};
|
3180 |
-
var mode = symbolToMode[symb];
|
3181 |
-
if (!mode)return cur;
|
3182 |
-
var init = findSymbolModes[mode].init;
|
3183 |
-
var isComplete = findSymbolModes[mode].isComplete;
|
3184 |
-
if (init) { init(state); }
|
3185 |
-
while (line !== endLine && repeat) {
|
3186 |
-
state.index += increment;
|
3187 |
-
state.nextCh = state.lineText.charAt(state.index);
|
3188 |
-
if (!state.nextCh) {
|
3189 |
-
line += increment;
|
3190 |
-
state.lineText = cm.getLine(line) || '';
|
3191 |
-
if (increment > 0) {
|
3192 |
-
state.index = 0;
|
3193 |
-
} else {
|
3194 |
-
var lineLen = state.lineText.length;
|
3195 |
-
state.index = (lineLen > 0) ? (lineLen-1) : 0;
|
3196 |
-
}
|
3197 |
-
state.nextCh = state.lineText.charAt(state.index);
|
3198 |
-
}
|
3199 |
-
if (isComplete(state)) {
|
3200 |
-
cur.line = line;
|
3201 |
-
cur.ch = state.index;
|
3202 |
-
repeat--;
|
3203 |
-
}
|
3204 |
-
}
|
3205 |
-
if (state.nextCh || state.curMoveThrough) {
|
3206 |
-
return Pos(line, state.index);
|
3207 |
-
}
|
3208 |
-
return cur;
|
3209 |
-
}
|
3210 |
-
|
3211 |
-
/**
|
3212 |
-
* Returns the boundaries of the next word. If the cursor in the middle of
|
3213 |
-
* the word, then returns the boundaries of the current word, starting at
|
3214 |
-
* the cursor. If the cursor is at the start/end of a word, and we are going
|
3215 |
-
* forward/backward, respectively, find the boundaries of the next word.
|
3216 |
-
*
|
3217 |
-
* @param {CodeMirror} cm CodeMirror object.
|
3218 |
-
* @param {Cursor} cur The cursor position.
|
3219 |
-
* @param {boolean} forward True to search forward. False to search
|
3220 |
-
* backward.
|
3221 |
-
* @param {boolean} bigWord True if punctuation count as part of the word.
|
3222 |
-
* False if only [a-zA-Z0-9] characters count as part of the word.
|
3223 |
-
* @param {boolean} emptyLineIsWord True if empty lines should be treated
|
3224 |
-
* as words.
|
3225 |
-
* @return {Object{from:number, to:number, line: number}} The boundaries of
|
3226 |
-
* the word, or null if there are no more words.
|
3227 |
-
*/
|
3228 |
-
function findWord(cm, cur, forward, bigWord, emptyLineIsWord) {
|
3229 |
-
var lineNum = cur.line;
|
3230 |
-
var pos = cur.ch;
|
3231 |
-
var line = cm.getLine(lineNum);
|
3232 |
-
var dir = forward ? 1 : -1;
|
3233 |
-
var charTests = bigWord ? bigWordCharTest: wordCharTest;
|
3234 |
-
|
3235 |
-
if (emptyLineIsWord && line == '') {
|
3236 |
-
lineNum += dir;
|
3237 |
-
line = cm.getLine(lineNum);
|
3238 |
-
if (!isLine(cm, lineNum)) {
|
3239 |
-
return null;
|
3240 |
-
}
|
3241 |
-
pos = (forward) ? 0 : line.length;
|
3242 |
-
}
|
3243 |
-
|
3244 |
-
while (true) {
|
3245 |
-
if (emptyLineIsWord && line == '') {
|
3246 |
-
return { from: 0, to: 0, line: lineNum };
|
3247 |
-
}
|
3248 |
-
var stop = (dir > 0) ? line.length : -1;
|
3249 |
-
var wordStart = stop, wordEnd = stop;
|
3250 |
-
// Find bounds of next word.
|
3251 |
-
while (pos != stop) {
|
3252 |
-
var foundWord = false;
|
3253 |
-
for (var i = 0; i < charTests.length && !foundWord; ++i) {
|
3254 |
-
if (charTests[i](line.charAt(pos))) {
|
3255 |
-
wordStart = pos;
|
3256 |
-
// Advance to end of word.
|
3257 |
-
while (pos != stop && charTests[i](line.charAt(pos))) {
|
3258 |
-
pos += dir;
|
3259 |
-
}
|
3260 |
-
wordEnd = pos;
|
3261 |
-
foundWord = wordStart != wordEnd;
|
3262 |
-
if (wordStart == cur.ch && lineNum == cur.line &&
|
3263 |
-
wordEnd == wordStart + dir) {
|
3264 |
-
// We started at the end of a word. Find the next one.
|
3265 |
-
continue;
|
3266 |
-
} else {
|
3267 |
-
return {
|
3268 |
-
from: Math.min(wordStart, wordEnd + 1),
|
3269 |
-
to: Math.max(wordStart, wordEnd),
|
3270 |
-
line: lineNum };
|
3271 |
-
}
|
3272 |
-
}
|
3273 |
-
}
|
3274 |
-
if (!foundWord) {
|
3275 |
-
pos += dir;
|
3276 |
-
}
|
3277 |
-
}
|
3278 |
-
// Advance to next/prev line.
|
3279 |
-
lineNum += dir;
|
3280 |
-
if (!isLine(cm, lineNum)) {
|
3281 |
-
return null;
|
3282 |
-
}
|
3283 |
-
line = cm.getLine(lineNum);
|
3284 |
-
pos = (dir > 0) ? 0 : line.length;
|
3285 |
-
}
|
3286 |
-
// Should never get here.
|
3287 |
-
throw new Error('The impossible happened.');
|
3288 |
-
}
|
3289 |
-
|
3290 |
-
/**
|
3291 |
-
* @param {CodeMirror} cm CodeMirror object.
|
3292 |
-
* @param {Pos} cur The position to start from.
|
3293 |
-
* @param {int} repeat Number of words to move past.
|
3294 |
-
* @param {boolean} forward True to search forward. False to search
|
3295 |
-
* backward.
|
3296 |
-
* @param {boolean} wordEnd True to move to end of word. False to move to
|
3297 |
-
* beginning of word.
|
3298 |
-
* @param {boolean} bigWord True if punctuation count as part of the word.
|
3299 |
-
* False if only alphabet characters count as part of the word.
|
3300 |
-
* @return {Cursor} The position the cursor should move to.
|
3301 |
-
*/
|
3302 |
-
function moveToWord(cm, cur, repeat, forward, wordEnd, bigWord) {
|
3303 |
-
var curStart = copyCursor(cur);
|
3304 |
-
var words = [];
|
3305 |
-
if (forward && !wordEnd || !forward && wordEnd) {
|
3306 |
-
repeat++;
|
3307 |
-
}
|
3308 |
-
// For 'e', empty lines are not considered words, go figure.
|
3309 |
-
var emptyLineIsWord = !(forward && wordEnd);
|
3310 |
-
for (var i = 0; i < repeat; i++) {
|
3311 |
-
var word = findWord(cm, cur, forward, bigWord, emptyLineIsWord);
|
3312 |
-
if (!word) {
|
3313 |
-
var eodCh = lineLength(cm, cm.lastLine());
|
3314 |
-
words.push(forward
|
3315 |
-
? {line: cm.lastLine(), from: eodCh, to: eodCh}
|
3316 |
-
: {line: 0, from: 0, to: 0});
|
3317 |
-
break;
|
3318 |
-
}
|
3319 |
-
words.push(word);
|
3320 |
-
cur = Pos(word.line, forward ? (word.to - 1) : word.from);
|
3321 |
-
}
|
3322 |
-
var shortCircuit = words.length != repeat;
|
3323 |
-
var firstWord = words[0];
|
3324 |
-
var lastWord = words.pop();
|
3325 |
-
if (forward && !wordEnd) {
|
3326 |
-
// w
|
3327 |
-
if (!shortCircuit && (firstWord.from != curStart.ch || firstWord.line != curStart.line)) {
|
3328 |
-
// We did not start in the middle of a word. Discard the extra word at the end.
|
3329 |
-
lastWord = words.pop();
|
3330 |
-
}
|
3331 |
-
return Pos(lastWord.line, lastWord.from);
|
3332 |
-
} else if (forward && wordEnd) {
|
3333 |
-
return Pos(lastWord.line, lastWord.to - 1);
|
3334 |
-
} else if (!forward && wordEnd) {
|
3335 |
-
// ge
|
3336 |
-
if (!shortCircuit && (firstWord.to != curStart.ch || firstWord.line != curStart.line)) {
|
3337 |
-
// We did not start in the middle of a word. Discard the extra word at the end.
|
3338 |
-
lastWord = words.pop();
|
3339 |
-
}
|
3340 |
-
return Pos(lastWord.line, lastWord.to);
|
3341 |
-
} else {
|
3342 |
-
// b
|
3343 |
-
return Pos(lastWord.line, lastWord.from);
|
3344 |
-
}
|
3345 |
-
}
|
3346 |
-
|
3347 |
-
function moveToCharacter(cm, repeat, forward, character) {
|
3348 |
-
var cur = cm.getCursor();
|
3349 |
-
var start = cur.ch;
|
3350 |
-
var idx;
|
3351 |
-
for (var i = 0; i < repeat; i ++) {
|
3352 |
-
var line = cm.getLine(cur.line);
|
3353 |
-
idx = charIdxInLine(start, line, character, forward, true);
|
3354 |
-
if (idx == -1) {
|
3355 |
-
return null;
|
3356 |
-
}
|
3357 |
-
start = idx;
|
3358 |
-
}
|
3359 |
-
return Pos(cm.getCursor().line, idx);
|
3360 |
-
}
|
3361 |
-
|
3362 |
-
function moveToColumn(cm, repeat) {
|
3363 |
-
// repeat is always >= 1, so repeat - 1 always corresponds
|
3364 |
-
// to the column we want to go to.
|
3365 |
-
var line = cm.getCursor().line;
|
3366 |
-
return clipCursorToContent(cm, Pos(line, repeat - 1));
|
3367 |
-
}
|
3368 |
-
|
3369 |
-
function updateMark(cm, vim, markName, pos) {
|
3370 |
-
if (!inArray(markName, validMarks)) {
|
3371 |
-
return;
|
3372 |
-
}
|
3373 |
-
if (vim.marks[markName]) {
|
3374 |
-
vim.marks[markName].clear();
|
3375 |
-
}
|
3376 |
-
vim.marks[markName] = cm.setBookmark(pos);
|
3377 |
-
}
|
3378 |
-
|
3379 |
-
function charIdxInLine(start, line, character, forward, includeChar) {
|
3380 |
-
// Search for char in line.
|
3381 |
-
// motion_options: {forward, includeChar}
|
3382 |
-
// If includeChar = true, include it too.
|
3383 |
-
// If forward = true, search forward, else search backwards.
|
3384 |
-
// If char is not found on this line, do nothing
|
3385 |
-
var idx;
|
3386 |
-
if (forward) {
|
3387 |
-
idx = line.indexOf(character, start + 1);
|
3388 |
-
if (idx != -1 && !includeChar) {
|
3389 |
-
idx -= 1;
|
3390 |
-
}
|
3391 |
-
} else {
|
3392 |
-
idx = line.lastIndexOf(character, start - 1);
|
3393 |
-
if (idx != -1 && !includeChar) {
|
3394 |
-
idx += 1;
|
3395 |
-
}
|
3396 |
-
}
|
3397 |
-
return idx;
|
3398 |
-
}
|
3399 |
-
|
3400 |
-
function findParagraph(cm, head, repeat, dir, inclusive) {
|
3401 |
-
var line = head.line;
|
3402 |
-
var min = cm.firstLine();
|
3403 |
-
var max = cm.lastLine();
|
3404 |
-
var start, end, i = line;
|
3405 |
-
function isEmpty(i) { return !cm.getLine(i); }
|
3406 |
-
function isBoundary(i, dir, any) {
|
3407 |
-
if (any) { return isEmpty(i) != isEmpty(i + dir); }
|
3408 |
-
return !isEmpty(i) && isEmpty(i + dir);
|
3409 |
-
}
|
3410 |
-
if (dir) {
|
3411 |
-
while (min <= i && i <= max && repeat > 0) {
|
3412 |
-
if (isBoundary(i, dir)) { repeat--; }
|
3413 |
-
i += dir;
|
3414 |
-
}
|
3415 |
-
return new Pos(i, 0);
|
3416 |
-
}
|
3417 |
-
|
3418 |
-
var vim = cm.state.vim;
|
3419 |
-
if (vim.visualLine && isBoundary(line, 1, true)) {
|
3420 |
-
var anchor = vim.sel.anchor;
|
3421 |
-
if (isBoundary(anchor.line, -1, true)) {
|
3422 |
-
if (!inclusive || anchor.line != line) {
|
3423 |
-
line += 1;
|
3424 |
-
}
|
3425 |
-
}
|
3426 |
-
}
|
3427 |
-
var startState = isEmpty(line);
|
3428 |
-
for (i = line; i <= max && repeat; i++) {
|
3429 |
-
if (isBoundary(i, 1, true)) {
|
3430 |
-
if (!inclusive || isEmpty(i) != startState) {
|
3431 |
-
repeat--;
|
3432 |
-
}
|
3433 |
-
}
|
3434 |
-
}
|
3435 |
-
end = new Pos(i, 0);
|
3436 |
-
// select boundary before paragraph for the last one
|
3437 |
-
if (i > max && !startState) { startState = true; }
|
3438 |
-
else { inclusive = false; }
|
3439 |
-
for (i = line; i > min; i--) {
|
3440 |
-
if (!inclusive || isEmpty(i) == startState || i == line) {
|
3441 |
-
if (isBoundary(i, -1, true)) { break; }
|
3442 |
-
}
|
3443 |
-
}
|
3444 |
-
start = new Pos(i, 0);
|
3445 |
-
return { start: start, end: end };
|
3446 |
-
}
|
3447 |
-
|
3448 |
-
// TODO: perhaps this finagling of start and end positions belonds
|
3449 |
-
// in codmirror/replaceRange?
|
3450 |
-
function selectCompanionObject(cm, head, symb, inclusive) {
|
3451 |
-
var cur = head, start, end;
|
3452 |
-
|
3453 |
-
var bracketRegexp = ({
|
3454 |
-
'(': /[()]/, ')': /[()]/,
|
3455 |
-
'[': /[[\]]/, ']': /[[\]]/,
|
3456 |
-
'{': /[{}]/, '}': /[{}]/})[symb];
|
3457 |
-
var openSym = ({
|
3458 |
-
'(': '(', ')': '(',
|
3459 |
-
'[': '[', ']': '[',
|
3460 |
-
'{': '{', '}': '{'})[symb];
|
3461 |
-
var curChar = cm.getLine(cur.line).charAt(cur.ch);
|
3462 |
-
// Due to the behavior of scanForBracket, we need to add an offset if the
|
3463 |
-
// cursor is on a matching open bracket.
|
3464 |
-
var offset = curChar === openSym ? 1 : 0;
|
3465 |
-
|
3466 |
-
start = cm.scanForBracket(Pos(cur.line, cur.ch + offset), -1, null, {'bracketRegex': bracketRegexp});
|
3467 |
-
end = cm.scanForBracket(Pos(cur.line, cur.ch + offset), 1, null, {'bracketRegex': bracketRegexp});
|
3468 |
-
|
3469 |
-
if (!start || !end) {
|
3470 |
-
return { start: cur, end: cur };
|
3471 |
-
}
|
3472 |
-
|
3473 |
-
start = start.pos;
|
3474 |
-
end = end.pos;
|
3475 |
-
|
3476 |
-
if ((start.line == end.line && start.ch > end.ch)
|
3477 |
-
|| (start.line > end.line)) {
|
3478 |
-
var tmp = start;
|
3479 |
-
start = end;
|
3480 |
-
end = tmp;
|
3481 |
-
}
|
3482 |
-
|
3483 |
-
if (inclusive) {
|
3484 |
-
end.ch += 1;
|
3485 |
-
} else {
|
3486 |
-
start.ch += 1;
|
3487 |
-
}
|
3488 |
-
|
3489 |
-
return { start: start, end: end };
|
3490 |
-
}
|
3491 |
-
|
3492 |
-
// Takes in a symbol and a cursor and tries to simulate text objects that
|
3493 |
-
// have identical opening and closing symbols
|
3494 |
-
// TODO support across multiple lines
|
3495 |
-
function findBeginningAndEnd(cm, head, symb, inclusive) {
|
3496 |
-
var cur = copyCursor(head);
|
3497 |
-
var line = cm.getLine(cur.line);
|
3498 |
-
var chars = line.split('');
|
3499 |
-
var start, end, i, len;
|
3500 |
-
var firstIndex = chars.indexOf(symb);
|
3501 |
-
|
3502 |
-
// the decision tree is to always look backwards for the beginning first,
|
3503 |
-
// but if the cursor is in front of the first instance of the symb,
|
3504 |
-
// then move the cursor forward
|
3505 |
-
if (cur.ch < firstIndex) {
|
3506 |
-
cur.ch = firstIndex;
|
3507 |
-
// Why is this line even here???
|
3508 |
-
// cm.setCursor(cur.line, firstIndex+1);
|
3509 |
-
}
|
3510 |
-
// otherwise if the cursor is currently on the closing symbol
|
3511 |
-
else if (firstIndex < cur.ch && chars[cur.ch] == symb) {
|
3512 |
-
end = cur.ch; // assign end to the current cursor
|
3513 |
-
--cur.ch; // make sure to look backwards
|
3514 |
-
}
|
3515 |
-
|
3516 |
-
// if we're currently on the symbol, we've got a start
|
3517 |
-
if (chars[cur.ch] == symb && !end) {
|
3518 |
-
start = cur.ch + 1; // assign start to ahead of the cursor
|
3519 |
-
} else {
|
3520 |
-
// go backwards to find the start
|
3521 |
-
for (i = cur.ch; i > -1 && !start; i--) {
|
3522 |
-
if (chars[i] == symb) {
|
3523 |
-
start = i + 1;
|
3524 |
-
}
|
3525 |
-
}
|
3526 |
-
}
|
3527 |
-
|
3528 |
-
// look forwards for the end symbol
|
3529 |
-
if (start && !end) {
|
3530 |
-
for (i = start, len = chars.length; i < len && !end; i++) {
|
3531 |
-
if (chars[i] == symb) {
|
3532 |
-
end = i;
|
3533 |
-
}
|
3534 |
-
}
|
3535 |
-
}
|
3536 |
-
|
3537 |
-
// nothing found
|
3538 |
-
if (!start || !end) {
|
3539 |
-
return { start: cur, end: cur };
|
3540 |
-
}
|
3541 |
-
|
3542 |
-
// include the symbols
|
3543 |
-
if (inclusive) {
|
3544 |
-
--start; ++end;
|
3545 |
-
}
|
3546 |
-
|
3547 |
-
return {
|
3548 |
-
start: Pos(cur.line, start),
|
3549 |
-
end: Pos(cur.line, end)
|
3550 |
-
};
|
3551 |
-
}
|
3552 |
-
|
3553 |
-
// Search functions
|
3554 |
-
defineOption('pcre', true, 'boolean');
|
3555 |
-
function SearchState() {}
|
3556 |
-
SearchState.prototype = {
|
3557 |
-
getQuery: function() {
|
3558 |
-
return vimGlobalState.query;
|
3559 |
-
},
|
3560 |
-
setQuery: function(query) {
|
3561 |
-
vimGlobalState.query = query;
|
3562 |
-
},
|
3563 |
-
getOverlay: function() {
|
3564 |
-
return this.searchOverlay;
|
3565 |
-
},
|
3566 |
-
setOverlay: function(overlay) {
|
3567 |
-
this.searchOverlay = overlay;
|
3568 |
-
},
|
3569 |
-
isReversed: function() {
|
3570 |
-
return vimGlobalState.isReversed;
|
3571 |
-
},
|
3572 |
-
setReversed: function(reversed) {
|
3573 |
-
vimGlobalState.isReversed = reversed;
|
3574 |
-
},
|
3575 |
-
getScrollbarAnnotate: function() {
|
3576 |
-
return this.annotate;
|
3577 |
-
},
|
3578 |
-
setScrollbarAnnotate: function(annotate) {
|
3579 |
-
this.annotate = annotate;
|
3580 |
-
}
|
3581 |
-
};
|
3582 |
-
function getSearchState(cm) {
|
3583 |
-
var vim = cm.state.vim;
|
3584 |
-
return vim.searchState_ || (vim.searchState_ = new SearchState());
|
3585 |
-
}
|
3586 |
-
function dialog(cm, template, shortText, onClose, options) {
|
3587 |
-
if (cm.openDialog) {
|
3588 |
-
cm.openDialog(template, onClose, { bottom: true, value: options.value,
|
3589 |
-
onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp,
|
3590 |
-
selectValueOnOpen: false});
|
3591 |
-
}
|
3592 |
-
else {
|
3593 |
-
onClose(prompt(shortText, ''));
|
3594 |
-
}
|
3595 |
-
}
|
3596 |
-
function splitBySlash(argString) {
|
3597 |
-
var slashes = findUnescapedSlashes(argString) || [];
|
3598 |
-
if (!slashes.length) return [];
|
3599 |
-
var tokens = [];
|
3600 |
-
// in case of strings like foo/bar
|
3601 |
-
if (slashes[0] !== 0) return;
|
3602 |
-
for (var i = 0; i < slashes.length; i++) {
|
3603 |
-
if (typeof slashes[i] == 'number')
|
3604 |
-
tokens.push(argString.substring(slashes[i] + 1, slashes[i+1]));
|
3605 |
-
}
|
3606 |
-
return tokens;
|
3607 |
-
}
|
3608 |
-
|
3609 |
-
function findUnescapedSlashes(str) {
|
3610 |
-
var escapeNextChar = false;
|
3611 |
-
var slashes = [];
|
3612 |
-
for (var i = 0; i < str.length; i++) {
|
3613 |
-
var c = str.charAt(i);
|
3614 |
-
if (!escapeNextChar && c == '/') {
|
3615 |
-
slashes.push(i);
|
3616 |
-
}
|
3617 |
-
escapeNextChar = !escapeNextChar && (c == '\\');
|
3618 |
-
}
|
3619 |
-
return slashes;
|
3620 |
-
}
|
3621 |
-
|
3622 |
-
// Translates a search string from ex (vim) syntax into javascript form.
|
3623 |
-
function translateRegex(str) {
|
3624 |
-
// When these match, add a '\' if unescaped or remove one if escaped.
|
3625 |
-
var specials = '|(){';
|
3626 |
-
// Remove, but never add, a '\' for these.
|
3627 |
-
var unescape = '}';
|
3628 |
-
var escapeNextChar = false;
|
3629 |
-
var out = [];
|
3630 |
-
for (var i = -1; i < str.length; i++) {
|
3631 |
-
var c = str.charAt(i) || '';
|
3632 |
-
var n = str.charAt(i+1) || '';
|
3633 |
-
var specialComesNext = (n && specials.indexOf(n) != -1);
|
3634 |
-
if (escapeNextChar) {
|
3635 |
-
if (c !== '\\' || !specialComesNext) {
|
3636 |
-
out.push(c);
|
3637 |
-
}
|
3638 |
-
escapeNextChar = false;
|
3639 |
-
} else {
|
3640 |
-
if (c === '\\') {
|
3641 |
-
escapeNextChar = true;
|
3642 |
-
// Treat the unescape list as special for removing, but not adding '\'.
|
3643 |
-
if (n && unescape.indexOf(n) != -1) {
|
3644 |
-
specialComesNext = true;
|
3645 |
-
}
|
3646 |
-
// Not passing this test means removing a '\'.
|
3647 |
-
if (!specialComesNext || n === '\\') {
|
3648 |
-
out.push(c);
|
3649 |
-
}
|
3650 |
-
} else {
|
3651 |
-
out.push(c);
|
3652 |
-
if (specialComesNext && n !== '\\') {
|
3653 |
-
out.push('\\');
|
3654 |
-
}
|
3655 |
-
}
|
3656 |
-
}
|
3657 |
-
}
|
3658 |
-
return out.join('');
|
3659 |
-
}
|
3660 |
-
|
3661 |
-
// Translates the replace part of a search and replace from ex (vim) syntax into
|
3662 |
-
// javascript form. Similar to translateRegex, but additionally fixes back references
|
3663 |
-
// (translates '\[0..9]' to '$[0..9]') and follows different rules for escaping '$'.
|
3664 |
-
var charUnescapes = {'\\n': '\n', '\\r': '\r', '\\t': '\t'};
|
3665 |
-
function translateRegexReplace(str) {
|
3666 |
-
var escapeNextChar = false;
|
3667 |
-
var out = [];
|
3668 |
-
for (var i = -1; i < str.length; i++) {
|
3669 |
-
var c = str.charAt(i) || '';
|
3670 |
-
var n = str.charAt(i+1) || '';
|
3671 |
-
if (charUnescapes[c + n]) {
|
3672 |
-
out.push(charUnescapes[c+n]);
|
3673 |
-
i++;
|
3674 |
-
} else if (escapeNextChar) {
|
3675 |
-
// At any point in the loop, escapeNextChar is true if the previous
|
3676 |
-
// character was a '\' and was not escaped.
|
3677 |
-
out.push(c);
|
3678 |
-
escapeNextChar = false;
|
3679 |
-
} else {
|
3680 |
-
if (c === '\\') {
|
3681 |
-
escapeNextChar = true;
|
3682 |
-
if ((isNumber(n) || n === '$')) {
|
3683 |
-
out.push('$');
|
3684 |
-
} else if (n !== '/' && n !== '\\') {
|
3685 |
-
out.push('\\');
|
3686 |
-
}
|
3687 |
-
} else {
|
3688 |
-
if (c === '$') {
|
3689 |
-
out.push('$');
|
3690 |
-
}
|
3691 |
-
out.push(c);
|
3692 |
-
if (n === '/') {
|
3693 |
-
out.push('\\');
|
3694 |
-
}
|
3695 |
-
}
|
3696 |
-
}
|
3697 |
-
}
|
3698 |
-
return out.join('');
|
3699 |
-
}
|
3700 |
-
|
3701 |
-
// Unescape \ and / in the replace part, for PCRE mode.
|
3702 |
-
var unescapes = {'\\/': '/', '\\\\': '\\', '\\n': '\n', '\\r': '\r', '\\t': '\t'};
|
3703 |
-
function unescapeRegexReplace(str) {
|
3704 |
-
var stream = new CodeMirror.StringStream(str);
|
3705 |
-
var output = [];
|
3706 |
-
while (!stream.eol()) {
|
3707 |
-
// Search for \.
|
3708 |
-
while (stream.peek() && stream.peek() != '\\') {
|
3709 |
-
output.push(stream.next());
|
3710 |
-
}
|
3711 |
-
var matched = false;
|
3712 |
-
for (var matcher in unescapes) {
|
3713 |
-
if (stream.match(matcher, true)) {
|
3714 |
-
matched = true;
|
3715 |
-
output.push(unescapes[matcher]);
|
3716 |
-
break;
|
3717 |
-
}
|
3718 |
-
}
|
3719 |
-
if (!matched) {
|
3720 |
-
// Don't change anything
|
3721 |
-
output.push(stream.next());
|
3722 |
-
}
|
3723 |
-
}
|
3724 |
-
return output.join('');
|
3725 |
-
}
|
3726 |
-
|
3727 |
-
/**
|
3728 |
-
* Extract the regular expression from the query and return a Regexp object.
|
3729 |
-
* Returns null if the query is blank.
|
3730 |
-
* If ignoreCase is passed in, the Regexp object will have the 'i' flag set.
|
3731 |
-
* If smartCase is passed in, and the query contains upper case letters,
|
3732 |
-
* then ignoreCase is overridden, and the 'i' flag will not be set.
|
3733 |
-
* If the query contains the /i in the flag part of the regular expression,
|
3734 |
-
* then both ignoreCase and smartCase are ignored, and 'i' will be passed
|
3735 |
-
* through to the Regex object.
|
3736 |
-
*/
|
3737 |
-
function parseQuery(query, ignoreCase, smartCase) {
|
3738 |
-
// First update the last search register
|
3739 |
-
var lastSearchRegister = vimGlobalState.registerController.getRegister('/');
|
3740 |
-
lastSearchRegister.setText(query);
|
3741 |
-
// Check if the query is already a regex.
|
3742 |
-
if (query instanceof RegExp) { return query; }
|
3743 |
-
// First try to extract regex + flags from the input. If no flags found,
|
3744 |
-
// extract just the regex. IE does not accept flags directly defined in
|
3745 |
-
// the regex string in the form /regex/flags
|
3746 |
-
var slashes = findUnescapedSlashes(query);
|
3747 |
-
var regexPart;
|
3748 |
-
var forceIgnoreCase;
|
3749 |
-
if (!slashes.length) {
|
3750 |
-
// Query looks like 'regexp'
|
3751 |
-
regexPart = query;
|
3752 |
-
} else {
|
3753 |
-
// Query looks like 'regexp/...'
|
3754 |
-
regexPart = query.substring(0, slashes[0]);
|
3755 |
-
var flagsPart = query.substring(slashes[0]);
|
3756 |
-
forceIgnoreCase = (flagsPart.indexOf('i') != -1);
|
3757 |
-
}
|
3758 |
-
if (!regexPart) {
|
3759 |
-
return null;
|
3760 |
-
}
|
3761 |
-
if (!getOption('pcre')) {
|
3762 |
-
regexPart = translateRegex(regexPart);
|
3763 |
-
}
|
3764 |
-
if (smartCase) {
|
3765 |
-
ignoreCase = (/^[^A-Z]*$/).test(regexPart);
|
3766 |
-
}
|
3767 |
-
var regexp = new RegExp(regexPart,
|
3768 |
-
(ignoreCase || forceIgnoreCase) ? 'i' : undefined);
|
3769 |
-
return regexp;
|
3770 |
-
}
|
3771 |
-
function showConfirm(cm, text) {
|
3772 |
-
if (cm.openNotification) {
|
3773 |
-
cm.openNotification('<span style="color: red">' + text + '</span>',
|
3774 |
-
{bottom: true, duration: 5000});
|
3775 |
-
} else {
|
3776 |
-
alert(text);
|
3777 |
-
}
|
3778 |
-
}
|
3779 |
-
function makePrompt(prefix, desc) {
|
3780 |
-
var raw = '';
|
3781 |
-
if (prefix) {
|
3782 |
-
raw += '<span style="font-family: monospace">' + prefix + '</span>';
|
3783 |
-
}
|
3784 |
-
raw += '<input type="text"/> ' +
|
3785 |
-
'<span style="color: #888">';
|
3786 |
-
if (desc) {
|
3787 |
-
raw += '<span style="color: #888">';
|
3788 |
-
raw += desc;
|
3789 |
-
raw += '</span>';
|
3790 |
-
}
|
3791 |
-
return raw;
|
3792 |
-
}
|
3793 |
-
var searchPromptDesc = '(Javascript regexp)';
|
3794 |
-
function showPrompt(cm, options) {
|
3795 |
-
var shortText = (options.prefix || '') + ' ' + (options.desc || '');
|
3796 |
-
var prompt = makePrompt(options.prefix, options.desc);
|
3797 |
-
dialog(cm, prompt, shortText, options.onClose, options);
|
3798 |
-
}
|
3799 |
-
function regexEqual(r1, r2) {
|
3800 |
-
if (r1 instanceof RegExp && r2 instanceof RegExp) {
|
3801 |
-
var props = ['global', 'multiline', 'ignoreCase', 'source'];
|
3802 |
-
for (var i = 0; i < props.length; i++) {
|
3803 |
-
var prop = props[i];
|
3804 |
-
if (r1[prop] !== r2[prop]) {
|
3805 |
-
return false;
|
3806 |
-
}
|
3807 |
-
}
|
3808 |
-
return true;
|
3809 |
-
}
|
3810 |
-
return false;
|
3811 |
-
}
|
3812 |
-
// Returns true if the query is valid.
|
3813 |
-
function updateSearchQuery(cm, rawQuery, ignoreCase, smartCase) {
|
3814 |
-
if (!rawQuery) {
|
3815 |
-
return;
|
3816 |
-
}
|
3817 |
-
var state = getSearchState(cm);
|
3818 |
-
var query = parseQuery(rawQuery, !!ignoreCase, !!smartCase);
|
3819 |
-
if (!query) {
|
3820 |
-
return;
|
3821 |
-
}
|
3822 |
-
highlightSearchMatches(cm, query);
|
3823 |
-
if (regexEqual(query, state.getQuery())) {
|
3824 |
-
return query;
|
3825 |
-
}
|
3826 |
-
state.setQuery(query);
|
3827 |
-
return query;
|
3828 |
-
}
|
3829 |
-
function searchOverlay(query) {
|
3830 |
-
if (query.source.charAt(0) == '^') {
|
3831 |
-
var matchSol = true;
|
3832 |
-
}
|
3833 |
-
return {
|
3834 |
-
token: function(stream) {
|
3835 |
-
if (matchSol && !stream.sol()) {
|
3836 |
-
stream.skipToEnd();
|
3837 |
-
return;
|
3838 |
-
}
|
3839 |
-
var match = stream.match(query, false);
|
3840 |
-
if (match) {
|
3841 |
-
if (match[0].length == 0) {
|
3842 |
-
// Matched empty string, skip to next.
|
3843 |
-
stream.next();
|
3844 |
-
return 'searching';
|
3845 |
-
}
|
3846 |
-
if (!stream.sol()) {
|
3847 |
-
// Backtrack 1 to match \b
|
3848 |
-
stream.backUp(1);
|
3849 |
-
if (!query.exec(stream.next() + match[0])) {
|
3850 |
-
stream.next();
|
3851 |
-
return null;
|
3852 |
-
}
|
3853 |
-
}
|
3854 |
-
stream.match(query);
|
3855 |
-
return 'searching';
|
3856 |
-
}
|
3857 |
-
while (!stream.eol()) {
|
3858 |
-
stream.next();
|
3859 |
-
if (stream.match(query, false)) break;
|
3860 |
-
}
|
3861 |
-
},
|
3862 |
-
query: query
|
3863 |
-
};
|
3864 |
-
}
|
3865 |
-
function highlightSearchMatches(cm, query) {
|
3866 |
-
var searchState = getSearchState(cm);
|
3867 |
-
var overlay = searchState.getOverlay();
|
3868 |
-
if (!overlay || query != overlay.query) {
|
3869 |
-
if (overlay) {
|
3870 |
-
cm.removeOverlay(overlay);
|
3871 |
-
}
|
3872 |
-
overlay = searchOverlay(query);
|
3873 |
-
cm.addOverlay(overlay);
|
3874 |
-
if (cm.showMatchesOnScrollbar) {
|
3875 |
-
if (searchState.getScrollbarAnnotate()) {
|
3876 |
-
searchState.getScrollbarAnnotate().clear();
|
3877 |
-
}
|
3878 |
-
searchState.setScrollbarAnnotate(cm.showMatchesOnScrollbar(query));
|
3879 |
-
}
|
3880 |
-
searchState.setOverlay(overlay);
|
3881 |
-
}
|
3882 |
-
}
|
3883 |
-
function findNext(cm, prev, query, repeat) {
|
3884 |
-
if (repeat === undefined) { repeat = 1; }
|
3885 |
-
return cm.operation(function() {
|
3886 |
-
var pos = cm.getCursor();
|
3887 |
-
var cursor = cm.getSearchCursor(query, pos);
|
3888 |
-
for (var i = 0; i < repeat; i++) {
|
3889 |
-
var found = cursor.find(prev);
|
3890 |
-
if (i == 0 && found && cursorEqual(cursor.from(), pos)) { found = cursor.find(prev); }
|
3891 |
-
if (!found) {
|
3892 |
-
// SearchCursor may have returned null because it hit EOF, wrap
|
3893 |
-
// around and try again.
|
3894 |
-
cursor = cm.getSearchCursor(query,
|
3895 |
-
(prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) );
|
3896 |
-
if (!cursor.find(prev)) {
|
3897 |
-
return;
|
3898 |
-
}
|
3899 |
-
}
|
3900 |
-
}
|
3901 |
-
return cursor.from();
|
3902 |
-
});
|
3903 |
-
}
|
3904 |
-
function clearSearchHighlight(cm) {
|
3905 |
-
var state = getSearchState(cm);
|
3906 |
-
cm.removeOverlay(getSearchState(cm).getOverlay());
|
3907 |
-
state.setOverlay(null);
|
3908 |
-
if (state.getScrollbarAnnotate()) {
|
3909 |
-
state.getScrollbarAnnotate().clear();
|
3910 |
-
state.setScrollbarAnnotate(null);
|
3911 |
-
}
|
3912 |
-
}
|
3913 |
-
/**
|
3914 |
-
* Check if pos is in the specified range, INCLUSIVE.
|
3915 |
-
* Range can be specified with 1 or 2 arguments.
|
3916 |
-
* If the first range argument is an array, treat it as an array of line
|
3917 |
-
* numbers. Match pos against any of the lines.
|
3918 |
-
* If the first range argument is a number,
|
3919 |
-
* if there is only 1 range argument, check if pos has the same line
|
3920 |
-
* number
|
3921 |
-
* if there are 2 range arguments, then check if pos is in between the two
|
3922 |
-
* range arguments.
|
3923 |
-
*/
|
3924 |
-
function isInRange(pos, start, end) {
|
3925 |
-
if (typeof pos != 'number') {
|
3926 |
-
// Assume it is a cursor position. Get the line number.
|
3927 |
-
pos = pos.line;
|
3928 |
-
}
|
3929 |
-
if (start instanceof Array) {
|
3930 |
-
return inArray(pos, start);
|
3931 |
-
} else {
|
3932 |
-
if (end) {
|
3933 |
-
return (pos >= start && pos <= end);
|
3934 |
-
} else {
|
3935 |
-
return pos == start;
|
3936 |
-
}
|
3937 |
-
}
|
3938 |
-
}
|
3939 |
-
function getUserVisibleLines(cm) {
|
3940 |
-
var scrollInfo = cm.getScrollInfo();
|
3941 |
-
var occludeToleranceTop = 6;
|
3942 |
-
var occludeToleranceBottom = 10;
|
3943 |
-
var from = cm.coordsChar({left:0, top: occludeToleranceTop + scrollInfo.top}, 'local');
|
3944 |
-
var bottomY = scrollInfo.clientHeight - occludeToleranceBottom + scrollInfo.top;
|
3945 |
-
var to = cm.coordsChar({left:0, top: bottomY}, 'local');
|
3946 |
-
return {top: from.line, bottom: to.line};
|
3947 |
-
}
|
3948 |
-
|
3949 |
-
var ExCommandDispatcher = function() {
|
3950 |
-
this.buildCommandMap_();
|
3951 |
-
};
|
3952 |
-
ExCommandDispatcher.prototype = {
|
3953 |
-
processCommand: function(cm, input, opt_params) {
|
3954 |
-
var that = this;
|
3955 |
-
cm.operation(function () {
|
3956 |
-
cm.curOp.isVimOp = true;
|
3957 |
-
that._processCommand(cm, input, opt_params);
|
3958 |
-
});
|
3959 |
-
},
|
3960 |
-
_processCommand: function(cm, input, opt_params) {
|
3961 |
-
var vim = cm.state.vim;
|
3962 |
-
var commandHistoryRegister = vimGlobalState.registerController.getRegister(':');
|
3963 |
-
var previousCommand = commandHistoryRegister.toString();
|
3964 |
-
if (vim.visualMode) {
|
3965 |
-
exitVisualMode(cm);
|
3966 |
-
}
|
3967 |
-
var inputStream = new CodeMirror.StringStream(input);
|
3968 |
-
// update ": with the latest command whether valid or invalid
|
3969 |
-
commandHistoryRegister.setText(input);
|
3970 |
-
var params = opt_params || {};
|
3971 |
-
params.input = input;
|
3972 |
-
try {
|
3973 |
-
this.parseInput_(cm, inputStream, params);
|
3974 |
-
} catch(e) {
|
3975 |
-
showConfirm(cm, e);
|
3976 |
-
throw e;
|
3977 |
-
}
|
3978 |
-
var command;
|
3979 |
-
var commandName;
|
3980 |
-
if (!params.commandName) {
|
3981 |
-
// If only a line range is defined, move to the line.
|
3982 |
-
if (params.line !== undefined) {
|
3983 |
-
commandName = 'move';
|
3984 |
-
}
|
3985 |
-
} else {
|
3986 |
-
command = this.matchCommand_(params.commandName);
|
3987 |
-
if (command) {
|
3988 |
-
commandName = command.name;
|
3989 |
-
if (command.excludeFromCommandHistory) {
|
3990 |
-
commandHistoryRegister.setText(previousCommand);
|
3991 |
-
}
|
3992 |
-
this.parseCommandArgs_(inputStream, params, command);
|
3993 |
-
if (command.type == 'exToKey') {
|
3994 |
-
// Handle Ex to Key mapping.
|
3995 |
-
for (var i = 0; i < command.toKeys.length; i++) {
|
3996 |
-
CodeMirror.Vim.handleKey(cm, command.toKeys[i], 'mapping');
|
3997 |
-
}
|
3998 |
-
return;
|
3999 |
-
} else if (command.type == 'exToEx') {
|
4000 |
-
// Handle Ex to Ex mapping.
|
4001 |
-
this.processCommand(cm, command.toInput);
|
4002 |
-
return;
|
4003 |
-
}
|
4004 |
-
}
|
4005 |
-
}
|
4006 |
-
if (!commandName) {
|
4007 |
-
showConfirm(cm, 'Not an editor command ":' + input + '"');
|
4008 |
-
return;
|
4009 |
-
}
|
4010 |
-
try {
|
4011 |
-
exCommands[commandName](cm, params);
|
4012 |
-
// Possibly asynchronous commands (e.g. substitute, which might have a
|
4013 |
-
// user confirmation), are responsible for calling the callback when
|
4014 |
-
// done. All others have it taken care of for them here.
|
4015 |
-
if ((!command || !command.possiblyAsync) && params.callback) {
|
4016 |
-
params.callback();
|
4017 |
-
}
|
4018 |
-
} catch(e) {
|
4019 |
-
showConfirm(cm, e);
|
4020 |
-
throw e;
|
4021 |
-
}
|
4022 |
-
},
|
4023 |
-
parseInput_: function(cm, inputStream, result) {
|
4024 |
-
inputStream.eatWhile(':');
|
4025 |
-
// Parse range.
|
4026 |
-
if (inputStream.eat('%')) {
|
4027 |
-
result.line = cm.firstLine();
|
4028 |
-
result.lineEnd = cm.lastLine();
|
4029 |
-
} else {
|
4030 |
-
result.line = this.parseLineSpec_(cm, inputStream);
|
4031 |
-
if (result.line !== undefined && inputStream.eat(',')) {
|
4032 |
-
result.lineEnd = this.parseLineSpec_(cm, inputStream);
|
4033 |
-
}
|
4034 |
-
}
|
4035 |
-
|
4036 |
-
// Parse command name.
|
4037 |
-
var commandMatch = inputStream.match(/^(\w+)/);
|
4038 |
-
if (commandMatch) {
|
4039 |
-
result.commandName = commandMatch[1];
|
4040 |
-
} else {
|
4041 |
-
result.commandName = inputStream.match(/.*/)[0];
|
4042 |
-
}
|
4043 |
-
|
4044 |
-
return result;
|
4045 |
-
},
|
4046 |
-
parseLineSpec_: function(cm, inputStream) {
|
4047 |
-
var numberMatch = inputStream.match(/^(\d+)/);
|
4048 |
-
if (numberMatch) {
|
4049 |
-
return parseInt(numberMatch[1], 10) - 1;
|
4050 |
-
}
|
4051 |
-
switch (inputStream.next()) {
|
4052 |
-
case '.':
|
4053 |
-
return cm.getCursor().line;
|
4054 |
-
case '$':
|
4055 |
-
return cm.lastLine();
|
4056 |
-
case '\'':
|
4057 |
-
var mark = cm.state.vim.marks[inputStream.next()];
|
4058 |
-
if (mark && mark.find()) {
|
4059 |
-
return mark.find().line;
|
4060 |
-
}
|
4061 |
-
throw new Error('Mark not set');
|
4062 |
-
default:
|
4063 |
-
inputStream.backUp(1);
|
4064 |
-
return undefined;
|
4065 |
-
}
|
4066 |
-
},
|
4067 |
-
parseCommandArgs_: function(inputStream, params, command) {
|
4068 |
-
if (inputStream.eol()) {
|
4069 |
-
return;
|
4070 |
-
}
|
4071 |
-
params.argString = inputStream.match(/.*/)[0];
|
4072 |
-
// Parse command-line arguments
|
4073 |
-
var delim = command.argDelimiter || /\s+/;
|
4074 |
-
var args = trim(params.argString).split(delim);
|
4075 |
-
if (args.length && args[0]) {
|
4076 |
-
params.args = args;
|
4077 |
-
}
|
4078 |
-
},
|
4079 |
-
matchCommand_: function(commandName) {
|
4080 |
-
// Return the command in the command map that matches the shortest
|
4081 |
-
// prefix of the passed in command name. The match is guaranteed to be
|
4082 |
-
// unambiguous if the defaultExCommandMap's shortNames are set up
|
4083 |
-
// correctly. (see @code{defaultExCommandMap}).
|
4084 |
-
for (var i = commandName.length; i > 0; i--) {
|
4085 |
-
var prefix = commandName.substring(0, i);
|
4086 |
-
if (this.commandMap_[prefix]) {
|
4087 |
-
var command = this.commandMap_[prefix];
|
4088 |
-
if (command.name.indexOf(commandName) === 0) {
|
4089 |
-
return command;
|
4090 |
-
}
|
4091 |
-
}
|
4092 |
-
}
|
4093 |
-
return null;
|
4094 |
-
},
|
4095 |
-
buildCommandMap_: function() {
|
4096 |
-
this.commandMap_ = {};
|
4097 |
-
for (var i = 0; i < defaultExCommandMap.length; i++) {
|
4098 |
-
var command = defaultExCommandMap[i];
|
4099 |
-
var key = command.shortName || command.name;
|
4100 |
-
this.commandMap_[key] = command;
|
4101 |
-
}
|
4102 |
-
},
|
4103 |
-
map: function(lhs, rhs, ctx) {
|
4104 |
-
if (lhs != ':' && lhs.charAt(0) == ':') {
|
4105 |
-
if (ctx) { throw Error('Mode not supported for ex mappings'); }
|
4106 |
-
var commandName = lhs.substring(1);
|
4107 |
-
if (rhs != ':' && rhs.charAt(0) == ':') {
|
4108 |
-
// Ex to Ex mapping
|
4109 |
-
this.commandMap_[commandName] = {
|
4110 |
-
name: commandName,
|
4111 |
-
type: 'exToEx',
|
4112 |
-
toInput: rhs.substring(1),
|
4113 |
-
user: true
|
4114 |
-
};
|
4115 |
-
} else {
|
4116 |
-
// Ex to key mapping
|
4117 |
-
this.commandMap_[commandName] = {
|
4118 |
-
name: commandName,
|
4119 |
-
type: 'exToKey',
|
4120 |
-
toKeys: rhs,
|
4121 |
-
user: true
|
4122 |
-
};
|
4123 |
-
}
|
4124 |
-
} else {
|
4125 |
-
if (rhs != ':' && rhs.charAt(0) == ':') {
|
4126 |
-
// Key to Ex mapping.
|
4127 |
-
var mapping = {
|
4128 |
-
keys: lhs,
|
4129 |
-
type: 'keyToEx',
|
4130 |
-
exArgs: { input: rhs.substring(1) },
|
4131 |
-
user: true};
|
4132 |
-
if (ctx) { mapping.context = ctx; }
|
4133 |
-
defaultKeymap.unshift(mapping);
|
4134 |
-
} else {
|
4135 |
-
// Key to key mapping
|
4136 |
-
var mapping = {
|
4137 |
-
keys: lhs,
|
4138 |
-
type: 'keyToKey',
|
4139 |
-
toKeys: rhs,
|
4140 |
-
user: true
|
4141 |
-
};
|
4142 |
-
if (ctx) { mapping.context = ctx; }
|
4143 |
-
defaultKeymap.unshift(mapping);
|
4144 |
-
}
|
4145 |
-
}
|
4146 |
-
},
|
4147 |
-
unmap: function(lhs, ctx) {
|
4148 |
-
if (lhs != ':' && lhs.charAt(0) == ':') {
|
4149 |
-
// Ex to Ex or Ex to key mapping
|
4150 |
-
if (ctx) { throw Error('Mode not supported for ex mappings'); }
|
4151 |
-
var commandName = lhs.substring(1);
|
4152 |
-
if (this.commandMap_[commandName] && this.commandMap_[commandName].user) {
|
4153 |
-
delete this.commandMap_[commandName];
|
4154 |
-
return;
|
4155 |
-
}
|
4156 |
-
} else {
|
4157 |
-
// Key to Ex or key to key mapping
|
4158 |
-
var keys = lhs;
|
4159 |
-
for (var i = 0; i < defaultKeymap.length; i++) {
|
4160 |
-
if (keys == defaultKeymap[i].keys
|
4161 |
-
&& defaultKeymap[i].context === ctx
|
4162 |
-
&& defaultKeymap[i].user) {
|
4163 |
-
defaultKeymap.splice(i, 1);
|
4164 |
-
return;
|
4165 |
-
}
|
4166 |
-
}
|
4167 |
-
}
|
4168 |
-
throw Error('No such mapping.');
|
4169 |
-
}
|
4170 |
-
};
|
4171 |
-
|
4172 |
-
var exCommands = {
|
4173 |
-
colorscheme: function(cm, params) {
|
4174 |
-
if (!params.args || params.args.length < 1) {
|
4175 |
-
showConfirm(cm, cm.getOption('theme'));
|
4176 |
-
return;
|
4177 |
-
}
|
4178 |
-
cm.setOption('theme', params.args[0]);
|
4179 |
-
},
|
4180 |
-
map: function(cm, params, ctx) {
|
4181 |
-
var mapArgs = params.args;
|
4182 |
-
if (!mapArgs || mapArgs.length < 2) {
|
4183 |
-
if (cm) {
|
4184 |
-
showConfirm(cm, 'Invalid mapping: ' + params.input);
|
4185 |
-
}
|
4186 |
-
return;
|
4187 |
-
}
|
4188 |
-
exCommandDispatcher.map(mapArgs[0], mapArgs[1], ctx);
|
4189 |
-
},
|
4190 |
-
imap: function(cm, params) { this.map(cm, params, 'insert'); },
|
4191 |
-
nmap: function(cm, params) { this.map(cm, params, 'normal'); },
|
4192 |
-
vmap: function(cm, params) { this.map(cm, params, 'visual'); },
|
4193 |
-
unmap: function(cm, params, ctx) {
|
4194 |
-
var mapArgs = params.args;
|
4195 |
-
if (!mapArgs || mapArgs.length < 1) {
|
4196 |
-
if (cm) {
|
4197 |
-
showConfirm(cm, 'No such mapping: ' + params.input);
|
4198 |
-
}
|
4199 |
-
return;
|
4200 |
-
}
|
4201 |
-
exCommandDispatcher.unmap(mapArgs[0], ctx);
|
4202 |
-
},
|
4203 |
-
move: function(cm, params) {
|
4204 |
-
commandDispatcher.processCommand(cm, cm.state.vim, {
|
4205 |
-
type: 'motion',
|
4206 |
-
motion: 'moveToLineOrEdgeOfDocument',
|
4207 |
-
motionArgs: { forward: false, explicitRepeat: true,
|
4208 |
-
linewise: true },
|
4209 |
-
repeatOverride: params.line+1});
|
4210 |
-
},
|
4211 |
-
set: function(cm, params) {
|
4212 |
-
var setArgs = params.args;
|
4213 |
-
// Options passed through to the setOption/getOption calls. May be passed in by the
|
4214 |
-
// local/global versions of the set command
|
4215 |
-
var setCfg = params.setCfg || {};
|
4216 |
-
if (!setArgs || setArgs.length < 1) {
|
4217 |
-
if (cm) {
|
4218 |
-
showConfirm(cm, 'Invalid mapping: ' + params.input);
|
4219 |
-
}
|
4220 |
-
return;
|
4221 |
-
}
|
4222 |
-
var expr = setArgs[0].split('=');
|
4223 |
-
var optionName = expr[0];
|
4224 |
-
var value = expr[1];
|
4225 |
-
var forceGet = false;
|
4226 |
-
|
4227 |
-
if (optionName.charAt(optionName.length - 1) == '?') {
|
4228 |
-
// If post-fixed with ?, then the set is actually a get.
|
4229 |
-
if (value) { throw Error('Trailing characters: ' + params.argString); }
|
4230 |
-
optionName = optionName.substring(0, optionName.length - 1);
|
4231 |
-
forceGet = true;
|
4232 |
-
}
|
4233 |
-
if (value === undefined && optionName.substring(0, 2) == 'no') {
|
4234 |
-
// To set boolean options to false, the option name is prefixed with
|
4235 |
-
// 'no'.
|
4236 |
-
optionName = optionName.substring(2);
|
4237 |
-
value = false;
|
4238 |
-
}
|
4239 |
-
|
4240 |
-
var optionIsBoolean = options[optionName] && options[optionName].type == 'boolean';
|
4241 |
-
if (optionIsBoolean && value == undefined) {
|
4242 |
-
// Calling set with a boolean option sets it to true.
|
4243 |
-
value = true;
|
4244 |
-
}
|
4245 |
-
// If no value is provided, then we assume this is a get.
|
4246 |
-
if (!optionIsBoolean && value === undefined || forceGet) {
|
4247 |
-
var oldValue = getOption(optionName, cm, setCfg);
|
4248 |
-
if (oldValue === true || oldValue === false) {
|
4249 |
-
showConfirm(cm, ' ' + (oldValue ? '' : 'no') + optionName);
|
4250 |
-
} else {
|
4251 |
-
showConfirm(cm, ' ' + optionName + '=' + oldValue);
|
4252 |
-
}
|
4253 |
-
} else {
|
4254 |
-
setOption(optionName, value, cm, setCfg);
|
4255 |
-
}
|
4256 |
-
},
|
4257 |
-
setlocal: function (cm, params) {
|
4258 |
-
// setCfg is passed through to setOption
|
4259 |
-
params.setCfg = {scope: 'local'};
|
4260 |
-
this.set(cm, params);
|
4261 |
-
},
|
4262 |
-
setglobal: function (cm, params) {
|
4263 |
-
// setCfg is passed through to setOption
|
4264 |
-
params.setCfg = {scope: 'global'};
|
4265 |
-
this.set(cm, params);
|
4266 |
-
},
|
4267 |
-
registers: function(cm, params) {
|
4268 |
-
var regArgs = params.args;
|
4269 |
-
var registers = vimGlobalState.registerController.registers;
|
4270 |
-
var regInfo = '----------Registers----------<br><br>';
|
4271 |
-
if (!regArgs) {
|
4272 |
-
for (var registerName in registers) {
|
4273 |
-
var text = registers[registerName].toString();
|
4274 |
-
if (text.length) {
|
4275 |
-
regInfo += '"' + registerName + ' ' + text + '<br>';
|
4276 |
-
}
|
4277 |
-
}
|
4278 |
-
} else {
|
4279 |
-
var registerName;
|
4280 |
-
regArgs = regArgs.join('');
|
4281 |
-
for (var i = 0; i < regArgs.length; i++) {
|
4282 |
-
registerName = regArgs.charAt(i);
|
4283 |
-
if (!vimGlobalState.registerController.isValidRegister(registerName)) {
|
4284 |
-
continue;
|
4285 |
-
}
|
4286 |
-
var register = registers[registerName] || new Register();
|
4287 |
-
regInfo += '"' + registerName + ' ' + register.toString() + '<br>';
|
4288 |
-
}
|
4289 |
-
}
|
4290 |
-
showConfirm(cm, regInfo);
|
4291 |
-
},
|
4292 |
-
sort: function(cm, params) {
|
4293 |
-
var reverse, ignoreCase, unique, number;
|
4294 |
-
function parseArgs() {
|
4295 |
-
if (params.argString) {
|
4296 |
-
var args = new CodeMirror.StringStream(params.argString);
|
4297 |
-
if (args.eat('!')) { reverse = true; }
|
4298 |
-
if (args.eol()) { return; }
|
4299 |
-
if (!args.eatSpace()) { return 'Invalid arguments'; }
|
4300 |
-
var opts = args.match(/[a-z]+/);
|
4301 |
-
if (opts) {
|
4302 |
-
opts = opts[0];
|
4303 |
-
ignoreCase = opts.indexOf('i') != -1;
|
4304 |
-
unique = opts.indexOf('u') != -1;
|
4305 |
-
var decimal = opts.indexOf('d') != -1 && 1;
|
4306 |
-
var hex = opts.indexOf('x') != -1 && 1;
|
4307 |
-
var octal = opts.indexOf('o') != -1 && 1;
|
4308 |
-
if (decimal + hex + octal > 1) { return 'Invalid arguments'; }
|
4309 |
-
number = decimal && 'decimal' || hex && 'hex' || octal && 'octal';
|
4310 |
-
}
|
4311 |
-
if (args.match(/\/.*\//)) { return 'patterns not supported'; }
|
4312 |
-
}
|
4313 |
-
}
|
4314 |
-
var err = parseArgs();
|
4315 |
-
if (err) {
|
4316 |
-
showConfirm(cm, err + ': ' + params.argString);
|
4317 |
-
return;
|
4318 |
-
}
|
4319 |
-
var lineStart = params.line || cm.firstLine();
|
4320 |
-
var lineEnd = params.lineEnd || params.line || cm.lastLine();
|
4321 |
-
if (lineStart == lineEnd) { return; }
|
4322 |
-
var curStart = Pos(lineStart, 0);
|
4323 |
-
var curEnd = Pos(lineEnd, lineLength(cm, lineEnd));
|
4324 |
-
var text = cm.getRange(curStart, curEnd).split('\n');
|
4325 |
-
var numberRegex = (number == 'decimal') ? /(-?)([\d]+)/ :
|
4326 |
-
(number == 'hex') ? /(-?)(?:0x)?([0-9a-f]+)/i :
|
4327 |
-
(number == 'octal') ? /([0-7]+)/ : null;
|
4328 |
-
var radix = (number == 'decimal') ? 10 : (number == 'hex') ? 16 : (number == 'octal') ? 8 : null;
|
4329 |
-
var numPart = [], textPart = [];
|
4330 |
-
if (number) {
|
4331 |
-
for (var i = 0; i < text.length; i++) {
|
4332 |
-
if (numberRegex.exec(text[i])) {
|
4333 |
-
numPart.push(text[i]);
|
4334 |
-
} else {
|
4335 |
-
textPart.push(text[i]);
|
4336 |
-
}
|
4337 |
-
}
|
4338 |
-
} else {
|
4339 |
-
textPart = text;
|
4340 |
-
}
|
4341 |
-
function compareFn(a, b) {
|
4342 |
-
if (reverse) { var tmp; tmp = a; a = b; b = tmp; }
|
4343 |
-
if (ignoreCase) { a = a.toLowerCase(); b = b.toLowerCase(); }
|
4344 |
-
var anum = number && numberRegex.exec(a);
|
4345 |
-
var bnum = number && numberRegex.exec(b);
|
4346 |
-
if (!anum) { return a < b ? -1 : 1; }
|
4347 |
-
anum = parseInt((anum[1] + anum[2]).toLowerCase(), radix);
|
4348 |
-
bnum = parseInt((bnum[1] + bnum[2]).toLowerCase(), radix);
|
4349 |
-
return anum - bnum;
|
4350 |
-
}
|
4351 |
-
numPart.sort(compareFn);
|
4352 |
-
textPart.sort(compareFn);
|
4353 |
-
text = (!reverse) ? textPart.concat(numPart) : numPart.concat(textPart);
|
4354 |
-
if (unique) { // Remove duplicate lines
|
4355 |
-
var textOld = text;
|
4356 |
-
var lastLine;
|
4357 |
-
text = [];
|
4358 |
-
for (var i = 0; i < textOld.length; i++) {
|
4359 |
-
if (textOld[i] != lastLine) {
|
4360 |
-
text.push(textOld[i]);
|
4361 |
-
}
|
4362 |
-
lastLine = textOld[i];
|
4363 |
-
}
|
4364 |
-
}
|
4365 |
-
cm.replaceRange(text.join('\n'), curStart, curEnd);
|
4366 |
-
},
|
4367 |
-
global: function(cm, params) {
|
4368 |
-
// a global command is of the form
|
4369 |
-
// :[range]g/pattern/[cmd]
|
4370 |
-
// argString holds the string /pattern/[cmd]
|
4371 |
-
var argString = params.argString;
|
4372 |
-
if (!argString) {
|
4373 |
-
showConfirm(cm, 'Regular Expression missing from global');
|
4374 |
-
return;
|
4375 |
-
}
|
4376 |
-
// range is specified here
|
4377 |
-
var lineStart = (params.line !== undefined) ? params.line : cm.firstLine();
|
4378 |
-
var lineEnd = params.lineEnd || params.line || cm.lastLine();
|
4379 |
-
// get the tokens from argString
|
4380 |
-
var tokens = splitBySlash(argString);
|
4381 |
-
var regexPart = argString, cmd;
|
4382 |
-
if (tokens.length) {
|
4383 |
-
regexPart = tokens[0];
|
4384 |
-
cmd = tokens.slice(1, tokens.length).join('/');
|
4385 |
-
}
|
4386 |
-
if (regexPart) {
|
4387 |
-
// If regex part is empty, then use the previous query. Otherwise
|
4388 |
-
// use the regex part as the new query.
|
4389 |
-
try {
|
4390 |
-
updateSearchQuery(cm, regexPart, true /** ignoreCase */,
|
4391 |
-
true /** smartCase */);
|
4392 |
-
} catch (e) {
|
4393 |
-
showConfirm(cm, 'Invalid regex: ' + regexPart);
|
4394 |
-
return;
|
4395 |
-
}
|
4396 |
-
}
|
4397 |
-
// now that we have the regexPart, search for regex matches in the
|
4398 |
-
// specified range of lines
|
4399 |
-
var query = getSearchState(cm).getQuery();
|
4400 |
-
var matchedLines = [], content = '';
|
4401 |
-
for (var i = lineStart; i <= lineEnd; i++) {
|
4402 |
-
var matched = query.test(cm.getLine(i));
|
4403 |
-
if (matched) {
|
4404 |
-
matchedLines.push(i+1);
|
4405 |
-
content+= cm.getLine(i) + '<br>';
|
4406 |
-
}
|
4407 |
-
}
|
4408 |
-
// if there is no [cmd], just display the list of matched lines
|
4409 |
-
if (!cmd) {
|
4410 |
-
showConfirm(cm, content);
|
4411 |
-
return;
|
4412 |
-
}
|
4413 |
-
var index = 0;
|
4414 |
-
var nextCommand = function() {
|
4415 |
-
if (index < matchedLines.length) {
|
4416 |
-
var command = matchedLines[index] + cmd;
|
4417 |
-
exCommandDispatcher.processCommand(cm, command, {
|
4418 |
-
callback: nextCommand
|
4419 |
-
});
|
4420 |
-
}
|
4421 |
-
index++;
|
4422 |
-
};
|
4423 |
-
nextCommand();
|
4424 |
-
},
|
4425 |
-
substitute: function(cm, params) {
|
4426 |
-
if (!cm.getSearchCursor) {
|
4427 |
-
throw new Error('Search feature not available. Requires searchcursor.js or ' +
|
4428 |
-
'any other getSearchCursor implementation.');
|
4429 |
-
}
|
4430 |
-
var argString = params.argString;
|
4431 |
-
var tokens = argString ? splitBySlash(argString) : [];
|
4432 |
-
var regexPart, replacePart = '', trailing, flagsPart, count;
|
4433 |
-
var confirm = false; // Whether to confirm each replace.
|
4434 |
-
var global = false; // True to replace all instances on a line, false to replace only 1.
|
4435 |
-
if (tokens.length) {
|
4436 |
-
regexPart = tokens[0];
|
4437 |
-
replacePart = tokens[1];
|
4438 |
-
if (replacePart !== undefined) {
|
4439 |
-
if (getOption('pcre')) {
|
4440 |
-
replacePart = unescapeRegexReplace(replacePart);
|
4441 |
-
} else {
|
4442 |
-
replacePart = translateRegexReplace(replacePart);
|
4443 |
-
}
|
4444 |
-
vimGlobalState.lastSubstituteReplacePart = replacePart;
|
4445 |
-
}
|
4446 |
-
trailing = tokens[2] ? tokens[2].split(' ') : [];
|
4447 |
-
} else {
|
4448 |
-
// either the argString is empty or its of the form ' hello/world'
|
4449 |
-
// actually splitBySlash returns a list of tokens
|
4450 |
-
// only if the string starts with a '/'
|
4451 |
-
if (argString && argString.length) {
|
4452 |
-
showConfirm(cm, 'Substitutions should be of the form ' +
|
4453 |
-
':s/pattern/replace/');
|
4454 |
-
return;
|
4455 |
-
}
|
4456 |
-
}
|
4457 |
-
// After the 3rd slash, we can have flags followed by a space followed
|
4458 |
-
// by count.
|
4459 |
-
if (trailing) {
|
4460 |
-
flagsPart = trailing[0];
|
4461 |
-
count = parseInt(trailing[1]);
|
4462 |
-
if (flagsPart) {
|
4463 |
-
if (flagsPart.indexOf('c') != -1) {
|
4464 |
-
confirm = true;
|
4465 |
-
flagsPart.replace('c', '');
|
4466 |
-
}
|
4467 |
-
if (flagsPart.indexOf('g') != -1) {
|
4468 |
-
global = true;
|
4469 |
-
flagsPart.replace('g', '');
|
4470 |
-
}
|
4471 |
-
regexPart = regexPart + '/' + flagsPart;
|
4472 |
-
}
|
4473 |
-
}
|
4474 |
-
if (regexPart) {
|
4475 |
-
// If regex part is empty, then use the previous query. Otherwise use
|
4476 |
-
// the regex part as the new query.
|
4477 |
-
try {
|
4478 |
-
updateSearchQuery(cm, regexPart, true /** ignoreCase */,
|
4479 |
-
true /** smartCase */);
|
4480 |
-
} catch (e) {
|
4481 |
-
showConfirm(cm, 'Invalid regex: ' + regexPart);
|
4482 |
-
return;
|
4483 |
-
}
|
4484 |
-
}
|
4485 |
-
replacePart = replacePart || vimGlobalState.lastSubstituteReplacePart;
|
4486 |
-
if (replacePart === undefined) {
|
4487 |
-
showConfirm(cm, 'No previous substitute regular expression');
|
4488 |
-
return;
|
4489 |
-
}
|
4490 |
-
var state = getSearchState(cm);
|
4491 |
-
var query = state.getQuery();
|
4492 |
-
var lineStart = (params.line !== undefined) ? params.line : cm.getCursor().line;
|
4493 |
-
var lineEnd = params.lineEnd || lineStart;
|
4494 |
-
if (lineStart == cm.firstLine() && lineEnd == cm.lastLine()) {
|
4495 |
-
lineEnd = Infinity;
|
4496 |
-
}
|
4497 |
-
if (count) {
|
4498 |
-
lineStart = lineEnd;
|
4499 |
-
lineEnd = lineStart + count - 1;
|
4500 |
-
}
|
4501 |
-
var startPos = clipCursorToContent(cm, Pos(lineStart, 0));
|
4502 |
-
var cursor = cm.getSearchCursor(query, startPos);
|
4503 |
-
doReplace(cm, confirm, global, lineStart, lineEnd, cursor, query, replacePart, params.callback);
|
4504 |
-
},
|
4505 |
-
redo: CodeMirror.commands.redo,
|
4506 |
-
undo: CodeMirror.commands.undo,
|
4507 |
-
write: function(cm) {
|
4508 |
-
if (CodeMirror.commands.save) {
|
4509 |
-
// If a save command is defined, call it.
|
4510 |
-
CodeMirror.commands.save(cm);
|
4511 |
-
} else {
|
4512 |
-
// Saves to text area if no save command is defined.
|
4513 |
-
cm.save();
|
4514 |
-
}
|
4515 |
-
},
|
4516 |
-
nohlsearch: function(cm) {
|
4517 |
-
clearSearchHighlight(cm);
|
4518 |
-
},
|
4519 |
-
delmarks: function(cm, params) {
|
4520 |
-
if (!params.argString || !trim(params.argString)) {
|
4521 |
-
showConfirm(cm, 'Argument required');
|
4522 |
-
return;
|
4523 |
-
}
|
4524 |
-
|
4525 |
-
var state = cm.state.vim;
|
4526 |
-
var stream = new CodeMirror.StringStream(trim(params.argString));
|
4527 |
-
while (!stream.eol()) {
|
4528 |
-
stream.eatSpace();
|
4529 |
-
|
4530 |
-
// Record the streams position at the beginning of the loop for use
|
4531 |
-
// in error messages.
|
4532 |
-
var count = stream.pos;
|
4533 |
-
|
4534 |
-
if (!stream.match(/[a-zA-Z]/, false)) {
|
4535 |
-
showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count));
|
4536 |
-
return;
|
4537 |
-
}
|
4538 |
-
|
4539 |
-
var sym = stream.next();
|
4540 |
-
// Check if this symbol is part of a range
|
4541 |
-
if (stream.match('-', true)) {
|
4542 |
-
// This symbol is part of a range.
|
4543 |
-
|
4544 |
-
// The range must terminate at an alphabetic character.
|
4545 |
-
if (!stream.match(/[a-zA-Z]/, false)) {
|
4546 |
-
showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count));
|
4547 |
-
return;
|
4548 |
-
}
|
4549 |
-
|
4550 |
-
var startMark = sym;
|
4551 |
-
var finishMark = stream.next();
|
4552 |
-
// The range must terminate at an alphabetic character which
|
4553 |
-
// shares the same case as the start of the range.
|
4554 |
-
if (isLowerCase(startMark) && isLowerCase(finishMark) ||
|
4555 |
-
isUpperCase(startMark) && isUpperCase(finishMark)) {
|
4556 |
-
var start = startMark.charCodeAt(0);
|
4557 |
-
var finish = finishMark.charCodeAt(0);
|
4558 |
-
if (start >= finish) {
|
4559 |
-
showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count));
|
4560 |
-
return;
|
4561 |
-
}
|
4562 |
-
|
4563 |
-
// Because marks are always ASCII values, and we have
|
4564 |
-
// determined that they are the same case, we can use
|
4565 |
-
// their char codes to iterate through the defined range.
|
4566 |
-
for (var j = 0; j <= finish - start; j++) {
|
4567 |
-
var mark = String.fromCharCode(start + j);
|
4568 |
-
delete state.marks[mark];
|
4569 |
-
}
|
4570 |
-
} else {
|
4571 |
-
showConfirm(cm, 'Invalid argument: ' + startMark + '-');
|
4572 |
-
return;
|
4573 |
-
}
|
4574 |
-
} else {
|
4575 |
-
// This symbol is a valid mark, and is not part of a range.
|
4576 |
-
delete state.marks[sym];
|
4577 |
-
}
|
4578 |
-
}
|
4579 |
-
}
|
4580 |
-
};
|
4581 |
-
|
4582 |
-
var exCommandDispatcher = new ExCommandDispatcher();
|
4583 |
-
|
4584 |
-
/**
|
4585 |
-
* @param {CodeMirror} cm CodeMirror instance we are in.
|
4586 |
-
* @param {boolean} confirm Whether to confirm each replace.
|
4587 |
-
* @param {Cursor} lineStart Line to start replacing from.
|
4588 |
-
* @param {Cursor} lineEnd Line to stop replacing at.
|
4589 |
-
* @param {RegExp} query Query for performing matches with.
|
4590 |
-
* @param {string} replaceWith Text to replace matches with. May contain $1,
|
4591 |
-
* $2, etc for replacing captured groups using Javascript replace.
|
4592 |
-
* @param {function()} callback A callback for when the replace is done.
|
4593 |
-
*/
|
4594 |
-
function doReplace(cm, confirm, global, lineStart, lineEnd, searchCursor, query,
|
4595 |
-
replaceWith, callback) {
|
4596 |
-
// Set up all the functions.
|
4597 |
-
cm.state.vim.exMode = true;
|
4598 |
-
var done = false;
|
4599 |
-
var lastPos = searchCursor.from();
|
4600 |
-
function replaceAll() {
|
4601 |
-
cm.operation(function() {
|
4602 |
-
while (!done) {
|
4603 |
-
replace();
|
4604 |
-
next();
|
4605 |
-
}
|
4606 |
-
stop();
|
4607 |
-
});
|
4608 |
-
}
|
4609 |
-
function replace() {
|
4610 |
-
var text = cm.getRange(searchCursor.from(), searchCursor.to());
|
4611 |
-
var newText = text.replace(query, replaceWith);
|
4612 |
-
searchCursor.replace(newText);
|
4613 |
-
}
|
4614 |
-
function next() {
|
4615 |
-
// The below only loops to skip over multiple occurrences on the same
|
4616 |
-
// line when 'global' is not true.
|
4617 |
-
while(searchCursor.findNext() &&
|
4618 |
-
isInRange(searchCursor.from(), lineStart, lineEnd)) {
|
4619 |
-
if (!global && lastPos && searchCursor.from().line == lastPos.line) {
|
4620 |
-
continue;
|
4621 |
-
}
|
4622 |
-
cm.scrollIntoView(searchCursor.from(), 30);
|
4623 |
-
cm.setSelection(searchCursor.from(), searchCursor.to());
|
4624 |
-
lastPos = searchCursor.from();
|
4625 |
-
done = false;
|
4626 |
-
return;
|
4627 |
-
}
|
4628 |
-
done = true;
|
4629 |
-
}
|
4630 |
-
function stop(close) {
|
4631 |
-
if (close) { close(); }
|
4632 |
-
cm.focus();
|
4633 |
-
if (lastPos) {
|
4634 |
-
cm.setCursor(lastPos);
|
4635 |
-
var vim = cm.state.vim;
|
4636 |
-
vim.exMode = false;
|
4637 |
-
vim.lastHPos = vim.lastHSPos = lastPos.ch;
|
4638 |
-
}
|
4639 |
-
if (callback) { callback(); }
|
4640 |
-
}
|
4641 |
-
function onPromptKeyDown(e, _value, close) {
|
4642 |
-
// Swallow all keys.
|
4643 |
-
CodeMirror.e_stop(e);
|
4644 |
-
var keyName = CodeMirror.keyName(e);
|
4645 |
-
switch (keyName) {
|
4646 |
-
case 'Y':
|
4647 |
-
replace(); next(); break;
|
4648 |
-
case 'N':
|
4649 |
-
next(); break;
|
4650 |
-
case 'A':
|
4651 |
-
// replaceAll contains a call to close of its own. We don't want it
|
4652 |
-
// to fire too early or multiple times.
|
4653 |
-
var savedCallback = callback;
|
4654 |
-
callback = undefined;
|
4655 |
-
cm.operation(replaceAll);
|
4656 |
-
callback = savedCallback;
|
4657 |
-
break;
|
4658 |
-
case 'L':
|
4659 |
-
replace();
|
4660 |
-
// fall through and exit.
|
4661 |
-
case 'Q':
|
4662 |
-
case 'Esc':
|
4663 |
-
case 'Ctrl-C':
|
4664 |
-
case 'Ctrl-[':
|
4665 |
-
stop(close);
|
4666 |
-
break;
|
4667 |
-
}
|
4668 |
-
if (done) { stop(close); }
|
4669 |
-
return true;
|
4670 |
-
}
|
4671 |
-
|
4672 |
-
// Actually do replace.
|
4673 |
-
next();
|
4674 |
-
if (done) {
|
4675 |
-
showConfirm(cm, 'No matches for ' + query.source);
|
4676 |
-
return;
|
4677 |
-
}
|
4678 |
-
if (!confirm) {
|
4679 |
-
replaceAll();
|
4680 |
-
if (callback) { callback(); };
|
4681 |
-
return;
|
4682 |
-
}
|
4683 |
-
showPrompt(cm, {
|
4684 |
-
prefix: 'replace with <strong>' + replaceWith + '</strong> (y/n/a/q/l)',
|
4685 |
-
onKeyDown: onPromptKeyDown
|
4686 |
-
});
|
4687 |
-
}
|
4688 |
-
|
4689 |
-
CodeMirror.keyMap.vim = {
|
4690 |
-
attach: attachVimMap,
|
4691 |
-
detach: detachVimMap,
|
4692 |
-
call: cmKey
|
4693 |
-
};
|
4694 |
-
|
4695 |
-
function exitInsertMode(cm) {
|
4696 |
-
var vim = cm.state.vim;
|
4697 |
-
var macroModeState = vimGlobalState.macroModeState;
|
4698 |
-
var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.');
|
4699 |
-
var isPlaying = macroModeState.isPlaying;
|
4700 |
-
var lastChange = macroModeState.lastInsertModeChanges;
|
4701 |
-
// In case of visual block, the insertModeChanges are not saved as a
|
4702 |
-
// single word, so we convert them to a single word
|
4703 |
-
// so as to update the ". register as expected in real vim.
|
4704 |
-
var text = [];
|
4705 |
-
if (!isPlaying) {
|
4706 |
-
var selLength = lastChange.inVisualBlock ? vim.lastSelection.visualBlock.height : 1;
|
4707 |
-
var changes = lastChange.changes;
|
4708 |
-
var text = [];
|
4709 |
-
var i = 0;
|
4710 |
-
// In case of multiple selections in blockwise visual,
|
4711 |
-
// the inserted text, for example: 'f<Backspace>oo', is stored as
|
4712 |
-
// 'f', 'f', InsertModeKey 'o', 'o', 'o', 'o'. (if you have a block with 2 lines).
|
4713 |
-
// We push the contents of the changes array as per the following:
|
4714 |
-
// 1. In case of InsertModeKey, just increment by 1.
|
4715 |
-
// 2. In case of a character, jump by selLength (2 in the example).
|
4716 |
-
while (i < changes.length) {
|
4717 |
-
// This loop will convert 'ff<bs>oooo' to 'f<bs>oo'.
|
4718 |
-
text.push(changes[i]);
|
4719 |
-
if (changes[i] instanceof InsertModeKey) {
|
4720 |
-
i++;
|
4721 |
-
} else {
|
4722 |
-
i+= selLength;
|
4723 |
-
}
|
4724 |
-
}
|
4725 |
-
lastChange.changes = text;
|
4726 |
-
cm.off('change', onChange);
|
4727 |
-
CodeMirror.off(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown);
|
4728 |
-
}
|
4729 |
-
if (!isPlaying && vim.insertModeRepeat > 1) {
|
4730 |
-
// Perform insert mode repeat for commands like 3,a and 3,o.
|
4731 |
-
repeatLastEdit(cm, vim, vim.insertModeRepeat - 1,
|
4732 |
-
true /** repeatForInsert */);
|
4733 |
-
vim.lastEditInputState.repeatOverride = vim.insertModeRepeat;
|
4734 |
-
}
|
4735 |
-
delete vim.insertModeRepeat;
|
4736 |
-
vim.insertMode = false;
|
4737 |
-
cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1);
|
4738 |
-
cm.setOption('keyMap', 'vim');
|
4739 |
-
cm.setOption('disableInput', true);
|
4740 |
-
cm.toggleOverwrite(false); // exit replace mode if we were in it.
|
4741 |
-
// update the ". register before exiting insert mode
|
4742 |
-
insertModeChangeRegister.setText(lastChange.changes.join(''));
|
4743 |
-
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
|
4744 |
-
if (macroModeState.isRecording) {
|
4745 |
-
logInsertModeChange(macroModeState);
|
4746 |
-
}
|
4747 |
-
}
|
4748 |
-
|
4749 |
-
function _mapCommand(command) {
|
4750 |
-
defaultKeymap.unshift(command);
|
4751 |
-
}
|
4752 |
-
|
4753 |
-
function mapCommand(keys, type, name, args, extra) {
|
4754 |
-
var command = {keys: keys, type: type};
|
4755 |
-
command[type] = name;
|
4756 |
-
command[type + "Args"] = args;
|
4757 |
-
for (var key in extra)
|
4758 |
-
command[key] = extra[key];
|
4759 |
-
_mapCommand(command);
|
4760 |
-
}
|
4761 |
-
|
4762 |
-
// The timeout in milliseconds for the two-character ESC keymap should be
|
4763 |
-
// adjusted according to your typing speed to prevent false positives.
|
4764 |
-
defineOption('insertModeEscKeysTimeout', 200, 'number');
|
4765 |
-
|
4766 |
-
CodeMirror.keyMap['vim-insert'] = {
|
4767 |
-
// TODO: override navigation keys so that Esc will cancel automatic
|
4768 |
-
// indentation from o, O, i_<CR>
|
4769 |
-
'Ctrl-N': 'autocomplete',
|
4770 |
-
'Ctrl-P': 'autocomplete',
|
4771 |
-
'Enter': function(cm) {
|
4772 |
-
var fn = CodeMirror.commands.newlineAndIndentContinueComment ||
|
4773 |
-
CodeMirror.commands.newlineAndIndent;
|
4774 |
-
fn(cm);
|
4775 |
-
},
|
4776 |
-
fallthrough: ['default'],
|
4777 |
-
attach: attachVimMap,
|
4778 |
-
detach: detachVimMap,
|
4779 |
-
call: cmKey
|
4780 |
-
};
|
4781 |
-
|
4782 |
-
CodeMirror.keyMap['vim-replace'] = {
|
4783 |
-
'Backspace': 'goCharLeft',
|
4784 |
-
fallthrough: ['vim-insert'],
|
4785 |
-
attach: attachVimMap,
|
4786 |
-
detach: detachVimMap,
|
4787 |
-
call: cmKey
|
4788 |
-
};
|
4789 |
-
|
4790 |
-
function executeMacroRegister(cm, vim, macroModeState, registerName) {
|
4791 |
-
var register = vimGlobalState.registerController.getRegister(registerName);
|
4792 |
-
if (registerName == ':') {
|
4793 |
-
// Read-only register containing last Ex command.
|
4794 |
-
if (register.keyBuffer[0]) {
|
4795 |
-
exCommandDispatcher.processCommand(cm, register.keyBuffer[0]);
|
4796 |
-
}
|
4797 |
-
macroModeState.isPlaying = false;
|
4798 |
-
return;
|
4799 |
-
}
|
4800 |
-
var keyBuffer = register.keyBuffer;
|
4801 |
-
var imc = 0;
|
4802 |
-
macroModeState.isPlaying = true;
|
4803 |
-
macroModeState.replaySearchQueries = register.searchQueries.slice(0);
|
4804 |
-
for (var i = 0; i < keyBuffer.length; i++) {
|
4805 |
-
var text = keyBuffer[i];
|
4806 |
-
var match, key;
|
4807 |
-
while (text) {
|
4808 |
-
// Pull off one command key, which is either a single character
|
4809 |
-
// or a special sequence wrapped in '<' and '>', e.g. '<Space>'.
|
4810 |
-
match = (/<\w+-.+?>|<\w+>|./).exec(text);
|
4811 |
-
key = match[0];
|
4812 |
-
text = text.substring(match.index + key.length);
|
4813 |
-
CodeMirror.Vim.handleKey(cm, key, 'macro');
|
4814 |
-
if (vim.insertMode) {
|
4815 |
-
var changes = register.insertModeChanges[imc++].changes;
|
4816 |
-
vimGlobalState.macroModeState.lastInsertModeChanges.changes =
|
4817 |
-
changes;
|
4818 |
-
repeatInsertModeChanges(cm, changes, 1);
|
4819 |
-
exitInsertMode(cm);
|
4820 |
-
}
|
4821 |
-
}
|
4822 |
-
};
|
4823 |
-
macroModeState.isPlaying = false;
|
4824 |
-
}
|
4825 |
-
|
4826 |
-
function logKey(macroModeState, key) {
|
4827 |
-
if (macroModeState.isPlaying) { return; }
|
4828 |
-
var registerName = macroModeState.latestRegister;
|
4829 |
-
var register = vimGlobalState.registerController.getRegister(registerName);
|
4830 |
-
if (register) {
|
4831 |
-
register.pushText(key);
|
4832 |
-
}
|
4833 |
-
}
|
4834 |
-
|
4835 |
-
function logInsertModeChange(macroModeState) {
|
4836 |
-
if (macroModeState.isPlaying) { return; }
|
4837 |
-
var registerName = macroModeState.latestRegister;
|
4838 |
-
var register = vimGlobalState.registerController.getRegister(registerName);
|
4839 |
-
if (register && register.pushInsertModeChanges) {
|
4840 |
-
register.pushInsertModeChanges(macroModeState.lastInsertModeChanges);
|
4841 |
-
}
|
4842 |
-
}
|
4843 |
-
|
4844 |
-
function logSearchQuery(macroModeState, query) {
|
4845 |
-
if (macroModeState.isPlaying) { return; }
|
4846 |
-
var registerName = macroModeState.latestRegister;
|
4847 |
-
var register = vimGlobalState.registerController.getRegister(registerName);
|
4848 |
-
if (register && register.pushSearchQuery) {
|
4849 |
-
register.pushSearchQuery(query);
|
4850 |
-
}
|
4851 |
-
}
|
4852 |
-
|
4853 |
-
/**
|
4854 |
-
* Listens for changes made in insert mode.
|
4855 |
-
* Should only be active in insert mode.
|
4856 |
-
*/
|
4857 |
-
function onChange(_cm, changeObj) {
|
4858 |
-
var macroModeState = vimGlobalState.macroModeState;
|
4859 |
-
var lastChange = macroModeState.lastInsertModeChanges;
|
4860 |
-
if (!macroModeState.isPlaying) {
|
4861 |
-
while(changeObj) {
|
4862 |
-
lastChange.expectCursorActivityForChange = true;
|
4863 |
-
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
|
4864 |
-
|| changeObj.origin === undefined /* only in testing */) {
|
4865 |
-
var text = changeObj.text.join('\n');
|
4866 |
-
lastChange.changes.push(text);
|
4867 |
-
}
|
4868 |
-
// Change objects may be chained with next.
|
4869 |
-
changeObj = changeObj.next;
|
4870 |
-
}
|
4871 |
-
}
|
4872 |
-
}
|
4873 |
-
|
4874 |
-
/**
|
4875 |
-
* Listens for any kind of cursor activity on CodeMirror.
|
4876 |
-
*/
|
4877 |
-
function onCursorActivity(cm) {
|
4878 |
-
var vim = cm.state.vim;
|
4879 |
-
if (vim.insertMode) {
|
4880 |
-
// Tracking cursor activity in insert mode (for macro support).
|
4881 |
-
var macroModeState = vimGlobalState.macroModeState;
|
4882 |
-
if (macroModeState.isPlaying) { return; }
|
4883 |
-
var lastChange = macroModeState.lastInsertModeChanges;
|
4884 |
-
if (lastChange.expectCursorActivityForChange) {
|
4885 |
-
lastChange.expectCursorActivityForChange = false;
|
4886 |
-
} else {
|
4887 |
-
// Cursor moved outside the context of an edit. Reset the change.
|
4888 |
-
lastChange.changes = [];
|
4889 |
-
}
|
4890 |
-
} else if (!cm.curOp.isVimOp) {
|
4891 |
-
handleExternalSelection(cm, vim);
|
4892 |
-
}
|
4893 |
-
if (vim.visualMode) {
|
4894 |
-
updateFakeCursor(cm);
|
4895 |
-
}
|
4896 |
-
}
|
4897 |
-
function updateFakeCursor(cm) {
|
4898 |
-
var vim = cm.state.vim;
|
4899 |
-
var from = clipCursorToContent(cm, copyCursor(vim.sel.head));
|
4900 |
-
var to = offsetCursor(from, 0, 1);
|
4901 |
-
if (vim.fakeCursor) {
|
4902 |
-
vim.fakeCursor.clear();
|
4903 |
-
}
|
4904 |
-
vim.fakeCursor = cm.markText(from, to, {className: 'cm-animate-fat-cursor'});
|
4905 |
-
}
|
4906 |
-
function handleExternalSelection(cm, vim) {
|
4907 |
-
var anchor = cm.getCursor('anchor');
|
4908 |
-
var head = cm.getCursor('head');
|
4909 |
-
// Enter or exit visual mode to match mouse selection.
|
4910 |
-
if (vim.visualMode && !cm.somethingSelected()) {
|
4911 |
-
exitVisualMode(cm, false);
|
4912 |
-
} else if (!vim.visualMode && !vim.insertMode && cm.somethingSelected()) {
|
4913 |
-
vim.visualMode = true;
|
4914 |
-
vim.visualLine = false;
|
4915 |
-
CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"});
|
4916 |
-
}
|
4917 |
-
if (vim.visualMode) {
|
4918 |
-
// Bind CodeMirror selection model to vim selection model.
|
4919 |
-
// Mouse selections are considered visual characterwise.
|
4920 |
-
var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0;
|
4921 |
-
var anchorOffset = cursorIsBefore(head, anchor) ? -1 : 0;
|
4922 |
-
head = offsetCursor(head, 0, headOffset);
|
4923 |
-
anchor = offsetCursor(anchor, 0, anchorOffset);
|
4924 |
-
vim.sel = {
|
4925 |
-
anchor: anchor,
|
4926 |
-
head: head
|
4927 |
-
};
|
4928 |
-
updateMark(cm, vim, '<', cursorMin(head, anchor));
|
4929 |
-
updateMark(cm, vim, '>', cursorMax(head, anchor));
|
4930 |
-
} else if (!vim.insertMode) {
|
4931 |
-
// Reset lastHPos if selection was modified by something outside of vim mode e.g. by mouse.
|
4932 |
-
vim.lastHPos = cm.getCursor().ch;
|
4933 |
-
}
|
4934 |
-
}
|
4935 |
-
|
4936 |
-
/** Wrapper for special keys pressed in insert mode */
|
4937 |
-
function InsertModeKey(keyName) {
|
4938 |
-
this.keyName = keyName;
|
4939 |
-
}
|
4940 |
-
|
4941 |
-
/**
|
4942 |
-
* Handles raw key down events from the text area.
|
4943 |
-
* - Should only be active in insert mode.
|
4944 |
-
* - For recording deletes in insert mode.
|
4945 |
-
*/
|
4946 |
-
function onKeyEventTargetKeyDown(e) {
|
4947 |
-
var macroModeState = vimGlobalState.macroModeState;
|
4948 |
-
var lastChange = macroModeState.lastInsertModeChanges;
|
4949 |
-
var keyName = CodeMirror.keyName(e);
|
4950 |
-
if (!keyName) { return; }
|
4951 |
-
function onKeyFound() {
|
4952 |
-
lastChange.changes.push(new InsertModeKey(keyName));
|
4953 |
-
return true;
|
4954 |
-
}
|
4955 |
-
if (keyName.indexOf('Delete') != -1 || keyName.indexOf('Backspace') != -1) {
|
4956 |
-
CodeMirror.lookupKey(keyName, 'vim-insert', onKeyFound);
|
4957 |
-
}
|
4958 |
-
}
|
4959 |
-
|
4960 |
-
/**
|
4961 |
-
* Repeats the last edit, which includes exactly 1 command and at most 1
|
4962 |
-
* insert. Operator and motion commands are read from lastEditInputState,
|
4963 |
-
* while action commands are read from lastEditActionCommand.
|
4964 |
-
*
|
4965 |
-
* If repeatForInsert is true, then the function was called by
|
4966 |
-
* exitInsertMode to repeat the insert mode changes the user just made. The
|
4967 |
-
* corresponding enterInsertMode call was made with a count.
|
4968 |
-
*/
|
4969 |
-
function repeatLastEdit(cm, vim, repeat, repeatForInsert) {
|
4970 |
-
var macroModeState = vimGlobalState.macroModeState;
|
4971 |
-
macroModeState.isPlaying = true;
|
4972 |
-
var isAction = !!vim.lastEditActionCommand;
|
4973 |
-
var cachedInputState = vim.inputState;
|
4974 |
-
function repeatCommand() {
|
4975 |
-
if (isAction) {
|
4976 |
-
commandDispatcher.processAction(cm, vim, vim.lastEditActionCommand);
|
4977 |
-
} else {
|
4978 |
-
commandDispatcher.evalInput(cm, vim);
|
4979 |
-
}
|
4980 |
-
}
|
4981 |
-
function repeatInsert(repeat) {
|
4982 |
-
if (macroModeState.lastInsertModeChanges.changes.length > 0) {
|
4983 |
-
// For some reason, repeat cw in desktop VIM does not repeat
|
4984 |
-
// insert mode changes. Will conform to that behavior.
|
4985 |
-
repeat = !vim.lastEditActionCommand ? 1 : repeat;
|
4986 |
-
var changeObject = macroModeState.lastInsertModeChanges;
|
4987 |
-
repeatInsertModeChanges(cm, changeObject.changes, repeat);
|
4988 |
-
}
|
4989 |
-
}
|
4990 |
-
vim.inputState = vim.lastEditInputState;
|
4991 |
-
if (isAction && vim.lastEditActionCommand.interlaceInsertRepeat) {
|
4992 |
-
// o and O repeat have to be interlaced with insert repeats so that the
|
4993 |
-
// insertions appear on separate lines instead of the last line.
|
4994 |
-
for (var i = 0; i < repeat; i++) {
|
4995 |
-
repeatCommand();
|
4996 |
-
repeatInsert(1);
|
4997 |
-
}
|
4998 |
-
} else {
|
4999 |
-
if (!repeatForInsert) {
|
5000 |
-
// Hack to get the cursor to end up at the right place. If I is
|
5001 |
-
// repeated in insert mode repeat, cursor will be 1 insert
|
5002 |
-
// change set left of where it should be.
|
5003 |
-
repeatCommand();
|
5004 |
-
}
|
5005 |
-
repeatInsert(repeat);
|
5006 |
-
}
|
5007 |
-
vim.inputState = cachedInputState;
|
5008 |
-
if (vim.insertMode && !repeatForInsert) {
|
5009 |
-
// Don't exit insert mode twice. If repeatForInsert is set, then we
|
5010 |
-
// were called by an exitInsertMode call lower on the stack.
|
5011 |
-
exitInsertMode(cm);
|
5012 |
-
}
|
5013 |
-
macroModeState.isPlaying = false;
|
5014 |
-
};
|
5015 |
-
|
5016 |
-
function repeatInsertModeChanges(cm, changes, repeat) {
|
5017 |
-
function keyHandler(binding) {
|
5018 |
-
if (typeof binding == 'string') {
|
5019 |
-
CodeMirror.commands[binding](cm);
|
5020 |
-
} else {
|
5021 |
-
binding(cm);
|
5022 |
-
}
|
5023 |
-
return true;
|
5024 |
-
}
|
5025 |
-
var head = cm.getCursor('head');
|
5026 |
-
var inVisualBlock = vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock;
|
5027 |
-
if (inVisualBlock) {
|
5028 |
-
// Set up block selection again for repeating the changes.
|
5029 |
-
var vim = cm.state.vim;
|
5030 |
-
var lastSel = vim.lastSelection;
|
5031 |
-
var offset = getOffset(lastSel.anchor, lastSel.head);
|
5032 |
-
selectForInsert(cm, head, offset.line + 1);
|
5033 |
-
repeat = cm.listSelections().length;
|
5034 |
-
cm.setCursor(head);
|
5035 |
-
}
|
5036 |
-
for (var i = 0; i < repeat; i++) {
|
5037 |
-
if (inVisualBlock) {
|
5038 |
-
cm.setCursor(offsetCursor(head, i, 0));
|
5039 |
-
}
|
5040 |
-
for (var j = 0; j < changes.length; j++) {
|
5041 |
-
var change = changes[j];
|
5042 |
-
if (change instanceof InsertModeKey) {
|
5043 |
-
CodeMirror.lookupKey(change.keyName, 'vim-insert', keyHandler);
|
5044 |
-
} else {
|
5045 |
-
var cur = cm.getCursor();
|
5046 |
-
cm.replaceRange(change, cur, cur);
|
5047 |
-
}
|
5048 |
-
}
|
5049 |
-
}
|
5050 |
-
if (inVisualBlock) {
|
5051 |
-
cm.setCursor(offsetCursor(head, 0, 1));
|
5052 |
-
}
|
5053 |
-
}
|
5054 |
-
|
5055 |
-
resetVimGlobalState();
|
5056 |
-
return vimApi;
|
5057 |
-
};
|
5058 |
-
// Initialize Vim and make it available as an API.
|
5059 |
-
CodeMirror.Vim = Vim();
|
5060 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/lib/codemirror.css
DELETED
@@ -1,334 +0,0 @@
|
|
1 |
-
/* BASICS */
|
2 |
-
|
3 |
-
.CodeMirror {
|
4 |
-
/* Set height, width, borders, and global font properties here */
|
5 |
-
font-family: monospace;
|
6 |
-
height: 300px;
|
7 |
-
color: black;
|
8 |
-
}
|
9 |
-
|
10 |
-
/* PADDING */
|
11 |
-
|
12 |
-
.CodeMirror-lines {
|
13 |
-
padding: 4px 0; /* Vertical padding around content */
|
14 |
-
}
|
15 |
-
.CodeMirror pre {
|
16 |
-
padding: 0 4px; /* Horizontal padding of content */
|
17 |
-
}
|
18 |
-
|
19 |
-
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
20 |
-
background-color: white; /* The little square between H and V scrollbars */
|
21 |
-
}
|
22 |
-
|
23 |
-
/* GUTTER */
|
24 |
-
|
25 |
-
.CodeMirror-gutters {
|
26 |
-
border-right: 1px solid #ddd;
|
27 |
-
background-color: #f7f7f7;
|
28 |
-
white-space: nowrap;
|
29 |
-
}
|
30 |
-
.CodeMirror-linenumbers {}
|
31 |
-
.CodeMirror-linenumber {
|
32 |
-
padding: 0 3px 0 5px;
|
33 |
-
min-width: 20px;
|
34 |
-
text-align: right;
|
35 |
-
color: #999;
|
36 |
-
white-space: nowrap;
|
37 |
-
}
|
38 |
-
|
39 |
-
.CodeMirror-guttermarker { color: black; }
|
40 |
-
.CodeMirror-guttermarker-subtle { color: #999; }
|
41 |
-
|
42 |
-
/* CURSOR */
|
43 |
-
|
44 |
-
.CodeMirror-cursor {
|
45 |
-
border-left: 1px solid black;
|
46 |
-
border-right: none;
|
47 |
-
width: 0;
|
48 |
-
}
|
49 |
-
/* Shown when moving in bi-directional text */
|
50 |
-
.CodeMirror div.CodeMirror-secondarycursor {
|
51 |
-
border-left: 1px solid silver;
|
52 |
-
}
|
53 |
-
.cm-fat-cursor .CodeMirror-cursor {
|
54 |
-
width: auto;
|
55 |
-
border: 0;
|
56 |
-
background: #7e7;
|
57 |
-
}
|
58 |
-
.cm-fat-cursor div.CodeMirror-cursors {
|
59 |
-
z-index: 1;
|
60 |
-
}
|
61 |
-
|
62 |
-
.cm-animate-fat-cursor {
|
63 |
-
width: auto;
|
64 |
-
border: 0;
|
65 |
-
-webkit-animation: blink 1.06s steps(1) infinite;
|
66 |
-
-moz-animation: blink 1.06s steps(1) infinite;
|
67 |
-
animation: blink 1.06s steps(1) infinite;
|
68 |
-
background-color: #7e7;
|
69 |
-
}
|
70 |
-
@-moz-keyframes blink {
|
71 |
-
0% {}
|
72 |
-
50% { background-color: transparent; }
|
73 |
-
100% {}
|
74 |
-
}
|
75 |
-
@-webkit-keyframes blink {
|
76 |
-
0% {}
|
77 |
-
50% { background-color: transparent; }
|
78 |
-
100% {}
|
79 |
-
}
|
80 |
-
@keyframes blink {
|
81 |
-
0% {}
|
82 |
-
50% { background-color: transparent; }
|
83 |
-
100% {}
|
84 |
-
}
|
85 |
-
|
86 |
-
/* Can style cursor different in overwrite (non-insert) mode */
|
87 |
-
.CodeMirror-overwrite .CodeMirror-cursor {}
|
88 |
-
|
89 |
-
.cm-tab { display: inline-block; text-decoration: inherit; }
|
90 |
-
|
91 |
-
.CodeMirror-ruler {
|
92 |
-
border-left: 1px solid #ccc;
|
93 |
-
position: absolute;
|
94 |
-
}
|
95 |
-
|
96 |
-
/* DEFAULT THEME */
|
97 |
-
|
98 |
-
.cm-s-default .cm-header {color: blue;}
|
99 |
-
.cm-s-default .cm-quote {color: #090;}
|
100 |
-
.cm-negative {color: #d44;}
|
101 |
-
.cm-positive {color: #292;}
|
102 |
-
.cm-header, .cm-strong {font-weight: bold;}
|
103 |
-
.cm-em {font-style: italic;}
|
104 |
-
.cm-link {text-decoration: underline;}
|
105 |
-
.cm-strikethrough {text-decoration: line-through;}
|
106 |
-
|
107 |
-
.cm-s-default .cm-keyword {color: #708;}
|
108 |
-
.cm-s-default .cm-atom {color: #219;}
|
109 |
-
.cm-s-default .cm-number {color: #164;}
|
110 |
-
.cm-s-default .cm-def {color: #00f;}
|
111 |
-
.cm-s-default .cm-variable,
|
112 |
-
.cm-s-default .cm-punctuation,
|
113 |
-
.cm-s-default .cm-property,
|
114 |
-
.cm-s-default .cm-operator {}
|
115 |
-
.cm-s-default .cm-variable-2 {color: #05a;}
|
116 |
-
.cm-s-default .cm-variable-3 {color: #085;}
|
117 |
-
.cm-s-default .cm-comment {color: #a50;}
|
118 |
-
.cm-s-default .cm-string {color: #a11;}
|
119 |
-
.cm-s-default .cm-string-2 {color: #f50;}
|
120 |
-
.cm-s-default .cm-meta {color: #555;}
|
121 |
-
.cm-s-default .cm-qualifier {color: #555;}
|
122 |
-
.cm-s-default .cm-builtin {color: #30a;}
|
123 |
-
.cm-s-default .cm-bracket {color: #997;}
|
124 |
-
.cm-s-default .cm-tag {color: #170;}
|
125 |
-
.cm-s-default .cm-attribute {color: #00c;}
|
126 |
-
.cm-s-default .cm-hr {color: #999;}
|
127 |
-
.cm-s-default .cm-link {color: #00c;}
|
128 |
-
|
129 |
-
.cm-s-default .cm-error {color: #f00;}
|
130 |
-
.cm-invalidchar {color: #f00;}
|
131 |
-
|
132 |
-
.CodeMirror-composing { border-bottom: 2px solid; }
|
133 |
-
|
134 |
-
/* Default styles for common addons */
|
135 |
-
|
136 |
-
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
137 |
-
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
138 |
-
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
139 |
-
.CodeMirror-activeline-background {background: #e8f2ff;}
|
140 |
-
|
141 |
-
/* STOP */
|
142 |
-
|
143 |
-
/* The rest of this file contains styles related to the mechanics of
|
144 |
-
the editor. You probably shouldn't touch them. */
|
145 |
-
|
146 |
-
.CodeMirror {
|
147 |
-
position: relative;
|
148 |
-
overflow: hidden;
|
149 |
-
background: white;
|
150 |
-
}
|
151 |
-
|
152 |
-
.CodeMirror-scroll {
|
153 |
-
overflow: scroll !important; /* Things will break if this is overridden */
|
154 |
-
/* 30px is the magic margin used to hide the element's real scrollbars */
|
155 |
-
/* See overflow: hidden in .CodeMirror */
|
156 |
-
margin-bottom: -30px; margin-right: -30px;
|
157 |
-
padding-bottom: 30px;
|
158 |
-
height: 100%;
|
159 |
-
outline: none; /* Prevent dragging from highlighting the element */
|
160 |
-
position: relative;
|
161 |
-
}
|
162 |
-
.CodeMirror-sizer {
|
163 |
-
position: relative;
|
164 |
-
border-right: 30px solid transparent;
|
165 |
-
}
|
166 |
-
|
167 |
-
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
168 |
-
before actuall scrolling happens, thus preventing shaking and
|
169 |
-
flickering artifacts. */
|
170 |
-
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
171 |
-
position: absolute;
|
172 |
-
z-index: 6;
|
173 |
-
display: none;
|
174 |
-
}
|
175 |
-
.CodeMirror-vscrollbar {
|
176 |
-
right: 0; top: 0;
|
177 |
-
overflow-x: hidden;
|
178 |
-
overflow-y: scroll;
|
179 |
-
}
|
180 |
-
.CodeMirror-hscrollbar {
|
181 |
-
bottom: 0; left: 0;
|
182 |
-
overflow-y: hidden;
|
183 |
-
overflow-x: scroll;
|
184 |
-
}
|
185 |
-
.CodeMirror-scrollbar-filler {
|
186 |
-
right: 0; bottom: 0;
|
187 |
-
}
|
188 |
-
.CodeMirror-gutter-filler {
|
189 |
-
left: 0; bottom: 0;
|
190 |
-
}
|
191 |
-
|
192 |
-
.CodeMirror-gutters {
|
193 |
-
position: absolute; left: 0; top: 0;
|
194 |
-
z-index: 3;
|
195 |
-
}
|
196 |
-
.CodeMirror-gutter {
|
197 |
-
white-space: normal;
|
198 |
-
height: 100%;
|
199 |
-
display: inline-block;
|
200 |
-
margin-bottom: -30px;
|
201 |
-
/* Hack to make IE7 behave */
|
202 |
-
*zoom:1;
|
203 |
-
*display:inline;
|
204 |
-
}
|
205 |
-
.CodeMirror-gutter-wrapper {
|
206 |
-
position: absolute;
|
207 |
-
z-index: 4;
|
208 |
-
background: none !important;
|
209 |
-
border: none !important;
|
210 |
-
}
|
211 |
-
.CodeMirror-gutter-background {
|
212 |
-
position: absolute;
|
213 |
-
top: 0; bottom: 0;
|
214 |
-
z-index: 4;
|
215 |
-
}
|
216 |
-
.CodeMirror-gutter-elt {
|
217 |
-
position: absolute;
|
218 |
-
cursor: default;
|
219 |
-
z-index: 4;
|
220 |
-
}
|
221 |
-
.CodeMirror-gutter-wrapper {
|
222 |
-
-webkit-user-select: none;
|
223 |
-
-moz-user-select: none;
|
224 |
-
user-select: none;
|
225 |
-
}
|
226 |
-
|
227 |
-
.CodeMirror-lines {
|
228 |
-
cursor: text;
|
229 |
-
min-height: 1px; /* prevents collapsing before first draw */
|
230 |
-
}
|
231 |
-
.CodeMirror pre {
|
232 |
-
/* Reset some styles that the rest of the page might have set */
|
233 |
-
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
234 |
-
border-width: 0;
|
235 |
-
background: transparent;
|
236 |
-
font-family: inherit;
|
237 |
-
font-size: inherit;
|
238 |
-
margin: 0;
|
239 |
-
white-space: pre;
|
240 |
-
word-wrap: normal;
|
241 |
-
line-height: inherit;
|
242 |
-
color: inherit;
|
243 |
-
z-index: 2;
|
244 |
-
position: relative;
|
245 |
-
overflow: visible;
|
246 |
-
-webkit-tap-highlight-color: transparent;
|
247 |
-
}
|
248 |
-
.CodeMirror-wrap pre {
|
249 |
-
word-wrap: break-word;
|
250 |
-
white-space: pre-wrap;
|
251 |
-
word-break: normal;
|
252 |
-
}
|
253 |
-
|
254 |
-
.CodeMirror-linebackground {
|
255 |
-
position: absolute;
|
256 |
-
left: 0; right: 0; top: 0; bottom: 0;
|
257 |
-
z-index: 0;
|
258 |
-
}
|
259 |
-
|
260 |
-
.CodeMirror-linewidget {
|
261 |
-
position: relative;
|
262 |
-
z-index: 2;
|
263 |
-
overflow: auto;
|
264 |
-
}
|
265 |
-
|
266 |
-
.CodeMirror-widget {}
|
267 |
-
|
268 |
-
.CodeMirror-code {
|
269 |
-
outline: none;
|
270 |
-
}
|
271 |
-
|
272 |
-
/* Force content-box sizing for the elements where we expect it */
|
273 |
-
.CodeMirror-scroll,
|
274 |
-
.CodeMirror-sizer,
|
275 |
-
.CodeMirror-gutter,
|
276 |
-
.CodeMirror-gutters,
|
277 |
-
.CodeMirror-linenumber {
|
278 |
-
-moz-box-sizing: content-box;
|
279 |
-
box-sizing: content-box;
|
280 |
-
}
|
281 |
-
|
282 |
-
.CodeMirror-measure {
|
283 |
-
position: absolute;
|
284 |
-
width: 100%;
|
285 |
-
height: 0;
|
286 |
-
overflow: hidden;
|
287 |
-
visibility: hidden;
|
288 |
-
}
|
289 |
-
|
290 |
-
.CodeMirror-cursor { position: absolute; }
|
291 |
-
.CodeMirror-measure pre { position: static; }
|
292 |
-
|
293 |
-
div.CodeMirror-cursors {
|
294 |
-
visibility: hidden;
|
295 |
-
position: relative;
|
296 |
-
z-index: 3;
|
297 |
-
}
|
298 |
-
div.CodeMirror-dragcursors {
|
299 |
-
visibility: visible;
|
300 |
-
}
|
301 |
-
|
302 |
-
.CodeMirror-focused div.CodeMirror-cursors {
|
303 |
-
visibility: visible;
|
304 |
-
}
|
305 |
-
|
306 |
-
.CodeMirror-selected { background: #d9d9d9; }
|
307 |
-
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
308 |
-
.CodeMirror-crosshair { cursor: crosshair; }
|
309 |
-
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
310 |
-
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
311 |
-
|
312 |
-
.cm-searching {
|
313 |
-
background: #ffa;
|
314 |
-
background: rgba(255, 255, 0, .4);
|
315 |
-
}
|
316 |
-
|
317 |
-
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
318 |
-
.CodeMirror span { *vertical-align: text-bottom; }
|
319 |
-
|
320 |
-
/* Used to force a border model for a node */
|
321 |
-
.cm-force-border { padding-right: .1px; }
|
322 |
-
|
323 |
-
@media print {
|
324 |
-
/* Hide the cursor when printing */
|
325 |
-
.CodeMirror div.CodeMirror-cursors {
|
326 |
-
visibility: hidden;
|
327 |
-
}
|
328 |
-
}
|
329 |
-
|
330 |
-
/* See issue #2901 */
|
331 |
-
.cm-tab-wrap-hack:after { content: ''; }
|
332 |
-
|
333 |
-
/* Help users use markselection to safely style text background */
|
334 |
-
span.CodeMirror-selectedtext { background: none; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/lib/codemirror.js
DELETED
@@ -1,8872 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
// This is CodeMirror (http://codemirror.net), a code editor
|
5 |
-
// implemented in JavaScript on top of the browser's DOM.
|
6 |
-
//
|
7 |
-
// You can find some technical background for some of the code below
|
8 |
-
// at http://marijnhaverbeke.nl/blog/#cm-internals .
|
9 |
-
|
10 |
-
(function(mod) {
|
11 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12 |
-
module.exports = mod();
|
13 |
-
else if (typeof define == "function" && define.amd) // AMD
|
14 |
-
return define([], mod);
|
15 |
-
else // Plain browser env
|
16 |
-
this.CodeMirror = mod();
|
17 |
-
})(function() {
|
18 |
-
"use strict";
|
19 |
-
|
20 |
-
// BROWSER SNIFFING
|
21 |
-
|
22 |
-
// Kludges for bugs and behavior differences that can't be feature
|
23 |
-
// detected are enabled based on userAgent etc sniffing.
|
24 |
-
var userAgent = navigator.userAgent;
|
25 |
-
var platform = navigator.platform;
|
26 |
-
|
27 |
-
var gecko = /gecko\/\d/i.test(userAgent);
|
28 |
-
var ie_upto10 = /MSIE \d/.test(userAgent);
|
29 |
-
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
|
30 |
-
var ie = ie_upto10 || ie_11up;
|
31 |
-
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
|
32 |
-
var webkit = /WebKit\//.test(userAgent);
|
33 |
-
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
|
34 |
-
var chrome = /Chrome\//.test(userAgent);
|
35 |
-
var presto = /Opera\//.test(userAgent);
|
36 |
-
var safari = /Apple Computer/.test(navigator.vendor);
|
37 |
-
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
|
38 |
-
var phantom = /PhantomJS/.test(userAgent);
|
39 |
-
|
40 |
-
var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
|
41 |
-
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
42 |
-
var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
|
43 |
-
var mac = ios || /Mac/.test(platform);
|
44 |
-
var windows = /win/i.test(platform);
|
45 |
-
|
46 |
-
var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
|
47 |
-
if (presto_version) presto_version = Number(presto_version[1]);
|
48 |
-
if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
|
49 |
-
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
|
50 |
-
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
|
51 |
-
var captureRightClick = gecko || (ie && ie_version >= 9);
|
52 |
-
|
53 |
-
// Optimize some code when these features are not used.
|
54 |
-
var sawReadOnlySpans = false, sawCollapsedSpans = false;
|
55 |
-
|
56 |
-
// EDITOR CONSTRUCTOR
|
57 |
-
|
58 |
-
// A CodeMirror instance represents an editor. This is the object
|
59 |
-
// that user code is usually dealing with.
|
60 |
-
|
61 |
-
function CodeMirror(place, options) {
|
62 |
-
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
|
63 |
-
|
64 |
-
this.options = options = options ? copyObj(options) : {};
|
65 |
-
// Determine effective options based on given values and defaults.
|
66 |
-
copyObj(defaults, options, false);
|
67 |
-
setGuttersForLineNumbers(options);
|
68 |
-
|
69 |
-
var doc = options.value;
|
70 |
-
if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
|
71 |
-
this.doc = doc;
|
72 |
-
|
73 |
-
var input = new CodeMirror.inputStyles[options.inputStyle](this);
|
74 |
-
var display = this.display = new Display(place, doc, input);
|
75 |
-
display.wrapper.CodeMirror = this;
|
76 |
-
updateGutters(this);
|
77 |
-
themeChanged(this);
|
78 |
-
if (options.lineWrapping)
|
79 |
-
this.display.wrapper.className += " CodeMirror-wrap";
|
80 |
-
if (options.autofocus && !mobile) display.input.focus();
|
81 |
-
initScrollbars(this);
|
82 |
-
|
83 |
-
this.state = {
|
84 |
-
keyMaps: [], // stores maps added by addKeyMap
|
85 |
-
overlays: [], // highlighting overlays, as added by addOverlay
|
86 |
-
modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
|
87 |
-
overwrite: false,
|
88 |
-
delayingBlurEvent: false,
|
89 |
-
focused: false,
|
90 |
-
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
|
91 |
-
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
|
92 |
-
selectingText: false,
|
93 |
-
draggingText: false,
|
94 |
-
highlight: new Delayed(), // stores highlight worker timeout
|
95 |
-
keySeq: null, // Unfinished key sequence
|
96 |
-
specialChars: null
|
97 |
-
};
|
98 |
-
|
99 |
-
var cm = this;
|
100 |
-
|
101 |
-
// Override magic textarea content restore that IE sometimes does
|
102 |
-
// on our hidden textarea on reload
|
103 |
-
if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
|
104 |
-
|
105 |
-
registerEventHandlers(this);
|
106 |
-
ensureGlobalHandlers();
|
107 |
-
|
108 |
-
startOperation(this);
|
109 |
-
this.curOp.forceUpdate = true;
|
110 |
-
attachDoc(this, doc);
|
111 |
-
|
112 |
-
if ((options.autofocus && !mobile) || cm.hasFocus())
|
113 |
-
setTimeout(bind(onFocus, this), 20);
|
114 |
-
else
|
115 |
-
onBlur(this);
|
116 |
-
|
117 |
-
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
|
118 |
-
optionHandlers[opt](this, options[opt], Init);
|
119 |
-
maybeUpdateLineNumberWidth(this);
|
120 |
-
if (options.finishInit) options.finishInit(this);
|
121 |
-
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
|
122 |
-
endOperation(this);
|
123 |
-
// Suppress optimizelegibility in Webkit, since it breaks text
|
124 |
-
// measuring on line wrapping boundaries.
|
125 |
-
if (webkit && options.lineWrapping &&
|
126 |
-
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
|
127 |
-
display.lineDiv.style.textRendering = "auto";
|
128 |
-
}
|
129 |
-
|
130 |
-
// DISPLAY CONSTRUCTOR
|
131 |
-
|
132 |
-
// The display handles the DOM integration, both for input reading
|
133 |
-
// and content drawing. It holds references to DOM nodes and
|
134 |
-
// display-related state.
|
135 |
-
|
136 |
-
function Display(place, doc, input) {
|
137 |
-
var d = this;
|
138 |
-
this.input = input;
|
139 |
-
|
140 |
-
// Covers bottom-right square when both scrollbars are present.
|
141 |
-
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
|
142 |
-
d.scrollbarFiller.setAttribute("cm-not-content", "true");
|
143 |
-
// Covers bottom of gutter when coverGutterNextToScrollbar is on
|
144 |
-
// and h scrollbar is present.
|
145 |
-
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
|
146 |
-
d.gutterFiller.setAttribute("cm-not-content", "true");
|
147 |
-
// Will contain the actual code, positioned to cover the viewport.
|
148 |
-
d.lineDiv = elt("div", null, "CodeMirror-code");
|
149 |
-
// Elements are added to these to represent selection and cursors.
|
150 |
-
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
|
151 |
-
d.cursorDiv = elt("div", null, "CodeMirror-cursors");
|
152 |
-
// A visibility: hidden element used to find the size of things.
|
153 |
-
d.measure = elt("div", null, "CodeMirror-measure");
|
154 |
-
// When lines outside of the viewport are measured, they are drawn in this.
|
155 |
-
d.lineMeasure = elt("div", null, "CodeMirror-measure");
|
156 |
-
// Wraps everything that needs to exist inside the vertically-padded coordinate system
|
157 |
-
d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
|
158 |
-
null, "position: relative; outline: none");
|
159 |
-
// Moved around its parent to cover visible view.
|
160 |
-
d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
|
161 |
-
// Set to the height of the document, allowing scrolling.
|
162 |
-
d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
|
163 |
-
d.sizerWidth = null;
|
164 |
-
// Behavior of elts with overflow: auto and padding is
|
165 |
-
// inconsistent across browsers. This is used to ensure the
|
166 |
-
// scrollable area is big enough.
|
167 |
-
d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
|
168 |
-
// Will contain the gutters, if any.
|
169 |
-
d.gutters = elt("div", null, "CodeMirror-gutters");
|
170 |
-
d.lineGutter = null;
|
171 |
-
// Actual scrollable element.
|
172 |
-
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
|
173 |
-
d.scroller.setAttribute("tabIndex", "-1");
|
174 |
-
// The element in which the editor lives.
|
175 |
-
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
|
176 |
-
|
177 |
-
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
|
178 |
-
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
|
179 |
-
if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
|
180 |
-
|
181 |
-
if (place) {
|
182 |
-
if (place.appendChild) place.appendChild(d.wrapper);
|
183 |
-
else place(d.wrapper);
|
184 |
-
}
|
185 |
-
|
186 |
-
// Current rendered range (may be bigger than the view window).
|
187 |
-
d.viewFrom = d.viewTo = doc.first;
|
188 |
-
d.reportedViewFrom = d.reportedViewTo = doc.first;
|
189 |
-
// Information about the rendered lines.
|
190 |
-
d.view = [];
|
191 |
-
d.renderedView = null;
|
192 |
-
// Holds info about a single rendered line when it was rendered
|
193 |
-
// for measurement, while not in view.
|
194 |
-
d.externalMeasured = null;
|
195 |
-
// Empty space (in pixels) above the view
|
196 |
-
d.viewOffset = 0;
|
197 |
-
d.lastWrapHeight = d.lastWrapWidth = 0;
|
198 |
-
d.updateLineNumbers = null;
|
199 |
-
|
200 |
-
d.nativeBarWidth = d.barHeight = d.barWidth = 0;
|
201 |
-
d.scrollbarsClipped = false;
|
202 |
-
|
203 |
-
// Used to only resize the line number gutter when necessary (when
|
204 |
-
// the amount of lines crosses a boundary that makes its width change)
|
205 |
-
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
|
206 |
-
// Set to true when a non-horizontal-scrolling line widget is
|
207 |
-
// added. As an optimization, line widget aligning is skipped when
|
208 |
-
// this is false.
|
209 |
-
d.alignWidgets = false;
|
210 |
-
|
211 |
-
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
|
212 |
-
|
213 |
-
// Tracks the maximum line length so that the horizontal scrollbar
|
214 |
-
// can be kept static when scrolling.
|
215 |
-
d.maxLine = null;
|
216 |
-
d.maxLineLength = 0;
|
217 |
-
d.maxLineChanged = false;
|
218 |
-
|
219 |
-
// Used for measuring wheel scrolling granularity
|
220 |
-
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
|
221 |
-
|
222 |
-
// True when shift is held down.
|
223 |
-
d.shift = false;
|
224 |
-
|
225 |
-
// Used to track whether anything happened since the context menu
|
226 |
-
// was opened.
|
227 |
-
d.selForContextMenu = null;
|
228 |
-
|
229 |
-
d.activeTouch = null;
|
230 |
-
|
231 |
-
input.init(d);
|
232 |
-
}
|
233 |
-
|
234 |
-
// STATE UPDATES
|
235 |
-
|
236 |
-
// Used to get the editor into a consistent state again when options change.
|
237 |
-
|
238 |
-
function loadMode(cm) {
|
239 |
-
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
|
240 |
-
resetModeState(cm);
|
241 |
-
}
|
242 |
-
|
243 |
-
function resetModeState(cm) {
|
244 |
-
cm.doc.iter(function(line) {
|
245 |
-
if (line.stateAfter) line.stateAfter = null;
|
246 |
-
if (line.styles) line.styles = null;
|
247 |
-
});
|
248 |
-
cm.doc.frontier = cm.doc.first;
|
249 |
-
startWorker(cm, 100);
|
250 |
-
cm.state.modeGen++;
|
251 |
-
if (cm.curOp) regChange(cm);
|
252 |
-
}
|
253 |
-
|
254 |
-
function wrappingChanged(cm) {
|
255 |
-
if (cm.options.lineWrapping) {
|
256 |
-
addClass(cm.display.wrapper, "CodeMirror-wrap");
|
257 |
-
cm.display.sizer.style.minWidth = "";
|
258 |
-
cm.display.sizerWidth = null;
|
259 |
-
} else {
|
260 |
-
rmClass(cm.display.wrapper, "CodeMirror-wrap");
|
261 |
-
findMaxLine(cm);
|
262 |
-
}
|
263 |
-
estimateLineHeights(cm);
|
264 |
-
regChange(cm);
|
265 |
-
clearCaches(cm);
|
266 |
-
setTimeout(function(){updateScrollbars(cm);}, 100);
|
267 |
-
}
|
268 |
-
|
269 |
-
// Returns a function that estimates the height of a line, to use as
|
270 |
-
// first approximation until the line becomes visible (and is thus
|
271 |
-
// properly measurable).
|
272 |
-
function estimateHeight(cm) {
|
273 |
-
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
|
274 |
-
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
|
275 |
-
return function(line) {
|
276 |
-
if (lineIsHidden(cm.doc, line)) return 0;
|
277 |
-
|
278 |
-
var widgetsHeight = 0;
|
279 |
-
if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
|
280 |
-
if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
|
281 |
-
}
|
282 |
-
|
283 |
-
if (wrapping)
|
284 |
-
return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
|
285 |
-
else
|
286 |
-
return widgetsHeight + th;
|
287 |
-
};
|
288 |
-
}
|
289 |
-
|
290 |
-
function estimateLineHeights(cm) {
|
291 |
-
var doc = cm.doc, est = estimateHeight(cm);
|
292 |
-
doc.iter(function(line) {
|
293 |
-
var estHeight = est(line);
|
294 |
-
if (estHeight != line.height) updateLineHeight(line, estHeight);
|
295 |
-
});
|
296 |
-
}
|
297 |
-
|
298 |
-
function themeChanged(cm) {
|
299 |
-
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
|
300 |
-
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
|
301 |
-
clearCaches(cm);
|
302 |
-
}
|
303 |
-
|
304 |
-
function guttersChanged(cm) {
|
305 |
-
updateGutters(cm);
|
306 |
-
regChange(cm);
|
307 |
-
setTimeout(function(){alignHorizontally(cm);}, 20);
|
308 |
-
}
|
309 |
-
|
310 |
-
// Rebuild the gutter elements, ensure the margin to the left of the
|
311 |
-
// code matches their width.
|
312 |
-
function updateGutters(cm) {
|
313 |
-
var gutters = cm.display.gutters, specs = cm.options.gutters;
|
314 |
-
removeChildren(gutters);
|
315 |
-
for (var i = 0; i < specs.length; ++i) {
|
316 |
-
var gutterClass = specs[i];
|
317 |
-
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
|
318 |
-
if (gutterClass == "CodeMirror-linenumbers") {
|
319 |
-
cm.display.lineGutter = gElt;
|
320 |
-
gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
|
321 |
-
}
|
322 |
-
}
|
323 |
-
gutters.style.display = i ? "" : "none";
|
324 |
-
updateGutterSpace(cm);
|
325 |
-
}
|
326 |
-
|
327 |
-
function updateGutterSpace(cm) {
|
328 |
-
var width = cm.display.gutters.offsetWidth;
|
329 |
-
cm.display.sizer.style.marginLeft = width + "px";
|
330 |
-
}
|
331 |
-
|
332 |
-
// Compute the character length of a line, taking into account
|
333 |
-
// collapsed ranges (see markText) that might hide parts, and join
|
334 |
-
// other lines onto it.
|
335 |
-
function lineLength(line) {
|
336 |
-
if (line.height == 0) return 0;
|
337 |
-
var len = line.text.length, merged, cur = line;
|
338 |
-
while (merged = collapsedSpanAtStart(cur)) {
|
339 |
-
var found = merged.find(0, true);
|
340 |
-
cur = found.from.line;
|
341 |
-
len += found.from.ch - found.to.ch;
|
342 |
-
}
|
343 |
-
cur = line;
|
344 |
-
while (merged = collapsedSpanAtEnd(cur)) {
|
345 |
-
var found = merged.find(0, true);
|
346 |
-
len -= cur.text.length - found.from.ch;
|
347 |
-
cur = found.to.line;
|
348 |
-
len += cur.text.length - found.to.ch;
|
349 |
-
}
|
350 |
-
return len;
|
351 |
-
}
|
352 |
-
|
353 |
-
// Find the longest line in the document.
|
354 |
-
function findMaxLine(cm) {
|
355 |
-
var d = cm.display, doc = cm.doc;
|
356 |
-
d.maxLine = getLine(doc, doc.first);
|
357 |
-
d.maxLineLength = lineLength(d.maxLine);
|
358 |
-
d.maxLineChanged = true;
|
359 |
-
doc.iter(function(line) {
|
360 |
-
var len = lineLength(line);
|
361 |
-
if (len > d.maxLineLength) {
|
362 |
-
d.maxLineLength = len;
|
363 |
-
d.maxLine = line;
|
364 |
-
}
|
365 |
-
});
|
366 |
-
}
|
367 |
-
|
368 |
-
// Make sure the gutters options contains the element
|
369 |
-
// "CodeMirror-linenumbers" when the lineNumbers option is true.
|
370 |
-
function setGuttersForLineNumbers(options) {
|
371 |
-
var found = indexOf(options.gutters, "CodeMirror-linenumbers");
|
372 |
-
if (found == -1 && options.lineNumbers) {
|
373 |
-
options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
|
374 |
-
} else if (found > -1 && !options.lineNumbers) {
|
375 |
-
options.gutters = options.gutters.slice(0);
|
376 |
-
options.gutters.splice(found, 1);
|
377 |
-
}
|
378 |
-
}
|
379 |
-
|
380 |
-
// SCROLLBARS
|
381 |
-
|
382 |
-
// Prepare DOM reads needed to update the scrollbars. Done in one
|
383 |
-
// shot to minimize update/measure roundtrips.
|
384 |
-
function measureForScrollbars(cm) {
|
385 |
-
var d = cm.display, gutterW = d.gutters.offsetWidth;
|
386 |
-
var docH = Math.round(cm.doc.height + paddingVert(cm.display));
|
387 |
-
return {
|
388 |
-
clientHeight: d.scroller.clientHeight,
|
389 |
-
viewHeight: d.wrapper.clientHeight,
|
390 |
-
scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
|
391 |
-
viewWidth: d.wrapper.clientWidth,
|
392 |
-
barLeft: cm.options.fixedGutter ? gutterW : 0,
|
393 |
-
docHeight: docH,
|
394 |
-
scrollHeight: docH + scrollGap(cm) + d.barHeight,
|
395 |
-
nativeBarWidth: d.nativeBarWidth,
|
396 |
-
gutterWidth: gutterW
|
397 |
-
};
|
398 |
-
}
|
399 |
-
|
400 |
-
function NativeScrollbars(place, scroll, cm) {
|
401 |
-
this.cm = cm;
|
402 |
-
var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
|
403 |
-
var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
|
404 |
-
place(vert); place(horiz);
|
405 |
-
|
406 |
-
on(vert, "scroll", function() {
|
407 |
-
if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
|
408 |
-
});
|
409 |
-
on(horiz, "scroll", function() {
|
410 |
-
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
|
411 |
-
});
|
412 |
-
|
413 |
-
this.checkedZeroWidth = false;
|
414 |
-
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
|
415 |
-
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
|
416 |
-
}
|
417 |
-
|
418 |
-
NativeScrollbars.prototype = copyObj({
|
419 |
-
update: function(measure) {
|
420 |
-
var needsH = measure.scrollWidth > measure.clientWidth + 1;
|
421 |
-
var needsV = measure.scrollHeight > measure.clientHeight + 1;
|
422 |
-
var sWidth = measure.nativeBarWidth;
|
423 |
-
|
424 |
-
if (needsV) {
|
425 |
-
this.vert.style.display = "block";
|
426 |
-
this.vert.style.bottom = needsH ? sWidth + "px" : "0";
|
427 |
-
var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
|
428 |
-
// A bug in IE8 can cause this value to be negative, so guard it.
|
429 |
-
this.vert.firstChild.style.height =
|
430 |
-
Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
|
431 |
-
} else {
|
432 |
-
this.vert.style.display = "";
|
433 |
-
this.vert.firstChild.style.height = "0";
|
434 |
-
}
|
435 |
-
|
436 |
-
if (needsH) {
|
437 |
-
this.horiz.style.display = "block";
|
438 |
-
this.horiz.style.right = needsV ? sWidth + "px" : "0";
|
439 |
-
this.horiz.style.left = measure.barLeft + "px";
|
440 |
-
var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
|
441 |
-
this.horiz.firstChild.style.width =
|
442 |
-
(measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
|
443 |
-
} else {
|
444 |
-
this.horiz.style.display = "";
|
445 |
-
this.horiz.firstChild.style.width = "0";
|
446 |
-
}
|
447 |
-
|
448 |
-
if (!this.checkedZeroWidth && measure.clientHeight > 0) {
|
449 |
-
if (sWidth == 0) this.zeroWidthHack();
|
450 |
-
this.checkedZeroWidth = true;
|
451 |
-
}
|
452 |
-
|
453 |
-
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
|
454 |
-
},
|
455 |
-
setScrollLeft: function(pos) {
|
456 |
-
if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
|
457 |
-
if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz);
|
458 |
-
},
|
459 |
-
setScrollTop: function(pos) {
|
460 |
-
if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
|
461 |
-
if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert);
|
462 |
-
},
|
463 |
-
zeroWidthHack: function() {
|
464 |
-
var w = mac && !mac_geMountainLion ? "12px" : "18px";
|
465 |
-
this.horiz.style.height = this.vert.style.width = w;
|
466 |
-
this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
|
467 |
-
this.disableHoriz = new Delayed;
|
468 |
-
this.disableVert = new Delayed;
|
469 |
-
},
|
470 |
-
enableZeroWidthBar: function(bar, delay) {
|
471 |
-
bar.style.pointerEvents = "auto";
|
472 |
-
function maybeDisable() {
|
473 |
-
// To find out whether the scrollbar is still visible, we
|
474 |
-
// check whether the element under the pixel in the bottom
|
475 |
-
// left corner of the scrollbar box is the scrollbar box
|
476 |
-
// itself (when the bar is still visible) or its filler child
|
477 |
-
// (when the bar is hidden). If it is still visible, we keep
|
478 |
-
// it enabled, if it's hidden, we disable pointer events.
|
479 |
-
var box = bar.getBoundingClientRect();
|
480 |
-
var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
|
481 |
-
if (elt != bar) bar.style.pointerEvents = "none";
|
482 |
-
else delay.set(1000, maybeDisable);
|
483 |
-
}
|
484 |
-
delay.set(1000, maybeDisable);
|
485 |
-
},
|
486 |
-
clear: function() {
|
487 |
-
var parent = this.horiz.parentNode;
|
488 |
-
parent.removeChild(this.horiz);
|
489 |
-
parent.removeChild(this.vert);
|
490 |
-
}
|
491 |
-
}, NativeScrollbars.prototype);
|
492 |
-
|
493 |
-
function NullScrollbars() {}
|
494 |
-
|
495 |
-
NullScrollbars.prototype = copyObj({
|
496 |
-
update: function() { return {bottom: 0, right: 0}; },
|
497 |
-
setScrollLeft: function() {},
|
498 |
-
setScrollTop: function() {},
|
499 |
-
clear: function() {}
|
500 |
-
}, NullScrollbars.prototype);
|
501 |
-
|
502 |
-
CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
|
503 |
-
|
504 |
-
function initScrollbars(cm) {
|
505 |
-
if (cm.display.scrollbars) {
|
506 |
-
cm.display.scrollbars.clear();
|
507 |
-
if (cm.display.scrollbars.addClass)
|
508 |
-
rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
|
509 |
-
}
|
510 |
-
|
511 |
-
cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
|
512 |
-
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
|
513 |
-
// Prevent clicks in the scrollbars from killing focus
|
514 |
-
on(node, "mousedown", function() {
|
515 |
-
if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
|
516 |
-
});
|
517 |
-
node.setAttribute("cm-not-content", "true");
|
518 |
-
}, function(pos, axis) {
|
519 |
-
if (axis == "horizontal") setScrollLeft(cm, pos);
|
520 |
-
else setScrollTop(cm, pos);
|
521 |
-
}, cm);
|
522 |
-
if (cm.display.scrollbars.addClass)
|
523 |
-
addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
|
524 |
-
}
|
525 |
-
|
526 |
-
function updateScrollbars(cm, measure) {
|
527 |
-
if (!measure) measure = measureForScrollbars(cm);
|
528 |
-
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
|
529 |
-
updateScrollbarsInner(cm, measure);
|
530 |
-
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
|
531 |
-
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
|
532 |
-
updateHeightsInViewport(cm);
|
533 |
-
updateScrollbarsInner(cm, measureForScrollbars(cm));
|
534 |
-
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
|
535 |
-
}
|
536 |
-
}
|
537 |
-
|
538 |
-
// Re-synchronize the fake scrollbars with the actual size of the
|
539 |
-
// content.
|
540 |
-
function updateScrollbarsInner(cm, measure) {
|
541 |
-
var d = cm.display;
|
542 |
-
var sizes = d.scrollbars.update(measure);
|
543 |
-
|
544 |
-
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
|
545 |
-
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
|
546 |
-
|
547 |
-
if (sizes.right && sizes.bottom) {
|
548 |
-
d.scrollbarFiller.style.display = "block";
|
549 |
-
d.scrollbarFiller.style.height = sizes.bottom + "px";
|
550 |
-
d.scrollbarFiller.style.width = sizes.right + "px";
|
551 |
-
} else d.scrollbarFiller.style.display = "";
|
552 |
-
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
|
553 |
-
d.gutterFiller.style.display = "block";
|
554 |
-
d.gutterFiller.style.height = sizes.bottom + "px";
|
555 |
-
d.gutterFiller.style.width = measure.gutterWidth + "px";
|
556 |
-
} else d.gutterFiller.style.display = "";
|
557 |
-
}
|
558 |
-
|
559 |
-
// Compute the lines that are visible in a given viewport (defaults
|
560 |
-
// the the current scroll position). viewport may contain top,
|
561 |
-
// height, and ensure (see op.scrollToPos) properties.
|
562 |
-
function visibleLines(display, doc, viewport) {
|
563 |
-
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
|
564 |
-
top = Math.floor(top - paddingTop(display));
|
565 |
-
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
|
566 |
-
|
567 |
-
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
|
568 |
-
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
|
569 |
-
// forces those lines into the viewport (if possible).
|
570 |
-
if (viewport && viewport.ensure) {
|
571 |
-
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
|
572 |
-
if (ensureFrom < from) {
|
573 |
-
from = ensureFrom;
|
574 |
-
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
|
575 |
-
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
|
576 |
-
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
|
577 |
-
to = ensureTo;
|
578 |
-
}
|
579 |
-
}
|
580 |
-
return {from: from, to: Math.max(to, from + 1)};
|
581 |
-
}
|
582 |
-
|
583 |
-
// LINE NUMBERS
|
584 |
-
|
585 |
-
// Re-align line numbers and gutter marks to compensate for
|
586 |
-
// horizontal scrolling.
|
587 |
-
function alignHorizontally(cm) {
|
588 |
-
var display = cm.display, view = display.view;
|
589 |
-
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
|
590 |
-
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
|
591 |
-
var gutterW = display.gutters.offsetWidth, left = comp + "px";
|
592 |
-
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
|
593 |
-
if (cm.options.fixedGutter && view[i].gutter)
|
594 |
-
view[i].gutter.style.left = left;
|
595 |
-
var align = view[i].alignable;
|
596 |
-
if (align) for (var j = 0; j < align.length; j++)
|
597 |
-
align[j].style.left = left;
|
598 |
-
}
|
599 |
-
if (cm.options.fixedGutter)
|
600 |
-
display.gutters.style.left = (comp + gutterW) + "px";
|
601 |
-
}
|
602 |
-
|
603 |
-
// Used to ensure that the line number gutter is still the right
|
604 |
-
// size for the current document size. Returns true when an update
|
605 |
-
// is needed.
|
606 |
-
function maybeUpdateLineNumberWidth(cm) {
|
607 |
-
if (!cm.options.lineNumbers) return false;
|
608 |
-
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
|
609 |
-
if (last.length != display.lineNumChars) {
|
610 |
-
var test = display.measure.appendChild(elt("div", [elt("div", last)],
|
611 |
-
"CodeMirror-linenumber CodeMirror-gutter-elt"));
|
612 |
-
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
|
613 |
-
display.lineGutter.style.width = "";
|
614 |
-
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
|
615 |
-
display.lineNumWidth = display.lineNumInnerWidth + padding;
|
616 |
-
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
|
617 |
-
display.lineGutter.style.width = display.lineNumWidth + "px";
|
618 |
-
updateGutterSpace(cm);
|
619 |
-
return true;
|
620 |
-
}
|
621 |
-
return false;
|
622 |
-
}
|
623 |
-
|
624 |
-
function lineNumberFor(options, i) {
|
625 |
-
return String(options.lineNumberFormatter(i + options.firstLineNumber));
|
626 |
-
}
|
627 |
-
|
628 |
-
// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
|
629 |
-
// but using getBoundingClientRect to get a sub-pixel-accurate
|
630 |
-
// result.
|
631 |
-
function compensateForHScroll(display) {
|
632 |
-
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
|
633 |
-
}
|
634 |
-
|
635 |
-
// DISPLAY DRAWING
|
636 |
-
|
637 |
-
function DisplayUpdate(cm, viewport, force) {
|
638 |
-
var display = cm.display;
|
639 |
-
|
640 |
-
this.viewport = viewport;
|
641 |
-
// Store some values that we'll need later (but don't want to force a relayout for)
|
642 |
-
this.visible = visibleLines(display, cm.doc, viewport);
|
643 |
-
this.editorIsHidden = !display.wrapper.offsetWidth;
|
644 |
-
this.wrapperHeight = display.wrapper.clientHeight;
|
645 |
-
this.wrapperWidth = display.wrapper.clientWidth;
|
646 |
-
this.oldDisplayWidth = displayWidth(cm);
|
647 |
-
this.force = force;
|
648 |
-
this.dims = getDimensions(cm);
|
649 |
-
this.events = [];
|
650 |
-
}
|
651 |
-
|
652 |
-
DisplayUpdate.prototype.signal = function(emitter, type) {
|
653 |
-
if (hasHandler(emitter, type))
|
654 |
-
this.events.push(arguments);
|
655 |
-
};
|
656 |
-
DisplayUpdate.prototype.finish = function() {
|
657 |
-
for (var i = 0; i < this.events.length; i++)
|
658 |
-
signal.apply(null, this.events[i]);
|
659 |
-
};
|
660 |
-
|
661 |
-
function maybeClipScrollbars(cm) {
|
662 |
-
var display = cm.display;
|
663 |
-
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
|
664 |
-
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
|
665 |
-
display.heightForcer.style.height = scrollGap(cm) + "px";
|
666 |
-
display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
|
667 |
-
display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
|
668 |
-
display.scrollbarsClipped = true;
|
669 |
-
}
|
670 |
-
}
|
671 |
-
|
672 |
-
// Does the actual updating of the line display. Bails out
|
673 |
-
// (returning false) when there is nothing to be done and forced is
|
674 |
-
// false.
|
675 |
-
function updateDisplayIfNeeded(cm, update) {
|
676 |
-
var display = cm.display, doc = cm.doc;
|
677 |
-
|
678 |
-
if (update.editorIsHidden) {
|
679 |
-
resetView(cm);
|
680 |
-
return false;
|
681 |
-
}
|
682 |
-
|
683 |
-
// Bail out if the visible area is already rendered and nothing changed.
|
684 |
-
if (!update.force &&
|
685 |
-
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
|
686 |
-
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
|
687 |
-
display.renderedView == display.view && countDirtyView(cm) == 0)
|
688 |
-
return false;
|
689 |
-
|
690 |
-
if (maybeUpdateLineNumberWidth(cm)) {
|
691 |
-
resetView(cm);
|
692 |
-
update.dims = getDimensions(cm);
|
693 |
-
}
|
694 |
-
|
695 |
-
// Compute a suitable new viewport (from & to)
|
696 |
-
var end = doc.first + doc.size;
|
697 |
-
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
|
698 |
-
var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
|
699 |
-
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
|
700 |
-
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
|
701 |
-
if (sawCollapsedSpans) {
|
702 |
-
from = visualLineNo(cm.doc, from);
|
703 |
-
to = visualLineEndNo(cm.doc, to);
|
704 |
-
}
|
705 |
-
|
706 |
-
var different = from != display.viewFrom || to != display.viewTo ||
|
707 |
-
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
|
708 |
-
adjustView(cm, from, to);
|
709 |
-
|
710 |
-
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
|
711 |
-
// Position the mover div to align with the current scroll position
|
712 |
-
cm.display.mover.style.top = display.viewOffset + "px";
|
713 |
-
|
714 |
-
var toUpdate = countDirtyView(cm);
|
715 |
-
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
|
716 |
-
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
|
717 |
-
return false;
|
718 |
-
|
719 |
-
// For big changes, we hide the enclosing element during the
|
720 |
-
// update, since that speeds up the operations on most browsers.
|
721 |
-
var focused = activeElt();
|
722 |
-
if (toUpdate > 4) display.lineDiv.style.display = "none";
|
723 |
-
patchDisplay(cm, display.updateLineNumbers, update.dims);
|
724 |
-
if (toUpdate > 4) display.lineDiv.style.display = "";
|
725 |
-
display.renderedView = display.view;
|
726 |
-
// There might have been a widget with a focused element that got
|
727 |
-
// hidden or updated, if so re-focus it.
|
728 |
-
if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
|
729 |
-
|
730 |
-
// Prevent selection and cursors from interfering with the scroll
|
731 |
-
// width and height.
|
732 |
-
removeChildren(display.cursorDiv);
|
733 |
-
removeChildren(display.selectionDiv);
|
734 |
-
display.gutters.style.height = display.sizer.style.minHeight = 0;
|
735 |
-
|
736 |
-
if (different) {
|
737 |
-
display.lastWrapHeight = update.wrapperHeight;
|
738 |
-
display.lastWrapWidth = update.wrapperWidth;
|
739 |
-
startWorker(cm, 400);
|
740 |
-
}
|
741 |
-
|
742 |
-
display.updateLineNumbers = null;
|
743 |
-
|
744 |
-
return true;
|
745 |
-
}
|
746 |
-
|
747 |
-
function postUpdateDisplay(cm, update) {
|
748 |
-
var viewport = update.viewport;
|
749 |
-
for (var first = true;; first = false) {
|
750 |
-
if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
|
751 |
-
// Clip forced viewport to actual scrollable area.
|
752 |
-
if (viewport && viewport.top != null)
|
753 |
-
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
|
754 |
-
// Updated line heights might result in the drawn area not
|
755 |
-
// actually covering the viewport. Keep looping until it does.
|
756 |
-
update.visible = visibleLines(cm.display, cm.doc, viewport);
|
757 |
-
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
|
758 |
-
break;
|
759 |
-
}
|
760 |
-
if (!updateDisplayIfNeeded(cm, update)) break;
|
761 |
-
updateHeightsInViewport(cm);
|
762 |
-
var barMeasure = measureForScrollbars(cm);
|
763 |
-
updateSelection(cm);
|
764 |
-
setDocumentHeight(cm, barMeasure);
|
765 |
-
updateScrollbars(cm, barMeasure);
|
766 |
-
}
|
767 |
-
|
768 |
-
update.signal(cm, "update", cm);
|
769 |
-
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
|
770 |
-
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
|
771 |
-
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
|
772 |
-
}
|
773 |
-
}
|
774 |
-
|
775 |
-
function updateDisplaySimple(cm, viewport) {
|
776 |
-
var update = new DisplayUpdate(cm, viewport);
|
777 |
-
if (updateDisplayIfNeeded(cm, update)) {
|
778 |
-
updateHeightsInViewport(cm);
|
779 |
-
postUpdateDisplay(cm, update);
|
780 |
-
var barMeasure = measureForScrollbars(cm);
|
781 |
-
updateSelection(cm);
|
782 |
-
setDocumentHeight(cm, barMeasure);
|
783 |
-
updateScrollbars(cm, barMeasure);
|
784 |
-
update.finish();
|
785 |
-
}
|
786 |
-
}
|
787 |
-
|
788 |
-
function setDocumentHeight(cm, measure) {
|
789 |
-
cm.display.sizer.style.minHeight = measure.docHeight + "px";
|
790 |
-
var total = measure.docHeight + cm.display.barHeight;
|
791 |
-
cm.display.heightForcer.style.top = total + "px";
|
792 |
-
cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px";
|
793 |
-
}
|
794 |
-
|
795 |
-
// Read the actual heights of the rendered lines, and update their
|
796 |
-
// stored heights to match.
|
797 |
-
function updateHeightsInViewport(cm) {
|
798 |
-
var display = cm.display;
|
799 |
-
var prevBottom = display.lineDiv.offsetTop;
|
800 |
-
for (var i = 0; i < display.view.length; i++) {
|
801 |
-
var cur = display.view[i], height;
|
802 |
-
if (cur.hidden) continue;
|
803 |
-
if (ie && ie_version < 8) {
|
804 |
-
var bot = cur.node.offsetTop + cur.node.offsetHeight;
|
805 |
-
height = bot - prevBottom;
|
806 |
-
prevBottom = bot;
|
807 |
-
} else {
|
808 |
-
var box = cur.node.getBoundingClientRect();
|
809 |
-
height = box.bottom - box.top;
|
810 |
-
}
|
811 |
-
var diff = cur.line.height - height;
|
812 |
-
if (height < 2) height = textHeight(display);
|
813 |
-
if (diff > .001 || diff < -.001) {
|
814 |
-
updateLineHeight(cur.line, height);
|
815 |
-
updateWidgetHeight(cur.line);
|
816 |
-
if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
|
817 |
-
updateWidgetHeight(cur.rest[j]);
|
818 |
-
}
|
819 |
-
}
|
820 |
-
}
|
821 |
-
|
822 |
-
// Read and store the height of line widgets associated with the
|
823 |
-
// given line.
|
824 |
-
function updateWidgetHeight(line) {
|
825 |
-
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
|
826 |
-
line.widgets[i].height = line.widgets[i].node.offsetHeight;
|
827 |
-
}
|
828 |
-
|
829 |
-
// Do a bulk-read of the DOM positions and sizes needed to draw the
|
830 |
-
// view, so that we don't interleave reading and writing to the DOM.
|
831 |
-
function getDimensions(cm) {
|
832 |
-
var d = cm.display, left = {}, width = {};
|
833 |
-
var gutterLeft = d.gutters.clientLeft;
|
834 |
-
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
|
835 |
-
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
|
836 |
-
width[cm.options.gutters[i]] = n.clientWidth;
|
837 |
-
}
|
838 |
-
return {fixedPos: compensateForHScroll(d),
|
839 |
-
gutterTotalWidth: d.gutters.offsetWidth,
|
840 |
-
gutterLeft: left,
|
841 |
-
gutterWidth: width,
|
842 |
-
wrapperWidth: d.wrapper.clientWidth};
|
843 |
-
}
|
844 |
-
|
845 |
-
// Sync the actual display DOM structure with display.view, removing
|
846 |
-
// nodes for lines that are no longer in view, and creating the ones
|
847 |
-
// that are not there yet, and updating the ones that are out of
|
848 |
-
// date.
|
849 |
-
function patchDisplay(cm, updateNumbersFrom, dims) {
|
850 |
-
var display = cm.display, lineNumbers = cm.options.lineNumbers;
|
851 |
-
var container = display.lineDiv, cur = container.firstChild;
|
852 |
-
|
853 |
-
function rm(node) {
|
854 |
-
var next = node.nextSibling;
|
855 |
-
// Works around a throw-scroll bug in OS X Webkit
|
856 |
-
if (webkit && mac && cm.display.currentWheelTarget == node)
|
857 |
-
node.style.display = "none";
|
858 |
-
else
|
859 |
-
node.parentNode.removeChild(node);
|
860 |
-
return next;
|
861 |
-
}
|
862 |
-
|
863 |
-
var view = display.view, lineN = display.viewFrom;
|
864 |
-
// Loop over the elements in the view, syncing cur (the DOM nodes
|
865 |
-
// in display.lineDiv) with the view as we go.
|
866 |
-
for (var i = 0; i < view.length; i++) {
|
867 |
-
var lineView = view[i];
|
868 |
-
if (lineView.hidden) {
|
869 |
-
} else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
|
870 |
-
var node = buildLineElement(cm, lineView, lineN, dims);
|
871 |
-
container.insertBefore(node, cur);
|
872 |
-
} else { // Already drawn
|
873 |
-
while (cur != lineView.node) cur = rm(cur);
|
874 |
-
var updateNumber = lineNumbers && updateNumbersFrom != null &&
|
875 |
-
updateNumbersFrom <= lineN && lineView.lineNumber;
|
876 |
-
if (lineView.changes) {
|
877 |
-
if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
|
878 |
-
updateLineForChanges(cm, lineView, lineN, dims);
|
879 |
-
}
|
880 |
-
if (updateNumber) {
|
881 |
-
removeChildren(lineView.lineNumber);
|
882 |
-
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
|
883 |
-
}
|
884 |
-
cur = lineView.node.nextSibling;
|
885 |
-
}
|
886 |
-
lineN += lineView.size;
|
887 |
-
}
|
888 |
-
while (cur) cur = rm(cur);
|
889 |
-
}
|
890 |
-
|
891 |
-
// When an aspect of a line changes, a string is added to
|
892 |
-
// lineView.changes. This updates the relevant part of the line's
|
893 |
-
// DOM structure.
|
894 |
-
function updateLineForChanges(cm, lineView, lineN, dims) {
|
895 |
-
for (var j = 0; j < lineView.changes.length; j++) {
|
896 |
-
var type = lineView.changes[j];
|
897 |
-
if (type == "text") updateLineText(cm, lineView);
|
898 |
-
else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
|
899 |
-
else if (type == "class") updateLineClasses(lineView);
|
900 |
-
else if (type == "widget") updateLineWidgets(cm, lineView, dims);
|
901 |
-
}
|
902 |
-
lineView.changes = null;
|
903 |
-
}
|
904 |
-
|
905 |
-
// Lines with gutter elements, widgets or a background class need to
|
906 |
-
// be wrapped, and have the extra elements added to the wrapper div
|
907 |
-
function ensureLineWrapped(lineView) {
|
908 |
-
if (lineView.node == lineView.text) {
|
909 |
-
lineView.node = elt("div", null, null, "position: relative");
|
910 |
-
if (lineView.text.parentNode)
|
911 |
-
lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
|
912 |
-
lineView.node.appendChild(lineView.text);
|
913 |
-
if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
|
914 |
-
}
|
915 |
-
return lineView.node;
|
916 |
-
}
|
917 |
-
|
918 |
-
function updateLineBackground(lineView) {
|
919 |
-
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
|
920 |
-
if (cls) cls += " CodeMirror-linebackground";
|
921 |
-
if (lineView.background) {
|
922 |
-
if (cls) lineView.background.className = cls;
|
923 |
-
else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
|
924 |
-
} else if (cls) {
|
925 |
-
var wrap = ensureLineWrapped(lineView);
|
926 |
-
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
|
927 |
-
}
|
928 |
-
}
|
929 |
-
|
930 |
-
// Wrapper around buildLineContent which will reuse the structure
|
931 |
-
// in display.externalMeasured when possible.
|
932 |
-
function getLineContent(cm, lineView) {
|
933 |
-
var ext = cm.display.externalMeasured;
|
934 |
-
if (ext && ext.line == lineView.line) {
|
935 |
-
cm.display.externalMeasured = null;
|
936 |
-
lineView.measure = ext.measure;
|
937 |
-
return ext.built;
|
938 |
-
}
|
939 |
-
return buildLineContent(cm, lineView);
|
940 |
-
}
|
941 |
-
|
942 |
-
// Redraw the line's text. Interacts with the background and text
|
943 |
-
// classes because the mode may output tokens that influence these
|
944 |
-
// classes.
|
945 |
-
function updateLineText(cm, lineView) {
|
946 |
-
var cls = lineView.text.className;
|
947 |
-
var built = getLineContent(cm, lineView);
|
948 |
-
if (lineView.text == lineView.node) lineView.node = built.pre;
|
949 |
-
lineView.text.parentNode.replaceChild(built.pre, lineView.text);
|
950 |
-
lineView.text = built.pre;
|
951 |
-
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
|
952 |
-
lineView.bgClass = built.bgClass;
|
953 |
-
lineView.textClass = built.textClass;
|
954 |
-
updateLineClasses(lineView);
|
955 |
-
} else if (cls) {
|
956 |
-
lineView.text.className = cls;
|
957 |
-
}
|
958 |
-
}
|
959 |
-
|
960 |
-
function updateLineClasses(lineView) {
|
961 |
-
updateLineBackground(lineView);
|
962 |
-
if (lineView.line.wrapClass)
|
963 |
-
ensureLineWrapped(lineView).className = lineView.line.wrapClass;
|
964 |
-
else if (lineView.node != lineView.text)
|
965 |
-
lineView.node.className = "";
|
966 |
-
var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
|
967 |
-
lineView.text.className = textClass || "";
|
968 |
-
}
|
969 |
-
|
970 |
-
function updateLineGutter(cm, lineView, lineN, dims) {
|
971 |
-
if (lineView.gutter) {
|
972 |
-
lineView.node.removeChild(lineView.gutter);
|
973 |
-
lineView.gutter = null;
|
974 |
-
}
|
975 |
-
if (lineView.gutterBackground) {
|
976 |
-
lineView.node.removeChild(lineView.gutterBackground);
|
977 |
-
lineView.gutterBackground = null;
|
978 |
-
}
|
979 |
-
if (lineView.line.gutterClass) {
|
980 |
-
var wrap = ensureLineWrapped(lineView);
|
981 |
-
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
|
982 |
-
"left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
|
983 |
-
"px; width: " + dims.gutterTotalWidth + "px");
|
984 |
-
wrap.insertBefore(lineView.gutterBackground, lineView.text);
|
985 |
-
}
|
986 |
-
var markers = lineView.line.gutterMarkers;
|
987 |
-
if (cm.options.lineNumbers || markers) {
|
988 |
-
var wrap = ensureLineWrapped(lineView);
|
989 |
-
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
|
990 |
-
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
|
991 |
-
cm.display.input.setUneditable(gutterWrap);
|
992 |
-
wrap.insertBefore(gutterWrap, lineView.text);
|
993 |
-
if (lineView.line.gutterClass)
|
994 |
-
gutterWrap.className += " " + lineView.line.gutterClass;
|
995 |
-
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
|
996 |
-
lineView.lineNumber = gutterWrap.appendChild(
|
997 |
-
elt("div", lineNumberFor(cm.options, lineN),
|
998 |
-
"CodeMirror-linenumber CodeMirror-gutter-elt",
|
999 |
-
"left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
|
1000 |
-
+ cm.display.lineNumInnerWidth + "px"));
|
1001 |
-
if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
|
1002 |
-
var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
|
1003 |
-
if (found)
|
1004 |
-
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
|
1005 |
-
dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
|
1006 |
-
}
|
1007 |
-
}
|
1008 |
-
}
|
1009 |
-
|
1010 |
-
function updateLineWidgets(cm, lineView, dims) {
|
1011 |
-
if (lineView.alignable) lineView.alignable = null;
|
1012 |
-
for (var node = lineView.node.firstChild, next; node; node = next) {
|
1013 |
-
var next = node.nextSibling;
|
1014 |
-
if (node.className == "CodeMirror-linewidget")
|
1015 |
-
lineView.node.removeChild(node);
|
1016 |
-
}
|
1017 |
-
insertLineWidgets(cm, lineView, dims);
|
1018 |
-
}
|
1019 |
-
|
1020 |
-
// Build a line's DOM representation from scratch
|
1021 |
-
function buildLineElement(cm, lineView, lineN, dims) {
|
1022 |
-
var built = getLineContent(cm, lineView);
|
1023 |
-
lineView.text = lineView.node = built.pre;
|
1024 |
-
if (built.bgClass) lineView.bgClass = built.bgClass;
|
1025 |
-
if (built.textClass) lineView.textClass = built.textClass;
|
1026 |
-
|
1027 |
-
updateLineClasses(lineView);
|
1028 |
-
updateLineGutter(cm, lineView, lineN, dims);
|
1029 |
-
insertLineWidgets(cm, lineView, dims);
|
1030 |
-
return lineView.node;
|
1031 |
-
}
|
1032 |
-
|
1033 |
-
// A lineView may contain multiple logical lines (when merged by
|
1034 |
-
// collapsed spans). The widgets for all of them need to be drawn.
|
1035 |
-
function insertLineWidgets(cm, lineView, dims) {
|
1036 |
-
insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
|
1037 |
-
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
|
1038 |
-
insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
|
1039 |
-
}
|
1040 |
-
|
1041 |
-
function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
|
1042 |
-
if (!line.widgets) return;
|
1043 |
-
var wrap = ensureLineWrapped(lineView);
|
1044 |
-
for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
|
1045 |
-
var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
|
1046 |
-
if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
|
1047 |
-
positionLineWidget(widget, node, lineView, dims);
|
1048 |
-
cm.display.input.setUneditable(node);
|
1049 |
-
if (allowAbove && widget.above)
|
1050 |
-
wrap.insertBefore(node, lineView.gutter || lineView.text);
|
1051 |
-
else
|
1052 |
-
wrap.appendChild(node);
|
1053 |
-
signalLater(widget, "redraw");
|
1054 |
-
}
|
1055 |
-
}
|
1056 |
-
|
1057 |
-
function positionLineWidget(widget, node, lineView, dims) {
|
1058 |
-
if (widget.noHScroll) {
|
1059 |
-
(lineView.alignable || (lineView.alignable = [])).push(node);
|
1060 |
-
var width = dims.wrapperWidth;
|
1061 |
-
node.style.left = dims.fixedPos + "px";
|
1062 |
-
if (!widget.coverGutter) {
|
1063 |
-
width -= dims.gutterTotalWidth;
|
1064 |
-
node.style.paddingLeft = dims.gutterTotalWidth + "px";
|
1065 |
-
}
|
1066 |
-
node.style.width = width + "px";
|
1067 |
-
}
|
1068 |
-
if (widget.coverGutter) {
|
1069 |
-
node.style.zIndex = 5;
|
1070 |
-
node.style.position = "relative";
|
1071 |
-
if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
|
1072 |
-
}
|
1073 |
-
}
|
1074 |
-
|
1075 |
-
// POSITION OBJECT
|
1076 |
-
|
1077 |
-
// A Pos instance represents a position within the text.
|
1078 |
-
var Pos = CodeMirror.Pos = function(line, ch) {
|
1079 |
-
if (!(this instanceof Pos)) return new Pos(line, ch);
|
1080 |
-
this.line = line; this.ch = ch;
|
1081 |
-
};
|
1082 |
-
|
1083 |
-
// Compare two positions, return 0 if they are the same, a negative
|
1084 |
-
// number when a is less, and a positive number otherwise.
|
1085 |
-
var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
|
1086 |
-
|
1087 |
-
function copyPos(x) {return Pos(x.line, x.ch);}
|
1088 |
-
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
|
1089 |
-
function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
|
1090 |
-
|
1091 |
-
// INPUT HANDLING
|
1092 |
-
|
1093 |
-
function ensureFocus(cm) {
|
1094 |
-
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
|
1095 |
-
}
|
1096 |
-
|
1097 |
-
function isReadOnly(cm) {
|
1098 |
-
return cm.options.readOnly || cm.doc.cantEdit;
|
1099 |
-
}
|
1100 |
-
|
1101 |
-
// This will be set to an array of strings when copying, so that,
|
1102 |
-
// when pasting, we know what kind of selections the copied text
|
1103 |
-
// was made out of.
|
1104 |
-
var lastCopied = null;
|
1105 |
-
|
1106 |
-
function applyTextInput(cm, inserted, deleted, sel, origin) {
|
1107 |
-
var doc = cm.doc;
|
1108 |
-
cm.display.shift = false;
|
1109 |
-
if (!sel) sel = doc.sel;
|
1110 |
-
|
1111 |
-
var paste = cm.state.pasteIncoming || origin == "paste";
|
1112 |
-
var textLines = doc.splitLines(inserted), multiPaste = null;
|
1113 |
-
// When pasing N lines into N selections, insert one line per selection
|
1114 |
-
if (paste && sel.ranges.length > 1) {
|
1115 |
-
if (lastCopied && lastCopied.join("\n") == inserted) {
|
1116 |
-
if (sel.ranges.length % lastCopied.length == 0) {
|
1117 |
-
multiPaste = [];
|
1118 |
-
for (var i = 0; i < lastCopied.length; i++)
|
1119 |
-
multiPaste.push(doc.splitLines(lastCopied[i]));
|
1120 |
-
}
|
1121 |
-
} else if (textLines.length == sel.ranges.length) {
|
1122 |
-
multiPaste = map(textLines, function(l) { return [l]; });
|
1123 |
-
}
|
1124 |
-
}
|
1125 |
-
|
1126 |
-
// Normal behavior is to insert the new text into every selection
|
1127 |
-
for (var i = sel.ranges.length - 1; i >= 0; i--) {
|
1128 |
-
var range = sel.ranges[i];
|
1129 |
-
var from = range.from(), to = range.to();
|
1130 |
-
if (range.empty()) {
|
1131 |
-
if (deleted && deleted > 0) // Handle deletion
|
1132 |
-
from = Pos(from.line, from.ch - deleted);
|
1133 |
-
else if (cm.state.overwrite && !paste) // Handle overwrite
|
1134 |
-
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
|
1135 |
-
}
|
1136 |
-
var updateInput = cm.curOp.updateInput;
|
1137 |
-
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
|
1138 |
-
origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
|
1139 |
-
makeChange(cm.doc, changeEvent);
|
1140 |
-
signalLater(cm, "inputRead", cm, changeEvent);
|
1141 |
-
}
|
1142 |
-
if (inserted && !paste)
|
1143 |
-
triggerElectric(cm, inserted);
|
1144 |
-
|
1145 |
-
ensureCursorVisible(cm);
|
1146 |
-
cm.curOp.updateInput = updateInput;
|
1147 |
-
cm.curOp.typing = true;
|
1148 |
-
cm.state.pasteIncoming = cm.state.cutIncoming = false;
|
1149 |
-
}
|
1150 |
-
|
1151 |
-
function handlePaste(e, cm) {
|
1152 |
-
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
1153 |
-
if (pasted) {
|
1154 |
-
e.preventDefault();
|
1155 |
-
if (!isReadOnly(cm) && !cm.options.disableInput)
|
1156 |
-
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
|
1157 |
-
return true;
|
1158 |
-
}
|
1159 |
-
}
|
1160 |
-
|
1161 |
-
function triggerElectric(cm, inserted) {
|
1162 |
-
// When an 'electric' character is inserted, immediately trigger a reindent
|
1163 |
-
if (!cm.options.electricChars || !cm.options.smartIndent) return;
|
1164 |
-
var sel = cm.doc.sel;
|
1165 |
-
|
1166 |
-
for (var i = sel.ranges.length - 1; i >= 0; i--) {
|
1167 |
-
var range = sel.ranges[i];
|
1168 |
-
if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue;
|
1169 |
-
var mode = cm.getModeAt(range.head);
|
1170 |
-
var indented = false;
|
1171 |
-
if (mode.electricChars) {
|
1172 |
-
for (var j = 0; j < mode.electricChars.length; j++)
|
1173 |
-
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
|
1174 |
-
indented = indentLine(cm, range.head.line, "smart");
|
1175 |
-
break;
|
1176 |
-
}
|
1177 |
-
} else if (mode.electricInput) {
|
1178 |
-
if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
|
1179 |
-
indented = indentLine(cm, range.head.line, "smart");
|
1180 |
-
}
|
1181 |
-
if (indented) signalLater(cm, "electricInput", cm, range.head.line);
|
1182 |
-
}
|
1183 |
-
}
|
1184 |
-
|
1185 |
-
function copyableRanges(cm) {
|
1186 |
-
var text = [], ranges = [];
|
1187 |
-
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
|
1188 |
-
var line = cm.doc.sel.ranges[i].head.line;
|
1189 |
-
var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
|
1190 |
-
ranges.push(lineRange);
|
1191 |
-
text.push(cm.getRange(lineRange.anchor, lineRange.head));
|
1192 |
-
}
|
1193 |
-
return {text: text, ranges: ranges};
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
function disableBrowserMagic(field) {
|
1197 |
-
field.setAttribute("autocorrect", "off");
|
1198 |
-
field.setAttribute("autocapitalize", "off");
|
1199 |
-
field.setAttribute("spellcheck", "false");
|
1200 |
-
}
|
1201 |
-
|
1202 |
-
// TEXTAREA INPUT STYLE
|
1203 |
-
|
1204 |
-
function TextareaInput(cm) {
|
1205 |
-
this.cm = cm;
|
1206 |
-
// See input.poll and input.reset
|
1207 |
-
this.prevInput = "";
|
1208 |
-
|
1209 |
-
// Flag that indicates whether we expect input to appear real soon
|
1210 |
-
// now (after some event like 'keypress' or 'input') and are
|
1211 |
-
// polling intensively.
|
1212 |
-
this.pollingFast = false;
|
1213 |
-
// Self-resetting timeout for the poller
|
1214 |
-
this.polling = new Delayed();
|
1215 |
-
// Tracks when input.reset has punted to just putting a short
|
1216 |
-
// string into the textarea instead of the full selection.
|
1217 |
-
this.inaccurateSelection = false;
|
1218 |
-
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
|
1219 |
-
this.hasSelection = false;
|
1220 |
-
this.composing = null;
|
1221 |
-
};
|
1222 |
-
|
1223 |
-
function hiddenTextarea() {
|
1224 |
-
var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
|
1225 |
-
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
|
1226 |
-
// The textarea is kept positioned near the cursor to prevent the
|
1227 |
-
// fact that it'll be scrolled into view on input from scrolling
|
1228 |
-
// our fake cursor out of view. On webkit, when wrap=off, paste is
|
1229 |
-
// very slow. So make the area wide instead.
|
1230 |
-
if (webkit) te.style.width = "1000px";
|
1231 |
-
else te.setAttribute("wrap", "off");
|
1232 |
-
// If border: 0; -- iOS fails to open keyboard (issue #1287)
|
1233 |
-
if (ios) te.style.border = "1px solid black";
|
1234 |
-
disableBrowserMagic(te);
|
1235 |
-
return div;
|
1236 |
-
}
|
1237 |
-
|
1238 |
-
TextareaInput.prototype = copyObj({
|
1239 |
-
init: function(display) {
|
1240 |
-
var input = this, cm = this.cm;
|
1241 |
-
|
1242 |
-
// Wraps and hides input textarea
|
1243 |
-
var div = this.wrapper = hiddenTextarea();
|
1244 |
-
// The semihidden textarea that is focused when the editor is
|
1245 |
-
// focused, and receives input.
|
1246 |
-
var te = this.textarea = div.firstChild;
|
1247 |
-
display.wrapper.insertBefore(div, display.wrapper.firstChild);
|
1248 |
-
|
1249 |
-
// Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
|
1250 |
-
if (ios) te.style.width = "0px";
|
1251 |
-
|
1252 |
-
on(te, "input", function() {
|
1253 |
-
if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
|
1254 |
-
input.poll();
|
1255 |
-
});
|
1256 |
-
|
1257 |
-
on(te, "paste", function(e) {
|
1258 |
-
if (handlePaste(e, cm)) return true;
|
1259 |
-
|
1260 |
-
cm.state.pasteIncoming = true;
|
1261 |
-
input.fastPoll();
|
1262 |
-
});
|
1263 |
-
|
1264 |
-
function prepareCopyCut(e) {
|
1265 |
-
if (cm.somethingSelected()) {
|
1266 |
-
lastCopied = cm.getSelections();
|
1267 |
-
if (input.inaccurateSelection) {
|
1268 |
-
input.prevInput = "";
|
1269 |
-
input.inaccurateSelection = false;
|
1270 |
-
te.value = lastCopied.join("\n");
|
1271 |
-
selectInput(te);
|
1272 |
-
}
|
1273 |
-
} else if (!cm.options.lineWiseCopyCut) {
|
1274 |
-
return;
|
1275 |
-
} else {
|
1276 |
-
var ranges = copyableRanges(cm);
|
1277 |
-
lastCopied = ranges.text;
|
1278 |
-
if (e.type == "cut") {
|
1279 |
-
cm.setSelections(ranges.ranges, null, sel_dontScroll);
|
1280 |
-
} else {
|
1281 |
-
input.prevInput = "";
|
1282 |
-
te.value = ranges.text.join("\n");
|
1283 |
-
selectInput(te);
|
1284 |
-
}
|
1285 |
-
}
|
1286 |
-
if (e.type == "cut") cm.state.cutIncoming = true;
|
1287 |
-
}
|
1288 |
-
on(te, "cut", prepareCopyCut);
|
1289 |
-
on(te, "copy", prepareCopyCut);
|
1290 |
-
|
1291 |
-
on(display.scroller, "paste", function(e) {
|
1292 |
-
if (eventInWidget(display, e)) return;
|
1293 |
-
cm.state.pasteIncoming = true;
|
1294 |
-
input.focus();
|
1295 |
-
});
|
1296 |
-
|
1297 |
-
// Prevent normal selection in the editor (we handle our own)
|
1298 |
-
on(display.lineSpace, "selectstart", function(e) {
|
1299 |
-
if (!eventInWidget(display, e)) e_preventDefault(e);
|
1300 |
-
});
|
1301 |
-
|
1302 |
-
on(te, "compositionstart", function() {
|
1303 |
-
var start = cm.getCursor("from");
|
1304 |
-
if (input.composing) input.composing.range.clear()
|
1305 |
-
input.composing = {
|
1306 |
-
start: start,
|
1307 |
-
range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
|
1308 |
-
};
|
1309 |
-
});
|
1310 |
-
on(te, "compositionend", function() {
|
1311 |
-
if (input.composing) {
|
1312 |
-
input.poll();
|
1313 |
-
input.composing.range.clear();
|
1314 |
-
input.composing = null;
|
1315 |
-
}
|
1316 |
-
});
|
1317 |
-
},
|
1318 |
-
|
1319 |
-
prepareSelection: function() {
|
1320 |
-
// Redraw the selection and/or cursor
|
1321 |
-
var cm = this.cm, display = cm.display, doc = cm.doc;
|
1322 |
-
var result = prepareSelection(cm);
|
1323 |
-
|
1324 |
-
// Move the hidden textarea near the cursor to prevent scrolling artifacts
|
1325 |
-
if (cm.options.moveInputWithCursor) {
|
1326 |
-
var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
|
1327 |
-
var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
|
1328 |
-
result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
|
1329 |
-
headPos.top + lineOff.top - wrapOff.top));
|
1330 |
-
result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
|
1331 |
-
headPos.left + lineOff.left - wrapOff.left));
|
1332 |
-
}
|
1333 |
-
|
1334 |
-
return result;
|
1335 |
-
},
|
1336 |
-
|
1337 |
-
showSelection: function(drawn) {
|
1338 |
-
var cm = this.cm, display = cm.display;
|
1339 |
-
removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
|
1340 |
-
removeChildrenAndAdd(display.selectionDiv, drawn.selection);
|
1341 |
-
if (drawn.teTop != null) {
|
1342 |
-
this.wrapper.style.top = drawn.teTop + "px";
|
1343 |
-
this.wrapper.style.left = drawn.teLeft + "px";
|
1344 |
-
}
|
1345 |
-
},
|
1346 |
-
|
1347 |
-
// Reset the input to correspond to the selection (or to be empty,
|
1348 |
-
// when not typing and nothing is selected)
|
1349 |
-
reset: function(typing) {
|
1350 |
-
if (this.contextMenuPending) return;
|
1351 |
-
var minimal, selected, cm = this.cm, doc = cm.doc;
|
1352 |
-
if (cm.somethingSelected()) {
|
1353 |
-
this.prevInput = "";
|
1354 |
-
var range = doc.sel.primary();
|
1355 |
-
minimal = hasCopyEvent &&
|
1356 |
-
(range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
|
1357 |
-
var content = minimal ? "-" : selected || cm.getSelection();
|
1358 |
-
this.textarea.value = content;
|
1359 |
-
if (cm.state.focused) selectInput(this.textarea);
|
1360 |
-
if (ie && ie_version >= 9) this.hasSelection = content;
|
1361 |
-
} else if (!typing) {
|
1362 |
-
this.prevInput = this.textarea.value = "";
|
1363 |
-
if (ie && ie_version >= 9) this.hasSelection = null;
|
1364 |
-
}
|
1365 |
-
this.inaccurateSelection = minimal;
|
1366 |
-
},
|
1367 |
-
|
1368 |
-
getField: function() { return this.textarea; },
|
1369 |
-
|
1370 |
-
supportsTouch: function() { return false; },
|
1371 |
-
|
1372 |
-
focus: function() {
|
1373 |
-
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
|
1374 |
-
try { this.textarea.focus(); }
|
1375 |
-
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
|
1376 |
-
}
|
1377 |
-
},
|
1378 |
-
|
1379 |
-
blur: function() { this.textarea.blur(); },
|
1380 |
-
|
1381 |
-
resetPosition: function() {
|
1382 |
-
this.wrapper.style.top = this.wrapper.style.left = 0;
|
1383 |
-
},
|
1384 |
-
|
1385 |
-
receivedFocus: function() { this.slowPoll(); },
|
1386 |
-
|
1387 |
-
// Poll for input changes, using the normal rate of polling. This
|
1388 |
-
// runs as long as the editor is focused.
|
1389 |
-
slowPoll: function() {
|
1390 |
-
var input = this;
|
1391 |
-
if (input.pollingFast) return;
|
1392 |
-
input.polling.set(this.cm.options.pollInterval, function() {
|
1393 |
-
input.poll();
|
1394 |
-
if (input.cm.state.focused) input.slowPoll();
|
1395 |
-
});
|
1396 |
-
},
|
1397 |
-
|
1398 |
-
// When an event has just come in that is likely to add or change
|
1399 |
-
// something in the input textarea, we poll faster, to ensure that
|
1400 |
-
// the change appears on the screen quickly.
|
1401 |
-
fastPoll: function() {
|
1402 |
-
var missed = false, input = this;
|
1403 |
-
input.pollingFast = true;
|
1404 |
-
function p() {
|
1405 |
-
var changed = input.poll();
|
1406 |
-
if (!changed && !missed) {missed = true; input.polling.set(60, p);}
|
1407 |
-
else {input.pollingFast = false; input.slowPoll();}
|
1408 |
-
}
|
1409 |
-
input.polling.set(20, p);
|
1410 |
-
},
|
1411 |
-
|
1412 |
-
// Read input from the textarea, and update the document to match.
|
1413 |
-
// When something is selected, it is present in the textarea, and
|
1414 |
-
// selected (unless it is huge, in which case a placeholder is
|
1415 |
-
// used). When nothing is selected, the cursor sits after previously
|
1416 |
-
// seen text (can be empty), which is stored in prevInput (we must
|
1417 |
-
// not reset the textarea when typing, because that breaks IME).
|
1418 |
-
poll: function() {
|
1419 |
-
var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
|
1420 |
-
// Since this is called a *lot*, try to bail out as cheaply as
|
1421 |
-
// possible when it is clear that nothing happened. hasSelection
|
1422 |
-
// will be the case when there is a lot of text in the textarea,
|
1423 |
-
// in which case reading its value would be expensive.
|
1424 |
-
if (this.contextMenuPending || !cm.state.focused ||
|
1425 |
-
(hasSelection(input) && !prevInput && !this.composing) ||
|
1426 |
-
isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq)
|
1427 |
-
return false;
|
1428 |
-
|
1429 |
-
var text = input.value;
|
1430 |
-
// If nothing changed, bail.
|
1431 |
-
if (text == prevInput && !cm.somethingSelected()) return false;
|
1432 |
-
// Work around nonsensical selection resetting in IE9/10, and
|
1433 |
-
// inexplicable appearance of private area unicode characters on
|
1434 |
-
// some key combos in Mac (#2689).
|
1435 |
-
if (ie && ie_version >= 9 && this.hasSelection === text ||
|
1436 |
-
mac && /[\uf700-\uf7ff]/.test(text)) {
|
1437 |
-
cm.display.input.reset();
|
1438 |
-
return false;
|
1439 |
-
}
|
1440 |
-
|
1441 |
-
if (cm.doc.sel == cm.display.selForContextMenu) {
|
1442 |
-
var first = text.charCodeAt(0);
|
1443 |
-
if (first == 0x200b && !prevInput) prevInput = "\u200b";
|
1444 |
-
if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); }
|
1445 |
-
}
|
1446 |
-
// Find the part of the input that is actually new
|
1447 |
-
var same = 0, l = Math.min(prevInput.length, text.length);
|
1448 |
-
while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
|
1449 |
-
|
1450 |
-
var self = this;
|
1451 |
-
runInOp(cm, function() {
|
1452 |
-
applyTextInput(cm, text.slice(same), prevInput.length - same,
|
1453 |
-
null, self.composing ? "*compose" : null);
|
1454 |
-
|
1455 |
-
// Don't leave long text in the textarea, since it makes further polling slow
|
1456 |
-
if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = "";
|
1457 |
-
else self.prevInput = text;
|
1458 |
-
|
1459 |
-
if (self.composing) {
|
1460 |
-
self.composing.range.clear();
|
1461 |
-
self.composing.range = cm.markText(self.composing.start, cm.getCursor("to"),
|
1462 |
-
{className: "CodeMirror-composing"});
|
1463 |
-
}
|
1464 |
-
});
|
1465 |
-
return true;
|
1466 |
-
},
|
1467 |
-
|
1468 |
-
ensurePolled: function() {
|
1469 |
-
if (this.pollingFast && this.poll()) this.pollingFast = false;
|
1470 |
-
},
|
1471 |
-
|
1472 |
-
onKeyPress: function() {
|
1473 |
-
if (ie && ie_version >= 9) this.hasSelection = null;
|
1474 |
-
this.fastPoll();
|
1475 |
-
},
|
1476 |
-
|
1477 |
-
onContextMenu: function(e) {
|
1478 |
-
var input = this, cm = input.cm, display = cm.display, te = input.textarea;
|
1479 |
-
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
|
1480 |
-
if (!pos || presto) return; // Opera is difficult.
|
1481 |
-
|
1482 |
-
// Reset the current text selection only if the click is done outside of the selection
|
1483 |
-
// and 'resetSelectionOnContextMenu' option is true.
|
1484 |
-
var reset = cm.options.resetSelectionOnContextMenu;
|
1485 |
-
if (reset && cm.doc.sel.contains(pos) == -1)
|
1486 |
-
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
|
1487 |
-
|
1488 |
-
var oldCSS = te.style.cssText;
|
1489 |
-
input.wrapper.style.position = "absolute";
|
1490 |
-
te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
|
1491 |
-
"px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
|
1492 |
-
(ie ? "rgba(255, 255, 255, .05)" : "transparent") +
|
1493 |
-
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
|
1494 |
-
if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
|
1495 |
-
display.input.focus();
|
1496 |
-
if (webkit) window.scrollTo(null, oldScrollY);
|
1497 |
-
display.input.reset();
|
1498 |
-
// Adds "Select all" to context menu in FF
|
1499 |
-
if (!cm.somethingSelected()) te.value = input.prevInput = " ";
|
1500 |
-
input.contextMenuPending = true;
|
1501 |
-
display.selForContextMenu = cm.doc.sel;
|
1502 |
-
clearTimeout(display.detectingSelectAll);
|
1503 |
-
|
1504 |
-
// Select-all will be greyed out if there's nothing to select, so
|
1505 |
-
// this adds a zero-width space so that we can later check whether
|
1506 |
-
// it got selected.
|
1507 |
-
function prepareSelectAllHack() {
|
1508 |
-
if (te.selectionStart != null) {
|
1509 |
-
var selected = cm.somethingSelected();
|
1510 |
-
var extval = "\u200b" + (selected ? te.value : "");
|
1511 |
-
te.value = "\u21da"; // Used to catch context-menu undo
|
1512 |
-
te.value = extval;
|
1513 |
-
input.prevInput = selected ? "" : "\u200b";
|
1514 |
-
te.selectionStart = 1; te.selectionEnd = extval.length;
|
1515 |
-
// Re-set this, in case some other handler touched the
|
1516 |
-
// selection in the meantime.
|
1517 |
-
display.selForContextMenu = cm.doc.sel;
|
1518 |
-
}
|
1519 |
-
}
|
1520 |
-
function rehide() {
|
1521 |
-
input.contextMenuPending = false;
|
1522 |
-
input.wrapper.style.position = "relative";
|
1523 |
-
te.style.cssText = oldCSS;
|
1524 |
-
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
|
1525 |
-
|
1526 |
-
// Try to detect the user choosing select-all
|
1527 |
-
if (te.selectionStart != null) {
|
1528 |
-
if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
|
1529 |
-
var i = 0, poll = function() {
|
1530 |
-
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
|
1531 |
-
te.selectionEnd > 0 && input.prevInput == "\u200b")
|
1532 |
-
operation(cm, commands.selectAll)(cm);
|
1533 |
-
else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
|
1534 |
-
else display.input.reset();
|
1535 |
-
};
|
1536 |
-
display.detectingSelectAll = setTimeout(poll, 200);
|
1537 |
-
}
|
1538 |
-
}
|
1539 |
-
|
1540 |
-
if (ie && ie_version >= 9) prepareSelectAllHack();
|
1541 |
-
if (captureRightClick) {
|
1542 |
-
e_stop(e);
|
1543 |
-
var mouseup = function() {
|
1544 |
-
off(window, "mouseup", mouseup);
|
1545 |
-
setTimeout(rehide, 20);
|
1546 |
-
};
|
1547 |
-
on(window, "mouseup", mouseup);
|
1548 |
-
} else {
|
1549 |
-
setTimeout(rehide, 50);
|
1550 |
-
}
|
1551 |
-
},
|
1552 |
-
|
1553 |
-
readOnlyChanged: function(val) {
|
1554 |
-
if (!val) this.reset();
|
1555 |
-
},
|
1556 |
-
|
1557 |
-
setUneditable: nothing,
|
1558 |
-
|
1559 |
-
needsContentAttribute: false
|
1560 |
-
}, TextareaInput.prototype);
|
1561 |
-
|
1562 |
-
// CONTENTEDITABLE INPUT STYLE
|
1563 |
-
|
1564 |
-
function ContentEditableInput(cm) {
|
1565 |
-
this.cm = cm;
|
1566 |
-
this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
|
1567 |
-
this.polling = new Delayed();
|
1568 |
-
this.gracePeriod = false;
|
1569 |
-
}
|
1570 |
-
|
1571 |
-
ContentEditableInput.prototype = copyObj({
|
1572 |
-
init: function(display) {
|
1573 |
-
var input = this, cm = input.cm;
|
1574 |
-
var div = input.div = display.lineDiv;
|
1575 |
-
disableBrowserMagic(div);
|
1576 |
-
|
1577 |
-
on(div, "paste", function(e) { handlePaste(e, cm); })
|
1578 |
-
|
1579 |
-
on(div, "compositionstart", function(e) {
|
1580 |
-
var data = e.data;
|
1581 |
-
input.composing = {sel: cm.doc.sel, data: data, startData: data};
|
1582 |
-
if (!data) return;
|
1583 |
-
var prim = cm.doc.sel.primary();
|
1584 |
-
var line = cm.getLine(prim.head.line);
|
1585 |
-
var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length));
|
1586 |
-
if (found > -1 && found <= prim.head.ch)
|
1587 |
-
input.composing.sel = simpleSelection(Pos(prim.head.line, found),
|
1588 |
-
Pos(prim.head.line, found + data.length));
|
1589 |
-
});
|
1590 |
-
on(div, "compositionupdate", function(e) {
|
1591 |
-
input.composing.data = e.data;
|
1592 |
-
});
|
1593 |
-
on(div, "compositionend", function(e) {
|
1594 |
-
var ours = input.composing;
|
1595 |
-
if (!ours) return;
|
1596 |
-
if (e.data != ours.startData && !/\u200b/.test(e.data))
|
1597 |
-
ours.data = e.data;
|
1598 |
-
// Need a small delay to prevent other code (input event,
|
1599 |
-
// selection polling) from doing damage when fired right after
|
1600 |
-
// compositionend.
|
1601 |
-
setTimeout(function() {
|
1602 |
-
if (!ours.handled)
|
1603 |
-
input.applyComposition(ours);
|
1604 |
-
if (input.composing == ours)
|
1605 |
-
input.composing = null;
|
1606 |
-
}, 50);
|
1607 |
-
});
|
1608 |
-
|
1609 |
-
on(div, "touchstart", function() {
|
1610 |
-
input.forceCompositionEnd();
|
1611 |
-
});
|
1612 |
-
|
1613 |
-
on(div, "input", function() {
|
1614 |
-
if (input.composing) return;
|
1615 |
-
if (isReadOnly(cm) || !input.pollContent())
|
1616 |
-
runInOp(input.cm, function() {regChange(cm);});
|
1617 |
-
});
|
1618 |
-
|
1619 |
-
function onCopyCut(e) {
|
1620 |
-
if (cm.somethingSelected()) {
|
1621 |
-
lastCopied = cm.getSelections();
|
1622 |
-
if (e.type == "cut") cm.replaceSelection("", null, "cut");
|
1623 |
-
} else if (!cm.options.lineWiseCopyCut) {
|
1624 |
-
return;
|
1625 |
-
} else {
|
1626 |
-
var ranges = copyableRanges(cm);
|
1627 |
-
lastCopied = ranges.text;
|
1628 |
-
if (e.type == "cut") {
|
1629 |
-
cm.operation(function() {
|
1630 |
-
cm.setSelections(ranges.ranges, 0, sel_dontScroll);
|
1631 |
-
cm.replaceSelection("", null, "cut");
|
1632 |
-
});
|
1633 |
-
}
|
1634 |
-
}
|
1635 |
-
// iOS exposes the clipboard API, but seems to discard content inserted into it
|
1636 |
-
if (e.clipboardData && !ios) {
|
1637 |
-
e.preventDefault();
|
1638 |
-
e.clipboardData.clearData();
|
1639 |
-
e.clipboardData.setData("text/plain", lastCopied.join("\n"));
|
1640 |
-
} else {
|
1641 |
-
// Old-fashioned briefly-focus-a-textarea hack
|
1642 |
-
var kludge = hiddenTextarea(), te = kludge.firstChild;
|
1643 |
-
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
1644 |
-
te.value = lastCopied.join("\n");
|
1645 |
-
var hadFocus = document.activeElement;
|
1646 |
-
selectInput(te);
|
1647 |
-
setTimeout(function() {
|
1648 |
-
cm.display.lineSpace.removeChild(kludge);
|
1649 |
-
hadFocus.focus();
|
1650 |
-
}, 50);
|
1651 |
-
}
|
1652 |
-
}
|
1653 |
-
on(div, "copy", onCopyCut);
|
1654 |
-
on(div, "cut", onCopyCut);
|
1655 |
-
},
|
1656 |
-
|
1657 |
-
prepareSelection: function() {
|
1658 |
-
var result = prepareSelection(this.cm, false);
|
1659 |
-
result.focus = this.cm.state.focused;
|
1660 |
-
return result;
|
1661 |
-
},
|
1662 |
-
|
1663 |
-
showSelection: function(info) {
|
1664 |
-
if (!info || !this.cm.display.view.length) return;
|
1665 |
-
if (info.focus) this.showPrimarySelection();
|
1666 |
-
this.showMultipleSelections(info);
|
1667 |
-
},
|
1668 |
-
|
1669 |
-
showPrimarySelection: function() {
|
1670 |
-
var sel = window.getSelection(), prim = this.cm.doc.sel.primary();
|
1671 |
-
var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset);
|
1672 |
-
var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset);
|
1673 |
-
if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
|
1674 |
-
cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
|
1675 |
-
cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
|
1676 |
-
return;
|
1677 |
-
|
1678 |
-
var start = posToDOM(this.cm, prim.from());
|
1679 |
-
var end = posToDOM(this.cm, prim.to());
|
1680 |
-
if (!start && !end) return;
|
1681 |
-
|
1682 |
-
var view = this.cm.display.view;
|
1683 |
-
var old = sel.rangeCount && sel.getRangeAt(0);
|
1684 |
-
if (!start) {
|
1685 |
-
start = {node: view[0].measure.map[2], offset: 0};
|
1686 |
-
} else if (!end) { // FIXME dangerously hacky
|
1687 |
-
var measure = view[view.length - 1].measure;
|
1688 |
-
var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
|
1689 |
-
end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
|
1690 |
-
}
|
1691 |
-
|
1692 |
-
try { var rng = range(start.node, start.offset, end.offset, end.node); }
|
1693 |
-
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
1694 |
-
if (rng) {
|
1695 |
-
sel.removeAllRanges();
|
1696 |
-
sel.addRange(rng);
|
1697 |
-
if (old && sel.anchorNode == null) sel.addRange(old);
|
1698 |
-
else if (gecko) this.startGracePeriod();
|
1699 |
-
}
|
1700 |
-
this.rememberSelection();
|
1701 |
-
},
|
1702 |
-
|
1703 |
-
startGracePeriod: function() {
|
1704 |
-
var input = this;
|
1705 |
-
clearTimeout(this.gracePeriod);
|
1706 |
-
this.gracePeriod = setTimeout(function() {
|
1707 |
-
input.gracePeriod = false;
|
1708 |
-
if (input.selectionChanged())
|
1709 |
-
input.cm.operation(function() { input.cm.curOp.selectionChanged = true; });
|
1710 |
-
}, 20);
|
1711 |
-
},
|
1712 |
-
|
1713 |
-
showMultipleSelections: function(info) {
|
1714 |
-
removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
|
1715 |
-
removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
|
1716 |
-
},
|
1717 |
-
|
1718 |
-
rememberSelection: function() {
|
1719 |
-
var sel = window.getSelection();
|
1720 |
-
this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
|
1721 |
-
this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
|
1722 |
-
},
|
1723 |
-
|
1724 |
-
selectionInEditor: function() {
|
1725 |
-
var sel = window.getSelection();
|
1726 |
-
if (!sel.rangeCount) return false;
|
1727 |
-
var node = sel.getRangeAt(0).commonAncestorContainer;
|
1728 |
-
return contains(this.div, node);
|
1729 |
-
},
|
1730 |
-
|
1731 |
-
focus: function() {
|
1732 |
-
if (this.cm.options.readOnly != "nocursor") this.div.focus();
|
1733 |
-
},
|
1734 |
-
blur: function() { this.div.blur(); },
|
1735 |
-
getField: function() { return this.div; },
|
1736 |
-
|
1737 |
-
supportsTouch: function() { return true; },
|
1738 |
-
|
1739 |
-
receivedFocus: function() {
|
1740 |
-
var input = this;
|
1741 |
-
if (this.selectionInEditor())
|
1742 |
-
this.pollSelection();
|
1743 |
-
else
|
1744 |
-
runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; });
|
1745 |
-
|
1746 |
-
function poll() {
|
1747 |
-
if (input.cm.state.focused) {
|
1748 |
-
input.pollSelection();
|
1749 |
-
input.polling.set(input.cm.options.pollInterval, poll);
|
1750 |
-
}
|
1751 |
-
}
|
1752 |
-
this.polling.set(this.cm.options.pollInterval, poll);
|
1753 |
-
},
|
1754 |
-
|
1755 |
-
selectionChanged: function() {
|
1756 |
-
var sel = window.getSelection();
|
1757 |
-
return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
|
1758 |
-
sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset;
|
1759 |
-
},
|
1760 |
-
|
1761 |
-
pollSelection: function() {
|
1762 |
-
if (!this.composing && !this.gracePeriod && this.selectionChanged()) {
|
1763 |
-
var sel = window.getSelection(), cm = this.cm;
|
1764 |
-
this.rememberSelection();
|
1765 |
-
var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
|
1766 |
-
var head = domToPos(cm, sel.focusNode, sel.focusOffset);
|
1767 |
-
if (anchor && head) runInOp(cm, function() {
|
1768 |
-
setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
|
1769 |
-
if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
|
1770 |
-
});
|
1771 |
-
}
|
1772 |
-
},
|
1773 |
-
|
1774 |
-
pollContent: function() {
|
1775 |
-
var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
|
1776 |
-
var from = sel.from(), to = sel.to();
|
1777 |
-
if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
|
1778 |
-
|
1779 |
-
var fromIndex;
|
1780 |
-
if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
|
1781 |
-
var fromLine = lineNo(display.view[0].line);
|
1782 |
-
var fromNode = display.view[0].node;
|
1783 |
-
} else {
|
1784 |
-
var fromLine = lineNo(display.view[fromIndex].line);
|
1785 |
-
var fromNode = display.view[fromIndex - 1].node.nextSibling;
|
1786 |
-
}
|
1787 |
-
var toIndex = findViewIndex(cm, to.line);
|
1788 |
-
if (toIndex == display.view.length - 1) {
|
1789 |
-
var toLine = display.viewTo - 1;
|
1790 |
-
var toNode = display.lineDiv.lastChild;
|
1791 |
-
} else {
|
1792 |
-
var toLine = lineNo(display.view[toIndex + 1].line) - 1;
|
1793 |
-
var toNode = display.view[toIndex + 1].node.previousSibling;
|
1794 |
-
}
|
1795 |
-
|
1796 |
-
var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
|
1797 |
-
var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
|
1798 |
-
while (newText.length > 1 && oldText.length > 1) {
|
1799 |
-
if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
|
1800 |
-
else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
|
1801 |
-
else break;
|
1802 |
-
}
|
1803 |
-
|
1804 |
-
var cutFront = 0, cutEnd = 0;
|
1805 |
-
var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
|
1806 |
-
while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
|
1807 |
-
++cutFront;
|
1808 |
-
var newBot = lst(newText), oldBot = lst(oldText);
|
1809 |
-
var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
|
1810 |
-
oldBot.length - (oldText.length == 1 ? cutFront : 0));
|
1811 |
-
while (cutEnd < maxCutEnd &&
|
1812 |
-
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
|
1813 |
-
++cutEnd;
|
1814 |
-
|
1815 |
-
newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd);
|
1816 |
-
newText[0] = newText[0].slice(cutFront);
|
1817 |
-
|
1818 |
-
var chFrom = Pos(fromLine, cutFront);
|
1819 |
-
var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
|
1820 |
-
if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
|
1821 |
-
replaceRange(cm.doc, newText, chFrom, chTo, "+input");
|
1822 |
-
return true;
|
1823 |
-
}
|
1824 |
-
},
|
1825 |
-
|
1826 |
-
ensurePolled: function() {
|
1827 |
-
this.forceCompositionEnd();
|
1828 |
-
},
|
1829 |
-
reset: function() {
|
1830 |
-
this.forceCompositionEnd();
|
1831 |
-
},
|
1832 |
-
forceCompositionEnd: function() {
|
1833 |
-
if (!this.composing || this.composing.handled) return;
|
1834 |
-
this.applyComposition(this.composing);
|
1835 |
-
this.composing.handled = true;
|
1836 |
-
this.div.blur();
|
1837 |
-
this.div.focus();
|
1838 |
-
},
|
1839 |
-
applyComposition: function(composing) {
|
1840 |
-
if (isReadOnly(this.cm))
|
1841 |
-
operation(this.cm, regChange)(this.cm)
|
1842 |
-
else if (composing.data && composing.data != composing.startData)
|
1843 |
-
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
|
1844 |
-
},
|
1845 |
-
|
1846 |
-
setUneditable: function(node) {
|
1847 |
-
node.contentEditable = "false"
|
1848 |
-
},
|
1849 |
-
|
1850 |
-
onKeyPress: function(e) {
|
1851 |
-
e.preventDefault();
|
1852 |
-
if (!isReadOnly(this.cm))
|
1853 |
-
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
|
1854 |
-
},
|
1855 |
-
|
1856 |
-
readOnlyChanged: function(val) {
|
1857 |
-
this.div.contentEditable = String(val != "nocursor")
|
1858 |
-
},
|
1859 |
-
|
1860 |
-
onContextMenu: nothing,
|
1861 |
-
resetPosition: nothing,
|
1862 |
-
|
1863 |
-
needsContentAttribute: true
|
1864 |
-
}, ContentEditableInput.prototype);
|
1865 |
-
|
1866 |
-
function posToDOM(cm, pos) {
|
1867 |
-
var view = findViewForLine(cm, pos.line);
|
1868 |
-
if (!view || view.hidden) return null;
|
1869 |
-
var line = getLine(cm.doc, pos.line);
|
1870 |
-
var info = mapFromLineView(view, line, pos.line);
|
1871 |
-
|
1872 |
-
var order = getOrder(line), side = "left";
|
1873 |
-
if (order) {
|
1874 |
-
var partPos = getBidiPartAt(order, pos.ch);
|
1875 |
-
side = partPos % 2 ? "right" : "left";
|
1876 |
-
}
|
1877 |
-
var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
|
1878 |
-
result.offset = result.collapse == "right" ? result.end : result.start;
|
1879 |
-
return result;
|
1880 |
-
}
|
1881 |
-
|
1882 |
-
function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
|
1883 |
-
|
1884 |
-
function domToPos(cm, node, offset) {
|
1885 |
-
var lineNode;
|
1886 |
-
if (node == cm.display.lineDiv) {
|
1887 |
-
lineNode = cm.display.lineDiv.childNodes[offset];
|
1888 |
-
if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
|
1889 |
-
node = null; offset = 0;
|
1890 |
-
} else {
|
1891 |
-
for (lineNode = node;; lineNode = lineNode.parentNode) {
|
1892 |
-
if (!lineNode || lineNode == cm.display.lineDiv) return null;
|
1893 |
-
if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
|
1894 |
-
}
|
1895 |
-
}
|
1896 |
-
for (var i = 0; i < cm.display.view.length; i++) {
|
1897 |
-
var lineView = cm.display.view[i];
|
1898 |
-
if (lineView.node == lineNode)
|
1899 |
-
return locateNodeInLineView(lineView, node, offset);
|
1900 |
-
}
|
1901 |
-
}
|
1902 |
-
|
1903 |
-
function locateNodeInLineView(lineView, node, offset) {
|
1904 |
-
var wrapper = lineView.text.firstChild, bad = false;
|
1905 |
-
if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
|
1906 |
-
if (node == wrapper) {
|
1907 |
-
bad = true;
|
1908 |
-
node = wrapper.childNodes[offset];
|
1909 |
-
offset = 0;
|
1910 |
-
if (!node) {
|
1911 |
-
var line = lineView.rest ? lst(lineView.rest) : lineView.line;
|
1912 |
-
return badPos(Pos(lineNo(line), line.text.length), bad);
|
1913 |
-
}
|
1914 |
-
}
|
1915 |
-
|
1916 |
-
var textNode = node.nodeType == 3 ? node : null, topNode = node;
|
1917 |
-
if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
|
1918 |
-
textNode = node.firstChild;
|
1919 |
-
if (offset) offset = textNode.nodeValue.length;
|
1920 |
-
}
|
1921 |
-
while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
|
1922 |
-
var measure = lineView.measure, maps = measure.maps;
|
1923 |
-
|
1924 |
-
function find(textNode, topNode, offset) {
|
1925 |
-
for (var i = -1; i < (maps ? maps.length : 0); i++) {
|
1926 |
-
var map = i < 0 ? measure.map : maps[i];
|
1927 |
-
for (var j = 0; j < map.length; j += 3) {
|
1928 |
-
var curNode = map[j + 2];
|
1929 |
-
if (curNode == textNode || curNode == topNode) {
|
1930 |
-
var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
|
1931 |
-
var ch = map[j] + offset;
|
1932 |
-
if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
|
1933 |
-
return Pos(line, ch);
|
1934 |
-
}
|
1935 |
-
}
|
1936 |
-
}
|
1937 |
-
}
|
1938 |
-
var found = find(textNode, topNode, offset);
|
1939 |
-
if (found) return badPos(found, bad);
|
1940 |
-
|
1941 |
-
// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
|
1942 |
-
for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
|
1943 |
-
found = find(after, after.firstChild, 0);
|
1944 |
-
if (found)
|
1945 |
-
return badPos(Pos(found.line, found.ch - dist), bad);
|
1946 |
-
else
|
1947 |
-
dist += after.textContent.length;
|
1948 |
-
}
|
1949 |
-
for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
|
1950 |
-
found = find(before, before.firstChild, -1);
|
1951 |
-
if (found)
|
1952 |
-
return badPos(Pos(found.line, found.ch + dist), bad);
|
1953 |
-
else
|
1954 |
-
dist += after.textContent.length;
|
1955 |
-
}
|
1956 |
-
}
|
1957 |
-
|
1958 |
-
function domTextBetween(cm, from, to, fromLine, toLine) {
|
1959 |
-
var text = "", closing = false, lineSep = cm.doc.lineSeparator();
|
1960 |
-
function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
|
1961 |
-
function walk(node) {
|
1962 |
-
if (node.nodeType == 1) {
|
1963 |
-
var cmText = node.getAttribute("cm-text");
|
1964 |
-
if (cmText != null) {
|
1965 |
-
if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
|
1966 |
-
text += cmText;
|
1967 |
-
return;
|
1968 |
-
}
|
1969 |
-
var markerID = node.getAttribute("cm-marker"), range;
|
1970 |
-
if (markerID) {
|
1971 |
-
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
|
1972 |
-
if (found.length && (range = found[0].find()))
|
1973 |
-
text += getBetween(cm.doc, range.from, range.to).join(lineSep);
|
1974 |
-
return;
|
1975 |
-
}
|
1976 |
-
if (node.getAttribute("contenteditable") == "false") return;
|
1977 |
-
for (var i = 0; i < node.childNodes.length; i++)
|
1978 |
-
walk(node.childNodes[i]);
|
1979 |
-
if (/^(pre|div|p)$/i.test(node.nodeName))
|
1980 |
-
closing = true;
|
1981 |
-
} else if (node.nodeType == 3) {
|
1982 |
-
var val = node.nodeValue;
|
1983 |
-
if (!val) return;
|
1984 |
-
if (closing) {
|
1985 |
-
text += lineSep;
|
1986 |
-
closing = false;
|
1987 |
-
}
|
1988 |
-
text += val;
|
1989 |
-
}
|
1990 |
-
}
|
1991 |
-
for (;;) {
|
1992 |
-
walk(from);
|
1993 |
-
if (from == to) break;
|
1994 |
-
from = from.nextSibling;
|
1995 |
-
}
|
1996 |
-
return text;
|
1997 |
-
}
|
1998 |
-
|
1999 |
-
CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
|
2000 |
-
|
2001 |
-
// SELECTION / CURSOR
|
2002 |
-
|
2003 |
-
// Selection objects are immutable. A new one is created every time
|
2004 |
-
// the selection changes. A selection is one or more non-overlapping
|
2005 |
-
// (and non-touching) ranges, sorted, and an integer that indicates
|
2006 |
-
// which one is the primary selection (the one that's scrolled into
|
2007 |
-
// view, that getCursor returns, etc).
|
2008 |
-
function Selection(ranges, primIndex) {
|
2009 |
-
this.ranges = ranges;
|
2010 |
-
this.primIndex = primIndex;
|
2011 |
-
}
|
2012 |
-
|
2013 |
-
Selection.prototype = {
|
2014 |
-
primary: function() { return this.ranges[this.primIndex]; },
|
2015 |
-
equals: function(other) {
|
2016 |
-
if (other == this) return true;
|
2017 |
-
if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
|
2018 |
-
for (var i = 0; i < this.ranges.length; i++) {
|
2019 |
-
var here = this.ranges[i], there = other.ranges[i];
|
2020 |
-
if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
|
2021 |
-
}
|
2022 |
-
return true;
|
2023 |
-
},
|
2024 |
-
deepCopy: function() {
|
2025 |
-
for (var out = [], i = 0; i < this.ranges.length; i++)
|
2026 |
-
out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
|
2027 |
-
return new Selection(out, this.primIndex);
|
2028 |
-
},
|
2029 |
-
somethingSelected: function() {
|
2030 |
-
for (var i = 0; i < this.ranges.length; i++)
|
2031 |
-
if (!this.ranges[i].empty()) return true;
|
2032 |
-
return false;
|
2033 |
-
},
|
2034 |
-
contains: function(pos, end) {
|
2035 |
-
if (!end) end = pos;
|
2036 |
-
for (var i = 0; i < this.ranges.length; i++) {
|
2037 |
-
var range = this.ranges[i];
|
2038 |
-
if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
|
2039 |
-
return i;
|
2040 |
-
}
|
2041 |
-
return -1;
|
2042 |
-
}
|
2043 |
-
};
|
2044 |
-
|
2045 |
-
function Range(anchor, head) {
|
2046 |
-
this.anchor = anchor; this.head = head;
|
2047 |
-
}
|
2048 |
-
|
2049 |
-
Range.prototype = {
|
2050 |
-
from: function() { return minPos(this.anchor, this.head); },
|
2051 |
-
to: function() { return maxPos(this.anchor, this.head); },
|
2052 |
-
empty: function() {
|
2053 |
-
return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
|
2054 |
-
}
|
2055 |
-
};
|
2056 |
-
|
2057 |
-
// Take an unsorted, potentially overlapping set of ranges, and
|
2058 |
-
// build a selection out of it. 'Consumes' ranges array (modifying
|
2059 |
-
// it).
|
2060 |
-
function normalizeSelection(ranges, primIndex) {
|
2061 |
-
var prim = ranges[primIndex];
|
2062 |
-
ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
|
2063 |
-
primIndex = indexOf(ranges, prim);
|
2064 |
-
for (var i = 1; i < ranges.length; i++) {
|
2065 |
-
var cur = ranges[i], prev = ranges[i - 1];
|
2066 |
-
if (cmp(prev.to(), cur.from()) >= 0) {
|
2067 |
-
var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
|
2068 |
-
var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
|
2069 |
-
if (i <= primIndex) --primIndex;
|
2070 |
-
ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
|
2071 |
-
}
|
2072 |
-
}
|
2073 |
-
return new Selection(ranges, primIndex);
|
2074 |
-
}
|
2075 |
-
|
2076 |
-
function simpleSelection(anchor, head) {
|
2077 |
-
return new Selection([new Range(anchor, head || anchor)], 0);
|
2078 |
-
}
|
2079 |
-
|
2080 |
-
// Most of the external API clips given positions to make sure they
|
2081 |
-
// actually exist within the document.
|
2082 |
-
function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
|
2083 |
-
function clipPos(doc, pos) {
|
2084 |
-
if (pos.line < doc.first) return Pos(doc.first, 0);
|
2085 |
-
var last = doc.first + doc.size - 1;
|
2086 |
-
if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
|
2087 |
-
return clipToLen(pos, getLine(doc, pos.line).text.length);
|
2088 |
-
}
|
2089 |
-
function clipToLen(pos, linelen) {
|
2090 |
-
var ch = pos.ch;
|
2091 |
-
if (ch == null || ch > linelen) return Pos(pos.line, linelen);
|
2092 |
-
else if (ch < 0) return Pos(pos.line, 0);
|
2093 |
-
else return pos;
|
2094 |
-
}
|
2095 |
-
function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
|
2096 |
-
function clipPosArray(doc, array) {
|
2097 |
-
for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
|
2098 |
-
return out;
|
2099 |
-
}
|
2100 |
-
|
2101 |
-
// SELECTION UPDATES
|
2102 |
-
|
2103 |
-
// The 'scroll' parameter given to many of these indicated whether
|
2104 |
-
// the new cursor position should be scrolled into view after
|
2105 |
-
// modifying the selection.
|
2106 |
-
|
2107 |
-
// If shift is held or the extend flag is set, extends a range to
|
2108 |
-
// include a given position (and optionally a second position).
|
2109 |
-
// Otherwise, simply returns the range between the given positions.
|
2110 |
-
// Used for cursor motion and such.
|
2111 |
-
function extendRange(doc, range, head, other) {
|
2112 |
-
if (doc.cm && doc.cm.display.shift || doc.extend) {
|
2113 |
-
var anchor = range.anchor;
|
2114 |
-
if (other) {
|
2115 |
-
var posBefore = cmp(head, anchor) < 0;
|
2116 |
-
if (posBefore != (cmp(other, anchor) < 0)) {
|
2117 |
-
anchor = head;
|
2118 |
-
head = other;
|
2119 |
-
} else if (posBefore != (cmp(head, other) < 0)) {
|
2120 |
-
head = other;
|
2121 |
-
}
|
2122 |
-
}
|
2123 |
-
return new Range(anchor, head);
|
2124 |
-
} else {
|
2125 |
-
return new Range(other || head, head);
|
2126 |
-
}
|
2127 |
-
}
|
2128 |
-
|
2129 |
-
// Extend the primary selection range, discard the rest.
|
2130 |
-
function extendSelection(doc, head, other, options) {
|
2131 |
-
setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
|
2132 |
-
}
|
2133 |
-
|
2134 |
-
// Extend all selections (pos is an array of selections with length
|
2135 |
-
// equal the number of selections)
|
2136 |
-
function extendSelections(doc, heads, options) {
|
2137 |
-
for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
|
2138 |
-
out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
|
2139 |
-
var newSel = normalizeSelection(out, doc.sel.primIndex);
|
2140 |
-
setSelection(doc, newSel, options);
|
2141 |
-
}
|
2142 |
-
|
2143 |
-
// Updates a single range in the selection.
|
2144 |
-
function replaceOneSelection(doc, i, range, options) {
|
2145 |
-
var ranges = doc.sel.ranges.slice(0);
|
2146 |
-
ranges[i] = range;
|
2147 |
-
setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
|
2148 |
-
}
|
2149 |
-
|
2150 |
-
// Reset the selection to a single range.
|
2151 |
-
function setSimpleSelection(doc, anchor, head, options) {
|
2152 |
-
setSelection(doc, simpleSelection(anchor, head), options);
|
2153 |
-
}
|
2154 |
-
|
2155 |
-
// Give beforeSelectionChange handlers a change to influence a
|
2156 |
-
// selection update.
|
2157 |
-
function filterSelectionChange(doc, sel) {
|
2158 |
-
var obj = {
|
2159 |
-
ranges: sel.ranges,
|
2160 |
-
update: function(ranges) {
|
2161 |
-
this.ranges = [];
|
2162 |
-
for (var i = 0; i < ranges.length; i++)
|
2163 |
-
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
2164 |
-
clipPos(doc, ranges[i].head));
|
2165 |
-
}
|
2166 |
-
};
|
2167 |
-
signal(doc, "beforeSelectionChange", doc, obj);
|
2168 |
-
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
|
2169 |
-
if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
|
2170 |
-
else return sel;
|
2171 |
-
}
|
2172 |
-
|
2173 |
-
function setSelectionReplaceHistory(doc, sel, options) {
|
2174 |
-
var done = doc.history.done, last = lst(done);
|
2175 |
-
if (last && last.ranges) {
|
2176 |
-
done[done.length - 1] = sel;
|
2177 |
-
setSelectionNoUndo(doc, sel, options);
|
2178 |
-
} else {
|
2179 |
-
setSelection(doc, sel, options);
|
2180 |
-
}
|
2181 |
-
}
|
2182 |
-
|
2183 |
-
// Set a new selection.
|
2184 |
-
function setSelection(doc, sel, options) {
|
2185 |
-
setSelectionNoUndo(doc, sel, options);
|
2186 |
-
addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
|
2187 |
-
}
|
2188 |
-
|
2189 |
-
function setSelectionNoUndo(doc, sel, options) {
|
2190 |
-
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
2191 |
-
sel = filterSelectionChange(doc, sel);
|
2192 |
-
|
2193 |
-
var bias = options && options.bias ||
|
2194 |
-
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
2195 |
-
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
|
2196 |
-
|
2197 |
-
if (!(options && options.scroll === false) && doc.cm)
|
2198 |
-
ensureCursorVisible(doc.cm);
|
2199 |
-
}
|
2200 |
-
|
2201 |
-
function setSelectionInner(doc, sel) {
|
2202 |
-
if (sel.equals(doc.sel)) return;
|
2203 |
-
|
2204 |
-
doc.sel = sel;
|
2205 |
-
|
2206 |
-
if (doc.cm) {
|
2207 |
-
doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
|
2208 |
-
signalCursorActivity(doc.cm);
|
2209 |
-
}
|
2210 |
-
signalLater(doc, "cursorActivity", doc);
|
2211 |
-
}
|
2212 |
-
|
2213 |
-
// Verify that the selection does not partially select any atomic
|
2214 |
-
// marked ranges.
|
2215 |
-
function reCheckSelection(doc) {
|
2216 |
-
setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
|
2217 |
-
}
|
2218 |
-
|
2219 |
-
// Return a selection that does not partially select any atomic
|
2220 |
-
// ranges.
|
2221 |
-
function skipAtomicInSelection(doc, sel, bias, mayClear) {
|
2222 |
-
var out;
|
2223 |
-
for (var i = 0; i < sel.ranges.length; i++) {
|
2224 |
-
var range = sel.ranges[i];
|
2225 |
-
var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
|
2226 |
-
var newHead = skipAtomic(doc, range.head, bias, mayClear);
|
2227 |
-
if (out || newAnchor != range.anchor || newHead != range.head) {
|
2228 |
-
if (!out) out = sel.ranges.slice(0, i);
|
2229 |
-
out[i] = new Range(newAnchor, newHead);
|
2230 |
-
}
|
2231 |
-
}
|
2232 |
-
return out ? normalizeSelection(out, sel.primIndex) : sel;
|
2233 |
-
}
|
2234 |
-
|
2235 |
-
// Ensure a given position is not inside an atomic range.
|
2236 |
-
function skipAtomic(doc, pos, bias, mayClear) {
|
2237 |
-
var flipped = false, curPos = pos;
|
2238 |
-
var dir = bias || 1;
|
2239 |
-
doc.cantEdit = false;
|
2240 |
-
search: for (;;) {
|
2241 |
-
var line = getLine(doc, curPos.line);
|
2242 |
-
if (line.markedSpans) {
|
2243 |
-
for (var i = 0; i < line.markedSpans.length; ++i) {
|
2244 |
-
var sp = line.markedSpans[i], m = sp.marker;
|
2245 |
-
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
|
2246 |
-
(sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
|
2247 |
-
if (mayClear) {
|
2248 |
-
signal(m, "beforeCursorEnter");
|
2249 |
-
if (m.explicitlyCleared) {
|
2250 |
-
if (!line.markedSpans) break;
|
2251 |
-
else {--i; continue;}
|
2252 |
-
}
|
2253 |
-
}
|
2254 |
-
if (!m.atomic) continue;
|
2255 |
-
var newPos = m.find(dir < 0 ? -1 : 1);
|
2256 |
-
if (cmp(newPos, curPos) == 0) {
|
2257 |
-
newPos.ch += dir;
|
2258 |
-
if (newPos.ch < 0) {
|
2259 |
-
if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
|
2260 |
-
else newPos = null;
|
2261 |
-
} else if (newPos.ch > line.text.length) {
|
2262 |
-
if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
|
2263 |
-
else newPos = null;
|
2264 |
-
}
|
2265 |
-
if (!newPos) {
|
2266 |
-
if (flipped) {
|
2267 |
-
// Driven in a corner -- no valid cursor position found at all
|
2268 |
-
// -- try again *with* clearing, if we didn't already
|
2269 |
-
if (!mayClear) return skipAtomic(doc, pos, bias, true);
|
2270 |
-
// Otherwise, turn off editing until further notice, and return the start of the doc
|
2271 |
-
doc.cantEdit = true;
|
2272 |
-
return Pos(doc.first, 0);
|
2273 |
-
}
|
2274 |
-
flipped = true; newPos = pos; dir = -dir;
|
2275 |
-
}
|
2276 |
-
}
|
2277 |
-
curPos = newPos;
|
2278 |
-
continue search;
|
2279 |
-
}
|
2280 |
-
}
|
2281 |
-
}
|
2282 |
-
return curPos;
|
2283 |
-
}
|
2284 |
-
}
|
2285 |
-
|
2286 |
-
// SELECTION DRAWING
|
2287 |
-
|
2288 |
-
function updateSelection(cm) {
|
2289 |
-
cm.display.input.showSelection(cm.display.input.prepareSelection());
|
2290 |
-
}
|
2291 |
-
|
2292 |
-
function prepareSelection(cm, primary) {
|
2293 |
-
var doc = cm.doc, result = {};
|
2294 |
-
var curFragment = result.cursors = document.createDocumentFragment();
|
2295 |
-
var selFragment = result.selection = document.createDocumentFragment();
|
2296 |
-
|
2297 |
-
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
2298 |
-
if (primary === false && i == doc.sel.primIndex) continue;
|
2299 |
-
var range = doc.sel.ranges[i];
|
2300 |
-
var collapsed = range.empty();
|
2301 |
-
if (collapsed || cm.options.showCursorWhenSelecting)
|
2302 |
-
drawSelectionCursor(cm, range.head, curFragment);
|
2303 |
-
if (!collapsed)
|
2304 |
-
drawSelectionRange(cm, range, selFragment);
|
2305 |
-
}
|
2306 |
-
return result;
|
2307 |
-
}
|
2308 |
-
|
2309 |
-
// Draws a cursor for the given range
|
2310 |
-
function drawSelectionCursor(cm, head, output) {
|
2311 |
-
var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
|
2312 |
-
|
2313 |
-
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
|
2314 |
-
cursor.style.left = pos.left + "px";
|
2315 |
-
cursor.style.top = pos.top + "px";
|
2316 |
-
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
|
2317 |
-
|
2318 |
-
if (pos.other) {
|
2319 |
-
// Secondary cursor, shown when on a 'jump' in bi-directional text
|
2320 |
-
var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
|
2321 |
-
otherCursor.style.display = "";
|
2322 |
-
otherCursor.style.left = pos.other.left + "px";
|
2323 |
-
otherCursor.style.top = pos.other.top + "px";
|
2324 |
-
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
|
2325 |
-
}
|
2326 |
-
}
|
2327 |
-
|
2328 |
-
// Draws the given range as a highlighted selection
|
2329 |
-
function drawSelectionRange(cm, range, output) {
|
2330 |
-
var display = cm.display, doc = cm.doc;
|
2331 |
-
var fragment = document.createDocumentFragment();
|
2332 |
-
var padding = paddingH(cm.display), leftSide = padding.left;
|
2333 |
-
var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
|
2334 |
-
|
2335 |
-
function add(left, top, width, bottom) {
|
2336 |
-
if (top < 0) top = 0;
|
2337 |
-
top = Math.round(top);
|
2338 |
-
bottom = Math.round(bottom);
|
2339 |
-
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
|
2340 |
-
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
|
2341 |
-
"px; height: " + (bottom - top) + "px"));
|
2342 |
-
}
|
2343 |
-
|
2344 |
-
function drawForLine(line, fromArg, toArg) {
|
2345 |
-
var lineObj = getLine(doc, line);
|
2346 |
-
var lineLen = lineObj.text.length;
|
2347 |
-
var start, end;
|
2348 |
-
function coords(ch, bias) {
|
2349 |
-
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
|
2350 |
-
}
|
2351 |
-
|
2352 |
-
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
|
2353 |
-
var leftPos = coords(from, "left"), rightPos, left, right;
|
2354 |
-
if (from == to) {
|
2355 |
-
rightPos = leftPos;
|
2356 |
-
left = right = leftPos.left;
|
2357 |
-
} else {
|
2358 |
-
rightPos = coords(to - 1, "right");
|
2359 |
-
if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
|
2360 |
-
left = leftPos.left;
|
2361 |
-
right = rightPos.right;
|
2362 |
-
}
|
2363 |
-
if (fromArg == null && from == 0) left = leftSide;
|
2364 |
-
if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
|
2365 |
-
add(left, leftPos.top, null, leftPos.bottom);
|
2366 |
-
left = leftSide;
|
2367 |
-
if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
|
2368 |
-
}
|
2369 |
-
if (toArg == null && to == lineLen) right = rightSide;
|
2370 |
-
if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
|
2371 |
-
start = leftPos;
|
2372 |
-
if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
|
2373 |
-
end = rightPos;
|
2374 |
-
if (left < leftSide + 1) left = leftSide;
|
2375 |
-
add(left, rightPos.top, right - left, rightPos.bottom);
|
2376 |
-
});
|
2377 |
-
return {start: start, end: end};
|
2378 |
-
}
|
2379 |
-
|
2380 |
-
var sFrom = range.from(), sTo = range.to();
|
2381 |
-
if (sFrom.line == sTo.line) {
|
2382 |
-
drawForLine(sFrom.line, sFrom.ch, sTo.ch);
|
2383 |
-
} else {
|
2384 |
-
var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
|
2385 |
-
var singleVLine = visualLine(fromLine) == visualLine(toLine);
|
2386 |
-
var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
|
2387 |
-
var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
|
2388 |
-
if (singleVLine) {
|
2389 |
-
if (leftEnd.top < rightStart.top - 2) {
|
2390 |
-
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
|
2391 |
-
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
|
2392 |
-
} else {
|
2393 |
-
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
|
2394 |
-
}
|
2395 |
-
}
|
2396 |
-
if (leftEnd.bottom < rightStart.top)
|
2397 |
-
add(leftSide, leftEnd.bottom, null, rightStart.top);
|
2398 |
-
}
|
2399 |
-
|
2400 |
-
output.appendChild(fragment);
|
2401 |
-
}
|
2402 |
-
|
2403 |
-
// Cursor-blinking
|
2404 |
-
function restartBlink(cm) {
|
2405 |
-
if (!cm.state.focused) return;
|
2406 |
-
var display = cm.display;
|
2407 |
-
clearInterval(display.blinker);
|
2408 |
-
var on = true;
|
2409 |
-
display.cursorDiv.style.visibility = "";
|
2410 |
-
if (cm.options.cursorBlinkRate > 0)
|
2411 |
-
display.blinker = setInterval(function() {
|
2412 |
-
display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
|
2413 |
-
}, cm.options.cursorBlinkRate);
|
2414 |
-
else if (cm.options.cursorBlinkRate < 0)
|
2415 |
-
display.cursorDiv.style.visibility = "hidden";
|
2416 |
-
}
|
2417 |
-
|
2418 |
-
// HIGHLIGHT WORKER
|
2419 |
-
|
2420 |
-
function startWorker(cm, time) {
|
2421 |
-
if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
|
2422 |
-
cm.state.highlight.set(time, bind(highlightWorker, cm));
|
2423 |
-
}
|
2424 |
-
|
2425 |
-
function highlightWorker(cm) {
|
2426 |
-
var doc = cm.doc;
|
2427 |
-
if (doc.frontier < doc.first) doc.frontier = doc.first;
|
2428 |
-
if (doc.frontier >= cm.display.viewTo) return;
|
2429 |
-
var end = +new Date + cm.options.workTime;
|
2430 |
-
var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
|
2431 |
-
var changedLines = [];
|
2432 |
-
|
2433 |
-
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
|
2434 |
-
if (doc.frontier >= cm.display.viewFrom) { // Visible
|
2435 |
-
var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
|
2436 |
-
var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
|
2437 |
-
line.styles = highlighted.styles;
|
2438 |
-
var oldCls = line.styleClasses, newCls = highlighted.classes;
|
2439 |
-
if (newCls) line.styleClasses = newCls;
|
2440 |
-
else if (oldCls) line.styleClasses = null;
|
2441 |
-
var ischange = !oldStyles || oldStyles.length != line.styles.length ||
|
2442 |
-
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
|
2443 |
-
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
|
2444 |
-
if (ischange) changedLines.push(doc.frontier);
|
2445 |
-
line.stateAfter = tooLong ? state : copyState(doc.mode, state);
|
2446 |
-
} else {
|
2447 |
-
if (line.text.length <= cm.options.maxHighlightLength)
|
2448 |
-
processLine(cm, line.text, state);
|
2449 |
-
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
|
2450 |
-
}
|
2451 |
-
++doc.frontier;
|
2452 |
-
if (+new Date > end) {
|
2453 |
-
startWorker(cm, cm.options.workDelay);
|
2454 |
-
return true;
|
2455 |
-
}
|
2456 |
-
});
|
2457 |
-
if (changedLines.length) runInOp(cm, function() {
|
2458 |
-
for (var i = 0; i < changedLines.length; i++)
|
2459 |
-
regLineChange(cm, changedLines[i], "text");
|
2460 |
-
});
|
2461 |
-
}
|
2462 |
-
|
2463 |
-
// Finds the line to start with when starting a parse. Tries to
|
2464 |
-
// find a line with a stateAfter, so that it can start with a
|
2465 |
-
// valid state. If that fails, it returns the line with the
|
2466 |
-
// smallest indentation, which tends to need the least context to
|
2467 |
-
// parse correctly.
|
2468 |
-
function findStartLine(cm, n, precise) {
|
2469 |
-
var minindent, minline, doc = cm.doc;
|
2470 |
-
var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
|
2471 |
-
for (var search = n; search > lim; --search) {
|
2472 |
-
if (search <= doc.first) return doc.first;
|
2473 |
-
var line = getLine(doc, search - 1);
|
2474 |
-
if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
|
2475 |
-
var indented = countColumn(line.text, null, cm.options.tabSize);
|
2476 |
-
if (minline == null || minindent > indented) {
|
2477 |
-
minline = search - 1;
|
2478 |
-
minindent = indented;
|
2479 |
-
}
|
2480 |
-
}
|
2481 |
-
return minline;
|
2482 |
-
}
|
2483 |
-
|
2484 |
-
function getStateBefore(cm, n, precise) {
|
2485 |
-
var doc = cm.doc, display = cm.display;
|
2486 |
-
if (!doc.mode.startState) return true;
|
2487 |
-
var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
|
2488 |
-
if (!state) state = startState(doc.mode);
|
2489 |
-
else state = copyState(doc.mode, state);
|
2490 |
-
doc.iter(pos, n, function(line) {
|
2491 |
-
processLine(cm, line.text, state);
|
2492 |
-
var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
|
2493 |
-
line.stateAfter = save ? copyState(doc.mode, state) : null;
|
2494 |
-
++pos;
|
2495 |
-
});
|
2496 |
-
if (precise) doc.frontier = pos;
|
2497 |
-
return state;
|
2498 |
-
}
|
2499 |
-
|
2500 |
-
// POSITION MEASUREMENT
|
2501 |
-
|
2502 |
-
function paddingTop(display) {return display.lineSpace.offsetTop;}
|
2503 |
-
function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
|
2504 |
-
function paddingH(display) {
|
2505 |
-
if (display.cachedPaddingH) return display.cachedPaddingH;
|
2506 |
-
var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
|
2507 |
-
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
|
2508 |
-
var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
|
2509 |
-
if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
|
2510 |
-
return data;
|
2511 |
-
}
|
2512 |
-
|
2513 |
-
function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
|
2514 |
-
function displayWidth(cm) {
|
2515 |
-
return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
|
2516 |
-
}
|
2517 |
-
function displayHeight(cm) {
|
2518 |
-
return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
|
2519 |
-
}
|
2520 |
-
|
2521 |
-
// Ensure the lineView.wrapping.heights array is populated. This is
|
2522 |
-
// an array of bottom offsets for the lines that make up a drawn
|
2523 |
-
// line. When lineWrapping is on, there might be more than one
|
2524 |
-
// height.
|
2525 |
-
function ensureLineHeights(cm, lineView, rect) {
|
2526 |
-
var wrapping = cm.options.lineWrapping;
|
2527 |
-
var curWidth = wrapping && displayWidth(cm);
|
2528 |
-
if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
|
2529 |
-
var heights = lineView.measure.heights = [];
|
2530 |
-
if (wrapping) {
|
2531 |
-
lineView.measure.width = curWidth;
|
2532 |
-
var rects = lineView.text.firstChild.getClientRects();
|
2533 |
-
for (var i = 0; i < rects.length - 1; i++) {
|
2534 |
-
var cur = rects[i], next = rects[i + 1];
|
2535 |
-
if (Math.abs(cur.bottom - next.bottom) > 2)
|
2536 |
-
heights.push((cur.bottom + next.top) / 2 - rect.top);
|
2537 |
-
}
|
2538 |
-
}
|
2539 |
-
heights.push(rect.bottom - rect.top);
|
2540 |
-
}
|
2541 |
-
}
|
2542 |
-
|
2543 |
-
// Find a line map (mapping character offsets to text nodes) and a
|
2544 |
-
// measurement cache for the given line number. (A line view might
|
2545 |
-
// contain multiple lines when collapsed ranges are present.)
|
2546 |
-
function mapFromLineView(lineView, line, lineN) {
|
2547 |
-
if (lineView.line == line)
|
2548 |
-
return {map: lineView.measure.map, cache: lineView.measure.cache};
|
2549 |
-
for (var i = 0; i < lineView.rest.length; i++)
|
2550 |
-
if (lineView.rest[i] == line)
|
2551 |
-
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
|
2552 |
-
for (var i = 0; i < lineView.rest.length; i++)
|
2553 |
-
if (lineNo(lineView.rest[i]) > lineN)
|
2554 |
-
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
|
2555 |
-
}
|
2556 |
-
|
2557 |
-
// Render a line into the hidden node display.externalMeasured. Used
|
2558 |
-
// when measurement is needed for a line that's not in the viewport.
|
2559 |
-
function updateExternalMeasurement(cm, line) {
|
2560 |
-
line = visualLine(line);
|
2561 |
-
var lineN = lineNo(line);
|
2562 |
-
var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
|
2563 |
-
view.lineN = lineN;
|
2564 |
-
var built = view.built = buildLineContent(cm, view);
|
2565 |
-
view.text = built.pre;
|
2566 |
-
removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
|
2567 |
-
return view;
|
2568 |
-
}
|
2569 |
-
|
2570 |
-
// Get a {top, bottom, left, right} box (in line-local coordinates)
|
2571 |
-
// for a given character.
|
2572 |
-
function measureChar(cm, line, ch, bias) {
|
2573 |
-
return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
|
2574 |
-
}
|
2575 |
-
|
2576 |
-
// Find a line view that corresponds to the given line number.
|
2577 |
-
function findViewForLine(cm, lineN) {
|
2578 |
-
if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
|
2579 |
-
return cm.display.view[findViewIndex(cm, lineN)];
|
2580 |
-
var ext = cm.display.externalMeasured;
|
2581 |
-
if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
|
2582 |
-
return ext;
|
2583 |
-
}
|
2584 |
-
|
2585 |
-
// Measurement can be split in two steps, the set-up work that
|
2586 |
-
// applies to the whole line, and the measurement of the actual
|
2587 |
-
// character. Functions like coordsChar, that need to do a lot of
|
2588 |
-
// measurements in a row, can thus ensure that the set-up work is
|
2589 |
-
// only done once.
|
2590 |
-
function prepareMeasureForLine(cm, line) {
|
2591 |
-
var lineN = lineNo(line);
|
2592 |
-
var view = findViewForLine(cm, lineN);
|
2593 |
-
if (view && !view.text) {
|
2594 |
-
view = null;
|
2595 |
-
} else if (view && view.changes) {
|
2596 |
-
updateLineForChanges(cm, view, lineN, getDimensions(cm));
|
2597 |
-
cm.curOp.forceUpdate = true;
|
2598 |
-
}
|
2599 |
-
if (!view)
|
2600 |
-
view = updateExternalMeasurement(cm, line);
|
2601 |
-
|
2602 |
-
var info = mapFromLineView(view, line, lineN);
|
2603 |
-
return {
|
2604 |
-
line: line, view: view, rect: null,
|
2605 |
-
map: info.map, cache: info.cache, before: info.before,
|
2606 |
-
hasHeights: false
|
2607 |
-
};
|
2608 |
-
}
|
2609 |
-
|
2610 |
-
// Given a prepared measurement object, measures the position of an
|
2611 |
-
// actual character (or fetches it from the cache).
|
2612 |
-
function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
|
2613 |
-
if (prepared.before) ch = -1;
|
2614 |
-
var key = ch + (bias || ""), found;
|
2615 |
-
if (prepared.cache.hasOwnProperty(key)) {
|
2616 |
-
found = prepared.cache[key];
|
2617 |
-
} else {
|
2618 |
-
if (!prepared.rect)
|
2619 |
-
prepared.rect = prepared.view.text.getBoundingClientRect();
|
2620 |
-
if (!prepared.hasHeights) {
|
2621 |
-
ensureLineHeights(cm, prepared.view, prepared.rect);
|
2622 |
-
prepared.hasHeights = true;
|
2623 |
-
}
|
2624 |
-
found = measureCharInner(cm, prepared, ch, bias);
|
2625 |
-
if (!found.bogus) prepared.cache[key] = found;
|
2626 |
-
}
|
2627 |
-
return {left: found.left, right: found.right,
|
2628 |
-
top: varHeight ? found.rtop : found.top,
|
2629 |
-
bottom: varHeight ? found.rbottom : found.bottom};
|
2630 |
-
}
|
2631 |
-
|
2632 |
-
var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
|
2633 |
-
|
2634 |
-
function nodeAndOffsetInLineMap(map, ch, bias) {
|
2635 |
-
var node, start, end, collapse;
|
2636 |
-
// First, search the line map for the text node corresponding to,
|
2637 |
-
// or closest to, the target character.
|
2638 |
-
for (var i = 0; i < map.length; i += 3) {
|
2639 |
-
var mStart = map[i], mEnd = map[i + 1];
|
2640 |
-
if (ch < mStart) {
|
2641 |
-
start = 0; end = 1;
|
2642 |
-
collapse = "left";
|
2643 |
-
} else if (ch < mEnd) {
|
2644 |
-
start = ch - mStart;
|
2645 |
-
end = start + 1;
|
2646 |
-
} else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
|
2647 |
-
end = mEnd - mStart;
|
2648 |
-
start = end - 1;
|
2649 |
-
if (ch >= mEnd) collapse = "right";
|
2650 |
-
}
|
2651 |
-
if (start != null) {
|
2652 |
-
node = map[i + 2];
|
2653 |
-
if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
|
2654 |
-
collapse = bias;
|
2655 |
-
if (bias == "left" && start == 0)
|
2656 |
-
while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
|
2657 |
-
node = map[(i -= 3) + 2];
|
2658 |
-
collapse = "left";
|
2659 |
-
}
|
2660 |
-
if (bias == "right" && start == mEnd - mStart)
|
2661 |
-
while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
|
2662 |
-
node = map[(i += 3) + 2];
|
2663 |
-
collapse = "right";
|
2664 |
-
}
|
2665 |
-
break;
|
2666 |
-
}
|
2667 |
-
}
|
2668 |
-
return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
|
2669 |
-
}
|
2670 |
-
|
2671 |
-
function measureCharInner(cm, prepared, ch, bias) {
|
2672 |
-
var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
|
2673 |
-
var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
|
2674 |
-
|
2675 |
-
var rect;
|
2676 |
-
if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
|
2677 |
-
for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
|
2678 |
-
while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
|
2679 |
-
while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
|
2680 |
-
if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
|
2681 |
-
rect = node.parentNode.getBoundingClientRect();
|
2682 |
-
} else if (ie && cm.options.lineWrapping) {
|
2683 |
-
var rects = range(node, start, end).getClientRects();
|
2684 |
-
if (rects.length)
|
2685 |
-
rect = rects[bias == "right" ? rects.length - 1 : 0];
|
2686 |
-
else
|
2687 |
-
rect = nullRect;
|
2688 |
-
} else {
|
2689 |
-
rect = range(node, start, end).getBoundingClientRect() || nullRect;
|
2690 |
-
}
|
2691 |
-
if (rect.left || rect.right || start == 0) break;
|
2692 |
-
end = start;
|
2693 |
-
start = start - 1;
|
2694 |
-
collapse = "right";
|
2695 |
-
}
|
2696 |
-
if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
|
2697 |
-
} else { // If it is a widget, simply get the box for the whole widget.
|
2698 |
-
if (start > 0) collapse = bias = "right";
|
2699 |
-
var rects;
|
2700 |
-
if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
|
2701 |
-
rect = rects[bias == "right" ? rects.length - 1 : 0];
|
2702 |
-
else
|
2703 |
-
rect = node.getBoundingClientRect();
|
2704 |
-
}
|
2705 |
-
if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
|
2706 |
-
var rSpan = node.parentNode.getClientRects()[0];
|
2707 |
-
if (rSpan)
|
2708 |
-
rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
|
2709 |
-
else
|
2710 |
-
rect = nullRect;
|
2711 |
-
}
|
2712 |
-
|
2713 |
-
var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
|
2714 |
-
var mid = (rtop + rbot) / 2;
|
2715 |
-
var heights = prepared.view.measure.heights;
|
2716 |
-
for (var i = 0; i < heights.length - 1; i++)
|
2717 |
-
if (mid < heights[i]) break;
|
2718 |
-
var top = i ? heights[i - 1] : 0, bot = heights[i];
|
2719 |
-
var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
|
2720 |
-
right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
|
2721 |
-
top: top, bottom: bot};
|
2722 |
-
if (!rect.left && !rect.right) result.bogus = true;
|
2723 |
-
if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
|
2724 |
-
|
2725 |
-
return result;
|
2726 |
-
}
|
2727 |
-
|
2728 |
-
// Work around problem with bounding client rects on ranges being
|
2729 |
-
// returned incorrectly when zoomed on IE10 and below.
|
2730 |
-
function maybeUpdateRectForZooming(measure, rect) {
|
2731 |
-
if (!window.screen || screen.logicalXDPI == null ||
|
2732 |
-
screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
|
2733 |
-
return rect;
|
2734 |
-
var scaleX = screen.logicalXDPI / screen.deviceXDPI;
|
2735 |
-
var scaleY = screen.logicalYDPI / screen.deviceYDPI;
|
2736 |
-
return {left: rect.left * scaleX, right: rect.right * scaleX,
|
2737 |
-
top: rect.top * scaleY, bottom: rect.bottom * scaleY};
|
2738 |
-
}
|
2739 |
-
|
2740 |
-
function clearLineMeasurementCacheFor(lineView) {
|
2741 |
-
if (lineView.measure) {
|
2742 |
-
lineView.measure.cache = {};
|
2743 |
-
lineView.measure.heights = null;
|
2744 |
-
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
|
2745 |
-
lineView.measure.caches[i] = {};
|
2746 |
-
}
|
2747 |
-
}
|
2748 |
-
|
2749 |
-
function clearLineMeasurementCache(cm) {
|
2750 |
-
cm.display.externalMeasure = null;
|
2751 |
-
removeChildren(cm.display.lineMeasure);
|
2752 |
-
for (var i = 0; i < cm.display.view.length; i++)
|
2753 |
-
clearLineMeasurementCacheFor(cm.display.view[i]);
|
2754 |
-
}
|
2755 |
-
|
2756 |
-
function clearCaches(cm) {
|
2757 |
-
clearLineMeasurementCache(cm);
|
2758 |
-
cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
|
2759 |
-
if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
|
2760 |
-
cm.display.lineNumChars = null;
|
2761 |
-
}
|
2762 |
-
|
2763 |
-
function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
|
2764 |
-
function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
|
2765 |
-
|
2766 |
-
// Converts a {top, bottom, left, right} box from line-local
|
2767 |
-
// coordinates into another coordinate system. Context may be one of
|
2768 |
-
// "line", "div" (display.lineDiv), "local"/null (editor), "window",
|
2769 |
-
// or "page".
|
2770 |
-
function intoCoordSystem(cm, lineObj, rect, context) {
|
2771 |
-
if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
|
2772 |
-
var size = widgetHeight(lineObj.widgets[i]);
|
2773 |
-
rect.top += size; rect.bottom += size;
|
2774 |
-
}
|
2775 |
-
if (context == "line") return rect;
|
2776 |
-
if (!context) context = "local";
|
2777 |
-
var yOff = heightAtLine(lineObj);
|
2778 |
-
if (context == "local") yOff += paddingTop(cm.display);
|
2779 |
-
else yOff -= cm.display.viewOffset;
|
2780 |
-
if (context == "page" || context == "window") {
|
2781 |
-
var lOff = cm.display.lineSpace.getBoundingClientRect();
|
2782 |
-
yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
|
2783 |
-
var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
|
2784 |
-
rect.left += xOff; rect.right += xOff;
|
2785 |
-
}
|
2786 |
-
rect.top += yOff; rect.bottom += yOff;
|
2787 |
-
return rect;
|
2788 |
-
}
|
2789 |
-
|
2790 |
-
// Coverts a box from "div" coords to another coordinate system.
|
2791 |
-
// Context may be "window", "page", "div", or "local"/null.
|
2792 |
-
function fromCoordSystem(cm, coords, context) {
|
2793 |
-
if (context == "div") return coords;
|
2794 |
-
var left = coords.left, top = coords.top;
|
2795 |
-
// First move into "page" coordinate system
|
2796 |
-
if (context == "page") {
|
2797 |
-
left -= pageScrollX();
|
2798 |
-
top -= pageScrollY();
|
2799 |
-
} else if (context == "local" || !context) {
|
2800 |
-
var localBox = cm.display.sizer.getBoundingClientRect();
|
2801 |
-
left += localBox.left;
|
2802 |
-
top += localBox.top;
|
2803 |
-
}
|
2804 |
-
|
2805 |
-
var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
|
2806 |
-
return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
|
2807 |
-
}
|
2808 |
-
|
2809 |
-
function charCoords(cm, pos, context, lineObj, bias) {
|
2810 |
-
if (!lineObj) lineObj = getLine(cm.doc, pos.line);
|
2811 |
-
return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
|
2812 |
-
}
|
2813 |
-
|
2814 |
-
// Returns a box for a given cursor position, which may have an
|
2815 |
-
// 'other' property containing the position of the secondary cursor
|
2816 |
-
// on a bidi boundary.
|
2817 |
-
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
|
2818 |
-
lineObj = lineObj || getLine(cm.doc, pos.line);
|
2819 |
-
if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
|
2820 |
-
function get(ch, right) {
|
2821 |
-
var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
|
2822 |
-
if (right) m.left = m.right; else m.right = m.left;
|
2823 |
-
return intoCoordSystem(cm, lineObj, m, context);
|
2824 |
-
}
|
2825 |
-
function getBidi(ch, partPos) {
|
2826 |
-
var part = order[partPos], right = part.level % 2;
|
2827 |
-
if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
|
2828 |
-
part = order[--partPos];
|
2829 |
-
ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
|
2830 |
-
right = true;
|
2831 |
-
} else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
|
2832 |
-
part = order[++partPos];
|
2833 |
-
ch = bidiLeft(part) - part.level % 2;
|
2834 |
-
right = false;
|
2835 |
-
}
|
2836 |
-
if (right && ch == part.to && ch > part.from) return get(ch - 1);
|
2837 |
-
return get(ch, right);
|
2838 |
-
}
|
2839 |
-
var order = getOrder(lineObj), ch = pos.ch;
|
2840 |
-
if (!order) return get(ch);
|
2841 |
-
var partPos = getBidiPartAt(order, ch);
|
2842 |
-
var val = getBidi(ch, partPos);
|
2843 |
-
if (bidiOther != null) val.other = getBidi(ch, bidiOther);
|
2844 |
-
return val;
|
2845 |
-
}
|
2846 |
-
|
2847 |
-
// Used to cheaply estimate the coordinates for a position. Used for
|
2848 |
-
// intermediate scroll updates.
|
2849 |
-
function estimateCoords(cm, pos) {
|
2850 |
-
var left = 0, pos = clipPos(cm.doc, pos);
|
2851 |
-
if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
|
2852 |
-
var lineObj = getLine(cm.doc, pos.line);
|
2853 |
-
var top = heightAtLine(lineObj) + paddingTop(cm.display);
|
2854 |
-
return {left: left, right: left, top: top, bottom: top + lineObj.height};
|
2855 |
-
}
|
2856 |
-
|
2857 |
-
// Positions returned by coordsChar contain some extra information.
|
2858 |
-
// xRel is the relative x position of the input coordinates compared
|
2859 |
-
// to the found position (so xRel > 0 means the coordinates are to
|
2860 |
-
// the right of the character position, for example). When outside
|
2861 |
-
// is true, that means the coordinates lie outside the line's
|
2862 |
-
// vertical range.
|
2863 |
-
function PosWithInfo(line, ch, outside, xRel) {
|
2864 |
-
var pos = Pos(line, ch);
|
2865 |
-
pos.xRel = xRel;
|
2866 |
-
if (outside) pos.outside = true;
|
2867 |
-
return pos;
|
2868 |
-
}
|
2869 |
-
|
2870 |
-
// Compute the character position closest to the given coordinates.
|
2871 |
-
// Input must be lineSpace-local ("div" coordinate system).
|
2872 |
-
function coordsChar(cm, x, y) {
|
2873 |
-
var doc = cm.doc;
|
2874 |
-
y += cm.display.viewOffset;
|
2875 |
-
if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
|
2876 |
-
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
|
2877 |
-
if (lineN > last)
|
2878 |
-
return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
|
2879 |
-
if (x < 0) x = 0;
|
2880 |
-
|
2881 |
-
var lineObj = getLine(doc, lineN);
|
2882 |
-
for (;;) {
|
2883 |
-
var found = coordsCharInner(cm, lineObj, lineN, x, y);
|
2884 |
-
var merged = collapsedSpanAtEnd(lineObj);
|
2885 |
-
var mergedPos = merged && merged.find(0, true);
|
2886 |
-
if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
|
2887 |
-
lineN = lineNo(lineObj = mergedPos.to.line);
|
2888 |
-
else
|
2889 |
-
return found;
|
2890 |
-
}
|
2891 |
-
}
|
2892 |
-
|
2893 |
-
function coordsCharInner(cm, lineObj, lineNo, x, y) {
|
2894 |
-
var innerOff = y - heightAtLine(lineObj);
|
2895 |
-
var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
|
2896 |
-
var preparedMeasure = prepareMeasureForLine(cm, lineObj);
|
2897 |
-
|
2898 |
-
function getX(ch) {
|
2899 |
-
var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
|
2900 |
-
wrongLine = true;
|
2901 |
-
if (innerOff > sp.bottom) return sp.left - adjust;
|
2902 |
-
else if (innerOff < sp.top) return sp.left + adjust;
|
2903 |
-
else wrongLine = false;
|
2904 |
-
return sp.left;
|
2905 |
-
}
|
2906 |
-
|
2907 |
-
var bidi = getOrder(lineObj), dist = lineObj.text.length;
|
2908 |
-
var from = lineLeft(lineObj), to = lineRight(lineObj);
|
2909 |
-
var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
|
2910 |
-
|
2911 |
-
if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
|
2912 |
-
// Do a binary search between these bounds.
|
2913 |
-
for (;;) {
|
2914 |
-
if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
|
2915 |
-
var ch = x < fromX || x - fromX <= toX - x ? from : to;
|
2916 |
-
var xDiff = x - (ch == from ? fromX : toX);
|
2917 |
-
while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
|
2918 |
-
var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
|
2919 |
-
xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
|
2920 |
-
return pos;
|
2921 |
-
}
|
2922 |
-
var step = Math.ceil(dist / 2), middle = from + step;
|
2923 |
-
if (bidi) {
|
2924 |
-
middle = from;
|
2925 |
-
for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
|
2926 |
-
}
|
2927 |
-
var middleX = getX(middle);
|
2928 |
-
if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
|
2929 |
-
else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
|
2930 |
-
}
|
2931 |
-
}
|
2932 |
-
|
2933 |
-
var measureText;
|
2934 |
-
// Compute the default text height.
|
2935 |
-
function textHeight(display) {
|
2936 |
-
if (display.cachedTextHeight != null) return display.cachedTextHeight;
|
2937 |
-
if (measureText == null) {
|
2938 |
-
measureText = elt("pre");
|
2939 |
-
// Measure a bunch of lines, for browsers that compute
|
2940 |
-
// fractional heights.
|
2941 |
-
for (var i = 0; i < 49; ++i) {
|
2942 |
-
measureText.appendChild(document.createTextNode("x"));
|
2943 |
-
measureText.appendChild(elt("br"));
|
2944 |
-
}
|
2945 |
-
measureText.appendChild(document.createTextNode("x"));
|
2946 |
-
}
|
2947 |
-
removeChildrenAndAdd(display.measure, measureText);
|
2948 |
-
var height = measureText.offsetHeight / 50;
|
2949 |
-
if (height > 3) display.cachedTextHeight = height;
|
2950 |
-
removeChildren(display.measure);
|
2951 |
-
return height || 1;
|
2952 |
-
}
|
2953 |
-
|
2954 |
-
// Compute the default character width.
|
2955 |
-
function charWidth(display) {
|
2956 |
-
if (display.cachedCharWidth != null) return display.cachedCharWidth;
|
2957 |
-
var anchor = elt("span", "xxxxxxxxxx");
|
2958 |
-
var pre = elt("pre", [anchor]);
|
2959 |
-
removeChildrenAndAdd(display.measure, pre);
|
2960 |
-
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
|
2961 |
-
if (width > 2) display.cachedCharWidth = width;
|
2962 |
-
return width || 10;
|
2963 |
-
}
|
2964 |
-
|
2965 |
-
// OPERATIONS
|
2966 |
-
|
2967 |
-
// Operations are used to wrap a series of changes to the editor
|
2968 |
-
// state in such a way that each change won't have to update the
|
2969 |
-
// cursor and display (which would be awkward, slow, and
|
2970 |
-
// error-prone). Instead, display updates are batched and then all
|
2971 |
-
// combined and executed at once.
|
2972 |
-
|
2973 |
-
var operationGroup = null;
|
2974 |
-
|
2975 |
-
var nextOpId = 0;
|
2976 |
-
// Start a new operation.
|
2977 |
-
function startOperation(cm) {
|
2978 |
-
cm.curOp = {
|
2979 |
-
cm: cm,
|
2980 |
-
viewChanged: false, // Flag that indicates that lines might need to be redrawn
|
2981 |
-
startHeight: cm.doc.height, // Used to detect need to update scrollbar
|
2982 |
-
forceUpdate: false, // Used to force a redraw
|
2983 |
-
updateInput: null, // Whether to reset the input textarea
|
2984 |
-
typing: false, // Whether this reset should be careful to leave existing text (for compositing)
|
2985 |
-
changeObjs: null, // Accumulated changes, for firing change events
|
2986 |
-
cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
|
2987 |
-
cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
|
2988 |
-
selectionChanged: false, // Whether the selection needs to be redrawn
|
2989 |
-
updateMaxLine: false, // Set when the widest line needs to be determined anew
|
2990 |
-
scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
|
2991 |
-
scrollToPos: null, // Used to scroll to a specific position
|
2992 |
-
focus: false,
|
2993 |
-
id: ++nextOpId // Unique ID
|
2994 |
-
};
|
2995 |
-
if (operationGroup) {
|
2996 |
-
operationGroup.ops.push(cm.curOp);
|
2997 |
-
} else {
|
2998 |
-
cm.curOp.ownsGroup = operationGroup = {
|
2999 |
-
ops: [cm.curOp],
|
3000 |
-
delayedCallbacks: []
|
3001 |
-
};
|
3002 |
-
}
|
3003 |
-
}
|
3004 |
-
|
3005 |
-
function fireCallbacksForOps(group) {
|
3006 |
-
// Calls delayed callbacks and cursorActivity handlers until no
|
3007 |
-
// new ones appear
|
3008 |
-
var callbacks = group.delayedCallbacks, i = 0;
|
3009 |
-
do {
|
3010 |
-
for (; i < callbacks.length; i++)
|
3011 |
-
callbacks[i].call(null);
|
3012 |
-
for (var j = 0; j < group.ops.length; j++) {
|
3013 |
-
var op = group.ops[j];
|
3014 |
-
if (op.cursorActivityHandlers)
|
3015 |
-
while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
|
3016 |
-
op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm);
|
3017 |
-
}
|
3018 |
-
} while (i < callbacks.length);
|
3019 |
-
}
|
3020 |
-
|
3021 |
-
// Finish an operation, updating the display and signalling delayed events
|
3022 |
-
function endOperation(cm) {
|
3023 |
-
var op = cm.curOp, group = op.ownsGroup;
|
3024 |
-
if (!group) return;
|
3025 |
-
|
3026 |
-
try { fireCallbacksForOps(group); }
|
3027 |
-
finally {
|
3028 |
-
operationGroup = null;
|
3029 |
-
for (var i = 0; i < group.ops.length; i++)
|
3030 |
-
group.ops[i].cm.curOp = null;
|
3031 |
-
endOperations(group);
|
3032 |
-
}
|
3033 |
-
}
|
3034 |
-
|
3035 |
-
// The DOM updates done when an operation finishes are batched so
|
3036 |
-
// that the minimum number of relayouts are required.
|
3037 |
-
function endOperations(group) {
|
3038 |
-
var ops = group.ops;
|
3039 |
-
for (var i = 0; i < ops.length; i++) // Read DOM
|
3040 |
-
endOperation_R1(ops[i]);
|
3041 |
-
for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
|
3042 |
-
endOperation_W1(ops[i]);
|
3043 |
-
for (var i = 0; i < ops.length; i++) // Read DOM
|
3044 |
-
endOperation_R2(ops[i]);
|
3045 |
-
for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
|
3046 |
-
endOperation_W2(ops[i]);
|
3047 |
-
for (var i = 0; i < ops.length; i++) // Read DOM
|
3048 |
-
endOperation_finish(ops[i]);
|
3049 |
-
}
|
3050 |
-
|
3051 |
-
function endOperation_R1(op) {
|
3052 |
-
var cm = op.cm, display = cm.display;
|
3053 |
-
maybeClipScrollbars(cm);
|
3054 |
-
if (op.updateMaxLine) findMaxLine(cm);
|
3055 |
-
|
3056 |
-
op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
|
3057 |
-
op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
|
3058 |
-
op.scrollToPos.to.line >= display.viewTo) ||
|
3059 |
-
display.maxLineChanged && cm.options.lineWrapping;
|
3060 |
-
op.update = op.mustUpdate &&
|
3061 |
-
new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
|
3062 |
-
}
|
3063 |
-
|
3064 |
-
function endOperation_W1(op) {
|
3065 |
-
op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
|
3066 |
-
}
|
3067 |
-
|
3068 |
-
function endOperation_R2(op) {
|
3069 |
-
var cm = op.cm, display = cm.display;
|
3070 |
-
if (op.updatedDisplay) updateHeightsInViewport(cm);
|
3071 |
-
|
3072 |
-
op.barMeasure = measureForScrollbars(cm);
|
3073 |
-
|
3074 |
-
// If the max line changed since it was last measured, measure it,
|
3075 |
-
// and ensure the document's width matches it.
|
3076 |
-
// updateDisplay_W2 will use these properties to do the actual resizing
|
3077 |
-
if (display.maxLineChanged && !cm.options.lineWrapping) {
|
3078 |
-
op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
|
3079 |
-
cm.display.sizerWidth = op.adjustWidthTo;
|
3080 |
-
op.barMeasure.scrollWidth =
|
3081 |
-
Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
|
3082 |
-
op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
|
3083 |
-
}
|
3084 |
-
|
3085 |
-
if (op.updatedDisplay || op.selectionChanged)
|
3086 |
-
op.preparedSelection = display.input.prepareSelection();
|
3087 |
-
}
|
3088 |
-
|
3089 |
-
function endOperation_W2(op) {
|
3090 |
-
var cm = op.cm;
|
3091 |
-
|
3092 |
-
if (op.adjustWidthTo != null) {
|
3093 |
-
cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
|
3094 |
-
if (op.maxScrollLeft < cm.doc.scrollLeft)
|
3095 |
-
setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
|
3096 |
-
cm.display.maxLineChanged = false;
|
3097 |
-
}
|
3098 |
-
|
3099 |
-
if (op.preparedSelection)
|
3100 |
-
cm.display.input.showSelection(op.preparedSelection);
|
3101 |
-
if (op.updatedDisplay)
|
3102 |
-
setDocumentHeight(cm, op.barMeasure);
|
3103 |
-
if (op.updatedDisplay || op.startHeight != cm.doc.height)
|
3104 |
-
updateScrollbars(cm, op.barMeasure);
|
3105 |
-
|
3106 |
-
if (op.selectionChanged) restartBlink(cm);
|
3107 |
-
|
3108 |
-
if (cm.state.focused && op.updateInput)
|
3109 |
-
cm.display.input.reset(op.typing);
|
3110 |
-
if (op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus()))
|
3111 |
-
ensureFocus(op.cm);
|
3112 |
-
}
|
3113 |
-
|
3114 |
-
function endOperation_finish(op) {
|
3115 |
-
var cm = op.cm, display = cm.display, doc = cm.doc;
|
3116 |
-
|
3117 |
-
if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
|
3118 |
-
|
3119 |
-
// Abort mouse wheel delta measurement, when scrolling explicitly
|
3120 |
-
if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
|
3121 |
-
display.wheelStartX = display.wheelStartY = null;
|
3122 |
-
|
3123 |
-
// Propagate the scroll position to the actual DOM scroller
|
3124 |
-
if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
|
3125 |
-
doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
|
3126 |
-
display.scrollbars.setScrollTop(doc.scrollTop);
|
3127 |
-
display.scroller.scrollTop = doc.scrollTop;
|
3128 |
-
}
|
3129 |
-
if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
|
3130 |
-
doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft));
|
3131 |
-
display.scrollbars.setScrollLeft(doc.scrollLeft);
|
3132 |
-
display.scroller.scrollLeft = doc.scrollLeft;
|
3133 |
-
alignHorizontally(cm);
|
3134 |
-
}
|
3135 |
-
// If we need to scroll a specific position into view, do so.
|
3136 |
-
if (op.scrollToPos) {
|
3137 |
-
var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
|
3138 |
-
clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
|
3139 |
-
if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
|
3140 |
-
}
|
3141 |
-
|
3142 |
-
// Fire events for markers that are hidden/unidden by editing or
|
3143 |
-
// undoing
|
3144 |
-
var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
|
3145 |
-
if (hidden) for (var i = 0; i < hidden.length; ++i)
|
3146 |
-
if (!hidden[i].lines.length) signal(hidden[i], "hide");
|
3147 |
-
if (unhidden) for (var i = 0; i < unhidden.length; ++i)
|
3148 |
-
if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
|
3149 |
-
|
3150 |
-
if (display.wrapper.offsetHeight)
|
3151 |
-
doc.scrollTop = cm.display.scroller.scrollTop;
|
3152 |
-
|
3153 |
-
// Fire change events, and delayed event handlers
|
3154 |
-
if (op.changeObjs)
|
3155 |
-
signal(cm, "changes", cm, op.changeObjs);
|
3156 |
-
if (op.update)
|
3157 |
-
op.update.finish();
|
3158 |
-
}
|
3159 |
-
|
3160 |
-
// Run the given function in an operation
|
3161 |
-
function runInOp(cm, f) {
|
3162 |
-
if (cm.curOp) return f();
|
3163 |
-
startOperation(cm);
|
3164 |
-
try { return f(); }
|
3165 |
-
finally { endOperation(cm); }
|
3166 |
-
}
|
3167 |
-
// Wraps a function in an operation. Returns the wrapped function.
|
3168 |
-
function operation(cm, f) {
|
3169 |
-
return function() {
|
3170 |
-
if (cm.curOp) return f.apply(cm, arguments);
|
3171 |
-
startOperation(cm);
|
3172 |
-
try { return f.apply(cm, arguments); }
|
3173 |
-
finally { endOperation(cm); }
|
3174 |
-
};
|
3175 |
-
}
|
3176 |
-
// Used to add methods to editor and doc instances, wrapping them in
|
3177 |
-
// operations.
|
3178 |
-
function methodOp(f) {
|
3179 |
-
return function() {
|
3180 |
-
if (this.curOp) return f.apply(this, arguments);
|
3181 |
-
startOperation(this);
|
3182 |
-
try { return f.apply(this, arguments); }
|
3183 |
-
finally { endOperation(this); }
|
3184 |
-
};
|
3185 |
-
}
|
3186 |
-
function docMethodOp(f) {
|
3187 |
-
return function() {
|
3188 |
-
var cm = this.cm;
|
3189 |
-
if (!cm || cm.curOp) return f.apply(this, arguments);
|
3190 |
-
startOperation(cm);
|
3191 |
-
try { return f.apply(this, arguments); }
|
3192 |
-
finally { endOperation(cm); }
|
3193 |
-
};
|
3194 |
-
}
|
3195 |
-
|
3196 |
-
// VIEW TRACKING
|
3197 |
-
|
3198 |
-
// These objects are used to represent the visible (currently drawn)
|
3199 |
-
// part of the document. A LineView may correspond to multiple
|
3200 |
-
// logical lines, if those are connected by collapsed ranges.
|
3201 |
-
function LineView(doc, line, lineN) {
|
3202 |
-
// The starting line
|
3203 |
-
this.line = line;
|
3204 |
-
// Continuing lines, if any
|
3205 |
-
this.rest = visualLineContinued(line);
|
3206 |
-
// Number of logical lines in this visual line
|
3207 |
-
this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
|
3208 |
-
this.node = this.text = null;
|
3209 |
-
this.hidden = lineIsHidden(doc, line);
|
3210 |
-
}
|
3211 |
-
|
3212 |
-
// Create a range of LineView objects for the given lines.
|
3213 |
-
function buildViewArray(cm, from, to) {
|
3214 |
-
var array = [], nextPos;
|
3215 |
-
for (var pos = from; pos < to; pos = nextPos) {
|
3216 |
-
var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
|
3217 |
-
nextPos = pos + view.size;
|
3218 |
-
array.push(view);
|
3219 |
-
}
|
3220 |
-
return array;
|
3221 |
-
}
|
3222 |
-
|
3223 |
-
// Updates the display.view data structure for a given change to the
|
3224 |
-
// document. From and to are in pre-change coordinates. Lendiff is
|
3225 |
-
// the amount of lines added or subtracted by the change. This is
|
3226 |
-
// used for changes that span multiple lines, or change the way
|
3227 |
-
// lines are divided into visual lines. regLineChange (below)
|
3228 |
-
// registers single-line changes.
|
3229 |
-
function regChange(cm, from, to, lendiff) {
|
3230 |
-
if (from == null) from = cm.doc.first;
|
3231 |
-
if (to == null) to = cm.doc.first + cm.doc.size;
|
3232 |
-
if (!lendiff) lendiff = 0;
|
3233 |
-
|
3234 |
-
var display = cm.display;
|
3235 |
-
if (lendiff && to < display.viewTo &&
|
3236 |
-
(display.updateLineNumbers == null || display.updateLineNumbers > from))
|
3237 |
-
display.updateLineNumbers = from;
|
3238 |
-
|
3239 |
-
cm.curOp.viewChanged = true;
|
3240 |
-
|
3241 |
-
if (from >= display.viewTo) { // Change after
|
3242 |
-
if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
|
3243 |
-
resetView(cm);
|
3244 |
-
} else if (to <= display.viewFrom) { // Change before
|
3245 |
-
if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
|
3246 |
-
resetView(cm);
|
3247 |
-
} else {
|
3248 |
-
display.viewFrom += lendiff;
|
3249 |
-
display.viewTo += lendiff;
|
3250 |
-
}
|
3251 |
-
} else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
|
3252 |
-
resetView(cm);
|
3253 |
-
} else if (from <= display.viewFrom) { // Top overlap
|
3254 |
-
var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
|
3255 |
-
if (cut) {
|
3256 |
-
display.view = display.view.slice(cut.index);
|
3257 |
-
display.viewFrom = cut.lineN;
|
3258 |
-
display.viewTo += lendiff;
|
3259 |
-
} else {
|
3260 |
-
resetView(cm);
|
3261 |
-
}
|
3262 |
-
} else if (to >= display.viewTo) { // Bottom overlap
|
3263 |
-
var cut = viewCuttingPoint(cm, from, from, -1);
|
3264 |
-
if (cut) {
|
3265 |
-
display.view = display.view.slice(0, cut.index);
|
3266 |
-
display.viewTo = cut.lineN;
|
3267 |
-
} else {
|
3268 |
-
resetView(cm);
|
3269 |
-
}
|
3270 |
-
} else { // Gap in the middle
|
3271 |
-
var cutTop = viewCuttingPoint(cm, from, from, -1);
|
3272 |
-
var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
|
3273 |
-
if (cutTop && cutBot) {
|
3274 |
-
display.view = display.view.slice(0, cutTop.index)
|
3275 |
-
.concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
|
3276 |
-
.concat(display.view.slice(cutBot.index));
|
3277 |
-
display.viewTo += lendiff;
|
3278 |
-
} else {
|
3279 |
-
resetView(cm);
|
3280 |
-
}
|
3281 |
-
}
|
3282 |
-
|
3283 |
-
var ext = display.externalMeasured;
|
3284 |
-
if (ext) {
|
3285 |
-
if (to < ext.lineN)
|
3286 |
-
ext.lineN += lendiff;
|
3287 |
-
else if (from < ext.lineN + ext.size)
|
3288 |
-
display.externalMeasured = null;
|
3289 |
-
}
|
3290 |
-
}
|
3291 |
-
|
3292 |
-
// Register a change to a single line. Type must be one of "text",
|
3293 |
-
// "gutter", "class", "widget"
|
3294 |
-
function regLineChange(cm, line, type) {
|
3295 |
-
cm.curOp.viewChanged = true;
|
3296 |
-
var display = cm.display, ext = cm.display.externalMeasured;
|
3297 |
-
if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
|
3298 |
-
display.externalMeasured = null;
|
3299 |
-
|
3300 |
-
if (line < display.viewFrom || line >= display.viewTo) return;
|
3301 |
-
var lineView = display.view[findViewIndex(cm, line)];
|
3302 |
-
if (lineView.node == null) return;
|
3303 |
-
var arr = lineView.changes || (lineView.changes = []);
|
3304 |
-
if (indexOf(arr, type) == -1) arr.push(type);
|
3305 |
-
}
|
3306 |
-
|
3307 |
-
// Clear the view.
|
3308 |
-
function resetView(cm) {
|
3309 |
-
cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
|
3310 |
-
cm.display.view = [];
|
3311 |
-
cm.display.viewOffset = 0;
|
3312 |
-
}
|
3313 |
-
|
3314 |
-
// Find the view element corresponding to a given line. Return null
|
3315 |
-
// when the line isn't visible.
|
3316 |
-
function findViewIndex(cm, n) {
|
3317 |
-
if (n >= cm.display.viewTo) return null;
|
3318 |
-
n -= cm.display.viewFrom;
|
3319 |
-
if (n < 0) return null;
|
3320 |
-
var view = cm.display.view;
|
3321 |
-
for (var i = 0; i < view.length; i++) {
|
3322 |
-
n -= view[i].size;
|
3323 |
-
if (n < 0) return i;
|
3324 |
-
}
|
3325 |
-
}
|
3326 |
-
|
3327 |
-
function viewCuttingPoint(cm, oldN, newN, dir) {
|
3328 |
-
var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
|
3329 |
-
if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
|
3330 |
-
return {index: index, lineN: newN};
|
3331 |
-
for (var i = 0, n = cm.display.viewFrom; i < index; i++)
|
3332 |
-
n += view[i].size;
|
3333 |
-
if (n != oldN) {
|
3334 |
-
if (dir > 0) {
|
3335 |
-
if (index == view.length - 1) return null;
|
3336 |
-
diff = (n + view[index].size) - oldN;
|
3337 |
-
index++;
|
3338 |
-
} else {
|
3339 |
-
diff = n - oldN;
|
3340 |
-
}
|
3341 |
-
oldN += diff; newN += diff;
|
3342 |
-
}
|
3343 |
-
while (visualLineNo(cm.doc, newN) != newN) {
|
3344 |
-
if (index == (dir < 0 ? 0 : view.length - 1)) return null;
|
3345 |
-
newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
|
3346 |
-
index += dir;
|
3347 |
-
}
|
3348 |
-
return {index: index, lineN: newN};
|
3349 |
-
}
|
3350 |
-
|
3351 |
-
// Force the view to cover a given range, adding empty view element
|
3352 |
-
// or clipping off existing ones as needed.
|
3353 |
-
function adjustView(cm, from, to) {
|
3354 |
-
var display = cm.display, view = display.view;
|
3355 |
-
if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
|
3356 |
-
display.view = buildViewArray(cm, from, to);
|
3357 |
-
display.viewFrom = from;
|
3358 |
-
} else {
|
3359 |
-
if (display.viewFrom > from)
|
3360 |
-
display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
|
3361 |
-
else if (display.viewFrom < from)
|
3362 |
-
display.view = display.view.slice(findViewIndex(cm, from));
|
3363 |
-
display.viewFrom = from;
|
3364 |
-
if (display.viewTo < to)
|
3365 |
-
display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
|
3366 |
-
else if (display.viewTo > to)
|
3367 |
-
display.view = display.view.slice(0, findViewIndex(cm, to));
|
3368 |
-
}
|
3369 |
-
display.viewTo = to;
|
3370 |
-
}
|
3371 |
-
|
3372 |
-
// Count the number of lines in the view whose DOM representation is
|
3373 |
-
// out of date (or nonexistent).
|
3374 |
-
function countDirtyView(cm) {
|
3375 |
-
var view = cm.display.view, dirty = 0;
|
3376 |
-
for (var i = 0; i < view.length; i++) {
|
3377 |
-
var lineView = view[i];
|
3378 |
-
if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
|
3379 |
-
}
|
3380 |
-
return dirty;
|
3381 |
-
}
|
3382 |
-
|
3383 |
-
// EVENT HANDLERS
|
3384 |
-
|
3385 |
-
// Attach the necessary event handlers when initializing the editor
|
3386 |
-
function registerEventHandlers(cm) {
|
3387 |
-
var d = cm.display;
|
3388 |
-
on(d.scroller, "mousedown", operation(cm, onMouseDown));
|
3389 |
-
// Older IE's will not fire a second mousedown for a double click
|
3390 |
-
if (ie && ie_version < 11)
|
3391 |
-
on(d.scroller, "dblclick", operation(cm, function(e) {
|
3392 |
-
if (signalDOMEvent(cm, e)) return;
|
3393 |
-
var pos = posFromMouse(cm, e);
|
3394 |
-
if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
|
3395 |
-
e_preventDefault(e);
|
3396 |
-
var word = cm.findWordAt(pos);
|
3397 |
-
extendSelection(cm.doc, word.anchor, word.head);
|
3398 |
-
}));
|
3399 |
-
else
|
3400 |
-
on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
|
3401 |
-
// Some browsers fire contextmenu *after* opening the menu, at
|
3402 |
-
// which point we can't mess with it anymore. Context menu is
|
3403 |
-
// handled in onMouseDown for these browsers.
|
3404 |
-
if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
|
3405 |
-
|
3406 |
-
// Used to suppress mouse event handling when a touch happens
|
3407 |
-
var touchFinished, prevTouch = {end: 0};
|
3408 |
-
function finishTouch() {
|
3409 |
-
if (d.activeTouch) {
|
3410 |
-
touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000);
|
3411 |
-
prevTouch = d.activeTouch;
|
3412 |
-
prevTouch.end = +new Date;
|
3413 |
-
}
|
3414 |
-
};
|
3415 |
-
function isMouseLikeTouchEvent(e) {
|
3416 |
-
if (e.touches.length != 1) return false;
|
3417 |
-
var touch = e.touches[0];
|
3418 |
-
return touch.radiusX <= 1 && touch.radiusY <= 1;
|
3419 |
-
}
|
3420 |
-
function farAway(touch, other) {
|
3421 |
-
if (other.left == null) return true;
|
3422 |
-
var dx = other.left - touch.left, dy = other.top - touch.top;
|
3423 |
-
return dx * dx + dy * dy > 20 * 20;
|
3424 |
-
}
|
3425 |
-
on(d.scroller, "touchstart", function(e) {
|
3426 |
-
if (!isMouseLikeTouchEvent(e)) {
|
3427 |
-
clearTimeout(touchFinished);
|
3428 |
-
var now = +new Date;
|
3429 |
-
d.activeTouch = {start: now, moved: false,
|
3430 |
-
prev: now - prevTouch.end <= 300 ? prevTouch : null};
|
3431 |
-
if (e.touches.length == 1) {
|
3432 |
-
d.activeTouch.left = e.touches[0].pageX;
|
3433 |
-
d.activeTouch.top = e.touches[0].pageY;
|
3434 |
-
}
|
3435 |
-
}
|
3436 |
-
});
|
3437 |
-
on(d.scroller, "touchmove", function() {
|
3438 |
-
if (d.activeTouch) d.activeTouch.moved = true;
|
3439 |
-
});
|
3440 |
-
on(d.scroller, "touchend", function(e) {
|
3441 |
-
var touch = d.activeTouch;
|
3442 |
-
if (touch && !eventInWidget(d, e) && touch.left != null &&
|
3443 |
-
!touch.moved && new Date - touch.start < 300) {
|
3444 |
-
var pos = cm.coordsChar(d.activeTouch, "page"), range;
|
3445 |
-
if (!touch.prev || farAway(touch, touch.prev)) // Single tap
|
3446 |
-
range = new Range(pos, pos);
|
3447 |
-
else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
|
3448 |
-
range = cm.findWordAt(pos);
|
3449 |
-
else // Triple tap
|
3450 |
-
range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)));
|
3451 |
-
cm.setSelection(range.anchor, range.head);
|
3452 |
-
cm.focus();
|
3453 |
-
e_preventDefault(e);
|
3454 |
-
}
|
3455 |
-
finishTouch();
|
3456 |
-
});
|
3457 |
-
on(d.scroller, "touchcancel", finishTouch);
|
3458 |
-
|
3459 |
-
// Sync scrolling between fake scrollbars and real scrollable
|
3460 |
-
// area, ensure viewport is updated when scrolling.
|
3461 |
-
on(d.scroller, "scroll", function() {
|
3462 |
-
if (d.scroller.clientHeight) {
|
3463 |
-
setScrollTop(cm, d.scroller.scrollTop);
|
3464 |
-
setScrollLeft(cm, d.scroller.scrollLeft, true);
|
3465 |
-
signal(cm, "scroll", cm);
|
3466 |
-
}
|
3467 |
-
});
|
3468 |
-
|
3469 |
-
// Listen to wheel events in order to try and update the viewport on time.
|
3470 |
-
on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
|
3471 |
-
on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
|
3472 |
-
|
3473 |
-
// Prevent wrapper from ever scrolling
|
3474 |
-
on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
|
3475 |
-
|
3476 |
-
d.dragFunctions = {
|
3477 |
-
enter: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
|
3478 |
-
over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
|
3479 |
-
start: function(e){onDragStart(cm, e);},
|
3480 |
-
drop: operation(cm, onDrop),
|
3481 |
-
leave: function() {clearDragCursor(cm);}
|
3482 |
-
};
|
3483 |
-
|
3484 |
-
var inp = d.input.getField();
|
3485 |
-
on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
|
3486 |
-
on(inp, "keydown", operation(cm, onKeyDown));
|
3487 |
-
on(inp, "keypress", operation(cm, onKeyPress));
|
3488 |
-
on(inp, "focus", bind(onFocus, cm));
|
3489 |
-
on(inp, "blur", bind(onBlur, cm));
|
3490 |
-
}
|
3491 |
-
|
3492 |
-
function dragDropChanged(cm, value, old) {
|
3493 |
-
var wasOn = old && old != CodeMirror.Init;
|
3494 |
-
if (!value != !wasOn) {
|
3495 |
-
var funcs = cm.display.dragFunctions;
|
3496 |
-
var toggle = value ? on : off;
|
3497 |
-
toggle(cm.display.scroller, "dragstart", funcs.start);
|
3498 |
-
toggle(cm.display.scroller, "dragenter", funcs.enter);
|
3499 |
-
toggle(cm.display.scroller, "dragover", funcs.over);
|
3500 |
-
toggle(cm.display.scroller, "dragleave", funcs.leave);
|
3501 |
-
toggle(cm.display.scroller, "drop", funcs.drop);
|
3502 |
-
}
|
3503 |
-
}
|
3504 |
-
|
3505 |
-
// Called when the window resizes
|
3506 |
-
function onResize(cm) {
|
3507 |
-
var d = cm.display;
|
3508 |
-
if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
|
3509 |
-
return;
|
3510 |
-
// Might be a text scaling operation, clear size caches.
|
3511 |
-
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
|
3512 |
-
d.scrollbarsClipped = false;
|
3513 |
-
cm.setSize();
|
3514 |
-
}
|
3515 |
-
|
3516 |
-
// MOUSE EVENTS
|
3517 |
-
|
3518 |
-
// Return true when the given mouse event happened in a widget
|
3519 |
-
function eventInWidget(display, e) {
|
3520 |
-
for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
|
3521 |
-
if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
|
3522 |
-
(n.parentNode == display.sizer && n != display.mover))
|
3523 |
-
return true;
|
3524 |
-
}
|
3525 |
-
}
|
3526 |
-
|
3527 |
-
// Given a mouse event, find the corresponding position. If liberal
|
3528 |
-
// is false, it checks whether a gutter or scrollbar was clicked,
|
3529 |
-
// and returns null if it was. forRect is used by rectangular
|
3530 |
-
// selections, and tries to estimate a character position even for
|
3531 |
-
// coordinates beyond the right of the text.
|
3532 |
-
function posFromMouse(cm, e, liberal, forRect) {
|
3533 |
-
var display = cm.display;
|
3534 |
-
if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null;
|
3535 |
-
|
3536 |
-
var x, y, space = display.lineSpace.getBoundingClientRect();
|
3537 |
-
// Fails unpredictably on IE[67] when mouse is dragged around quickly.
|
3538 |
-
try { x = e.clientX - space.left; y = e.clientY - space.top; }
|
3539 |
-
catch (e) { return null; }
|
3540 |
-
var coords = coordsChar(cm, x, y), line;
|
3541 |
-
if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
|
3542 |
-
var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
|
3543 |
-
coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
|
3544 |
-
}
|
3545 |
-
return coords;
|
3546 |
-
}
|
3547 |
-
|
3548 |
-
// A mouse down can be a single click, double click, triple click,
|
3549 |
-
// start of selection drag, start of text drag, new cursor
|
3550 |
-
// (ctrl-click), rectangle drag (alt-drag), or xwin
|
3551 |
-
// middle-click-paste. Or it might be a click on something we should
|
3552 |
-
// not interfere with, such as a scrollbar or widget.
|
3553 |
-
function onMouseDown(e) {
|
3554 |
-
var cm = this, display = cm.display;
|
3555 |
-
if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return;
|
3556 |
-
display.shift = e.shiftKey;
|
3557 |
-
|
3558 |
-
if (eventInWidget(display, e)) {
|
3559 |
-
if (!webkit) {
|
3560 |
-
// Briefly turn off draggability, to allow widgets to do
|
3561 |
-
// normal dragging things.
|
3562 |
-
display.scroller.draggable = false;
|
3563 |
-
setTimeout(function(){display.scroller.draggable = true;}, 100);
|
3564 |
-
}
|
3565 |
-
return;
|
3566 |
-
}
|
3567 |
-
if (clickInGutter(cm, e)) return;
|
3568 |
-
var start = posFromMouse(cm, e);
|
3569 |
-
window.focus();
|
3570 |
-
|
3571 |
-
switch (e_button(e)) {
|
3572 |
-
case 1:
|
3573 |
-
// #3261: make sure, that we're not starting a second selection
|
3574 |
-
if (cm.state.selectingText)
|
3575 |
-
cm.state.selectingText(e);
|
3576 |
-
else if (start)
|
3577 |
-
leftButtonDown(cm, e, start);
|
3578 |
-
else if (e_target(e) == display.scroller)
|
3579 |
-
e_preventDefault(e);
|
3580 |
-
break;
|
3581 |
-
case 2:
|
3582 |
-
if (webkit) cm.state.lastMiddleDown = +new Date;
|
3583 |
-
if (start) extendSelection(cm.doc, start);
|
3584 |
-
setTimeout(function() {display.input.focus();}, 20);
|
3585 |
-
e_preventDefault(e);
|
3586 |
-
break;
|
3587 |
-
case 3:
|
3588 |
-
if (captureRightClick) onContextMenu(cm, e);
|
3589 |
-
else delayBlurEvent(cm);
|
3590 |
-
break;
|
3591 |
-
}
|
3592 |
-
}
|
3593 |
-
|
3594 |
-
var lastClick, lastDoubleClick;
|
3595 |
-
function leftButtonDown(cm, e, start) {
|
3596 |
-
if (ie) setTimeout(bind(ensureFocus, cm), 0);
|
3597 |
-
else cm.curOp.focus = activeElt();
|
3598 |
-
|
3599 |
-
var now = +new Date, type;
|
3600 |
-
if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
|
3601 |
-
type = "triple";
|
3602 |
-
} else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
|
3603 |
-
type = "double";
|
3604 |
-
lastDoubleClick = {time: now, pos: start};
|
3605 |
-
} else {
|
3606 |
-
type = "single";
|
3607 |
-
lastClick = {time: now, pos: start};
|
3608 |
-
}
|
3609 |
-
|
3610 |
-
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
|
3611 |
-
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) &&
|
3612 |
-
type == "single" && (contained = sel.contains(start)) > -1 &&
|
3613 |
-
(cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
|
3614 |
-
(cmp(contained.to(), start) > 0 || start.xRel < 0))
|
3615 |
-
leftButtonStartDrag(cm, e, start, modifier);
|
3616 |
-
else
|
3617 |
-
leftButtonSelect(cm, e, start, type, modifier);
|
3618 |
-
}
|
3619 |
-
|
3620 |
-
// Start a text drag. When it ends, see if any dragging actually
|
3621 |
-
// happen, and treat as a click if it didn't.
|
3622 |
-
function leftButtonStartDrag(cm, e, start, modifier) {
|
3623 |
-
var display = cm.display, startTime = +new Date;
|
3624 |
-
var dragEnd = operation(cm, function(e2) {
|
3625 |
-
if (webkit) display.scroller.draggable = false;
|
3626 |
-
cm.state.draggingText = false;
|
3627 |
-
off(document, "mouseup", dragEnd);
|
3628 |
-
off(display.scroller, "drop", dragEnd);
|
3629 |
-
if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
|
3630 |
-
e_preventDefault(e2);
|
3631 |
-
if (!modifier && +new Date - 200 < startTime)
|
3632 |
-
extendSelection(cm.doc, start);
|
3633 |
-
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
|
3634 |
-
if (webkit || ie && ie_version == 9)
|
3635 |
-
setTimeout(function() {document.body.focus(); display.input.focus();}, 20);
|
3636 |
-
else
|
3637 |
-
display.input.focus();
|
3638 |
-
}
|
3639 |
-
});
|
3640 |
-
// Let the drag handler handle this.
|
3641 |
-
if (webkit) display.scroller.draggable = true;
|
3642 |
-
cm.state.draggingText = dragEnd;
|
3643 |
-
// IE's approach to draggable
|
3644 |
-
if (display.scroller.dragDrop) display.scroller.dragDrop();
|
3645 |
-
on(document, "mouseup", dragEnd);
|
3646 |
-
on(display.scroller, "drop", dragEnd);
|
3647 |
-
}
|
3648 |
-
|
3649 |
-
// Normal selection, as opposed to text dragging.
|
3650 |
-
function leftButtonSelect(cm, e, start, type, addNew) {
|
3651 |
-
var display = cm.display, doc = cm.doc;
|
3652 |
-
e_preventDefault(e);
|
3653 |
-
|
3654 |
-
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
|
3655 |
-
if (addNew && !e.shiftKey) {
|
3656 |
-
ourIndex = doc.sel.contains(start);
|
3657 |
-
if (ourIndex > -1)
|
3658 |
-
ourRange = ranges[ourIndex];
|
3659 |
-
else
|
3660 |
-
ourRange = new Range(start, start);
|
3661 |
-
} else {
|
3662 |
-
ourRange = doc.sel.primary();
|
3663 |
-
ourIndex = doc.sel.primIndex;
|
3664 |
-
}
|
3665 |
-
|
3666 |
-
if (e.altKey) {
|
3667 |
-
type = "rect";
|
3668 |
-
if (!addNew) ourRange = new Range(start, start);
|
3669 |
-
start = posFromMouse(cm, e, true, true);
|
3670 |
-
ourIndex = -1;
|
3671 |
-
} else if (type == "double") {
|
3672 |
-
var word = cm.findWordAt(start);
|
3673 |
-
if (cm.display.shift || doc.extend)
|
3674 |
-
ourRange = extendRange(doc, ourRange, word.anchor, word.head);
|
3675 |
-
else
|
3676 |
-
ourRange = word;
|
3677 |
-
} else if (type == "triple") {
|
3678 |
-
var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
|
3679 |
-
if (cm.display.shift || doc.extend)
|
3680 |
-
ourRange = extendRange(doc, ourRange, line.anchor, line.head);
|
3681 |
-
else
|
3682 |
-
ourRange = line;
|
3683 |
-
} else {
|
3684 |
-
ourRange = extendRange(doc, ourRange, start);
|
3685 |
-
}
|
3686 |
-
|
3687 |
-
if (!addNew) {
|
3688 |
-
ourIndex = 0;
|
3689 |
-
setSelection(doc, new Selection([ourRange], 0), sel_mouse);
|
3690 |
-
startSel = doc.sel;
|
3691 |
-
} else if (ourIndex == -1) {
|
3692 |
-
ourIndex = ranges.length;
|
3693 |
-
setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
|
3694 |
-
{scroll: false, origin: "*mouse"});
|
3695 |
-
} else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
|
3696 |
-
setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
3697 |
-
{scroll: false, origin: "*mouse"});
|
3698 |
-
startSel = doc.sel;
|
3699 |
-
} else {
|
3700 |
-
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
3701 |
-
}
|
3702 |
-
|
3703 |
-
var lastPos = start;
|
3704 |
-
function extendTo(pos) {
|
3705 |
-
if (cmp(lastPos, pos) == 0) return;
|
3706 |
-
lastPos = pos;
|
3707 |
-
|
3708 |
-
if (type == "rect") {
|
3709 |
-
var ranges = [], tabSize = cm.options.tabSize;
|
3710 |
-
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
|
3711 |
-
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
|
3712 |
-
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
|
3713 |
-
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
3714 |
-
line <= end; line++) {
|
3715 |
-
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
|
3716 |
-
if (left == right)
|
3717 |
-
ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
|
3718 |
-
else if (text.length > leftPos)
|
3719 |
-
ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
|
3720 |
-
}
|
3721 |
-
if (!ranges.length) ranges.push(new Range(start, start));
|
3722 |
-
setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
3723 |
-
{origin: "*mouse", scroll: false});
|
3724 |
-
cm.scrollIntoView(pos);
|
3725 |
-
} else {
|
3726 |
-
var oldRange = ourRange;
|
3727 |
-
var anchor = oldRange.anchor, head = pos;
|
3728 |
-
if (type != "single") {
|
3729 |
-
if (type == "double")
|
3730 |
-
var range = cm.findWordAt(pos);
|
3731 |
-
else
|
3732 |
-
var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
|
3733 |
-
if (cmp(range.anchor, anchor) > 0) {
|
3734 |
-
head = range.head;
|
3735 |
-
anchor = minPos(oldRange.from(), range.anchor);
|
3736 |
-
} else {
|
3737 |
-
head = range.anchor;
|
3738 |
-
anchor = maxPos(oldRange.to(), range.head);
|
3739 |
-
}
|
3740 |
-
}
|
3741 |
-
var ranges = startSel.ranges.slice(0);
|
3742 |
-
ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
|
3743 |
-
setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
|
3744 |
-
}
|
3745 |
-
}
|
3746 |
-
|
3747 |
-
var editorSize = display.wrapper.getBoundingClientRect();
|
3748 |
-
// Used to ensure timeout re-tries don't fire when another extend
|
3749 |
-
// happened in the meantime (clearTimeout isn't reliable -- at
|
3750 |
-
// least on Chrome, the timeouts still happen even when cleared,
|
3751 |
-
// if the clear happens after their scheduled firing time).
|
3752 |
-
var counter = 0;
|
3753 |
-
|
3754 |
-
function extend(e) {
|
3755 |
-
var curCount = ++counter;
|
3756 |
-
var cur = posFromMouse(cm, e, true, type == "rect");
|
3757 |
-
if (!cur) return;
|
3758 |
-
if (cmp(cur, lastPos) != 0) {
|
3759 |
-
cm.curOp.focus = activeElt();
|
3760 |
-
extendTo(cur);
|
3761 |
-
var visible = visibleLines(display, doc);
|
3762 |
-
if (cur.line >= visible.to || cur.line < visible.from)
|
3763 |
-
setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
|
3764 |
-
} else {
|
3765 |
-
var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
|
3766 |
-
if (outside) setTimeout(operation(cm, function() {
|
3767 |
-
if (counter != curCount) return;
|
3768 |
-
display.scroller.scrollTop += outside;
|
3769 |
-
extend(e);
|
3770 |
-
}), 50);
|
3771 |
-
}
|
3772 |
-
}
|
3773 |
-
|
3774 |
-
function done(e) {
|
3775 |
-
cm.state.selectingText = false;
|
3776 |
-
counter = Infinity;
|
3777 |
-
e_preventDefault(e);
|
3778 |
-
display.input.focus();
|
3779 |
-
off(document, "mousemove", move);
|
3780 |
-
off(document, "mouseup", up);
|
3781 |
-
doc.history.lastSelOrigin = null;
|
3782 |
-
}
|
3783 |
-
|
3784 |
-
var move = operation(cm, function(e) {
|
3785 |
-
if (!e_button(e)) done(e);
|
3786 |
-
else extend(e);
|
3787 |
-
});
|
3788 |
-
var up = operation(cm, done);
|
3789 |
-
cm.state.selectingText = up;
|
3790 |
-
on(document, "mousemove", move);
|
3791 |
-
on(document, "mouseup", up);
|
3792 |
-
}
|
3793 |
-
|
3794 |
-
// Determines whether an event happened in the gutter, and fires the
|
3795 |
-
// handlers for the corresponding event.
|
3796 |
-
function gutterEvent(cm, e, type, prevent) {
|
3797 |
-
try { var mX = e.clientX, mY = e.clientY; }
|
3798 |
-
catch(e) { return false; }
|
3799 |
-
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
|
3800 |
-
if (prevent) e_preventDefault(e);
|
3801 |
-
|
3802 |
-
var display = cm.display;
|
3803 |
-
var lineBox = display.lineDiv.getBoundingClientRect();
|
3804 |
-
|
3805 |
-
if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
|
3806 |
-
mY -= lineBox.top - display.viewOffset;
|
3807 |
-
|
3808 |
-
for (var i = 0; i < cm.options.gutters.length; ++i) {
|
3809 |
-
var g = display.gutters.childNodes[i];
|
3810 |
-
if (g && g.getBoundingClientRect().right >= mX) {
|
3811 |
-
var line = lineAtHeight(cm.doc, mY);
|
3812 |
-
var gutter = cm.options.gutters[i];
|
3813 |
-
signal(cm, type, cm, line, gutter, e);
|
3814 |
-
return e_defaultPrevented(e);
|
3815 |
-
}
|
3816 |
-
}
|
3817 |
-
}
|
3818 |
-
|
3819 |
-
function clickInGutter(cm, e) {
|
3820 |
-
return gutterEvent(cm, e, "gutterClick", true);
|
3821 |
-
}
|
3822 |
-
|
3823 |
-
// Kludge to work around strange IE behavior where it'll sometimes
|
3824 |
-
// re-fire a series of drag-related events right after the drop (#1551)
|
3825 |
-
var lastDrop = 0;
|
3826 |
-
|
3827 |
-
function onDrop(e) {
|
3828 |
-
var cm = this;
|
3829 |
-
clearDragCursor(cm);
|
3830 |
-
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
|
3831 |
-
return;
|
3832 |
-
e_preventDefault(e);
|
3833 |
-
if (ie) lastDrop = +new Date;
|
3834 |
-
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
3835 |
-
if (!pos || isReadOnly(cm)) return;
|
3836 |
-
// Might be a file drop, in which case we simply extract the text
|
3837 |
-
// and insert it.
|
3838 |
-
if (files && files.length && window.FileReader && window.File) {
|
3839 |
-
var n = files.length, text = Array(n), read = 0;
|
3840 |
-
var loadFile = function(file, i) {
|
3841 |
-
if (cm.options.allowDropFileTypes &&
|
3842 |
-
indexOf(cm.options.allowDropFileTypes, file.type) == -1)
|
3843 |
-
return;
|
3844 |
-
|
3845 |
-
var reader = new FileReader;
|
3846 |
-
reader.onload = operation(cm, function() {
|
3847 |
-
var content = reader.result;
|
3848 |
-
if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = "";
|
3849 |
-
text[i] = content;
|
3850 |
-
if (++read == n) {
|
3851 |
-
pos = clipPos(cm.doc, pos);
|
3852 |
-
var change = {from: pos, to: pos,
|
3853 |
-
text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
|
3854 |
-
origin: "paste"};
|
3855 |
-
makeChange(cm.doc, change);
|
3856 |
-
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
|
3857 |
-
}
|
3858 |
-
});
|
3859 |
-
reader.readAsText(file);
|
3860 |
-
};
|
3861 |
-
for (var i = 0; i < n; ++i) loadFile(files[i], i);
|
3862 |
-
} else { // Normal drop
|
3863 |
-
// Don't do a replace if the drop happened inside of the selected text.
|
3864 |
-
if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
|
3865 |
-
cm.state.draggingText(e);
|
3866 |
-
// Ensure the editor is re-focused
|
3867 |
-
setTimeout(function() {cm.display.input.focus();}, 20);
|
3868 |
-
return;
|
3869 |
-
}
|
3870 |
-
try {
|
3871 |
-
var text = e.dataTransfer.getData("Text");
|
3872 |
-
if (text) {
|
3873 |
-
if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey))
|
3874 |
-
var selected = cm.listSelections();
|
3875 |
-
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
|
3876 |
-
if (selected) for (var i = 0; i < selected.length; ++i)
|
3877 |
-
replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
|
3878 |
-
cm.replaceSelection(text, "around", "paste");
|
3879 |
-
cm.display.input.focus();
|
3880 |
-
}
|
3881 |
-
}
|
3882 |
-
catch(e){}
|
3883 |
-
}
|
3884 |
-
}
|
3885 |
-
|
3886 |
-
function onDragStart(cm, e) {
|
3887 |
-
if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
|
3888 |
-
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
|
3889 |
-
|
3890 |
-
e.dataTransfer.setData("Text", cm.getSelection());
|
3891 |
-
|
3892 |
-
// Use dummy image instead of default browsers image.
|
3893 |
-
// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
|
3894 |
-
if (e.dataTransfer.setDragImage && !safari) {
|
3895 |
-
var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
|
3896 |
-
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
|
3897 |
-
if (presto) {
|
3898 |
-
img.width = img.height = 1;
|
3899 |
-
cm.display.wrapper.appendChild(img);
|
3900 |
-
// Force a relayout, or Opera won't use our image for some obscure reason
|
3901 |
-
img._top = img.offsetTop;
|
3902 |
-
}
|
3903 |
-
e.dataTransfer.setDragImage(img, 0, 0);
|
3904 |
-
if (presto) img.parentNode.removeChild(img);
|
3905 |
-
}
|
3906 |
-
}
|
3907 |
-
|
3908 |
-
function onDragOver(cm, e) {
|
3909 |
-
var pos = posFromMouse(cm, e);
|
3910 |
-
if (!pos) return;
|
3911 |
-
var frag = document.createDocumentFragment();
|
3912 |
-
drawSelectionCursor(cm, pos, frag);
|
3913 |
-
if (!cm.display.dragCursor) {
|
3914 |
-
cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
|
3915 |
-
cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
|
3916 |
-
}
|
3917 |
-
removeChildrenAndAdd(cm.display.dragCursor, frag);
|
3918 |
-
}
|
3919 |
-
|
3920 |
-
function clearDragCursor(cm) {
|
3921 |
-
if (cm.display.dragCursor) {
|
3922 |
-
cm.display.lineSpace.removeChild(cm.display.dragCursor);
|
3923 |
-
cm.display.dragCursor = null;
|
3924 |
-
}
|
3925 |
-
}
|
3926 |
-
|
3927 |
-
// SCROLL EVENTS
|
3928 |
-
|
3929 |
-
// Sync the scrollable area and scrollbars, ensure the viewport
|
3930 |
-
// covers the visible area.
|
3931 |
-
function setScrollTop(cm, val) {
|
3932 |
-
if (Math.abs(cm.doc.scrollTop - val) < 2) return;
|
3933 |
-
cm.doc.scrollTop = val;
|
3934 |
-
if (!gecko) updateDisplaySimple(cm, {top: val});
|
3935 |
-
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
|
3936 |
-
cm.display.scrollbars.setScrollTop(val);
|
3937 |
-
if (gecko) updateDisplaySimple(cm);
|
3938 |
-
startWorker(cm, 100);
|
3939 |
-
}
|
3940 |
-
// Sync scroller and scrollbar, ensure the gutter elements are
|
3941 |
-
// aligned.
|
3942 |
-
function setScrollLeft(cm, val, isScroller) {
|
3943 |
-
if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
|
3944 |
-
val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
|
3945 |
-
cm.doc.scrollLeft = val;
|
3946 |
-
alignHorizontally(cm);
|
3947 |
-
if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
|
3948 |
-
cm.display.scrollbars.setScrollLeft(val);
|
3949 |
-
}
|
3950 |
-
|
3951 |
-
// Since the delta values reported on mouse wheel events are
|
3952 |
-
// unstandardized between browsers and even browser versions, and
|
3953 |
-
// generally horribly unpredictable, this code starts by measuring
|
3954 |
-
// the scroll effect that the first few mouse wheel events have,
|
3955 |
-
// and, from that, detects the way it can convert deltas to pixel
|
3956 |
-
// offsets afterwards.
|
3957 |
-
//
|
3958 |
-
// The reason we want to know the amount a wheel event will scroll
|
3959 |
-
// is that it gives us a chance to update the display before the
|
3960 |
-
// actual scrolling happens, reducing flickering.
|
3961 |
-
|
3962 |
-
var wheelSamples = 0, wheelPixelsPerUnit = null;
|
3963 |
-
// Fill in a browser-detected starting value on browsers where we
|
3964 |
-
// know one. These don't have to be accurate -- the result of them
|
3965 |
-
// being wrong would just be a slight flicker on the first wheel
|
3966 |
-
// scroll (if it is large enough).
|
3967 |
-
if (ie) wheelPixelsPerUnit = -.53;
|
3968 |
-
else if (gecko) wheelPixelsPerUnit = 15;
|
3969 |
-
else if (chrome) wheelPixelsPerUnit = -.7;
|
3970 |
-
else if (safari) wheelPixelsPerUnit = -1/3;
|
3971 |
-
|
3972 |
-
var wheelEventDelta = function(e) {
|
3973 |
-
var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
|
3974 |
-
if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
|
3975 |
-
if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
|
3976 |
-
else if (dy == null) dy = e.wheelDelta;
|
3977 |
-
return {x: dx, y: dy};
|
3978 |
-
};
|
3979 |
-
CodeMirror.wheelEventPixels = function(e) {
|
3980 |
-
var delta = wheelEventDelta(e);
|
3981 |
-
delta.x *= wheelPixelsPerUnit;
|
3982 |
-
delta.y *= wheelPixelsPerUnit;
|
3983 |
-
return delta;
|
3984 |
-
};
|
3985 |
-
|
3986 |
-
function onScrollWheel(cm, e) {
|
3987 |
-
var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
|
3988 |
-
|
3989 |
-
var display = cm.display, scroll = display.scroller;
|
3990 |
-
// Quit if there's nothing to scroll here
|
3991 |
-
var canScrollX = scroll.scrollWidth > scroll.clientWidth;
|
3992 |
-
var canScrollY = scroll.scrollHeight > scroll.clientHeight;
|
3993 |
-
if (!(dx && canScrollX || dy && canScrollY)) return;
|
3994 |
-
|
3995 |
-
// Webkit browsers on OS X abort momentum scrolls when the target
|
3996 |
-
// of the scroll event is removed from the scrollable element.
|
3997 |
-
// This hack (see related code in patchDisplay) makes sure the
|
3998 |
-
// element is kept around.
|
3999 |
-
if (dy && mac && webkit) {
|
4000 |
-
outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
|
4001 |
-
for (var i = 0; i < view.length; i++) {
|
4002 |
-
if (view[i].node == cur) {
|
4003 |
-
cm.display.currentWheelTarget = cur;
|
4004 |
-
break outer;
|
4005 |
-
}
|
4006 |
-
}
|
4007 |
-
}
|
4008 |
-
}
|
4009 |
-
|
4010 |
-
// On some browsers, horizontal scrolling will cause redraws to
|
4011 |
-
// happen before the gutter has been realigned, causing it to
|
4012 |
-
// wriggle around in a most unseemly way. When we have an
|
4013 |
-
// estimated pixels/delta value, we just handle horizontal
|
4014 |
-
// scrolling entirely here. It'll be slightly off from native, but
|
4015 |
-
// better than glitching out.
|
4016 |
-
if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
|
4017 |
-
if (dy && canScrollY)
|
4018 |
-
setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
|
4019 |
-
setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
|
4020 |
-
// Only prevent default scrolling if vertical scrolling is
|
4021 |
-
// actually possible. Otherwise, it causes vertical scroll
|
4022 |
-
// jitter on OSX trackpads when deltaX is small and deltaY
|
4023 |
-
// is large (issue #3579)
|
4024 |
-
if (!dy || (dy && canScrollY))
|
4025 |
-
e_preventDefault(e);
|
4026 |
-
display.wheelStartX = null; // Abort measurement, if in progress
|
4027 |
-
return;
|
4028 |
-
}
|
4029 |
-
|
4030 |
-
// 'Project' the visible viewport to cover the area that is being
|
4031 |
-
// scrolled into view (if we know enough to estimate it).
|
4032 |
-
if (dy && wheelPixelsPerUnit != null) {
|
4033 |
-
var pixels = dy * wheelPixelsPerUnit;
|
4034 |
-
var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
|
4035 |
-
if (pixels < 0) top = Math.max(0, top + pixels - 50);
|
4036 |
-
else bot = Math.min(cm.doc.height, bot + pixels + 50);
|
4037 |
-
updateDisplaySimple(cm, {top: top, bottom: bot});
|
4038 |
-
}
|
4039 |
-
|
4040 |
-
if (wheelSamples < 20) {
|
4041 |
-
if (display.wheelStartX == null) {
|
4042 |
-
display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
|
4043 |
-
display.wheelDX = dx; display.wheelDY = dy;
|
4044 |
-
setTimeout(function() {
|
4045 |
-
if (display.wheelStartX == null) return;
|
4046 |
-
var movedX = scroll.scrollLeft - display.wheelStartX;
|
4047 |
-
var movedY = scroll.scrollTop - display.wheelStartY;
|
4048 |
-
var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
|
4049 |
-
(movedX && display.wheelDX && movedX / display.wheelDX);
|
4050 |
-
display.wheelStartX = display.wheelStartY = null;
|
4051 |
-
if (!sample) return;
|
4052 |
-
wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
|
4053 |
-
++wheelSamples;
|
4054 |
-
}, 200);
|
4055 |
-
} else {
|
4056 |
-
display.wheelDX += dx; display.wheelDY += dy;
|
4057 |
-
}
|
4058 |
-
}
|
4059 |
-
}
|
4060 |
-
|
4061 |
-
// KEY EVENTS
|
4062 |
-
|
4063 |
-
// Run a handler that was bound to a key.
|
4064 |
-
function doHandleBinding(cm, bound, dropShift) {
|
4065 |
-
if (typeof bound == "string") {
|
4066 |
-
bound = commands[bound];
|
4067 |
-
if (!bound) return false;
|
4068 |
-
}
|
4069 |
-
// Ensure previous input has been read, so that the handler sees a
|
4070 |
-
// consistent view of the document
|
4071 |
-
cm.display.input.ensurePolled();
|
4072 |
-
var prevShift = cm.display.shift, done = false;
|
4073 |
-
try {
|
4074 |
-
if (isReadOnly(cm)) cm.state.suppressEdits = true;
|
4075 |
-
if (dropShift) cm.display.shift = false;
|
4076 |
-
done = bound(cm) != Pass;
|
4077 |
-
} finally {
|
4078 |
-
cm.display.shift = prevShift;
|
4079 |
-
cm.state.suppressEdits = false;
|
4080 |
-
}
|
4081 |
-
return done;
|
4082 |
-
}
|
4083 |
-
|
4084 |
-
function lookupKeyForEditor(cm, name, handle) {
|
4085 |
-
for (var i = 0; i < cm.state.keyMaps.length; i++) {
|
4086 |
-
var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
|
4087 |
-
if (result) return result;
|
4088 |
-
}
|
4089 |
-
return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
|
4090 |
-
|| lookupKey(name, cm.options.keyMap, handle, cm);
|
4091 |
-
}
|
4092 |
-
|
4093 |
-
var stopSeq = new Delayed;
|
4094 |
-
function dispatchKey(cm, name, e, handle) {
|
4095 |
-
var seq = cm.state.keySeq;
|
4096 |
-
if (seq) {
|
4097 |
-
if (isModifierKey(name)) return "handled";
|
4098 |
-
stopSeq.set(50, function() {
|
4099 |
-
if (cm.state.keySeq == seq) {
|
4100 |
-
cm.state.keySeq = null;
|
4101 |
-
cm.display.input.reset();
|
4102 |
-
}
|
4103 |
-
});
|
4104 |
-
name = seq + " " + name;
|
4105 |
-
}
|
4106 |
-
var result = lookupKeyForEditor(cm, name, handle);
|
4107 |
-
|
4108 |
-
if (result == "multi")
|
4109 |
-
cm.state.keySeq = name;
|
4110 |
-
if (result == "handled")
|
4111 |
-
signalLater(cm, "keyHandled", cm, name, e);
|
4112 |
-
|
4113 |
-
if (result == "handled" || result == "multi") {
|
4114 |
-
e_preventDefault(e);
|
4115 |
-
restartBlink(cm);
|
4116 |
-
}
|
4117 |
-
|
4118 |
-
if (seq && !result && /\'$/.test(name)) {
|
4119 |
-
e_preventDefault(e);
|
4120 |
-
return true;
|
4121 |
-
}
|
4122 |
-
return !!result;
|
4123 |
-
}
|
4124 |
-
|
4125 |
-
// Handle a key from the keydown event.
|
4126 |
-
function handleKeyBinding(cm, e) {
|
4127 |
-
var name = keyName(e, true);
|
4128 |
-
if (!name) return false;
|
4129 |
-
|
4130 |
-
if (e.shiftKey && !cm.state.keySeq) {
|
4131 |
-
// First try to resolve full name (including 'Shift-'). Failing
|
4132 |
-
// that, see if there is a cursor-motion command (starting with
|
4133 |
-
// 'go') bound to the keyname without 'Shift-'.
|
4134 |
-
return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);})
|
4135 |
-
|| dispatchKey(cm, name, e, function(b) {
|
4136 |
-
if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
|
4137 |
-
return doHandleBinding(cm, b);
|
4138 |
-
});
|
4139 |
-
} else {
|
4140 |
-
return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); });
|
4141 |
-
}
|
4142 |
-
}
|
4143 |
-
|
4144 |
-
// Handle a key from the keypress event
|
4145 |
-
function handleCharBinding(cm, e, ch) {
|
4146 |
-
return dispatchKey(cm, "'" + ch + "'", e,
|
4147 |
-
function(b) { return doHandleBinding(cm, b, true); });
|
4148 |
-
}
|
4149 |
-
|
4150 |
-
var lastStoppedKey = null;
|
4151 |
-
function onKeyDown(e) {
|
4152 |
-
var cm = this;
|
4153 |
-
cm.curOp.focus = activeElt();
|
4154 |
-
if (signalDOMEvent(cm, e)) return;
|
4155 |
-
// IE does strange things with escape.
|
4156 |
-
if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
|
4157 |
-
var code = e.keyCode;
|
4158 |
-
cm.display.shift = code == 16 || e.shiftKey;
|
4159 |
-
var handled = handleKeyBinding(cm, e);
|
4160 |
-
if (presto) {
|
4161 |
-
lastStoppedKey = handled ? code : null;
|
4162 |
-
// Opera has no cut event... we try to at least catch the key combo
|
4163 |
-
if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
|
4164 |
-
cm.replaceSelection("", null, "cut");
|
4165 |
-
}
|
4166 |
-
|
4167 |
-
// Turn mouse into crosshair when Alt is held on Mac.
|
4168 |
-
if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
|
4169 |
-
showCrossHair(cm);
|
4170 |
-
}
|
4171 |
-
|
4172 |
-
function showCrossHair(cm) {
|
4173 |
-
var lineDiv = cm.display.lineDiv;
|
4174 |
-
addClass(lineDiv, "CodeMirror-crosshair");
|
4175 |
-
|
4176 |
-
function up(e) {
|
4177 |
-
if (e.keyCode == 18 || !e.altKey) {
|
4178 |
-
rmClass(lineDiv, "CodeMirror-crosshair");
|
4179 |
-
off(document, "keyup", up);
|
4180 |
-
off(document, "mouseover", up);
|
4181 |
-
}
|
4182 |
-
}
|
4183 |
-
on(document, "keyup", up);
|
4184 |
-
on(document, "mouseover", up);
|
4185 |
-
}
|
4186 |
-
|
4187 |
-
function onKeyUp(e) {
|
4188 |
-
if (e.keyCode == 16) this.doc.sel.shift = false;
|
4189 |
-
signalDOMEvent(this, e);
|
4190 |
-
}
|
4191 |
-
|
4192 |
-
function onKeyPress(e) {
|
4193 |
-
var cm = this;
|
4194 |
-
if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
|
4195 |
-
var keyCode = e.keyCode, charCode = e.charCode;
|
4196 |
-
if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
|
4197 |
-
if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return;
|
4198 |
-
var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
|
4199 |
-
if (handleCharBinding(cm, e, ch)) return;
|
4200 |
-
cm.display.input.onKeyPress(e);
|
4201 |
-
}
|
4202 |
-
|
4203 |
-
// FOCUS/BLUR EVENTS
|
4204 |
-
|
4205 |
-
function delayBlurEvent(cm) {
|
4206 |
-
cm.state.delayingBlurEvent = true;
|
4207 |
-
setTimeout(function() {
|
4208 |
-
if (cm.state.delayingBlurEvent) {
|
4209 |
-
cm.state.delayingBlurEvent = false;
|
4210 |
-
onBlur(cm);
|
4211 |
-
}
|
4212 |
-
}, 100);
|
4213 |
-
}
|
4214 |
-
|
4215 |
-
function onFocus(cm) {
|
4216 |
-
if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
|
4217 |
-
|
4218 |
-
if (cm.options.readOnly == "nocursor") return;
|
4219 |
-
if (!cm.state.focused) {
|
4220 |
-
signal(cm, "focus", cm);
|
4221 |
-
cm.state.focused = true;
|
4222 |
-
addClass(cm.display.wrapper, "CodeMirror-focused");
|
4223 |
-
// This test prevents this from firing when a context
|
4224 |
-
// menu is closed (since the input reset would kill the
|
4225 |
-
// select-all detection hack)
|
4226 |
-
if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
|
4227 |
-
cm.display.input.reset();
|
4228 |
-
if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730
|
4229 |
-
}
|
4230 |
-
cm.display.input.receivedFocus();
|
4231 |
-
}
|
4232 |
-
restartBlink(cm);
|
4233 |
-
}
|
4234 |
-
function onBlur(cm) {
|
4235 |
-
if (cm.state.delayingBlurEvent) return;
|
4236 |
-
|
4237 |
-
if (cm.state.focused) {
|
4238 |
-
signal(cm, "blur", cm);
|
4239 |
-
cm.state.focused = false;
|
4240 |
-
rmClass(cm.display.wrapper, "CodeMirror-focused");
|
4241 |
-
}
|
4242 |
-
clearInterval(cm.display.blinker);
|
4243 |
-
setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
|
4244 |
-
}
|
4245 |
-
|
4246 |
-
// CONTEXT MENU HANDLING
|
4247 |
-
|
4248 |
-
// To make the context menu work, we need to briefly unhide the
|
4249 |
-
// textarea (making it as unobtrusive as possible) to let the
|
4250 |
-
// right-click take effect on it.
|
4251 |
-
function onContextMenu(cm, e) {
|
4252 |
-
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
|
4253 |
-
if (signalDOMEvent(cm, e, "contextmenu")) return;
|
4254 |
-
cm.display.input.onContextMenu(e);
|
4255 |
-
}
|
4256 |
-
|
4257 |
-
function contextMenuInGutter(cm, e) {
|
4258 |
-
if (!hasHandler(cm, "gutterContextMenu")) return false;
|
4259 |
-
return gutterEvent(cm, e, "gutterContextMenu", false);
|
4260 |
-
}
|
4261 |
-
|
4262 |
-
// UPDATING
|
4263 |
-
|
4264 |
-
// Compute the position of the end of a change (its 'to' property
|
4265 |
-
// refers to the pre-change end).
|
4266 |
-
var changeEnd = CodeMirror.changeEnd = function(change) {
|
4267 |
-
if (!change.text) return change.to;
|
4268 |
-
return Pos(change.from.line + change.text.length - 1,
|
4269 |
-
lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
|
4270 |
-
};
|
4271 |
-
|
4272 |
-
// Adjust a position to refer to the post-change position of the
|
4273 |
-
// same text, or the end of the change if the change covers it.
|
4274 |
-
function adjustForChange(pos, change) {
|
4275 |
-
if (cmp(pos, change.from) < 0) return pos;
|
4276 |
-
if (cmp(pos, change.to) <= 0) return changeEnd(change);
|
4277 |
-
|
4278 |
-
var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
|
4279 |
-
if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
|
4280 |
-
return Pos(line, ch);
|
4281 |
-
}
|
4282 |
-
|
4283 |
-
function computeSelAfterChange(doc, change) {
|
4284 |
-
var out = [];
|
4285 |
-
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
4286 |
-
var range = doc.sel.ranges[i];
|
4287 |
-
out.push(new Range(adjustForChange(range.anchor, change),
|
4288 |
-
adjustForChange(range.head, change)));
|
4289 |
-
}
|
4290 |
-
return normalizeSelection(out, doc.sel.primIndex);
|
4291 |
-
}
|
4292 |
-
|
4293 |
-
function offsetPos(pos, old, nw) {
|
4294 |
-
if (pos.line == old.line)
|
4295 |
-
return Pos(nw.line, pos.ch - old.ch + nw.ch);
|
4296 |
-
else
|
4297 |
-
return Pos(nw.line + (pos.line - old.line), pos.ch);
|
4298 |
-
}
|
4299 |
-
|
4300 |
-
// Used by replaceSelections to allow moving the selection to the
|
4301 |
-
// start or around the replaced test. Hint may be "start" or "around".
|
4302 |
-
function computeReplacedSel(doc, changes, hint) {
|
4303 |
-
var out = [];
|
4304 |
-
var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
|
4305 |
-
for (var i = 0; i < changes.length; i++) {
|
4306 |
-
var change = changes[i];
|
4307 |
-
var from = offsetPos(change.from, oldPrev, newPrev);
|
4308 |
-
var to = offsetPos(changeEnd(change), oldPrev, newPrev);
|
4309 |
-
oldPrev = change.to;
|
4310 |
-
newPrev = to;
|
4311 |
-
if (hint == "around") {
|
4312 |
-
var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
|
4313 |
-
out[i] = new Range(inv ? to : from, inv ? from : to);
|
4314 |
-
} else {
|
4315 |
-
out[i] = new Range(from, from);
|
4316 |
-
}
|
4317 |
-
}
|
4318 |
-
return new Selection(out, doc.sel.primIndex);
|
4319 |
-
}
|
4320 |
-
|
4321 |
-
// Allow "beforeChange" event handlers to influence a change
|
4322 |
-
function filterChange(doc, change, update) {
|
4323 |
-
var obj = {
|
4324 |
-
canceled: false,
|
4325 |
-
from: change.from,
|
4326 |
-
to: change.to,
|
4327 |
-
text: change.text,
|
4328 |
-
origin: change.origin,
|
4329 |
-
cancel: function() { this.canceled = true; }
|
4330 |
-
};
|
4331 |
-
if (update) obj.update = function(from, to, text, origin) {
|
4332 |
-
if (from) this.from = clipPos(doc, from);
|
4333 |
-
if (to) this.to = clipPos(doc, to);
|
4334 |
-
if (text) this.text = text;
|
4335 |
-
if (origin !== undefined) this.origin = origin;
|
4336 |
-
};
|
4337 |
-
signal(doc, "beforeChange", doc, obj);
|
4338 |
-
if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
|
4339 |
-
|
4340 |
-
if (obj.canceled) return null;
|
4341 |
-
return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
|
4342 |
-
}
|
4343 |
-
|
4344 |
-
// Apply a change to a document, and add it to the document's
|
4345 |
-
// history, and propagating it to all linked documents.
|
4346 |
-
function makeChange(doc, change, ignoreReadOnly) {
|
4347 |
-
if (doc.cm) {
|
4348 |
-
if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
|
4349 |
-
if (doc.cm.state.suppressEdits) return;
|
4350 |
-
}
|
4351 |
-
|
4352 |
-
if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
|
4353 |
-
change = filterChange(doc, change, true);
|
4354 |
-
if (!change) return;
|
4355 |
-
}
|
4356 |
-
|
4357 |
-
// Possibly split or suppress the update based on the presence
|
4358 |
-
// of read-only spans in its range.
|
4359 |
-
var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
|
4360 |
-
if (split) {
|
4361 |
-
for (var i = split.length - 1; i >= 0; --i)
|
4362 |
-
makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
|
4363 |
-
} else {
|
4364 |
-
makeChangeInner(doc, change);
|
4365 |
-
}
|
4366 |
-
}
|
4367 |
-
|
4368 |
-
function makeChangeInner(doc, change) {
|
4369 |
-
if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
|
4370 |
-
var selAfter = computeSelAfterChange(doc, change);
|
4371 |
-
addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
|
4372 |
-
|
4373 |
-
makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
|
4374 |
-
var rebased = [];
|
4375 |
-
|
4376 |
-
linkedDocs(doc, function(doc, sharedHist) {
|
4377 |
-
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
|
4378 |
-
rebaseHist(doc.history, change);
|
4379 |
-
rebased.push(doc.history);
|
4380 |
-
}
|
4381 |
-
makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
|
4382 |
-
});
|
4383 |
-
}
|
4384 |
-
|
4385 |
-
// Revert a change stored in a document's history.
|
4386 |
-
function makeChangeFromHistory(doc, type, allowSelectionOnly) {
|
4387 |
-
if (doc.cm && doc.cm.state.suppressEdits) return;
|
4388 |
-
|
4389 |
-
var hist = doc.history, event, selAfter = doc.sel;
|
4390 |
-
var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
|
4391 |
-
|
4392 |
-
// Verify that there is a useable event (so that ctrl-z won't
|
4393 |
-
// needlessly clear selection events)
|
4394 |
-
for (var i = 0; i < source.length; i++) {
|
4395 |
-
event = source[i];
|
4396 |
-
if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
|
4397 |
-
break;
|
4398 |
-
}
|
4399 |
-
if (i == source.length) return;
|
4400 |
-
hist.lastOrigin = hist.lastSelOrigin = null;
|
4401 |
-
|
4402 |
-
for (;;) {
|
4403 |
-
event = source.pop();
|
4404 |
-
if (event.ranges) {
|
4405 |
-
pushSelectionToHistory(event, dest);
|
4406 |
-
if (allowSelectionOnly && !event.equals(doc.sel)) {
|
4407 |
-
setSelection(doc, event, {clearRedo: false});
|
4408 |
-
return;
|
4409 |
-
}
|
4410 |
-
selAfter = event;
|
4411 |
-
}
|
4412 |
-
else break;
|
4413 |
-
}
|
4414 |
-
|
4415 |
-
// Build up a reverse change object to add to the opposite history
|
4416 |
-
// stack (redo when undoing, and vice versa).
|
4417 |
-
var antiChanges = [];
|
4418 |
-
pushSelectionToHistory(selAfter, dest);
|
4419 |
-
dest.push({changes: antiChanges, generation: hist.generation});
|
4420 |
-
hist.generation = event.generation || ++hist.maxGeneration;
|
4421 |
-
|
4422 |
-
var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
|
4423 |
-
|
4424 |
-
for (var i = event.changes.length - 1; i >= 0; --i) {
|
4425 |
-
var change = event.changes[i];
|
4426 |
-
change.origin = type;
|
4427 |
-
if (filter && !filterChange(doc, change, false)) {
|
4428 |
-
source.length = 0;
|
4429 |
-
return;
|
4430 |
-
}
|
4431 |
-
|
4432 |
-
antiChanges.push(historyChangeFromChange(doc, change));
|
4433 |
-
|
4434 |
-
var after = i ? computeSelAfterChange(doc, change) : lst(source);
|
4435 |
-
makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
|
4436 |
-
if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)});
|
4437 |
-
var rebased = [];
|
4438 |
-
|
4439 |
-
// Propagate to the linked documents
|
4440 |
-
linkedDocs(doc, function(doc, sharedHist) {
|
4441 |
-
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
|
4442 |
-
rebaseHist(doc.history, change);
|
4443 |
-
rebased.push(doc.history);
|
4444 |
-
}
|
4445 |
-
makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
|
4446 |
-
});
|
4447 |
-
}
|
4448 |
-
}
|
4449 |
-
|
4450 |
-
// Sub-views need their line numbers shifted when text is added
|
4451 |
-
// above or below them in the parent document.
|
4452 |
-
function shiftDoc(doc, distance) {
|
4453 |
-
if (distance == 0) return;
|
4454 |
-
doc.first += distance;
|
4455 |
-
doc.sel = new Selection(map(doc.sel.ranges, function(range) {
|
4456 |
-
return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
|
4457 |
-
Pos(range.head.line + distance, range.head.ch));
|
4458 |
-
}), doc.sel.primIndex);
|
4459 |
-
if (doc.cm) {
|
4460 |
-
regChange(doc.cm, doc.first, doc.first - distance, distance);
|
4461 |
-
for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
|
4462 |
-
regLineChange(doc.cm, l, "gutter");
|
4463 |
-
}
|
4464 |
-
}
|
4465 |
-
|
4466 |
-
// More lower-level change function, handling only a single document
|
4467 |
-
// (not linked ones).
|
4468 |
-
function makeChangeSingleDoc(doc, change, selAfter, spans) {
|
4469 |
-
if (doc.cm && !doc.cm.curOp)
|
4470 |
-
return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
|
4471 |
-
|
4472 |
-
if (change.to.line < doc.first) {
|
4473 |
-
shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
|
4474 |
-
return;
|
4475 |
-
}
|
4476 |
-
if (change.from.line > doc.lastLine()) return;
|
4477 |
-
|
4478 |
-
// Clip the change to the size of this doc
|
4479 |
-
if (change.from.line < doc.first) {
|
4480 |
-
var shift = change.text.length - 1 - (doc.first - change.from.line);
|
4481 |
-
shiftDoc(doc, shift);
|
4482 |
-
change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
|
4483 |
-
text: [lst(change.text)], origin: change.origin};
|
4484 |
-
}
|
4485 |
-
var last = doc.lastLine();
|
4486 |
-
if (change.to.line > last) {
|
4487 |
-
change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
|
4488 |
-
text: [change.text[0]], origin: change.origin};
|
4489 |
-
}
|
4490 |
-
|
4491 |
-
change.removed = getBetween(doc, change.from, change.to);
|
4492 |
-
|
4493 |
-
if (!selAfter) selAfter = computeSelAfterChange(doc, change);
|
4494 |
-
if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
|
4495 |
-
else updateDoc(doc, change, spans);
|
4496 |
-
setSelectionNoUndo(doc, selAfter, sel_dontScroll);
|
4497 |
-
}
|
4498 |
-
|
4499 |
-
// Handle the interaction of a change to a document with the editor
|
4500 |
-
// that this document is part of.
|
4501 |
-
function makeChangeSingleDocInEditor(cm, change, spans) {
|
4502 |
-
var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
|
4503 |
-
|
4504 |
-
var recomputeMaxLength = false, checkWidthStart = from.line;
|
4505 |
-
if (!cm.options.lineWrapping) {
|
4506 |
-
checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
|
4507 |
-
doc.iter(checkWidthStart, to.line + 1, function(line) {
|
4508 |
-
if (line == display.maxLine) {
|
4509 |
-
recomputeMaxLength = true;
|
4510 |
-
return true;
|
4511 |
-
}
|
4512 |
-
});
|
4513 |
-
}
|
4514 |
-
|
4515 |
-
if (doc.sel.contains(change.from, change.to) > -1)
|
4516 |
-
signalCursorActivity(cm);
|
4517 |
-
|
4518 |
-
updateDoc(doc, change, spans, estimateHeight(cm));
|
4519 |
-
|
4520 |
-
if (!cm.options.lineWrapping) {
|
4521 |
-
doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
|
4522 |
-
var len = lineLength(line);
|
4523 |
-
if (len > display.maxLineLength) {
|
4524 |
-
display.maxLine = line;
|
4525 |
-
display.maxLineLength = len;
|
4526 |
-
display.maxLineChanged = true;
|
4527 |
-
recomputeMaxLength = false;
|
4528 |
-
}
|
4529 |
-
});
|
4530 |
-
if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
|
4531 |
-
}
|
4532 |
-
|
4533 |
-
// Adjust frontier, schedule worker
|
4534 |
-
doc.frontier = Math.min(doc.frontier, from.line);
|
4535 |
-
startWorker(cm, 400);
|
4536 |
-
|
4537 |
-
var lendiff = change.text.length - (to.line - from.line) - 1;
|
4538 |
-
// Remember that these lines changed, for updating the display
|
4539 |
-
if (change.full)
|
4540 |
-
regChange(cm);
|
4541 |
-
else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
|
4542 |
-
regLineChange(cm, from.line, "text");
|
4543 |
-
else
|
4544 |
-
regChange(cm, from.line, to.line + 1, lendiff);
|
4545 |
-
|
4546 |
-
var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
|
4547 |
-
if (changeHandler || changesHandler) {
|
4548 |
-
var obj = {
|
4549 |
-
from: from, to: to,
|
4550 |
-
text: change.text,
|
4551 |
-
removed: change.removed,
|
4552 |
-
origin: change.origin
|
4553 |
-
};
|
4554 |
-
if (changeHandler) signalLater(cm, "change", cm, obj);
|
4555 |
-
if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
|
4556 |
-
}
|
4557 |
-
cm.display.selForContextMenu = null;
|
4558 |
-
}
|
4559 |
-
|
4560 |
-
function replaceRange(doc, code, from, to, origin) {
|
4561 |
-
if (!to) to = from;
|
4562 |
-
if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
|
4563 |
-
if (typeof code == "string") code = doc.splitLines(code);
|
4564 |
-
makeChange(doc, {from: from, to: to, text: code, origin: origin});
|
4565 |
-
}
|
4566 |
-
|
4567 |
-
// SCROLLING THINGS INTO VIEW
|
4568 |
-
|
4569 |
-
// If an editor sits on the top or bottom of the window, partially
|
4570 |
-
// scrolled out of view, this ensures that the cursor is visible.
|
4571 |
-
function maybeScrollWindow(cm, coords) {
|
4572 |
-
if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
|
4573 |
-
|
4574 |
-
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
|
4575 |
-
if (coords.top + box.top < 0) doScroll = true;
|
4576 |
-
else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
|
4577 |
-
if (doScroll != null && !phantom) {
|
4578 |
-
var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
|
4579 |
-
(coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
|
4580 |
-
(coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
|
4581 |
-
coords.left + "px; width: 2px;");
|
4582 |
-
cm.display.lineSpace.appendChild(scrollNode);
|
4583 |
-
scrollNode.scrollIntoView(doScroll);
|
4584 |
-
cm.display.lineSpace.removeChild(scrollNode);
|
4585 |
-
}
|
4586 |
-
}
|
4587 |
-
|
4588 |
-
// Scroll a given position into view (immediately), verifying that
|
4589 |
-
// it actually became visible (as line heights are accurately
|
4590 |
-
// measured, the position of something may 'drift' during drawing).
|
4591 |
-
function scrollPosIntoView(cm, pos, end, margin) {
|
4592 |
-
if (margin == null) margin = 0;
|
4593 |
-
for (var limit = 0; limit < 5; limit++) {
|
4594 |
-
var changed = false, coords = cursorCoords(cm, pos);
|
4595 |
-
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
|
4596 |
-
var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
|
4597 |
-
Math.min(coords.top, endCoords.top) - margin,
|
4598 |
-
Math.max(coords.left, endCoords.left),
|
4599 |
-
Math.max(coords.bottom, endCoords.bottom) + margin);
|
4600 |
-
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
|
4601 |
-
if (scrollPos.scrollTop != null) {
|
4602 |
-
setScrollTop(cm, scrollPos.scrollTop);
|
4603 |
-
if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
|
4604 |
-
}
|
4605 |
-
if (scrollPos.scrollLeft != null) {
|
4606 |
-
setScrollLeft(cm, scrollPos.scrollLeft);
|
4607 |
-
if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
|
4608 |
-
}
|
4609 |
-
if (!changed) break;
|
4610 |
-
}
|
4611 |
-
return coords;
|
4612 |
-
}
|
4613 |
-
|
4614 |
-
// Scroll a given set of coordinates into view (immediately).
|
4615 |
-
function scrollIntoView(cm, x1, y1, x2, y2) {
|
4616 |
-
var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
|
4617 |
-
if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
|
4618 |
-
if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
|
4619 |
-
}
|
4620 |
-
|
4621 |
-
// Calculate a new scroll position needed to scroll the given
|
4622 |
-
// rectangle into view. Returns an object with scrollTop and
|
4623 |
-
// scrollLeft properties. When these are undefined, the
|
4624 |
-
// vertical/horizontal position does not need to be adjusted.
|
4625 |
-
function calculateScrollPos(cm, x1, y1, x2, y2) {
|
4626 |
-
var display = cm.display, snapMargin = textHeight(cm.display);
|
4627 |
-
if (y1 < 0) y1 = 0;
|
4628 |
-
var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
|
4629 |
-
var screen = displayHeight(cm), result = {};
|
4630 |
-
if (y2 - y1 > screen) y2 = y1 + screen;
|
4631 |
-
var docBottom = cm.doc.height + paddingVert(display);
|
4632 |
-
var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
|
4633 |
-
if (y1 < screentop) {
|
4634 |
-
result.scrollTop = atTop ? 0 : y1;
|
4635 |
-
} else if (y2 > screentop + screen) {
|
4636 |
-
var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
|
4637 |
-
if (newTop != screentop) result.scrollTop = newTop;
|
4638 |
-
}
|
4639 |
-
|
4640 |
-
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
|
4641 |
-
var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
|
4642 |
-
var tooWide = x2 - x1 > screenw;
|
4643 |
-
if (tooWide) x2 = x1 + screenw;
|
4644 |
-
if (x1 < 10)
|
4645 |
-
result.scrollLeft = 0;
|
4646 |
-
else if (x1 < screenleft)
|
4647 |
-
result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10));
|
4648 |
-
else if (x2 > screenw + screenleft - 3)
|
4649 |
-
result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw;
|
4650 |
-
return result;
|
4651 |
-
}
|
4652 |
-
|
4653 |
-
// Store a relative adjustment to the scroll position in the current
|
4654 |
-
// operation (to be applied when the operation finishes).
|
4655 |
-
function addToScrollPos(cm, left, top) {
|
4656 |
-
if (left != null || top != null) resolveScrollToPos(cm);
|
4657 |
-
if (left != null)
|
4658 |
-
cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
|
4659 |
-
if (top != null)
|
4660 |
-
cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
|
4661 |
-
}
|
4662 |
-
|
4663 |
-
// Make sure that at the end of the operation the current cursor is
|
4664 |
-
// shown.
|
4665 |
-
function ensureCursorVisible(cm) {
|
4666 |
-
resolveScrollToPos(cm);
|
4667 |
-
var cur = cm.getCursor(), from = cur, to = cur;
|
4668 |
-
if (!cm.options.lineWrapping) {
|
4669 |
-
from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
|
4670 |
-
to = Pos(cur.line, cur.ch + 1);
|
4671 |
-
}
|
4672 |
-
cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
|
4673 |
-
}
|
4674 |
-
|
4675 |
-
// When an operation has its scrollToPos property set, and another
|
4676 |
-
// scroll action is applied before the end of the operation, this
|
4677 |
-
// 'simulates' scrolling that position into view in a cheap way, so
|
4678 |
-
// that the effect of intermediate scroll commands is not ignored.
|
4679 |
-
function resolveScrollToPos(cm) {
|
4680 |
-
var range = cm.curOp.scrollToPos;
|
4681 |
-
if (range) {
|
4682 |
-
cm.curOp.scrollToPos = null;
|
4683 |
-
var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
|
4684 |
-
var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
|
4685 |
-
Math.min(from.top, to.top) - range.margin,
|
4686 |
-
Math.max(from.right, to.right),
|
4687 |
-
Math.max(from.bottom, to.bottom) + range.margin);
|
4688 |
-
cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
|
4689 |
-
}
|
4690 |
-
}
|
4691 |
-
|
4692 |
-
// API UTILITIES
|
4693 |
-
|
4694 |
-
// Indent the given line. The how parameter can be "smart",
|
4695 |
-
// "add"/null, "subtract", or "prev". When aggressive is false
|
4696 |
-
// (typically set to true for forced single-line indents), empty
|
4697 |
-
// lines are not indented, and places where the mode returns Pass
|
4698 |
-
// are left alone.
|
4699 |
-
function indentLine(cm, n, how, aggressive) {
|
4700 |
-
var doc = cm.doc, state;
|
4701 |
-
if (how == null) how = "add";
|
4702 |
-
if (how == "smart") {
|
4703 |
-
// Fall back to "prev" when the mode doesn't have an indentation
|
4704 |
-
// method.
|
4705 |
-
if (!doc.mode.indent) how = "prev";
|
4706 |
-
else state = getStateBefore(cm, n);
|
4707 |
-
}
|
4708 |
-
|
4709 |
-
var tabSize = cm.options.tabSize;
|
4710 |
-
var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
|
4711 |
-
if (line.stateAfter) line.stateAfter = null;
|
4712 |
-
var curSpaceString = line.text.match(/^\s*/)[0], indentation;
|
4713 |
-
if (!aggressive && !/\S/.test(line.text)) {
|
4714 |
-
indentation = 0;
|
4715 |
-
how = "not";
|
4716 |
-
} else if (how == "smart") {
|
4717 |
-
indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
|
4718 |
-
if (indentation == Pass || indentation > 150) {
|
4719 |
-
if (!aggressive) return;
|
4720 |
-
how = "prev";
|
4721 |
-
}
|
4722 |
-
}
|
4723 |
-
if (how == "prev") {
|
4724 |
-
if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
|
4725 |
-
else indentation = 0;
|
4726 |
-
} else if (how == "add") {
|
4727 |
-
indentation = curSpace + cm.options.indentUnit;
|
4728 |
-
} else if (how == "subtract") {
|
4729 |
-
indentation = curSpace - cm.options.indentUnit;
|
4730 |
-
} else if (typeof how == "number") {
|
4731 |
-
indentation = curSpace + how;
|
4732 |
-
}
|
4733 |
-
indentation = Math.max(0, indentation);
|
4734 |
-
|
4735 |
-
var indentString = "", pos = 0;
|
4736 |
-
if (cm.options.indentWithTabs)
|
4737 |
-
for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
|
4738 |
-
if (pos < indentation) indentString += spaceStr(indentation - pos);
|
4739 |
-
|
4740 |
-
if (indentString != curSpaceString) {
|
4741 |
-
replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
|
4742 |
-
line.stateAfter = null;
|
4743 |
-
return true;
|
4744 |
-
} else {
|
4745 |
-
// Ensure that, if the cursor was in the whitespace at the start
|
4746 |
-
// of the line, it is moved to the end of that space.
|
4747 |
-
for (var i = 0; i < doc.sel.ranges.length; i++) {
|
4748 |
-
var range = doc.sel.ranges[i];
|
4749 |
-
if (range.head.line == n && range.head.ch < curSpaceString.length) {
|
4750 |
-
var pos = Pos(n, curSpaceString.length);
|
4751 |
-
replaceOneSelection(doc, i, new Range(pos, pos));
|
4752 |
-
break;
|
4753 |
-
}
|
4754 |
-
}
|
4755 |
-
}
|
4756 |
-
}
|
4757 |
-
|
4758 |
-
// Utility for applying a change to a line by handle or number,
|
4759 |
-
// returning the number and optionally registering the line as
|
4760 |
-
// changed.
|
4761 |
-
function changeLine(doc, handle, changeType, op) {
|
4762 |
-
var no = handle, line = handle;
|
4763 |
-
if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
|
4764 |
-
else no = lineNo(handle);
|
4765 |
-
if (no == null) return null;
|
4766 |
-
if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType);
|
4767 |
-
return line;
|
4768 |
-
}
|
4769 |
-
|
4770 |
-
// Helper for deleting text near the selection(s), used to implement
|
4771 |
-
// backspace, delete, and similar functionality.
|
4772 |
-
function deleteNearSelection(cm, compute) {
|
4773 |
-
var ranges = cm.doc.sel.ranges, kill = [];
|
4774 |
-
// Build up a set of ranges to kill first, merging overlapping
|
4775 |
-
// ranges.
|
4776 |
-
for (var i = 0; i < ranges.length; i++) {
|
4777 |
-
var toKill = compute(ranges[i]);
|
4778 |
-
while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
|
4779 |
-
var replaced = kill.pop();
|
4780 |
-
if (cmp(replaced.from, toKill.from) < 0) {
|
4781 |
-
toKill.from = replaced.from;
|
4782 |
-
break;
|
4783 |
-
}
|
4784 |
-
}
|
4785 |
-
kill.push(toKill);
|
4786 |
-
}
|
4787 |
-
// Next, remove those actual ranges.
|
4788 |
-
runInOp(cm, function() {
|
4789 |
-
for (var i = kill.length - 1; i >= 0; i--)
|
4790 |
-
replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
|
4791 |
-
ensureCursorVisible(cm);
|
4792 |
-
});
|
4793 |
-
}
|
4794 |
-
|
4795 |
-
// Used for horizontal relative motion. Dir is -1 or 1 (left or
|
4796 |
-
// right), unit can be "char", "column" (like char, but doesn't
|
4797 |
-
// cross line boundaries), "word" (across next word), or "group" (to
|
4798 |
-
// the start of next group of word or non-word-non-whitespace
|
4799 |
-
// chars). The visually param controls whether, in right-to-left
|
4800 |
-
// text, direction 1 means to move towards the next index in the
|
4801 |
-
// string, or towards the character to the right of the current
|
4802 |
-
// position. The resulting position will have a hitSide=true
|
4803 |
-
// property if it reached the end of the document.
|
4804 |
-
function findPosH(doc, pos, dir, unit, visually) {
|
4805 |
-
var line = pos.line, ch = pos.ch, origDir = dir;
|
4806 |
-
var lineObj = getLine(doc, line);
|
4807 |
-
var possible = true;
|
4808 |
-
function findNextLine() {
|
4809 |
-
var l = line + dir;
|
4810 |
-
if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
|
4811 |
-
line = l;
|
4812 |
-
return lineObj = getLine(doc, l);
|
4813 |
-
}
|
4814 |
-
function moveOnce(boundToLine) {
|
4815 |
-
var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
|
4816 |
-
if (next == null) {
|
4817 |
-
if (!boundToLine && findNextLine()) {
|
4818 |
-
if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
|
4819 |
-
else ch = dir < 0 ? lineObj.text.length : 0;
|
4820 |
-
} else return (possible = false);
|
4821 |
-
} else ch = next;
|
4822 |
-
return true;
|
4823 |
-
}
|
4824 |
-
|
4825 |
-
if (unit == "char") moveOnce();
|
4826 |
-
else if (unit == "column") moveOnce(true);
|
4827 |
-
else if (unit == "word" || unit == "group") {
|
4828 |
-
var sawType = null, group = unit == "group";
|
4829 |
-
var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
|
4830 |
-
for (var first = true;; first = false) {
|
4831 |
-
if (dir < 0 && !moveOnce(!first)) break;
|
4832 |
-
var cur = lineObj.text.charAt(ch) || "\n";
|
4833 |
-
var type = isWordChar(cur, helper) ? "w"
|
4834 |
-
: group && cur == "\n" ? "n"
|
4835 |
-
: !group || /\s/.test(cur) ? null
|
4836 |
-
: "p";
|
4837 |
-
if (group && !first && !type) type = "s";
|
4838 |
-
if (sawType && sawType != type) {
|
4839 |
-
if (dir < 0) {dir = 1; moveOnce();}
|
4840 |
-
break;
|
4841 |
-
}
|
4842 |
-
|
4843 |
-
if (type) sawType = type;
|
4844 |
-
if (dir > 0 && !moveOnce(!first)) break;
|
4845 |
-
}
|
4846 |
-
}
|
4847 |
-
var result = skipAtomic(doc, Pos(line, ch), origDir, true);
|
4848 |
-
if (!possible) result.hitSide = true;
|
4849 |
-
return result;
|
4850 |
-
}
|
4851 |
-
|
4852 |
-
// For relative vertical movement. Dir may be -1 or 1. Unit can be
|
4853 |
-
// "page" or "line". The resulting position will have a hitSide=true
|
4854 |
-
// property if it reached the end of the document.
|
4855 |
-
function findPosV(cm, pos, dir, unit) {
|
4856 |
-
var doc = cm.doc, x = pos.left, y;
|
4857 |
-
if (unit == "page") {
|
4858 |
-
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
|
4859 |
-
y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
|
4860 |
-
} else if (unit == "line") {
|
4861 |
-
y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
|
4862 |
-
}
|
4863 |
-
for (;;) {
|
4864 |
-
var target = coordsChar(cm, x, y);
|
4865 |
-
if (!target.outside) break;
|
4866 |
-
if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
|
4867 |
-
y += dir * 5;
|
4868 |
-
}
|
4869 |
-
return target;
|
4870 |
-
}
|
4871 |
-
|
4872 |
-
// EDITOR METHODS
|
4873 |
-
|
4874 |
-
// The publicly visible API. Note that methodOp(f) means
|
4875 |
-
// 'wrap f in an operation, performed on its `this` parameter'.
|
4876 |
-
|
4877 |
-
// This is not the complete set of editor methods. Most of the
|
4878 |
-
// methods defined on the Doc type are also injected into
|
4879 |
-
// CodeMirror.prototype, for backwards compatibility and
|
4880 |
-
// convenience.
|
4881 |
-
|
4882 |
-
CodeMirror.prototype = {
|
4883 |
-
constructor: CodeMirror,
|
4884 |
-
focus: function(){window.focus(); this.display.input.focus();},
|
4885 |
-
|
4886 |
-
setOption: function(option, value) {
|
4887 |
-
var options = this.options, old = options[option];
|
4888 |
-
if (options[option] == value && option != "mode") return;
|
4889 |
-
options[option] = value;
|
4890 |
-
if (optionHandlers.hasOwnProperty(option))
|
4891 |
-
operation(this, optionHandlers[option])(this, value, old);
|
4892 |
-
},
|
4893 |
-
|
4894 |
-
getOption: function(option) {return this.options[option];},
|
4895 |
-
getDoc: function() {return this.doc;},
|
4896 |
-
|
4897 |
-
addKeyMap: function(map, bottom) {
|
4898 |
-
this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map));
|
4899 |
-
},
|
4900 |
-
removeKeyMap: function(map) {
|
4901 |
-
var maps = this.state.keyMaps;
|
4902 |
-
for (var i = 0; i < maps.length; ++i)
|
4903 |
-
if (maps[i] == map || maps[i].name == map) {
|
4904 |
-
maps.splice(i, 1);
|
4905 |
-
return true;
|
4906 |
-
}
|
4907 |
-
},
|
4908 |
-
|
4909 |
-
addOverlay: methodOp(function(spec, options) {
|
4910 |
-
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
|
4911 |
-
if (mode.startState) throw new Error("Overlays may not be stateful.");
|
4912 |
-
this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
|
4913 |
-
this.state.modeGen++;
|
4914 |
-
regChange(this);
|
4915 |
-
}),
|
4916 |
-
removeOverlay: methodOp(function(spec) {
|
4917 |
-
var overlays = this.state.overlays;
|
4918 |
-
for (var i = 0; i < overlays.length; ++i) {
|
4919 |
-
var cur = overlays[i].modeSpec;
|
4920 |
-
if (cur == spec || typeof spec == "string" && cur.name == spec) {
|
4921 |
-
overlays.splice(i, 1);
|
4922 |
-
this.state.modeGen++;
|
4923 |
-
regChange(this);
|
4924 |
-
return;
|
4925 |
-
}
|
4926 |
-
}
|
4927 |
-
}),
|
4928 |
-
|
4929 |
-
indentLine: methodOp(function(n, dir, aggressive) {
|
4930 |
-
if (typeof dir != "string" && typeof dir != "number") {
|
4931 |
-
if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
|
4932 |
-
else dir = dir ? "add" : "subtract";
|
4933 |
-
}
|
4934 |
-
if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
|
4935 |
-
}),
|
4936 |
-
indentSelection: methodOp(function(how) {
|
4937 |
-
var ranges = this.doc.sel.ranges, end = -1;
|
4938 |
-
for (var i = 0; i < ranges.length; i++) {
|
4939 |
-
var range = ranges[i];
|
4940 |
-
if (!range.empty()) {
|
4941 |
-
var from = range.from(), to = range.to();
|
4942 |
-
var start = Math.max(end, from.line);
|
4943 |
-
end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
|
4944 |
-
for (var j = start; j < end; ++j)
|
4945 |
-
indentLine(this, j, how);
|
4946 |
-
var newRanges = this.doc.sel.ranges;
|
4947 |
-
if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
|
4948 |
-
replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll);
|
4949 |
-
} else if (range.head.line > end) {
|
4950 |
-
indentLine(this, range.head.line, how, true);
|
4951 |
-
end = range.head.line;
|
4952 |
-
if (i == this.doc.sel.primIndex) ensureCursorVisible(this);
|
4953 |
-
}
|
4954 |
-
}
|
4955 |
-
}),
|
4956 |
-
|
4957 |
-
// Fetch the parser token for a given character. Useful for hacks
|
4958 |
-
// that want to inspect the mode state (say, for completion).
|
4959 |
-
getTokenAt: function(pos, precise) {
|
4960 |
-
return takeToken(this, pos, precise);
|
4961 |
-
},
|
4962 |
-
|
4963 |
-
getLineTokens: function(line, precise) {
|
4964 |
-
return takeToken(this, Pos(line), precise, true);
|
4965 |
-
},
|
4966 |
-
|
4967 |
-
getTokenTypeAt: function(pos) {
|
4968 |
-
pos = clipPos(this.doc, pos);
|
4969 |
-
var styles = getLineStyles(this, getLine(this.doc, pos.line));
|
4970 |
-
var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
|
4971 |
-
var type;
|
4972 |
-
if (ch == 0) type = styles[2];
|
4973 |
-
else for (;;) {
|
4974 |
-
var mid = (before + after) >> 1;
|
4975 |
-
if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
|
4976 |
-
else if (styles[mid * 2 + 1] < ch) before = mid + 1;
|
4977 |
-
else { type = styles[mid * 2 + 2]; break; }
|
4978 |
-
}
|
4979 |
-
var cut = type ? type.indexOf("cm-overlay ") : -1;
|
4980 |
-
return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
|
4981 |
-
},
|
4982 |
-
|
4983 |
-
getModeAt: function(pos) {
|
4984 |
-
var mode = this.doc.mode;
|
4985 |
-
if (!mode.innerMode) return mode;
|
4986 |
-
return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
|
4987 |
-
},
|
4988 |
-
|
4989 |
-
getHelper: function(pos, type) {
|
4990 |
-
return this.getHelpers(pos, type)[0];
|
4991 |
-
},
|
4992 |
-
|
4993 |
-
getHelpers: function(pos, type) {
|
4994 |
-
var found = [];
|
4995 |
-
if (!helpers.hasOwnProperty(type)) return found;
|
4996 |
-
var help = helpers[type], mode = this.getModeAt(pos);
|
4997 |
-
if (typeof mode[type] == "string") {
|
4998 |
-
if (help[mode[type]]) found.push(help[mode[type]]);
|
4999 |
-
} else if (mode[type]) {
|
5000 |
-
for (var i = 0; i < mode[type].length; i++) {
|
5001 |
-
var val = help[mode[type][i]];
|
5002 |
-
if (val) found.push(val);
|
5003 |
-
}
|
5004 |
-
} else if (mode.helperType && help[mode.helperType]) {
|
5005 |
-
found.push(help[mode.helperType]);
|
5006 |
-
} else if (help[mode.name]) {
|
5007 |
-
found.push(help[mode.name]);
|
5008 |
-
}
|
5009 |
-
for (var i = 0; i < help._global.length; i++) {
|
5010 |
-
var cur = help._global[i];
|
5011 |
-
if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
|
5012 |
-
found.push(cur.val);
|
5013 |
-
}
|
5014 |
-
return found;
|
5015 |
-
},
|
5016 |
-
|
5017 |
-
getStateAfter: function(line, precise) {
|
5018 |
-
var doc = this.doc;
|
5019 |
-
line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
|
5020 |
-
return getStateBefore(this, line + 1, precise);
|
5021 |
-
},
|
5022 |
-
|
5023 |
-
cursorCoords: function(start, mode) {
|
5024 |
-
var pos, range = this.doc.sel.primary();
|
5025 |
-
if (start == null) pos = range.head;
|
5026 |
-
else if (typeof start == "object") pos = clipPos(this.doc, start);
|
5027 |
-
else pos = start ? range.from() : range.to();
|
5028 |
-
return cursorCoords(this, pos, mode || "page");
|
5029 |
-
},
|
5030 |
-
|
5031 |
-
charCoords: function(pos, mode) {
|
5032 |
-
return charCoords(this, clipPos(this.doc, pos), mode || "page");
|
5033 |
-
},
|
5034 |
-
|
5035 |
-
coordsChar: function(coords, mode) {
|
5036 |
-
coords = fromCoordSystem(this, coords, mode || "page");
|
5037 |
-
return coordsChar(this, coords.left, coords.top);
|
5038 |
-
},
|
5039 |
-
|
5040 |
-
lineAtHeight: function(height, mode) {
|
5041 |
-
height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
|
5042 |
-
return lineAtHeight(this.doc, height + this.display.viewOffset);
|
5043 |
-
},
|
5044 |
-
heightAtLine: function(line, mode) {
|
5045 |
-
var end = false, lineObj;
|
5046 |
-
if (typeof line == "number") {
|
5047 |
-
var last = this.doc.first + this.doc.size - 1;
|
5048 |
-
if (line < this.doc.first) line = this.doc.first;
|
5049 |
-
else if (line > last) { line = last; end = true; }
|
5050 |
-
lineObj = getLine(this.doc, line);
|
5051 |
-
} else {
|
5052 |
-
lineObj = line;
|
5053 |
-
}
|
5054 |
-
return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
|
5055 |
-
(end ? this.doc.height - heightAtLine(lineObj) : 0);
|
5056 |
-
},
|
5057 |
-
|
5058 |
-
defaultTextHeight: function() { return textHeight(this.display); },
|
5059 |
-
defaultCharWidth: function() { return charWidth(this.display); },
|
5060 |
-
|
5061 |
-
setGutterMarker: methodOp(function(line, gutterID, value) {
|
5062 |
-
return changeLine(this.doc, line, "gutter", function(line) {
|
5063 |
-
var markers = line.gutterMarkers || (line.gutterMarkers = {});
|
5064 |
-
markers[gutterID] = value;
|
5065 |
-
if (!value && isEmpty(markers)) line.gutterMarkers = null;
|
5066 |
-
return true;
|
5067 |
-
});
|
5068 |
-
}),
|
5069 |
-
|
5070 |
-
clearGutter: methodOp(function(gutterID) {
|
5071 |
-
var cm = this, doc = cm.doc, i = doc.first;
|
5072 |
-
doc.iter(function(line) {
|
5073 |
-
if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
|
5074 |
-
line.gutterMarkers[gutterID] = null;
|
5075 |
-
regLineChange(cm, i, "gutter");
|
5076 |
-
if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
|
5077 |
-
}
|
5078 |
-
++i;
|
5079 |
-
});
|
5080 |
-
}),
|
5081 |
-
|
5082 |
-
lineInfo: function(line) {
|
5083 |
-
if (typeof line == "number") {
|
5084 |
-
if (!isLine(this.doc, line)) return null;
|
5085 |
-
var n = line;
|
5086 |
-
line = getLine(this.doc, line);
|
5087 |
-
if (!line) return null;
|
5088 |
-
} else {
|
5089 |
-
var n = lineNo(line);
|
5090 |
-
if (n == null) return null;
|
5091 |
-
}
|
5092 |
-
return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
|
5093 |
-
textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
|
5094 |
-
widgets: line.widgets};
|
5095 |
-
},
|
5096 |
-
|
5097 |
-
getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},
|
5098 |
-
|
5099 |
-
addWidget: function(pos, node, scroll, vert, horiz) {
|
5100 |
-
var display = this.display;
|
5101 |
-
pos = cursorCoords(this, clipPos(this.doc, pos));
|
5102 |
-
var top = pos.bottom, left = pos.left;
|
5103 |
-
node.style.position = "absolute";
|
5104 |
-
node.setAttribute("cm-ignore-events", "true");
|
5105 |
-
this.display.input.setUneditable(node);
|
5106 |
-
display.sizer.appendChild(node);
|
5107 |
-
if (vert == "over") {
|
5108 |
-
top = pos.top;
|
5109 |
-
} else if (vert == "above" || vert == "near") {
|
5110 |
-
var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
|
5111 |
-
hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
|
5112 |
-
// Default to positioning above (if specified and possible); otherwise default to positioning below
|
5113 |
-
if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
|
5114 |
-
top = pos.top - node.offsetHeight;
|
5115 |
-
else if (pos.bottom + node.offsetHeight <= vspace)
|
5116 |
-
top = pos.bottom;
|
5117 |
-
if (left + node.offsetWidth > hspace)
|
5118 |
-
left = hspace - node.offsetWidth;
|
5119 |
-
}
|
5120 |
-
node.style.top = top + "px";
|
5121 |
-
node.style.left = node.style.right = "";
|
5122 |
-
if (horiz == "right") {
|
5123 |
-
left = display.sizer.clientWidth - node.offsetWidth;
|
5124 |
-
node.style.right = "0px";
|
5125 |
-
} else {
|
5126 |
-
if (horiz == "left") left = 0;
|
5127 |
-
else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
|
5128 |
-
node.style.left = left + "px";
|
5129 |
-
}
|
5130 |
-
if (scroll)
|
5131 |
-
scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
|
5132 |
-
},
|
5133 |
-
|
5134 |
-
triggerOnKeyDown: methodOp(onKeyDown),
|
5135 |
-
triggerOnKeyPress: methodOp(onKeyPress),
|
5136 |
-
triggerOnKeyUp: onKeyUp,
|
5137 |
-
|
5138 |
-
execCommand: function(cmd) {
|
5139 |
-
if (commands.hasOwnProperty(cmd))
|
5140 |
-
return commands[cmd].call(null, this);
|
5141 |
-
},
|
5142 |
-
|
5143 |
-
triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
|
5144 |
-
|
5145 |
-
findPosH: function(from, amount, unit, visually) {
|
5146 |
-
var dir = 1;
|
5147 |
-
if (amount < 0) { dir = -1; amount = -amount; }
|
5148 |
-
for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
|
5149 |
-
cur = findPosH(this.doc, cur, dir, unit, visually);
|
5150 |
-
if (cur.hitSide) break;
|
5151 |
-
}
|
5152 |
-
return cur;
|
5153 |
-
},
|
5154 |
-
|
5155 |
-
moveH: methodOp(function(dir, unit) {
|
5156 |
-
var cm = this;
|
5157 |
-
cm.extendSelectionsBy(function(range) {
|
5158 |
-
if (cm.display.shift || cm.doc.extend || range.empty())
|
5159 |
-
return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);
|
5160 |
-
else
|
5161 |
-
return dir < 0 ? range.from() : range.to();
|
5162 |
-
}, sel_move);
|
5163 |
-
}),
|
5164 |
-
|
5165 |
-
deleteH: methodOp(function(dir, unit) {
|
5166 |
-
var sel = this.doc.sel, doc = this.doc;
|
5167 |
-
if (sel.somethingSelected())
|
5168 |
-
doc.replaceSelection("", null, "+delete");
|
5169 |
-
else
|
5170 |
-
deleteNearSelection(this, function(range) {
|
5171 |
-
var other = findPosH(doc, range.head, dir, unit, false);
|
5172 |
-
return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};
|
5173 |
-
});
|
5174 |
-
}),
|
5175 |
-
|
5176 |
-
findPosV: function(from, amount, unit, goalColumn) {
|
5177 |
-
var dir = 1, x = goalColumn;
|
5178 |
-
if (amount < 0) { dir = -1; amount = -amount; }
|
5179 |
-
for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
|
5180 |
-
var coords = cursorCoords(this, cur, "div");
|
5181 |
-
if (x == null) x = coords.left;
|
5182 |
-
else coords.left = x;
|
5183 |
-
cur = findPosV(this, coords, dir, unit);
|
5184 |
-
if (cur.hitSide) break;
|
5185 |
-
}
|
5186 |
-
return cur;
|
5187 |
-
},
|
5188 |
-
|
5189 |
-
moveV: methodOp(function(dir, unit) {
|
5190 |
-
var cm = this, doc = this.doc, goals = [];
|
5191 |
-
var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();
|
5192 |
-
doc.extendSelectionsBy(function(range) {
|
5193 |
-
if (collapse)
|
5194 |
-
return dir < 0 ? range.from() : range.to();
|
5195 |
-
var headPos = cursorCoords(cm, range.head, "div");
|
5196 |
-
if (range.goalColumn != null) headPos.left = range.goalColumn;
|
5197 |
-
goals.push(headPos.left);
|
5198 |
-
var pos = findPosV(cm, headPos, dir, unit);
|
5199 |
-
if (unit == "page" && range == doc.sel.primary())
|
5200 |
-
addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top);
|
5201 |
-
return pos;
|
5202 |
-
}, sel_move);
|
5203 |
-
if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)
|
5204 |
-
doc.sel.ranges[i].goalColumn = goals[i];
|
5205 |
-
}),
|
5206 |
-
|
5207 |
-
// Find the word at the given position (as returned by coordsChar).
|
5208 |
-
findWordAt: function(pos) {
|
5209 |
-
var doc = this.doc, line = getLine(doc, pos.line).text;
|
5210 |
-
var start = pos.ch, end = pos.ch;
|
5211 |
-
if (line) {
|
5212 |
-
var helper = this.getHelper(pos, "wordChars");
|
5213 |
-
if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
|
5214 |
-
var startChar = line.charAt(start);
|
5215 |
-
var check = isWordChar(startChar, helper)
|
5216 |
-
? function(ch) { return isWordChar(ch, helper); }
|
5217 |
-
: /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
|
5218 |
-
: function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
|
5219 |
-
while (start > 0 && check(line.charAt(start - 1))) --start;
|
5220 |
-
while (end < line.length && check(line.charAt(end))) ++end;
|
5221 |
-
}
|
5222 |
-
return new Range(Pos(pos.line, start), Pos(pos.line, end));
|
5223 |
-
},
|
5224 |
-
|
5225 |
-
toggleOverwrite: function(value) {
|
5226 |
-
if (value != null && value == this.state.overwrite) return;
|
5227 |
-
if (this.state.overwrite = !this.state.overwrite)
|
5228 |
-
addClass(this.display.cursorDiv, "CodeMirror-overwrite");
|
5229 |
-
else
|
5230 |
-
rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
|
5231 |
-
|
5232 |
-
signal(this, "overwriteToggle", this, this.state.overwrite);
|
5233 |
-
},
|
5234 |
-
hasFocus: function() { return this.display.input.getField() == activeElt(); },
|
5235 |
-
|
5236 |
-
scrollTo: methodOp(function(x, y) {
|
5237 |
-
if (x != null || y != null) resolveScrollToPos(this);
|
5238 |
-
if (x != null) this.curOp.scrollLeft = x;
|
5239 |
-
if (y != null) this.curOp.scrollTop = y;
|
5240 |
-
}),
|
5241 |
-
getScrollInfo: function() {
|
5242 |
-
var scroller = this.display.scroller;
|
5243 |
-
return {left: scroller.scrollLeft, top: scroller.scrollTop,
|
5244 |
-
height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
|
5245 |
-
width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
|
5246 |
-
clientHeight: displayHeight(this), clientWidth: displayWidth(this)};
|
5247 |
-
},
|
5248 |
-
|
5249 |
-
scrollIntoView: methodOp(function(range, margin) {
|
5250 |
-
if (range == null) {
|
5251 |
-
range = {from: this.doc.sel.primary().head, to: null};
|
5252 |
-
if (margin == null) margin = this.options.cursorScrollMargin;
|
5253 |
-
} else if (typeof range == "number") {
|
5254 |
-
range = {from: Pos(range, 0), to: null};
|
5255 |
-
} else if (range.from == null) {
|
5256 |
-
range = {from: range, to: null};
|
5257 |
-
}
|
5258 |
-
if (!range.to) range.to = range.from;
|
5259 |
-
range.margin = margin || 0;
|
5260 |
-
|
5261 |
-
if (range.from.line != null) {
|
5262 |
-
resolveScrollToPos(this);
|
5263 |
-
this.curOp.scrollToPos = range;
|
5264 |
-
} else {
|
5265 |
-
var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
|
5266 |
-
Math.min(range.from.top, range.to.top) - range.margin,
|
5267 |
-
Math.max(range.from.right, range.to.right),
|
5268 |
-
Math.max(range.from.bottom, range.to.bottom) + range.margin);
|
5269 |
-
this.scrollTo(sPos.scrollLeft, sPos.scrollTop);
|
5270 |
-
}
|
5271 |
-
}),
|
5272 |
-
|
5273 |
-
setSize: methodOp(function(width, height) {
|
5274 |
-
var cm = this;
|
5275 |
-
function interpret(val) {
|
5276 |
-
return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
|
5277 |
-
}
|
5278 |
-
if (width != null) cm.display.wrapper.style.width = interpret(width);
|
5279 |
-
if (height != null) cm.display.wrapper.style.height = interpret(height);
|
5280 |
-
if (cm.options.lineWrapping) clearLineMeasurementCache(this);
|
5281 |
-
var lineNo = cm.display.viewFrom;
|
5282 |
-
cm.doc.iter(lineNo, cm.display.viewTo, function(line) {
|
5283 |
-
if (line.widgets) for (var i = 0; i < line.widgets.length; i++)
|
5284 |
-
if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; }
|
5285 |
-
++lineNo;
|
5286 |
-
});
|
5287 |
-
cm.curOp.forceUpdate = true;
|
5288 |
-
signal(cm, "refresh", this);
|
5289 |
-
}),
|
5290 |
-
|
5291 |
-
operation: function(f){return runInOp(this, f);},
|
5292 |
-
|
5293 |
-
refresh: methodOp(function() {
|
5294 |
-
var oldHeight = this.display.cachedTextHeight;
|
5295 |
-
regChange(this);
|
5296 |
-
this.curOp.forceUpdate = true;
|
5297 |
-
clearCaches(this);
|
5298 |
-
this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);
|
5299 |
-
updateGutterSpace(this);
|
5300 |
-
if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
|
5301 |
-
estimateLineHeights(this);
|
5302 |
-
signal(this, "refresh", this);
|
5303 |
-
}),
|
5304 |
-
|
5305 |
-
swapDoc: methodOp(function(doc) {
|
5306 |
-
var old = this.doc;
|
5307 |
-
old.cm = null;
|
5308 |
-
attachDoc(this, doc);
|
5309 |
-
clearCaches(this);
|
5310 |
-
this.display.input.reset();
|
5311 |
-
this.scrollTo(doc.scrollLeft, doc.scrollTop);
|
5312 |
-
this.curOp.forceScroll = true;
|
5313 |
-
signalLater(this, "swapDoc", this, old);
|
5314 |
-
return old;
|
5315 |
-
}),
|
5316 |
-
|
5317 |
-
getInputField: function(){return this.display.input.getField();},
|
5318 |
-
getWrapperElement: function(){return this.display.wrapper;},
|
5319 |
-
getScrollerElement: function(){return this.display.scroller;},
|
5320 |
-
getGutterElement: function(){return this.display.gutters;}
|
5321 |
-
};
|
5322 |
-
eventMixin(CodeMirror);
|
5323 |
-
|
5324 |
-
// OPTION DEFAULTS
|
5325 |
-
|
5326 |
-
// The default configuration options.
|
5327 |
-
var defaults = CodeMirror.defaults = {};
|
5328 |
-
// Functions to run when options are changed.
|
5329 |
-
var optionHandlers = CodeMirror.optionHandlers = {};
|
5330 |
-
|
5331 |
-
function option(name, deflt, handle, notOnInit) {
|
5332 |
-
CodeMirror.defaults[name] = deflt;
|
5333 |
-
if (handle) optionHandlers[name] =
|
5334 |
-
notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
|
5335 |
-
}
|
5336 |
-
|
5337 |
-
// Passed to option handlers when there is no old value.
|
5338 |
-
var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
|
5339 |
-
|
5340 |
-
// These two are, on init, called from the constructor because they
|
5341 |
-
// have to be initialized before the editor can start at all.
|
5342 |
-
option("value", "", function(cm, val) {
|
5343 |
-
cm.setValue(val);
|
5344 |
-
}, true);
|
5345 |
-
option("mode", null, function(cm, val) {
|
5346 |
-
cm.doc.modeOption = val;
|
5347 |
-
loadMode(cm);
|
5348 |
-
}, true);
|
5349 |
-
|
5350 |
-
option("indentUnit", 2, loadMode, true);
|
5351 |
-
option("indentWithTabs", false);
|
5352 |
-
option("smartIndent", true);
|
5353 |
-
option("tabSize", 4, function(cm) {
|
5354 |
-
resetModeState(cm);
|
5355 |
-
clearCaches(cm);
|
5356 |
-
regChange(cm);
|
5357 |
-
}, true);
|
5358 |
-
option("lineSeparator", null, function(cm, val) {
|
5359 |
-
cm.doc.lineSep = val;
|
5360 |
-
if (!val) return;
|
5361 |
-
var newBreaks = [], lineNo = cm.doc.first;
|
5362 |
-
cm.doc.iter(function(line) {
|
5363 |
-
for (var pos = 0;;) {
|
5364 |
-
var found = line.text.indexOf(val, pos);
|
5365 |
-
if (found == -1) break;
|
5366 |
-
pos = found + val.length;
|
5367 |
-
newBreaks.push(Pos(lineNo, found));
|
5368 |
-
}
|
5369 |
-
lineNo++;
|
5370 |
-
});
|
5371 |
-
for (var i = newBreaks.length - 1; i >= 0; i--)
|
5372 |
-
replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length))
|
5373 |
-
});
|
5374 |
-
option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
|
5375 |
-
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
|
5376 |
-
if (old != CodeMirror.Init) cm.refresh();
|
5377 |
-
});
|
5378 |
-
option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
|
5379 |
-
option("electricChars", true);
|
5380 |
-
option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
|
5381 |
-
throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
|
5382 |
-
}, true);
|
5383 |
-
option("rtlMoveVisually", !windows);
|
5384 |
-
option("wholeLineUpdateBefore", true);
|
5385 |
-
|
5386 |
-
option("theme", "default", function(cm) {
|
5387 |
-
themeChanged(cm);
|
5388 |
-
guttersChanged(cm);
|
5389 |
-
}, true);
|
5390 |
-
option("keyMap", "default", function(cm, val, old) {
|
5391 |
-
var next = getKeyMap(val);
|
5392 |
-
var prev = old != CodeMirror.Init && getKeyMap(old);
|
5393 |
-
if (prev && prev.detach) prev.detach(cm, next);
|
5394 |
-
if (next.attach) next.attach(cm, prev || null);
|
5395 |
-
});
|
5396 |
-
option("extraKeys", null);
|
5397 |
-
|
5398 |
-
option("lineWrapping", false, wrappingChanged, true);
|
5399 |
-
option("gutters", [], function(cm) {
|
5400 |
-
setGuttersForLineNumbers(cm.options);
|
5401 |
-
guttersChanged(cm);
|
5402 |
-
}, true);
|
5403 |
-
option("fixedGutter", true, function(cm, val) {
|
5404 |
-
cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
|
5405 |
-
cm.refresh();
|
5406 |
-
}, true);
|
5407 |
-
option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true);
|
5408 |
-
option("scrollbarStyle", "native", function(cm) {
|
5409 |
-
initScrollbars(cm);
|
5410 |
-
updateScrollbars(cm);
|
5411 |
-
cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
|
5412 |
-
cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
|
5413 |
-
}, true);
|
5414 |
-
option("lineNumbers", false, function(cm) {
|
5415 |
-
setGuttersForLineNumbers(cm.options);
|
5416 |
-
guttersChanged(cm);
|
5417 |
-
}, true);
|
5418 |
-
option("firstLineNumber", 1, guttersChanged, true);
|
5419 |
-
option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
|
5420 |
-
option("showCursorWhenSelecting", false, updateSelection, true);
|
5421 |
-
|
5422 |
-
option("resetSelectionOnContextMenu", true);
|
5423 |
-
option("lineWiseCopyCut", true);
|
5424 |
-
|
5425 |
-
option("readOnly", false, function(cm, val) {
|
5426 |
-
if (val == "nocursor") {
|
5427 |
-
onBlur(cm);
|
5428 |
-
cm.display.input.blur();
|
5429 |
-
cm.display.disabled = true;
|
5430 |
-
} else {
|
5431 |
-
cm.display.disabled = false;
|
5432 |
-
}
|
5433 |
-
cm.display.input.readOnlyChanged(val)
|
5434 |
-
});
|
5435 |
-
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
|
5436 |
-
option("dragDrop", true, dragDropChanged);
|
5437 |
-
option("allowDropFileTypes", null);
|
5438 |
-
|
5439 |
-
option("cursorBlinkRate", 530);
|
5440 |
-
option("cursorScrollMargin", 0);
|
5441 |
-
option("cursorHeight", 1, updateSelection, true);
|
5442 |
-
option("singleCursorHeightPerLine", true, updateSelection, true);
|
5443 |
-
option("workTime", 100);
|
5444 |
-
option("workDelay", 100);
|
5445 |
-
option("flattenSpans", true, resetModeState, true);
|
5446 |
-
option("addModeClass", false, resetModeState, true);
|
5447 |
-
option("pollInterval", 100);
|
5448 |
-
option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
|
5449 |
-
option("historyEventDelay", 1250);
|
5450 |
-
option("viewportMargin", 10, function(cm){cm.refresh();}, true);
|
5451 |
-
option("maxHighlightLength", 10000, resetModeState, true);
|
5452 |
-
option("moveInputWithCursor", true, function(cm, val) {
|
5453 |
-
if (!val) cm.display.input.resetPosition();
|
5454 |
-
});
|
5455 |
-
|
5456 |
-
option("tabindex", null, function(cm, val) {
|
5457 |
-
cm.display.input.getField().tabIndex = val || "";
|
5458 |
-
});
|
5459 |
-
option("autofocus", null);
|
5460 |
-
|
5461 |
-
// MODE DEFINITION AND QUERYING
|
5462 |
-
|
5463 |
-
// Known modes, by name and by MIME
|
5464 |
-
var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
|
5465 |
-
|
5466 |
-
// Extra arguments are stored as the mode's dependencies, which is
|
5467 |
-
// used by (legacy) mechanisms like loadmode.js to automatically
|
5468 |
-
// load a mode. (Preferred mechanism is the require/define calls.)
|
5469 |
-
CodeMirror.defineMode = function(name, mode) {
|
5470 |
-
if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
|
5471 |
-
if (arguments.length > 2)
|
5472 |
-
mode.dependencies = Array.prototype.slice.call(arguments, 2);
|
5473 |
-
modes[name] = mode;
|
5474 |
-
};
|
5475 |
-
|
5476 |
-
CodeMirror.defineMIME = function(mime, spec) {
|
5477 |
-
mimeModes[mime] = spec;
|
5478 |
-
};
|
5479 |
-
|
5480 |
-
// Given a MIME type, a {name, ...options} config object, or a name
|
5481 |
-
// string, return a mode config object.
|
5482 |
-
CodeMirror.resolveMode = function(spec) {
|
5483 |
-
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
|
5484 |
-
spec = mimeModes[spec];
|
5485 |
-
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
|
5486 |
-
var found = mimeModes[spec.name];
|
5487 |
-
if (typeof found == "string") found = {name: found};
|
5488 |
-
spec = createObj(found, spec);
|
5489 |
-
spec.name = found.name;
|
5490 |
-
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
|
5491 |
-
return CodeMirror.resolveMode("application/xml");
|
5492 |
-
}
|
5493 |
-
if (typeof spec == "string") return {name: spec};
|
5494 |
-
else return spec || {name: "null"};
|
5495 |
-
};
|
5496 |
-
|
5497 |
-
// Given a mode spec (anything that resolveMode accepts), find and
|
5498 |
-
// initialize an actual mode object.
|
5499 |
-
CodeMirror.getMode = function(options, spec) {
|
5500 |
-
var spec = CodeMirror.resolveMode(spec);
|
5501 |
-
var mfactory = modes[spec.name];
|
5502 |
-
if (!mfactory) return CodeMirror.getMode(options, "text/plain");
|
5503 |
-
var modeObj = mfactory(options, spec);
|
5504 |
-
if (modeExtensions.hasOwnProperty(spec.name)) {
|
5505 |
-
var exts = modeExtensions[spec.name];
|
5506 |
-
for (var prop in exts) {
|
5507 |
-
if (!exts.hasOwnProperty(prop)) continue;
|
5508 |
-
if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
|
5509 |
-
modeObj[prop] = exts[prop];
|
5510 |
-
}
|
5511 |
-
}
|
5512 |
-
modeObj.name = spec.name;
|
5513 |
-
if (spec.helperType) modeObj.helperType = spec.helperType;
|
5514 |
-
if (spec.modeProps) for (var prop in spec.modeProps)
|
5515 |
-
modeObj[prop] = spec.modeProps[prop];
|
5516 |
-
|
5517 |
-
return modeObj;
|
5518 |
-
};
|
5519 |
-
|
5520 |
-
// Minimal default mode.
|
5521 |
-
CodeMirror.defineMode("null", function() {
|
5522 |
-
return {token: function(stream) {stream.skipToEnd();}};
|
5523 |
-
});
|
5524 |
-
CodeMirror.defineMIME("text/plain", "null");
|
5525 |
-
|
5526 |
-
// This can be used to attach properties to mode objects from
|
5527 |
-
// outside the actual mode definition.
|
5528 |
-
var modeExtensions = CodeMirror.modeExtensions = {};
|
5529 |
-
CodeMirror.extendMode = function(mode, properties) {
|
5530 |
-
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
|
5531 |
-
copyObj(properties, exts);
|
5532 |
-
};
|
5533 |
-
|
5534 |
-
// EXTENSIONS
|
5535 |
-
|
5536 |
-
CodeMirror.defineExtension = function(name, func) {
|
5537 |
-
CodeMirror.prototype[name] = func;
|
5538 |
-
};
|
5539 |
-
CodeMirror.defineDocExtension = function(name, func) {
|
5540 |
-
Doc.prototype[name] = func;
|
5541 |
-
};
|
5542 |
-
CodeMirror.defineOption = option;
|
5543 |
-
|
5544 |
-
var initHooks = [];
|
5545 |
-
CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
|
5546 |
-
|
5547 |
-
var helpers = CodeMirror.helpers = {};
|
5548 |
-
CodeMirror.registerHelper = function(type, name, value) {
|
5549 |
-
if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
|
5550 |
-
helpers[type][name] = value;
|
5551 |
-
};
|
5552 |
-
CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
|
5553 |
-
CodeMirror.registerHelper(type, name, value);
|
5554 |
-
helpers[type]._global.push({pred: predicate, val: value});
|
5555 |
-
};
|
5556 |
-
|
5557 |
-
// MODE STATE HANDLING
|
5558 |
-
|
5559 |
-
// Utility functions for working with state. Exported because nested
|
5560 |
-
// modes need to do this for their inner modes.
|
5561 |
-
|
5562 |
-
var copyState = CodeMirror.copyState = function(mode, state) {
|
5563 |
-
if (state === true) return state;
|
5564 |
-
if (mode.copyState) return mode.copyState(state);
|
5565 |
-
var nstate = {};
|
5566 |
-
for (var n in state) {
|
5567 |
-
var val = state[n];
|
5568 |
-
if (val instanceof Array) val = val.concat([]);
|
5569 |
-
nstate[n] = val;
|
5570 |
-
}
|
5571 |
-
return nstate;
|
5572 |
-
};
|
5573 |
-
|
5574 |
-
var startState = CodeMirror.startState = function(mode, a1, a2) {
|
5575 |
-
return mode.startState ? mode.startState(a1, a2) : true;
|
5576 |
-
};
|
5577 |
-
|
5578 |
-
// Given a mode and a state (for that mode), find the inner mode and
|
5579 |
-
// state at the position that the state refers to.
|
5580 |
-
CodeMirror.innerMode = function(mode, state) {
|
5581 |
-
while (mode.innerMode) {
|
5582 |
-
var info = mode.innerMode(state);
|
5583 |
-
if (!info || info.mode == mode) break;
|
5584 |
-
state = info.state;
|
5585 |
-
mode = info.mode;
|
5586 |
-
}
|
5587 |
-
return info || {mode: mode, state: state};
|
5588 |
-
};
|
5589 |
-
|
5590 |
-
// STANDARD COMMANDS
|
5591 |
-
|
5592 |
-
// Commands are parameter-less actions that can be performed on an
|
5593 |
-
// editor, mostly used for keybindings.
|
5594 |
-
var commands = CodeMirror.commands = {
|
5595 |
-
selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
|
5596 |
-
singleSelection: function(cm) {
|
5597 |
-
cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
|
5598 |
-
},
|
5599 |
-
killLine: function(cm) {
|
5600 |
-
deleteNearSelection(cm, function(range) {
|
5601 |
-
if (range.empty()) {
|
5602 |
-
var len = getLine(cm.doc, range.head.line).text.length;
|
5603 |
-
if (range.head.ch == len && range.head.line < cm.lastLine())
|
5604 |
-
return {from: range.head, to: Pos(range.head.line + 1, 0)};
|
5605 |
-
else
|
5606 |
-
return {from: range.head, to: Pos(range.head.line, len)};
|
5607 |
-
} else {
|
5608 |
-
return {from: range.from(), to: range.to()};
|
5609 |
-
}
|
5610 |
-
});
|
5611 |
-
},
|
5612 |
-
deleteLine: function(cm) {
|
5613 |
-
deleteNearSelection(cm, function(range) {
|
5614 |
-
return {from: Pos(range.from().line, 0),
|
5615 |
-
to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
|
5616 |
-
});
|
5617 |
-
},
|
5618 |
-
delLineLeft: function(cm) {
|
5619 |
-
deleteNearSelection(cm, function(range) {
|
5620 |
-
return {from: Pos(range.from().line, 0), to: range.from()};
|
5621 |
-
});
|
5622 |
-
},
|
5623 |
-
delWrappedLineLeft: function(cm) {
|
5624 |
-
deleteNearSelection(cm, function(range) {
|
5625 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5626 |
-
var leftPos = cm.coordsChar({left: 0, top: top}, "div");
|
5627 |
-
return {from: leftPos, to: range.from()};
|
5628 |
-
});
|
5629 |
-
},
|
5630 |
-
delWrappedLineRight: function(cm) {
|
5631 |
-
deleteNearSelection(cm, function(range) {
|
5632 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5633 |
-
var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
|
5634 |
-
return {from: range.from(), to: rightPos };
|
5635 |
-
});
|
5636 |
-
},
|
5637 |
-
undo: function(cm) {cm.undo();},
|
5638 |
-
redo: function(cm) {cm.redo();},
|
5639 |
-
undoSelection: function(cm) {cm.undoSelection();},
|
5640 |
-
redoSelection: function(cm) {cm.redoSelection();},
|
5641 |
-
goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
|
5642 |
-
goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
|
5643 |
-
goLineStart: function(cm) {
|
5644 |
-
cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
|
5645 |
-
{origin: "+move", bias: 1});
|
5646 |
-
},
|
5647 |
-
goLineStartSmart: function(cm) {
|
5648 |
-
cm.extendSelectionsBy(function(range) {
|
5649 |
-
return lineStartSmart(cm, range.head);
|
5650 |
-
}, {origin: "+move", bias: 1});
|
5651 |
-
},
|
5652 |
-
goLineEnd: function(cm) {
|
5653 |
-
cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
|
5654 |
-
{origin: "+move", bias: -1});
|
5655 |
-
},
|
5656 |
-
goLineRight: function(cm) {
|
5657 |
-
cm.extendSelectionsBy(function(range) {
|
5658 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5659 |
-
return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
|
5660 |
-
}, sel_move);
|
5661 |
-
},
|
5662 |
-
goLineLeft: function(cm) {
|
5663 |
-
cm.extendSelectionsBy(function(range) {
|
5664 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5665 |
-
return cm.coordsChar({left: 0, top: top}, "div");
|
5666 |
-
}, sel_move);
|
5667 |
-
},
|
5668 |
-
goLineLeftSmart: function(cm) {
|
5669 |
-
cm.extendSelectionsBy(function(range) {
|
5670 |
-
var top = cm.charCoords(range.head, "div").top + 5;
|
5671 |
-
var pos = cm.coordsChar({left: 0, top: top}, "div");
|
5672 |
-
if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head);
|
5673 |
-
return pos;
|
5674 |
-
}, sel_move);
|
5675 |
-
},
|
5676 |
-
goLineUp: function(cm) {cm.moveV(-1, "line");},
|
5677 |
-
goLineDown: function(cm) {cm.moveV(1, "line");},
|
5678 |
-
goPageUp: function(cm) {cm.moveV(-1, "page");},
|
5679 |
-
goPageDown: function(cm) {cm.moveV(1, "page");},
|
5680 |
-
goCharLeft: function(cm) {cm.moveH(-1, "char");},
|
5681 |
-
goCharRight: function(cm) {cm.moveH(1, "char");},
|
5682 |
-
goColumnLeft: function(cm) {cm.moveH(-1, "column");},
|
5683 |
-
goColumnRight: function(cm) {cm.moveH(1, "column");},
|
5684 |
-
goWordLeft: function(cm) {cm.moveH(-1, "word");},
|
5685 |
-
goGroupRight: function(cm) {cm.moveH(1, "group");},
|
5686 |
-
goGroupLeft: function(cm) {cm.moveH(-1, "group");},
|
5687 |
-
goWordRight: function(cm) {cm.moveH(1, "word");},
|
5688 |
-
delCharBefore: function(cm) {cm.deleteH(-1, "char");},
|
5689 |
-
delCharAfter: function(cm) {cm.deleteH(1, "char");},
|
5690 |
-
delWordBefore: function(cm) {cm.deleteH(-1, "word");},
|
5691 |
-
delWordAfter: function(cm) {cm.deleteH(1, "word");},
|
5692 |
-
delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
|
5693 |
-
delGroupAfter: function(cm) {cm.deleteH(1, "group");},
|
5694 |
-
indentAuto: function(cm) {cm.indentSelection("smart");},
|
5695 |
-
indentMore: function(cm) {cm.indentSelection("add");},
|
5696 |
-
indentLess: function(cm) {cm.indentSelection("subtract");},
|
5697 |
-
insertTab: function(cm) {cm.replaceSelection("\t");},
|
5698 |
-
insertSoftTab: function(cm) {
|
5699 |
-
var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
|
5700 |
-
for (var i = 0; i < ranges.length; i++) {
|
5701 |
-
var pos = ranges[i].from();
|
5702 |
-
var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
|
5703 |
-
spaces.push(new Array(tabSize - col % tabSize + 1).join(" "));
|
5704 |
-
}
|
5705 |
-
cm.replaceSelections(spaces);
|
5706 |
-
},
|
5707 |
-
defaultTab: function(cm) {
|
5708 |
-
if (cm.somethingSelected()) cm.indentSelection("add");
|
5709 |
-
else cm.execCommand("insertTab");
|
5710 |
-
},
|
5711 |
-
transposeChars: function(cm) {
|
5712 |
-
runInOp(cm, function() {
|
5713 |
-
var ranges = cm.listSelections(), newSel = [];
|
5714 |
-
for (var i = 0; i < ranges.length; i++) {
|
5715 |
-
var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
|
5716 |
-
if (line) {
|
5717 |
-
if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
|
5718 |
-
if (cur.ch > 0) {
|
5719 |
-
cur = new Pos(cur.line, cur.ch + 1);
|
5720 |
-
cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
|
5721 |
-
Pos(cur.line, cur.ch - 2), cur, "+transpose");
|
5722 |
-
} else if (cur.line > cm.doc.first) {
|
5723 |
-
var prev = getLine(cm.doc, cur.line - 1).text;
|
5724 |
-
if (prev)
|
5725 |
-
cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
|
5726 |
-
prev.charAt(prev.length - 1),
|
5727 |
-
Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
|
5728 |
-
}
|
5729 |
-
}
|
5730 |
-
newSel.push(new Range(cur, cur));
|
5731 |
-
}
|
5732 |
-
cm.setSelections(newSel);
|
5733 |
-
});
|
5734 |
-
},
|
5735 |
-
newlineAndIndent: function(cm) {
|
5736 |
-
runInOp(cm, function() {
|
5737 |
-
var len = cm.listSelections().length;
|
5738 |
-
for (var i = 0; i < len; i++) {
|
5739 |
-
var range = cm.listSelections()[i];
|
5740 |
-
cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input");
|
5741 |
-
cm.indentLine(range.from().line + 1, null, true);
|
5742 |
-
}
|
5743 |
-
ensureCursorVisible(cm);
|
5744 |
-
});
|
5745 |
-
},
|
5746 |
-
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
|
5747 |
-
};
|
5748 |
-
|
5749 |
-
|
5750 |
-
// STANDARD KEYMAPS
|
5751 |
-
|
5752 |
-
var keyMap = CodeMirror.keyMap = {};
|
5753 |
-
|
5754 |
-
keyMap.basic = {
|
5755 |
-
"Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
|
5756 |
-
"End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
|
5757 |
-
"Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
|
5758 |
-
"Tab": "defaultTab", "Shift-Tab": "indentAuto",
|
5759 |
-
"Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
|
5760 |
-
"Esc": "singleSelection"
|
5761 |
-
};
|
5762 |
-
// Note that the save and find-related commands aren't defined by
|
5763 |
-
// default. User code or addons can define them. Unknown commands
|
5764 |
-
// are simply ignored.
|
5765 |
-
keyMap.pcDefault = {
|
5766 |
-
"Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
|
5767 |
-
"Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
|
5768 |
-
"Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
|
5769 |
-
"Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
|
5770 |
-
"Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
|
5771 |
-
"Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
|
5772 |
-
"Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
|
5773 |
-
fallthrough: "basic"
|
5774 |
-
};
|
5775 |
-
// Very basic readline/emacs-style bindings, which are standard on Mac.
|
5776 |
-
keyMap.emacsy = {
|
5777 |
-
"Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
|
5778 |
-
"Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
|
5779 |
-
"Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
|
5780 |
-
"Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
|
5781 |
-
};
|
5782 |
-
keyMap.macDefault = {
|
5783 |
-
"Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
|
5784 |
-
"Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
|
5785 |
-
"Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
|
5786 |
-
"Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
|
5787 |
-
"Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
|
5788 |
-
"Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
|
5789 |
-
"Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
|
5790 |
-
fallthrough: ["basic", "emacsy"]
|
5791 |
-
};
|
5792 |
-
keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
|
5793 |
-
|
5794 |
-
// KEYMAP DISPATCH
|
5795 |
-
|
5796 |
-
function normalizeKeyName(name) {
|
5797 |
-
var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
|
5798 |
-
var alt, ctrl, shift, cmd;
|
5799 |
-
for (var i = 0; i < parts.length - 1; i++) {
|
5800 |
-
var mod = parts[i];
|
5801 |
-
if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
|
5802 |
-
else if (/^a(lt)?$/i.test(mod)) alt = true;
|
5803 |
-
else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
|
5804 |
-
else if (/^s(hift)$/i.test(mod)) shift = true;
|
5805 |
-
else throw new Error("Unrecognized modifier name: " + mod);
|
5806 |
-
}
|
5807 |
-
if (alt) name = "Alt-" + name;
|
5808 |
-
if (ctrl) name = "Ctrl-" + name;
|
5809 |
-
if (cmd) name = "Cmd-" + name;
|
5810 |
-
if (shift) name = "Shift-" + name;
|
5811 |
-
return name;
|
5812 |
-
}
|
5813 |
-
|
5814 |
-
// This is a kludge to keep keymaps mostly working as raw objects
|
5815 |
-
// (backwards compatibility) while at the same time support features
|
5816 |
-
// like normalization and multi-stroke key bindings. It compiles a
|
5817 |
-
// new normalized keymap, and then updates the old object to reflect
|
5818 |
-
// this.
|
5819 |
-
CodeMirror.normalizeKeyMap = function(keymap) {
|
5820 |
-
var copy = {};
|
5821 |
-
for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) {
|
5822 |
-
var value = keymap[keyname];
|
5823 |
-
if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue;
|
5824 |
-
if (value == "...") { delete keymap[keyname]; continue; }
|
5825 |
-
|
5826 |
-
var keys = map(keyname.split(" "), normalizeKeyName);
|
5827 |
-
for (var i = 0; i < keys.length; i++) {
|
5828 |
-
var val, name;
|
5829 |
-
if (i == keys.length - 1) {
|
5830 |
-
name = keys.join(" ");
|
5831 |
-
val = value;
|
5832 |
-
} else {
|
5833 |
-
name = keys.slice(0, i + 1).join(" ");
|
5834 |
-
val = "...";
|
5835 |
-
}
|
5836 |
-
var prev = copy[name];
|
5837 |
-
if (!prev) copy[name] = val;
|
5838 |
-
else if (prev != val) throw new Error("Inconsistent bindings for " + name);
|
5839 |
-
}
|
5840 |
-
delete keymap[keyname];
|
5841 |
-
}
|
5842 |
-
for (var prop in copy) keymap[prop] = copy[prop];
|
5843 |
-
return keymap;
|
5844 |
-
};
|
5845 |
-
|
5846 |
-
var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) {
|
5847 |
-
map = getKeyMap(map);
|
5848 |
-
var found = map.call ? map.call(key, context) : map[key];
|
5849 |
-
if (found === false) return "nothing";
|
5850 |
-
if (found === "...") return "multi";
|
5851 |
-
if (found != null && handle(found)) return "handled";
|
5852 |
-
|
5853 |
-
if (map.fallthrough) {
|
5854 |
-
if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
|
5855 |
-
return lookupKey(key, map.fallthrough, handle, context);
|
5856 |
-
for (var i = 0; i < map.fallthrough.length; i++) {
|
5857 |
-
var result = lookupKey(key, map.fallthrough[i], handle, context);
|
5858 |
-
if (result) return result;
|
5859 |
-
}
|
5860 |
-
}
|
5861 |
-
};
|
5862 |
-
|
5863 |
-
// Modifier key presses don't count as 'real' key presses for the
|
5864 |
-
// purpose of keymap fallthrough.
|
5865 |
-
var isModifierKey = CodeMirror.isModifierKey = function(value) {
|
5866 |
-
var name = typeof value == "string" ? value : keyNames[value.keyCode];
|
5867 |
-
return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
|
5868 |
-
};
|
5869 |
-
|
5870 |
-
// Look up the name of a key as indicated by an event object.
|
5871 |
-
var keyName = CodeMirror.keyName = function(event, noShift) {
|
5872 |
-
if (presto && event.keyCode == 34 && event["char"]) return false;
|
5873 |
-
var base = keyNames[event.keyCode], name = base;
|
5874 |
-
if (name == null || event.altGraphKey) return false;
|
5875 |
-
if (event.altKey && base != "Alt") name = "Alt-" + name;
|
5876 |
-
if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name;
|
5877 |
-
if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name;
|
5878 |
-
if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name;
|
5879 |
-
return name;
|
5880 |
-
};
|
5881 |
-
|
5882 |
-
function getKeyMap(val) {
|
5883 |
-
return typeof val == "string" ? keyMap[val] : val;
|
5884 |
-
}
|
5885 |
-
|
5886 |
-
// FROMTEXTAREA
|
5887 |
-
|
5888 |
-
CodeMirror.fromTextArea = function(textarea, options) {
|
5889 |
-
options = options ? copyObj(options) : {};
|
5890 |
-
options.value = textarea.value;
|
5891 |
-
if (!options.tabindex && textarea.tabIndex)
|
5892 |
-
options.tabindex = textarea.tabIndex;
|
5893 |
-
if (!options.placeholder && textarea.placeholder)
|
5894 |
-
options.placeholder = textarea.placeholder;
|
5895 |
-
// Set autofocus to true if this textarea is focused, or if it has
|
5896 |
-
// autofocus and no other element is focused.
|
5897 |
-
if (options.autofocus == null) {
|
5898 |
-
var hasFocus = activeElt();
|
5899 |
-
options.autofocus = hasFocus == textarea ||
|
5900 |
-
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
|
5901 |
-
}
|
5902 |
-
|
5903 |
-
function save() {textarea.value = cm.getValue();}
|
5904 |
-
if (textarea.form) {
|
5905 |
-
on(textarea.form, "submit", save);
|
5906 |
-
// Deplorable hack to make the submit method do the right thing.
|
5907 |
-
if (!options.leaveSubmitMethodAlone) {
|
5908 |
-
var form = textarea.form, realSubmit = form.submit;
|
5909 |
-
try {
|
5910 |
-
var wrappedSubmit = form.submit = function() {
|
5911 |
-
save();
|
5912 |
-
form.submit = realSubmit;
|
5913 |
-
form.submit();
|
5914 |
-
form.submit = wrappedSubmit;
|
5915 |
-
};
|
5916 |
-
} catch(e) {}
|
5917 |
-
}
|
5918 |
-
}
|
5919 |
-
|
5920 |
-
options.finishInit = function(cm) {
|
5921 |
-
cm.save = save;
|
5922 |
-
cm.getTextArea = function() { return textarea; };
|
5923 |
-
cm.toTextArea = function() {
|
5924 |
-
cm.toTextArea = isNaN; // Prevent this from being ran twice
|
5925 |
-
save();
|
5926 |
-
textarea.parentNode.removeChild(cm.getWrapperElement());
|
5927 |
-
textarea.style.display = "";
|
5928 |
-
if (textarea.form) {
|
5929 |
-
off(textarea.form, "submit", save);
|
5930 |
-
if (typeof textarea.form.submit == "function")
|
5931 |
-
textarea.form.submit = realSubmit;
|
5932 |
-
}
|
5933 |
-
};
|
5934 |
-
};
|
5935 |
-
|
5936 |
-
textarea.style.display = "none";
|
5937 |
-
var cm = CodeMirror(function(node) {
|
5938 |
-
textarea.parentNode.insertBefore(node, textarea.nextSibling);
|
5939 |
-
}, options);
|
5940 |
-
return cm;
|
5941 |
-
};
|
5942 |
-
|
5943 |
-
// STRING STREAM
|
5944 |
-
|
5945 |
-
// Fed to the mode parsers, provides helper functions to make
|
5946 |
-
// parsers more succinct.
|
5947 |
-
|
5948 |
-
var StringStream = CodeMirror.StringStream = function(string, tabSize) {
|
5949 |
-
this.pos = this.start = 0;
|
5950 |
-
this.string = string;
|
5951 |
-
this.tabSize = tabSize || 8;
|
5952 |
-
this.lastColumnPos = this.lastColumnValue = 0;
|
5953 |
-
this.lineStart = 0;
|
5954 |
-
};
|
5955 |
-
|
5956 |
-
StringStream.prototype = {
|
5957 |
-
eol: function() {return this.pos >= this.string.length;},
|
5958 |
-
sol: function() {return this.pos == this.lineStart;},
|
5959 |
-
peek: function() {return this.string.charAt(this.pos) || undefined;},
|
5960 |
-
next: function() {
|
5961 |
-
if (this.pos < this.string.length)
|
5962 |
-
return this.string.charAt(this.pos++);
|
5963 |
-
},
|
5964 |
-
eat: function(match) {
|
5965 |
-
var ch = this.string.charAt(this.pos);
|
5966 |
-
if (typeof match == "string") var ok = ch == match;
|
5967 |
-
else var ok = ch && (match.test ? match.test(ch) : match(ch));
|
5968 |
-
if (ok) {++this.pos; return ch;}
|
5969 |
-
},
|
5970 |
-
eatWhile: function(match) {
|
5971 |
-
var start = this.pos;
|
5972 |
-
while (this.eat(match)){}
|
5973 |
-
return this.pos > start;
|
5974 |
-
},
|
5975 |
-
eatSpace: function() {
|
5976 |
-
var start = this.pos;
|
5977 |
-
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
|
5978 |
-
return this.pos > start;
|
5979 |
-
},
|
5980 |
-
skipToEnd: function() {this.pos = this.string.length;},
|
5981 |
-
skipTo: function(ch) {
|
5982 |
-
var found = this.string.indexOf(ch, this.pos);
|
5983 |
-
if (found > -1) {this.pos = found; return true;}
|
5984 |
-
},
|
5985 |
-
backUp: function(n) {this.pos -= n;},
|
5986 |
-
column: function() {
|
5987 |
-
if (this.lastColumnPos < this.start) {
|
5988 |
-
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
|
5989 |
-
this.lastColumnPos = this.start;
|
5990 |
-
}
|
5991 |
-
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
5992 |
-
},
|
5993 |
-
indentation: function() {
|
5994 |
-
return countColumn(this.string, null, this.tabSize) -
|
5995 |
-
(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
|
5996 |
-
},
|
5997 |
-
match: function(pattern, consume, caseInsensitive) {
|
5998 |
-
if (typeof pattern == "string") {
|
5999 |
-
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
|
6000 |
-
var substr = this.string.substr(this.pos, pattern.length);
|
6001 |
-
if (cased(substr) == cased(pattern)) {
|
6002 |
-
if (consume !== false) this.pos += pattern.length;
|
6003 |
-
return true;
|
6004 |
-
}
|
6005 |
-
} else {
|
6006 |
-
var match = this.string.slice(this.pos).match(pattern);
|
6007 |
-
if (match && match.index > 0) return null;
|
6008 |
-
if (match && consume !== false) this.pos += match[0].length;
|
6009 |
-
return match;
|
6010 |
-
}
|
6011 |
-
},
|
6012 |
-
current: function(){return this.string.slice(this.start, this.pos);},
|
6013 |
-
hideFirstChars: function(n, inner) {
|
6014 |
-
this.lineStart += n;
|
6015 |
-
try { return inner(); }
|
6016 |
-
finally { this.lineStart -= n; }
|
6017 |
-
}
|
6018 |
-
};
|
6019 |
-
|
6020 |
-
// TEXTMARKERS
|
6021 |
-
|
6022 |
-
// Created with markText and setBookmark methods. A TextMarker is a
|
6023 |
-
// handle that can be used to clear or find a marked position in the
|
6024 |
-
// document. Line objects hold arrays (markedSpans) containing
|
6025 |
-
// {from, to, marker} object pointing to such marker objects, and
|
6026 |
-
// indicating that such a marker is present on that line. Multiple
|
6027 |
-
// lines may point to the same marker when it spans across lines.
|
6028 |
-
// The spans will have null for their from/to properties when the
|
6029 |
-
// marker continues beyond the start/end of the line. Markers have
|
6030 |
-
// links back to the lines they currently touch.
|
6031 |
-
|
6032 |
-
var nextMarkerId = 0;
|
6033 |
-
|
6034 |
-
var TextMarker = CodeMirror.TextMarker = function(doc, type) {
|
6035 |
-
this.lines = [];
|
6036 |
-
this.type = type;
|
6037 |
-
this.doc = doc;
|
6038 |
-
this.id = ++nextMarkerId;
|
6039 |
-
};
|
6040 |
-
eventMixin(TextMarker);
|
6041 |
-
|
6042 |
-
// Clear the marker.
|
6043 |
-
TextMarker.prototype.clear = function() {
|
6044 |
-
if (this.explicitlyCleared) return;
|
6045 |
-
var cm = this.doc.cm, withOp = cm && !cm.curOp;
|
6046 |
-
if (withOp) startOperation(cm);
|
6047 |
-
if (hasHandler(this, "clear")) {
|
6048 |
-
var found = this.find();
|
6049 |
-
if (found) signalLater(this, "clear", found.from, found.to);
|
6050 |
-
}
|
6051 |
-
var min = null, max = null;
|
6052 |
-
for (var i = 0; i < this.lines.length; ++i) {
|
6053 |
-
var line = this.lines[i];
|
6054 |
-
var span = getMarkedSpanFor(line.markedSpans, this);
|
6055 |
-
if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
|
6056 |
-
else if (cm) {
|
6057 |
-
if (span.to != null) max = lineNo(line);
|
6058 |
-
if (span.from != null) min = lineNo(line);
|
6059 |
-
}
|
6060 |
-
line.markedSpans = removeMarkedSpan(line.markedSpans, span);
|
6061 |
-
if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
|
6062 |
-
updateLineHeight(line, textHeight(cm.display));
|
6063 |
-
}
|
6064 |
-
if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
|
6065 |
-
var visual = visualLine(this.lines[i]), len = lineLength(visual);
|
6066 |
-
if (len > cm.display.maxLineLength) {
|
6067 |
-
cm.display.maxLine = visual;
|
6068 |
-
cm.display.maxLineLength = len;
|
6069 |
-
cm.display.maxLineChanged = true;
|
6070 |
-
}
|
6071 |
-
}
|
6072 |
-
|
6073 |
-
if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
|
6074 |
-
this.lines.length = 0;
|
6075 |
-
this.explicitlyCleared = true;
|
6076 |
-
if (this.atomic && this.doc.cantEdit) {
|
6077 |
-
this.doc.cantEdit = false;
|
6078 |
-
if (cm) reCheckSelection(cm.doc);
|
6079 |
-
}
|
6080 |
-
if (cm) signalLater(cm, "markerCleared", cm, this);
|
6081 |
-
if (withOp) endOperation(cm);
|
6082 |
-
if (this.parent) this.parent.clear();
|
6083 |
-
};
|
6084 |
-
|
6085 |
-
// Find the position of the marker in the document. Returns a {from,
|
6086 |
-
// to} object by default. Side can be passed to get a specific side
|
6087 |
-
// -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
|
6088 |
-
// Pos objects returned contain a line object, rather than a line
|
6089 |
-
// number (used to prevent looking up the same line twice).
|
6090 |
-
TextMarker.prototype.find = function(side, lineObj) {
|
6091 |
-
if (side == null && this.type == "bookmark") side = 1;
|
6092 |
-
var from, to;
|
6093 |
-
for (var i = 0; i < this.lines.length; ++i) {
|
6094 |
-
var line = this.lines[i];
|
6095 |
-
var span = getMarkedSpanFor(line.markedSpans, this);
|
6096 |
-
if (span.from != null) {
|
6097 |
-
from = Pos(lineObj ? line : lineNo(line), span.from);
|
6098 |
-
if (side == -1) return from;
|
6099 |
-
}
|
6100 |
-
if (span.to != null) {
|
6101 |
-
to = Pos(lineObj ? line : lineNo(line), span.to);
|
6102 |
-
if (side == 1) return to;
|
6103 |
-
}
|
6104 |
-
}
|
6105 |
-
return from && {from: from, to: to};
|
6106 |
-
};
|
6107 |
-
|
6108 |
-
// Signals that the marker's widget changed, and surrounding layout
|
6109 |
-
// should be recomputed.
|
6110 |
-
TextMarker.prototype.changed = function() {
|
6111 |
-
var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
|
6112 |
-
if (!pos || !cm) return;
|
6113 |
-
runInOp(cm, function() {
|
6114 |
-
var line = pos.line, lineN = lineNo(pos.line);
|
6115 |
-
var view = findViewForLine(cm, lineN);
|
6116 |
-
if (view) {
|
6117 |
-
clearLineMeasurementCacheFor(view);
|
6118 |
-
cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
|
6119 |
-
}
|
6120 |
-
cm.curOp.updateMaxLine = true;
|
6121 |
-
if (!lineIsHidden(widget.doc, line) && widget.height != null) {
|
6122 |
-
var oldHeight = widget.height;
|
6123 |
-
widget.height = null;
|
6124 |
-
var dHeight = widgetHeight(widget) - oldHeight;
|
6125 |
-
if (dHeight)
|
6126 |
-
updateLineHeight(line, line.height + dHeight);
|
6127 |
-
}
|
6128 |
-
});
|
6129 |
-
};
|
6130 |
-
|
6131 |
-
TextMarker.prototype.attachLine = function(line) {
|
6132 |
-
if (!this.lines.length && this.doc.cm) {
|
6133 |
-
var op = this.doc.cm.curOp;
|
6134 |
-
if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
|
6135 |
-
(op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
|
6136 |
-
}
|
6137 |
-
this.lines.push(line);
|
6138 |
-
};
|
6139 |
-
TextMarker.prototype.detachLine = function(line) {
|
6140 |
-
this.lines.splice(indexOf(this.lines, line), 1);
|
6141 |
-
if (!this.lines.length && this.doc.cm) {
|
6142 |
-
var op = this.doc.cm.curOp;
|
6143 |
-
(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
|
6144 |
-
}
|
6145 |
-
};
|
6146 |
-
|
6147 |
-
// Collapsed markers have unique ids, in order to be able to order
|
6148 |
-
// them, which is needed for uniquely determining an outer marker
|
6149 |
-
// when they overlap (they may nest, but not partially overlap).
|
6150 |
-
var nextMarkerId = 0;
|
6151 |
-
|
6152 |
-
// Create a marker, wire it up to the right lines, and
|
6153 |
-
function markText(doc, from, to, options, type) {
|
6154 |
-
// Shared markers (across linked documents) are handled separately
|
6155 |
-
// (markTextShared will call out to this again, once per
|
6156 |
-
// document).
|
6157 |
-
if (options && options.shared) return markTextShared(doc, from, to, options, type);
|
6158 |
-
// Ensure we are in an operation.
|
6159 |
-
if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
|
6160 |
-
|
6161 |
-
var marker = new TextMarker(doc, type), diff = cmp(from, to);
|
6162 |
-
if (options) copyObj(options, marker, false);
|
6163 |
-
// Don't connect empty markers unless clearWhenEmpty is false
|
6164 |
-
if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
|
6165 |
-
return marker;
|
6166 |
-
if (marker.replacedWith) {
|
6167 |
-
// Showing up as a widget implies collapsed (widget replaces text)
|
6168 |
-
marker.collapsed = true;
|
6169 |
-
marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
|
6170 |
-
if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true");
|
6171 |
-
if (options.insertLeft) marker.widgetNode.insertLeft = true;
|
6172 |
-
}
|
6173 |
-
if (marker.collapsed) {
|
6174 |
-
if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
|
6175 |
-
from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
|
6176 |
-
throw new Error("Inserting collapsed marker partially overlapping an existing one");
|
6177 |
-
sawCollapsedSpans = true;
|
6178 |
-
}
|
6179 |
-
|
6180 |
-
if (marker.addToHistory)
|
6181 |
-
addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
|
6182 |
-
|
6183 |
-
var curLine = from.line, cm = doc.cm, updateMaxLine;
|
6184 |
-
doc.iter(curLine, to.line + 1, function(line) {
|
6185 |
-
if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
|
6186 |
-
updateMaxLine = true;
|
6187 |
-
if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
|
6188 |
-
addMarkedSpan(line, new MarkedSpan(marker,
|
6189 |
-
curLine == from.line ? from.ch : null,
|
6190 |
-
curLine == to.line ? to.ch : null));
|
6191 |
-
++curLine;
|
6192 |
-
});
|
6193 |
-
// lineIsHidden depends on the presence of the spans, so needs a second pass
|
6194 |
-
if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
|
6195 |
-
if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
|
6196 |
-
});
|
6197 |
-
|
6198 |
-
if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
|
6199 |
-
|
6200 |
-
if (marker.readOnly) {
|
6201 |
-
sawReadOnlySpans = true;
|
6202 |
-
if (doc.history.done.length || doc.history.undone.length)
|
6203 |
-
doc.clearHistory();
|
6204 |
-
}
|
6205 |
-
if (marker.collapsed) {
|
6206 |
-
marker.id = ++nextMarkerId;
|
6207 |
-
marker.atomic = true;
|
6208 |
-
}
|
6209 |
-
if (cm) {
|
6210 |
-
// Sync editor state
|
6211 |
-
if (updateMaxLine) cm.curOp.updateMaxLine = true;
|
6212 |
-
if (marker.collapsed)
|
6213 |
-
regChange(cm, from.line, to.line + 1);
|
6214 |
-
else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
|
6215 |
-
for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
|
6216 |
-
if (marker.atomic) reCheckSelection(cm.doc);
|
6217 |
-
signalLater(cm, "markerAdded", cm, marker);
|
6218 |
-
}
|
6219 |
-
return marker;
|
6220 |
-
}
|
6221 |
-
|
6222 |
-
// SHARED TEXTMARKERS
|
6223 |
-
|
6224 |
-
// A shared marker spans multiple linked documents. It is
|
6225 |
-
// implemented as a meta-marker-object controlling multiple normal
|
6226 |
-
// markers.
|
6227 |
-
var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {
|
6228 |
-
this.markers = markers;
|
6229 |
-
this.primary = primary;
|
6230 |
-
for (var i = 0; i < markers.length; ++i)
|
6231 |
-
markers[i].parent = this;
|
6232 |
-
};
|
6233 |
-
eventMixin(SharedTextMarker);
|
6234 |
-
|
6235 |
-
SharedTextMarker.prototype.clear = function() {
|
6236 |
-
if (this.explicitlyCleared) return;
|
6237 |
-
this.explicitlyCleared = true;
|
6238 |
-
for (var i = 0; i < this.markers.length; ++i)
|
6239 |
-
this.markers[i].clear();
|
6240 |
-
signalLater(this, "clear");
|
6241 |
-
};
|
6242 |
-
SharedTextMarker.prototype.find = function(side, lineObj) {
|
6243 |
-
return this.primary.find(side, lineObj);
|
6244 |
-
};
|
6245 |
-
|
6246 |
-
function markTextShared(doc, from, to, options, type) {
|
6247 |
-
options = copyObj(options);
|
6248 |
-
options.shared = false;
|
6249 |
-
var markers = [markText(doc, from, to, options, type)], primary = markers[0];
|
6250 |
-
var widget = options.widgetNode;
|
6251 |
-
linkedDocs(doc, function(doc) {
|
6252 |
-
if (widget) options.widgetNode = widget.cloneNode(true);
|
6253 |
-
markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
|
6254 |
-
for (var i = 0; i < doc.linked.length; ++i)
|
6255 |
-
if (doc.linked[i].isParent) return;
|
6256 |
-
primary = lst(markers);
|
6257 |
-
});
|
6258 |
-
return new SharedTextMarker(markers, primary);
|
6259 |
-
}
|
6260 |
-
|
6261 |
-
function findSharedMarkers(doc) {
|
6262 |
-
return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),
|
6263 |
-
function(m) { return m.parent; });
|
6264 |
-
}
|
6265 |
-
|
6266 |
-
function copySharedMarkers(doc, markers) {
|
6267 |
-
for (var i = 0; i < markers.length; i++) {
|
6268 |
-
var marker = markers[i], pos = marker.find();
|
6269 |
-
var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
|
6270 |
-
if (cmp(mFrom, mTo)) {
|
6271 |
-
var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
|
6272 |
-
marker.markers.push(subMark);
|
6273 |
-
subMark.parent = marker;
|
6274 |
-
}
|
6275 |
-
}
|
6276 |
-
}
|
6277 |
-
|
6278 |
-
function detachSharedMarkers(markers) {
|
6279 |
-
for (var i = 0; i < markers.length; i++) {
|
6280 |
-
var marker = markers[i], linked = [marker.primary.doc];;
|
6281 |
-
linkedDocs(marker.primary.doc, function(d) { linked.push(d); });
|
6282 |
-
for (var j = 0; j < marker.markers.length; j++) {
|
6283 |
-
var subMarker = marker.markers[j];
|
6284 |
-
if (indexOf(linked, subMarker.doc) == -1) {
|
6285 |
-
subMarker.parent = null;
|
6286 |
-
marker.markers.splice(j--, 1);
|
6287 |
-
}
|
6288 |
-
}
|
6289 |
-
}
|
6290 |
-
}
|
6291 |
-
|
6292 |
-
// TEXTMARKER SPANS
|
6293 |
-
|
6294 |
-
function MarkedSpan(marker, from, to) {
|
6295 |
-
this.marker = marker;
|
6296 |
-
this.from = from; this.to = to;
|
6297 |
-
}
|
6298 |
-
|
6299 |
-
// Search an array of spans for a span matching the given marker.
|
6300 |
-
function getMarkedSpanFor(spans, marker) {
|
6301 |
-
if (spans) for (var i = 0; i < spans.length; ++i) {
|
6302 |
-
var span = spans[i];
|
6303 |
-
if (span.marker == marker) return span;
|
6304 |
-
}
|
6305 |
-
}
|
6306 |
-
// Remove a span from an array, returning undefined if no spans are
|
6307 |
-
// left (we don't store arrays for lines without spans).
|
6308 |
-
function removeMarkedSpan(spans, span) {
|
6309 |
-
for (var r, i = 0; i < spans.length; ++i)
|
6310 |
-
if (spans[i] != span) (r || (r = [])).push(spans[i]);
|
6311 |
-
return r;
|
6312 |
-
}
|
6313 |
-
// Add a span to a line.
|
6314 |
-
function addMarkedSpan(line, span) {
|
6315 |
-
line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
|
6316 |
-
span.marker.attachLine(line);
|
6317 |
-
}
|
6318 |
-
|
6319 |
-
// Used for the algorithm that adjusts markers for a change in the
|
6320 |
-
// document. These functions cut an array of spans at a given
|
6321 |
-
// character position, returning an array of remaining chunks (or
|
6322 |
-
// undefined if nothing remains).
|
6323 |
-
function markedSpansBefore(old, startCh, isInsert) {
|
6324 |
-
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
6325 |
-
var span = old[i], marker = span.marker;
|
6326 |
-
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
|
6327 |
-
if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
|
6328 |
-
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
|
6329 |
-
(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
|
6330 |
-
}
|
6331 |
-
}
|
6332 |
-
return nw;
|
6333 |
-
}
|
6334 |
-
function markedSpansAfter(old, endCh, isInsert) {
|
6335 |
-
if (old) for (var i = 0, nw; i < old.length; ++i) {
|
6336 |
-
var span = old[i], marker = span.marker;
|
6337 |
-
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
|
6338 |
-
if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
|
6339 |
-
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
|
6340 |
-
(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
|
6341 |
-
span.to == null ? null : span.to - endCh));
|
6342 |
-
}
|
6343 |
-
}
|
6344 |
-
return nw;
|
6345 |
-
}
|
6346 |
-
|
6347 |
-
// Given a change object, compute the new set of marker spans that
|
6348 |
-
// cover the line in which the change took place. Removes spans
|
6349 |
-
// entirely within the change, reconnects spans belonging to the
|
6350 |
-
// same marker that appear on both sides of the change, and cuts off
|
6351 |
-
// spans partially within the change. Returns an array of span
|
6352 |
-
// arrays with one element for each line in (after) the change.
|
6353 |
-
function stretchSpansOverChange(doc, change) {
|
6354 |
-
if (change.full) return null;
|
6355 |
-
var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
|
6356 |
-
var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
|
6357 |
-
if (!oldFirst && !oldLast) return null;
|
6358 |
-
|
6359 |
-
var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
|
6360 |
-
// Get the spans that 'stick out' on both sides
|
6361 |
-
var first = markedSpansBefore(oldFirst, startCh, isInsert);
|
6362 |
-
var last = markedSpansAfter(oldLast, endCh, isInsert);
|
6363 |
-
|
6364 |
-
// Next, merge those two ends
|
6365 |
-
var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
|
6366 |
-
if (first) {
|
6367 |
-
// Fix up .to properties of first
|
6368 |
-
for (var i = 0; i < first.length; ++i) {
|
6369 |
-
var span = first[i];
|
6370 |
-
if (span.to == null) {
|
6371 |
-
var found = getMarkedSpanFor(last, span.marker);
|
6372 |
-
if (!found) span.to = startCh;
|
6373 |
-
else if (sameLine) span.to = found.to == null ? null : found.to + offset;
|
6374 |
-
}
|
6375 |
-
}
|
6376 |
-
}
|
6377 |
-
if (last) {
|
6378 |
-
// Fix up .from in last (or move them into first in case of sameLine)
|
6379 |
-
for (var i = 0; i < last.length; ++i) {
|
6380 |
-
var span = last[i];
|
6381 |
-
if (span.to != null) span.to += offset;
|
6382 |
-
if (span.from == null) {
|
6383 |
-
var found = getMarkedSpanFor(first, span.marker);
|
6384 |
-
if (!found) {
|
6385 |
-
span.from = offset;
|
6386 |
-
if (sameLine) (first || (first = [])).push(span);
|
6387 |
-
}
|
6388 |
-
} else {
|
6389 |
-
span.from += offset;
|
6390 |
-
if (sameLine) (first || (first = [])).push(span);
|
6391 |
-
}
|
6392 |
-
}
|
6393 |
-
}
|
6394 |
-
// Make sure we didn't create any zero-length spans
|
6395 |
-
if (first) first = clearEmptySpans(first);
|
6396 |
-
if (last && last != first) last = clearEmptySpans(last);
|
6397 |
-
|
6398 |
-
var newMarkers = [first];
|
6399 |
-
if (!sameLine) {
|
6400 |
-
// Fill gap with whole-line-spans
|
6401 |
-
var gap = change.text.length - 2, gapMarkers;
|
6402 |
-
if (gap > 0 && first)
|
6403 |
-
for (var i = 0; i < first.length; ++i)
|
6404 |
-
if (first[i].to == null)
|
6405 |
-
(gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
|
6406 |
-
for (var i = 0; i < gap; ++i)
|
6407 |
-
newMarkers.push(gapMarkers);
|
6408 |
-
newMarkers.push(last);
|
6409 |
-
}
|
6410 |
-
return newMarkers;
|
6411 |
-
}
|
6412 |
-
|
6413 |
-
// Remove spans that are empty and don't have a clearWhenEmpty
|
6414 |
-
// option of false.
|
6415 |
-
function clearEmptySpans(spans) {
|
6416 |
-
for (var i = 0; i < spans.length; ++i) {
|
6417 |
-
var span = spans[i];
|
6418 |
-
if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
|
6419 |
-
spans.splice(i--, 1);
|
6420 |
-
}
|
6421 |
-
if (!spans.length) return null;
|
6422 |
-
return spans;
|
6423 |
-
}
|
6424 |
-
|
6425 |
-
// Used for un/re-doing changes from the history. Combines the
|
6426 |
-
// result of computing the existing spans with the set of spans that
|
6427 |
-
// existed in the history (so that deleting around a span and then
|
6428 |
-
// undoing brings back the span).
|
6429 |
-
function mergeOldSpans(doc, change) {
|
6430 |
-
var old = getOldSpans(doc, change);
|
6431 |
-
var stretched = stretchSpansOverChange(doc, change);
|
6432 |
-
if (!old) return stretched;
|
6433 |
-
if (!stretched) return old;
|
6434 |
-
|
6435 |
-
for (var i = 0; i < old.length; ++i) {
|
6436 |
-
var oldCur = old[i], stretchCur = stretched[i];
|
6437 |
-
if (oldCur && stretchCur) {
|
6438 |
-
spans: for (var j = 0; j < stretchCur.length; ++j) {
|
6439 |
-
var span = stretchCur[j];
|
6440 |
-
for (var k = 0; k < oldCur.length; ++k)
|
6441 |
-
if (oldCur[k].marker == span.marker) continue spans;
|
6442 |
-
oldCur.push(span);
|
6443 |
-
}
|
6444 |
-
} else if (stretchCur) {
|
6445 |
-
old[i] = stretchCur;
|
6446 |
-
}
|
6447 |
-
}
|
6448 |
-
return old;
|
6449 |
-
}
|
6450 |
-
|
6451 |
-
// Used to 'clip' out readOnly ranges when making a change.
|
6452 |
-
function removeReadOnlyRanges(doc, from, to) {
|
6453 |
-
var markers = null;
|
6454 |
-
doc.iter(from.line, to.line + 1, function(line) {
|
6455 |
-
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
|
6456 |
-
var mark = line.markedSpans[i].marker;
|
6457 |
-
if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
|
6458 |
-
(markers || (markers = [])).push(mark);
|
6459 |
-
}
|
6460 |
-
});
|
6461 |
-
if (!markers) return null;
|
6462 |
-
var parts = [{from: from, to: to}];
|
6463 |
-
for (var i = 0; i < markers.length; ++i) {
|
6464 |
-
var mk = markers[i], m = mk.find(0);
|
6465 |
-
for (var j = 0; j < parts.length; ++j) {
|
6466 |
-
var p = parts[j];
|
6467 |
-
if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
|
6468 |
-
var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
|
6469 |
-
if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
|
6470 |
-
newParts.push({from: p.from, to: m.from});
|
6471 |
-
if (dto > 0 || !mk.inclusiveRight && !dto)
|
6472 |
-
newParts.push({from: m.to, to: p.to});
|
6473 |
-
parts.splice.apply(parts, newParts);
|
6474 |
-
j += newParts.length - 1;
|
6475 |
-
}
|
6476 |
-
}
|
6477 |
-
return parts;
|
6478 |
-
}
|
6479 |
-
|
6480 |
-
// Connect or disconnect spans from a line.
|
6481 |
-
function detachMarkedSpans(line) {
|
6482 |
-
var spans = line.markedSpans;
|
6483 |
-
if (!spans) return;
|
6484 |
-
for (var i = 0; i < spans.length; ++i)
|
6485 |
-
spans[i].marker.detachLine(line);
|
6486 |
-
line.markedSpans = null;
|
6487 |
-
}
|
6488 |
-
function attachMarkedSpans(line, spans) {
|
6489 |
-
if (!spans) return;
|
6490 |
-
for (var i = 0; i < spans.length; ++i)
|
6491 |
-
spans[i].marker.attachLine(line);
|
6492 |
-
line.markedSpans = spans;
|
6493 |
-
}
|
6494 |
-
|
6495 |
-
// Helpers used when computing which overlapping collapsed span
|
6496 |
-
// counts as the larger one.
|
6497 |
-
function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
|
6498 |
-
function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
|
6499 |
-
|
6500 |
-
// Returns a number indicating which of two overlapping collapsed
|
6501 |
-
// spans is larger (and thus includes the other). Falls back to
|
6502 |
-
// comparing ids when the spans cover exactly the same range.
|
6503 |
-
function compareCollapsedMarkers(a, b) {
|
6504 |
-
var lenDiff = a.lines.length - b.lines.length;
|
6505 |
-
if (lenDiff != 0) return lenDiff;
|
6506 |
-
var aPos = a.find(), bPos = b.find();
|
6507 |
-
var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
|
6508 |
-
if (fromCmp) return -fromCmp;
|
6509 |
-
var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
|
6510 |
-
if (toCmp) return toCmp;
|
6511 |
-
return b.id - a.id;
|
6512 |
-
}
|
6513 |
-
|
6514 |
-
// Find out whether a line ends or starts in a collapsed span. If
|
6515 |
-
// so, return the marker for that span.
|
6516 |
-
function collapsedSpanAtSide(line, start) {
|
6517 |
-
var sps = sawCollapsedSpans && line.markedSpans, found;
|
6518 |
-
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
|
6519 |
-
sp = sps[i];
|
6520 |
-
if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
|
6521 |
-
(!found || compareCollapsedMarkers(found, sp.marker) < 0))
|
6522 |
-
found = sp.marker;
|
6523 |
-
}
|
6524 |
-
return found;
|
6525 |
-
}
|
6526 |
-
function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
|
6527 |
-
function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
|
6528 |
-
|
6529 |
-
// Test whether there exists a collapsed span that partially
|
6530 |
-
// overlaps (covers the start or end, but not both) of a new span.
|
6531 |
-
// Such overlap is not allowed.
|
6532 |
-
function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
|
6533 |
-
var line = getLine(doc, lineNo);
|
6534 |
-
var sps = sawCollapsedSpans && line.markedSpans;
|
6535 |
-
if (sps) for (var i = 0; i < sps.length; ++i) {
|
6536 |
-
var sp = sps[i];
|
6537 |
-
if (!sp.marker.collapsed) continue;
|
6538 |
-
var found = sp.marker.find(0);
|
6539 |
-
var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
|
6540 |
-
var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
|
6541 |
-
if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
|
6542 |
-
if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) ||
|
6543 |
-
fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight)))
|
6544 |
-
return true;
|
6545 |
-
}
|
6546 |
-
}
|
6547 |
-
|
6548 |
-
// A visual line is a line as drawn on the screen. Folding, for
|
6549 |
-
// example, can cause multiple logical lines to appear on the same
|
6550 |
-
// visual line. This finds the start of the visual line that the
|
6551 |
-
// given line is part of (usually that is the line itself).
|
6552 |
-
function visualLine(line) {
|
6553 |
-
var merged;
|
6554 |
-
while (merged = collapsedSpanAtStart(line))
|
6555 |
-
line = merged.find(-1, true).line;
|
6556 |
-
return line;
|
6557 |
-
}
|
6558 |
-
|
6559 |
-
// Returns an array of logical lines that continue the visual line
|
6560 |
-
// started by the argument, or undefined if there are no such lines.
|
6561 |
-
function visualLineContinued(line) {
|
6562 |
-
var merged, lines;
|
6563 |
-
while (merged = collapsedSpanAtEnd(line)) {
|
6564 |
-
line = merged.find(1, true).line;
|
6565 |
-
(lines || (lines = [])).push(line);
|
6566 |
-
}
|
6567 |
-
return lines;
|
6568 |
-
}
|
6569 |
-
|
6570 |
-
// Get the line number of the start of the visual line that the
|
6571 |
-
// given line number is part of.
|
6572 |
-
function visualLineNo(doc, lineN) {
|
6573 |
-
var line = getLine(doc, lineN), vis = visualLine(line);
|
6574 |
-
if (line == vis) return lineN;
|
6575 |
-
return lineNo(vis);
|
6576 |
-
}
|
6577 |
-
// Get the line number of the start of the next visual line after
|
6578 |
-
// the given line.
|
6579 |
-
function visualLineEndNo(doc, lineN) {
|
6580 |
-
if (lineN > doc.lastLine()) return lineN;
|
6581 |
-
var line = getLine(doc, lineN), merged;
|
6582 |
-
if (!lineIsHidden(doc, line)) return lineN;
|
6583 |
-
while (merged = collapsedSpanAtEnd(line))
|
6584 |
-
line = merged.find(1, true).line;
|
6585 |
-
return lineNo(line) + 1;
|
6586 |
-
}
|
6587 |
-
|
6588 |
-
// Compute whether a line is hidden. Lines count as hidden when they
|
6589 |
-
// are part of a visual line that starts with another line, or when
|
6590 |
-
// they are entirely covered by collapsed, non-widget span.
|
6591 |
-
function lineIsHidden(doc, line) {
|
6592 |
-
var sps = sawCollapsedSpans && line.markedSpans;
|
6593 |
-
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
|
6594 |
-
sp = sps[i];
|
6595 |
-
if (!sp.marker.collapsed) continue;
|
6596 |
-
if (sp.from == null) return true;
|
6597 |
-
if (sp.marker.widgetNode) continue;
|
6598 |
-
if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
|
6599 |
-
return true;
|
6600 |
-
}
|
6601 |
-
}
|
6602 |
-
function lineIsHiddenInner(doc, line, span) {
|
6603 |
-
if (span.to == null) {
|
6604 |
-
var end = span.marker.find(1, true);
|
6605 |
-
return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
|
6606 |
-
}
|
6607 |
-
if (span.marker.inclusiveRight && span.to == line.text.length)
|
6608 |
-
return true;
|
6609 |
-
for (var sp, i = 0; i < line.markedSpans.length; ++i) {
|
6610 |
-
sp = line.markedSpans[i];
|
6611 |
-
if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
|
6612 |
-
(sp.to == null || sp.to != span.from) &&
|
6613 |
-
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
|
6614 |
-
lineIsHiddenInner(doc, line, sp)) return true;
|
6615 |
-
}
|
6616 |
-
}
|
6617 |
-
|
6618 |
-
// LINE WIDGETS
|
6619 |
-
|
6620 |
-
// Line widgets are block elements displayed above or below a line.
|
6621 |
-
|
6622 |
-
var LineWidget = CodeMirror.LineWidget = function(doc, node, options) {
|
6623 |
-
if (options) for (var opt in options) if (options.hasOwnProperty(opt))
|
6624 |
-
this[opt] = options[opt];
|
6625 |
-
this.doc = doc;
|
6626 |
-
this.node = node;
|
6627 |
-
};
|
6628 |
-
eventMixin(LineWidget);
|
6629 |
-
|
6630 |
-
function adjustScrollWhenAboveVisible(cm, line, diff) {
|
6631 |
-
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
|
6632 |
-
addToScrollPos(cm, null, diff);
|
6633 |
-
}
|
6634 |
-
|
6635 |
-
LineWidget.prototype.clear = function() {
|
6636 |
-
var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
|
6637 |
-
if (no == null || !ws) return;
|
6638 |
-
for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
|
6639 |
-
if (!ws.length) line.widgets = null;
|
6640 |
-
var height = widgetHeight(this);
|
6641 |
-
updateLineHeight(line, Math.max(0, line.height - height));
|
6642 |
-
if (cm) runInOp(cm, function() {
|
6643 |
-
adjustScrollWhenAboveVisible(cm, line, -height);
|
6644 |
-
regLineChange(cm, no, "widget");
|
6645 |
-
});
|
6646 |
-
};
|
6647 |
-
LineWidget.prototype.changed = function() {
|
6648 |
-
var oldH = this.height, cm = this.doc.cm, line = this.line;
|
6649 |
-
this.height = null;
|
6650 |
-
var diff = widgetHeight(this) - oldH;
|
6651 |
-
if (!diff) return;
|
6652 |
-
updateLineHeight(line, line.height + diff);
|
6653 |
-
if (cm) runInOp(cm, function() {
|
6654 |
-
cm.curOp.forceUpdate = true;
|
6655 |
-
adjustScrollWhenAboveVisible(cm, line, diff);
|
6656 |
-
});
|
6657 |
-
};
|
6658 |
-
|
6659 |
-
function widgetHeight(widget) {
|
6660 |
-
if (widget.height != null) return widget.height;
|
6661 |
-
var cm = widget.doc.cm;
|
6662 |
-
if (!cm) return 0;
|
6663 |
-
if (!contains(document.body, widget.node)) {
|
6664 |
-
var parentStyle = "position: relative;";
|
6665 |
-
if (widget.coverGutter)
|
6666 |
-
parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;";
|
6667 |
-
if (widget.noHScroll)
|
6668 |
-
parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
|
6669 |
-
removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
|
6670 |
-
}
|
6671 |
-
return widget.height = widget.node.offsetHeight;
|
6672 |
-
}
|
6673 |
-
|
6674 |
-
function addLineWidget(doc, handle, node, options) {
|
6675 |
-
var widget = new LineWidget(doc, node, options);
|
6676 |
-
var cm = doc.cm;
|
6677 |
-
if (cm && widget.noHScroll) cm.display.alignWidgets = true;
|
6678 |
-
changeLine(doc, handle, "widget", function(line) {
|
6679 |
-
var widgets = line.widgets || (line.widgets = []);
|
6680 |
-
if (widget.insertAt == null) widgets.push(widget);
|
6681 |
-
else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
|
6682 |
-
widget.line = line;
|
6683 |
-
if (cm && !lineIsHidden(doc, line)) {
|
6684 |
-
var aboveVisible = heightAtLine(line) < doc.scrollTop;
|
6685 |
-
updateLineHeight(line, line.height + widgetHeight(widget));
|
6686 |
-
if (aboveVisible) addToScrollPos(cm, null, widget.height);
|
6687 |
-
cm.curOp.forceUpdate = true;
|
6688 |
-
}
|
6689 |
-
return true;
|
6690 |
-
});
|
6691 |
-
return widget;
|
6692 |
-
}
|
6693 |
-
|
6694 |
-
// LINE DATA STRUCTURE
|
6695 |
-
|
6696 |
-
// Line objects. These hold state related to a line, including
|
6697 |
-
// highlighting info (the styles array).
|
6698 |
-
var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
|
6699 |
-
this.text = text;
|
6700 |
-
attachMarkedSpans(this, markedSpans);
|
6701 |
-
this.height = estimateHeight ? estimateHeight(this) : 1;
|
6702 |
-
};
|
6703 |
-
eventMixin(Line);
|
6704 |
-
Line.prototype.lineNo = function() { return lineNo(this); };
|
6705 |
-
|
6706 |
-
// Change the content (text, markers) of a line. Automatically
|
6707 |
-
// invalidates cached information and tries to re-estimate the
|
6708 |
-
// line's height.
|
6709 |
-
function updateLine(line, text, markedSpans, estimateHeight) {
|
6710 |
-
line.text = text;
|
6711 |
-
if (line.stateAfter) line.stateAfter = null;
|
6712 |
-
if (line.styles) line.styles = null;
|
6713 |
-
if (line.order != null) line.order = null;
|
6714 |
-
detachMarkedSpans(line);
|
6715 |
-
attachMarkedSpans(line, markedSpans);
|
6716 |
-
var estHeight = estimateHeight ? estimateHeight(line) : 1;
|
6717 |
-
if (estHeight != line.height) updateLineHeight(line, estHeight);
|
6718 |
-
}
|
6719 |
-
|
6720 |
-
// Detach a line from the document tree and its markers.
|
6721 |
-
function cleanUpLine(line) {
|
6722 |
-
line.parent = null;
|
6723 |
-
detachMarkedSpans(line);
|
6724 |
-
}
|
6725 |
-
|
6726 |
-
function extractLineClasses(type, output) {
|
6727 |
-
if (type) for (;;) {
|
6728 |
-
var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
|
6729 |
-
if (!lineClass) break;
|
6730 |
-
type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
|
6731 |
-
var prop = lineClass[1] ? "bgClass" : "textClass";
|
6732 |
-
if (output[prop] == null)
|
6733 |
-
output[prop] = lineClass[2];
|
6734 |
-
else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
|
6735 |
-
output[prop] += " " + lineClass[2];
|
6736 |
-
}
|
6737 |
-
return type;
|
6738 |
-
}
|
6739 |
-
|
6740 |
-
function callBlankLine(mode, state) {
|
6741 |
-
if (mode.blankLine) return mode.blankLine(state);
|
6742 |
-
if (!mode.innerMode) return;
|
6743 |
-
var inner = CodeMirror.innerMode(mode, state);
|
6744 |
-
if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
|
6745 |
-
}
|
6746 |
-
|
6747 |
-
function readToken(mode, stream, state, inner) {
|
6748 |
-
for (var i = 0; i < 10; i++) {
|
6749 |
-
if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode;
|
6750 |
-
var style = mode.token(stream, state);
|
6751 |
-
if (stream.pos > stream.start) return style;
|
6752 |
-
}
|
6753 |
-
throw new Error("Mode " + mode.name + " failed to advance stream.");
|
6754 |
-
}
|
6755 |
-
|
6756 |
-
// Utility for getTokenAt and getLineTokens
|
6757 |
-
function takeToken(cm, pos, precise, asArray) {
|
6758 |
-
function getObj(copy) {
|
6759 |
-
return {start: stream.start, end: stream.pos,
|
6760 |
-
string: stream.current(),
|
6761 |
-
type: style || null,
|
6762 |
-
state: copy ? copyState(doc.mode, state) : state};
|
6763 |
-
}
|
6764 |
-
|
6765 |
-
var doc = cm.doc, mode = doc.mode, style;
|
6766 |
-
pos = clipPos(doc, pos);
|
6767 |
-
var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise);
|
6768 |
-
var stream = new StringStream(line.text, cm.options.tabSize), tokens;
|
6769 |
-
if (asArray) tokens = [];
|
6770 |
-
while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
|
6771 |
-
stream.start = stream.pos;
|
6772 |
-
style = readToken(mode, stream, state);
|
6773 |
-
if (asArray) tokens.push(getObj(true));
|
6774 |
-
}
|
6775 |
-
return asArray ? tokens : getObj();
|
6776 |
-
}
|
6777 |
-
|
6778 |
-
// Run the given mode's parser over a line, calling f for each token.
|
6779 |
-
function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
|
6780 |
-
var flattenSpans = mode.flattenSpans;
|
6781 |
-
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
|
6782 |
-
var curStart = 0, curStyle = null;
|
6783 |
-
var stream = new StringStream(text, cm.options.tabSize), style;
|
6784 |
-
var inner = cm.options.addModeClass && [null];
|
6785 |
-
if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
|
6786 |
-
while (!stream.eol()) {
|
6787 |
-
if (stream.pos > cm.options.maxHighlightLength) {
|
6788 |
-
flattenSpans = false;
|
6789 |
-
if (forceToEnd) processLine(cm, text, state, stream.pos);
|
6790 |
-
stream.pos = text.length;
|
6791 |
-
style = null;
|
6792 |
-
} else {
|
6793 |
-
style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
|
6794 |
-
}
|
6795 |
-
if (inner) {
|
6796 |
-
var mName = inner[0].name;
|
6797 |
-
if (mName) style = "m-" + (style ? mName + " " + style : mName);
|
6798 |
-
}
|
6799 |
-
if (!flattenSpans || curStyle != style) {
|
6800 |
-
while (curStart < stream.start) {
|
6801 |
-
curStart = Math.min(stream.start, curStart + 50000);
|
6802 |
-
f(curStart, curStyle);
|
6803 |
-
}
|
6804 |
-
curStyle = style;
|
6805 |
-
}
|
6806 |
-
stream.start = stream.pos;
|
6807 |
-
}
|
6808 |
-
while (curStart < stream.pos) {
|
6809 |
-
// Webkit seems to refuse to render text nodes longer than 57444 characters
|
6810 |
-
var pos = Math.min(stream.pos, curStart + 50000);
|
6811 |
-
f(pos, curStyle);
|
6812 |
-
curStart = pos;
|
6813 |
-
}
|
6814 |
-
}
|
6815 |
-
|
6816 |
-
// Compute a style array (an array starting with a mode generation
|
6817 |
-
// -- for invalidation -- followed by pairs of end positions and
|
6818 |
-
// style strings), which is used to highlight the tokens on the
|
6819 |
-
// line.
|
6820 |
-
function highlightLine(cm, line, state, forceToEnd) {
|
6821 |
-
// A styles array always starts with a number identifying the
|
6822 |
-
// mode/overlays that it is based on (for easy invalidation).
|
6823 |
-
var st = [cm.state.modeGen], lineClasses = {};
|
6824 |
-
// Compute the base array of styles
|
6825 |
-
runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
|
6826 |
-
st.push(end, style);
|
6827 |
-
}, lineClasses, forceToEnd);
|
6828 |
-
|
6829 |
-
// Run overlays, adjust style array.
|
6830 |
-
for (var o = 0; o < cm.state.overlays.length; ++o) {
|
6831 |
-
var overlay = cm.state.overlays[o], i = 1, at = 0;
|
6832 |
-
runMode(cm, line.text, overlay.mode, true, function(end, style) {
|
6833 |
-
var start = i;
|
6834 |
-
// Ensure there's a token end at the current position, and that i points at it
|
6835 |
-
while (at < end) {
|
6836 |
-
var i_end = st[i];
|
6837 |
-
if (i_end > end)
|
6838 |
-
st.splice(i, 1, end, st[i+1], i_end);
|
6839 |
-
i += 2;
|
6840 |
-
at = Math.min(end, i_end);
|
6841 |
-
}
|
6842 |
-
if (!style) return;
|
6843 |
-
if (overlay.opaque) {
|
6844 |
-
st.splice(start, i - start, end, "cm-overlay " + style);
|
6845 |
-
i = start + 2;
|
6846 |
-
} else {
|
6847 |
-
for (; start < i; start += 2) {
|
6848 |
-
var cur = st[start+1];
|
6849 |
-
st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
|
6850 |
-
}
|
6851 |
-
}
|
6852 |
-
}, lineClasses);
|
6853 |
-
}
|
6854 |
-
|
6855 |
-
return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
|
6856 |
-
}
|
6857 |
-
|
6858 |
-
function getLineStyles(cm, line, updateFrontier) {
|
6859 |
-
if (!line.styles || line.styles[0] != cm.state.modeGen) {
|
6860 |
-
var state = getStateBefore(cm, lineNo(line));
|
6861 |
-
var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state);
|
6862 |
-
line.stateAfter = state;
|
6863 |
-
line.styles = result.styles;
|
6864 |
-
if (result.classes) line.styleClasses = result.classes;
|
6865 |
-
else if (line.styleClasses) line.styleClasses = null;
|
6866 |
-
if (updateFrontier === cm.doc.frontier) cm.doc.frontier++;
|
6867 |
-
}
|
6868 |
-
return line.styles;
|
6869 |
-
}
|
6870 |
-
|
6871 |
-
// Lightweight form of highlight -- proceed over this line and
|
6872 |
-
// update state, but don't save a style array. Used for lines that
|
6873 |
-
// aren't currently visible.
|
6874 |
-
function processLine(cm, text, state, startAt) {
|
6875 |
-
var mode = cm.doc.mode;
|
6876 |
-
var stream = new StringStream(text, cm.options.tabSize);
|
6877 |
-
stream.start = stream.pos = startAt || 0;
|
6878 |
-
if (text == "") callBlankLine(mode, state);
|
6879 |
-
while (!stream.eol()) {
|
6880 |
-
readToken(mode, stream, state);
|
6881 |
-
stream.start = stream.pos;
|
6882 |
-
}
|
6883 |
-
}
|
6884 |
-
|
6885 |
-
// Convert a style as returned by a mode (either null, or a string
|
6886 |
-
// containing one or more styles) to a CSS style. This is cached,
|
6887 |
-
// and also looks for line-wide styles.
|
6888 |
-
var styleToClassCache = {}, styleToClassCacheWithMode = {};
|
6889 |
-
function interpretTokenStyle(style, options) {
|
6890 |
-
if (!style || /^\s*$/.test(style)) return null;
|
6891 |
-
var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
|
6892 |
-
return cache[style] ||
|
6893 |
-
(cache[style] = style.replace(/\S+/g, "cm-$&"));
|
6894 |
-
}
|
6895 |
-
|
6896 |
-
// Render the DOM representation of the text of a line. Also builds
|
6897 |
-
// up a 'line map', which points at the DOM nodes that represent
|
6898 |
-
// specific stretches of text, and is used by the measuring code.
|
6899 |
-
// The returned object contains the DOM node, this map, and
|
6900 |
-
// information about line-wide styles that were set by the mode.
|
6901 |
-
function buildLineContent(cm, lineView) {
|
6902 |
-
// The padding-right forces the element to have a 'border', which
|
6903 |
-
// is needed on Webkit to be able to get line-level bounding
|
6904 |
-
// rectangles for it (in measureChar).
|
6905 |
-
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
|
6906 |
-
var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
|
6907 |
-
col: 0, pos: 0, cm: cm,
|
6908 |
-
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
|
6909 |
-
lineView.measure = {};
|
6910 |
-
|
6911 |
-
// Iterate over the logical lines that make up this visual line.
|
6912 |
-
for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
|
6913 |
-
var line = i ? lineView.rest[i - 1] : lineView.line, order;
|
6914 |
-
builder.pos = 0;
|
6915 |
-
builder.addToken = buildToken;
|
6916 |
-
// Optionally wire in some hacks into the token-rendering
|
6917 |
-
// algorithm, to deal with browser quirks.
|
6918 |
-
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
|
6919 |
-
builder.addToken = buildTokenBadBidi(builder.addToken, order);
|
6920 |
-
builder.map = [];
|
6921 |
-
var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
|
6922 |
-
insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
|
6923 |
-
if (line.styleClasses) {
|
6924 |
-
if (line.styleClasses.bgClass)
|
6925 |
-
builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
|
6926 |
-
if (line.styleClasses.textClass)
|
6927 |
-
builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
|
6928 |
-
}
|
6929 |
-
|
6930 |
-
// Ensure at least a single node is present, for measuring.
|
6931 |
-
if (builder.map.length == 0)
|
6932 |
-
builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
|
6933 |
-
|
6934 |
-
// Store the map and a cache object for the current logical line
|
6935 |
-
if (i == 0) {
|
6936 |
-
lineView.measure.map = builder.map;
|
6937 |
-
lineView.measure.cache = {};
|
6938 |
-
} else {
|
6939 |
-
(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
|
6940 |
-
(lineView.measure.caches || (lineView.measure.caches = [])).push({});
|
6941 |
-
}
|
6942 |
-
}
|
6943 |
-
|
6944 |
-
// See issue #2901
|
6945 |
-
if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className))
|
6946 |
-
builder.content.className = "cm-tab-wrap-hack";
|
6947 |
-
|
6948 |
-
signal(cm, "renderLine", cm, lineView.line, builder.pre);
|
6949 |
-
if (builder.pre.className)
|
6950 |
-
builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
|
6951 |
-
|
6952 |
-
return builder;
|
6953 |
-
}
|
6954 |
-
|
6955 |
-
function defaultSpecialCharPlaceholder(ch) {
|
6956 |
-
var token = elt("span", "\u2022", "cm-invalidchar");
|
6957 |
-
token.title = "\\u" + ch.charCodeAt(0).toString(16);
|
6958 |
-
token.setAttribute("aria-label", token.title);
|
6959 |
-
return token;
|
6960 |
-
}
|
6961 |
-
|
6962 |
-
// Build up the DOM representation for a single token, and add it to
|
6963 |
-
// the line map. Takes care to render special characters separately.
|
6964 |
-
function buildToken(builder, text, style, startStyle, endStyle, title, css) {
|
6965 |
-
if (!text) return;
|
6966 |
-
var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text;
|
6967 |
-
var special = builder.cm.state.specialChars, mustWrap = false;
|
6968 |
-
if (!special.test(text)) {
|
6969 |
-
builder.col += text.length;
|
6970 |
-
var content = document.createTextNode(displayText);
|
6971 |
-
builder.map.push(builder.pos, builder.pos + text.length, content);
|
6972 |
-
if (ie && ie_version < 9) mustWrap = true;
|
6973 |
-
builder.pos += text.length;
|
6974 |
-
} else {
|
6975 |
-
var content = document.createDocumentFragment(), pos = 0;
|
6976 |
-
while (true) {
|
6977 |
-
special.lastIndex = pos;
|
6978 |
-
var m = special.exec(text);
|
6979 |
-
var skipped = m ? m.index - pos : text.length - pos;
|
6980 |
-
if (skipped) {
|
6981 |
-
var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
|
6982 |
-
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
|
6983 |
-
else content.appendChild(txt);
|
6984 |
-
builder.map.push(builder.pos, builder.pos + skipped, txt);
|
6985 |
-
builder.col += skipped;
|
6986 |
-
builder.pos += skipped;
|
6987 |
-
}
|
6988 |
-
if (!m) break;
|
6989 |
-
pos += skipped + 1;
|
6990 |
-
if (m[0] == "\t") {
|
6991 |
-
var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
|
6992 |
-
var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
|
6993 |
-
txt.setAttribute("role", "presentation");
|
6994 |
-
txt.setAttribute("cm-text", "\t");
|
6995 |
-
builder.col += tabWidth;
|
6996 |
-
} else if (m[0] == "\r" || m[0] == "\n") {
|
6997 |
-
var txt = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
|
6998 |
-
txt.setAttribute("cm-text", m[0]);
|
6999 |
-
builder.col += 1;
|
7000 |
-
} else {
|
7001 |
-
var txt = builder.cm.options.specialCharPlaceholder(m[0]);
|
7002 |
-
txt.setAttribute("cm-text", m[0]);
|
7003 |
-
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
|
7004 |
-
else content.appendChild(txt);
|
7005 |
-
builder.col += 1;
|
7006 |
-
}
|
7007 |
-
builder.map.push(builder.pos, builder.pos + 1, txt);
|
7008 |
-
builder.pos++;
|
7009 |
-
}
|
7010 |
-
}
|
7011 |
-
if (style || startStyle || endStyle || mustWrap || css) {
|
7012 |
-
var fullStyle = style || "";
|
7013 |
-
if (startStyle) fullStyle += startStyle;
|
7014 |
-
if (endStyle) fullStyle += endStyle;
|
7015 |
-
var token = elt("span", [content], fullStyle, css);
|
7016 |
-
if (title) token.title = title;
|
7017 |
-
return builder.content.appendChild(token);
|
7018 |
-
}
|
7019 |
-
builder.content.appendChild(content);
|
7020 |
-
}
|
7021 |
-
|
7022 |
-
function splitSpaces(old) {
|
7023 |
-
var out = " ";
|
7024 |
-
for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
|
7025 |
-
out += " ";
|
7026 |
-
return out;
|
7027 |
-
}
|
7028 |
-
|
7029 |
-
// Work around nonsense dimensions being reported for stretches of
|
7030 |
-
// right-to-left text.
|
7031 |
-
function buildTokenBadBidi(inner, order) {
|
7032 |
-
return function(builder, text, style, startStyle, endStyle, title, css) {
|
7033 |
-
style = style ? style + " cm-force-border" : "cm-force-border";
|
7034 |
-
var start = builder.pos, end = start + text.length;
|
7035 |
-
for (;;) {
|
7036 |
-
// Find the part that overlaps with the start of this text
|
7037 |
-
for (var i = 0; i < order.length; i++) {
|
7038 |
-
var part = order[i];
|
7039 |
-
if (part.to > start && part.from <= start) break;
|
7040 |
-
}
|
7041 |
-
if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css);
|
7042 |
-
inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css);
|
7043 |
-
startStyle = null;
|
7044 |
-
text = text.slice(part.to - start);
|
7045 |
-
start = part.to;
|
7046 |
-
}
|
7047 |
-
};
|
7048 |
-
}
|
7049 |
-
|
7050 |
-
function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
|
7051 |
-
var widget = !ignoreWidget && marker.widgetNode;
|
7052 |
-
if (widget) builder.map.push(builder.pos, builder.pos + size, widget);
|
7053 |
-
if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
|
7054 |
-
if (!widget)
|
7055 |
-
widget = builder.content.appendChild(document.createElement("span"));
|
7056 |
-
widget.setAttribute("cm-marker", marker.id);
|
7057 |
-
}
|
7058 |
-
if (widget) {
|
7059 |
-
builder.cm.display.input.setUneditable(widget);
|
7060 |
-
builder.content.appendChild(widget);
|
7061 |
-
}
|
7062 |
-
builder.pos += size;
|
7063 |
-
}
|
7064 |
-
|
7065 |
-
// Outputs a number of spans to make up a line, taking highlighting
|
7066 |
-
// and marked text into account.
|
7067 |
-
function insertLineContent(line, builder, styles) {
|
7068 |
-
var spans = line.markedSpans, allText = line.text, at = 0;
|
7069 |
-
if (!spans) {
|
7070 |
-
for (var i = 1; i < styles.length; i+=2)
|
7071 |
-
builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
|
7072 |
-
return;
|
7073 |
-
}
|
7074 |
-
|
7075 |
-
var len = allText.length, pos = 0, i = 1, text = "", style, css;
|
7076 |
-
var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
|
7077 |
-
for (;;) {
|
7078 |
-
if (nextChange == pos) { // Update current marker set
|
7079 |
-
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
|
7080 |
-
collapsed = null; nextChange = Infinity;
|
7081 |
-
var foundBookmarks = [];
|
7082 |
-
for (var j = 0; j < spans.length; ++j) {
|
7083 |
-
var sp = spans[j], m = sp.marker;
|
7084 |
-
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
|
7085 |
-
foundBookmarks.push(m);
|
7086 |
-
} else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
|
7087 |
-
if (sp.to != null && sp.to != pos && nextChange > sp.to) {
|
7088 |
-
nextChange = sp.to;
|
7089 |
-
spanEndStyle = "";
|
7090 |
-
}
|
7091 |
-
if (m.className) spanStyle += " " + m.className;
|
7092 |
-
if (m.css) css = (css ? css + ";" : "") + m.css;
|
7093 |
-
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
|
7094 |
-
if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
|
7095 |
-
if (m.title && !title) title = m.title;
|
7096 |
-
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
7097 |
-
collapsed = sp;
|
7098 |
-
} else if (sp.from > pos && nextChange > sp.from) {
|
7099 |
-
nextChange = sp.from;
|
7100 |
-
}
|
7101 |
-
}
|
7102 |
-
if (collapsed && (collapsed.from || 0) == pos) {
|
7103 |
-
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
7104 |
-
collapsed.marker, collapsed.from == null);
|
7105 |
-
if (collapsed.to == null) return;
|
7106 |
-
if (collapsed.to == pos) collapsed = false;
|
7107 |
-
}
|
7108 |
-
if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
|
7109 |
-
buildCollapsedSpan(builder, 0, foundBookmarks[j]);
|
7110 |
-
}
|
7111 |
-
if (pos >= len) break;
|
7112 |
-
|
7113 |
-
var upto = Math.min(len, nextChange);
|
7114 |
-
while (true) {
|
7115 |
-
if (text) {
|
7116 |
-
var end = pos + text.length;
|
7117 |
-
if (!collapsed) {
|
7118 |
-
var tokenText = end > upto ? text.slice(0, upto - pos) : text;
|
7119 |
-
builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
|
7120 |
-
spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
|
7121 |
-
}
|
7122 |
-
if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
|
7123 |
-
pos = end;
|
7124 |
-
spanStartStyle = "";
|
7125 |
-
}
|
7126 |
-
text = allText.slice(at, at = styles[i++]);
|
7127 |
-
style = interpretTokenStyle(styles[i++], builder.cm.options);
|
7128 |
-
}
|
7129 |
-
}
|
7130 |
-
}
|
7131 |
-
|
7132 |
-
// DOCUMENT DATA STRUCTURE
|
7133 |
-
|
7134 |
-
// By default, updates that start and end at the beginning of a line
|
7135 |
-
// are treated specially, in order to make the association of line
|
7136 |
-
// widgets and marker elements with the text behave more intuitive.
|
7137 |
-
function isWholeLineUpdate(doc, change) {
|
7138 |
-
return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
|
7139 |
-
(!doc.cm || doc.cm.options.wholeLineUpdateBefore);
|
7140 |
-
}
|
7141 |
-
|
7142 |
-
// Perform a change on the document data structure.
|
7143 |
-
function updateDoc(doc, change, markedSpans, estimateHeight) {
|
7144 |
-
function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
|
7145 |
-
function update(line, text, spans) {
|
7146 |
-
updateLine(line, text, spans, estimateHeight);
|
7147 |
-
signalLater(line, "change", line, change);
|
7148 |
-
}
|
7149 |
-
function linesFor(start, end) {
|
7150 |
-
for (var i = start, result = []; i < end; ++i)
|
7151 |
-
result.push(new Line(text[i], spansFor(i), estimateHeight));
|
7152 |
-
return result;
|
7153 |
-
}
|
7154 |
-
|
7155 |
-
var from = change.from, to = change.to, text = change.text;
|
7156 |
-
var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
|
7157 |
-
var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
|
7158 |
-
|
7159 |
-
// Adjust the line structure
|
7160 |
-
if (change.full) {
|
7161 |
-
doc.insert(0, linesFor(0, text.length));
|
7162 |
-
doc.remove(text.length, doc.size - text.length);
|
7163 |
-
} else if (isWholeLineUpdate(doc, change)) {
|
7164 |
-
// This is a whole-line replace. Treated specially to make
|
7165 |
-
// sure line objects move the way they are supposed to.
|
7166 |
-
var added = linesFor(0, text.length - 1);
|
7167 |
-
update(lastLine, lastLine.text, lastSpans);
|
7168 |
-
if (nlines) doc.remove(from.line, nlines);
|
7169 |
-
if (added.length) doc.insert(from.line, added);
|
7170 |
-
} else if (firstLine == lastLine) {
|
7171 |
-
if (text.length == 1) {
|
7172 |
-
update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
|
7173 |
-
} else {
|
7174 |
-
var added = linesFor(1, text.length - 1);
|
7175 |
-
added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
|
7176 |
-
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
|
7177 |
-
doc.insert(from.line + 1, added);
|
7178 |
-
}
|
7179 |
-
} else if (text.length == 1) {
|
7180 |
-
update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
|
7181 |
-
doc.remove(from.line + 1, nlines);
|
7182 |
-
} else {
|
7183 |
-
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
|
7184 |
-
update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
|
7185 |
-
var added = linesFor(1, text.length - 1);
|
7186 |
-
if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
|
7187 |
-
doc.insert(from.line + 1, added);
|
7188 |
-
}
|
7189 |
-
|
7190 |
-
signalLater(doc, "change", doc, change);
|
7191 |
-
}
|
7192 |
-
|
7193 |
-
// The document is represented as a BTree consisting of leaves, with
|
7194 |
-
// chunk of lines in them, and branches, with up to ten leaves or
|
7195 |
-
// other branch nodes below them. The top node is always a branch
|
7196 |
-
// node, and is the document object itself (meaning it has
|
7197 |
-
// additional methods and properties).
|
7198 |
-
//
|
7199 |
-
// All nodes have parent links. The tree is used both to go from
|
7200 |
-
// line numbers to line objects, and to go from objects to numbers.
|
7201 |
-
// It also indexes by height, and is used to convert between height
|
7202 |
-
// and line object, and to find the total height of the document.
|
7203 |
-
//
|
7204 |
-
// See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
|
7205 |
-
|
7206 |
-
function LeafChunk(lines) {
|
7207 |
-
this.lines = lines;
|
7208 |
-
this.parent = null;
|
7209 |
-
for (var i = 0, height = 0; i < lines.length; ++i) {
|
7210 |
-
lines[i].parent = this;
|
7211 |
-
height += lines[i].height;
|
7212 |
-
}
|
7213 |
-
this.height = height;
|
7214 |
-
}
|
7215 |
-
|
7216 |
-
LeafChunk.prototype = {
|
7217 |
-
chunkSize: function() { return this.lines.length; },
|
7218 |
-
// Remove the n lines at offset 'at'.
|
7219 |
-
removeInner: function(at, n) {
|
7220 |
-
for (var i = at, e = at + n; i < e; ++i) {
|
7221 |
-
var line = this.lines[i];
|
7222 |
-
this.height -= line.height;
|
7223 |
-
cleanUpLine(line);
|
7224 |
-
signalLater(line, "delete");
|
7225 |
-
}
|
7226 |
-
this.lines.splice(at, n);
|
7227 |
-
},
|
7228 |
-
// Helper used to collapse a small branch into a single leaf.
|
7229 |
-
collapse: function(lines) {
|
7230 |
-
lines.push.apply(lines, this.lines);
|
7231 |
-
},
|
7232 |
-
// Insert the given array of lines at offset 'at', count them as
|
7233 |
-
// having the given height.
|
7234 |
-
insertInner: function(at, lines, height) {
|
7235 |
-
this.height += height;
|
7236 |
-
this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
|
7237 |
-
for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
|
7238 |
-
},
|
7239 |
-
// Used to iterate over a part of the tree.
|
7240 |
-
iterN: function(at, n, op) {
|
7241 |
-
for (var e = at + n; at < e; ++at)
|
7242 |
-
if (op(this.lines[at])) return true;
|
7243 |
-
}
|
7244 |
-
};
|
7245 |
-
|
7246 |
-
function BranchChunk(children) {
|
7247 |
-
this.children = children;
|
7248 |
-
var size = 0, height = 0;
|
7249 |
-
for (var i = 0; i < children.length; ++i) {
|
7250 |
-
var ch = children[i];
|
7251 |
-
size += ch.chunkSize(); height += ch.height;
|
7252 |
-
ch.parent = this;
|
7253 |
-
}
|
7254 |
-
this.size = size;
|
7255 |
-
this.height = height;
|
7256 |
-
this.parent = null;
|
7257 |
-
}
|
7258 |
-
|
7259 |
-
BranchChunk.prototype = {
|
7260 |
-
chunkSize: function() { return this.size; },
|
7261 |
-
removeInner: function(at, n) {
|
7262 |
-
this.size -= n;
|
7263 |
-
for (var i = 0; i < this.children.length; ++i) {
|
7264 |
-
var child = this.children[i], sz = child.chunkSize();
|
7265 |
-
if (at < sz) {
|
7266 |
-
var rm = Math.min(n, sz - at), oldHeight = child.height;
|
7267 |
-
child.removeInner(at, rm);
|
7268 |
-
this.height -= oldHeight - child.height;
|
7269 |
-
if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
|
7270 |
-
if ((n -= rm) == 0) break;
|
7271 |
-
at = 0;
|
7272 |
-
} else at -= sz;
|
7273 |
-
}
|
7274 |
-
// If the result is smaller than 25 lines, ensure that it is a
|
7275 |
-
// single leaf node.
|
7276 |
-
if (this.size - n < 25 &&
|
7277 |
-
(this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
|
7278 |
-
var lines = [];
|
7279 |
-
this.collapse(lines);
|
7280 |
-
this.children = [new LeafChunk(lines)];
|
7281 |
-
this.children[0].parent = this;
|
7282 |
-
}
|
7283 |
-
},
|
7284 |
-
collapse: function(lines) {
|
7285 |
-
for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);
|
7286 |
-
},
|
7287 |
-
insertInner: function(at, lines, height) {
|
7288 |
-
this.size += lines.length;
|
7289 |
-
this.height += height;
|
7290 |
-
for (var i = 0; i < this.children.length; ++i) {
|
7291 |
-
var child = this.children[i], sz = child.chunkSize();
|
7292 |
-
if (at <= sz) {
|
7293 |
-
child.insertInner(at, lines, height);
|
7294 |
-
if (child.lines && child.lines.length > 50) {
|
7295 |
-
while (child.lines.length > 50) {
|
7296 |
-
var spilled = child.lines.splice(child.lines.length - 25, 25);
|
7297 |
-
var newleaf = new LeafChunk(spilled);
|
7298 |
-
child.height -= newleaf.height;
|
7299 |
-
this.children.splice(i + 1, 0, newleaf);
|
7300 |
-
newleaf.parent = this;
|
7301 |
-
}
|
7302 |
-
this.maybeSpill();
|
7303 |
-
}
|
7304 |
-
break;
|
7305 |
-
}
|
7306 |
-
at -= sz;
|
7307 |
-
}
|
7308 |
-
},
|
7309 |
-
// When a node has grown, check whether it should be split.
|
7310 |
-
maybeSpill: function() {
|
7311 |
-
if (this.children.length <= 10) return;
|
7312 |
-
var me = this;
|
7313 |
-
do {
|
7314 |
-
var spilled = me.children.splice(me.children.length - 5, 5);
|
7315 |
-
var sibling = new BranchChunk(spilled);
|
7316 |
-
if (!me.parent) { // Become the parent node
|
7317 |
-
var copy = new BranchChunk(me.children);
|
7318 |
-
copy.parent = me;
|
7319 |
-
me.children = [copy, sibling];
|
7320 |
-
me = copy;
|
7321 |
-
} else {
|
7322 |
-
me.size -= sibling.size;
|
7323 |
-
me.height -= sibling.height;
|
7324 |
-
var myIndex = indexOf(me.parent.children, me);
|
7325 |
-
me.parent.children.splice(myIndex + 1, 0, sibling);
|
7326 |
-
}
|
7327 |
-
sibling.parent = me.parent;
|
7328 |
-
} while (me.children.length > 10);
|
7329 |
-
me.parent.maybeSpill();
|
7330 |
-
},
|
7331 |
-
iterN: function(at, n, op) {
|
7332 |
-
for (var i = 0; i < this.children.length; ++i) {
|
7333 |
-
var child = this.children[i], sz = child.chunkSize();
|
7334 |
-
if (at < sz) {
|
7335 |
-
var used = Math.min(n, sz - at);
|
7336 |
-
if (child.iterN(at, used, op)) return true;
|
7337 |
-
if ((n -= used) == 0) break;
|
7338 |
-
at = 0;
|
7339 |
-
} else at -= sz;
|
7340 |
-
}
|
7341 |
-
}
|
7342 |
-
};
|
7343 |
-
|
7344 |
-
var nextDocId = 0;
|
7345 |
-
var Doc = CodeMirror.Doc = function(text, mode, firstLine, lineSep) {
|
7346 |
-
if (!(this instanceof Doc)) return new Doc(text, mode, firstLine, lineSep);
|
7347 |
-
if (firstLine == null) firstLine = 0;
|
7348 |
-
|
7349 |
-
BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
|
7350 |
-
this.first = firstLine;
|
7351 |
-
this.scrollTop = this.scrollLeft = 0;
|
7352 |
-
this.cantEdit = false;
|
7353 |
-
this.cleanGeneration = 1;
|
7354 |
-
this.frontier = firstLine;
|
7355 |
-
var start = Pos(firstLine, 0);
|
7356 |
-
this.sel = simpleSelection(start);
|
7357 |
-
this.history = new History(null);
|
7358 |
-
this.id = ++nextDocId;
|
7359 |
-
this.modeOption = mode;
|
7360 |
-
this.lineSep = lineSep;
|
7361 |
-
this.extend = false;
|
7362 |
-
|
7363 |
-
if (typeof text == "string") text = this.splitLines(text);
|
7364 |
-
updateDoc(this, {from: start, to: start, text: text});
|
7365 |
-
setSelection(this, simpleSelection(start), sel_dontScroll);
|
7366 |
-
};
|
7367 |
-
|
7368 |
-
Doc.prototype = createObj(BranchChunk.prototype, {
|
7369 |
-
constructor: Doc,
|
7370 |
-
// Iterate over the document. Supports two forms -- with only one
|
7371 |
-
// argument, it calls that for each line in the document. With
|
7372 |
-
// three, it iterates over the range given by the first two (with
|
7373 |
-
// the second being non-inclusive).
|
7374 |
-
iter: function(from, to, op) {
|
7375 |
-
if (op) this.iterN(from - this.first, to - from, op);
|
7376 |
-
else this.iterN(this.first, this.first + this.size, from);
|
7377 |
-
},
|
7378 |
-
|
7379 |
-
// Non-public interface for adding and removing lines.
|
7380 |
-
insert: function(at, lines) {
|
7381 |
-
var height = 0;
|
7382 |
-
for (var i = 0; i < lines.length; ++i) height += lines[i].height;
|
7383 |
-
this.insertInner(at - this.first, lines, height);
|
7384 |
-
},
|
7385 |
-
remove: function(at, n) { this.removeInner(at - this.first, n); },
|
7386 |
-
|
7387 |
-
// From here, the methods are part of the public interface. Most
|
7388 |
-
// are also available from CodeMirror (editor) instances.
|
7389 |
-
|
7390 |
-
getValue: function(lineSep) {
|
7391 |
-
var lines = getLines(this, this.first, this.first + this.size);
|
7392 |
-
if (lineSep === false) return lines;
|
7393 |
-
return lines.join(lineSep || this.lineSeparator());
|
7394 |
-
},
|
7395 |
-
setValue: docMethodOp(function(code) {
|
7396 |
-
var top = Pos(this.first, 0), last = this.first + this.size - 1;
|
7397 |
-
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
|
7398 |
-
text: this.splitLines(code), origin: "setValue", full: true}, true);
|
7399 |
-
setSelection(this, simpleSelection(top));
|
7400 |
-
}),
|
7401 |
-
replaceRange: function(code, from, to, origin) {
|
7402 |
-
from = clipPos(this, from);
|
7403 |
-
to = to ? clipPos(this, to) : from;
|
7404 |
-
replaceRange(this, code, from, to, origin);
|
7405 |
-
},
|
7406 |
-
getRange: function(from, to, lineSep) {
|
7407 |
-
var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
|
7408 |
-
if (lineSep === false) return lines;
|
7409 |
-
return lines.join(lineSep || this.lineSeparator());
|
7410 |
-
},
|
7411 |
-
|
7412 |
-
getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
|
7413 |
-
|
7414 |
-
getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
|
7415 |
-
getLineNumber: function(line) {return lineNo(line);},
|
7416 |
-
|
7417 |
-
getLineHandleVisualStart: function(line) {
|
7418 |
-
if (typeof line == "number") line = getLine(this, line);
|
7419 |
-
return visualLine(line);
|
7420 |
-
},
|
7421 |
-
|
7422 |
-
lineCount: function() {return this.size;},
|
7423 |
-
firstLine: function() {return this.first;},
|
7424 |
-
lastLine: function() {return this.first + this.size - 1;},
|
7425 |
-
|
7426 |
-
clipPos: function(pos) {return clipPos(this, pos);},
|
7427 |
-
|
7428 |
-
getCursor: function(start) {
|
7429 |
-
var range = this.sel.primary(), pos;
|
7430 |
-
if (start == null || start == "head") pos = range.head;
|
7431 |
-
else if (start == "anchor") pos = range.anchor;
|
7432 |
-
else if (start == "end" || start == "to" || start === false) pos = range.to();
|
7433 |
-
else pos = range.from();
|
7434 |
-
return pos;
|
7435 |
-
},
|
7436 |
-
listSelections: function() { return this.sel.ranges; },
|
7437 |
-
somethingSelected: function() {return this.sel.somethingSelected();},
|
7438 |
-
|
7439 |
-
setCursor: docMethodOp(function(line, ch, options) {
|
7440 |
-
setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
|
7441 |
-
}),
|
7442 |
-
setSelection: docMethodOp(function(anchor, head, options) {
|
7443 |
-
setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
|
7444 |
-
}),
|
7445 |
-
extendSelection: docMethodOp(function(head, other, options) {
|
7446 |
-
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
|
7447 |
-
}),
|
7448 |
-
extendSelections: docMethodOp(function(heads, options) {
|
7449 |
-
extendSelections(this, clipPosArray(this, heads, options));
|
7450 |
-
}),
|
7451 |
-
extendSelectionsBy: docMethodOp(function(f, options) {
|
7452 |
-
extendSelections(this, map(this.sel.ranges, f), options);
|
7453 |
-
}),
|
7454 |
-
setSelections: docMethodOp(function(ranges, primary, options) {
|
7455 |
-
if (!ranges.length) return;
|
7456 |
-
for (var i = 0, out = []; i < ranges.length; i++)
|
7457 |
-
out[i] = new Range(clipPos(this, ranges[i].anchor),
|
7458 |
-
clipPos(this, ranges[i].head));
|
7459 |
-
if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
|
7460 |
-
setSelection(this, normalizeSelection(out, primary), options);
|
7461 |
-
}),
|
7462 |
-
addSelection: docMethodOp(function(anchor, head, options) {
|
7463 |
-
var ranges = this.sel.ranges.slice(0);
|
7464 |
-
ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
|
7465 |
-
setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
|
7466 |
-
}),
|
7467 |
-
|
7468 |
-
getSelection: function(lineSep) {
|
7469 |
-
var ranges = this.sel.ranges, lines;
|
7470 |
-
for (var i = 0; i < ranges.length; i++) {
|
7471 |
-
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
|
7472 |
-
lines = lines ? lines.concat(sel) : sel;
|
7473 |
-
}
|
7474 |
-
if (lineSep === false) return lines;
|
7475 |
-
else return lines.join(lineSep || this.lineSeparator());
|
7476 |
-
},
|
7477 |
-
getSelections: function(lineSep) {
|
7478 |
-
var parts = [], ranges = this.sel.ranges;
|
7479 |
-
for (var i = 0; i < ranges.length; i++) {
|
7480 |
-
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
|
7481 |
-
if (lineSep !== false) sel = sel.join(lineSep || this.lineSeparator());
|
7482 |
-
parts[i] = sel;
|
7483 |
-
}
|
7484 |
-
return parts;
|
7485 |
-
},
|
7486 |
-
replaceSelection: function(code, collapse, origin) {
|
7487 |
-
var dup = [];
|
7488 |
-
for (var i = 0; i < this.sel.ranges.length; i++)
|
7489 |
-
dup[i] = code;
|
7490 |
-
this.replaceSelections(dup, collapse, origin || "+input");
|
7491 |
-
},
|
7492 |
-
replaceSelections: docMethodOp(function(code, collapse, origin) {
|
7493 |
-
var changes = [], sel = this.sel;
|
7494 |
-
for (var i = 0; i < sel.ranges.length; i++) {
|
7495 |
-
var range = sel.ranges[i];
|
7496 |
-
changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin};
|
7497 |
-
}
|
7498 |
-
var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
|
7499 |
-
for (var i = changes.length - 1; i >= 0; i--)
|
7500 |
-
makeChange(this, changes[i]);
|
7501 |
-
if (newSel) setSelectionReplaceHistory(this, newSel);
|
7502 |
-
else if (this.cm) ensureCursorVisible(this.cm);
|
7503 |
-
}),
|
7504 |
-
undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
|
7505 |
-
redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
|
7506 |
-
undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
|
7507 |
-
redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
|
7508 |
-
|
7509 |
-
setExtending: function(val) {this.extend = val;},
|
7510 |
-
getExtending: function() {return this.extend;},
|
7511 |
-
|
7512 |
-
historySize: function() {
|
7513 |
-
var hist = this.history, done = 0, undone = 0;
|
7514 |
-
for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
|
7515 |
-
for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
|
7516 |
-
return {undo: done, redo: undone};
|
7517 |
-
},
|
7518 |
-
clearHistory: function() {this.history = new History(this.history.maxGeneration);},
|
7519 |
-
|
7520 |
-
markClean: function() {
|
7521 |
-
this.cleanGeneration = this.changeGeneration(true);
|
7522 |
-
},
|
7523 |
-
changeGeneration: function(forceSplit) {
|
7524 |
-
if (forceSplit)
|
7525 |
-
this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
|
7526 |
-
return this.history.generation;
|
7527 |
-
},
|
7528 |
-
isClean: function (gen) {
|
7529 |
-
return this.history.generation == (gen || this.cleanGeneration);
|
7530 |
-
},
|
7531 |
-
|
7532 |
-
getHistory: function() {
|
7533 |
-
return {done: copyHistoryArray(this.history.done),
|
7534 |
-
undone: copyHistoryArray(this.history.undone)};
|
7535 |
-
},
|
7536 |
-
setHistory: function(histData) {
|
7537 |
-
var hist = this.history = new History(this.history.maxGeneration);
|
7538 |
-
hist.done = copyHistoryArray(histData.done.slice(0), null, true);
|
7539 |
-
hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
|
7540 |
-
},
|
7541 |
-
|
7542 |
-
addLineClass: docMethodOp(function(handle, where, cls) {
|
7543 |
-
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
|
7544 |
-
var prop = where == "text" ? "textClass"
|
7545 |
-
: where == "background" ? "bgClass"
|
7546 |
-
: where == "gutter" ? "gutterClass" : "wrapClass";
|
7547 |
-
if (!line[prop]) line[prop] = cls;
|
7548 |
-
else if (classTest(cls).test(line[prop])) return false;
|
7549 |
-
else line[prop] += " " + cls;
|
7550 |
-
return true;
|
7551 |
-
});
|
7552 |
-
}),
|
7553 |
-
removeLineClass: docMethodOp(function(handle, where, cls) {
|
7554 |
-
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
|
7555 |
-
var prop = where == "text" ? "textClass"
|
7556 |
-
: where == "background" ? "bgClass"
|
7557 |
-
: where == "gutter" ? "gutterClass" : "wrapClass";
|
7558 |
-
var cur = line[prop];
|
7559 |
-
if (!cur) return false;
|
7560 |
-
else if (cls == null) line[prop] = null;
|
7561 |
-
else {
|
7562 |
-
var found = cur.match(classTest(cls));
|
7563 |
-
if (!found) return false;
|
7564 |
-
var end = found.index + found[0].length;
|
7565 |
-
line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
|
7566 |
-
}
|
7567 |
-
return true;
|
7568 |
-
});
|
7569 |
-
}),
|
7570 |
-
|
7571 |
-
addLineWidget: docMethodOp(function(handle, node, options) {
|
7572 |
-
return addLineWidget(this, handle, node, options);
|
7573 |
-
}),
|
7574 |
-
removeLineWidget: function(widget) { widget.clear(); },
|
7575 |
-
|
7576 |
-
markText: function(from, to, options) {
|
7577 |
-
return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range");
|
7578 |
-
},
|
7579 |
-
setBookmark: function(pos, options) {
|
7580 |
-
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
|
7581 |
-
insertLeft: options && options.insertLeft,
|
7582 |
-
clearWhenEmpty: false, shared: options && options.shared,
|
7583 |
-
handleMouseEvents: options && options.handleMouseEvents};
|
7584 |
-
pos = clipPos(this, pos);
|
7585 |
-
return markText(this, pos, pos, realOpts, "bookmark");
|
7586 |
-
},
|
7587 |
-
findMarksAt: function(pos) {
|
7588 |
-
pos = clipPos(this, pos);
|
7589 |
-
var markers = [], spans = getLine(this, pos.line).markedSpans;
|
7590 |
-
if (spans) for (var i = 0; i < spans.length; ++i) {
|
7591 |
-
var span = spans[i];
|
7592 |
-
if ((span.from == null || span.from <= pos.ch) &&
|
7593 |
-
(span.to == null || span.to >= pos.ch))
|
7594 |
-
markers.push(span.marker.parent || span.marker);
|
7595 |
-
}
|
7596 |
-
return markers;
|
7597 |
-
},
|
7598 |
-
findMarks: function(from, to, filter) {
|
7599 |
-
from = clipPos(this, from); to = clipPos(this, to);
|
7600 |
-
var found = [], lineNo = from.line;
|
7601 |
-
this.iter(from.line, to.line + 1, function(line) {
|
7602 |
-
var spans = line.markedSpans;
|
7603 |
-
if (spans) for (var i = 0; i < spans.length; i++) {
|
7604 |
-
var span = spans[i];
|
7605 |
-
if (!(lineNo == from.line && from.ch > span.to ||
|
7606 |
-
span.from == null && lineNo != from.line||
|
7607 |
-
lineNo == to.line && span.from > to.ch) &&
|
7608 |
-
(!filter || filter(span.marker)))
|
7609 |
-
found.push(span.marker.parent || span.marker);
|
7610 |
-
}
|
7611 |
-
++lineNo;
|
7612 |
-
});
|
7613 |
-
return found;
|
7614 |
-
},
|
7615 |
-
getAllMarks: function() {
|
7616 |
-
var markers = [];
|
7617 |
-
this.iter(function(line) {
|
7618 |
-
var sps = line.markedSpans;
|
7619 |
-
if (sps) for (var i = 0; i < sps.length; ++i)
|
7620 |
-
if (sps[i].from != null) markers.push(sps[i].marker);
|
7621 |
-
});
|
7622 |
-
return markers;
|
7623 |
-
},
|
7624 |
-
|
7625 |
-
posFromIndex: function(off) {
|
7626 |
-
var ch, lineNo = this.first;
|
7627 |
-
this.iter(function(line) {
|
7628 |
-
var sz = line.text.length + 1;
|
7629 |
-
if (sz > off) { ch = off; return true; }
|
7630 |
-
off -= sz;
|
7631 |
-
++lineNo;
|
7632 |
-
});
|
7633 |
-
return clipPos(this, Pos(lineNo, ch));
|
7634 |
-
},
|
7635 |
-
indexFromPos: function (coords) {
|
7636 |
-
coords = clipPos(this, coords);
|
7637 |
-
var index = coords.ch;
|
7638 |
-
if (coords.line < this.first || coords.ch < 0) return 0;
|
7639 |
-
this.iter(this.first, coords.line, function (line) {
|
7640 |
-
index += line.text.length + 1;
|
7641 |
-
});
|
7642 |
-
return index;
|
7643 |
-
},
|
7644 |
-
|
7645 |
-
copy: function(copyHistory) {
|
7646 |
-
var doc = new Doc(getLines(this, this.first, this.first + this.size),
|
7647 |
-
this.modeOption, this.first, this.lineSep);
|
7648 |
-
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
|
7649 |
-
doc.sel = this.sel;
|
7650 |
-
doc.extend = false;
|
7651 |
-
if (copyHistory) {
|
7652 |
-
doc.history.undoDepth = this.history.undoDepth;
|
7653 |
-
doc.setHistory(this.getHistory());
|
7654 |
-
}
|
7655 |
-
return doc;
|
7656 |
-
},
|
7657 |
-
|
7658 |
-
linkedDoc: function(options) {
|
7659 |
-
if (!options) options = {};
|
7660 |
-
var from = this.first, to = this.first + this.size;
|
7661 |
-
if (options.from != null && options.from > from) from = options.from;
|
7662 |
-
if (options.to != null && options.to < to) to = options.to;
|
7663 |
-
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep);
|
7664 |
-
if (options.sharedHist) copy.history = this.history;
|
7665 |
-
(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
|
7666 |
-
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
|
7667 |
-
copySharedMarkers(copy, findSharedMarkers(this));
|
7668 |
-
return copy;
|
7669 |
-
},
|
7670 |
-
unlinkDoc: function(other) {
|
7671 |
-
if (other instanceof CodeMirror) other = other.doc;
|
7672 |
-
if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
|
7673 |
-
var link = this.linked[i];
|
7674 |
-
if (link.doc != other) continue;
|
7675 |
-
this.linked.splice(i, 1);
|
7676 |
-
other.unlinkDoc(this);
|
7677 |
-
detachSharedMarkers(findSharedMarkers(this));
|
7678 |
-
break;
|
7679 |
-
}
|
7680 |
-
// If the histories were shared, split them again
|
7681 |
-
if (other.history == this.history) {
|
7682 |
-
var splitIds = [other.id];
|
7683 |
-
linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
|
7684 |
-
other.history = new History(null);
|
7685 |
-
other.history.done = copyHistoryArray(this.history.done, splitIds);
|
7686 |
-
other.history.undone = copyHistoryArray(this.history.undone, splitIds);
|
7687 |
-
}
|
7688 |
-
},
|
7689 |
-
iterLinkedDocs: function(f) {linkedDocs(this, f);},
|
7690 |
-
|
7691 |
-
getMode: function() {return this.mode;},
|
7692 |
-
getEditor: function() {return this.cm;},
|
7693 |
-
|
7694 |
-
splitLines: function(str) {
|
7695 |
-
if (this.lineSep) return str.split(this.lineSep);
|
7696 |
-
return splitLinesAuto(str);
|
7697 |
-
},
|
7698 |
-
lineSeparator: function() { return this.lineSep || "\n"; }
|
7699 |
-
});
|
7700 |
-
|
7701 |
-
// Public alias.
|
7702 |
-
Doc.prototype.eachLine = Doc.prototype.iter;
|
7703 |
-
|
7704 |
-
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
|
7705 |
-
var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
|
7706 |
-
for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
|
7707 |
-
CodeMirror.prototype[prop] = (function(method) {
|
7708 |
-
return function() {return method.apply(this.doc, arguments);};
|
7709 |
-
})(Doc.prototype[prop]);
|
7710 |
-
|
7711 |
-
eventMixin(Doc);
|
7712 |
-
|
7713 |
-
// Call f for all linked documents.
|
7714 |
-
function linkedDocs(doc, f, sharedHistOnly) {
|
7715 |
-
function propagate(doc, skip, sharedHist) {
|
7716 |
-
if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
|
7717 |
-
var rel = doc.linked[i];
|
7718 |
-
if (rel.doc == skip) continue;
|
7719 |
-
var shared = sharedHist && rel.sharedHist;
|
7720 |
-
if (sharedHistOnly && !shared) continue;
|
7721 |
-
f(rel.doc, shared);
|
7722 |
-
propagate(rel.doc, doc, shared);
|
7723 |
-
}
|
7724 |
-
}
|
7725 |
-
propagate(doc, null, true);
|
7726 |
-
}
|
7727 |
-
|
7728 |
-
// Attach a document to an editor.
|
7729 |
-
function attachDoc(cm, doc) {
|
7730 |
-
if (doc.cm) throw new Error("This document is already in use.");
|
7731 |
-
cm.doc = doc;
|
7732 |
-
doc.cm = cm;
|
7733 |
-
estimateLineHeights(cm);
|
7734 |
-
loadMode(cm);
|
7735 |
-
if (!cm.options.lineWrapping) findMaxLine(cm);
|
7736 |
-
cm.options.mode = doc.modeOption;
|
7737 |
-
regChange(cm);
|
7738 |
-
}
|
7739 |
-
|
7740 |
-
// LINE UTILITIES
|
7741 |
-
|
7742 |
-
// Find the line object corresponding to the given line number.
|
7743 |
-
function getLine(doc, n) {
|
7744 |
-
n -= doc.first;
|
7745 |
-
if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
|
7746 |
-
for (var chunk = doc; !chunk.lines;) {
|
7747 |
-
for (var i = 0;; ++i) {
|
7748 |
-
var child = chunk.children[i], sz = child.chunkSize();
|
7749 |
-
if (n < sz) { chunk = child; break; }
|
7750 |
-
n -= sz;
|
7751 |
-
}
|
7752 |
-
}
|
7753 |
-
return chunk.lines[n];
|
7754 |
-
}
|
7755 |
-
|
7756 |
-
// Get the part of a document between two positions, as an array of
|
7757 |
-
// strings.
|
7758 |
-
function getBetween(doc, start, end) {
|
7759 |
-
var out = [], n = start.line;
|
7760 |
-
doc.iter(start.line, end.line + 1, function(line) {
|
7761 |
-
var text = line.text;
|
7762 |
-
if (n == end.line) text = text.slice(0, end.ch);
|
7763 |
-
if (n == start.line) text = text.slice(start.ch);
|
7764 |
-
out.push(text);
|
7765 |
-
++n;
|
7766 |
-
});
|
7767 |
-
return out;
|
7768 |
-
}
|
7769 |
-
// Get the lines between from and to, as array of strings.
|
7770 |
-
function getLines(doc, from, to) {
|
7771 |
-
var out = [];
|
7772 |
-
doc.iter(from, to, function(line) { out.push(line.text); });
|
7773 |
-
return out;
|
7774 |
-
}
|
7775 |
-
|
7776 |
-
// Update the height of a line, propagating the height change
|
7777 |
-
// upwards to parent nodes.
|
7778 |
-
function updateLineHeight(line, height) {
|
7779 |
-
var diff = height - line.height;
|
7780 |
-
if (diff) for (var n = line; n; n = n.parent) n.height += diff;
|
7781 |
-
}
|
7782 |
-
|
7783 |
-
// Given a line object, find its line number by walking up through
|
7784 |
-
// its parent links.
|
7785 |
-
function lineNo(line) {
|
7786 |
-
if (line.parent == null) return null;
|
7787 |
-
var cur = line.parent, no = indexOf(cur.lines, line);
|
7788 |
-
for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
|
7789 |
-
for (var i = 0;; ++i) {
|
7790 |
-
if (chunk.children[i] == cur) break;
|
7791 |
-
no += chunk.children[i].chunkSize();
|
7792 |
-
}
|
7793 |
-
}
|
7794 |
-
return no + cur.first;
|
7795 |
-
}
|
7796 |
-
|
7797 |
-
// Find the line at the given vertical position, using the height
|
7798 |
-
// information in the document tree.
|
7799 |
-
function lineAtHeight(chunk, h) {
|
7800 |
-
var n = chunk.first;
|
7801 |
-
outer: do {
|
7802 |
-
for (var i = 0; i < chunk.children.length; ++i) {
|
7803 |
-
var child = chunk.children[i], ch = child.height;
|
7804 |
-
if (h < ch) { chunk = child; continue outer; }
|
7805 |
-
h -= ch;
|
7806 |
-
n += child.chunkSize();
|
7807 |
-
}
|
7808 |
-
return n;
|
7809 |
-
} while (!chunk.lines);
|
7810 |
-
for (var i = 0; i < chunk.lines.length; ++i) {
|
7811 |
-
var line = chunk.lines[i], lh = line.height;
|
7812 |
-
if (h < lh) break;
|
7813 |
-
h -= lh;
|
7814 |
-
}
|
7815 |
-
return n + i;
|
7816 |
-
}
|
7817 |
-
|
7818 |
-
|
7819 |
-
// Find the height above the given line.
|
7820 |
-
function heightAtLine(lineObj) {
|
7821 |
-
lineObj = visualLine(lineObj);
|
7822 |
-
|
7823 |
-
var h = 0, chunk = lineObj.parent;
|
7824 |
-
for (var i = 0; i < chunk.lines.length; ++i) {
|
7825 |
-
var line = chunk.lines[i];
|
7826 |
-
if (line == lineObj) break;
|
7827 |
-
else h += line.height;
|
7828 |
-
}
|
7829 |
-
for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
|
7830 |
-
for (var i = 0; i < p.children.length; ++i) {
|
7831 |
-
var cur = p.children[i];
|
7832 |
-
if (cur == chunk) break;
|
7833 |
-
else h += cur.height;
|
7834 |
-
}
|
7835 |
-
}
|
7836 |
-
return h;
|
7837 |
-
}
|
7838 |
-
|
7839 |
-
// Get the bidi ordering for the given line (and cache it). Returns
|
7840 |
-
// false for lines that are fully left-to-right, and an array of
|
7841 |
-
// BidiSpan objects otherwise.
|
7842 |
-
function getOrder(line) {
|
7843 |
-
var order = line.order;
|
7844 |
-
if (order == null) order = line.order = bidiOrdering(line.text);
|
7845 |
-
return order;
|
7846 |
-
}
|
7847 |
-
|
7848 |
-
// HISTORY
|
7849 |
-
|
7850 |
-
function History(startGen) {
|
7851 |
-
// Arrays of change events and selections. Doing something adds an
|
7852 |
-
// event to done and clears undo. Undoing moves events from done
|
7853 |
-
// to undone, redoing moves them in the other direction.
|
7854 |
-
this.done = []; this.undone = [];
|
7855 |
-
this.undoDepth = Infinity;
|
7856 |
-
// Used to track when changes can be merged into a single undo
|
7857 |
-
// event
|
7858 |
-
this.lastModTime = this.lastSelTime = 0;
|
7859 |
-
this.lastOp = this.lastSelOp = null;
|
7860 |
-
this.lastOrigin = this.lastSelOrigin = null;
|
7861 |
-
// Used by the isClean() method
|
7862 |
-
this.generation = this.maxGeneration = startGen || 1;
|
7863 |
-
}
|
7864 |
-
|
7865 |
-
// Create a history change event from an updateDoc-style change
|
7866 |
-
// object.
|
7867 |
-
function historyChangeFromChange(doc, change) {
|
7868 |
-
var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
|
7869 |
-
attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
|
7870 |
-
linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
|
7871 |
-
return histChange;
|
7872 |
-
}
|
7873 |
-
|
7874 |
-
// Pop all selection events off the end of a history array. Stop at
|
7875 |
-
// a change event.
|
7876 |
-
function clearSelectionEvents(array) {
|
7877 |
-
while (array.length) {
|
7878 |
-
var last = lst(array);
|
7879 |
-
if (last.ranges) array.pop();
|
7880 |
-
else break;
|
7881 |
-
}
|
7882 |
-
}
|
7883 |
-
|
7884 |
-
// Find the top change event in the history. Pop off selection
|
7885 |
-
// events that are in the way.
|
7886 |
-
function lastChangeEvent(hist, force) {
|
7887 |
-
if (force) {
|
7888 |
-
clearSelectionEvents(hist.done);
|
7889 |
-
return lst(hist.done);
|
7890 |
-
} else if (hist.done.length && !lst(hist.done).ranges) {
|
7891 |
-
return lst(hist.done);
|
7892 |
-
} else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
|
7893 |
-
hist.done.pop();
|
7894 |
-
return lst(hist.done);
|
7895 |
-
}
|
7896 |
-
}
|
7897 |
-
|
7898 |
-
// Register a change in the history. Merges changes that are within
|
7899 |
-
// a single operation, ore are close together with an origin that
|
7900 |
-
// allows merging (starting with "+") into a single event.
|
7901 |
-
function addChangeToHistory(doc, change, selAfter, opId) {
|
7902 |
-
var hist = doc.history;
|
7903 |
-
hist.undone.length = 0;
|
7904 |
-
var time = +new Date, cur;
|
7905 |
-
|
7906 |
-
if ((hist.lastOp == opId ||
|
7907 |
-
hist.lastOrigin == change.origin && change.origin &&
|
7908 |
-
((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
|
7909 |
-
change.origin.charAt(0) == "*")) &&
|
7910 |
-
(cur = lastChangeEvent(hist, hist.lastOp == opId))) {
|
7911 |
-
// Merge this change into the last event
|
7912 |
-
var last = lst(cur.changes);
|
7913 |
-
if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
|
7914 |
-
// Optimized case for simple insertion -- don't want to add
|
7915 |
-
// new changesets for every character typed
|
7916 |
-
last.to = changeEnd(change);
|
7917 |
-
} else {
|
7918 |
-
// Add new sub-event
|
7919 |
-
cur.changes.push(historyChangeFromChange(doc, change));
|
7920 |
-
}
|
7921 |
-
} else {
|
7922 |
-
// Can not be merged, start a new event.
|
7923 |
-
var before = lst(hist.done);
|
7924 |
-
if (!before || !before.ranges)
|
7925 |
-
pushSelectionToHistory(doc.sel, hist.done);
|
7926 |
-
cur = {changes: [historyChangeFromChange(doc, change)],
|
7927 |
-
generation: hist.generation};
|
7928 |
-
hist.done.push(cur);
|
7929 |
-
while (hist.done.length > hist.undoDepth) {
|
7930 |
-
hist.done.shift();
|
7931 |
-
if (!hist.done[0].ranges) hist.done.shift();
|
7932 |
-
}
|
7933 |
-
}
|
7934 |
-
hist.done.push(selAfter);
|
7935 |
-
hist.generation = ++hist.maxGeneration;
|
7936 |
-
hist.lastModTime = hist.lastSelTime = time;
|
7937 |
-
hist.lastOp = hist.lastSelOp = opId;
|
7938 |
-
hist.lastOrigin = hist.lastSelOrigin = change.origin;
|
7939 |
-
|
7940 |
-
if (!last) signal(doc, "historyAdded");
|
7941 |
-
}
|
7942 |
-
|
7943 |
-
function selectionEventCanBeMerged(doc, origin, prev, sel) {
|
7944 |
-
var ch = origin.charAt(0);
|
7945 |
-
return ch == "*" ||
|
7946 |
-
ch == "+" &&
|
7947 |
-
prev.ranges.length == sel.ranges.length &&
|
7948 |
-
prev.somethingSelected() == sel.somethingSelected() &&
|
7949 |
-
new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
|
7950 |
-
}
|
7951 |
-
|
7952 |
-
// Called whenever the selection changes, sets the new selection as
|
7953 |
-
// the pending selection in the history, and pushes the old pending
|
7954 |
-
// selection into the 'done' array when it was significantly
|
7955 |
-
// different (in number of selected ranges, emptiness, or time).
|
7956 |
-
function addSelectionToHistory(doc, sel, opId, options) {
|
7957 |
-
var hist = doc.history, origin = options && options.origin;
|
7958 |
-
|
7959 |
-
// A new event is started when the previous origin does not match
|
7960 |
-
// the current, or the origins don't allow matching. Origins
|
7961 |
-
// starting with * are always merged, those starting with + are
|
7962 |
-
// merged when similar and close together in time.
|
7963 |
-
if (opId == hist.lastSelOp ||
|
7964 |
-
(origin && hist.lastSelOrigin == origin &&
|
7965 |
-
(hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
|
7966 |
-
selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
|
7967 |
-
hist.done[hist.done.length - 1] = sel;
|
7968 |
-
else
|
7969 |
-
pushSelectionToHistory(sel, hist.done);
|
7970 |
-
|
7971 |
-
hist.lastSelTime = +new Date;
|
7972 |
-
hist.lastSelOrigin = origin;
|
7973 |
-
hist.lastSelOp = opId;
|
7974 |
-
if (options && options.clearRedo !== false)
|
7975 |
-
clearSelectionEvents(hist.undone);
|
7976 |
-
}
|
7977 |
-
|
7978 |
-
function pushSelectionToHistory(sel, dest) {
|
7979 |
-
var top = lst(dest);
|
7980 |
-
if (!(top && top.ranges && top.equals(sel)))
|
7981 |
-
dest.push(sel);
|
7982 |
-
}
|
7983 |
-
|
7984 |
-
// Used to store marked span information in the history.
|
7985 |
-
function attachLocalSpans(doc, change, from, to) {
|
7986 |
-
var existing = change["spans_" + doc.id], n = 0;
|
7987 |
-
doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
|
7988 |
-
if (line.markedSpans)
|
7989 |
-
(existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
|
7990 |
-
++n;
|
7991 |
-
});
|
7992 |
-
}
|
7993 |
-
|
7994 |
-
// When un/re-doing restores text containing marked spans, those
|
7995 |
-
// that have been explicitly cleared should not be restored.
|
7996 |
-
function removeClearedSpans(spans) {
|
7997 |
-
if (!spans) return null;
|
7998 |
-
for (var i = 0, out; i < spans.length; ++i) {
|
7999 |
-
if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
|
8000 |
-
else if (out) out.push(spans[i]);
|
8001 |
-
}
|
8002 |
-
return !out ? spans : out.length ? out : null;
|
8003 |
-
}
|
8004 |
-
|
8005 |
-
// Retrieve and filter the old marked spans stored in a change event.
|
8006 |
-
function getOldSpans(doc, change) {
|
8007 |
-
var found = change["spans_" + doc.id];
|
8008 |
-
if (!found) return null;
|
8009 |
-
for (var i = 0, nw = []; i < change.text.length; ++i)
|
8010 |
-
nw.push(removeClearedSpans(found[i]));
|
8011 |
-
return nw;
|
8012 |
-
}
|
8013 |
-
|
8014 |
-
// Used both to provide a JSON-safe object in .getHistory, and, when
|
8015 |
-
// detaching a document, to split the history in two
|
8016 |
-
function copyHistoryArray(events, newGroup, instantiateSel) {
|
8017 |
-
for (var i = 0, copy = []; i < events.length; ++i) {
|
8018 |
-
var event = events[i];
|
8019 |
-
if (event.ranges) {
|
8020 |
-
copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
|
8021 |
-
continue;
|
8022 |
-
}
|
8023 |
-
var changes = event.changes, newChanges = [];
|
8024 |
-
copy.push({changes: newChanges});
|
8025 |
-
for (var j = 0; j < changes.length; ++j) {
|
8026 |
-
var change = changes[j], m;
|
8027 |
-
newChanges.push({from: change.from, to: change.to, text: change.text});
|
8028 |
-
if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
|
8029 |
-
if (indexOf(newGroup, Number(m[1])) > -1) {
|
8030 |
-
lst(newChanges)[prop] = change[prop];
|
8031 |
-
delete change[prop];
|
8032 |
-
}
|
8033 |
-
}
|
8034 |
-
}
|
8035 |
-
}
|
8036 |
-
return copy;
|
8037 |
-
}
|
8038 |
-
|
8039 |
-
// Rebasing/resetting history to deal with externally-sourced changes
|
8040 |
-
|
8041 |
-
function rebaseHistSelSingle(pos, from, to, diff) {
|
8042 |
-
if (to < pos.line) {
|
8043 |
-
pos.line += diff;
|
8044 |
-
} else if (from < pos.line) {
|
8045 |
-
pos.line = from;
|
8046 |
-
pos.ch = 0;
|
8047 |
-
}
|
8048 |
-
}
|
8049 |
-
|
8050 |
-
// Tries to rebase an array of history events given a change in the
|
8051 |
-
// document. If the change touches the same lines as the event, the
|
8052 |
-
// event, and everything 'behind' it, is discarded. If the change is
|
8053 |
-
// before the event, the event's positions are updated. Uses a
|
8054 |
-
// copy-on-write scheme for the positions, to avoid having to
|
8055 |
-
// reallocate them all on every rebase, but also avoid problems with
|
8056 |
-
// shared position objects being unsafely updated.
|
8057 |
-
function rebaseHistArray(array, from, to, diff) {
|
8058 |
-
for (var i = 0; i < array.length; ++i) {
|
8059 |
-
var sub = array[i], ok = true;
|
8060 |
-
if (sub.ranges) {
|
8061 |
-
if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
|
8062 |
-
for (var j = 0; j < sub.ranges.length; j++) {
|
8063 |
-
rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
|
8064 |
-
rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
|
8065 |
-
}
|
8066 |
-
continue;
|
8067 |
-
}
|
8068 |
-
for (var j = 0; j < sub.changes.length; ++j) {
|
8069 |
-
var cur = sub.changes[j];
|
8070 |
-
if (to < cur.from.line) {
|
8071 |
-
cur.from = Pos(cur.from.line + diff, cur.from.ch);
|
8072 |
-
cur.to = Pos(cur.to.line + diff, cur.to.ch);
|
8073 |
-
} else if (from <= cur.to.line) {
|
8074 |
-
ok = false;
|
8075 |
-
break;
|
8076 |
-
}
|
8077 |
-
}
|
8078 |
-
if (!ok) {
|
8079 |
-
array.splice(0, i + 1);
|
8080 |
-
i = 0;
|
8081 |
-
}
|
8082 |
-
}
|
8083 |
-
}
|
8084 |
-
|
8085 |
-
function rebaseHist(hist, change) {
|
8086 |
-
var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
|
8087 |
-
rebaseHistArray(hist.done, from, to, diff);
|
8088 |
-
rebaseHistArray(hist.undone, from, to, diff);
|
8089 |
-
}
|
8090 |
-
|
8091 |
-
// EVENT UTILITIES
|
8092 |
-
|
8093 |
-
// Due to the fact that we still support jurassic IE versions, some
|
8094 |
-
// compatibility wrappers are needed.
|
8095 |
-
|
8096 |
-
var e_preventDefault = CodeMirror.e_preventDefault = function(e) {
|
8097 |
-
if (e.preventDefault) e.preventDefault();
|
8098 |
-
else e.returnValue = false;
|
8099 |
-
};
|
8100 |
-
var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {
|
8101 |
-
if (e.stopPropagation) e.stopPropagation();
|
8102 |
-
else e.cancelBubble = true;
|
8103 |
-
};
|
8104 |
-
function e_defaultPrevented(e) {
|
8105 |
-
return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
|
8106 |
-
}
|
8107 |
-
var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};
|
8108 |
-
|
8109 |
-
function e_target(e) {return e.target || e.srcElement;}
|
8110 |
-
function e_button(e) {
|
8111 |
-
var b = e.which;
|
8112 |
-
if (b == null) {
|
8113 |
-
if (e.button & 1) b = 1;
|
8114 |
-
else if (e.button & 2) b = 3;
|
8115 |
-
else if (e.button & 4) b = 2;
|
8116 |
-
}
|
8117 |
-
if (mac && e.ctrlKey && b == 1) b = 3;
|
8118 |
-
return b;
|
8119 |
-
}
|
8120 |
-
|
8121 |
-
// EVENT HANDLING
|
8122 |
-
|
8123 |
-
// Lightweight event framework. on/off also work on DOM nodes,
|
8124 |
-
// registering native DOM handlers.
|
8125 |
-
|
8126 |
-
var on = CodeMirror.on = function(emitter, type, f) {
|
8127 |
-
if (emitter.addEventListener)
|
8128 |
-
emitter.addEventListener(type, f, false);
|
8129 |
-
else if (emitter.attachEvent)
|
8130 |
-
emitter.attachEvent("on" + type, f);
|
8131 |
-
else {
|
8132 |
-
var map = emitter._handlers || (emitter._handlers = {});
|
8133 |
-
var arr = map[type] || (map[type] = []);
|
8134 |
-
arr.push(f);
|
8135 |
-
}
|
8136 |
-
};
|
8137 |
-
|
8138 |
-
var noHandlers = []
|
8139 |
-
function getHandlers(emitter, type, copy) {
|
8140 |
-
var arr = emitter._handlers && emitter._handlers[type]
|
8141 |
-
if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers
|
8142 |
-
else return arr || noHandlers
|
8143 |
-
}
|
8144 |
-
|
8145 |
-
var off = CodeMirror.off = function(emitter, type, f) {
|
8146 |
-
if (emitter.removeEventListener)
|
8147 |
-
emitter.removeEventListener(type, f, false);
|
8148 |
-
else if (emitter.detachEvent)
|
8149 |
-
emitter.detachEvent("on" + type, f);
|
8150 |
-
else {
|
8151 |
-
var handlers = getHandlers(emitter, type, false)
|
8152 |
-
for (var i = 0; i < handlers.length; ++i)
|
8153 |
-
if (handlers[i] == f) { handlers.splice(i, 1); break; }
|
8154 |
-
}
|
8155 |
-
};
|
8156 |
-
|
8157 |
-
var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
|
8158 |
-
var handlers = getHandlers(emitter, type, true)
|
8159 |
-
if (!handlers.length) return;
|
8160 |
-
var args = Array.prototype.slice.call(arguments, 2);
|
8161 |
-
for (var i = 0; i < handlers.length; ++i) handlers[i].apply(null, args);
|
8162 |
-
};
|
8163 |
-
|
8164 |
-
var orphanDelayedCallbacks = null;
|
8165 |
-
|
8166 |
-
// Often, we want to signal events at a point where we are in the
|
8167 |
-
// middle of some work, but don't want the handler to start calling
|
8168 |
-
// other methods on the editor, which might be in an inconsistent
|
8169 |
-
// state or simply not expect any other events to happen.
|
8170 |
-
// signalLater looks whether there are any handlers, and schedules
|
8171 |
-
// them to be executed when the last operation ends, or, if no
|
8172 |
-
// operation is active, when a timeout fires.
|
8173 |
-
function signalLater(emitter, type /*, values...*/) {
|
8174 |
-
var arr = getHandlers(emitter, type, false)
|
8175 |
-
if (!arr.length) return;
|
8176 |
-
var args = Array.prototype.slice.call(arguments, 2), list;
|
8177 |
-
if (operationGroup) {
|
8178 |
-
list = operationGroup.delayedCallbacks;
|
8179 |
-
} else if (orphanDelayedCallbacks) {
|
8180 |
-
list = orphanDelayedCallbacks;
|
8181 |
-
} else {
|
8182 |
-
list = orphanDelayedCallbacks = [];
|
8183 |
-
setTimeout(fireOrphanDelayed, 0);
|
8184 |
-
}
|
8185 |
-
function bnd(f) {return function(){f.apply(null, args);};};
|
8186 |
-
for (var i = 0; i < arr.length; ++i)
|
8187 |
-
list.push(bnd(arr[i]));
|
8188 |
-
}
|
8189 |
-
|
8190 |
-
function fireOrphanDelayed() {
|
8191 |
-
var delayed = orphanDelayedCallbacks;
|
8192 |
-
orphanDelayedCallbacks = null;
|
8193 |
-
for (var i = 0; i < delayed.length; ++i) delayed[i]();
|
8194 |
-
}
|
8195 |
-
|
8196 |
-
// The DOM events that CodeMirror handles can be overridden by
|
8197 |
-
// registering a (non-DOM) handler on the editor for the event name,
|
8198 |
-
// and preventDefault-ing the event in that handler.
|
8199 |
-
function signalDOMEvent(cm, e, override) {
|
8200 |
-
if (typeof e == "string")
|
8201 |
-
e = {type: e, preventDefault: function() { this.defaultPrevented = true; }};
|
8202 |
-
signal(cm, override || e.type, cm, e);
|
8203 |
-
return e_defaultPrevented(e) || e.codemirrorIgnore;
|
8204 |
-
}
|
8205 |
-
|
8206 |
-
function signalCursorActivity(cm) {
|
8207 |
-
var arr = cm._handlers && cm._handlers.cursorActivity;
|
8208 |
-
if (!arr) return;
|
8209 |
-
var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
|
8210 |
-
for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
|
8211 |
-
set.push(arr[i]);
|
8212 |
-
}
|
8213 |
-
|
8214 |
-
function hasHandler(emitter, type) {
|
8215 |
-
return getHandlers(emitter, type).length > 0
|
8216 |
-
}
|
8217 |
-
|
8218 |
-
// Add on and off methods to a constructor's prototype, to make
|
8219 |
-
// registering events on such objects more convenient.
|
8220 |
-
function eventMixin(ctor) {
|
8221 |
-
ctor.prototype.on = function(type, f) {on(this, type, f);};
|
8222 |
-
ctor.prototype.off = function(type, f) {off(this, type, f);};
|
8223 |
-
}
|
8224 |
-
|
8225 |
-
// MISC UTILITIES
|
8226 |
-
|
8227 |
-
// Number of pixels added to scroller and sizer to hide scrollbar
|
8228 |
-
var scrollerGap = 30;
|
8229 |
-
|
8230 |
-
// Returned or thrown by various protocols to signal 'I'm not
|
8231 |
-
// handling this'.
|
8232 |
-
var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
|
8233 |
-
|
8234 |
-
// Reused option objects for setSelection & friends
|
8235 |
-
var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
|
8236 |
-
|
8237 |
-
function Delayed() {this.id = null;}
|
8238 |
-
Delayed.prototype.set = function(ms, f) {
|
8239 |
-
clearTimeout(this.id);
|
8240 |
-
this.id = setTimeout(f, ms);
|
8241 |
-
};
|
8242 |
-
|
8243 |
-
// Counts the column offset in a string, taking tabs into account.
|
8244 |
-
// Used mostly to find indentation.
|
8245 |
-
var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {
|
8246 |
-
if (end == null) {
|
8247 |
-
end = string.search(/[^\s\u00a0]/);
|
8248 |
-
if (end == -1) end = string.length;
|
8249 |
-
}
|
8250 |
-
for (var i = startIndex || 0, n = startValue || 0;;) {
|
8251 |
-
var nextTab = string.indexOf("\t", i);
|
8252 |
-
if (nextTab < 0 || nextTab >= end)
|
8253 |
-
return n + (end - i);
|
8254 |
-
n += nextTab - i;
|
8255 |
-
n += tabSize - (n % tabSize);
|
8256 |
-
i = nextTab + 1;
|
8257 |
-
}
|
8258 |
-
};
|
8259 |
-
|
8260 |
-
// The inverse of countColumn -- find the offset that corresponds to
|
8261 |
-
// a particular column.
|
8262 |
-
var findColumn = CodeMirror.findColumn = function(string, goal, tabSize) {
|
8263 |
-
for (var pos = 0, col = 0;;) {
|
8264 |
-
var nextTab = string.indexOf("\t", pos);
|
8265 |
-
if (nextTab == -1) nextTab = string.length;
|
8266 |
-
var skipped = nextTab - pos;
|
8267 |
-
if (nextTab == string.length || col + skipped >= goal)
|
8268 |
-
return pos + Math.min(skipped, goal - col);
|
8269 |
-
col += nextTab - pos;
|
8270 |
-
col += tabSize - (col % tabSize);
|
8271 |
-
pos = nextTab + 1;
|
8272 |
-
if (col >= goal) return pos;
|
8273 |
-
}
|
8274 |
-
}
|
8275 |
-
|
8276 |
-
var spaceStrs = [""];
|
8277 |
-
function spaceStr(n) {
|
8278 |
-
while (spaceStrs.length <= n)
|
8279 |
-
spaceStrs.push(lst(spaceStrs) + " ");
|
8280 |
-
return spaceStrs[n];
|
8281 |
-
}
|
8282 |
-
|
8283 |
-
function lst(arr) { return arr[arr.length-1]; }
|
8284 |
-
|
8285 |
-
var selectInput = function(node) { node.select(); };
|
8286 |
-
if (ios) // Mobile Safari apparently has a bug where select() is broken.
|
8287 |
-
selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };
|
8288 |
-
else if (ie) // Suppress mysterious IE10 errors
|
8289 |
-
selectInput = function(node) { try { node.select(); } catch(_e) {} };
|
8290 |
-
|
8291 |
-
function indexOf(array, elt) {
|
8292 |
-
for (var i = 0; i < array.length; ++i)
|
8293 |
-
if (array[i] == elt) return i;
|
8294 |
-
return -1;
|
8295 |
-
}
|
8296 |
-
function map(array, f) {
|
8297 |
-
var out = [];
|
8298 |
-
for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
|
8299 |
-
return out;
|
8300 |
-
}
|
8301 |
-
|
8302 |
-
function nothing() {}
|
8303 |
-
|
8304 |
-
function createObj(base, props) {
|
8305 |
-
var inst;
|
8306 |
-
if (Object.create) {
|
8307 |
-
inst = Object.create(base);
|
8308 |
-
} else {
|
8309 |
-
nothing.prototype = base;
|
8310 |
-
inst = new nothing();
|
8311 |
-
}
|
8312 |
-
if (props) copyObj(props, inst);
|
8313 |
-
return inst;
|
8314 |
-
};
|
8315 |
-
|
8316 |
-
function copyObj(obj, target, overwrite) {
|
8317 |
-
if (!target) target = {};
|
8318 |
-
for (var prop in obj)
|
8319 |
-
if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
|
8320 |
-
target[prop] = obj[prop];
|
8321 |
-
return target;
|
8322 |
-
}
|
8323 |
-
|
8324 |
-
function bind(f) {
|
8325 |
-
var args = Array.prototype.slice.call(arguments, 1);
|
8326 |
-
return function(){return f.apply(null, args);};
|
8327 |
-
}
|
8328 |
-
|
8329 |
-
var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
|
8330 |
-
var isWordCharBasic = CodeMirror.isWordChar = function(ch) {
|
8331 |
-
return /\w/.test(ch) || ch > "\x80" &&
|
8332 |
-
(ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
|
8333 |
-
};
|
8334 |
-
function isWordChar(ch, helper) {
|
8335 |
-
if (!helper) return isWordCharBasic(ch);
|
8336 |
-
if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
|
8337 |
-
return helper.test(ch);
|
8338 |
-
}
|
8339 |
-
|
8340 |
-
function isEmpty(obj) {
|
8341 |
-
for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
|
8342 |
-
return true;
|
8343 |
-
}
|
8344 |
-
|
8345 |
-
// Extending unicode characters. A series of a non-extending char +
|
8346 |
-
// any number of extending chars is treated as a single unit as far
|
8347 |
-
// as editing and measuring is concerned. This is not fully correct,
|
8348 |
-
// since some scripts/fonts/browsers also treat other configurations
|
8349 |
-
// of code points as a group.
|
8350 |
-
var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
|
8351 |
-
function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
|
8352 |
-
|
8353 |
-
// DOM UTILITIES
|
8354 |
-
|
8355 |
-
function elt(tag, content, className, style) {
|
8356 |
-
var e = document.createElement(tag);
|
8357 |
-
if (className) e.className = className;
|
8358 |
-
if (style) e.style.cssText = style;
|
8359 |
-
if (typeof content == "string") e.appendChild(document.createTextNode(content));
|
8360 |
-
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
|
8361 |
-
return e;
|
8362 |
-
}
|
8363 |
-
|
8364 |
-
var range;
|
8365 |
-
if (document.createRange) range = function(node, start, end, endNode) {
|
8366 |
-
var r = document.createRange();
|
8367 |
-
r.setEnd(endNode || node, end);
|
8368 |
-
r.setStart(node, start);
|
8369 |
-
return r;
|
8370 |
-
};
|
8371 |
-
else range = function(node, start, end) {
|
8372 |
-
var r = document.body.createTextRange();
|
8373 |
-
try { r.moveToElementText(node.parentNode); }
|
8374 |
-
catch(e) { return r; }
|
8375 |
-
r.collapse(true);
|
8376 |
-
r.moveEnd("character", end);
|
8377 |
-
r.moveStart("character", start);
|
8378 |
-
return r;
|
8379 |
-
};
|
8380 |
-
|
8381 |
-
function removeChildren(e) {
|
8382 |
-
for (var count = e.childNodes.length; count > 0; --count)
|
8383 |
-
e.removeChild(e.firstChild);
|
8384 |
-
return e;
|
8385 |
-
}
|
8386 |
-
|
8387 |
-
function removeChildrenAndAdd(parent, e) {
|
8388 |
-
return removeChildren(parent).appendChild(e);
|
8389 |
-
}
|
8390 |
-
|
8391 |
-
var contains = CodeMirror.contains = function(parent, child) {
|
8392 |
-
if (child.nodeType == 3) // Android browser always returns false when child is a textnode
|
8393 |
-
child = child.parentNode;
|
8394 |
-
if (parent.contains)
|
8395 |
-
return parent.contains(child);
|
8396 |
-
do {
|
8397 |
-
if (child.nodeType == 11) child = child.host;
|
8398 |
-
if (child == parent) return true;
|
8399 |
-
} while (child = child.parentNode);
|
8400 |
-
};
|
8401 |
-
|
8402 |
-
function activeElt() {
|
8403 |
-
var activeElement = document.activeElement;
|
8404 |
-
while (activeElement && activeElement.root && activeElement.root.activeElement)
|
8405 |
-
activeElement = activeElement.root.activeElement;
|
8406 |
-
return activeElement;
|
8407 |
-
}
|
8408 |
-
// Older versions of IE throws unspecified error when touching
|
8409 |
-
// document.activeElement in some cases (during loading, in iframe)
|
8410 |
-
if (ie && ie_version < 11) activeElt = function() {
|
8411 |
-
try { return document.activeElement; }
|
8412 |
-
catch(e) { return document.body; }
|
8413 |
-
};
|
8414 |
-
|
8415 |
-
function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); }
|
8416 |
-
var rmClass = CodeMirror.rmClass = function(node, cls) {
|
8417 |
-
var current = node.className;
|
8418 |
-
var match = classTest(cls).exec(current);
|
8419 |
-
if (match) {
|
8420 |
-
var after = current.slice(match.index + match[0].length);
|
8421 |
-
node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
|
8422 |
-
}
|
8423 |
-
};
|
8424 |
-
var addClass = CodeMirror.addClass = function(node, cls) {
|
8425 |
-
var current = node.className;
|
8426 |
-
if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls;
|
8427 |
-
};
|
8428 |
-
function joinClasses(a, b) {
|
8429 |
-
var as = a.split(" ");
|
8430 |
-
for (var i = 0; i < as.length; i++)
|
8431 |
-
if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
|
8432 |
-
return b;
|
8433 |
-
}
|
8434 |
-
|
8435 |
-
// WINDOW-WIDE EVENTS
|
8436 |
-
|
8437 |
-
// These must be handled carefully, because naively registering a
|
8438 |
-
// handler for each editor will cause the editors to never be
|
8439 |
-
// garbage collected.
|
8440 |
-
|
8441 |
-
function forEachCodeMirror(f) {
|
8442 |
-
if (!document.body.getElementsByClassName) return;
|
8443 |
-
var byClass = document.body.getElementsByClassName("CodeMirror");
|
8444 |
-
for (var i = 0; i < byClass.length; i++) {
|
8445 |
-
var cm = byClass[i].CodeMirror;
|
8446 |
-
if (cm) f(cm);
|
8447 |
-
}
|
8448 |
-
}
|
8449 |
-
|
8450 |
-
var globalsRegistered = false;
|
8451 |
-
function ensureGlobalHandlers() {
|
8452 |
-
if (globalsRegistered) return;
|
8453 |
-
registerGlobalHandlers();
|
8454 |
-
globalsRegistered = true;
|
8455 |
-
}
|
8456 |
-
function registerGlobalHandlers() {
|
8457 |
-
// When the window resizes, we need to refresh active editors.
|
8458 |
-
var resizeTimer;
|
8459 |
-
on(window, "resize", function() {
|
8460 |
-
if (resizeTimer == null) resizeTimer = setTimeout(function() {
|
8461 |
-
resizeTimer = null;
|
8462 |
-
forEachCodeMirror(onResize);
|
8463 |
-
}, 100);
|
8464 |
-
});
|
8465 |
-
// When the window loses focus, we want to show the editor as blurred
|
8466 |
-
on(window, "blur", function() {
|
8467 |
-
forEachCodeMirror(onBlur);
|
8468 |
-
});
|
8469 |
-
}
|
8470 |
-
|
8471 |
-
// FEATURE DETECTION
|
8472 |
-
|
8473 |
-
// Detect drag-and-drop
|
8474 |
-
var dragAndDrop = function() {
|
8475 |
-
// There is *some* kind of drag-and-drop support in IE6-8, but I
|
8476 |
-
// couldn't get it to work yet.
|
8477 |
-
if (ie && ie_version < 9) return false;
|
8478 |
-
var div = elt('div');
|
8479 |
-
return "draggable" in div || "dragDrop" in div;
|
8480 |
-
}();
|
8481 |
-
|
8482 |
-
var zwspSupported;
|
8483 |
-
function zeroWidthElement(measure) {
|
8484 |
-
if (zwspSupported == null) {
|
8485 |
-
var test = elt("span", "\u200b");
|
8486 |
-
removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
|
8487 |
-
if (measure.firstChild.offsetHeight != 0)
|
8488 |
-
zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
|
8489 |
-
}
|
8490 |
-
var node = zwspSupported ? elt("span", "\u200b") :
|
8491 |
-
elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
|
8492 |
-
node.setAttribute("cm-text", "");
|
8493 |
-
return node;
|
8494 |
-
}
|
8495 |
-
|
8496 |
-
// Feature-detect IE's crummy client rect reporting for bidi text
|
8497 |
-
var badBidiRects;
|
8498 |
-
function hasBadBidiRects(measure) {
|
8499 |
-
if (badBidiRects != null) return badBidiRects;
|
8500 |
-
var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
|
8501 |
-
var r0 = range(txt, 0, 1).getBoundingClientRect();
|
8502 |
-
if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
|
8503 |
-
var r1 = range(txt, 1, 2).getBoundingClientRect();
|
8504 |
-
return badBidiRects = (r1.right - r0.right < 3);
|
8505 |
-
}
|
8506 |
-
|
8507 |
-
// See if "".split is the broken IE version, if so, provide an
|
8508 |
-
// alternative way to split lines.
|
8509 |
-
var splitLinesAuto = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
|
8510 |
-
var pos = 0, result = [], l = string.length;
|
8511 |
-
while (pos <= l) {
|
8512 |
-
var nl = string.indexOf("\n", pos);
|
8513 |
-
if (nl == -1) nl = string.length;
|
8514 |
-
var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
|
8515 |
-
var rt = line.indexOf("\r");
|
8516 |
-
if (rt != -1) {
|
8517 |
-
result.push(line.slice(0, rt));
|
8518 |
-
pos += rt + 1;
|
8519 |
-
} else {
|
8520 |
-
result.push(line);
|
8521 |
-
pos = nl + 1;
|
8522 |
-
}
|
8523 |
-
}
|
8524 |
-
return result;
|
8525 |
-
} : function(string){return string.split(/\r\n?|\n/);};
|
8526 |
-
|
8527 |
-
var hasSelection = window.getSelection ? function(te) {
|
8528 |
-
try { return te.selectionStart != te.selectionEnd; }
|
8529 |
-
catch(e) { return false; }
|
8530 |
-
} : function(te) {
|
8531 |
-
try {var range = te.ownerDocument.selection.createRange();}
|
8532 |
-
catch(e) {}
|
8533 |
-
if (!range || range.parentElement() != te) return false;
|
8534 |
-
return range.compareEndPoints("StartToEnd", range) != 0;
|
8535 |
-
};
|
8536 |
-
|
8537 |
-
var hasCopyEvent = (function() {
|
8538 |
-
var e = elt("div");
|
8539 |
-
if ("oncopy" in e) return true;
|
8540 |
-
e.setAttribute("oncopy", "return;");
|
8541 |
-
return typeof e.oncopy == "function";
|
8542 |
-
})();
|
8543 |
-
|
8544 |
-
var badZoomedRects = null;
|
8545 |
-
function hasBadZoomedRects(measure) {
|
8546 |
-
if (badZoomedRects != null) return badZoomedRects;
|
8547 |
-
var node = removeChildrenAndAdd(measure, elt("span", "x"));
|
8548 |
-
var normal = node.getBoundingClientRect();
|
8549 |
-
var fromRange = range(node, 0, 1).getBoundingClientRect();
|
8550 |
-
return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
|
8551 |
-
}
|
8552 |
-
|
8553 |
-
// KEY NAMES
|
8554 |
-
|
8555 |
-
var keyNames = CodeMirror.keyNames = {
|
8556 |
-
3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
|
8557 |
-
19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
|
8558 |
-
36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
|
8559 |
-
46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
|
8560 |
-
106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete",
|
8561 |
-
173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
|
8562 |
-
221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
|
8563 |
-
63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
|
8564 |
-
};
|
8565 |
-
(function() {
|
8566 |
-
// Number keys
|
8567 |
-
for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
|
8568 |
-
// Alphabetic keys
|
8569 |
-
for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
|
8570 |
-
// Function keys
|
8571 |
-
for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
|
8572 |
-
})();
|
8573 |
-
|
8574 |
-
// BIDI HELPERS
|
8575 |
-
|
8576 |
-
function iterateBidiSections(order, from, to, f) {
|
8577 |
-
if (!order) return f(from, to, "ltr");
|
8578 |
-
var found = false;
|
8579 |
-
for (var i = 0; i < order.length; ++i) {
|
8580 |
-
var part = order[i];
|
8581 |
-
if (part.from < to && part.to > from || from == to && part.to == from) {
|
8582 |
-
f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
|
8583 |
-
found = true;
|
8584 |
-
}
|
8585 |
-
}
|
8586 |
-
if (!found) f(from, to, "ltr");
|
8587 |
-
}
|
8588 |
-
|
8589 |
-
function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
|
8590 |
-
function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
|
8591 |
-
|
8592 |
-
function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
|
8593 |
-
function lineRight(line) {
|
8594 |
-
var order = getOrder(line);
|
8595 |
-
if (!order) return line.text.length;
|
8596 |
-
return bidiRight(lst(order));
|
8597 |
-
}
|
8598 |
-
|
8599 |
-
function lineStart(cm, lineN) {
|
8600 |
-
var line = getLine(cm.doc, lineN);
|
8601 |
-
var visual = visualLine(line);
|
8602 |
-
if (visual != line) lineN = lineNo(visual);
|
8603 |
-
var order = getOrder(visual);
|
8604 |
-
var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
|
8605 |
-
return Pos(lineN, ch);
|
8606 |
-
}
|
8607 |
-
function lineEnd(cm, lineN) {
|
8608 |
-
var merged, line = getLine(cm.doc, lineN);
|
8609 |
-
while (merged = collapsedSpanAtEnd(line)) {
|
8610 |
-
line = merged.find(1, true).line;
|
8611 |
-
lineN = null;
|
8612 |
-
}
|
8613 |
-
var order = getOrder(line);
|
8614 |
-
var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
|
8615 |
-
return Pos(lineN == null ? lineNo(line) : lineN, ch);
|
8616 |
-
}
|
8617 |
-
function lineStartSmart(cm, pos) {
|
8618 |
-
var start = lineStart(cm, pos.line);
|
8619 |
-
var line = getLine(cm.doc, start.line);
|
8620 |
-
var order = getOrder(line);
|
8621 |
-
if (!order || order[0].level == 0) {
|
8622 |
-
var firstNonWS = Math.max(0, line.text.search(/\S/));
|
8623 |
-
var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
|
8624 |
-
return Pos(start.line, inWS ? 0 : firstNonWS);
|
8625 |
-
}
|
8626 |
-
return start;
|
8627 |
-
}
|
8628 |
-
|
8629 |
-
function compareBidiLevel(order, a, b) {
|
8630 |
-
var linedir = order[0].level;
|
8631 |
-
if (a == linedir) return true;
|
8632 |
-
if (b == linedir) return false;
|
8633 |
-
return a < b;
|
8634 |
-
}
|
8635 |
-
var bidiOther;
|
8636 |
-
function getBidiPartAt(order, pos) {
|
8637 |
-
bidiOther = null;
|
8638 |
-
for (var i = 0, found; i < order.length; ++i) {
|
8639 |
-
var cur = order[i];
|
8640 |
-
if (cur.from < pos && cur.to > pos) return i;
|
8641 |
-
if ((cur.from == pos || cur.to == pos)) {
|
8642 |
-
if (found == null) {
|
8643 |
-
found = i;
|
8644 |
-
} else if (compareBidiLevel(order, cur.level, order[found].level)) {
|
8645 |
-
if (cur.from != cur.to) bidiOther = found;
|
8646 |
-
return i;
|
8647 |
-
} else {
|
8648 |
-
if (cur.from != cur.to) bidiOther = i;
|
8649 |
-
return found;
|
8650 |
-
}
|
8651 |
-
}
|
8652 |
-
}
|
8653 |
-
return found;
|
8654 |
-
}
|
8655 |
-
|
8656 |
-
function moveInLine(line, pos, dir, byUnit) {
|
8657 |
-
if (!byUnit) return pos + dir;
|
8658 |
-
do pos += dir;
|
8659 |
-
while (pos > 0 && isExtendingChar(line.text.charAt(pos)));
|
8660 |
-
return pos;
|
8661 |
-
}
|
8662 |
-
|
8663 |
-
// This is needed in order to move 'visually' through bi-directional
|
8664 |
-
// text -- i.e., pressing left should make the cursor go left, even
|
8665 |
-
// when in RTL text. The tricky part is the 'jumps', where RTL and
|
8666 |
-
// LTR text touch each other. This often requires the cursor offset
|
8667 |
-
// to move more than one unit, in order to visually move one unit.
|
8668 |
-
function moveVisually(line, start, dir, byUnit) {
|
8669 |
-
var bidi = getOrder(line);
|
8670 |
-
if (!bidi) return moveLogically(line, start, dir, byUnit);
|
8671 |
-
var pos = getBidiPartAt(bidi, start), part = bidi[pos];
|
8672 |
-
var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
|
8673 |
-
|
8674 |
-
for (;;) {
|
8675 |
-
if (target > part.from && target < part.to) return target;
|
8676 |
-
if (target == part.from || target == part.to) {
|
8677 |
-
if (getBidiPartAt(bidi, target) == pos) return target;
|
8678 |
-
part = bidi[pos += dir];
|
8679 |
-
return (dir > 0) == part.level % 2 ? part.to : part.from;
|
8680 |
-
} else {
|
8681 |
-
part = bidi[pos += dir];
|
8682 |
-
if (!part) return null;
|
8683 |
-
if ((dir > 0) == part.level % 2)
|
8684 |
-
target = moveInLine(line, part.to, -1, byUnit);
|
8685 |
-
else
|
8686 |
-
target = moveInLine(line, part.from, 1, byUnit);
|
8687 |
-
}
|
8688 |
-
}
|
8689 |
-
}
|
8690 |
-
|
8691 |
-
function moveLogically(line, start, dir, byUnit) {
|
8692 |
-
var target = start + dir;
|
8693 |
-
if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;
|
8694 |
-
return target < 0 || target > line.text.length ? null : target;
|
8695 |
-
}
|
8696 |
-
|
8697 |
-
// Bidirectional ordering algorithm
|
8698 |
-
// See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
|
8699 |
-
// that this (partially) implements.
|
8700 |
-
|
8701 |
-
// One-char codes used for character types:
|
8702 |
-
// L (L): Left-to-Right
|
8703 |
-
// R (R): Right-to-Left
|
8704 |
-
// r (AL): Right-to-Left Arabic
|
8705 |
-
// 1 (EN): European Number
|
8706 |
-
// + (ES): European Number Separator
|
8707 |
-
// % (ET): European Number Terminator
|
8708 |
-
// n (AN): Arabic Number
|
8709 |
-
// , (CS): Common Number Separator
|
8710 |
-
// m (NSM): Non-Spacing Mark
|
8711 |
-
// b (BN): Boundary Neutral
|
8712 |
-
// s (B): Paragraph Separator
|
8713 |
-
// t (S): Segment Separator
|
8714 |
-
// w (WS): Whitespace
|
8715 |
-
// N (ON): Other Neutrals
|
8716 |
-
|
8717 |
-
// Returns null if characters are ordered as they appear
|
8718 |
-
// (left-to-right), or an array of sections ({from, to, level}
|
8719 |
-
// objects) in the order in which they occur visually.
|
8720 |
-
var bidiOrdering = (function() {
|
8721 |
-
// Character types for codepoints 0 to 0xff
|
8722 |
-
var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
|
8723 |
-
// Character types for codepoints 0x600 to 0x6ff
|
8724 |
-
var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";
|
8725 |
-
function charType(code) {
|
8726 |
-
if (code <= 0xf7) return lowTypes.charAt(code);
|
8727 |
-
else if (0x590 <= code && code <= 0x5f4) return "R";
|
8728 |
-
else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);
|
8729 |
-
else if (0x6ee <= code && code <= 0x8ac) return "r";
|
8730 |
-
else if (0x2000 <= code && code <= 0x200b) return "w";
|
8731 |
-
else if (code == 0x200c) return "b";
|
8732 |
-
else return "L";
|
8733 |
-
}
|
8734 |
-
|
8735 |
-
var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
|
8736 |
-
var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
|
8737 |
-
// Browsers seem to always treat the boundaries of block elements as being L.
|
8738 |
-
var outerType = "L";
|
8739 |
-
|
8740 |
-
function BidiSpan(level, from, to) {
|
8741 |
-
this.level = level;
|
8742 |
-
this.from = from; this.to = to;
|
8743 |
-
}
|
8744 |
-
|
8745 |
-
return function(str) {
|
8746 |
-
if (!bidiRE.test(str)) return false;
|
8747 |
-
var len = str.length, types = [];
|
8748 |
-
for (var i = 0, type; i < len; ++i)
|
8749 |
-
types.push(type = charType(str.charCodeAt(i)));
|
8750 |
-
|
8751 |
-
// W1. Examine each non-spacing mark (NSM) in the level run, and
|
8752 |
-
// change the type of the NSM to the type of the previous
|
8753 |
-
// character. If the NSM is at the start of the level run, it will
|
8754 |
-
// get the type of sor.
|
8755 |
-
for (var i = 0, prev = outerType; i < len; ++i) {
|
8756 |
-
var type = types[i];
|
8757 |
-
if (type == "m") types[i] = prev;
|
8758 |
-
else prev = type;
|
8759 |
-
}
|
8760 |
-
|
8761 |
-
// W2. Search backwards from each instance of a European number
|
8762 |
-
// until the first strong type (R, L, AL, or sor) is found. If an
|
8763 |
-
// AL is found, change the type of the European number to Arabic
|
8764 |
-
// number.
|
8765 |
-
// W3. Change all ALs to R.
|
8766 |
-
for (var i = 0, cur = outerType; i < len; ++i) {
|
8767 |
-
var type = types[i];
|
8768 |
-
if (type == "1" && cur == "r") types[i] = "n";
|
8769 |
-
else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
|
8770 |
-
}
|
8771 |
-
|
8772 |
-
// W4. A single European separator between two European numbers
|
8773 |
-
// changes to a European number. A single common separator between
|
8774 |
-
// two numbers of the same type changes to that type.
|
8775 |
-
for (var i = 1, prev = types[0]; i < len - 1; ++i) {
|
8776 |
-
var type = types[i];
|
8777 |
-
if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
|
8778 |
-
else if (type == "," && prev == types[i+1] &&
|
8779 |
-
(prev == "1" || prev == "n")) types[i] = prev;
|
8780 |
-
prev = type;
|
8781 |
-
}
|
8782 |
-
|
8783 |
-
// W5. A sequence of European terminators adjacent to European
|
8784 |
-
// numbers changes to all European numbers.
|
8785 |
-
// W6. Otherwise, separators and terminators change to Other
|
8786 |
-
// Neutral.
|
8787 |
-
for (var i = 0; i < len; ++i) {
|
8788 |
-
var type = types[i];
|
8789 |
-
if (type == ",") types[i] = "N";
|
8790 |
-
else if (type == "%") {
|
8791 |
-
for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
|
8792 |
-
var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
|
8793 |
-
for (var j = i; j < end; ++j) types[j] = replace;
|
8794 |
-
i = end - 1;
|
8795 |
-
}
|
8796 |
-
}
|
8797 |
-
|
8798 |
-
// W7. Search backwards from each instance of a European number
|
8799 |
-
// until the first strong type (R, L, or sor) is found. If an L is
|
8800 |
-
// found, then change the type of the European number to L.
|
8801 |
-
for (var i = 0, cur = outerType; i < len; ++i) {
|
8802 |
-
var type = types[i];
|
8803 |
-
if (cur == "L" && type == "1") types[i] = "L";
|
8804 |
-
else if (isStrong.test(type)) cur = type;
|
8805 |
-
}
|
8806 |
-
|
8807 |
-
// N1. A sequence of neutrals takes the direction of the
|
8808 |
-
// surrounding strong text if the text on both sides has the same
|
8809 |
-
// direction. European and Arabic numbers act as if they were R in
|
8810 |
-
// terms of their influence on neutrals. Start-of-level-run (sor)
|
8811 |
-
// and end-of-level-run (eor) are used at level run boundaries.
|
8812 |
-
// N2. Any remaining neutrals take the embedding direction.
|
8813 |
-
for (var i = 0; i < len; ++i) {
|
8814 |
-
if (isNeutral.test(types[i])) {
|
8815 |
-
for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
|
8816 |
-
var before = (i ? types[i-1] : outerType) == "L";
|
8817 |
-
var after = (end < len ? types[end] : outerType) == "L";
|
8818 |
-
var replace = before || after ? "L" : "R";
|
8819 |
-
for (var j = i; j < end; ++j) types[j] = replace;
|
8820 |
-
i = end - 1;
|
8821 |
-
}
|
8822 |
-
}
|
8823 |
-
|
8824 |
-
// Here we depart from the documented algorithm, in order to avoid
|
8825 |
-
// building up an actual levels array. Since there are only three
|
8826 |
-
// levels (0, 1, 2) in an implementation that doesn't take
|
8827 |
-
// explicit embedding into account, we can build up the order on
|
8828 |
-
// the fly, without following the level-based algorithm.
|
8829 |
-
var order = [], m;
|
8830 |
-
for (var i = 0; i < len;) {
|
8831 |
-
if (countsAsLeft.test(types[i])) {
|
8832 |
-
var start = i;
|
8833 |
-
for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
|
8834 |
-
order.push(new BidiSpan(0, start, i));
|
8835 |
-
} else {
|
8836 |
-
var pos = i, at = order.length;
|
8837 |
-
for (++i; i < len && types[i] != "L"; ++i) {}
|
8838 |
-
for (var j = pos; j < i;) {
|
8839 |
-
if (countsAsNum.test(types[j])) {
|
8840 |
-
if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));
|
8841 |
-
var nstart = j;
|
8842 |
-
for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
|
8843 |
-
order.splice(at, 0, new BidiSpan(2, nstart, j));
|
8844 |
-
pos = j;
|
8845 |
-
} else ++j;
|
8846 |
-
}
|
8847 |
-
if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));
|
8848 |
-
}
|
8849 |
-
}
|
8850 |
-
if (order[0].level == 1 && (m = str.match(/^\s+/))) {
|
8851 |
-
order[0].from = m[0].length;
|
8852 |
-
order.unshift(new BidiSpan(0, 0, m[0].length));
|
8853 |
-
}
|
8854 |
-
if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
|
8855 |
-
lst(order).to -= m[0].length;
|
8856 |
-
order.push(new BidiSpan(0, len - m[0].length, len));
|
8857 |
-
}
|
8858 |
-
if (order[0].level == 2)
|
8859 |
-
order.unshift(new BidiSpan(1, order[0].to, order[0].to));
|
8860 |
-
if (order[0].level != lst(order).level)
|
8861 |
-
order.push(new BidiSpan(order[0].level, len, len));
|
8862 |
-
|
8863 |
-
return order;
|
8864 |
-
};
|
8865 |
-
})();
|
8866 |
-
|
8867 |
-
// THE END
|
8868 |
-
|
8869 |
-
CodeMirror.version = "5.9.0";
|
8870 |
-
|
8871 |
-
return CodeMirror;
|
8872 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/jeg-framework/assets/js/vendor/codemirror/mode/coffeescript/coffeescript.js
DELETED
@@ -1,355 +0,0 @@
|
|
1 |
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
-
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Link to the project's GitHub page:
|
6 |
-
* https://github.com/pickhardt/coffeescript-codemirror-mode
|
7 |
-
*/
|
8 |
-
(function(mod) {
|
9 |
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
-
mod(require("../../lib/codemirror"));
|
11 |
-
else if (typeof define == "function" && define.amd) // AMD
|
12 |
-
define(["../../lib/codemirror"], mod);
|
13 |
-
else // Plain browser env
|
14 |
-
mod(CodeMirror);
|
15 |
-
})(function(CodeMirror) {
|
16 |
-
"use strict";
|
17 |
-
|
18 |
-
CodeMirror.defineMode("coffeescript", function(conf, parserConf) {
|
19 |
-
var ERRORCLASS = "error";
|
20 |
-
|
21 |
-
function wordRegexp(words) {
|
22 |
-
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
23 |
-
}
|
24 |
-
|
25 |
-
var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/;
|
26 |
-
var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
|
27 |
-
var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
|
28 |
-
var atProp = /^@[_A-Za-z$][_A-Za-z$0-9]*/;
|
29 |
-
|
30 |
-
var wordOperators = wordRegexp(["and", "or", "not",
|
31 |
-
"is", "isnt", "in",
|
32 |
-
"instanceof", "typeof"]);
|
33 |
-
var indentKeywords = ["for", "while", "loop", "if", "unless", "else",
|
34 |
-
"switch", "try", "catch", "finally", "class"];
|
35 |
-
var commonKeywords = ["break", "by", "continue", "debugger", "delete",
|
36 |
-
"do", "in", "of", "new", "return", "then",
|
37 |
-
"this", "@", "throw", "when", "until", "extends"];
|
38 |
-
|
39 |
-
var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
|
40 |
-
|
41 |
-
indentKeywords = wordRegexp(indentKeywords);
|
42 |
-
|
43 |
-
|
44 |
-
var stringPrefixes = /^('{3}|\"{3}|['\"])/;
|
45 |
-
var regexPrefixes = /^(\/{3}|\/)/;
|
46 |
-
var commonConstants = ["Infinity", "NaN", "undefined", "null", "true", "false", "on", "off", "yes", "no"];
|
47 |
-
var constants = wordRegexp(commonConstants);
|
48 |
-
|
49 |
-
// Tokenizers
|
50 |
-
function tokenBase(stream, state) {
|
51 |
-
// Handle scope changes
|
52 |
-
if (stream.sol()) {
|
53 |
-
if (state.scope.align === null) state.scope.align = false;
|
54 |
-
var scopeOffset = state.scope.offset;
|
55 |
-
if (stream.eatSpace()) {
|
56 |
-
var lineOffset = stream.indentation();
|
57 |
-
if (lineOffset > scopeOffset && state.scope.type == "coffee") {
|
58 |
-
return "indent";
|
59 |
-
} else if (lineOffset < scopeOffset) {
|
60 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|