screenxtv 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/screenxtv.rb +35 -9
- metadata +2 -2
data/lib/screenxtv.rb
CHANGED
@@ -6,6 +6,11 @@ require 'json'
|
|
6
6
|
require 'yaml'
|
7
7
|
require 'optparse'
|
8
8
|
require 'readline'
|
9
|
+
require 'tempfile'
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
9
14
|
|
10
15
|
if ENV['SCREENXTV_BROADCASTING']
|
11
16
|
print "cannot broadcast inside broadcasting screen\n"
|
@@ -40,12 +45,10 @@ def kvconnect(host,port)
|
|
40
45
|
socket
|
41
46
|
end
|
42
47
|
|
43
|
-
@sttyoption=`stty -g`
|
44
48
|
def stop msg
|
45
49
|
height,width=STDOUT.winsize
|
46
|
-
print "\e[?1l\e[>\e[1;#{height}r\e[#{height};1H"
|
47
|
-
|
48
|
-
print msg+"\n"
|
50
|
+
print "\e[?1l\e[>\e[1;#{height}r\e[#{height};1H\e[K"
|
51
|
+
print msg+"\r\n"
|
49
52
|
exit
|
50
53
|
end
|
51
54
|
|
@@ -55,7 +58,7 @@ conf_scan=[
|
|
55
58
|
key:"url",
|
56
59
|
msg:"Create a new URL. If given \"foo\", your URL will be \"http://screenx.tv/foo\".",
|
57
60
|
value:"",
|
58
|
-
match:/^[
|
61
|
+
match:/^[_a-zA-Z0-9]*$/,
|
59
62
|
errmsg:'You can use only alphabets, numbers and underscore.'
|
60
63
|
},
|
61
64
|
{key:"screen",value:"screenxtv"},
|
@@ -108,7 +111,7 @@ conf_scan.each do |item|
|
|
108
111
|
end
|
109
112
|
end
|
110
113
|
end
|
111
|
-
conf['url'].gsub! /[^
|
114
|
+
conf['url'].gsub! /[^_a-zA-Z0-9]/,""
|
112
115
|
conf['color'].downcase!
|
113
116
|
File.write conf_file,conf.to_yaml
|
114
117
|
|
@@ -138,6 +141,20 @@ print "Your url is http://screenx.tv/"+conf['url'].split("#")[0]+"\n\n";
|
|
138
141
|
print "Press Enter to start broadcasting\n"
|
139
142
|
readline
|
140
143
|
|
144
|
+
screenrc=Tempfile.new("screenrc");
|
145
|
+
begin
|
146
|
+
begin
|
147
|
+
File.open("#{ENV['HOME']}/.screenrc"){|file|
|
148
|
+
screenrc.write "#{file.read}\n"
|
149
|
+
}
|
150
|
+
rescue
|
151
|
+
end
|
152
|
+
screenrc.write "hardstatus alwayslastline 'http://screenx.tv/#{conf['url']}'\n"
|
153
|
+
screenrc.flush
|
154
|
+
rescue
|
155
|
+
end
|
156
|
+
p ENV['SCREENRC']=screenrc.path
|
157
|
+
|
141
158
|
Thread.new{
|
142
159
|
begin
|
143
160
|
loop do
|
@@ -149,7 +166,6 @@ Thread.new{
|
|
149
166
|
}
|
150
167
|
|
151
168
|
begin
|
152
|
-
system "stty raw"
|
153
169
|
master,slave=PTY.open
|
154
170
|
ENV['TERM']='vt100'
|
155
171
|
ENV['LANG']='en_US.UTF-8'
|
@@ -160,11 +176,21 @@ begin
|
|
160
176
|
socket.send 'winch',{width:width,height:height}.to_json
|
161
177
|
}
|
162
178
|
winsize.call
|
163
|
-
|
179
|
+
resized=false
|
180
|
+
Thread.new{
|
181
|
+
loop do
|
182
|
+
sleep 0.1
|
183
|
+
if resized
|
184
|
+
resized=false
|
185
|
+
winsize.call
|
186
|
+
end
|
187
|
+
end
|
188
|
+
}
|
189
|
+
Signal.trap(:SIGWINCH){resized=true}
|
164
190
|
Signal.trap(:SIGCHLD){stop "broadcast end"}
|
165
191
|
Thread.new{
|
166
192
|
loop do
|
167
|
-
master.write STDIN.
|
193
|
+
master.write STDIN.getch
|
168
194
|
end
|
169
195
|
}
|
170
196
|
while(data=master.readpartial 1024)
|
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.5
|
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-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: io-console
|