-
Notifications
You must be signed in to change notification settings - Fork 0
/
slate.js
184 lines (147 loc) Β· 4.73 KB
/
slate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* .slate.js
*/
// Dimensions
// ==============================================================================
var screenRect = function () { return slate.screen().rect(); };
var screenLeft = function () { return screenRect().x; };
var screenTop = function () { return screenRect().y; };
var screenWidth = function () { return screenRect().width; };
var screenHeight = function () { return screenRect().height; };
// Constants
// ==============================================================================
// Boundary between edge of screen and windows
var padding = {
top: 0,
bottom: 0,
left: 0,
right: 0
};
// Midpoint boundary between adjacent windows
var gap = 5;
// Globals
// ==============================================================================
slate.configAll({
defaultToCurrentScreen: true,
resizePercentOf: 'screenSize',
windowHintsFontName: 'Menlo',
windowHintsFontSize: '18',
windowHintsIgnoreHiddenWindows: false,
windowHintsSpread: true,
windowHintsWidth: '30',
windowHintsHeight: '30',
windowHintsRoundedCornerSize: '1',
});
// Keystrokes
// ==============================================================================
var hyper = 'ctrl;shift';
// Operations
// ==============================================================================
var full = slate.operation('move', {
x: screenLeft() + padding.left,
y: screenTop() + padding.top,
width: screenWidth() - padding.left - padding.right,
height: screenHeight() - padding.top - padding.bottom,
});
var leftHalf = slate.operation('move', {
x: screenLeft() + padding.left,
y: screenTop() + padding.top,
width: screenWidth() / 2 - padding.left - gap,
height: screenHeight() - padding.top - padding.bottom,
});
var rightHalf = slate.operation('move', {
x: screenLeft() + gap + screenWidth() / 2,
y: screenTop() + padding.top,
width: screenWidth() / 2 - padding.left - gap,
height: screenHeight() - padding.top - padding.bottom,
});
var center = slate.operation('move', {
x: screenLeft() + screenWidth() / 6,
y: screenTop() + screenHeight() / 6,
width: screenWidth() * 2 / 3,
height: screenHeight() * 2 / 3,
});
var topLeft = slate.operation('move', {
x: screenLeft() + padding.left,
y: screenTop() + padding.top,
width: screenWidth() / 2 - padding.left - gap,
height: screenHeight() / 2 - padding.top - gap,
});
var topRight = slate.operation('move', {
x: screenLeft() + screenWidth() / 2 + gap,
y: screenTop() + padding.top,
width: screenWidth() / 2 - gap - padding.right,
height: screenHeight() / 2 - padding.top - gap,
});
var bottomLeft = slate.operation('move', {
x: screenLeft() + padding.left,
y: screenTop() + screenHeight() / 2 + gap,
width: screenWidth() / 2 - padding.left - gap,
height: screenHeight() / 2 - gap - padding.bottom,
});
var bottomRight = slate.operation('move', {
x: screenLeft() + screenWidth() / 2 + gap,
y: screenTop() + screenHeight() / 2 + gap,
width: screenWidth() / 2 - padding.left - gap,
height: screenHeight() / 2 - gap - padding.bottom,
});
var focusLeft = slate.operation('focus', {
direction: 'left',
});
var focusRight = slate.operation('focus', {
direction: 'right',
});
var focusUp = slate.operation('focus', {
direction: 'up',
});
var focusDown = slate.operation('focus', {
direction: 'down',
});
var resizeLeft = slate.operation('resize', {
width: '-10%',
height: '+0%',
});
var resizeRight = slate.operation('resize', {
width: '+10%',
height: '+0%',
});
var resizeUp = slate.operation('resize', {
width: '+0%',
height: '-10%',
});
var resizeDown = slate.operation('resize', {
width: '+0%',
height: '+10%',
});
var hint = slate.operation('hint', {
characters: 'asdfghjklqwertyuiopcvbn',
});
var relaunch = slate.operation('relaunch');
// keybinds
// ==============================================================================
// General
slate.bind(`a:${hyper}`, hint);
slate.bind(`r:${hyper}`, relaunch);
slate.bind(`t:${hyper}`, function(win) {
slate.shell('/usr/bin/osascript /Users/Richard/bin/iterm.scpt' , true);
});
// Layouts
slate.bind(`f:${hyper}`, full);
slate.bind(`left:${hyper}`, leftHalf);
slate.bind(`right:${hyper}`, rightHalf);
slate.bind(`c:${hyper}`, center);
// Quarters
slate.bind(`-:${hyper}`, topLeft);
slate.bind(`=:${hyper}`, topRight);
slate.bind(`[:${hyper}`, bottomLeft);
slate.bind(`]:${hyper}`, bottomRight);
// Focus
slate.bind(`h:${hyper}`, focusLeft);
slate.bind(`j:${hyper}`, focusDown);
slate.bind(`k:${hyper}`, focusUp);
slate.bind(`l:${hyper}`, focusRight);
// Resize
slate.bind('left:alt', resizeLeft);
slate.bind('right:alt', resizeRight);
slate.bind('up:alt', resizeUp);
slate.bind('down:alt', resizeDown);