class Fox::FXIrb
Attributes
input[R]
Public Class Methods
init(p, tgt, sel, opts)
click to toggle source
# File lib/fox16/irb.rb, line 92 def FXIrb.init(p, tgt, sel, opts) unless @__instance__ Thread.critical = true begin @__instance__ ||= new(p, tgt, sel, opts) ensure Thread.critical = false end end return @__instance__ end
new(p, tgt, sel, opts)
click to toggle source
Calls superclass method
Fox::FXText.new
# File lib/fox16/irb.rb, line 104 def initialize(p, tgt, sel, opts) FXMAPFUNC(SEL_KEYRELEASE, 0, "onKeyRelease") super setFont(FXFont.new(FXApp.instance, "-misc-fixed-medium-r-semicondensed-*-*-120-*-*-c-*-iso8859-1")) end
Public Instance Methods
create()
click to toggle source
Calls superclass method
Fox::FXText#create
# File lib/fox16/irb.rb, line 111 def create super setFocus # IRB initialization @redir = Redirect.new(self) @input = IO.pipe @irb = Thread.new { IRB.start_in_fxirb(@redir) } end
gets(prompt)
click to toggle source
# File lib/fox16/irb.rb, line 160 def gets(prompt) @running = false @anchor = getLength return @input[0].gets end
newLineEntered()
click to toggle source
# File lib/fox16/irb.rb, line 129 def newLineEntered if @running start = prevLine(getLength) @input[1].puts(extractText(start, getLength - start)) else processCommandLine(extractText(@anchor, getLength-@anchor)) end end
onKeyRelease(sender, sel, event)
click to toggle source
# File lib/fox16/irb.rb, line 122 def onKeyRelease(sender, sel, event) if [Fox::KEY_Return, Fox::KEY_KP_Enter].include?(event.code) newLineEntered end return 1 end
processCommandLine(cmd)
click to toggle source
# File lib/fox16/irb.rb, line 138 def processCommandLine(cmd) @redir.redir @running = true @input[1].puts cmd end
sendCommand(cmd)
click to toggle source
# File lib/fox16/irb.rb, line 144 def sendCommand(cmd) setCursorPos(getLength) makePositionVisible(getLength) unless isPosVisible(getLength) cmd += "\n" appendText(cmd) processCommandLine(cmd) end
write(obj)
click to toggle source
# File lib/fox16/irb.rb, line 152 def write(obj) str = obj.to_s appendText(str) setCursorPos(getLength) makePositionVisible(getLength) unless isPosVisible(getLength) return str.length end