mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-25 19:58:21 +01:00
add shortcut to vterm
This commit is contained in:
parent
b243751aa0
commit
16909a4ed4
@ -1 +1,34 @@
|
|||||||
(function(){var t;(t=class extends this.OS.application.BaseApplication{constructor(t){super("About",t)}main(){var t,n;return t=this,this.container=this.find("container"),(n="os://README.md").asFileHandle().read().then((function(n){var i;return i=new showdown.Converter,$(t.container).html(i.makeHtml(n))})).catch(()=>this.notify(__("Unable to read: {0}",n))),this.find("btnclose").onbtclick=()=>this.quit()}}).singleton=!0,t.dependencies=["os://scripts/showdown.min.js"],this.OS.register("About",t)}).call(this);
|
(function() {
|
||||||
|
var About;
|
||||||
|
|
||||||
|
About = class About extends this.OS.application.BaseApplication {
|
||||||
|
constructor(args) {
|
||||||
|
super("About", args);
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
var me, path;
|
||||||
|
me = this;
|
||||||
|
this.container = this.find("container");
|
||||||
|
path = "os://README.md";
|
||||||
|
path.asFileHandle().read().then(function(txt) {
|
||||||
|
var converter;
|
||||||
|
converter = new showdown.Converter();
|
||||||
|
return ($(me.container)).html(converter.makeHtml(txt));
|
||||||
|
}).catch(() => {
|
||||||
|
return this.notify(__("Unable to read: {0}", path));
|
||||||
|
});
|
||||||
|
return this.find("btnclose").onbtclick = () => {
|
||||||
|
return this.quit();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
About.singleton = true;
|
||||||
|
|
||||||
|
About.dependencies = ["os://scripts/showdown.min.js"];
|
||||||
|
|
||||||
|
this.OS.register("About", About);
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,146 +1 @@
|
|||||||
(function() {
|
(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);
|
||||||
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);
|
|
Binary file not shown.
@ -295,7 +295,7 @@
|
|||||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/vTerm/README.md",
|
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/vTerm/README.md",
|
||||||
"category": "System",
|
"category": "System",
|
||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"version": "0.1.11-a",
|
"version": "0.1.12-a",
|
||||||
"dependencies": ["Antunnel@0.1.8-a","xTerm@4.8.1-r"],
|
"dependencies": ["Antunnel@0.1.8-a","xTerm@4.8.1-r"],
|
||||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/vTerm/build/release/vTerm.zip"
|
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/vTerm/build/release/vTerm.zip"
|
||||||
},
|
},
|
||||||
|
@ -12,5 +12,6 @@ VTerm depends on the server side **tunnel** plugin and the AntOS **Antunnel**
|
|||||||
client side package
|
client side package
|
||||||
|
|
||||||
## Change logs
|
## Change logs
|
||||||
|
- v0.1.12-a: Add copy/paste shortcuts (CTRL+SHIFT+C/ CTRL+SHIFT+V)
|
||||||
- v0.1.9-a: Update dependencies to latest
|
- v0.1.9-a: Update dependencies to latest
|
||||||
- v0.1.6-a: Add dependencies to package meta-data
|
- v0.1.6-a: Add dependencies to package meta-data
|
@ -12,5 +12,6 @@ VTerm depends on the server side **tunnel** plugin and the AntOS **Antunnel**
|
|||||||
client side package
|
client side package
|
||||||
|
|
||||||
## Change logs
|
## Change logs
|
||||||
|
- v0.1.12-a: Add copy/paste shortcuts (CTRL+SHIFT+C/ CTRL+SHIFT+V)
|
||||||
- v0.1.9-a: Update dependencies to latest
|
- v0.1.9-a: Update dependencies to latest
|
||||||
- v0.1.6-a: Add dependencies to package meta-data
|
- v0.1.6-a: Add dependencies to package meta-data
|
@ -1 +1 @@
|
|||||||
(function(){var t;(t=class extends this.OS.application.BaseApplication{constructor(t){super("vTerm",t)}main(){var t;return this.mterm=this.find("myterm"),this.term=new Terminal({cursorBlink:!0}),this.fitAddon=new FitAddon.FitAddon,this.term.loadAddon(this.fitAddon),this.term.setOption("fontSize","12"),this.term.open(this.mterm),this.sub=void 0,this.term.onKey(t=>{if(this.sub)return this.sub.send(Antunnel.Msg.DATA,new TextEncoder("utf-8").encode(t.key))}),this.on("focus",()=>this.term.focus()),this.mterm.contextmenuHandle=(t,e)=>(e.items=[{text:"__(Copy)",id:"copy"},{text:"__(Paste)",id:"paste"}],e.onmenuselect=t=>{if(t)return this.mctxHandle(t.data.item.data)},e.show(t)),this.resizeContent(),this.systemsetting.desktop.menu[this.name]||(this.systemsetting.desktop.menu[this.name]={text:"__(Open terminal)",app:"vTerm"}),this.on("hboxchange",t=>this.resizeContent()),t=()=>Antunnel.tunnel?(this.tunnel=Antunnel.tunnel,this.openSession()):(this.error(__("The Antunnel service is not started, please start it first")),this._gui.pushService("Antunnel/AntunnelService").catch(t=>this.error(t.toString(),t)),this.quit()),window.Antunnel?t():(console.log("require Antunnel"),this._api.requires("pkg://Antunnel/main.js").then(()=>t()).catch(t=>(this.error(__("Unable to load Antunnel: {0}",t.toString()),t),this.quit())))}mctxHandle(t){var e,s;switch(t.id){case"paste":return e=t=>{if(t&&""!==t)return t=t.replace(/\n/g,"\r"),this.sub&&this.sub.send(Antunnel.Msg.DATA,new TextEncoder("utf-8").encode(t)),this.term.focus()},this._api.getClipboard().then(t=>e(t)).catch(t=>(this.error(__("Unable to paste"),t),this.openDialog("TextDialog",{title:"Paste text"}).then(t=>e(t)).catch(t=>this.error(t.toString(),t))));case"copy":if(!(s=this.term.getSelection())||""===s)return;return this._api.setClipboard(s)}}resizeContent(){var t,e,s;if(this.fitAddon.fit(),e=this.term.cols,s=this.term.rows,this.sub)return(t=new Uint8Array(8)).set(Antunnel.Msg.bytes_of(e),0),t.set(Antunnel.Msg.bytes_of(s),4),this.sub.send(Antunnel.Msg.CTRL,t)}openSession(){return this.term.clear(),this.term.focus(),this.sub=new Antunnel.Subscriber("vterm"),this.sub.onopen=()=>(console.log("Subscribed"),this.resizeContent($(this.mterm).width(),$(this.mterm).height()),this.term.focus()),this.sub.onerror=t=>(this.error(__("Unable to connect to: vterm"),t),this.sub=void 0),this.sub.onmessage=t=>{if(this.term&&t.data)return this.term.write(new TextDecoder("utf-8").decode(t.data))},this.sub.onclose=()=>(this.sub=void 0,this.notify(__("Terminal connection closed")),this.quit()),this.tunnel.subscribe(this.sub)}cleanup(t){if(this.sub)return this.sub.close()}}).dependencies=["pkg://xTerm/main.js","pkg://xTerm/main.css","pkg://Antunnel/main.js"],this.OS.register("vTerm",t)}).call(this);
|
(function(){var t;(t=class extends this.OS.application.BaseApplication{constructor(t){super("vTerm",t)}main(){var t;return this.mterm=this.find("myterm"),this.term=new Terminal({cursorBlink:!0}),this.fitAddon=new FitAddon.FitAddon,this.term.loadAddon(this.fitAddon),this.term.setOption("fontSize","12"),this.term.open(this.mterm),this.sub=void 0,this.bindKey("CTRL-SHIFT-C",t=>(this.mctxHandle({id:"copy"}),this.term.focus())),this.bindKey("CTRL-SHIFT-V",t=>this.mctxHandle({id:"paste"})),this.term.onKey(t=>{if(this.sub)return this.sub.send(Antunnel.Msg.DATA,new TextEncoder("utf-8").encode(t.key))}),this.on("focus",()=>this.term.focus()),this.mterm.contextmenuHandle=(t,e)=>(e.items=[{text:"__(Copy)",id:"copy"},{text:"__(Paste)",id:"paste"}],e.onmenuselect=t=>{if(t)return this.mctxHandle(t.data.item.data)},e.show(t)),this.resizeContent(),this.systemsetting.desktop.menu[this.name]||(this.systemsetting.desktop.menu[this.name]={text:"__(Open terminal)",app:"vTerm"}),this.on("hboxchange",t=>this.resizeContent()),t=()=>Antunnel.tunnel?(this.tunnel=Antunnel.tunnel,this.openSession()):(this.error(__("The Antunnel service is not started, please start it first")),this._gui.pushService("Antunnel/AntunnelService").catch(t=>this.error(t.toString(),t)),this.quit()),window.Antunnel?t():(console.log("require Antunnel"),this._api.requires("pkg://Antunnel/main.js").then(()=>t()).catch(t=>(this.error(__("Unable to load Antunnel: {0}",t.toString()),t),this.quit())))}mctxHandle(t){var e,s;switch(t.id){case"paste":return e=t=>{if(t&&""!==t)return t=t.replace(/\n/g,"\r"),this.sub&&this.sub.send(Antunnel.Msg.DATA,new TextEncoder("utf-8").encode(t)),this.term.focus()},this._api.getClipboard().then(t=>e(t)).catch(t=>(this.error(__("Unable to paste"),t),this.openDialog("TextDialog",{title:"Paste text"}).then(t=>e(t)).catch(t=>this.error(t.toString(),t))));case"copy":if(!(s=this.term.getSelection())||""===s)return;return this._api.setClipboard(s)}}resizeContent(){var t,e,s;if(this.fitAddon.fit(),e=this.term.cols,s=this.term.rows,this.sub)return(t=new Uint8Array(8)).set(Antunnel.Msg.bytes_of(e),0),t.set(Antunnel.Msg.bytes_of(s),4),this.sub.send(Antunnel.Msg.CTRL,t)}openSession(){return this.term.clear(),this.term.focus(),this.sub=new Antunnel.Subscriber("vterm"),this.sub.onopen=()=>(console.log("Subscribed"),this.resizeContent($(this.mterm).width(),$(this.mterm).height()),this.term.focus()),this.sub.onerror=t=>(this.error(__("Unable to connect to: vterm"),t),this.sub=void 0),this.sub.onmessage=t=>{if(this.term&&t.data)return this.term.write(new TextDecoder("utf-8").decode(t.data))},this.sub.onclose=()=>(this.sub=void 0,this.notify(__("Terminal connection closed")),this.quit()),this.tunnel.subscribe(this.sub)}cleanup(t){if(this.sub)return this.sub.close()}}).dependencies=["pkg://xTerm/main.js","pkg://xTerm/main.css","pkg://Antunnel/main.js"],this.OS.register("vTerm",t)}).call(this);
|
@ -6,7 +6,7 @@
|
|||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "xsang.le@gmail.com"
|
"email": "xsang.le@gmail.com"
|
||||||
},
|
},
|
||||||
"version":"0.1.11-a",
|
"version":"0.1.12-a",
|
||||||
"category":"System",
|
"category":"System",
|
||||||
"iconclass":"fa fa-terminal",
|
"iconclass":"fa fa-terminal",
|
||||||
"mimes":["none"],
|
"mimes":["none"],
|
||||||
|
Binary file not shown.
@ -28,6 +28,14 @@ class vTerm extends this.OS.application.BaseApplication
|
|||||||
@term.setOption('fontSize', '12')
|
@term.setOption('fontSize', '12')
|
||||||
@term.open @mterm
|
@term.open @mterm
|
||||||
@sub = undefined
|
@sub = undefined
|
||||||
|
|
||||||
|
@bindKey "CTRL-SHIFT-C", (e) =>
|
||||||
|
@mctxHandle {id: "copy"}
|
||||||
|
@term.focus()
|
||||||
|
|
||||||
|
@bindKey "CTRL-SHIFT-V", (e) =>
|
||||||
|
@mctxHandle {id: "paste"}
|
||||||
|
|
||||||
@term.onKey (d) =>
|
@term.onKey (d) =>
|
||||||
return unless @sub
|
return unless @sub
|
||||||
@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode(d.key)
|
@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode(d.key)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "xsang.le@gmail.com"
|
"email": "xsang.le@gmail.com"
|
||||||
},
|
},
|
||||||
"version":"0.1.11-a",
|
"version":"0.1.12-a",
|
||||||
"category":"System",
|
"category":"System",
|
||||||
"iconclass":"fa fa-terminal",
|
"iconclass":"fa fa-terminal",
|
||||||
"mimes":["none"],
|
"mimes":["none"],
|
||||||
|
Loading…
Reference in New Issue
Block a user