uh-layout 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a1637a620687e36d7ff7fbe4af3b4ffff5a8039
4
- data.tar.gz: ff7e8946af03a49c31a403c8130bce7cf36adc06
3
+ metadata.gz: 27063bf0c7da809ea430cc4de1595149868766db
4
+ data.tar.gz: 3770a238eb847d0f214d4560cc28b11177443ea1
5
5
  SHA512:
6
- metadata.gz: 0d5b7d74cfb9127b7fd9cec06256d2848a5fdc5fd8bdffc45fb57301421175421c1b855ff35e7b96a8cca3b6491daacbbb06962a1c29074df53c1568998cbe61
7
- data.tar.gz: 047789ccf9b1c14401e707869867bfd11b4ed4d88dc178ca1b74f0b04eb1eecdcfa26ed652fc85dd745bcfddd448ca1fce94d7698c352ac1a8f174db55436a05
6
+ metadata.gz: c58a7649238a4fad66661ece07040c51359d0afdbb485fea97a2352c2def84634c4a2b2b1bd7b5d6d3eceefa000be944d5eee87f83c84ca01785e3df2bca1f88
7
+ data.tar.gz: 1fe67fcbd4de7cc6525d7822e83da41c13b6d80b8a002cdf4e7d7904c937a50a827372c09f40c8977cadd3e320d665dcc79a709772035f76fdfcb0fbbc350789
data/lib/uh/layout/bar.rb CHANGED
@@ -6,7 +6,7 @@ module Uh
6
6
  BORDER_HEIGHT = 2
7
7
  BORDER_PADDING_Y = 0
8
8
  COLUMN_PADDING_X = 1
9
- TAG_PADDING_X = 5
9
+ VIEW_PADDING_X = 5
10
10
 
11
11
  include GeoAccessors
12
12
 
@@ -38,9 +38,9 @@ module Uh
38
38
  def redraw
39
39
  draw_background
40
40
  draw_columns BORDER_HEIGHT + BORDER_PADDING_Y,
41
- @screen.current_tag.columns, @screen.current_tag.current_column
42
- draw_tags BORDER_HEIGHT + BORDER_PADDING_Y + text_line_height,
43
- @screen.tags, @screen.current_tag
41
+ @screen.current_view.columns, @screen.current_view.current_column
42
+ draw_views BORDER_HEIGHT + BORDER_PADDING_Y + text_line_height,
43
+ @screen.views, @screen.current_view
44
44
  if @status
45
45
  draw_status BORDER_HEIGHT + BORDER_PADDING_Y + text_line_height,
46
46
  @status
@@ -126,19 +126,19 @@ module Uh
126
126
  bg: current ? @colors[:hi] : @colors[:bg]
127
127
  end
128
128
 
129
- def draw_tags(y_offset, tags, current_tag)
130
- tags.sort_by(&:id).inject(0) do |x_offset, tag|
131
- color = if tag == current_tag
129
+ def draw_views(y_offset, views, current_view)
130
+ views.sort_by(&:id).inject(0) do |x_offset, view|
131
+ color = if view == current_view
132
132
  active_color
133
- elsif tag.clients.any?
133
+ elsif view.clients.any?
134
134
  @colors[:hi]
135
135
  else
136
136
  @colors[:bg]
137
137
  end
138
138
 
139
- x_offset + draw_text(tag.id, x_offset, y_offset,
139
+ x_offset + draw_text(view.id, x_offset, y_offset,
140
140
  bg: color,
141
- padding_x: TAG_PADDING_X
141
+ padding_x: VIEW_PADDING_X
142
142
  )
143
143
  end
144
144
  end
@@ -8,10 +8,10 @@ module Uh
8
8
  def to_s
9
9
  @layout.screens.inject('') do |m, screen|
10
10
  m << "%s%s\n" % [@layout.current_screen?(screen) ? '*' : ' ', screen]
11
- screen.tags.each do |tag|
12
- m << " %s%s\n" % [screen.current_tag?(tag) ? '*' : ' ', tag]
13
- tag.columns.each do |column|
14
- m << " %s%s\n" % [tag.current_column?(column) ? '*' : ' ', column]
11
+ screen.views.each do |view|
12
+ m << " %s%s\n" % [screen.current_view?(view) ? '*' : ' ', view]
13
+ view.columns.each do |column|
14
+ m << " %s%s\n" % [view.current_column?(column) ? '*' : ' ', column]
15
15
  column.clients.each do |client|
16
16
  m << " %s%s\n" % [
17
17
  column.current_client?(client) ? '*' : ' ',
@@ -1,24 +1,24 @@
1
1
  module Uh
2
2
  class Layout
3
3
  class History
4
- TAGS_SIZE_MAX = 8
4
+ VIEWS_SIZE_MAX = 8
5
5
 
6
- attr_reader :tags, :tags_size_max
6
+ attr_reader :views, :views_size_max
7
7
 
8
- def initialize(tags = [], tags_size_max: TAGS_SIZE_MAX)
9
- @tags = tags
10
- @tags_size_max = tags_size_max
8
+ def initialize(views = [], views_size_max: VIEWS_SIZE_MAX)
9
+ @views = views
10
+ @views_size_max = views_size_max
11
11
  end
12
12
 
13
- def record_tag(tag)
14
- @tags << tag
15
- if @tags.size > @tags_size_max
16
- @tags = @tags.drop @tags.size - @tags_size_max
13
+ def record_view(view)
14
+ @views << view
15
+ if @views.size > @views_size_max
16
+ @views = @views.drop @views.size - @views_size_max
17
17
  end
18
18
  end
19
19
 
20
- def last_tag
21
- @tags.last
20
+ def last_view
21
+ @views.last
22
22
  end
23
23
  end
24
24
  end
@@ -4,15 +4,15 @@ module Uh
4
4
  include GeoAccessors
5
5
 
6
6
  extend Forwardable
7
- def_delegator :@tags, :current, :current_tag
8
- def_delegator :current_tag, :==, :current_tag?
7
+ def_delegator :@views, :current, :current_view
8
+ def_delegator :current_view, :==, :current_view?
9
9
 
10
- attr_reader :id, :tags, :geo
10
+ attr_reader :id, :views, :geo
11
11
 
12
12
  def initialize(id, geo)
13
13
  @id = id
14
14
  @geo = geo.dup
15
- @tags = Container.new([Tag.new('1', @geo)])
15
+ @views = Container.new([View.new('1', @geo)])
16
16
  end
17
17
 
18
18
  def to_s
@@ -21,11 +21,11 @@ module Uh
21
21
 
22
22
  def height=(value)
23
23
  @geo.height = value
24
- @tags.each { |tag| tag.height = value }
24
+ @views.each { |view| view.height = value }
25
25
  end
26
26
 
27
27
  def include?(client)
28
- @tags.any? { |tag| tag.include? client }
28
+ @views.any? { |view| view.include? client }
29
29
  end
30
30
  end
31
31
  end
@@ -1,5 +1,5 @@
1
1
  module Uh
2
2
  class Layout
3
- VERSION = '0.3.2'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  module Uh
2
2
  class Layout
3
- class Tag
3
+ class View
4
4
  include GeoAccessors
5
5
 
6
6
  extend Forwardable
@@ -23,7 +23,7 @@ module Uh
23
23
  end
24
24
 
25
25
  def to_s
26
- "TAG ##{@id}, geo: #{@geo}"
26
+ "VIEW ##{@id}, geo: #{@geo}"
27
27
  end
28
28
 
29
29
  def clients
data/lib/uh/layout.rb CHANGED
@@ -11,7 +11,7 @@ require 'uh/layout/dumper'
11
11
  require 'uh/layout/history'
12
12
  require 'uh/layout/registrant'
13
13
  require 'uh/layout/screen'
14
- require 'uh/layout/tag'
14
+ require 'uh/layout/view'
15
15
 
16
16
  module Uh
17
17
  class Layout
@@ -29,8 +29,8 @@ module Uh
29
29
  extend Forwardable
30
30
  def_delegator :@screens, :current, :current_screen
31
31
  def_delegator :current_screen, :==, :current_screen?
32
- def_delegator :current_screen, :current_tag
33
- def_delegator :current_tag, :current_column
32
+ def_delegator :current_screen, :current_view
33
+ def_delegator :current_view, :current_column
34
34
 
35
35
  attr_reader :screens, :widgets, :colors, :history
36
36
 
@@ -65,11 +65,11 @@ module Uh
65
65
  end
66
66
 
67
67
  def suggest_geo
68
- (current_column or current_tag).geo.dup
68
+ (current_column or current_view).geo.dup
69
69
  end
70
70
 
71
71
  def <<(client)
72
- current_tag.current_column_or_create << client
72
+ current_view.current_column_or_create << client
73
73
  current_column.current_client = client
74
74
  current_column.arrange_clients
75
75
  current_column.show_hide_clients
@@ -80,9 +80,9 @@ module Uh
80
80
  alias push <<
81
81
 
82
82
  def remove(client)
83
- screen, tag, column = find_client client
83
+ screen, view, column = find_client client
84
84
  column.remove client
85
- tag.arrange_columns
85
+ view.arrange_columns
86
86
  column.show_hide_clients
87
87
  current_client.focus if current_client
88
88
  update_widgets
@@ -109,29 +109,29 @@ module Uh
109
109
  push client
110
110
  end
111
111
 
112
- def handle_tag_sel(tag_id)
113
- tag_id = tag_id.to_s
114
- return unless current_tag.id != tag_id
115
- @history.record_tag current_tag
116
- current_tag.hide
117
- current_screen.tags.current = find_tag_or_create tag_id
118
- current_tag.each_column &:show_hide_clients
112
+ def handle_view_sel(view_id)
113
+ view_id = view_id.to_s
114
+ return unless current_view.id != view_id
115
+ @history.record_view current_view
116
+ current_view.hide
117
+ current_screen.views.current = find_view_or_create view_id
118
+ current_view.each_column &:show_hide_clients
119
119
  current_client.focus if current_client
120
120
  update_widgets
121
121
  end
122
122
 
123
- def handle_tag_set(tag_id)
124
- return unless current_client && current_tag.id != tag_id
125
- previous_tag_id = current_tag.id
123
+ def handle_view_set(view_id)
124
+ return unless current_client && current_view.id != view_id
125
+ previous_view_id = current_view.id
126
126
  remove client = current_client
127
- handle_tag_sel tag_id
127
+ handle_view_sel view_id
128
128
  push client
129
- handle_tag_sel previous_tag_id
129
+ handle_view_sel previous_view_id
130
130
  end
131
131
 
132
132
  def handle_column_sel(direction)
133
- return unless current_tag.columns.any?
134
- current_tag.columns.sel direction
133
+ return unless current_view.columns.any?
134
+ current_view.columns.sel direction
135
135
  current_client.focus
136
136
  update_widgets
137
137
  end
@@ -157,16 +157,16 @@ module Uh
157
157
  update_widgets
158
158
  end
159
159
 
160
- def handle_client_column_set(direction, mover: client_mover_for_current_tag)
160
+ def handle_client_column_set(direction, mover: client_mover_for_current_view)
161
161
  return unless current_client
162
162
  mover.move_current direction
163
- current_tag.arrange_columns
164
- current_tag.each_column &:show_hide_clients
163
+ current_view.arrange_columns
164
+ current_view.each_column &:show_hide_clients
165
165
  update_widgets
166
166
  end
167
167
 
168
- def handle_history_tag_pred
169
- handle_tag_sel @history.last_tag.id
168
+ def handle_history_view_pred
169
+ handle_view_sel @history.last_view.id
170
170
  end
171
171
 
172
172
  def handle_kill_current
@@ -178,24 +178,24 @@ module Uh
178
178
 
179
179
  def find_client(client)
180
180
  screens.each do |screen|
181
- screen.tags.each do |tag|
182
- tag.each_column do |column|
181
+ screen.views.each do |view|
182
+ view.each_column do |column|
183
183
  if column.include? client
184
- return screen, tag, column
184
+ return screen, view, column
185
185
  end
186
186
  end
187
187
  end
188
188
  end
189
189
  end
190
190
 
191
- def find_tag_or_create(tag_id)
192
- current_screen.tags.find { |e| e.id == tag_id } or Tag.new(tag_id, current_screen.geo).tap do |tag|
193
- current_screen.tags << tag
191
+ def find_view_or_create(view_id)
192
+ current_screen.views.find { |e| e.id == view_id } or View.new(view_id, current_screen.geo).tap do |view|
193
+ current_screen.views << view
194
194
  end
195
195
  end
196
196
 
197
- def client_mover_for_current_tag
198
- ClientColumnMover.new(current_tag.columns, current_tag.columns_max_count?)
197
+ def client_mover_for_current_view
198
+ ClientColumnMover.new(current_view.columns, current_view.columns_max_count?)
199
199
  end
200
200
  end
201
201
  end
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.3.2
4
+ version: 0.4.0
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-04-26 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uh
@@ -72,8 +72,8 @@ files:
72
72
  - lib/uh/layout/history.rb
73
73
  - lib/uh/layout/registrant.rb
74
74
  - lib/uh/layout/screen.rb
75
- - lib/uh/layout/tag.rb
76
75
  - lib/uh/layout/version.rb
76
+ - lib/uh/layout/view.rb
77
77
  homepage: https://rubygems.org/gems/uh-layout
78
78
  licenses:
79
79
  - BSD-3-Clause