Last active
August 29, 2015 14:27
-
-
Save proshunsuke/c52166d0b60f6e9d132c to your computer and use it in GitHub Desktop.
This is a script file for using Tile Tabs from KeySnail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tile Tabsの設定 | |
key.setGlobalKey(['C-x', '0'], function (ev, arg) { | |
tileTabs.menuActions('untile',-1); | |
}, '現在のフレームを閉じる'); | |
key.setGlobalKey(['C-x', '1'], function (ev, arg) { | |
tileTabs.menuActions('close',null); | |
}, '現在のフレームだけを表示'); | |
key.setGlobalKey(['C-x', '2'], function (ev, arg) { | |
tileTabs.menuActions('tiledup-above',-1); | |
}, 'フレームを横に分割'); | |
key.setGlobalKey(['C-x', '3'], function (ev, arg) { | |
tileTabs.menuActions('tiledup-left',-1); | |
}, 'フレームを縦に分割'); | |
key.setGlobalKey(['C-x', 'o'], function (ev, arg) { | |
// Tile Tabsにも同じメソッドがあるが、nullが返るときにエラーメッセージが出るのでここで定義 | |
function findLayoutByTab(tab) { | |
var i; | |
for (i = 0; i < tileTabs.layouts.length; i++) { | |
if (tileTabs.layouts[i].layoutID == tab.getAttribute("tiletabs-assigned")) | |
return tileTabs.layouts[i]; | |
} | |
return null; | |
} | |
var tabs = gBrowser.tabs; | |
// 指定の位置から探し、フォーカスするタブを返す | |
function getBeFocusedTabByIndex(startIndex, selectedTabLayout) { | |
for (var i = startIndex; i < tabs.length; i++) { | |
var tabLayout = findLayoutByTab(tabs[i]); | |
if (!tabLayout) { | |
continue | |
} | |
if (tabLayout.layoutID === selectedTabLayout.layoutID) { | |
return tabs[i]; | |
} | |
} | |
return null; | |
} | |
// 現在のタブが画面分割されていない場合は何もしない | |
var selectedTabLayout = findLayoutByTab(gBrowser.selectedTab); | |
if (!selectedTabLayout) { | |
return; | |
} | |
var currentTabIndex; | |
// 現在のタブ位置を取得 | |
for (var i = 0; tabs.length; i++) { | |
if (tabs[i] === gBrowser.selectedTab) { | |
currentTabIndex = i; | |
break; | |
} | |
} | |
// 現在のタブの位置から同じレイアウトグループのタブを取得 | |
var tab = getBeFocusedTabByIndex(currentTabIndex + 1, selectedTabLayout); | |
if (tab) { | |
gBrowser.selectedTab = tab; | |
} else { | |
// 最後まで調べて見つからなかったら最初から調べる | |
tab = getBeFocusedTabByIndex(0, selectedTabLayout); | |
gBrowser.selectedTab = tab; | |
} | |
}, '次のフレームを選択', true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment