uh-layout 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,485 +0,0 @@
1
- module Uh
2
- describe Layout do
3
- let(:geo) { build_geo }
4
- let(:client) { build_client }
5
- let(:other_client) { build_client }
6
- let(:widget) { double('widget').as_null_object }
7
- let(:options) { { } }
8
- subject(:layout) { described_class.new options }
9
-
10
- before do
11
- layout.screens << Layout::Screen.new(0, geo)
12
- layout.screens << Layout::Screen.new(1, geo)
13
- layout.widgets << widget
14
- end
15
-
16
- context 'when given colors option' do
17
- let(:options) { { colors: { fg: 'rgb:42/42/42' } } }
18
-
19
- it 'merges given colors with default ones' do
20
- expect(layout.colors).to include fg: 'rgb:42/42/42', bg: 'rgb:0c/0c/0c'
21
- end
22
- end
23
-
24
- describe '#register' do
25
- it 'uses a registrant to register the layout with given display' do
26
- display = double 'display'
27
- expect(Layout::Registrant).to receive(:register).with layout, display
28
- layout.register display
29
- end
30
- end
31
-
32
- describe '#include?' do
33
- it 'returns false when layout does not include given client' do
34
- expect(layout.include? client).to be false
35
- end
36
-
37
- it 'returns true when layout includes given client' do
38
- layout << client
39
- expect(layout.include? client).to be true
40
- end
41
- end
42
-
43
- describe '#update_widgets' do
44
- it 'updates widgets' do
45
- expect(layout.widgets).to all receive :update
46
- layout.update_widgets
47
- end
48
-
49
- it 'redraws widgets' do
50
- expect(layout.widgets).to all receive :redraw
51
- layout.update_widgets
52
- end
53
- end
54
-
55
- describe '#suggest_geo' do
56
- it 'returns current tag geo copy' do
57
- expect(layout.suggest_geo)
58
- .to eq(layout.current_tag.geo)
59
- .and not_be layout.current_tag.geo
60
- end
61
-
62
- context 'when current tag has a column' do
63
- before { layout.current_tag.columns << Layout::Column.new(build_geo 42) }
64
-
65
- it 'returns current column geo' do
66
- expect(layout.suggest_geo)
67
- .to eq(layout.current_column.geo)
68
- .and not_be layout.current_column.geo
69
- end
70
- end
71
- end
72
-
73
- describe '#<<' do
74
- before { layout << other_client }
75
-
76
- it 'adds given client to current column' do
77
- layout << client
78
- expect(layout.current_column).to include client
79
- end
80
-
81
- it 'sets given client as the current one in current column' do
82
- layout << client
83
- expect(layout.current_column.current_client).to be client
84
- end
85
-
86
- it 'arranges current column clients' do
87
- expect(layout.current_column).to receive :arrange_clients
88
- layout << client
89
- end
90
-
91
- it 'shows and hides clients in current column' do
92
- expect(layout.current_column).to receive :show_hide_clients
93
- layout << client
94
- end
95
-
96
- it 'focuses given client' do
97
- expect(client).to receive :focus
98
- layout << client
99
- end
100
-
101
- it 'updates widgets' do
102
- expect(widget).to receive :update
103
- layout << client
104
- end
105
-
106
- it 'returns self' do
107
- expect(layout << client).to be layout
108
- end
109
- end
110
-
111
- describe '#remove' do
112
- before { layout << client << other_client }
113
-
114
- it 'removes given client from the layout' do
115
- layout.remove client
116
- expect(layout).not_to include client
117
- end
118
-
119
- it 'arranges columns in removed client tag' do
120
- expect(layout.current_tag).to receive :arrange_columns
121
- layout.remove client
122
- end
123
-
124
- it 'shows and hides clients in removed client column' do
125
- expect(layout.current_column).to receive :show_hide_clients
126
- layout.remove client
127
- end
128
-
129
- it 'focuses the new current client' do
130
- expect(other_client).to receive :focus
131
- layout.remove client
132
- end
133
-
134
- it 'updates widgets' do
135
- expect(widget).to receive :update
136
- layout.remove client
137
- end
138
- end
139
-
140
- describe '#update' do
141
- context 'when given client is visible' do
142
- before { client.show }
143
-
144
- it 'updates the widgets' do
145
- expect(layout).to receive :update_widgets
146
- layout.update client
147
- end
148
- end
149
-
150
- context 'when client is hidden' do
151
- before { client.hide }
152
-
153
- it 'does not update the widget' do
154
- expect(layout).not_to receive :update_widgets
155
- layout.update client
156
- end
157
- end
158
- end
159
-
160
- describe '#expose' do
161
- it 'updates the widgets' do
162
- expect(layout).to receive :update_widgets
163
- layout.expose :window
164
- end
165
- end
166
-
167
- describe '#handle_screen_sel' do
168
- it 'selects consecutive screen in given direction' do
169
- expect { layout.handle_screen_sel :succ }
170
- .to change { layout.current_screen.id }.from(0).to(1)
171
- end
172
-
173
- it 'focus selected screen current client' do
174
- layout << client
175
- expect(client).to receive :focus
176
- 2.times { layout.handle_screen_sel :succ }
177
- end
178
-
179
- it 'updates widgets' do
180
- expect(widget).to receive :update
181
- layout.handle_screen_sel :succ
182
- end
183
- end
184
-
185
- describe '#handle_screen_set' do
186
- before { layout << client }
187
-
188
- it 'removes current client from origin screen' do
189
- layout.handle_screen_set :succ
190
- expect(layout.screens[0].tags.flat_map(&:clients)).not_to include client
191
- end
192
-
193
- it 'adds current client to consecutive screen in given direction' do
194
- layout.handle_screen_set :succ
195
- expect(layout.screens[1].tags.flat_map(&:clients)).to include client
196
- end
197
-
198
- it 'selects consecutive screen in given direction' do
199
- expect { layout.handle_screen_set :succ }
200
- .to change { layout.current_screen.id }.from(0).to(1)
201
- end
202
-
203
- context 'without client' do
204
- before { layout.remove client }
205
-
206
- it 'does not raise any error' do
207
- expect { layout.handle_screen_set :succ }.not_to raise_error
208
- end
209
- end
210
- end
211
-
212
- describe '#handle_tag_sel' do
213
- before { layout << client }
214
-
215
- it 'hides clients on previously selected tag' do
216
- layout.handle_tag_sel '2'
217
- expect(client).to be_hidden
218
- end
219
-
220
- it 'sets the selected tag as the current one' do
221
- layout.handle_tag_sel '2'
222
- expect(layout.current_tag.id).to eq '2'
223
- end
224
-
225
- it 'shows and hides clients in selected tag columns' do
226
- layout.handle_tag_sel '2'
227
- expect(layout.current_screen.tags[0].columns)
228
- .to all receive :show_hide_clients
229
- layout.handle_tag_sel '1'
230
- end
231
-
232
- it 'focuses selected tag current client' do
233
- layout.handle_tag_sel '2'
234
- expect(client).to receive :focus
235
- layout.handle_tag_sel '1'
236
- end
237
-
238
- it 'updates widgets' do
239
- expect(widget).to receive :update
240
- layout.handle_tag_sel '2'
241
- end
242
-
243
- it 'accepts non-string arguments' do
244
- layout.handle_tag_sel 2
245
- expect(layout.current_tag.id).to eq '2'
246
- end
247
-
248
- it 'records previous tag in history' do
249
- previous_tag = layout.current_tag
250
- layout.handle_tag_sel 2
251
- expect(layout.history.tags).to include previous_tag
252
- end
253
- end
254
-
255
- describe '#handle_tag_set' do
256
- context 'without client' do
257
- it 'does not raise any error' do
258
- expect { layout.handle_tag_set '2' }.not_to raise_error
259
- end
260
- end
261
-
262
- context 'with a client' do
263
- before { layout << other_client << client }
264
-
265
- it 'removes current client from origin tag' do
266
- origin_tag = layout.current_tag
267
- layout.handle_tag_set '2'
268
- expect(origin_tag).not_to include client
269
- end
270
-
271
- it 'removes current client from layout' do
272
- expect(layout).to receive(:remove).with client
273
- layout.handle_tag_set '2'
274
- end
275
-
276
- it 'hides current client' do
277
- expect(client).to receive :hide
278
- layout.handle_tag_set '2'
279
- end
280
-
281
- it 'adds current client to given tag' do
282
- layout.handle_tag_set '2'
283
- dest_tag = layout.current_screen.tags.find { |e| e.id == '2' }
284
- expect(dest_tag).to include client
285
- end
286
-
287
- it 'preserves current tag' do
288
- layout.handle_tag_set '2'
289
- expect(layout.current_tag.id).to eq '1'
290
- end
291
-
292
- it 'updates widgets' do
293
- expect(widget).to receive :update
294
- layout.handle_tag_set '2'
295
- end
296
- end
297
- end
298
-
299
- describe '#handle_column_sel' do
300
- context 'without client' do
301
- it 'does not raise any error' do
302
- expect { layout.handle_column_sel :succ }.not_to raise_error
303
- end
304
- end
305
-
306
- context 'with two clients in two columns' do
307
- before do
308
- layout << client
309
- layout.current_tag.columns << Layout::Column.new(geo).tap do |o|
310
- o << other_client
311
- end
312
- end
313
-
314
- it 'selects the column consecutive to current one in given direction' do
315
- layout.handle_column_sel :succ
316
- expect(layout.current_column).to be layout.current_tag.columns[1]
317
- end
318
-
319
- it 'focuses the current client of selected column' do
320
- expect(other_client).to receive :focus
321
- layout.handle_column_sel :succ
322
- end
323
-
324
- it 'updates widgets' do
325
- expect(widget).to receive :update
326
- layout.handle_column_sel :succ
327
- end
328
- end
329
- end
330
-
331
- describe '#handle_column_mode_toggle' do
332
- context 'without column' do
333
- it 'does not raise any error' do
334
- expect { layout.handle_column_mode_toggle }.not_to raise_error
335
- end
336
- end
337
-
338
- context 'with a column' do
339
- before { layout << client }
340
-
341
- it 'toggles current column mode' do
342
- expect(layout.current_column).to receive :mode_toggle
343
- layout.handle_column_mode_toggle
344
- end
345
-
346
- it 'arranges current column clients' do
347
- expect(layout.current_column).to receive :arrange_clients
348
- layout.handle_column_mode_toggle
349
- end
350
-
351
- it 'shows and hides clients in current column' do
352
- expect(layout.current_column).to receive :show_hide_clients
353
- layout.handle_column_mode_toggle
354
- end
355
- end
356
- end
357
-
358
- describe '#handle_client_sel' do
359
- context 'without client' do
360
- it 'does not raise any error' do
361
- expect { layout.handle_client_sel :succ }.not_to raise_error
362
- end
363
- end
364
-
365
- context 'with one column and two clients' do
366
- before { layout << client << other_client }
367
-
368
- it 'selects current column consecutive client in given direction' do
369
- expect { layout.handle_client_sel :pred }
370
- .to change { layout.current_client }.from(other_client).to(client)
371
- end
372
-
373
- it 'focuses current client' do
374
- expect(client).to receive :focus
375
- layout.handle_client_sel :pred
376
- end
377
-
378
- it 'updates column clients visibility' do
379
- expect(layout.current_column).to receive :show_hide_clients
380
- layout.handle_client_sel :pred
381
- end
382
-
383
- it 'updates widgets' do
384
- expect(widget).to receive :update
385
- layout.handle_client_sel :pred
386
- end
387
- end
388
- end
389
-
390
- describe '#handle_client_swap' do
391
- context 'without client' do
392
- it 'does not raise any error' do
393
- expect { layout.handle_client_swap :pred }.not_to raise_error
394
- end
395
- end
396
-
397
- context 'with one column and two clients' do
398
- before { layout << client }
399
-
400
- it 'does not raise any error' do
401
- expect { layout.handle_client_swap :pred }.not_to raise_error
402
- end
403
- end
404
-
405
- context 'with one column and two clients' do
406
- before { layout << other_client << client }
407
-
408
- it 'sends #client_swap to current column with given direction' do
409
- expect(layout.current_column).to receive(:client_swap).with :pred
410
- layout.handle_client_swap :pred
411
- end
412
-
413
- it 'updates widgets' do
414
- expect(widget).to receive :update
415
- layout.handle_client_swap :pred
416
- end
417
- end
418
- end
419
-
420
- describe '#handle_client_column_set' do
421
- context 'without client' do
422
- it 'does not raise any error' do
423
- expect { layout.handle_client_column_set :succ }.not_to raise_error
424
- end
425
- end
426
-
427
- context 'with one column and two clients' do
428
- let(:mover) { instance_spy Layout::ClientColumnMover }
429
-
430
- before { layout << other_client << client }
431
-
432
- it 'moves current client with given client column mover' do
433
- expect(mover).to receive(:move_current).with(:succ)
434
- layout.handle_client_column_set :succ, mover: mover
435
- end
436
-
437
- it 'arranges current tag columns' do
438
- expect(layout.current_tag).to receive :arrange_columns
439
- layout.handle_client_column_set :succ
440
- end
441
-
442
- it 'shows and hides clients in selected tag columns' do
443
- expect(layout.current_tag.columns).to all receive :show_hide_clients
444
- layout.handle_client_column_set :succ
445
- end
446
-
447
- it 'does not change current client' do
448
- expect { layout.handle_client_column_set :succ }
449
- .not_to change { layout.current_client }
450
- end
451
-
452
- it 'updates widgets' do
453
- expect(widget).to receive :update
454
- layout.handle_client_column_set :succ
455
- end
456
- end
457
- end
458
-
459
- describe '#handle_history_tag_pred' do
460
- it 'selects last tag recorded in history' do
461
- layout.handle_tag_sel 2
462
- expect { layout.handle_history_tag_pred }
463
- .to change { layout.current_tag.id }
464
- .from(?2).to ?1
465
- end
466
- end
467
-
468
- describe '#handle_kill_current' do
469
- context 'without client' do
470
- it 'does not raise any error' do
471
- expect { layout.handle_kill_current }.not_to raise_error
472
- end
473
- end
474
-
475
- context 'with a client' do
476
- before { layout << client }
477
-
478
- it 'kills current client' do
479
- expect(client).to receive :kill
480
- layout.handle_kill_current
481
- end
482
- end
483
- end
484
- end
485
- end
data/uh-layout.gemspec DELETED
@@ -1,20 +0,0 @@
1
- require File.expand_path('../lib/uh/layout/version', __FILE__)
2
-
3
- Gem::Specification.new do |s|
4
- s.name = 'uh-layout'
5
- s.version = Uh::Layout::VERSION.dup
6
- s.summary = 'simple tiling and stacking layout for uh-wm'
7
- s.description = s.name
8
- s.license = 'BSD-3-Clause'
9
- s.homepage = 'https://rubygems.org/gems/uh-layout'
10
-
11
- s.authors = 'Thibault Jouan'
12
- s.email = 'tj@a13.fr'
13
-
14
- s.files = `git ls-files`.split $/
15
-
16
-
17
- s.add_development_dependency 'uh', '~> 1.0'
18
- s.add_development_dependency 'rake', '~> 10.4'
19
- s.add_development_dependency 'rspec', '~> 3.2'
20
- end