Skip to content

Commit

Permalink
[#65] Added Open Externally button to treeview entries
Browse files Browse the repository at this point in the history
  • Loading branch information
FManga committed Oct 5, 2019
1 parent c5c3671 commit fafef3a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,12 @@ APP.addPlugin("Tree", [], _=>{
actions.push(
{
type:"button",
label:"rename",
label:"Open Externally",
cb:APP.openExternally.bind(null, buffer)
},
{
type:"button",
label:"Rename",
cb:APP.renameBuffer.bind(null, buffer)
}
);
Expand Down
15 changes: 15 additions & 0 deletions www/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ class Frame {

}

openExternally( buffer ){
let cmd;
if( DATA.os == "windows" ){
if( buffer.type == "directory" ) cmd = "explorer";
else cmd = "start";
}else if( DATA.os == "linux" ){
cmd = "xdg-open";
}else if( DATA.os == "darwin" ){
cmd = "open";
}

APP.spawn(cmd, buffer.path);
}

renameBuffer( buffer, newName ){
if( !buffer || !newName || typeof newName != "string" )
return; // prompt for buffer to rename?
Expand All @@ -139,6 +153,7 @@ class Frame {
else{
buffer.path = newName;
buffer.name = newName.split(/[\\/]/).pop();
buffer.type = newName.split(".").pop().toUpperCase();
APP.onRenameBuffer( buffer );
}
});
Expand Down

0 comments on commit fafef3a

Please sign in to comment.