Class: Aniview::View::StatusLine
- Inherits:
-
Object
- Object
- Aniview::View::StatusLine
show all
- Includes:
- Util, Observable
- Defined in:
- lib/aniview/view/statusline.rb
Instance Method Summary
collapse
Methods included from Util
decode_object, encode_object, error_message, format_duration, format_progress, format_size, parse_format, readline
Constructor Details
#initialize(pref, term, mpvbridge) ⇒ StatusLine
Returns a new instance of StatusLine.
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/aniview/view/statusline.rb', line 11
def initialize pref, term, mpvbridge
@term = term
@pref = pref
@mpvbridge = mpvbridge
@mpvbridge.add_observer(self, :draw)
@clr = Aniview::View::Color.public_send(@pref.get("clr")["main"])
reset_message
end
|
Instance Method Details
#draw ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/aniview/view/statusline.rb', line 46
def draw
if @message["text"] == nil
line = Util.parse_format @pref.get("format_status"), @mpvbridge.attributes, @term.cols
print_row line
else
line = Color.public_send(@message["color"]) + @message["text"]
print_row line
sleep Integer(@message["linger"])
reset_message
end
end
|
#message(msg, display_for: 1, color: "red") ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/aniview/view/statusline.rb', line 22
def message msg, display_for: 1, color: "red"
@message = {
"text" => msg,
"linger" => display_for,
"color" => color
}
changed
notify_observers
end
|
#print_row(line) ⇒ Object
42
43
44
|
# File 'lib/aniview/view/statusline.rb', line 42
def print_row line
print "\e[#{@term.rows - 1};1H" + @clr + line + "\e[K\nq\e[2K"
end
|
#reset_message ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/aniview/view/statusline.rb', line 32
def reset_message
@message = {
"text" => nil,
"linger" => 0,
"color" => "red"
}
changed
notify_observers
end
|