From 8fb1ae4555cd6342b5ea4b6dbe8a3a7808a8c74c Mon Sep 17 00:00:00 2001 From: lxsang Date: Mon, 4 Jan 2021 09:19:04 +0000 Subject: [PATCH] update diff editor --- DiffEditor/build/debug/main.js | 276 +----------------------- DiffEditor/build/debug/package.json | 2 +- DiffEditor/build/release/DiffEditor.zip | Bin 7190 -> 7270 bytes DiffEditor/coffees/main.coffee | 2 + DiffEditor/package.json | 2 +- packages.json | 2 +- 6 files changed, 6 insertions(+), 278 deletions(-) diff --git a/DiffEditor/build/debug/main.js b/DiffEditor/build/debug/main.js index 3bc67d0..63d3b0f 100644 --- a/DiffEditor/build/debug/main.js +++ b/DiffEditor/build/debug/main.js @@ -1,275 +1 @@ -(function() { - var DiffEditor; - - DiffEditor = class DiffEditor extends this.OS.application.BaseApplication { - constructor(args) { - super("DiffEditor", args); - } - - main() { - var j, len, list, opts, ref, v; - this.editor_cnt = this.find("diffeditor"); - this.fileview = this.find("fileview"); - this.fileview.fetch = (path) => { - return new Promise((resolve, reject) => { - return path.asFileHandle().read().then((d) => { - if (d.error) { - return reject(d.error); - } - return resolve(d.result); - }).catch((e) => { - return reject(__e(e)); - }); - }); - }; - this.fileview.onfileopen = (e) => { - if (!(e.data && e.data.path)) { - return; - } - if (e.data.type === "dir") { - return; - } - return this.openFile(e.data.path.asFileHandle()); - }; - this.currdir = void 0; - ace.config.set('basePath', "scripts/ace"); - ace.require("ace/ext/language_tools"); - this.modelist = ace.require("ace/ext/modelist"); - list = []; - ref = this.modelist.modes; - for (j = 0, len = ref.length; j < len; j++) { - v = ref[j]; - list.push({ - text: v.caption, - mode: v.mode - }); - } - this.langlist = this.find("langmode"); - this.langlist.data = list; - this.langlist.onlistselect = (e) => { - this.editors.left.getSession().setMode(e.data.item.data.mode); - return this.editors.right.getSession().setMode(e.data.item.data.mode); - }; - this.differ = new AceDiff({ - // ace: window.ace, - element: this.editor_cnt, - theme: "ace/theme/monokai", - left: { - content: '' - }, - right: { - content: '' - } - }); - this.editors = this.differ.getEditors(); - opts = { - enableBasicAutocompletion: true, - enableSnippets: true, - enableLiveAutocompletion: true, - highlightActiveLine: true, - highlightSelectedWord: true, - behavioursEnabled: true, - //wrap: true, - fontSize: "10pt", - showInvisibles: true - }; - this.editors.left.setOptions(opts); - this.editors.right.setOptions(opts); - this.editors.left.current_file = void 0; - this.editors.right.current_file = void 0; - this.editors.left.afx_label = this.find("left-file"); - this.editors.right.afx_label = this.find("right-file"); - this.editors.left.mux = false; - this.editors.right.mux = false; - this.on("resize", () => { - this.editors = this.differ.getEditors(); - this.editors.left.resize(); - return this.editors.right.resize(); - }); - $('.acediff__left .ace_scrollbar-v', this.editor_cnt).scroll(() => { - return this.editors.right.session.setScrollTop(this.editors.left.session.getScrollTop()); - }); - $('.acediff__right .ace_scrollbar-v', this.editor_cnt).scroll(() => { - return this.editors.left.session.setScrollTop(this.editors.right.session.getScrollTop()); - }); - this.editors.left.on("focus", (e) => { - return this.current_editor = this.editors.left; - }); - this.editors.right.on("focus", (e) => { - return this.current_editor = this.editors.right; - }); - this.editors.left.on("input", (e) => { - if (this.editors.left.mux) { - return this.editors.left.mux = false; - } - if (!this.editors.left.current_file) { - return this.editors.left.afx_label.text = __("Temporary file"); - } - if (this.editors.left.current_file.dirty) { - return; - } - this.editors.left.current_file.dirty = true; - return this.editors.left.afx_label.text += "*"; - }); - this.editors.right.on("input", (e) => { - if (this.editors.right.mux) { - return this.editors.right.mux = false; - } - if (!this.editors.right.current_file) { - return this.editors.right.afx_label.text = __("Temporary file"); - } - if (this.editors.right.current_file.dirty) { - return; - } - this.editors.right.current_file.dirty = true; - return this.editors.right.afx_label.text += "*"; - }); - this.current_editor = this.editors.left; - this.current_editor.focus(); - this.bindKey("ALT-O", () => { - return this.menuAction("open"); - }); - this.bindKey("ALT-F", () => { - return this.menuAction("opendir"); - }); - this.bindKey("CTRL-S", () => { - return this.menuAction("save"); - }); - return this.toggleSideBar(); - } - - toggleSideBar() { - if (this.currdir) { - $(this.fileview).show(); - this.fileview.path = this.currdir.path; - } else { - $(this.fileview).hide(); - } - return this.trigger("resize"); - } - - menu() { - return [ - { - text: __("File"), - nodes: [ - { - text: __("Open"), - dataid: "open", - shortcut: "A-O" - }, - { - text: __("Open Folder"), - dataid: "opendir", - shortcut: "A-F" - }, - { - text: __("Save"), - dataid: "save", - shortcut: "C-S" - } - ], - onchildselect: (e) => { - return this.menuAction(e.data.item.data.dataid); - } - } - ]; - } - - openFile(file) { - this.current_editor.mux = true; - return file.read().then((d) => { - var i, item, j, len, m, ref, v; - file.cache = d; - this.current_editor.current_file = file; - this.current_editor.afx_label.text = file.path; - this.current_editor.setValue(d, -1); - // select current mode - m = this.modelist.getModeForPath(file.path); - ref = this.langlist.data; - for (i = j = 0, len = ref.length; j < len; i = ++j) { - v = ref[i]; - if (v.mode === m.mode) { - item = i; - } - } - if (item === void 0) { - return; - } - return this.langlist.selected = item; - }); - } - - menuAction(dataid) { - var fn; - switch (dataid) { - case "open": - return this.openDialog("FileDialog", { - title: __("Open file"), - mimes: ["text/.*", "application/json", "application/javascript"] - }).then((f) => { - return this.openFile(f.file.path.asFileHandle()); - }); - case "opendir": - return this.openDialog("FileDialog", { - title: __("Open folder"), - mimes: ["dir"] - }).then((f) => { - this.currdir = f.file.path.asFileHandle(); - return this.toggleSideBar(); - }); - case "save": - fn = (ed) => { - if (!(ed.current_file && ed.current_file.dirty)) { - return; - } - ed.current_file.cache = ed.getValue(); - return ed.current_file.write("text/plain").then((r) => { - ed.current_file.dirty = false; - ed.afx_label.text = ed.current_file.path; - return this.notify(__("File {0} saved", ed.current_file.path)); - }).catch((e) => { - return this.error(__("Unable to save to: {0}", ed.current_file.path), e); - }); - }; - fn(this.editors.left); - return fn(this.editors.right); - default: - return console.log(dataid); - } - } - - cleanup(evt) { - var dirty; - dirty = false; - if (this.editors.left.current_file && this.editors.left.current_file.dirty) { - dirty = true; - } - if (this.editors.right.current_file && this.editors.right.current_file.dirty) { - dirty = true; - } - if (dirty) { - evt.preventDefault(); - return this.ask({ - title: __("Unsaved changes"), - text: __("Ignore modification ?") - }).then((d) => { - if (!d) { - return; - } - this.editors.left.current_file.dirty = false; - this.editors.right.current_file.dirty = false; - return this.quit(); - }); - } else { - return this.differ.destroy(); - } - } - - }; - - DiffEditor.dependencies = ["os://scripts/ace/ace.js", "pkg://AceDiff/main.js", "pkg://AceDiff/main.css"]; - - this.OS.register("DiffEditor", DiffEditor); - -}).call(this); +(function(){var t;(t=class extends this.OS.application.BaseApplication{constructor(t){super("DiffEditor",t)}main(){var t,e,i,r,s,o;for(this.editor_cnt=this.find("diffeditor"),this.fileview=this.find("fileview"),this.fileview.fetch=t=>new Promise((e,i)=>t.asFileHandle().read().then(t=>t.error?i(t.error):e(t.result)).catch(t=>i(__e(t)))),this.fileview.onfileopen=t=>{if(t.data&&t.data.path&&"dir"!==t.data.type)return this.openFile(t.data.path.asFileHandle())},this.currdir=void 0,ace.config.set("basePath","scripts/ace"),ace.require("ace/ext/language_tools"),this.modelist=ace.require("ace/ext/modelist"),i=[],t=0,e=(s=this.modelist.modes).length;t(this.editors.left.getSession().setMode(t.data.item.data.mode),this.editors.right.getSession().setMode(t.data.item.data.mode)),this.differ=new AceDiff({element:this.editor_cnt,theme:"ace/theme/monokai",left:{content:""},right:{content:""}}),this.editors=this.differ.getEditors(),r={enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:!0,highlightActiveLine:!0,highlightSelectedWord:!0,behavioursEnabled:!0,fontSize:"10pt",showInvisibles:!0},this.editors.left.setOptions(r),this.editors.right.setOptions(r),this.editors.left.current_file=void 0,this.editors.right.current_file=void 0,this.editors.left.afx_label=this.find("left-file"),this.editors.right.afx_label=this.find("right-file"),this.editors.left.mux=!1,this.editors.right.mux=!1,this.on("resize",()=>(this.editors=this.differ.getEditors(),this.editors.left.resize(),this.editors.right.resize())),$(".acediff__left .ace_scrollbar-v",this.editor_cnt).scroll(()=>this.editors.right.session.setScrollTop(this.editors.left.session.getScrollTop())),$(".acediff__right .ace_scrollbar-v",this.editor_cnt).scroll(()=>this.editors.left.session.setScrollTop(this.editors.right.session.getScrollTop())),this.editors.left.on("focus",t=>this.current_editor=this.editors.left),this.editors.right.on("focus",t=>this.current_editor=this.editors.right),this.editors.left.on("input",t=>this.editors.left.mux?this.editors.left.mux=!1:this.editors.left.current_file?this.editors.left.current_file.dirty?void 0:(this.editors.left.current_file.dirty=!0,this.editors.left.afx_label.text+="*"):this.editors.left.afx_label.text=__("Temporary file")),this.editors.right.on("input",t=>this.editors.right.mux?this.editors.right.mux=!1:this.editors.right.current_file?this.editors.right.current_file.dirty?void 0:(this.editors.right.current_file.dirty=!0,this.editors.right.afx_label.text+="*"):this.editors.right.afx_label.text=__("Temporary file")),this.current_editor=this.editors.left,this.current_editor.focus(),this.bindKey("ALT-O",()=>this.menuAction("open")),this.bindKey("ALT-F",()=>this.menuAction("opendir")),this.bindKey("CTRL-S",()=>this.menuAction("save")),this.toggleSideBar()}toggleSideBar(){return this.currdir?($(this.fileview).show(),this.fileview.path=this.currdir.path):$(this.fileview).hide(),this.trigger("resize")}menu(){return[{text:__("File"),nodes:[{text:__("Open"),dataid:"open",shortcut:"A-O"},{text:__("Open Folder"),dataid:"opendir",shortcut:"A-F"},{text:__("Save"),dataid:"save",shortcut:"C-S"}],onchildselect:t=>this.menuAction(t.data.item.data.dataid)}]}openFile(t){return this.current_editor.mux=!0,t.read().then(e=>{var i,r,s,o,h,l;for(t.cache=e,this.current_editor.current_file=t,this.current_editor.afx_label.text=t.path,this.current_editor.setValue(e,-1),h=this.modelist.getModeForPath(t.path),i=s=0,o=(l=this.langlist.data).length;sthis.openFile(t.file.path.asFileHandle()));case"opendir":return this.openDialog("FileDialog",{title:__("Open folder"),mimes:["dir"]}).then(t=>(this.currdir=t.file.path.asFileHandle(),this.toggleSideBar()));case"save":return(e=t=>{if(t.current_file&&t.current_file.dirty)return t.current_file.cache=t.getValue(),t.current_file.write("text/plain").then(e=>(t.current_file.dirty=!1,t.afx_label.text=t.current_file.path,this.notify(__("File {0} saved",t.current_file.path)))).catch(e=>this.error(__("Unable to save to: {0}",t.current_file.path),e))})(this.editors.left),e(this.editors.right);default:return console.log(t)}}cleanup(t){var e;return e=!1,this.editors.left.current_file&&this.editors.left.current_file.dirty&&(e=!0),this.editors.right.current_file&&this.editors.right.current_file.dirty&&(e=!0),e?(t.preventDefault(),this.ask({title:__("Unsaved changes"),text:__("Ignore modification ?")}).then(t=>{if(t)return this.editors.left.current_file.dirty=!1,this.editors.right.current_file.dirty=!1,this.quit()})):this.differ.destroy()}}).dependencies=["os://scripts/ace/ace.js","os://scripts/ace/ext-themelist.js","os://scripts/ace/ext-language_tools.js","pkg://AceDiff/main.js","pkg://AceDiff/main.css"],this.OS.register("DiffEditor",t)}).call(this); \ No newline at end of file diff --git a/DiffEditor/build/debug/package.json b/DiffEditor/build/debug/package.json index c9f3f0b..f6b0c77 100644 --- a/DiffEditor/build/debug/package.json +++ b/DiffEditor/build/debug/package.json @@ -7,7 +7,7 @@ "author": "", "edsdmail": "" }, - "version":"0.0.1-a", + "version":"0.1.2-a", "category":"Other", "iconclass":"fa fa-adn", "mimes":["none"], diff --git a/DiffEditor/build/release/DiffEditor.zip b/DiffEditor/build/release/DiffEditor.zip index 28a84ae725582bba145a88b56d5f785efe2decdb..0b8266ac62135c89a3e1225b481e8a0b5d19bda7 100644 GIT binary patch delta 418 zcmbPc@ytRZz?+$civa|Ly;Op>2cEgWBErDHBC>fsYpSq&ezBFlesOY9W8bH0`T04;lldg`Sww*5Prkz($RY}4 zY&K*mVB{48vZk%>za7ZPzz{gOOL7x)N^#0$8!07bLp`I(iBdg0Fvo#ZZsa?}9M8xk z!hp@a3=HgGUmz2?iJ5soHwJhkG=UuP?BSX~J)k-e=0sM{peZsrKw2E^z{%OtQekz# zpa2_^T#RB0io1bs=Rq;$lPCj2L1J8eflw4^qO~-L2LPD7T)6-M delta 386 zcmaE6G0lQ6z?+$civa{q1x*RuTrGZxnFm>9vbjhg3s|a0q=1nR#9EX5NOHR{1H*RV zjS{KClOG8SPrfT0#tV{iHGCc9$H>6oH