diff options
Diffstat (limited to 'panorama.js')
-rw-r--r-- | panorama.js | 96 |
1 files changed, 71 insertions, 25 deletions
diff --git a/panorama.js b/panorama.js index a14efdf..47f120a 100644 --- a/panorama.js +++ b/panorama.js @@ -2,7 +2,7 @@ * Use at your OWN RISK. */ let INFO = <> -<plugin name="panorama" version="0.1" +<plugin name="panorama" version="0.5" href="https://github.com/vimpr/vimperator-plugins/blob/master/panorama.js" summary="Add supports for Panorama" lang="en-US" @@ -69,6 +69,20 @@ let INFO = <> <p>Switch group to <a>GroupName</a></p> </description> </item> + <item> + <tags>:rmgroup :rmg</tags> + <spec>:rmg<oa>group</oa><oa>!</oa> <oa>GroupName</oa></spec> + <description> + <p>remove group. The current group is used if ommited <oa>GroupName</oa></p> + </description> + </item> + <item> + <tags>:pullgroup :pull</tags> + <spec>:pull<oa>group</oa> <oa>buffer</oa></spec> + <description> + <p>pull a tab from the other group</p> + </description> + </item> </plugin> </>; @@ -407,7 +421,8 @@ mappings.getDefault(modes.NORMAL, "b").action = function (count) { */ let (cmd = commands.get("buffers")) { cmd.action = function (args) { - completion.listCompleter("buffer", args.literalArg, null, args.bang); + completion.listCompleter("buffer", args.literalArg, null, + args.bang ? completion.buffer.ALL : completion.buffer.VISIBLE); }; cmd.bang = true; } @@ -425,7 +440,7 @@ let (cmd = commands.get("buffer")) { else switchTo(arg, args.bang); }; - cmd.completer = function (context) completion.buffer(context, true); + cmd.completer = function (context) completion.buffer(context, completion.buffer.ALL); } /** @@ -528,9 +543,27 @@ commands.addUserCommand(["rmg[roup]"], "close all tabs in the group", group.closeAll(); }, { argCount: "?", - literalArg: 0, + literal: 0, completer: function (context) completion.tabgroup(context, false), - }); + }, true); + +commands.addUserCommand(["pull[tab]"], "pull a tab from the other group", + function (args) { + const GI = tabView.GroupItems; + let activeGroup = GI.getActiveGroupItem(); + liberator.assert(activeGroup, "Cannot move to the current"); + let arg = args.literalArg; + if (!arg) + return; + let tab = searchTab(arg); + liberator.assert(tab, "No such tab: " + arg); + TV.moveTabTo(tab, activeGroup.id); + gBrowser.mTabContainer.selectedItem = tab; + }, { + argCount: "1", + literal: 0, + completer: function (context) completion.buffer(context, completion.buffer.GROUPS | completion.buffer.ORPHANS), + }, true); // }}} @@ -633,7 +666,10 @@ completion.tabgroup = function TabGroupCompleter (context, excludeActiveGroup) { } } - completion.buffer = function bufferCompletion (context, all) { + completion.buffer = function bufferCompletion (context, flag) { + if (!flag) + flag = this.buffer.VISIBLE; + context.anchored = false; context.keys = { text: "text", description: "url", icon: "icon" }; context.compare = CompletionContext.Sort.number; @@ -644,33 +680,43 @@ completion.tabgroup = function TabGroupCompleter (context, excludeActiveGroup) { { process.call(this, item, text) } </> ]; - context.title = ["Buffers"]; - context.completions = [item for (item in generateVisibleTabs())]; - if (!all) + if (flag & this.buffer.VISIBLE) { + context.title = ["Buffers"]; + context.completions = [item for (item in generateVisibleTabs())]; + } + if (!(flag & this.buffer.GROUPS) || !(flag & this.buffer.ORPHANS)) return; let self = this; TV._initFrame(function() { let groups = TV._window.GroupItems; - let activeGroup = groups.getActiveGroupItem(); - let activeGroupId = activeGroup === null ? null : activeGroup.id; - for (let [i, group] in Iterator(groups.groupItems)) { - if (group.id != activeGroupId) { - let groupName = group.getTitle(); - context.fork("GROUP_" + group.id, 0, self, function (context) { - context.title = [groupName || UNTITLE_LABEL]; - context.completions = [item for (item in generateGroupList(group, groupName))]; - }); + if (flag & self.buffer.GROUPS) { + let activeGroup = groups.getActiveGroupItem(); + let activeGroupId = activeGroup === null ? null : activeGroup.id; + for (let [i, group] in Iterator(groups.groupItems)) { + if (group.id != activeGroupId) { + let groupName = group.getTitle(); + context.fork("GROUP_" + group.id, 0, self, function (context) { + context.title = [groupName || UNTITLE_LABEL]; + context.completions = [item for (item in generateGroupList(group, groupName))]; + }); + } } } - let orphanedTabs = [tabItem for ([, tabItem] in Iterator(groups.getOrphanedTabs())) if (tabItem.tab.hidden)]; - if (orphanedTabs.length == 0) - return; - context.fork("__ORPHANED__", 0, self, function (context) { - context.title = ["Orphaned"]; - context.completions = [item for (item in generateOrphanedList(orphanedTabs))]; - }); + if (flag & self.buffer.ORPHANS) { + let orphanedTabs = [tabItem for ([, tabItem] in Iterator(groups.getOrphanedTabs())) if (tabItem.tab.hidden)]; + if (orphanedTabs.length == 0) + return; + context.fork("__ORPHANED__", 0, self, function (context) { + context.title = ["Orphaned"]; + context.completions = [item for (item in generateOrphanedList(orphanedTabs))]; + }); + } }); }; + completion.buffer.ALL = 1 | 2 | 4; + completion.buffer.VISIBLE = 1 << 0; + completion.buffer.GROUPS = 1 << 1; + completion.buffer.ORPHANS = 1 << 2; })(window.TabView, window.gBrowser); |