From e54a33605a567ae4f8a755af591455d8ecbc4069 Mon Sep 17 00:00:00 2001 From: lxsang Date: Tue, 24 Jul 2018 17:18:07 +0000 Subject: [PATCH] add TinyEditor package --- LuaPlayground/build/debug/main.js | 105 ----------------- LuaPlayground/coffees/main.coffee | 2 +- TinyEditor/README.md | 24 ++++ TinyEditor/assets/scheme.html | 5 + TinyEditor/build/debug/README.md | 24 ++++ TinyEditor/build/debug/main.css | 9 ++ TinyEditor/build/debug/main.js | 145 ++++++++++++++++++++++++ TinyEditor/build/debug/package.json | 13 +++ TinyEditor/build/debug/scheme.html | 5 + TinyEditor/build/release/TinyEditor.zip | Bin 0 -> 5302 bytes TinyEditor/coffees/main.coffee | 85 ++++++++++++++ TinyEditor/css/main.css | 8 ++ TinyEditor/package.json | 13 +++ TinyEditor/project.apj | 1 + 14 files changed, 333 insertions(+), 106 deletions(-) delete mode 100644 LuaPlayground/build/debug/main.js create mode 100644 TinyEditor/README.md create mode 100644 TinyEditor/assets/scheme.html create mode 100644 TinyEditor/build/debug/README.md create mode 100644 TinyEditor/build/debug/main.css create mode 100644 TinyEditor/build/debug/main.js create mode 100644 TinyEditor/build/debug/package.json create mode 100644 TinyEditor/build/debug/scheme.html create mode 100644 TinyEditor/build/release/TinyEditor.zip create mode 100644 TinyEditor/coffees/main.coffee create mode 100644 TinyEditor/css/main.css create mode 100644 TinyEditor/package.json create mode 100644 TinyEditor/project.apj diff --git a/LuaPlayground/build/debug/main.js b/LuaPlayground/build/debug/main.js deleted file mode 100644 index b83df93..0000000 --- a/LuaPlayground/build/debug/main.js +++ /dev/null @@ -1,105 +0,0 @@ -(function() { - var LuaPlayground; - - LuaPlayground = class LuaPlayground extends this.OS.GUI.BaseApplication { - constructor(args) { - super("LuaPlayground", args); - } - - main() { - var me; - me = this; - this.datarea = this.find("editorea"); - this.output = this.find("output"); - this.editor = ace.edit(this.datarea); - this.editor.setOptions({ - enableBasicAutocompletion: true, - enableLiveAutocompletion: true, - fontSize: "10pt" - }); - this.editor.getSession().setUseWrapMode(true); - this.editor.session.setMode("ace/mode/lua"); - this.editor.setTheme("ace/theme/monokai"); - this.on("vboxchange", function() { - return me.editor.resize(); - }); - (this.find("log-clear")).set("onbtclick", function(e) { - return me.log("clean"); - }); - this.socket = null; - return this.bindKey("CTRL-R", function() { - return me.run(); - }); - } - - menu() { - var me, menu; - me = this; - menu = [ - { - text: "__(Code)", - child: [ - { - text: "__(Run)", - dataid: `${this.name}-Run`, - shortcut: "C-R" - } - ], - onmenuselect: function(e) { - return me.run(); - } - } - ]; - return menu; - } - - log(t, m) { - var p; - if (t === "clean") { - return $(this.output).empty(); - } - p = ($("

")).attr("class", t.toLowerCase())[0]; - $(p).html(`${t}: ${m.__()}`); - ($(this.output)).append(p); - return ($(this.output)).scrollTop(this.output.scrollHeight); - } - - run() { - var me, proto, value; - me = this; - value = this.editor.getValue().trim(); - if (!(value && value !== "")) { - return; - } - proto = window.location.protocol === "https:" ? "wss://" : "ws://"; - this.socket = new WebSocket(proto + this._api.HOST + "/lua-api/os/apigateway?ws=1"); - this.socket.onopen = function() { - //send data to server - return me.socket.send(JSON.stringify({ - code: value - })); - }; - this.socket.onmessage = function(e) { - if (e.data) { - return me.log("INFO", e.data); - } - }; - return this.socket.onclose = function() { - me.socket = null; - return console.log("socket closed"); - }; - } - - cleanup(e) { - if (this.socket) { - return this.socket.close(); - } - } - - }; - - this.OS.dependencies = ["ace/ace"]; - - this.OS.register("LuaPlayground", LuaPlayground); - -}).call(this); diff --git a/LuaPlayground/coffees/main.coffee b/LuaPlayground/coffees/main.coffee index 9beb35f..6d059b2 100644 --- a/LuaPlayground/coffees/main.coffee +++ b/LuaPlayground/coffees/main.coffee @@ -57,5 +57,5 @@ class LuaPlayground extends this.OS.GUI.BaseApplication cleanup: (e)-> @socket.close() if @socket -this.OS.dependencies = ["ace/ace"] +LuaPlayground.dependencies = ["ace/ace"] this.OS.register "LuaPlayground", LuaPlayground diff --git a/TinyEditor/README.md b/TinyEditor/README.md new file mode 100644 index 0000000..1faff57 --- /dev/null +++ b/TinyEditor/README.md @@ -0,0 +1,24 @@ +# TinyEditor +This is an example project, generated by AntOS Development Kit + +## Howto + +1. Open the project.apj file with AntOSDK (simply double Click on it) +2. Modify the UI in *assets/scheme.html* +3. Modify application code in *coffees/main.coffee* +4. Modify CSS style in *css/main.css* +5. Other files need to be copied: put in to assets + +## Set up build target + +Click **Menu> Build > Build Option** or simply hit **ALT-Y** + +In the build options dialog, add or remove files that need to be +included into the build + +Click **Save** + +## Build application +* To build: **Menu > Build > Build** or **ALT-C** +* To build and run: **Menu > Build > Build and Run** or **CTRL-R** +* To release: **Menu > Build > Build release** or **ALT-P** \ No newline at end of file diff --git a/TinyEditor/assets/scheme.html b/TinyEditor/assets/scheme.html new file mode 100644 index 0000000..a207cc9 --- /dev/null +++ b/TinyEditor/assets/scheme.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/TinyEditor/build/debug/README.md b/TinyEditor/build/debug/README.md new file mode 100644 index 0000000..1faff57 --- /dev/null +++ b/TinyEditor/build/debug/README.md @@ -0,0 +1,24 @@ +# TinyEditor +This is an example project, generated by AntOS Development Kit + +## Howto + +1. Open the project.apj file with AntOSDK (simply double Click on it) +2. Modify the UI in *assets/scheme.html* +3. Modify application code in *coffees/main.coffee* +4. Modify CSS style in *css/main.css* +5. Other files need to be copied: put in to assets + +## Set up build target + +Click **Menu> Build > Build Option** or simply hit **ALT-Y** + +In the build options dialog, add or remove files that need to be +included into the build + +Click **Save** + +## Build application +* To build: **Menu > Build > Build** or **ALT-C** +* To build and run: **Menu > Build > Build and Run** or **CTRL-R** +* To release: **Menu > Build > Build release** or **ALT-P** \ No newline at end of file diff --git a/TinyEditor/build/debug/main.css b/TinyEditor/build/debug/main.css new file mode 100644 index 0000000..5b61782 --- /dev/null +++ b/TinyEditor/build/debug/main.css @@ -0,0 +1,9 @@ + +afx-app-window[data-id="TinyEditor"] textarea[data-id="editor"] +{ + background-color: #272822; + color:white; + margin: 0; + padding:10px; + border: 0; +} \ No newline at end of file diff --git a/TinyEditor/build/debug/main.js b/TinyEditor/build/debug/main.js new file mode 100644 index 0000000..a201be2 --- /dev/null +++ b/TinyEditor/build/debug/main.js @@ -0,0 +1,145 @@ +(function() { + var TinyEditor; + + TinyEditor = class TinyEditor extends this.OS.GUI.BaseApplication { + constructor(args) { + super("TinyEditor", args); + } + + main() { + var me; + me = this; + this.editor = this.find("editor"); + this.stbar = this.find("statusbar"); + this.bindKey("ALT-N", function() { + return me.newFile(); + }); + this.bindKey("ALT-O", function() { + return me.openFile(); + }); + this.bindKey("CTRL-S", function() { + return me.saveFile(); + }); + this.filehandler = null; + $(this.editor).on('input', function(e) { + if (me.filehandler.dirty === true) { + return; + } + me.filehandler.dirty = true; + return me.scheme.set("apptitle", `${me.filehandler.path}*`); + }); + return this.read(); + } + + menu() { + var m, me; + me = this; + m = [ + { + text: "__(File)", + child: [ + { + text: "__(New)", + dataid: "new", + shortcut: 'A-N' + }, + { + text: "__(Open)", + dataid: "open", + shortcut: 'A-O' + }, + { + text: "__(Save)", + dataid: "save", + shortcut: 'C-S' + } + ], + onmenuselect: function(e) { + switch (e.item.data.dataid) { + case "new": + return me.newFile(); + case "open": + return me.openFile(); + case "save": + return me.saveFile(); + } + } + } + ]; + return m; + } + + newFile() { + this.filehandler = null; + return this.read(); + } + + openFile(fi) { + var me; + me = this; + return this.openDialog("FileDiaLog", function(dir, fname, d) { + me.filehandler = `${dir}/${fname}`.asFileHandler(); + return me.read(); + }, __("Open file")); + } + + saveFile() { + var me; + me = this; + this.filehandler.cache = this.editor.value; + if (this.filehandler.path !== "Untitled") { + return this.write(); + } + return this.openDialog("FileDiaLog", function(dir, fname, d) { + me.filehandler.setPath(`${dir}/${fname}`); + return me.write(); + }, __("Save as"), { + file: me.filehandler + }); + } + + read() { + var me; + me = this; + this.editor.value = ""; + if (this.filehandler === null) { + this.filehandler = "Untitled".asFileHandler(); + this.scheme.set("apptitle", "Untitled"); + return; + } + return this.filehandler.read(function(d) { + me.scheme.set("apptitle", me.filehandler.path); + return me.editor.value = d; + }); + } + + write() { + var me; + me = this; + return this.filehandler.write("text/plain", function(d) { + if (d.error) { + return me.error(__("Error saving file {0}", me.filehandler.path)); + } + me.filehandler.dirty = false; + return me.scheme.set("apptitle", `${me.filehandler.path}`); + }); + } + + cleanup(e) { + var me; + if (!this.filehandler.dirty) { + return; + } + me = this; + e.preventDefault(); + return this.ask("__(Quit)", "__(Quit without saving?)", function() { + me.filehandler.dirty = false; + return me.quit(); + }); + } + + }; + + this.OS.register("TinyEditor", TinyEditor); + +}).call(this); diff --git a/TinyEditor/build/debug/package.json b/TinyEditor/build/debug/package.json new file mode 100644 index 0000000..d3c9f90 --- /dev/null +++ b/TinyEditor/build/debug/package.json @@ -0,0 +1,13 @@ +{ + "app":"TinyEditor", + "name":"TinyEditor", + "description":"", + "info":{ + "author": "", + "email": "" + }, + "version":"0.0.1-a", + "category":"Other", + "iconclass":"fa fa-adn", + "mimes":["none"] +} \ No newline at end of file diff --git a/TinyEditor/build/debug/scheme.html b/TinyEditor/build/debug/scheme.html new file mode 100644 index 0000000..a207cc9 --- /dev/null +++ b/TinyEditor/build/debug/scheme.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/TinyEditor/build/release/TinyEditor.zip b/TinyEditor/build/release/TinyEditor.zip new file mode 100644 index 0000000000000000000000000000000000000000..cb2bbe7c242ba0d8f28b8ed0714512e3a4c6e455 GIT binary patch literal 5302 zcmcIo&2J<}6?Xz5O9vzp$o-{vCAV9iw$~&OP1Z(^ZIYF}YiGxMh*nm%rn_dQc6+*; zu4;eCntvb?7mm3m5@)Xb1zZr~0D}Jji5xj_;J|xT{ZZZH8LyBSyY1o1%bI)xAx$B@;e1zfwW~2oGXOkE zTr=jbwH8V>M0SQlxlSsk3W>v=r9p#NfE~tc=tRD=d}Rc zXjLRxp;j$ecw=Y)F#-=ku{Z{i$ki2WZzKA7(OO)=SV<#SFz}MWZ(^cZG|L++$Z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T3Fe(}dO)W + super "TinyEditor", args + + main: () -> + me = @ + @editor = @find "editor" + @stbar = @find "statusbar" + @bindKey "ALT-N", () -> me.newFile() + @bindKey "ALT-O", () -> me.openFile() + @bindKey "CTRL-S", () -> me.saveFile() + @filehandler = null + $(@editor).on 'input', (e) -> + return if me.filehandler.dirty is true + me.filehandler.dirty = true + me.scheme.set "apptitle", "#{me.filehandler.path}*" + @read() + + menu: () -> + me = @ + m = [ + { + text: "__(File)", + child: [ + { text: "__(New)", dataid :"new", shortcut: 'A-N' }, + { text: "__(Open)", dataid :"open", shortcut: 'A-O' }, + { text: "__(Save)", dataid :"save", shortcut: 'C-S' } + ], + onmenuselect: (e) -> + switch e.item.data.dataid + when "new" then me.newFile() + when "open" then me.openFile() + when "save" then me.saveFile() + } + ] + m + + newFile: () -> + @filehandler = null + @read() + + openFile: (fi) -> + me = @ + @openDialog "FileDiaLog", ( dir, fname, d ) -> + me.filehandler = "#{dir}/#{fname}".asFileHandler() + me.read() + , __("Open file") + + saveFile: () -> + me = @ + @filehandler.cache = @editor.value + return @write() unless @filehandler.path is "Untitled" + @openDialog "FileDiaLog", (dir, fname, d) -> + me.filehandler.setPath "#{dir}/#{fname}" + me.write() + , __("Save as"), { file: me.filehandler } + + read: () -> + me = @ + @editor.value = "" + if @filehandler is null + @filehandler = "Untitled".asFileHandler() + @scheme.set "apptitle", "Untitled" + return + @filehandler.read (d) -> + me.scheme.set "apptitle", me.filehandler.path + me.editor.value = d + + write: () -> + me = @ + @filehandler.write "text/plain", (d) -> + return me.error __("Error saving file {0}", me.filehandler.path) if d.error + me.filehandler.dirty = false + me.scheme.set "apptitle", "#{me.filehandler.path}" + + + cleanup: (e) -> + return unless @filehandler.dirty + me = @ + e.preventDefault() + @ask "__(Quit)", "__(Quit without saving?)", () -> + me.filehandler.dirty = false + me.quit() + +this.OS.register "TinyEditor", TinyEditor \ No newline at end of file diff --git a/TinyEditor/css/main.css b/TinyEditor/css/main.css new file mode 100644 index 0000000..15a6b1d --- /dev/null +++ b/TinyEditor/css/main.css @@ -0,0 +1,8 @@ +afx-app-window[data-id="TinyEditor"] textarea[data-id="editor"] +{ + background-color: #272822; + color:white; + margin: 0; + padding:10px; + border: 0; +} \ No newline at end of file diff --git a/TinyEditor/package.json b/TinyEditor/package.json new file mode 100644 index 0000000..d3c9f90 --- /dev/null +++ b/TinyEditor/package.json @@ -0,0 +1,13 @@ +{ + "app":"TinyEditor", + "name":"TinyEditor", + "description":"", + "info":{ + "author": "", + "email": "" + }, + "version":"0.0.1-a", + "category":"Other", + "iconclass":"fa fa-adn", + "mimes":["none"] +} \ No newline at end of file diff --git a/TinyEditor/project.apj b/TinyEditor/project.apj new file mode 100644 index 0000000..5afdd5d --- /dev/null +++ b/TinyEditor/project.apj @@ -0,0 +1 @@ +{"name":"TinyEditor","root":"home://workspace/TinyEditor","css":["css/main.css"],"javascripts":[],"coffees":["coffees/main.coffee"],"copies":["assets/scheme.html","package.json","README.md"]} \ No newline at end of file