Class: FXIrb

Inherits:
FXText
  • Object
show all
Includes:
Responder, Singleton
Defined in:
lib/fxirb.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p, tgt, sel, opts) ⇒ FXIrb

Returns a new instance of FXIrb.



173
174
175
176
177
178
179
180
181
182
183
# File 'lib/fxirb.rb', line 173

def initialize(p, tgt, sel, opts)
	FXMAPFUNC(SEL_KEYRELEASE, 0, "onKeyRelease")
	FXMAPFUNC(SEL_KEYPRESS, 0, "onKeyPress")
	FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,"onLeftBtnPress")
	FXMAPFUNC(SEL_MIDDLEBUTTONPRESS,0,"onMiddleBtnPress")
	FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,"onLeftBtnRelease")

	super
	setFont(FXFont.new(FXApp.instance, "lucida console", 9))
	@anchor = 0
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



158
159
160
# File 'lib/fxirb.rb', line 158

def input
  @input
end

#multilineObject

Returns the value of attribute multiline.



159
160
161
# File 'lib/fxirb.rb', line 159

def multiline
  @multiline
end

Class Method Details

.init(p, tgt, sel, opts) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
# File 'lib/fxirb.rb', line 161

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

Instance Method Details

#createObject



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/fxirb.rb', line 185

def create
	super
	setFocus
	# IRB initialization
	@inputAdded = 0
	@input = IO.pipe
	$DEFAULT_OUTPUT = self

	@im = FXIRBInputMethod.new
	@irb = Thread.new {
		IRB.start_in_fxirb(@im)
		self.crash
	}

	@multiline = false

	@exit_proc = lambda {exit}
end

#get_lineObject



439
440
441
442
443
444
445
446
447
448
449
# File 'lib/fxirb.rb', line 439

def get_line
	@anchor = getLength
	if @inputAdded == 0
		Thread.stop
	end
	@inputAdded -= 1
	retval = @input[0].gets
	# don't print every prompt for multiline input
	@im.print_prompt = (@inputAdded == 0) 
	return retval
end

#on_exit(&block) ⇒ Object



204
205
206
# File 'lib/fxirb.rb', line 204

def on_exit(&block)
	@exit_proc = block
end

#send_command(cmd) ⇒ Object



423
424
425
426
427
428
429
# File 'lib/fxirb.rb', line 423

def send_command(cmd)
	setCursorPos(getLength)
	makePositionVisible(getLength) unless isPosVisible(getLength)
	cmd += "\n"
	appendText(cmd)
	process_commandline(cmd)
end

#write(obj) ⇒ Object



431
432
433
434
435
436
437
# File 'lib/fxirb.rb', line 431

def write(obj)
	str = obj.to_s
	appendText(str)
	setCursorPos(getLength)
	makePositionVisible(getLength) unless isPosVisible(getLength)
	return str.length
end