Class: XMP

Inherits:
Object show all
Defined in:
lib/irb/xmp.rb

Defined Under Namespace

Classes: StringInputMethod

Instance Method Summary collapse

Constructor Details

#initialize(bind = nil) ⇒ XMP

Returns a new instance of XMP.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/irb/xmp.rb', line 19

def initialize(bind = nil)
  IRB.init_config(nil)
  #IRB.parse_opts
  #IRB.load_modules

  IRB.conf[:PROMPT_MODE] = :XMP

  bind = IRB::Frame.top(1) unless bind
  ws = IRB::WorkSpace.new(bind)
  @io = StringInputMethod.new
  @irb = IRB::Irb.new(ws, @io)
  @irb.context.ignore_sigint = false

#    IRB.conf[:IRB_RC].call(@irb.context) if IRB.conf[:IRB_RC]
  IRB.conf[:MAIN_CONTEXT] = @irb.context
end

Instance Method Details

#puts(exps) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/irb/xmp.rb', line 36

def puts(exps)
  @io.puts exps

  if @irb.context.ignore_sigint
    begin
	trap_proc_b = trap("SIGINT"){@irb.signal_handle}
	catch(:IRB_EXIT) do
 @irb.eval_input
	end
    ensure
	trap("SIGINT", trap_proc_b)
    end
  else
    catch(:IRB_EXIT) do
	@irb.eval_input
    end
  end
end