Skip to content
Browse files

comment phoenix

  • Loading branch information...
1 parent f9f6572 commit 5f6186f160e67490a8133d1b0dc38a93c5812624 @alswl committed Jul 3, 2014
Showing with 103 additions and 30 deletions.
  1. +102 −30 .phoenix.js
  2. +1 −0 .zshrc
View
132 .phoenix.js
@@ -8,12 +8,12 @@ var mousePositions = {};
/**
- * Utils
+ * Utils Functions
*/
var alert_title = function(window) { api.alert(window.title())};
-function sortByMostRecent(windows) { // TODO: check
+function sortByMostRecent(windows) {
var visibleAppMostRecentFirst = _.map(Window.visibleWindowsMostRecentFirst(),
function(w) { return w.app().title(); });
var visibleAppMostRecentFirstWithWeight = _.object(visibleAppMostRecentFirst,
@@ -44,7 +44,7 @@ function getLargerFrame(frame) {
}
/**
- * Screen
+ * Screen Functions
*/
function moveToScreen(window, screen) {
@@ -63,12 +63,8 @@ function moveToScreen(window, screen) {
window.setFrame({
x: (mid_pos_x - oldScreenRect.x) * xRatio + newScreenRect.x - 0.5 * frame.width,
y: (mid_pos_y - oldScreenRect.y) * yRatio + newScreenRect.y - 0.5 * frame.height,
- //x: frame.x - oldScreenRect.x + newScreenRect.x - mid_pos_x,
- //y: mid_pos_y,
width: frame.width,
height: frame.height
- //width: Math.round(frame.width * xRatio),
- //height: Math.round(frame.height * yRatio)
});
};
@@ -81,14 +77,16 @@ function windowsOnOtherScreen() {
/**
- * Window
+ * Window Functions
*/
function getAnotherWindowsOnSameScreen(window, offset) {
var windows = window.otherWindowsOnSameScreen();
windows.push(window);
windows = _.chain(windows).sortBy(function(window) {
- return window.topLeft().y;
+ return window.frame().y;
+ }).sortBy(function(window) {
+ return window.frame().x;
}).sortBy(function(window) {
return window.app().pid;
}).sortBy(function(window) {
@@ -98,23 +96,23 @@ function getAnotherWindowsOnSameScreen(window, offset) {
}
function getNextWindowsOnSameScreen(window) {
- return getAnotherWindowsOnSameScreen(window, 1)
+ return getAnotherWindowsOnSameScreen(window, -1)
};
function getPreviousWindowsOnSameScreen(window) {
- return getAnotherWindowsOnSameScreen(window, -1)
+ return getAnotherWindowsOnSameScreen(window, 1)
};
function setWindowCentral(window) {
window.setTopLeft({
- x: (window.screen().frameIncludingDockAndMenu().width - window.size().width) / 2 + window.screen().frameIncludingDockAndMenu().x,
- y: (window.screen().frameIncludingDockAndMenu().height - window.size().height) / 2 + window.screen().frameIncludingDockAndMenu().y
+ x: (window.screen().frameWithoutDockOrMenu().width - window.size().width) / 2 + window.screen().frameWithoutDockOrMenu().x,
+ y: (window.screen().frameWithoutDockOrMenu().height - window.size().height) / 2 + window.screen().frameWithoutDockOrMenu().y
});
};
/**
- * Mouse
+ * Mouse Functions
*/
function save_mouse_position_for_window(window) {
@@ -152,7 +150,7 @@ function restore_mouse_position_for_now() {
/**
- * App
+ * App Functions
*/
//switch app, and remember mouse position
@@ -170,14 +168,7 @@ function switchApp(appName) {
/**
- * Upgrade Phoenix Window
- */
-
-
-
-
-/**
- * My Settings
+ * My Configuartion App
*/
// Launch App
@@ -191,6 +182,11 @@ api.bind(',', mash, function() { switchApp('Sparrow'); });
api.bind('.', mash, function() { switchApp('Evernote'); });
api.bind('/', mash, function() { switchApp('Finder'); });
+
+/**
+ * My Configuartion Screen
+ */
+
// Next screen, now only support 2 display // TODO
api.bind('l', mash, function() {
var window = Window.focusedWindow();
@@ -245,8 +241,13 @@ api.bind('h', mashShift, function() {
moveToScreen(window, window.screen().previousScreen());
});
+
+/**
+ * My Configuartion Window
+ */
+
// Window Maximize
-api.bind('m', mash, function() {
+api.bind('m', mashShift, function() {
var window = Window.focusedWindow();
if (!window) return;
window.maximize();
@@ -278,12 +279,72 @@ api.bind('=', mash, function() {
});
// Window Central
-api.bind('m', mashShift, function() {
+api.bind('m', mash, function() {
var window = Window.focusedWindow();
if (!window) return;
setWindowCentral(window);
});
+// Window Vertical
+api.bind('\\', mash, function() {
+ var window = Window.focusedWindow();
+ if (!window) return;
+ window.setFrame({
+ x: window.frame().x,
+ y: window.screen().frameWithoutDockOrMenu().y,
+ width: window.frame().width,
+ height: window.screen().frameWithoutDockOrMenu().height
+ });
+});
+
+// Window >
+api.bind('right', mash, function() {
+ var window = Window.focusedWindow();
+ if (!window) return;
+ window.setFrame({
+ x: window.frame().x + 100,
+ y: window.frame().y,
+ width: window.frame().width,
+ height: window.frame().height
+ });
+});
+
+// Window <
+api.bind('left', mash, function() {
+ var window = Window.focusedWindow();
+ if (!window) return;
+ window.setFrame({
+ x: window.frame().x - 100,
+ y: window.frame().y,
+ width: window.frame().width,
+ height: window.frame().height
+ });
+});
+
+// Window ^
+api.bind('up', mash, function() {
+ var window = Window.focusedWindow();
+ if (!window) return;
+ window.setFrame({
+ x: window.frame().x,
+ y: window.frame().y - 100,
+ width: window.frame().width,
+ height: window.frame().height
+ });
+});
+
+// Window v
+api.bind('down', mash, function() {
+ var window = Window.focusedWindow();
+ if (!window) return;
+ window.setFrame({
+ x: window.frame().x,
+ y: window.frame().y + 100,
+ width: window.frame().width,
+ height: window.frame().height
+ });
+});
+
// Next Window in One Screen
api.bind('j', mash, function() {
var window = Window.focusedWindow();
@@ -312,6 +373,11 @@ api.bind('k', mash, function() {
restore_mouse_position_for_window(targetWindow);
});
+
+/**
+ * My Configuartion Mouse
+ */
+
// Central Mouse
api.bind('space', mash, function() {
var window = Window.focusedWindow();
@@ -320,6 +386,17 @@ api.bind('space', mash, function() {
});
+/**
+ * Mission Control
+ */
+
+// use Mac Keyboard setting
+// mash + i
+// mash + o
+
+
+
+
// Test
api.bind('0', mash, function() {
var cw = Window.focusedWindow();
@@ -340,8 +417,3 @@ api.bind('0', mash, function() {
//api.alert(_.chain(Window.allWindows()).difference(Window.visibleWindows()).value().length);
//api.alert(_.chain(Window.allWindows()).value().length);
});
-
-// Mission Control
-// use Mac Keyboard setting
-// mash + i
-// mash + o
View
1 .zshrc
@@ -116,6 +116,7 @@ alias ksh='killall ssh'
alias screen='TERM=xterm-256color screen'
alias s='sudo '
alias vd='vimdiff'
+alias vdiff='vimdiff'
alias f='find . -name '
alias tarx='tar xzvf'
alias tarc='tar czvf'

0 comments on commit 5f6186f

Please sign in to comment.
Something went wrong with that request. Please try again.