353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
# File 'lib/coderunner/interactive_methods.rb', line 353
def gets
Readline.input = @stdin
Readline.output = @stdout
prompt_end = Time.now.to_s[11...16]
begin
memsize = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{Process::pid}"`.chomp.split(/\s+/).map {|s| s.strip.to_i}[1].to_i/1000
prompt_end += " #{memsize}k"
rescue
end
prompt_end +=" (#{CodeRunner::SETUP_RUN_CLASSES.join(",")})"
if l = readline(@prompt.gsub(/timemarker/, prompt_end) , false)
HISTORY.push(l) if !l.empty? and (HISTORY.size ==0 or l != HISTORY[-1])
i = 0
loop do
break if HISTORY.size == 1
(HISTORY.delete_at(i); i-=1) if HISTORY[i] == l
i+=1
break if i >= HISTORY.size - 1
end
@line[@line_no += 1] = l + "\n"
else
@eof = true
l
end
end
|