Skip to content

Commit 2a5e449

Browse files
committed
initial commit for local recording branch
1 parent 0ebd1c4 commit 2a5e449

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

lib/record.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<meta encoding=utf-8>
2+
<script src='http://screenx.tv/assets/screen.js'></script>
3+
<script>
4+
var data=[];
5+
onload=function(){
6+
var termdiv=document.getElementById('term')
7+
term=new Terminal(termdiv,info.w,info.h);
8+
var index=0;
9+
var time=0;
10+
function schedule(){
11+
if(data[index])setTimeout(show,1000*(data[index].time-time))
12+
}
13+
function show(){
14+
d=data[index++];
15+
if(d.data){
16+
for(var i=0;i<d.data.length;i++)term.write(d.data[i]);
17+
term.updateView();
18+
}else if(d.winch){
19+
term.resize(d.winch.w,d.winch.h);
20+
term.updateView();
21+
}
22+
time=d.time;
23+
schedule();
24+
}
25+
schedule();
26+
}
27+
</script>
28+
<div id='term' style='border:1px solid black'></div>

lib/record.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'json'
2+
class Recorder
3+
def initialize filename,info
4+
@time=Time.now
5+
@file=File.open filename,'w'
6+
@file.write File.read('./record.html')
7+
@file.write "<script>info=#{info.to_json};</script>\n"
8+
end
9+
def self.open(file,info)
10+
if block_given?
11+
rec=self.new file,info
12+
yield rec
13+
rec.close
14+
else
15+
self.new file,info
16+
end
17+
end
18+
def write hash
19+
hash[:time]=Time.now-@time
20+
@file.write "<script>data.push(#{hash.to_json})</script>\n"
21+
end
22+
def close
23+
@file.close
24+
end
25+
end

lib/screenxtv.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ def showVersion
1414
end
1515
def showHelp
1616
print <<EOS
17-
Usage:
17+
Usage:
1818
screenxtv [options]
1919
2020
Options:
2121
-u, [--url]      # Select a url (e.g. yasulab, tompng)
2222
-c, [--color]    # Select a color (options: black/white/green/novel)
2323
-t, [--title]    # Select a title (e.g. Joe's Codestream)
2424
-r, [--reset]    # Reset your default configuration (e.g. url, color, title)
25-
-f CONFIG_FILE   # Path to a preset configuration
25+
-f CONFIG_FILE   # Path to a preset configuration
2626
-p, [--private]  # Broadcast your terminal privately (anyone who has the link can access)
2727
-h, [--help]     # Show this help message and quit
2828
-v, [--version]  # Show ScreenX TV Ruby Client version number and quit
@@ -287,12 +287,17 @@ def auth(conf)
287287
}
288288

289289
begin
290+
require './record'
291+
h,w=STDIN.winsize
292+
@rec=Recorder.new "#{ENV['HOME']}/screenxtv_rec#{Time.now.strftime '%m%d%H%M'}.html",w:w,h:h
293+
290294
ENV['LANG']='en_US.UTF-8'
291295
screen_name=argv[:private] ? conf['screen_private'] : conf['screen']
292296
PTY::getpty "screen -x #{screen_name} -R" do |rr,ww|
293297
winsize=->{
294298
height,width=ww.winsize=rr.winsize=STDOUT.winsize
295299
socket.send 'winch',{width:width,height:height}.to_json
300+
@rec.write winch:{w:width,h:height}
296301
}
297302
winsize.call
298303
resized=false
@@ -337,6 +342,7 @@ def auth(conf)
337342
odata=data[0,data.size-ncount]
338343
print odata
339344
socket.send 'data',odata
345+
@rec.write data:odata.force_encoding('utf-8')
340346
data=data[data.size-ncount,ncount]
341347
end
342348
end

0 commit comments

Comments
 (0)