scriptty 0.5.0-java → 0.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -0,0 +1,420 @@
1
+ [dump1]
2
+ size: (24, 80)
3
+ cursor_pos: (0, 29)
4
+ text: <<END
5
+ +--------------------------------------------------------------------------------+
6
+ |dwaynelitzenberger@debian:~$ |
7
+ | |
8
+ | |
9
+ | |
10
+ | |
11
+ | |
12
+ | |
13
+ | |
14
+ | |
15
+ | |
16
+ | |
17
+ | |
18
+ | |
19
+ | |
20
+ | |
21
+ | |
22
+ | |
23
+ | |
24
+ | |
25
+ | |
26
+ | |
27
+ | |
28
+ | |
29
+ | |
30
+ +--------------------------------------------------------------------------------+
31
+ END
32
+
33
+ [dump2]
34
+ size: (24, 80)
35
+ cursor_pos: (0, 0)
36
+ char_ignore: "?"
37
+ text: <<END
38
+ +--------------------------------------------------------------------------------+
39
+ | |
40
+ |~ |
41
+ |~ |
42
+ |~ |
43
+ |~ |
44
+ |~ |
45
+ |~ VIM - Vi IMproved |
46
+ |~ |
47
+ |~ version 7.1.314 |
48
+ |~ by Bram Moolenaar et al. |
49
+ |~ Vim is open source and freely distributable |
50
+ |~ |
51
+ |~ ??????????????????????????????????????????????? |
52
+ |~ ??????????????????????????????????????????????? |
53
+ |~ ??????????????????????????????????????????????? |
54
+ |~ ??????????????????????????????????????????????? |
55
+ |~ ??????????????????????????????????????????????? |
56
+ |~ ??????????????????????????????????????????????? |
57
+ |~ ??????????????????????????????????????????????? |
58
+ |~ ??????????????????????????????????????????????? |
59
+ |~ |
60
+ |~ |
61
+ |~ |
62
+ | 0,0-1 All |
63
+ +--------------------------------------------------------------------------------+
64
+
65
+ END
66
+
67
+ [dump3]
68
+ size: (24, 80)
69
+ cursor_pos: (0, 0)
70
+ char_ignore: "."
71
+ text: <<END
72
+ +--------------------------------------------------------------------------------+
73
+ |................................................................................|
74
+ |................................................................................|
75
+ |................................................................................|
76
+ |................................................................................|
77
+ |................................................................................|
78
+ |................................................................................|
79
+ |................................................................................|
80
+ |................................................................................|
81
+ |................................................................................|
82
+ |................................................................................|
83
+ |................................................................................|
84
+ |................................................................................|
85
+ |................................................................................|
86
+ |................................................................................|
87
+ |................................................................................|
88
+ |................................................................................|
89
+ |................................................................................|
90
+ |................................................................................|
91
+ |................................................................................|
92
+ |................................................................................|
93
+ |................................................................................|
94
+ |................................................................................|
95
+ |................................................................................|
96
+ |-- INSERT --....................................................................|
97
+ +--------------------------------------------------------------------------------+
98
+ END
99
+
100
+ [dump4]
101
+ size: (24, 80)
102
+ cursor_pos: (0, 11)
103
+ text: <<END
104
+ +--------------------------------------------------------------------------------+
105
+ |Hello world! |
106
+ |~ |
107
+ |~ |
108
+ |~ |
109
+ |~ |
110
+ |~ |
111
+ |~ |
112
+ |~ |
113
+ |~ |
114
+ |~ |
115
+ |~ |
116
+ |~ |
117
+ |~ |
118
+ |~ |
119
+ |~ |
120
+ |~ |
121
+ |~ |
122
+ |~ |
123
+ |~ |
124
+ |~ |
125
+ |~ |
126
+ |~ |
127
+ |~ |
128
+ | 1,12 All |
129
+ +--------------------------------------------------------------------------------+
130
+ END
131
+
132
+ [dump5]
133
+ size: (24, 80)
134
+ cursor_pos: (0, 11)
135
+ text: <<END
136
+ +--------------------------------------------------------------------------------+
137
+ |Hello world! |
138
+ |~ |
139
+ |~ |
140
+ |~ |
141
+ |~ |
142
+ |~ |
143
+ |~ |
144
+ |~ |
145
+ |~ |
146
+ |~ |
147
+ |~ |
148
+ |~ |
149
+ |~ |
150
+ |~ |
151
+ |~ |
152
+ |~ |
153
+ |~ |
154
+ |~ |
155
+ |~ |
156
+ |~ |
157
+ |~ |
158
+ |~ |
159
+ |~ |
160
+ |"foo.txt" [New] 1L, 13C written 1,12 All |
161
+ +--------------------------------------------------------------------------------+
162
+ END
163
+
164
+ [dump6]
165
+ size: (24, 80)
166
+ cursor_pos: (20, 51)
167
+ text: <<END
168
+ +--------------------------------------------------------------------------------+
169
+ |Score: 0 |
170
+ | |
171
+ | |
172
+ | |
173
+ | |
174
+ | |
175
+ | |
176
+ | |
177
+ | |
178
+ | |
179
+ | |
180
+ | |
181
+ | |
182
+ | |
183
+ | |
184
+ | |
185
+ | |
186
+ | |
187
+ | |
188
+ | |
189
+ | |
190
+ | |
191
+ | j - left k - rotate l - right <space> - drop p - pause q - quit |
192
+ | |
193
+ +--------------------------------------------------------------------------------+
194
+ END
195
+
196
+ [dump7]
197
+ size: (24, 80)
198
+ cursor_pos: (23, 0)
199
+ text: <<END
200
+ +--------------------------------------------------------------------------------+
201
+ | |
202
+ | |
203
+ | |
204
+ | |
205
+ | |
206
+ | |
207
+ | |
208
+ | |
209
+ | |
210
+ | |
211
+ | |
212
+ | |
213
+ | |
214
+ | |
215
+ | |
216
+ | |
217
+ | |
218
+ | |
219
+ | |
220
+ | |
221
+ |Your score: 0 points x level 2 = 0 |
222
+ | |
223
+ |Hit RETURN to see high scores, ^C to skip. |
224
+ | |
225
+ +--------------------------------------------------------------------------------+
226
+ END
227
+
228
+ [dump8]
229
+ size: (24, 80)
230
+ cursor_pos: (23, 29)
231
+ text: <<END
232
+ +--------------------------------------------------------------------------------+
233
+ | |
234
+ | |
235
+ | |
236
+ | |
237
+ | |
238
+ | |
239
+ | |
240
+ | |
241
+ | |
242
+ | |
243
+ | |
244
+ | |
245
+ | |
246
+ | |
247
+ | |
248
+ |Your score: 0 points x level 2 = 0 |
249
+ | |
250
+ |Hit RETURN to see high scores, ^C to skip. |
251
+ | |
252
+ | |
253
+ | Tetris High Scores |
254
+ |Rank Score Name (points/level) |
255
+ | 1* 256 dwaynelitzenberger ( 128 on 2) |
256
+ |dwaynelitzenberger@debian:~$ |
257
+ +--------------------------------------------------------------------------------+
258
+ END
259
+
260
+ [dump9]
261
+ size: (24, 80)
262
+ cursor_pos: (17, 40)
263
+ text: <<END
264
+ +--------------------------------------------------------------------------------+
265
+ | IPTraf |
266
+ | |
267
+ | |
268
+ | |
269
+ | lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk |
270
+ | x IPTraf x |
271
+ | x An IP Network Statistics Utility x |
272
+ | x Version 3.0.0 x |
273
+ | x x |
274
+ | x Written by Gerard Paul Java x |
275
+ | x Copyright (c) Gerard Paul Java 1997-2004 x |
276
+ | x x |
277
+ | x This program is open-source software released x |
278
+ | x under the terms of the GNU General Public x |
279
+ | x Public License Version 2 or any later version. x |
280
+ | x See the included LICENSE file for details. x |
281
+ | x x |
282
+ | x Press a key to continue x |
283
+ | mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj |
284
+ | |
285
+ | |
286
+ | |
287
+ | |
288
+ | Linux/i386 |
289
+ +--------------------------------------------------------------------------------+
290
+ END
291
+
292
+ [dump11]
293
+ size: (24, 80)
294
+ char_ignore: "?"
295
+ text: <<END
296
+ +--------------------------------------------------------------------------------+
297
+ | IPTraf |
298
+ | |
299
+ | |
300
+ | |
301
+ | |
302
+ | ??????????????????????????????????? |
303
+ | ? IP traffic monitor ? |
304
+ | ? General interface statistics ? |
305
+ | ? Detailed interface statistics ? |
306
+ | ? Statistical breakdowns... ? |
307
+ | ? LAN station monitor ? |
308
+ | ??????????????????????????????????? |
309
+ | ? Filters... ? |
310
+ | ??????????????????????????????????? |
311
+ | ? Configure... ? |
312
+ | ??????????????????????????????????? |
313
+ | ? Exit ? |
314
+ | ??????????????????????????????????? |
315
+ | |
316
+ | |
317
+ | |
318
+ | |
319
+ | Displays current IP traffic information |
320
+ | Up/Down-Move selector Enter-execute |
321
+ +--------------------------------------------------------------------------------+
322
+ END
323
+
324
+ [dump14]
325
+ size: (24, 80)
326
+ char_field: "#"
327
+ text: <<END
328
+ +--------------------------------------------------------------------------------+
329
+ | IPTraf |
330
+ | |
331
+ | |
332
+ | |
333
+ | |
334
+ | l Select Interface qqqqkqqqqqqqqqqqqqk |
335
+ | x #################### x x | ("iface0")
336
+ | x #################### xtatistics x | ("iface1")
337
+ | x #################### xstatistics x | ("iface2")
338
+ | x #################### xwns... x | ("iface3")
339
+ | x #################### x x | ("iface4")
340
+ | x #################### xqqqqqqqqqqqqqx | ("iface5")
341
+ | x #################### x x | ("iface6")
342
+ | x #################### xqqqqqqqqqqqqqx | ("iface7")
343
+ | x #################### x x | ("iface8")
344
+ | x #################### xqqqqqqqqqqqqqx | ("iface9")
345
+ | x #################### x x | ("iface10")
346
+ | x #################### xqqqqqqqqqqqqqj | ("iface11")
347
+ | mqqqqqqqqqqqqqqqqqqqqqqj |
348
+ | |
349
+ | |
350
+ | |
351
+ | |
352
+ | Up/Down-move pointer Enter-select X/Ctrl+X-close list |
353
+ +--------------------------------------------------------------------------------+
354
+ END
355
+
356
+ [dump15]
357
+ size: (24, 80)
358
+ char_ignore: "."
359
+ text: <<END
360
+ +--------------------------------------------------------------------------------+
361
+ | IPTraf |
362
+ |. TCP Connections (Source Host:Port) .......... Packets.... Bytes Flags Iface .|
363
+ |.................................... .......... ........... ..... .... ..... .|
364
+ |.................................... .......... ........... ..... .... ..... .|
365
+ |.................................... .......... ........... ..... .... ..... .|
366
+ |.................................... .......... ........... ..... .... ..... .|
367
+ |.................................... .......... ........... ..... .... ..... .|
368
+ |.................................... .......... ........... ..... .... ..... .|
369
+ |.................................... .......... ........... ..... .... ..... .|
370
+ |.................................... .......... ........... ..... .... ..... .|
371
+ |.................................... .......... ........... ..... .... ..... .|
372
+ |.................................... .......... ........... ..... .... ..... .|
373
+ |.................................... .......... ........... ..... .... ..... .|
374
+ |.................................... .......... ........... ..... .... ..... .|
375
+ |. TCP: ...... entries ................................................ Active ..|
376
+ |.qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq.|
377
+ |................................................................................|
378
+ |................................................................................|
379
+ |................................................................................|
380
+ |................................................................................|
381
+ |................................................................................|
382
+ |................................................................................|
383
+ | Pkts captured (all interfaces):.............x..................................|
384
+ | Up/Dn/PgUp/PgDn-scroll M-more TCP info W-chg actv win S-sort TCP X-exit |
385
+ +--------------------------------------------------------------------------------+
386
+ END
387
+
388
+ [dump16]
389
+ size: (24, 80)
390
+ cursor_pos: (23, 29)
391
+ char_field: "$"
392
+ text: <<END
393
+ +--------------------------------------------------------------------------------+
394
+ | |
395
+ | |
396
+ | |
397
+ | |
398
+ | |
399
+ | |
400
+ | |
401
+ | |
402
+ | |
403
+ | |
404
+ | |
405
+ | |
406
+ | |
407
+ | |
408
+ | |
409
+ | |
410
+ | |
411
+ | |
412
+ | |
413
+ | |
414
+ | |
415
+ | |
416
+ | |
417
+ |$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$| ("prompt")
418
+ +--------------------------------------------------------------------------------+
419
+ END
420
+
@@ -0,0 +1,62 @@
1
+ load_screens "demo-telnet-session-screens.txt"
2
+ init_term "xterm"
3
+ set_timeout 5.0
4
+ connect ['192.168.3.104', 23]
5
+ puts "TELNET negotiation..."
6
+ eval_script_file "telnet-nego.rb"
7
+
8
+ # Login
9
+ puts "Logging in..."
10
+ expect("login:")
11
+ send("dwaynelitzenberger\n")
12
+ expect("Password:")
13
+ send("secret\n")
14
+ expect(":~$") # prompt
15
+ send("export TERM=xterm\n") # XXX - we should negotiate the terminal type during TELNET negotiation
16
+ send("clear\n")
17
+
18
+ # Mess around in vim
19
+ puts "Messing around in vim..."
20
+ send("vim\n")
21
+ expect screen("dump2")
22
+ send("i")
23
+ expect screen("dump3")
24
+ send("Hello world!\e")
25
+ expect screen("dump4")
26
+ send(":q!\n")
27
+ expect(":~$") # prompt
28
+
29
+ # Start iptraf
30
+ puts "Messing around in iptraf..."
31
+ send("sudo iptraf\n")
32
+ expect screen("dump9")
33
+ send(" ")
34
+ expect screen("dump11")
35
+ send("m")
36
+ expect screen("dump14")
37
+ (0..11).each do |n|
38
+ if match["iface#{n}"].strip == "eth0"
39
+ send("\eOB"*n)
40
+ break
41
+ end
42
+ end
43
+ send "\r"
44
+
45
+ # Wait for iptraf main loop to start
46
+ expect screen("dump15")
47
+
48
+ # Exit iptraf
49
+ send("x")
50
+ expect screen("dump11")
51
+ send("x")
52
+
53
+ puts "Waiting for prompt..."
54
+ expect screen("dump16")
55
+ puts "Delaying..."
56
+ sleep 1
57
+ expect screen("dump16")
58
+ match['prompt'] =~ /:~\$/
59
+
60
+ puts "Exiting..."
61
+ send("exit\n")
62
+ exit
@@ -74,13 +74,13 @@ module ScripTTY
74
74
  private
75
75
 
76
76
  def handle_receive_bytes(bytes)
77
- bytes.split("").each do |byte|
78
- if byte =~ /\A[\x20-\x7e]\Z/m # printable
77
+ bytes.split(//n).each do |byte|
78
+ if byte =~ /\A[\x20-\x7e]\Z/mn # printable
79
79
  @prompt_input << byte
80
80
  elsif byte == "\b" or byte == "\x7f" # backspace or DEL
81
81
  @prompt_input = @prompt_input[0..-2] || ""
82
82
  elsif byte == "\r"
83
- handle_command_entered(@prompt_input)
83
+ handle_command_entered(@prompt_input.strip)
84
84
  @prompt_input = ""
85
85
  elsif byte == "\n"
86
86
  # ignore
@@ -45,9 +45,9 @@ module ScripTTY
45
45
  @password_buffer << byte
46
46
  if byte == "\r" or byte == "\n"
47
47
  @done = true
48
- @conn.write(IAC_DO_ECHO + "\r\n") if @password_buffer =~ /#{Regexp.escape(IAC_DO_ECHO)}|#{Regexp.escape(IAC_WILL_ECHO)}/ # echo on, send newline
48
+ @conn.write(IAC_DO_ECHO + "\r\n") if @password_buffer =~ /#{Regexp.escape(IAC_DO_ECHO)}|#{Regexp.escape(IAC_WILL_ECHO)}/n # echo on, send newline
49
49
  password = @password_buffer
50
- password.gsub!(/\377[\373-\376]./m, "") # Strip IAC DO/DONT/WILL/WONT option from password
50
+ password.gsub!(/\377[\373-\376]./mn, "") # Strip IAC DO/DONT/WILL/WONT option from password
51
51
  password.chomp! # strip trailing newline
52
52
  if @authenticate_proc.call(password)
53
53
  # success
@@ -20,6 +20,7 @@ require 'optparse'
20
20
  require 'scriptty/net/event_loop'
21
21
  require 'scriptty/util/transcript/writer'
22
22
  require 'scriptty/term'
23
+ require 'scriptty/screen_pattern'
23
24
  require 'logger'
24
25
  require 'stringio'
25
26
 
@@ -38,6 +39,7 @@ module ScripTTY
38
39
  @net = ScripTTY::Net::EventLoop.new
39
40
  @log_stringio = StringIO.new
40
41
  @log = Logger.new(@log_stringio)
42
+ @dump_counter = 1
41
43
  end
42
44
 
43
45
  def detach_console(console)
@@ -88,6 +90,8 @@ module ScripTTY
88
90
  comment = $1.strip
89
91
  @output_file.info("Comment: #{comment}") if @output_file
90
92
  log.info("Comment: #{comment}")
93
+ when /^d(ump)?$/i # Generate ScreenPattern based on a screen dump and write it to a file.
94
+ cmd_dump
91
95
  else
92
96
  log.warn("Unknown console command: #{cmd}")
93
97
  end
@@ -181,6 +185,9 @@ module ScripTTY
181
185
  opts.on("-o", "--output FILE", "Write transcript to FILE") do |optarg|
182
186
  options[:output] = optarg
183
187
  end
188
+ opts.on("-O", "--output-dir DIR", "Allow writing screenshots and other outputs to DIR (default: not allowed)") do |optarg|
189
+ options[:output_dir] = optarg
190
+ end
184
191
  opts.on("-a", "--[no-]append", "Append to output file instead of overwriting it") do |optarg|
185
192
  options[:append] = optarg
186
193
  end
@@ -205,6 +212,38 @@ module ScripTTY
205
212
  end
206
213
  [host, port]
207
214
  end
215
+
216
+ def cmd_dump
217
+ unless @options[:output_dir]
218
+ log.error("Cannot dump: --output-dir not enabled")
219
+ return
220
+ end
221
+ unless @term
222
+ log.error("Cannot dump: No terminal")
223
+ return
224
+ end
225
+
226
+ name = nil
227
+ filepath = nil
228
+ loop do
229
+ name = "dump#{@dump_counter}"
230
+ filepath = File.join(@options[:output_dir], "#{name}.txt")
231
+ break unless File.exist?(filepath)
232
+ @dump_counter += 1
233
+ end
234
+ pattern = ScreenPattern.from_term(@term, :name => name)
235
+ dumped_pattern = pattern.generate
236
+
237
+ File.open(filepath, "w") do |outfile|
238
+ outfile.puts(dumped_pattern)
239
+ outfile.puts("")
240
+ end
241
+ @dump_counter += 1
242
+
243
+ @output_file.info("Screen dumped", name, filepath) if @output_file
244
+ log.info("Screen dumped [#{name}] #{filepath}")
245
+ nil
246
+ end
208
247
  end
209
248
  end
210
249
  end
@@ -241,6 +241,23 @@ module ScripTTY
241
241
  @transcript_writer.close if @transcript_writer
242
242
  end
243
243
 
244
+ # Generate a ScreenPattern from the current terminal state, and optionally
245
+ # append it to the specified file.
246
+ #
247
+ # NOTE: This method is intended for script development only; it is not
248
+ # exported to the Evaluator.
249
+ def dump(filename=nil)
250
+ result = ScreenPattern.from_term(@term).generate
251
+ if filename
252
+ File.open(filename, "a") { |outfile|
253
+ outfile.puts(result); outfile.puts("")
254
+ }
255
+ nil
256
+ else
257
+ result
258
+ end
259
+ end
260
+
244
261
  private
245
262
 
246
263
  # Kick the watchdog timer
@@ -271,7 +288,9 @@ module ScripTTY
271
288
  # Enable timeout handling (if @timeout is set)
272
289
  def enable_timeout
273
290
  if @timeout
274
- @timeout_timer = @net.timer(@timeout, :daemon=>true) { raise ScripTTY::Exception::Timeout.new("Operation timed out") }
291
+ @timeout_timer = @net.timer(@timeout, :daemon=>true) {
292
+ raise ScripTTY::Exception::Timeout.new("Timed out waiting for #{@effective_patterns.map{|pattern_handle| pattern_handle.pattern}.inspect}")
293
+ }
275
294
  end
276
295
  nil
277
296
  end
@@ -36,6 +36,7 @@ module ScripTTY
36
36
  # matching text or fields there. :force_cursor may also be a
37
37
  # Regexp, in which case the regexp must match in order for the field
38
38
  # to be replaced. :force_fields takes precedence over :force_cursor.
39
+ # :force_cursor defaults to the regexp /\s/
39
40
  # [:ignore]
40
41
  # If specified, this is an array of [row, col0..col1] ranges.
41
42
  def generate(name, properties_and_options={})
@@ -50,7 +51,7 @@ module ScripTTY
50
51
 
51
52
  def initialize(name, properties={})
52
53
  properties = properties.dup
53
- @force_cursor = properties.delete(:force_cursor)
54
+ @force_cursor = properties.delete(:force_cursor) || /\s/
54
55
  @force_fields = properties.delete(:force_fields)
55
56
  @ignore = properties.delete(:ignore)
56
57
  load_spec(name, properties)
@@ -394,7 +394,10 @@ module ScripTTY
394
394
  add_field_to_screen(field_name, abs_pos(rel_range), lineno+i)
395
395
  end
396
396
  else
397
- v = abs_pos(v) if k == "cursor_pos"
397
+ if k == "cursor_pos"
398
+ ensure_position # "position", if set, must be set before this field is set
399
+ v = abs_pos(v)
400
+ end
398
401
  # Don't allow setting a screen property more than once to different values.
399
402
  old_value = @screen_properties[k]
400
403
  unless old_value.nil? or old_value == v
@@ -28,8 +28,8 @@ module ScripTTY
28
28
  retval
29
29
  end
30
30
 
31
- def from_term(term, name=nil)
32
- from_text(term.text, :name => name, :cursor_pos => term.cursor_pos)
31
+ def from_term(term, opts={})
32
+ from_text(term.text, {:cursor_pos => term.cursor_pos}.merge(opts))
33
33
  end
34
34
 
35
35
  def from_text(text, opts={})
@@ -94,8 +94,8 @@ module ScripTTY
94
94
  fields
95
95
  end
96
96
 
97
- def generate(name=nil)
98
- Generator.generate(name || "untitled", :cursor_pos => @cursor_pos, :matches => @matches, :fields => @field_ranges, :position => @position, :size => @size)
97
+ def generate
98
+ Generator.generate(@name, :cursor_pos => @cursor_pos, :matches => @matches, :fields => @field_ranges, :position => @position, :size => @size)
99
99
  end
100
100
  end
101
101
  end
@@ -356,11 +356,6 @@ module ScripTTY # :nodoc:
356
356
  nil
357
357
  end
358
358
 
359
- def error(message) # XXX - This sucks
360
- raise ArgumentError.new(message)
361
- #puts message # DEBUG FIXME
362
- end
363
-
364
359
  def t_reset(fsm)
365
360
  reset_to_initial_state!
366
361
  end
@@ -40,7 +40,9 @@
40
40
  'P' => t_delete_characters
41
41
  'S' => t_scroll_up
42
42
  'T' => t_scroll_down
43
+ 'X' => t_erase_characters
43
44
  'c' => t_send_device_attributes_primary # Primary DA
45
+ 'd' => t_line_position_absolute
44
46
  'g' => t_tab_clear
45
47
  'h' => t_set_mode
46
48
  'l' => t_reset_mode
@@ -52,6 +54,9 @@
52
54
  ']' => t_parse_osc => { # OSC - "Operating system command"
53
55
  '\007' => t_osc_set_text_params
54
56
  }
57
+ [()*+\-./] => { # Designate G0/G1/G2/G3 character set (ISO 2022)
58
+ * => t_designate_gx_charset
59
+ }
55
60
  }
56
61
  '\377' => {
57
62
  '\372' => t_parse_telnet_sb => {
@@ -288,6 +288,14 @@ module ScripTTY # :nodoc:
288
288
  true
289
289
  end
290
290
 
291
+ # Erase, starting with the character under the cursor and extending to the end of the line.
292
+ # Return true.
293
+ def erase_characters!(count=1)
294
+ @glyphs.replace_at(@cursor.row, @cursor.column, " "*([@width-@cursor.column, count].min))
295
+ @attrs.replace_at(@cursor.row, @cursor.column, " "*([@width-@cursor.column, count].min))
296
+ true
297
+ end
298
+
291
299
  # Erase, starting with the character under the cursor and extending to the end of the line.
292
300
  # Return true.
293
301
  def erase_to_end_of_line!
@@ -373,11 +381,6 @@ module ScripTTY # :nodoc:
373
381
  nil
374
382
  end
375
383
 
376
- def error(message) # XXX - This sucks
377
- raise ArgumentError.new(message)
378
- #puts message # DEBUG FIXME
379
- end
380
-
381
384
  def t_reset(fsm)
382
385
  reset_to_initial_state!
383
386
  end
@@ -466,7 +469,7 @@ module ScripTTY # :nodoc:
466
469
  @flags[:wraparound_mode] = true
467
470
  when 47 # Use alternate screen buffer
468
471
  else
469
- return error("unknown DEC private mode set (escape sequence: #{fsm.input_sequence.inspect})")
472
+ raise Util::FSM::NoMatch.new("unknown DEC private mode set", fsm.input_sequence, fsm.state)
470
473
  end
471
474
  end
472
475
  end
@@ -480,7 +483,7 @@ module ScripTTY # :nodoc:
480
483
  @flags[:wraparound_mode] = false
481
484
  when 47 # Use normal screen buffer
482
485
  else
483
- return error("unknown DEC private mode reset (escape sequence: #{fsm.input_sequence.inspect})")
486
+ raise Util::FSM::NoMatch.new("unknown DEC private mode reset", fsm.input_sequence, fsm.state)
484
487
  end
485
488
  end
486
489
  end
@@ -547,6 +550,15 @@ module ScripTTY # :nodoc:
547
550
  @cursor.pos = [row, column]
548
551
  end
549
552
 
553
+ # ESC [ Ps d
554
+ def t_line_position_absolute(fsm)
555
+ row = parse_csi_params(fsm.input_sequence)[0] || 0
556
+ row -= 1
557
+ row = 0 if row < 0
558
+ row = @height-1 if row >= @height
559
+ @cursor.row = row
560
+ end
561
+
550
562
  # Select graphic rendition
551
563
  # ESC [ Pm m
552
564
  def t_sgr(fsm)
@@ -588,6 +600,12 @@ module ScripTTY # :nodoc:
588
600
  delete_characters!(count)
589
601
  end
590
602
 
603
+ # ESC [ Ps X
604
+ def t_erase_characters(fsm)
605
+ count = parse_csi_params(fsm.input_sequence)[0] || 1
606
+ erase_characters!(count)
607
+ end
608
+
591
609
  # ESC [ Ps g
592
610
  def t_tab_clear(fsm) end # TODO
593
611
 
@@ -608,6 +626,8 @@ module ScripTTY # :nodoc:
608
626
 
609
627
  def t_osc_set_text_params(fsm) end # TODO - used for setting window title, etc.
610
628
 
629
+ def t_designate_gx_charset(fsm) end # TODO
630
+
611
631
  # ESC [ ... h
612
632
  def t_set_mode(fsm)
613
633
  parse_csi_params(fsm.input_sequence).each do |mode|
@@ -615,7 +635,7 @@ module ScripTTY # :nodoc:
615
635
  when 4 # Insert mode
616
636
  @flags[:insert_mode] = true
617
637
  else
618
- return error("unknown set mode (escape sequence: #{fsm.input_sequence.inspect})")
638
+ raise Util::FSM::NoMatch.new("unknown set mode", fsm.input_sequence, fsm.state)
619
639
  end
620
640
  end
621
641
  end
@@ -627,7 +647,7 @@ module ScripTTY # :nodoc:
627
647
  when 4 # Replace mode
628
648
  @flags[:insert_mode] = false
629
649
  else
630
- return error("unknown reset mode (escape sequence: #{fsm.input_sequence.inspect})")
650
+ raise Util::FSM::NoMatch.new("unknown reset mode", fsm.input_sequence, fsm.state)
631
651
  end
632
652
  end
633
653
  end
@@ -155,7 +155,7 @@ grammar ScripTTYFSMDefinition
155
155
  end
156
156
 
157
157
  rule str_single
158
- "\\" [enrt"'\\] {
158
+ "\\" [enrt"'\\\-] {
159
159
  def to_s
160
160
  case text_value[1..-1]
161
161
  when 'e'
@@ -172,6 +172,8 @@ grammar ScripTTYFSMDefinition
172
172
  "'"
173
173
  when "\\"
174
174
  "\\"
175
+ when "-"
176
+ "-"
175
177
  end
176
178
  end
177
179
  }
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 5
7
+ - 6
8
8
  - 0
9
- version: 0.5.0
9
+ version: 0.6.0
10
10
  platform: java
11
11
  authors:
12
12
  - Dwayne Litzenberger
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-23 00:00:00 -04:00
17
+ date: 2010-03-24 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -73,6 +73,8 @@ files:
73
73
  - examples/captures/xterm-overlong-line-prompt.bin
74
74
  - examples/captures/xterm-vim-session.bin
75
75
  - examples/demo-capture.rb
76
+ - examples/demo-telnet-session-screens.txt
77
+ - examples/demo-telnet-session.rb
76
78
  - examples/telnet-nego.rb
77
79
  - lib/scriptty/apps/capture_app.rb
78
80
  - lib/scriptty/apps/capture_app/console.rb
@@ -172,4 +174,5 @@ test_files:
172
174
  - test/util/transcript/reader_test.rb
173
175
  - test/util/transcript/writer_test.rb
174
176
  - examples/demo-capture.rb
177
+ - examples/demo-telnet-session.rb
175
178
  - examples/telnet-nego.rb