diff options
author | teramako | 2010-12-08 23:08:15 +0900 |
---|---|---|
committer | teramako | 2010-12-08 23:08:15 +0900 |
commit | 64c6e37da6e8c394aebf7d08ff2c28d38913d8f5 (patch) | |
tree | f811a4cd9eee869149bb550b30f9a131b9623a60 | |
parent | 0fd97f2d5679d511f943bfa7499c625a536f303e (diff) | |
download | vimperator-plugins-64c6e37da6e8c394aebf7d08ff2c28d38913d8f5.tar.bz2 |
update buffer completion
completion.buffer の第二引数のフラグを変更
ビット演算で以下のフラグ設定を可能に
* 1 表示されているタブ
* 2 他のグループのタブ群
* 4 孤立したタブ群
-rw-r--r-- | panorama.js | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/panorama.js b/panorama.js index 0f1fb90..e86f82b 100644 --- a/panorama.js +++ b/panorama.js @@ -414,7 +414,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; } @@ -432,7 +433,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); } /** @@ -640,7 +641,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; @@ -651,33 +655,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); |