Class: Rascut::Plugin::Screen
- Inherits:
-
Base
- Object
- Base
- Rascut::Plugin::Screen
show all
- Defined in:
- lib/rascut/plugin/screen.rb
Constant Summary
collapse
- STATUS =
%q[%H %`%-w%{=b bw}%n %t%{-}%+w %=]
- SCREEN_CMD =
'screen'
- SCREEN_COLOR =
{
:black => 'dd',
:blue => 'bk',
:green => 'gk',
:red => 'rw',
}
Instance Method Summary
collapse
Methods inherited from Base
#config, #initialize
Instance Method Details
#clear ⇒ Object
43
44
45
|
# File 'lib/rascut/plugin/screen.rb', line 43
def clear
send_cmd('')
end
|
#error ⇒ Object
27
28
29
|
# File 'lib/rascut/plugin/screen.rb', line 27
def error
message 'E', :red
end
|
#message(msg, color = :black) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/rascut/plugin/screen.rb', line 35
def message(msg, color = :black)
if run_screen_session?
col = SCREEN_COLOR[color]
msg = %Q[ %{=b #{col}} #{msg} %{-}]
send_cmd(msg)
end
end
|
#run ⇒ Object
17
18
19
20
21
|
# File 'lib/rascut/plugin/screen.rb', line 17
def run
@command.wrapper.hooks[:compile_start] << method(:start)
@command.wrapper.hooks[:compile_error] << method(:error)
@command.wrapper.hooks[:compile_success] << method(:success)
end
|
#run_screen_session? ⇒ Boolean
47
48
49
50
|
# File 'lib/rascut/plugin/screen.rb', line 47
def run_screen_session?
str = `#{SCREEN_CMD} -ls`
str.match(/(\d+) Socket/) && ($1.to_i > 0)
end
|
#send_cmd(msg) ⇒ Object
52
53
54
55
|
# File 'lib/rascut/plugin/screen.rb', line 52
def send_cmd(msg)
cmd = %Q[#{SCREEN_CMD} -X eval 'hardstatus alwayslastline "#{(STATUS + msg).gsub('"', '\"')}"']
system cmd
end
|
#start ⇒ Object
23
24
25
|
# File 'lib/rascut/plugin/screen.rb', line 23
def start
message 'C'
end
|
#success ⇒ Object
31
32
33
|
# File 'lib/rascut/plugin/screen.rb', line 31
def success
message 'S', :blue
end
|