Skip to content
This repository was archived by the owner on Mar 9, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions penta-sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ group.commands.add(['sessions[ave]','mkses[sion]'],
'Save current window',
function(args) {
let filename = args[0] ? (/^~?\//.test(args[0]) ? args[0] :
options.sessiondir+args[0]) : options.sessiondir+Date.now()+'.penta'
options.sessiondir+args[0]) :
options.sessiondir + File(
services.directory.get("ProfD", Ci.nsIFile)).leafName
+'/'+ new Date().toLocaleString().replace(/\s/g,"_")+'.penta'
let file = io.File(filename);

dactyl.assert(!file.exists() || args.bang, _("io.exists", file.path.quote()));
Expand All @@ -94,16 +97,31 @@ group.commands.add(['sessions[ave]','mkses[sion]'],
cmds = array.flatten(cmds);
lines = lines.concat(cmds);
}

if (/tabs/.test(sesop)) {
tabs.visibleTabs.forEach(function (tab, i) {
let loc = tab.linkedBrowser.contentDocument.location.href;
if (/^dactyl:\/\/help\//.test(loc) && !/help/.test(sesop))
return;
if (loc == 'about:blank' && !/blank/.test(sesop))
return;
lines.push('tabopen '+loc);
});
tabs.getGroups( function ({ GroupItems }) {
GroupItems.groupItems.forEach( function (group, k) {

lines.push('js <<EOF');
lines.push('tabs.getGroups(function ({ GroupItems }) {');
lines.push('\tlet newGroup = GroupItems.newGroup();');
if (!(group.getTitle() === ""))
lines.push('\tnewGroup.setTitle(\''+group.getTitle()+'\');');
lines.push('\tGroupItems.setActiveGroupItem(newGroup);');

let children = group.getChildren();
children.forEach(function (tab, i) {
let loc = tab.tab.linkedBrowser.contentDocument.location.href;
if (/^dactyl:\/\/help\//.test(loc) && !/help/.test(sesop))
return;
if (loc == 'about:blank' && !/blank/.test(sesop))
return;
lines.push('\tex.tabopen(\''+loc+'\');');
});
lines.push('});');
lines.push('EOF');
});
});
}

try {
Expand Down Expand Up @@ -166,8 +184,18 @@ group.commands.add(['sessionl[oad]'],
return;
}

// delete inactive groups --> only vivisble tabs will remain
tabs.getGroups( function ({ GroupItems }) {
let activeGroup = GroupItems.getActiveGroupItem();
let items = GroupItems.groupItems;
for(let i in items){
if (items[i].id !== activeGroup.id)
items[i].closeAll();
}
});

let curtab = gBrowser.mCurrentTab;
if(!args.bang) tabs.keepOnly(curtab);
if(!args.bang) tabs.keepOnly(curtab); //FIXME deletes only visible tabs
let sessionscript = io.source(file.path);
sessionscript.unload();
options.sessionfile=file.path;
Expand Down