Skip to content

Instantly share code, notes, and snippets.

@jewel12
Last active December 28, 2015 16:19
Show Gist options
  • Save jewel12/7527752 to your computer and use it in GitHub Desktop.
Save jewel12/7527752 to your computer and use it in GitHub Desktop.
同じアプリケーションで別のウィンドウにフォーカスする Slate.app の設定
// 同じアプリケーションで別のウィンドウにフォーカスする
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();
});
// 同じアプリケーションで別のウィンドウにフォーカスする (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