screenxtv 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/screenxtv.rb +19 -13
- metadata +2 -2
data/lib/screenxtv.rb
CHANGED
@@ -5,6 +5,15 @@ require 'socket'
|
|
5
5
|
require 'json'
|
6
6
|
require 'yaml'
|
7
7
|
require 'optparse'
|
8
|
+
require 'readline'
|
9
|
+
|
10
|
+
Signal.trap(:INT){exit;}
|
11
|
+
|
12
|
+
def readline
|
13
|
+
s=Readline.readline("> ",true)
|
14
|
+
if !s then exit end
|
15
|
+
s.strip
|
16
|
+
end
|
8
17
|
|
9
18
|
def kvconnect(host,port)
|
10
19
|
socket=TCPSocket.open host, port
|
@@ -25,9 +34,7 @@ def kvconnect(host,port)
|
|
25
34
|
socket
|
26
35
|
end
|
27
36
|
|
28
|
-
|
29
|
-
@sttyoption=`stty -g`
|
30
|
-
end
|
37
|
+
@sttyoption=`stty -g`
|
31
38
|
def stop msg
|
32
39
|
height,width=STDOUT.winsize
|
33
40
|
print "\e[?1l\e[>\e[1;#{height}r\e[#{height};1H"
|
@@ -86,8 +93,8 @@ conf_scan.each do |item|
|
|
86
93
|
value=item[:value]
|
87
94
|
if !conf[key] then
|
88
95
|
if msg then
|
89
|
-
print item[:msg]+"\n
|
90
|
-
s=
|
96
|
+
print item[:msg]+"\n"
|
97
|
+
s=readline
|
91
98
|
if s=="" then s=value end
|
92
99
|
conf[key]=s
|
93
100
|
else
|
@@ -95,7 +102,7 @@ conf_scan.each do |item|
|
|
95
102
|
end
|
96
103
|
end
|
97
104
|
end
|
98
|
-
conf['url'].gsub! /[^a-
|
105
|
+
conf['url'].gsub! /[^a-zA-Z0-9_]/,""
|
99
106
|
conf['color'].downcase!
|
100
107
|
File.write conf_file,conf.to_yaml
|
101
108
|
|
@@ -115,17 +122,16 @@ loop do
|
|
115
122
|
conf['url'],conf['urlhash']=value.split("#")
|
116
123
|
break
|
117
124
|
end
|
118
|
-
print "Specified url '"+conf['url']+"' is alerady in use. Please set another url.\n
|
119
|
-
conf['url']=
|
125
|
+
print "Specified url '"+conf['url']+"' is alerady in use. Please set another url.\n"
|
126
|
+
conf['url']=readline
|
120
127
|
end
|
121
128
|
|
122
129
|
File.write conf_file,conf.to_yaml
|
123
130
|
|
124
131
|
print "Your url is http://screenx.tv/"+conf['url'].split("#")[0]+"\n\n";
|
125
|
-
print "Press Enter to start broadcasting\n
|
126
|
-
|
132
|
+
print "Press Enter to start broadcasting\n"
|
133
|
+
readline
|
127
134
|
|
128
|
-
start
|
129
135
|
Thread.new{
|
130
136
|
begin
|
131
137
|
loop do
|
@@ -148,8 +154,8 @@ begin
|
|
148
154
|
socket.send 'winch',{width:width,height:height}.to_json
|
149
155
|
}
|
150
156
|
winsize.call
|
151
|
-
Signal.trap(
|
152
|
-
Signal.trap(
|
157
|
+
Signal.trap(:SIGWINCH){Thread.new{winsize.call}}
|
158
|
+
Signal.trap(:SIGCHLD){stop "broadcast end"}
|
153
159
|
Thread.new{
|
154
160
|
loop do
|
155
161
|
master.write STDIN.getc
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: screenxtv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: io-console
|