Class: Fox::FXIrb

Inherits:
FXText show all
Includes:
Responder, Singleton
Defined in:
lib/fox16/irb.rb

Instance Attribute Summary collapse

Attributes inherited from FXText

#activeBackColor, #anchorPos, #barColor, #barColumns, #cursorCol, #cursorColor, #cursorPos, #cursorRow, #delimiters, #editable, #font, #helpText, #hiliteBackColor, #hiliteMatchTime, #hiliteStyles, #hiliteTextColor, #length, #marginBottom, #marginLeft, #marginRight, #marginTop, #modified, #numberColor, #selBackColor, #selEndPos, #selStartPos, #selTextColor, #styled, #tabColumns, #text, #textColor, #textStyle, #tipText, #visibleColumns, #visibleRows, #wrapColumns

Attributes inherited from FXScrollArea

#contentHeight, #contentWidth, #horizontalScrollBar, #scrollStyle, #verticalScrollBar, #viewportHeight, #viewportWidth, #xPosition, #yPosition

Attributes inherited from FXWindow

#accelTable, #backColor, #defaultCursor, #dragCursor, #first, #focus, #key, #last, #layoutHints, #next, #numChildren, #owner, #parent, #prev, #root, #selector, #shell, #target, #x, #y

Attributes inherited from FXDrawable

#height, #visual, #width

Attributes inherited from FXId

#app, #userData, #xid

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Responder

#FXMAPFUNC, #FXMAPFUNCS, #FXMAPTYPE, #FXMAPTYPES, #addMapEntry, #assocIndex, #identifier, #messageMap

Methods inherited from FXText

#appendStyledText, #appendText, #changeStyle, #countCols, #countLines, #countRows, #dec, #editable?, #extendSelection, #extractStyle, #extractText, #findText, #getBottomLine, #getByte, #getChar, #getCharLen, #getPosAt, #getStyle, #getTopLine, #inc, #insertStyledText, #insertText, #killHighlight, #killSelection, #leftWord, #lineEnd, #lineStart, #makePositionVisible, #modified?, #nextLine, #nextRow, #numRows, #overstrike=, #overstrike?, #positionSelected?, #positionVisible?, #prevLine, #prevRow, #removeText, #replaceStyledText, #replaceText, #rightWord, #rowEnd, #rowStart, #selectAll, #setBottomLine, #setCenterLine, #setCursorCol, #setCursorPos, #setCursorRow, #setHighlight, #setSelection, #setStyledText, #setText, #setTopLine, #shiftText, #styled?, #to_s, #validPos, #wordEnd, #wordStart

Methods inherited from FXScrollArea

#horizontalScrollable?, #position, #scrollCorner, #setPosition, #verticalScrollable?

Methods inherited from FXComposite

#maxChildHeight, #maxChildWidth

Methods inherited from FXWindow

#acceptDrop, #acquireClipboard, #acquireSelection, #active?, #addHotKey, #after?, after?, before?, #before?, #beginDrag, #canFocus?, #changeFocus, #childAtIndex, #childOf?, #children, #clearDragRectangle, #clearShape, colorType, colorTypeName, commonAncestor, #composeContext, #composite?, #contains?, #containsChild?, #createComposeContext, #cursorPosition, #default?, #defaultHeight, #defaultWidth, deleteType, deleteTypeName, #destroy, #destroyComposeContext, #detach, #didAccept, #disable, #doesSaveUnder?, #dragging?, #dropDisable, #dropEnable, #dropEnabled?, #dropFinished, #dropTarget?, #each_child, #each_child_recursive, #enable, #enabled?, #endDrag, #forceRefresh, #getChildAt, #getDNDData, #getHeightForWidth, #getWidthForHeight, #grab, #grabKeyboard, #grabbed?, #grabbedKeyboard?, #handleDrag, #hasClipboard?, #hasFocus?, #hasSelection?, #height, #height=, #hide, imageType, #inFocusChain?, #indexOfChild, #initial?, #inquireDNDAction, #inquireDNDTypes, #killFocus, #layout, #linkAfter, #linkBefore, #lower, #move, octetType, octetTypeName, #offeredDNDType?, #position, #raiseWindow, #recalc, #releaseClipboard, #releaseSelection, #remHotKey, #removeChild, #repaint, #reparent, #resize, #scroll, #setCursorPosition, #setDNDData, #setDefault, #setDragRectangle, #setFocus, #setInitial, #setShape, #shell?, #show, #shown?, stringType, textType, textTypeName, #tr, #translateCoordinatesFrom, #translateCoordinatesTo, #underCursor?, #ungrab, #ungrabKeyboard, #update, urilistType, urilistTypeName, utf16Type, utf16TypeName, utf8Type, utf8TypeName, #visible=, #width, #width=

Methods included from Responder2

#connect

Methods inherited from FXDrawable

#resize

Methods inherited from FXId

#created?, #destroy, #detach, #runOnUiThread

Methods inherited from FXObject

#bind, #handle, #load, #save, subclasses

Constructor Details

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

Returns a new instance of FXIrb.



104
105
106
107
108
109
# 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

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



90
91
92
# File 'lib/fox16/irb.rb', line 90

def input
  @input
end

Class Method Details

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



92
93
94
95
96
97
98
99
100
101
102
# 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

Instance Method Details

#createObject



111
112
113
114
115
116
117
118
119
120
# 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) ⇒ Object



160
161
162
163
164
# File 'lib/fox16/irb.rb', line 160

def gets(prompt)
 @running = false
 @anchor = getLength
 return @input[0].gets
end

#newLineEnteredObject



129
130
131
132
133
134
135
136
# 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) ⇒ Object



122
123
124
125
126
127
# 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) ⇒ Object



138
139
140
141
142
# File 'lib/fox16/irb.rb', line 138

def processCommandLine(cmd)
 @redir.redir
 @running = true
 @input[1].puts cmd
end

#sendCommand(cmd) ⇒ Object



144
145
146
147
148
149
150
# 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) ⇒ Object



152
153
154
155
156
157
158
# 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