screenxtv 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/screenxtv.rb +51 -29
- metadata +2 -2
data/lib/screenxtv.rb
CHANGED
@@ -140,7 +140,7 @@ conf_scan=[
|
|
140
140
|
match:/^[_a-zA-Z0-9]*$/,
|
141
141
|
errmsg:'You can use only alphabets, numbers and underscore.'
|
142
142
|
},
|
143
|
-
{key:"screen",value:"
|
143
|
+
{key:"screen",value:"screenxtv_public"},
|
144
144
|
{key:"screen_private",value:"screenxtv_private"},
|
145
145
|
{
|
146
146
|
key:"color",msg:"Terminal Color [BLACK/white/green/novel]",
|
@@ -253,7 +253,7 @@ File.write conf_file,conf.to_yaml
|
|
253
253
|
info={
|
254
254
|
'url'=>url,
|
255
255
|
'authorized'=>conf['urlhash']==url+"/"+(conf['auth_key']||''),
|
256
|
-
'private'=>argv[:private]
|
256
|
+
'private'=>argv[:private]
|
257
257
|
}
|
258
258
|
ENV['SCREENXTV_BROADCASTING']=info.to_json
|
259
259
|
show_info(info)
|
@@ -269,6 +269,7 @@ begin
|
|
269
269
|
}
|
270
270
|
rescue
|
271
271
|
end
|
272
|
+
screenrc.write "term xterm-256color\n"
|
272
273
|
screenrc.write "hardstatus alwayslastline 'http://#{HOST}/#{url}'\n"
|
273
274
|
screenrc.flush
|
274
275
|
rescue
|
@@ -286,37 +287,58 @@ Thread.new{
|
|
286
287
|
}
|
287
288
|
|
288
289
|
begin
|
289
|
-
master,slave=PTY.open
|
290
|
-
ENV['TERM']='vt100'
|
291
290
|
ENV['LANG']='en_US.UTF-8'
|
292
|
-
master.winsize=STDOUT.winsize
|
293
291
|
screen_name=argv[:private] ? conf['screen_private'] : conf['screen']
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
292
|
+
PTY::getpty "screen -x #{screen_name} -R" do |rr,ww|
|
293
|
+
winsize=->{
|
294
|
+
height,width=ww.winsize=rr.winsize=STDOUT.winsize
|
295
|
+
socket.send 'winch',{width:width,height:height}.to_json
|
296
|
+
}
|
297
|
+
winsize.call
|
298
|
+
resized=false
|
299
|
+
Thread.new{
|
300
|
+
loop do
|
301
|
+
sleep 0.1
|
302
|
+
if resized
|
303
|
+
resized=false
|
304
|
+
winsize.call
|
305
|
+
end
|
307
306
|
end
|
307
|
+
}
|
308
|
+
Signal.trap(:SIGWINCH){resized=true}
|
309
|
+
Signal.trap(:SIGCHLD){stop "broadcast end"}
|
310
|
+
Thread.new{
|
311
|
+
loop do
|
312
|
+
ww.write STDIN.getch
|
313
|
+
end
|
314
|
+
}
|
315
|
+
data=''
|
316
|
+
while(data+=rr.readpartial 1024)
|
317
|
+
ncount=code=0
|
318
|
+
[4,data.length].min.times do
|
319
|
+
c=data[data.length-ncount-1]
|
320
|
+
code=c.ord
|
321
|
+
ncount+=1
|
322
|
+
break if code&0x80==0 or code&0x40!=0
|
323
|
+
end
|
324
|
+
if code&0x80==0 or code&0x40==0
|
325
|
+
ncount=0
|
326
|
+
elsif code&0x20==0
|
327
|
+
ncount=0 if ncount==2
|
328
|
+
elsif code&0x10==0
|
329
|
+
ncount=0 if ncount==3
|
330
|
+
elsif code&0x08==0
|
331
|
+
ncount=0 if ncount==4
|
332
|
+
elsif code&0x04==0
|
333
|
+
ncount=0 if ncount==5
|
334
|
+
elsif code&0x02==0
|
335
|
+
ncount=0 if ncount==6
|
336
|
+
end
|
337
|
+
odata=data[0,data.size-ncount]
|
338
|
+
print odata
|
339
|
+
socket.send 'data',odata
|
340
|
+
data=data[data.size-ncount,ncount]
|
308
341
|
end
|
309
|
-
}
|
310
|
-
Signal.trap(:SIGWINCH){resized=true}
|
311
|
-
Signal.trap(:SIGCHLD){stop "broadcast end"}
|
312
|
-
Thread.new{
|
313
|
-
loop do
|
314
|
-
master.write STDIN.getch
|
315
|
-
end
|
316
|
-
}
|
317
|
-
while(data=master.readpartial 1024)
|
318
|
-
print data
|
319
|
-
socket.send 'data',data
|
320
342
|
end
|
321
343
|
rescue
|
322
344
|
end
|
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.10
|
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: 2013-02-
|
12
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|