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 0000000..cb2bbe7 Binary files /dev/null and b/TinyEditor/build/release/TinyEditor.zip differ diff --git a/TinyEditor/coffees/main.coffee b/TinyEditor/coffees/main.coffee new file mode 100644 index 0000000..9560ee8 --- /dev/null +++ b/TinyEditor/coffees/main.coffee @@ -0,0 +1,85 @@ +class TinyEditor extends this.OS.GUI.BaseApplication + constructor: ( args ) -> + 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