antosdk-apps/CodePad/build/debug/main.js

1 line
15 KiB
JavaScript
Raw Normal View History

2021-04-21 11:37:58 +02:00
var ace,OS;!function(t){let e;!function(t){class e extends t.BaseEditorModel{constructor(t,e,i){ace.require("ace/ext/language_tools"),super(t,e,i),this.modes=ace.require("ace/ext/modelist")}resetEditor(){this.setValue(""),this.editor.getSession().setUndoManager(new ace.UndoManager)}getTexModel(){const t={};return t.cursor=this.editor.getCursorPosition(),t.cache=this.getValue(),t.um=this.editor.session.getUndoManager(),t.langmode=this.mode,t}setTextModel(t){this.editor.getSession().setUndoManager(new ace.UndoManager),this.setValue(t.cache),this.setMode(t.langmode),t.cursor&&this.setCursor(t.cursor),this.editor.getSession().setUndoManager(t.um)}newTextModelFrom(t){const e={};return e.um=new ace.UndoManager,e.cache=t.cache,e.cursor=void 0,"Untitled"!==t.path.toString()?e.langmode=this.getModeForPath(t.path):e.langmode={text:"Text",mode:"ace/mode/text"},e}getModes(){const t=[];let e;for(e of Array.from(this.modes.modes))t.push({text:e.caption,mode:e.mode});return t}setTheme(t){this.editor.setTheme(t)}setCursor(t){this.editor.renderer.scrollCursorIntoView({row:t.row,column:t.column},.5),this.editor.selection.moveTo(t.row,t.column)}setMode(t){this.mode=t,this.editor.getSession().setMode(t.mode)}editorSetup(t){this.editor=ace.edit(t),this.editor.setOptions({enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:!0,highlightActiveLine:!0,highlightSelectedWord:!0,behavioursEnabled:!0,wrap:!0,fontSize:"10pt",showInvisibles:!0}),this.editor.setTheme("ace/theme/monokai"),this.editor.completers.push({getCompletions(t,e,i,s,a){}}),this.editor.getSession().setUseWrapMode(!0)}on(t,e){switch(t){case"input":case"focus":this.editor.on(t,e);break;case"changeCursor":this.editor.getSession().selection.on(t,e)}}resize(){this.editor.resize()}focus(){this.editor.focus()}getModeForPath(t){const e=this.modes.getModeForPath(t);return{text:e.caption,mode:e.mode}}getEditorStatus(){const t=this.editor.session.selection.getCursor(),e=this.editor.session.getLength();return{row:t.row,column:t.column,line:e,langmode:this.mode,file:this.currfile.path}}getValue(){return this.editor.getValue()}setValue(t){this.editor.setValue(t,-1)}getThemes(){const t=ace.require("ace/ext/themelist"),e=[];for(let i in t.themesByName){const s=t.themesByName[i];e.push({text:s.caption,theme:s.theme})}return e}}t.ACEModel=e}(e=t.application||(t.application={}))}(OS||(OS={})),function(t){let e;!function(t){t.BaseEditorModel=class{constructor(t,e,i){this.container=i,this.currfile="Untitled".asFileHandle(),this.tabbar=e,this.editorSetup(i),this.app=t,this.editormux=!1,this.onstatuschange=void 0,this.on("focus",()=>{this.onstatuschange&&this.onstatuschange(this.getEditorStatus())}),this.on("input",()=>this.editormux?(this.editormux=!1,!1):this.currfile.dirty?void 0:(this.currfile.dirty=!0,this.currfile.text+="*",this.tabbar.update(void 0))),this.on("changeCursor",()=>{this.onstatuschange&&this.onstatuschange(this.getEditorStatus())}),this.tabbar.ontabselect=t=>this.selecteTab($(t.data.item).index()),this.tabbar.ontabclose=t=>{const e=t.data.item;return!!e&&(e.data.dirty?(this.app.openDialog("YesNoDialog",{title:__("Close tab"),text:__("Close without saving ?")}).then(t=>t?this.closeTab(e):this.focus()),!1):this.closeTab(e))}}findTabByFile(t){const e=this.tabbar.items,i=(()=>{const i=[];for(let s=0;s<e.length;s++)e[s].hash()===t.hash()&&i.push(s);return i})();return 0===i.length?-1:i[0]}newTab(t){t.text=t.basename?t.basename:t.path,t.cache||(t.cache=""),t.textModel=this.newTextModelFrom(t),this.currfile.selected=!1,t.selected=!0,this.tabbar.push(t)}closeTab(t){this.tabbar.delete(t);const e=this.tabbar.items.length;return 0===e?(this.openFile("Untitled".asFileHandle()),!1):(this.tabbar.selected=e-1,!1)}selecteTab(t){const e=this.tabbar.items[t];e&&(this.currfile!==e&&(this.currfile.textModel=this.getTexModel(),this.currfile.selected=!1,this.currfile=e),this.editormux=!0,this.setTextModel(e.textModel),this.onstatuschange&&this.onstatuschange(this.getEditorStatus()),this.focus())}selectFile(t){const e=this.findTabByFile(t.asFileHandle());-1!==e&&(this.tabbar.selected=e