Class: GGLib::DebugConsole
Constant Summary
collapse
- @@allow =
false
Instance Attribute Summary
Attributes inherited from Widget
#buttonId, #defimage, #id, #name, #sleeping, #theme, #window, #zfocus
Attributes inherited from Tile
#id, #inclusive, #x1, #x2, #y1, #y2
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Widget
#blur, #button, #clicked?, #del, #event, #focus, #hasFocus?, #hasStickyFocus?, #intDraw, #onClick, #onDelete, #onDrag, #onInitialize, #onMouseOut, #onMouseOver, #onRightClick, #onRightDrag, #over?, #sleeping?, #stickFocus, #unstickFocus
Methods inherited from Tile
#centerOn, #del, deleteAllInstances, deleteById, #each, #eachBorder, getAllInstances, getById, #height, #iTile, #intersect?, intersect?, #isInTile?, #move, setAllInstances, #setCoordinates, #setTile, #width, #xTile
Constructor Details
#initialize(name = "unnamed", theme = Themes::blank) ⇒ DebugConsole
Returns a new instance of DebugConsole.
5
6
7
8
9
10
11
12
|
# File 'lib/ext/widgets.rb', line 5
def initialize(name="unnamed", theme=Themes::blank)
super(name, 0, 0, 640, 480, theme)
@vline=0
@oldtext=[]
@textm=false
clear
stickFocus
end
|
Class Method Details
.enabled ⇒ Object
162
163
164
|
# File 'lib/ext/widgets.rb', line 162
def DebugConsole.enabled
return @@allow
end
|
.enabled=(bool) ⇒ Object
159
160
161
|
# File 'lib/ext/widgets.rb', line 159
def DebugConsole.enabled=(bool)
@@allow=bool
end
|
Instance Method Details
#clear ⇒ Object
91
92
93
94
95
96
97
98
99
|
# File 'lib/ext/widgets.rb', line 91
def clear
@text=[]
@text[0]="CONSOLE"
@text[1]="#########"
@text[2]="<Press ` (backquote) or enter '/exit' to exit>"
@text[3]=">> "
@line=3
@vline=@oldtext.size-1
end
|
#draw ⇒ Object
165
166
167
168
169
170
171
|
# File 'lib/ext/widgets.rb', line 165
def draw
i=0
@text.each {|line|
@theme.font.default.draw(line, 10, 10+i*@theme.font.default.height, ZOrder::Text, 1.0, 1.0, 0xffffffff)
i+=1
}
end
|
#feedText(char) ⇒ Object
59
60
61
|
# File 'lib/ext/widgets.rb', line 59
def feedText(char)
@text[@line]+=char.to_s unless char=="`"
end
|
#justify(ln) ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/ext/widgets.rb', line 62
def justify(ln)
fin=""
size=ln.size
while ln.size>70
fin+=ln.slice(0,70)+"\fNL"
ln=ln.slice(70,ln.size)
end
fin+=ln.to_s
return fin
end
|
#onKeyPress(key) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/ext/widgets.rb', line 13
def onKeyPress(key)
if key==WidgetEvent::KeyDelete
thisline=@text[@line]
if @textm and thisline.length>0
@text[@line]=thisline.slice(0,thisline.length-1)
elsif thisline.length>3
@text[@line]=thisline.slice(0,thisline.length-1)
end
elsif key==WidgetEvent::KeySpace
@text[@line]+=" "
elsif key==WidgetEvent::KeyEscape
sleep
elsif key==WidgetEvent::KeyEnter
if @textm
if @text[@line]=="/endtext"
@textm=false
@line+=1
@text[@line]=">> "
else
@line+=1
@text[@line]=""
end
return
end
@oldtext.push @text[@line]
cmd=@text[@line].slice(3,@text[@line].length-3)
if cmd.slice(cmd.size-3,3)=="/nl"
@text[@line]=@text[@line].slice(0,@text[@line].length-3)
@text[@line+1]="|> "
@line+=1
else
runcmd(cmd)
end
@vline=@oldtext.size
elsif key==WidgetEvent::KeyUp
if @vline-1 >= 0 and
@vline-=1
@text[@line]=@oldtext[@vline]
end
elsif key==WidgetEvent::KeyDown
if @vline+1 < @oldtext.size and
@vline+=1
@text[@line]=@oldtext[@vline]
end
end
end
|
#onStickyBlur ⇒ Object
156
157
158
|
# File 'lib/ext/widgets.rb', line 156
def onStickyBlur
$window.setTextInput(nil)
end
|
#onStickyFocus ⇒ Object
153
154
155
|
# File 'lib/ext/widgets.rb', line 153
def onStickyFocus
$window.setTextInput(@textinput)
end
|
#respond(text) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/ext/widgets.rb', line 72
def respond(text)
text=text.to_s
@line+=1
if text==""
text="<no output>"
end
text=justify(text) if text.index("\fNL")==nil
text=text.split("\fNL")
mult=false
text.each { |ln|
if ln.slice(0,4)=="\fERR"
@text[@line]="!> "+ln.strip
else
@text[@line]="^> "+ln
end
@line+=1
@text[@line]=">> "
}
end
|
#sleep ⇒ Object
139
140
141
142
143
144
|
# File 'lib/ext/widgets.rb', line 139
def sleep
@text=[]
@line=0
@vline=0
super
end
|
#wakeUp ⇒ Object
145
146
147
148
149
150
151
152
|
# File 'lib/ext/widgets.rb', line 145
def wakeUp
@oldtext=[]
@vline=0
@text=false
clear
stickFocus
super
end
|