Last active
December 28, 2015 16:19
-
-
Save jewel12/7527752 to your computer and use it in GitHub Desktop.
同じアプリケーションで別のウィンドウにフォーカスする Slate.app の設定
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
// 同じアプリケーションで別のウィンドウにフォーカスする | |
S.bind('n:alt,ctrl', function() { | |
function get_next_win(windows) { | |
truth_values_of_is_main = _.map(windows, function(w){ return w.isMain(); }) | |
next_idx = _.indexOf(truth_values_of_is_main, 1) + 1; | |
if (next_idx >= _.size(windows)) { return windows[0]; } | |
return windows[next_idx]; | |
} | |
windows = []; | |
slate.app().eachWindow(function(win){ windows.push(win); }); | |
if (_.size(windows) === 1){ return; } | |
sorted = _.sortBy(windows, function(win){ return win.title(); }); | |
get_next_win(sorted).focus(); | |
}); |
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
// 同じアプリケーションで別のウィンドウにフォーカスする (Chrome対応版) | |
S.bind('n:alt,ctrl', function() { | |
function get_next_win(windows) { | |
truth_values_of_is_main = _.map(windows, function(w){ return w.isMain(); }) | |
next_idx = _.indexOf(truth_values_of_is_main, 1) + 1; | |
if (next_idx >= _.size(windows)) { return windows[0]; } | |
return windows[next_idx]; | |
} | |
windows = []; | |
slate.app().eachWindow(function(win){ | |
if (win.title() !== '') { windows.push(win); } // タイトルが無いウィンドウは無視 | |
}); | |
if (_.size(windows) === 1){ return; } | |
sorted = _.sortBy(windows, function(win){ return win.title(); }); | |
get_next_win(sorted).focus(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment