Class: Uh::Layout
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/uh/layout.rb,
lib/uh/layout/bar.rb,
lib/uh/layout/view.rb,
lib/uh/layout/column.rb,
lib/uh/layout/dumper.rb,
lib/uh/layout/screen.rb,
lib/uh/layout/history.rb,
lib/uh/layout/version.rb,
lib/uh/layout/container.rb,
lib/uh/layout/registrant.rb,
lib/uh/layout/arrangers/stack.rb,
lib/uh/layout/arrangers/vert_tile.rb,
lib/uh/layout/client_column_mover.rb,
lib/uh/layout/arrangers/fixed_width.rb
Defined Under Namespace
Modules: Arrangers, Registrant
Classes: Bar, ClientColumnMover, Column, Container, Dumper, History, Screen, View
Constant Summary
collapse
- Error =
Class.new StandardError
- RuntimeError =
Class.new RuntimeError
- ArgumentError =
Class.new Error
- COLORS =
{
fg: 'rgb:d0/d0/d0'.freeze,
bg: 'rgb:0c/0c/0c'.freeze,
sel: 'rgb:d7/00/5f'.freeze,
hi: 'rgb:82/00/3a'.freeze
}.freeze
- VERSION =
'0.5.1'.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(**options) ⇒ Layout
Returns a new instance of Layout.
37
38
39
40
41
42
43
44
45
|
# File 'lib/uh/layout.rb', line 37
def initialize **options
@screens = Container.new
@widgets = []
@colors = COLORS
@history = History.new
@bar_status = options[:bar_status]
@colors = @colors.merge options[:colors] if options.key? :colors
end
|
Instance Attribute Details
#bar_status ⇒ Object
Returns the value of attribute bar_status.
35
36
37
|
# File 'lib/uh/layout.rb', line 35
def bar_status
@bar_status
end
|
#colors ⇒ Object
Returns the value of attribute colors.
35
36
37
|
# File 'lib/uh/layout.rb', line 35
def colors
@colors
end
|
#history ⇒ Object
Returns the value of attribute history.
35
36
37
|
# File 'lib/uh/layout.rb', line 35
def history
@history
end
|
#screens ⇒ Object
Returns the value of attribute screens.
35
36
37
|
# File 'lib/uh/layout.rb', line 35
def screens
@screens
end
|
Returns the value of attribute widgets.
35
36
37
|
# File 'lib/uh/layout.rb', line 35
def widgets
@widgets
end
|
Instance Method Details
#<<(client) ⇒ Object
Also known as:
push
72
73
74
75
76
77
78
79
80
|
# File 'lib/uh/layout.rb', line 72
def << client
current_view.current_column_or_create << client
current_column.current_client = client
current_column.arrange_clients
current_column.show_hide_clients
client.focus
update_widgets
self
end
|
#current_client ⇒ Object
55
56
57
|
# File 'lib/uh/layout.rb', line 55
def current_client
current_column and current_column.current_client
end
|
#expose(window) ⇒ Object
97
98
99
|
# File 'lib/uh/layout.rb', line 97
def expose window
update_widgets
end
|
#handle_client_column_set(direction, mover: client_mover_for_current_view) ⇒ Object
162
163
164
165
166
167
168
|
# File 'lib/uh/layout.rb', line 162
def handle_client_column_set direction, mover: client_mover_for_current_view
return unless current_client
mover.move_current direction
current_view.arrange_columns
current_view.each_column &:show_hide_clients
update_widgets
end
|
#handle_client_sel(direction) ⇒ Object
148
149
150
151
152
153
154
|
# File 'lib/uh/layout.rb', line 148
def handle_client_sel direction
return unless current_client
current_column.clients.sel direction
current_column.show_hide_clients
current_client.focus
update_widgets
end
|
#handle_client_swap(direction) ⇒ Object
156
157
158
159
160
|
# File 'lib/uh/layout.rb', line 156
def handle_client_swap direction
return unless current_client && current_column.clients.size >= 2
current_column.client_swap direction
update_widgets
end
|
#handle_column_mode_toggle ⇒ Object
141
142
143
144
145
146
|
# File 'lib/uh/layout.rb', line 141
def handle_column_mode_toggle
return unless current_column
current_column.mode_toggle
current_column.arrange_clients
current_column.show_hide_clients
end
|
#handle_column_sel(direction) ⇒ Object
134
135
136
137
138
139
|
# File 'lib/uh/layout.rb', line 134
def handle_column_sel direction
return unless current_view.columns.any?
current_view.columns.sel direction
current_client.focus
update_widgets
end
|
#handle_history_view_pred ⇒ Object
170
171
172
|
# File 'lib/uh/layout.rb', line 170
def handle_history_view_pred
handle_view_sel @history.last_view.id
end
|
#handle_screen_sel(direction) ⇒ Object
101
102
103
104
105
|
# File 'lib/uh/layout.rb', line 101
def handle_screen_sel direction
screens.sel direction
current_client.focus if current_client
update_widgets
end
|
#handle_screen_set(direction) ⇒ Object
107
108
109
110
111
112
|
# File 'lib/uh/layout.rb', line 107
def handle_screen_set direction
return unless current_client
remove client = current_client
screens.sel direction
push client
end
|
#handle_view_sel(view_id) ⇒ Object
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/uh/layout.rb', line 114
def handle_view_sel view_id
view_id = view_id.to_s
return unless current_view.id != view_id
@history.record_view current_view
current_view.hide
current_screen.views.current = find_view_or_create view_id
current_view.each_column &:show_hide_clients
current_client.focus if current_client
update_widgets
end
|
#handle_view_set(view_id) ⇒ Object
125
126
127
128
129
130
131
132
|
# File 'lib/uh/layout.rb', line 125
def handle_view_set view_id
return unless current_client && current_view.id != view_id
previous_view_id = current_view.id
remove client = current_client
handle_view_sel view_id
push client
handle_view_sel previous_view_id
end
|
#include?(client) ⇒ Boolean
59
60
61
|
# File 'lib/uh/layout.rb', line 59
def include? client
screens.any? { |screen| screen.include? client }
end
|
#register(display) ⇒ Object
47
48
49
|
# File 'lib/uh/layout.rb', line 47
def register display
Registrant.register self, display
end
|
#remove(client) ⇒ Object
83
84
85
86
87
88
89
90
|
# File 'lib/uh/layout.rb', line 83
def remove client
screen, view, column = find_client client
column.remove client
view.arrange_columns
column.show_hide_clients
current_client.focus if current_client
update_widgets
end
|
#suggest_geo ⇒ Object
68
69
70
|
# File 'lib/uh/layout.rb', line 68
def suggest_geo
(current_column or current_view).geo.dup
end
|
#to_s ⇒ Object
51
52
53
|
# File 'lib/uh/layout.rb', line 51
def to_s
Dumper.new(self).to_s
end
|
#update(client = nil) ⇒ Object
92
93
94
95
|
# File 'lib/uh/layout.rb', line 92
def update client = nil
return if client && client.hidden?
update_widgets
end
|
63
64
65
66
|
# File 'lib/uh/layout.rb', line 63
def update_widgets
@widgets.each &:update
@widgets.each &:redraw
end
|