mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 18:48:41 +00:00
8 lines
110 KiB
JavaScript
8 lines
110 KiB
JavaScript
|
ace.define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"],function(e,t,n){"use strict";function i(e,t){function m(e,t,n){if(e.length<t)return;var r=e.slice(0,t),i=e.slice(t),s=/^(?:(\s+)|(\S+)(\s+))/.exec(i),o=/(?:(\s+)|(\s+)(\S+))$/.exec(r),u=0,a=0;o&&!o[2]&&(u=t-o[1].length,a=t),s&&!s[2]&&(u||(u=t),a=t+s[1].length);if(u)return{start:u,end:a};if(o&&o[2]&&o.index>n)return{start:o.index,end:o.index+o[2].length};if(s&&s[2])return u=t+s[2].length,{start:u,end:u+s[3].length}}var n=t.column||e.getOption("printMarginColumn"),i=t.allowMerge!=0,s=Math.min(t.startRow,t.endRow),o=Math.max(t.startRow,t.endRow),u=e.session;while(s<=o){var a=u.getLine(s);if(a.length>n){var f=m(a,n,5);if(f){var l=/^\s*/.exec(a)[0];u.replace(new r(s,f.start,s,f.end),"\n"+l)}o++}else if(i&&/\S/.test(a)&&s!=o){var c=u.getLine(s+1);if(c&&/\S/.test(c)){var h=a.replace(/\s+$/,""),p=c.replace(/^\s+/,""),d=h+" "+p,f=m(d,n,5);if(f&&f.start>h.length||d.length<n){var v=new r(s,h.length,s+1,c.length-p.length);u.replace(v," "),s--,o--}else h.length<a.length&&u.remove(new r(s,h.length,s,a.length))}}s++}}function s(e){if(e.command.name=="insertstring"&&/\S/.test(e.args)){var t=e.editor,n=t.selection.cursor;if(n.column<=t.renderer.$printMarginColumn)return;var r=t.session.$undoManager.$lastDelta;i(t,{startRow:n.row,endRow:n.row,allowMerge:!1}),r!=t.session.$undoManager.$lastDelta&&t.session.markUndoGroup()}}var r=e("../range").Range,o=e("../editor").Editor;e("../config").defineOptions(o.prototype,"editor",{hardWrap:{set:function(e){e?this.commands.on("afterExec",s):this.commands.off("afterExec",s)},value:!1}}),t.hardWrap=i}),ace.define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/dom","ace/lib/oop","ace/lib/keys","ace/lib/event","ace/search","ace/lib/useragent","ace/search_highlight","ace/commands/multi_select_commands","ace/mode/text","ace/ext/hardwrap","ace/multi_select"],function(e,t,n){"use strict";function r(){function t(e){return typeof e!="object"?e+"":"line"in e?e.line+":"+e.ch:"anchor"in e?t(e.anchor)+"->"+t(e.head):Array.isArray(e)?"["+e.map(function(e){return t(e)})+"]":JSON.stringify(e)}var e="";for(var n=0;n<arguments.length;n++){var r=arguments[n],i=t(r);e+=i+" "}console.log(e)}function g(e){return{row:e.line,column:e.ch}}function y(e){return new w(e.row,e.column)}function E(e,t){var n=e.state.vim;if(!n||n.insertMode)return t.head;var r=n.sel.head;if(!r)return t.head;if(n.visualBlock&&t.head.line!=r.line)return;return t.from()==t.anchor&&!t.empty()&&t.head.line==r.line&&t.head.ch!=r.ch?new w(t.head.line,t.head.ch-1):t.head}function S(e,t,n){if(t.line===n.line&&t.ch>=n.ch-1){var r=e.getLine(t.line),i=r.charCodeAt(t.ch);55296<=i&&i<=55551&&(n.ch+=1)}return{start:t,end:n}}function C(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),m.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",ar),ut(e),m.on(e.getInputField(),"paste",P(e))}function k(e){e.setOption("disableInput",!1),e.off("cursorActivity",ar),m.off(e.getInputField(),"paste",P(e)),e.state.vim=null,Rn&&clearTimeout(Rn)}function L(e,t){this==m.keyMap.vim&&(e.options.$customCursor=null,m.rmClass(e.getWrapperElement(),"cm-fat-cursor")),(!t||t.attach!=A)&&k(e)}function A(e,t){this==m.keyMap.vim&&(e.curOp&&(e.curOp.selectionChanged=!0),e.options.$customCursor=E,m.addClass(e.getWrapperElement(),"cm-fat-cursor")),(!t||t.attach!=A)&&C(e)}function O(e,t){if(!t)return undefined;if(this[e])return this[e];var n=D(e);if(!n)return!1;var r=ct.findKey(t,n);return typeof r=="function"&&m.signal(t,"vim-keypress",n),r}function D(e){if(e.charAt(0)=="'")return e.charAt(1);var t=e.split(/-(?!$)/),n=t[t.length-1];if(t.length==1&&t[0].length==1)return!1;if(t.length==2&&t[0]=="Shift"&&n.length==1)return!1;var r=!1;for(var i=0;i<t.length;i++){var s=t[i];s in M?t[i]=M[s]:r=!0,s in _&&(t[i]=_[s])}return r?(Q(n)&&(t[t.length-1]=n.toLowerCase()),"<"+t.join("-")+">"):!1}function P(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(Lt(e.getCursor(),0,1)),Tt.ent
|
||
|
ace.require(["ace/keyboard/vim"], function(m) {
|
||
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
||
|
module.exports = m;
|
||
|
}
|
||
|
});
|
||
|
})();
|
||
|
|