uh-layout 0.1.8 → 0.1.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ca5769ff37a5c22c8bc3706f22efce055edc717
4
- data.tar.gz: 3cceb31d660ec6f2fa63e2975adf075377095fb4
3
+ metadata.gz: 0e7f4858efe8b6d9ee912cb9d44d079196afecec
4
+ data.tar.gz: 2310f35802017071d7e96d96c6e58e754fed081a
5
5
  SHA512:
6
- metadata.gz: c6c21ded8c3b0fef4c4497c7e6783343ffc8571c5aa883f098a10ab1c76d1b8ad58af8895a07be12922b974ebae926167c2c9c92c1d968303801393222aefcc0
7
- data.tar.gz: b55f1a21d29e7ce29f314e367f408f7183178250a7dd5b8154fb7b2954a4700ce40cc148911a2f0dfafef9f040115bbe9ff22a440d7cd6f6f3fa0cab31a3ce73
6
+ metadata.gz: c8fc50f2837acf00921c01adb7b55b2cda10788c79ebdd110712e5545a945b88b08077cfcd7a20ca69b9262a76e87401e233351907ece31dc569e79a62f8b914
7
+ data.tar.gz: 1ea07ba5be3797274ff42007feb9386f0970738668a0d1c9e3323d7ce7fb57d4c1bab581810cf2cbf197af25ff40d5c6ccc73994d57606fd1617d35dc538865f
data/lib/uh/layout/bar.rb CHANGED
@@ -10,7 +10,7 @@ module Uh
10
10
 
11
11
  include GeoAccessors
12
12
 
13
- attr_writer :active
13
+ attr_writer :active, :status
14
14
 
15
15
  def initialize(display, screen, colors)
16
16
  @display = display
@@ -40,6 +40,10 @@ module Uh
40
40
  @screen.current_tag.columns, @screen.current_tag.current_column
41
41
  draw_tags BORDER_HEIGHT + BORDER_PADDING_Y + text_line_height,
42
42
  @screen.tags, @screen.current_tag
43
+ if @status
44
+ draw_status BORDER_HEIGHT + BORDER_PADDING_Y + text_line_height,
45
+ @status
46
+ end
43
47
  blit
44
48
  end
45
49
 
@@ -80,6 +84,10 @@ module Uh
80
84
  @display.font.height + TEXT_PADDING_Y * 2
81
85
  end
82
86
 
87
+ def text_width(text, padding_x: TEXT_PADDING_X)
88
+ text.length * @display.font.width + padding_x * 2
89
+ end
90
+
83
91
  def column_offset_x(column)
84
92
  column.x - x
85
93
  end
@@ -134,9 +142,13 @@ module Uh
134
142
  end
135
143
  end
136
144
 
145
+ def draw_status(y_offset, status)
146
+ draw_text status, width - text_width(status), y_offset
147
+ end
148
+
137
149
  def draw_text(text, x, y, bg: nil, padding_x: TEXT_PADDING_X)
138
150
  text = text.to_s
139
- text_width = text.length * @display.font.width + padding_x * 2
151
+ text_width = text_width text, padding_x: padding_x
140
152
  text_y = y + @display.font.ascent + TEXT_PADDING_Y
141
153
  if bg
142
154
  @pixmap.gc_color bg
@@ -1,5 +1,5 @@
1
1
  module Uh
2
2
  class Layout
3
- VERSION = '0.1.8'
3
+ VERSION = '0.1.9'
4
4
  end
5
5
  end
data/lib/uh/layout.rb CHANGED
@@ -129,7 +129,7 @@ module Uh
129
129
  end
130
130
 
131
131
  def handle_client_swap(direction)
132
- return unless current_client
132
+ return unless current_client && current_column.clients.size >= 2
133
133
  current_column.client_swap direction
134
134
  update_widgets
135
135
  end
@@ -350,6 +350,14 @@ module Uh
350
350
  end
351
351
  end
352
352
 
353
+ context 'with one column and two clients' do
354
+ before { layout << client }
355
+
356
+ it 'does not raise any error' do
357
+ expect { layout.handle_client_swap :pred }.not_to raise_error
358
+ end
359
+ end
360
+
353
361
  context 'with one column and two clients' do
354
362
  before { layout << other_client << client }
355
363
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uh-layout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-17 00:00:00.000000000 Z
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uh
@@ -126,4 +126,3 @@ test_files:
126
126
  - spec/uh/layout/screen_spec.rb
127
127
  - spec/uh/layout/tag_spec.rb
128
128
  - spec/uh/layout_spec.rb
129
- has_rdoc: