Class: Twterm::Tab::Preferences::NotificationBackend
- Inherits:
-
Base
- Object
- Base
- Twterm::Tab::Preferences::NotificationBackend
show all
- Includes:
- Publisher, Scrollable
- Defined in:
- lib/twterm/tab/preferences/notification_backend.rb
Instance Attribute Summary
Attributes inherited from Base
#window
Instance Method Summary
collapse
Methods included from Publisher
#publish
Methods included from Utils
check_type
Methods included from Scrollable
#scroller, #total_item_count
Methods inherited from Base
#==, #close, #find_or_fetch_list, #find_or_fetch_status, #find_or_fetch_user, #initialize, #render
Methods included from Subscriber
included, #subscribe, #unsubscribe
Instance Method Details
#drawable_item_count ⇒ Object
14
15
16
|
# File 'lib/twterm/tab/preferences/notification_backend.rb', line 14
def drawable_item_count
(window.maxy - 1) / 2
end
|
#image ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/twterm/tab/preferences/notification_backend.rb', line 18
def image
drawable_items.map.with_index do |item, i|
cursor = Image.cursor(1, scroller.current_index?(i))
checkbox = Image.checkbox(app.preferences[:notification_backend, item])
desc =
case item
when :inline
'Inline backend'
when :tmux
'Tmux backend'
when :terminal_notifier
'Terminal Notifier backend'
end
cursor - Image.whitespace - checkbox - Image.whitespace - Image.string(desc)
end
.intersperse(Image.blank_line)
.reduce(Image.empty) { |acc, x| acc | x }
end
|
#items ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'lib/twterm/tab/preferences/notification_backend.rb', line 38
def items
env = app.environment
[
:inline,
(:tmux if env.with_tmux?),
(:terminal_notifier if env.terminal_notifier_available?),
].compact
end
|
#respond_to_key(key) ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/twterm/tab/preferences/notification_backend.rb', line 48
def respond_to_key(key)
return true if scroller.respond_to_key(key)
case key
when 10
perform_selected_action
end
false
end
|
#title ⇒ Object
59
60
61
|
# File 'lib/twterm/tab/preferences/notification_backend.rb', line 59
def title
'Notification backend preferences'
end
|