diff --git a/TinyEditor/build/debug/README.md b/TinyEditor/build/debug/README.md index 5797927..f77295b 100644 --- a/TinyEditor/build/debug/README.md +++ b/TinyEditor/build/debug/README.md @@ -1,3 +1,3 @@ # TinyEditor -This is the example project for the tutorial: [https://blog.lxsang.me/post/id/20](https://blog.lxsang.me/post/id/20) +This is the example project for the tutorial: [https://blog.lxsang.me/post/id/20](https://blog.lxsang.me/post/id/20). The tutorial is outdated, it is no longer compatible with the new antos API diff --git a/TinyEditor/build/debug/main.js b/TinyEditor/build/debug/main.js index 27465ab..5e0f379 100644 --- a/TinyEditor/build/debug/main.js +++ b/TinyEditor/build/debug/main.js @@ -1 +1,146 @@ -(function(){var e;e=class extends this.OS.application.BaseApplication{constructor(e){super("TinyEditor",e)}main(){return this.editor=this.find("editor"),this.bindKey("ALT-N",()=>this.newFile()),this.bindKey("ALT-O",()=>this.openFile()),this.bindKey("CTRL-S",()=>this.saveFile()),this.filehandle=this.args&&this.args.length>0?this.args[0].path.asFileHandle():null,$(this.editor).on("input",e=>{if(!0!==this.filehandle.dirty)return this.filehandle.dirty=!0,this.scheme.apptitle=this.filehandle.path+"*"}),this.read()}menu(){return[{text:"__(File)",nodes:[{text:"__(New)",dataid:"new",shortcut:"A-N"},{text:"__(Open)",dataid:"open",shortcut:"A-O"},{text:"__(Save)",dataid:"save",shortcut:"C-S"}],onchildselect:e=>{switch(e.data.item.data.dataid){case"new":return this.newFile();case"open":return this.openFile();case"save":return this.saveFile()}}}]}newFile(){return this.filehandle=null,this.read()}openFile(){return this.openDialog("FileDialog",{title:__("Open file")}).then(e=>(this.filehandle=e.file.path.asFileHandle(),this.read()))}saveFile(){return this.filehandle.cache=this.editor.value,"Untitled"!==this.filehandle.path?this.write():this.openDialog("FileDialog",{title:__("Save as"),file:this.filehandle}).then(e=>{var t;return t=e.file.path.asFileHandle(),"file"===e.file.type&&(t=t.parent()),this.filehandle.setPath(`${t.path}/${e.name}`),this.write()})}read(){return this.editor.value="",null===this.filehandle?(this.filehandle="Untitled".asFileHandle(),void(this.scheme.apptitle="Untitled")):this.filehandle.read().then(e=>(this.scheme.apptitle=this.filehandle.path,this.editor.value=e)).catch(e=>this.error(__("Unable to read file content")))}write(){return this.filehandle.write("text/plain").then(e=>(this.filehandle.dirty=!1,this.scheme.apptitle=""+this.filehandle.path)).catch(e=>this.error(__("Error saving file {0}",this.filehandle.path),e))}cleanup(e){if(this.filehandle.dirty)return e.preventDefault(),this.ask({title:"__(Quit)",text:"__(Quit without saving?)"}).then(e=>{if(e)return this.filehandle.dirty=!1,this.quit()})}},this.OS.register("TinyEditor",e)}).call(this); \ No newline at end of file +(function() { + var TinyEditor; + + TinyEditor = class TinyEditor extends this.OS.application.BaseApplication { + constructor(args) { + super("TinyEditor", args); + } + + main() { + this.editor = this.find("editor"); + this.bindKey("ALT-N", () => { + return this.newFile(); + }); + this.bindKey("ALT-O", () => { + return this.openFile(); + }); + this.bindKey("CTRL-S", () => { + return this.saveFile(); + }); + this.filehandle = this.args && this.args.length > 0 ? this.args[0].path.asFileHandle() : null; + $(this.editor).on('input', (e) => { + if (this.filehandle.dirty === true) { + return; + } + this.filehandle.dirty = true; + return this.scheme.apptitle = `${this.filehandle.path}*`; + }); + return this.read(); + } + + menu() { + var m; + m = [ + { + text: "__(File)", + nodes: [ + { + text: "__(New)", + dataid: "new", + shortcut: 'A-N' + }, + { + text: "__(Open)", + dataid: "open", + shortcut: 'A-O' + }, + { + text: "__(Save)", + dataid: "save", + shortcut: 'C-S' + } + ], + onchildselect: (e) => { + switch (e.data.item.data.dataid) { + case "new": + return this.newFile(); + case "open": + return this.openFile(); + case "save": + return this.saveFile(); + } + } + } + ]; + return m; + } + + newFile() { + this.filehandle = null; + return this.read(); + } + + openFile() { + return this.openDialog("FileDialog", { + title: __("Open file") + }).then((d) => { + this.filehandle = d.file.path.asFileHandle(); + return this.read(); + }); + } + + saveFile() { + this.filehandle.cache = this.editor.value; + if (this.filehandle.path !== "Untitled") { + return this.write(); + } + return this.openDialog("FileDialog", { + title: __("Save as"), + file: this.filehandle + }).then((f) => { + var d; + d = f.file.path.asFileHandle(); + if (f.file.type === "file") { + d = d.parent(); + } + this.filehandle.setPath(`${d.path}/${f.name}`); + return this.write(); + }); + } + + read() { + this.editor.value = ""; + if (this.filehandle === null) { + this.filehandle = "Untitled".asFileHandle(); + this.scheme.apptitle = "Untitled"; + return; + } + return this.filehandle.read().then((d) => { + this.scheme.apptitle = this.filehandle.path; + return this.editor.value = d; + }).catch((e) => { + return this.error(__("Unable to read file content")); + }); + } + + write() { + return this.filehandle.write("text/plain").then((d) => { + this.filehandle.dirty = false; + return this.scheme.apptitle = `${this.filehandle.path}`; + }).catch((e) => { + return this.error(__("Error saving file {0}", this.filehandle.path), e); + }); + } + + cleanup(e) { + if (!this.filehandle.dirty) { + return; + } + e.preventDefault(); + return this.ask({ + title: "__(Quit)", + text: "__(Quit without saving?)" + }).then((d) => { + if (!d) { + return; + } + this.filehandle.dirty = false; + return this.quit(); + }); + } + + }; + + this.OS.register("TinyEditor", TinyEditor); + +}).call(this); diff --git a/TinyEditor/build/release/TinyEditor.zip b/TinyEditor/build/release/TinyEditor.zip index 793f896..b0de0a4 100644 Binary files a/TinyEditor/build/release/TinyEditor.zip and b/TinyEditor/build/release/TinyEditor.zip differ diff --git a/TinyEditor/coffees/main.coffee b/TinyEditor/coffees/main.coffee index 9bc46e2..8e230f6 100644 --- a/TinyEditor/coffees/main.coffee +++ b/TinyEditor/coffees/main.coffee @@ -13,7 +13,6 @@ class TinyEditor extends this.OS.application.BaseApplication @filehandle.dirty = true @scheme.apptitle = "#{@filehandle.path}*" @read() - menu: () -> m = [ { diff --git a/packages.json b/packages.json index cf99dfd..fe1468a 100644 --- a/packages.json +++ b/packages.json @@ -176,7 +176,7 @@ "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/vTerm/README.md", "category": "System", "author": "Xuan Sang LE", - "version": "0.1.5-a", + "version": "0.1.6-a", "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/vTerm/build/release/vTerm.zip" }, { diff --git a/vTerm/README.md b/vTerm/README.md index 43901e0..0eff12d 100644 --- a/vTerm/README.md +++ b/vTerm/README.md @@ -9,4 +9,7 @@ thanks to the Antd **tunnel** plugin. VTerm depends on the server side **tunnel** plugin and the AntOS **Antunnel** -client side package \ No newline at end of file +client side package + +## Change logs +- v0.1.6-a: Add dependencies to package meta-data \ No newline at end of file diff --git a/vTerm/build/debug/README.md b/vTerm/build/debug/README.md index 43901e0..0eff12d 100644 --- a/vTerm/build/debug/README.md +++ b/vTerm/build/debug/README.md @@ -9,4 +9,7 @@ thanks to the Antd **tunnel** plugin. VTerm depends on the server side **tunnel** plugin and the AntOS **Antunnel** -client side package \ No newline at end of file +client side package + +## Change logs +- v0.1.6-a: Add dependencies to package meta-data \ No newline at end of file diff --git a/vTerm/build/debug/package.json b/vTerm/build/debug/package.json index 1d46ce7..005f2ca 100644 --- a/vTerm/build/debug/package.json +++ b/vTerm/build/debug/package.json @@ -6,10 +6,11 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1.5-a", + "version":"0.1.6-a", "category":"System", "iconclass":"fa fa-terminal", "mimes":["none"], + "dependencies": ["Antunnel@0.1.4-a"], "locales":{ "fr_FR": { "Open terminal": "Ouvrir terminal", diff --git a/vTerm/build/release/vTerm.zip b/vTerm/build/release/vTerm.zip index 4ac8135..5ada2bd 100644 Binary files a/vTerm/build/release/vTerm.zip and b/vTerm/build/release/vTerm.zip differ diff --git a/vTerm/package.json b/vTerm/package.json index 1d46ce7..005f2ca 100644 --- a/vTerm/package.json +++ b/vTerm/package.json @@ -6,10 +6,11 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.1.5-a", + "version":"0.1.6-a", "category":"System", "iconclass":"fa fa-terminal", "mimes":["none"], + "dependencies": ["Antunnel@0.1.4-a"], "locales":{ "fr_FR": { "Open terminal": "Ouvrir terminal",