|
|
|
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(W){"use strict";var I="CodeMirror-hint-active";function o(t,i){this.cm=t,this.options=i,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var e=this;t.on("cursorActivity",this.activityFunc=function(){e.cursorActivity()})}W.showHint=function(t,i,e){if(!i)return t.showHint(e);e&&e.async&&(i.async=!0);var n={hint:i};if(e)for(var o in e)n[o]=e[o];return t.showHint(n)},W.defineExtension("showHint",function(t){t=function(t,i,e){var n=t.options.hintOptions,o={};for(var s in l)o[s]=l[s];if(n)for(var s in n)void 0!==n[s]&&(o[s]=n[s]);if(e)for(var s in e)void 0!==e[s]&&(o[s]=e[s]);o.hint.resolve&&(o.hint=o.hint.resolve(t,i));return o}(this,this.getCursor("start"),t);var i=this.listSelections();if(!(1<i.length)){if(this.somethingSelected()){if(!t.hint.supportsSelection)return;for(var e=0;e<i.length;e++)if(i[e].head.line!=i[e].anchor.line)return}this.state.completionActive&&this.state.completionActive.close();var n=this.state.completionActive=new o(this,t);n.options.hint&&(W.signal(this,"startCompletion",this),n.update(!0))}}),W.defineExtension("closeHint",function(){this.state.completionActive&&this.state.completionActive.close()});var s=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},c=window.cancelAnimationFrame||clearTimeout;function B(t){return"string"==typeof t?t:t.text}function K(t,i){for(;i&&i!=t;){if("LI"===i.nodeName.toUpperCase()&&i.parentNode==t)return i;i=i.parentNode}}function n(o,t){this.completion=o,this.data=t,this.picked=!1;var e=this,s=o.cm,c=s.getInputField().ownerDocument,r=c.defaultView||c.parentWindow,l=this.hints=c.createElement("ul"),i=o.cm.options.theme;l.className="CodeMirror-hints "+i,this.selectedHint=t.selectedHint||0;for(var n=t.list,h=0;h<n.length;++h){var a=l.appendChild(c.createElement("li")),u=n[h],f="CodeMirror-hint"+(h!=this.selectedHint?"":" "+I);null!=u.className&&(f=u.className+" "+f),a.className=f,u.render?u.render(a,t,u):a.appendChild(c.createTextNode(u.displayText||B(u))),a.hintId=h}var p,d,m,g=o.options.container||c.body,v=s.cursorCoords(o.options.alignWithWord?t.from:null),y=v.left,w=v.bottom,H=!0,C=0,b=0;g!==c.body&&(d=(p=-1!==["absolute","relative","fixed"].indexOf(r.getComputedStyle(g).position)?g:g.offsetParent).getBoundingClientRect(),m=c.body.getBoundingClientRect(),C=d.left-m.left-p.scrollLeft,b=d.top-m.top-p.scrollTop),l.style.left=y-C+"px",l.style.top=w-b+"px";var k=r.innerWidth||Math.max(c.body.offsetWidth,c.documentElement.offsetWidth),A=r.innerHeight||Math.max(c.body.offsetHeight,c.documentElement.offsetHeight);g.appendChild(l);var x,T,S=l.getBoundingClientRect(),M=S.bottom-A,N=l.scrollHeight>l.clientHeight+1,F=s.getScrollInfo();0<M&&(x=S.bottom-S.top,0<v.top-(v.bottom-S.top)-x?(l.style.top=(w=v.top-x-b)+"px",H=!1):A<x&&(l.style.height=A-5+"px",l.style.top=(w=v.bottom-S.top-b)+"px",T=s.getCursor(),t.from.ch!=T.ch&&(v=s.cursorCoords(T),l.style.left=(y=v.left-C)+"px",S=l.getBoundingClientRect())));var E,O=S.right-k;if(0<O&&(S.right-S.left>k&&(l.style.width=k-5+"px",O-=S.right-S.left-k),l.style.left=(y=v.left-O-C)+"px"),N)for(var P=l.firstChild;P;P=P.nextSibling)P.style.paddingRight=s.display.nativeBarWidth+"px";return s.addKeyMap(this.keyMap=function(t,n){var o={Up:function(){n.moveFocus(-1)},Down:function(){n.moveFocus(1)},PageUp:function(){n.moveFocus(1-n.menuSize(),!0)},PageDown:function(){n.moveFocus(n.menuSize()-1,!0)},Home:function(){n.setFocus(0)},End:function(){n.setFocus(n.length-1)},Enter:n.pick,Tab:n.pick,Esc:n.close};/Mac/.test(navigator.platform)&&(o["Ctrl-P"]=function(){n.moveFocus(-1)},o["Ctrl-N"]=function(){n.moveFocus(1)});var i=t.options.customKeys,s=i?{}:o;function e(t,i){var e="string"!=typeof i?function(t){return i(t,n)}:o.hasOwnProperty(i)?o[i]:i;s[t]=e}if(i)for(var c in i)i.hasOwnProperty(c)&&e(c,i[c]);var r=t.options.ex
|