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 +4 -4
- data/lib/uh/layout/bar.rb +10 -10
- data/lib/uh/layout/dumper.rb +4 -4
- data/lib/uh/layout/history.rb +11 -11
- data/lib/uh/layout/screen.rb +6 -6
- data/lib/uh/layout/version.rb +1 -1
- data/lib/uh/layout/{tag.rb → view.rb} +2 -2
- data/lib/uh/layout.rb +34 -34
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27063bf0c7da809ea430cc4de1595149868766db
|
4
|
+
data.tar.gz: 3770a238eb847d0f214d4560cc28b11177443ea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.
|
42
|
-
|
43
|
-
@screen.
|
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
|
130
|
-
|
131
|
-
color = if
|
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
|
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(
|
139
|
+
x_offset + draw_text(view.id, x_offset, y_offset,
|
140
140
|
bg: color,
|
141
|
-
padding_x:
|
141
|
+
padding_x: VIEW_PADDING_X
|
142
142
|
)
|
143
143
|
end
|
144
144
|
end
|
data/lib/uh/layout/dumper.rb
CHANGED
@@ -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.
|
12
|
-
m << " %s%s\n" % [screen.
|
13
|
-
|
14
|
-
m << " %s%s\n" % [
|
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) ? '*' : ' ',
|
data/lib/uh/layout/history.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
module Uh
|
2
2
|
class Layout
|
3
3
|
class History
|
4
|
-
|
4
|
+
VIEWS_SIZE_MAX = 8
|
5
5
|
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :views, :views_size_max
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
10
|
-
@
|
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
|
14
|
-
@
|
15
|
-
if @
|
16
|
-
@
|
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
|
21
|
-
@
|
20
|
+
def last_view
|
21
|
+
@views.last
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/uh/layout/screen.rb
CHANGED
@@ -4,15 +4,15 @@ module Uh
|
|
4
4
|
include GeoAccessors
|
5
5
|
|
6
6
|
extend Forwardable
|
7
|
-
def_delegator :@
|
8
|
-
def_delegator :
|
7
|
+
def_delegator :@views, :current, :current_view
|
8
|
+
def_delegator :current_view, :==, :current_view?
|
9
9
|
|
10
|
-
attr_reader :id, :
|
10
|
+
attr_reader :id, :views, :geo
|
11
11
|
|
12
12
|
def initialize(id, geo)
|
13
13
|
@id = id
|
14
14
|
@geo = geo.dup
|
15
|
-
@
|
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
|
-
@
|
24
|
+
@views.each { |view| view.height = value }
|
25
25
|
end
|
26
26
|
|
27
27
|
def include?(client)
|
28
|
-
@
|
28
|
+
@views.any? { |view| view.include? client }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/uh/layout/version.rb
CHANGED
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/
|
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, :
|
33
|
-
def_delegator :
|
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
|
68
|
+
(current_column or current_view).geo.dup
|
69
69
|
end
|
70
70
|
|
71
71
|
def <<(client)
|
72
|
-
|
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,
|
83
|
+
screen, view, column = find_client client
|
84
84
|
column.remove client
|
85
|
-
|
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
|
113
|
-
|
114
|
-
return unless
|
115
|
-
@history.
|
116
|
-
|
117
|
-
current_screen.
|
118
|
-
|
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
|
124
|
-
return unless current_client &&
|
125
|
-
|
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
|
-
|
127
|
+
handle_view_sel view_id
|
128
128
|
push client
|
129
|
-
|
129
|
+
handle_view_sel previous_view_id
|
130
130
|
end
|
131
131
|
|
132
132
|
def handle_column_sel(direction)
|
133
|
-
return unless
|
134
|
-
|
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:
|
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
|
-
|
164
|
-
|
163
|
+
current_view.arrange_columns
|
164
|
+
current_view.each_column &:show_hide_clients
|
165
165
|
update_widgets
|
166
166
|
end
|
167
167
|
|
168
|
-
def
|
169
|
-
|
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.
|
182
|
-
|
181
|
+
screen.views.each do |view|
|
182
|
+
view.each_column do |column|
|
183
183
|
if column.include? client
|
184
|
-
return screen,
|
184
|
+
return screen, view, column
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
def
|
192
|
-
current_screen.
|
193
|
-
current_screen.
|
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
|
198
|
-
ClientColumnMover.new(
|
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.
|
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-
|
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
|