fxri 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/fxri +4 -344
- data/fxri.gemspec +24 -24
- data/fxri.rb +351 -0
- data/lib/Empty_Text_Field_Handler.rb +63 -63
- data/lib/FoxDisplayer.rb +148 -148
- data/lib/FoxTextFormatter.rb +274 -274
- data/lib/Icon_Loader.rb +35 -35
- data/lib/Packet_Item.rb +178 -178
- data/lib/Packet_List.rb +192 -192
- data/lib/Recursive_Open_Struct.rb +233 -238
- data/lib/Search_Engine.rb +165 -165
- data/lib/fxirb.rb +401 -400
- metadata +13 -22
- data/bugs/fxri bug `concat' can't convert nil into Array (TypeError).eml +0 -50
- data/bugs/fxri with Ruby v1.8.5 via OneClickInstaller v1.8.5-21.eml +0 -167
- data/fxri-0.3.4.gem +0 -0
- data/lib/fxirb-0.2.1/CHANGELOG +0 -31
- data/lib/fxirb-0.2.1/fxirb.rb +0 -395
data/fxri
CHANGED
@@ -1,344 +1,4 @@
|
|
1
|
-
#!/bin/env ruby
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# Load FXRuby: try gem, then Fox 1.2, then Fox 1.0
|
8
|
-
begin
|
9
|
-
# try fxruby gem
|
10
|
-
require 'rubygems'
|
11
|
-
require_gem 'fxruby', '= 1.6'
|
12
|
-
require 'fox16'
|
13
|
-
require 'fox16/colors'
|
14
|
-
FOXVERSION="1.6"
|
15
|
-
include Fox
|
16
|
-
rescue LoadError
|
17
|
-
# no gem? try fox16 direct.
|
18
|
-
begin
|
19
|
-
require 'fox16'
|
20
|
-
require 'fox16/colors'
|
21
|
-
FOXVERSION="1.6"
|
22
|
-
include Fox
|
23
|
-
rescue LoadError
|
24
|
-
# no gem, no fox16? -> die
|
25
|
-
STDERR << "ERROR: You need FXRuby 1.6!"
|
26
|
-
exit
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
require 'thread'
|
31
|
-
#require 'optparse'
|
32
|
-
#require 'ostruct'
|
33
|
-
|
34
|
-
require 'lib/RiManager'
|
35
|
-
require 'lib/Recursive_Open_Struct'
|
36
|
-
require 'lib/Globals'
|
37
|
-
require 'lib/Packet_List'
|
38
|
-
require 'lib/Packet_Item'
|
39
|
-
require 'lib/Empty_Text_Field_Handler'
|
40
|
-
require 'lib/Icon_Loader'
|
41
|
-
require 'lib/Search_Engine'
|
42
|
-
require 'lib/FoxDisplayer'
|
43
|
-
require 'lib/FoxTextFormatter'
|
44
|
-
require 'lib/fxirb'
|
45
|
-
|
46
|
-
=begin
|
47
|
-
# Parse any options passed to fxri and store them in $options
|
48
|
-
$options = OpenStruct.new
|
49
|
-
$options.search_paths = []
|
50
|
-
|
51
|
-
opts = OptionParser.new { |opts|
|
52
|
-
opts.banner = "fxri - A graphical interface to the Ruby documentation.\nUsage: fxri [options]"
|
53
|
-
|
54
|
-
opts.separator ""
|
55
|
-
opts.separator "Specific options:"
|
56
|
-
|
57
|
-
opts.on( "-I", "--search-path [PATH]",
|
58
|
-
"Specify additional search paths to look for ri documentation",
|
59
|
-
"(may be used multiple times)") { |path|
|
60
|
-
$options.search_paths << path if File.directory? path
|
61
|
-
}
|
62
|
-
|
63
|
-
opts.separator ""
|
64
|
-
opts.separator "Common options:"
|
65
|
-
|
66
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
67
|
-
puts opts
|
68
|
-
exit
|
69
|
-
end
|
70
|
-
}
|
71
|
-
|
72
|
-
opts.parse!( ARGV )
|
73
|
-
=end
|
74
|
-
|
75
|
-
# Responsible for application initialization
|
76
|
-
class FXri < FXHorizontalFrame
|
77
|
-
|
78
|
-
# Initializes the XDCC-application.
|
79
|
-
def initialize(p, opts=0, x=0 ,y=0 ,w=0 ,h=0 , pl=DEFAULT_SPACING, pr=DEFAULT_SPACING, pt=DEFAULT_SPACING, pb=DEFAULT_SPACING, hs=DEFAULT_SPACING, vs=DEFAULT_SPACING)
|
80
|
-
super(p, opts, x ,y ,w ,h , pl, pr, pt, pb, hs, vs)
|
81
|
-
@isLoaded = false
|
82
|
-
set_default_font
|
83
|
-
# load icons
|
84
|
-
icon_loader = Icon_Loader.new(FXApp::instance)
|
85
|
-
icon_loader.cfg_to_icons($cfg.icons)
|
86
|
-
|
87
|
-
@gui = Recursive_Open_Struct.new
|
88
|
-
@gui.main = self
|
89
|
-
@data = Recursive_Open_Struct.new
|
90
|
-
@data.gui_mutex = Mutex.new
|
91
|
-
|
92
|
-
build(self)
|
93
|
-
FXToolTip.new(FXApp::instance, TOOLTIP_NORMAL)
|
94
|
-
|
95
|
-
@gui.close
|
96
|
-
create_data
|
97
|
-
|
98
|
-
@data.close
|
99
|
-
|
100
|
-
@search_engine = Search_Engine.new(@gui, @data)
|
101
|
-
|
102
|
-
# show init message
|
103
|
-
@data.displayer.display_information($cfg.text.help)
|
104
|
-
end
|
105
|
-
|
106
|
-
# Automatically called when the Fox application is created
|
107
|
-
def create
|
108
|
-
super
|
109
|
-
show
|
110
|
-
# load items
|
111
|
-
Thread.new do
|
112
|
-
# delayed loading, this speeds up freeride's startup.
|
113
|
-
sleep 1 if $cfg.delayed_loading
|
114
|
-
@gui.search_field.enabled = false
|
115
|
-
load_items
|
116
|
-
@isLoaded = true
|
117
|
-
@gui.search_field.enabled = true
|
118
|
-
@gui.search_field.text = ""
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def create_data
|
123
|
-
@data.displayer = FoxDisplayer.new(@gui.text)
|
124
|
-
@data.ri_manager = RiManager.new(@data.displayer)
|
125
|
-
@data.items = Array.new
|
126
|
-
@desc = nil
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
# Set the default font to the first font of $cfg.app.font.name that is available on this system.
|
131
|
-
def set_default_font
|
132
|
-
@font = load_font($cfg.app.font.name)
|
133
|
-
FXApp::instance.normalFont = @font if @font
|
134
|
-
end
|
135
|
-
|
136
|
-
# Returns the first font of the given array of font names that can be loaded, or nil.
|
137
|
-
def load_font(font_array)
|
138
|
-
# load default font
|
139
|
-
font = nil
|
140
|
-
font_array.detect do |name|
|
141
|
-
next if FXFont.listFonts(name).empty?
|
142
|
-
font = FXFont.new(FXApp::instance, name, $cfg.app.font.size)
|
143
|
-
end
|
144
|
-
font
|
145
|
-
end
|
146
|
-
|
147
|
-
# build gui
|
148
|
-
def build(parent)
|
149
|
-
FXSplitter.new(parent, SPLITTER_TRACKING|LAYOUT_FILL_X|LAYOUT_FILL_Y) do |base|
|
150
|
-
FXVerticalFrame.new(base, LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,$cfg.packet_list_width,0, 0,0,0,0,0,0) do |search_frame|
|
151
|
-
|
152
|
-
@gui.search_field = FXTextField.new(search_frame, 1, nil, 0, TEXTFIELD_NORMAL|LAYOUT_FILL_X|FRAME_SUNKEN)
|
153
|
-
@gui.search_field.connect(SEL_CHANGED) do |*args|
|
154
|
-
on_search
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
|
-
FXVerticalFrame.new(search_frame, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0,0,0) do |list_frame|
|
159
|
-
@gui.packet_list = Packet_List.new(@data, list_frame, nil, 0,
|
160
|
-
ICONLIST_DETAILED|
|
161
|
-
ICONLIST_COLUMNS|
|
162
|
-
#ICONLIST_MINI_ICONS|
|
163
|
-
HSCROLLER_NEVER|
|
164
|
-
VSCROLLER_ALWAYS|
|
165
|
-
ICONLIST_BROWSESELECT|
|
166
|
-
LAYOUT_FILL_X|
|
167
|
-
LAYOUT_FILL_Y) do |packet_list|
|
168
|
-
packet_list.add_header($cfg.text.method_name, $cfg.packet_list_width) { |x| make_sortable(x) }
|
169
|
-
end
|
170
|
-
|
171
|
-
@gui.packet_list.setHeaderSize(0, 1000)
|
172
|
-
end
|
173
|
-
|
174
|
-
@gui.search_label = FXLabel.new(search_frame, "", nil, LAYOUT_FILL_X|LABEL_NORMAL|JUSTIFY_RIGHT, 0,0,0,0, 0,0,0,0)
|
175
|
-
|
176
|
-
@gui.packet_list.connect(SEL_SELECTED) do |sender, sel, data|
|
177
|
-
item = sender.getItem(data).packet_item
|
178
|
-
show_info(item.data)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
split = FXSplitter.new(base, SPLITTER_TRACKING|LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_VERTICAL) if $cfg.launch_irb
|
183
|
-
right = FXHorizontalFrame.new(($cfg.launch_irb ? split : base), FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0,0,0)
|
184
|
-
@gui.text = FXText.new(right, nil, 0, TEXT_READONLY|TEXT_WORDWRAP|LAYOUT_FILL_X|LAYOUT_FILL_Y)
|
185
|
-
if $cfg.launch_irb
|
186
|
-
irb_frame = FXHorizontalFrame.new(split, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0,0,0)
|
187
|
-
@irb_frame = irb_frame
|
188
|
-
@gui.irb = FXIrb.init(irb_frame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_WORDWRAP|TEXT_SHOWACTIVE)
|
189
|
-
@gui.irb.setFont(@font) if @font
|
190
|
-
split.setSplit(0, $cfg.irb_height)
|
191
|
-
end
|
192
|
-
font = load_font($cfg.ri_font)
|
193
|
-
@gui.text.font = font if font
|
194
|
-
font.create
|
195
|
-
@gui.text_width = font.fontWidth
|
196
|
-
|
197
|
-
@gui.text.connect(SEL_CONFIGURE) do
|
198
|
-
on_show if @desc
|
199
|
-
end
|
200
|
-
|
201
|
-
# construct hilite styles
|
202
|
-
@gui.text.styled = true
|
203
|
-
@gui.text.hiliteStyles = create_styles
|
204
|
-
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def create_empty_style
|
209
|
-
hs = FXHiliteStyle.new
|
210
|
-
hs.activeBackColor = FXColor::White
|
211
|
-
hs.hiliteBackColor = FXColor::DarkBlue
|
212
|
-
hs.normalBackColor = FXColor::White
|
213
|
-
hs.normalForeColor = FXColor::Black
|
214
|
-
hs.selectBackColor = FXColor::DarkBlue
|
215
|
-
hs.selectForeColor = FXColor::White
|
216
|
-
hs.style = 0
|
217
|
-
hs
|
218
|
-
end
|
219
|
-
|
220
|
-
def create_styles
|
221
|
-
styles = Array.new
|
222
|
-
|
223
|
-
#normal
|
224
|
-
styles.push create_empty_style
|
225
|
-
|
226
|
-
# bold
|
227
|
-
hs = create_empty_style
|
228
|
-
hs.style = FXText::STYLE_BOLD
|
229
|
-
styles.push hs
|
230
|
-
|
231
|
-
# H1
|
232
|
-
hs = create_empty_style
|
233
|
-
hs.style = FXText::STYLE_UNDERLINE|FXText::STYLE_BOLD
|
234
|
-
hs.normalForeColor = FXColor::ForestGreen
|
235
|
-
styles.push hs
|
236
|
-
|
237
|
-
# H2
|
238
|
-
hs = create_empty_style
|
239
|
-
hs.style = FXText::STYLE_UNDERLINE
|
240
|
-
hs.normalForeColor = FXColor::ForestGreen
|
241
|
-
styles.push hs
|
242
|
-
|
243
|
-
# H3
|
244
|
-
hs = create_empty_style
|
245
|
-
hs.normalForeColor = FXColor::ForestGreen
|
246
|
-
styles.push hs
|
247
|
-
|
248
|
-
# teletype
|
249
|
-
hs = create_empty_style
|
250
|
-
hs.normalForeColor = FXColor::DarkCyan
|
251
|
-
styles.push hs
|
252
|
-
|
253
|
-
# code
|
254
|
-
hs = create_empty_style
|
255
|
-
hs.activeBackColor = FXColor::LightGrey
|
256
|
-
hs.normalForeColor = FXColor::DarkGreen
|
257
|
-
hs.style = FXText::STYLE_UNDERLINE|FXText::STYLE_BOLD
|
258
|
-
styles.push hs
|
259
|
-
|
260
|
-
# emphasis
|
261
|
-
hs = create_empty_style
|
262
|
-
hs.normalForeColor = FXColor::DarkCyan
|
263
|
-
styles.push hs
|
264
|
-
|
265
|
-
# class
|
266
|
-
hs = create_empty_style
|
267
|
-
hs.style = FXText::STYLE_BOLD
|
268
|
-
hs.normalForeColor = FXColor::Blue
|
269
|
-
styles.push hs
|
270
|
-
|
271
|
-
styles
|
272
|
-
end
|
273
|
-
|
274
|
-
|
275
|
-
# loads all ri items
|
276
|
-
def load_items
|
277
|
-
@gui.search_field.text = "loading..."
|
278
|
-
@data.ri_manager.all_names.each do |name|
|
279
|
-
icon = case name.type
|
280
|
-
when NameDescriptor::CLASS
|
281
|
-
$cfg.icons.klass
|
282
|
-
when NameDescriptor::INSTANCE_METHOD
|
283
|
-
$cfg.icons.instance_method
|
284
|
-
when NameDescriptor::CLASS_METHOD
|
285
|
-
$cfg.icons.class_method
|
286
|
-
end
|
287
|
-
item = Packet_Item.new(@gui.packet_list, icon, name.to_s)
|
288
|
-
@search_engine.update_search_status_text
|
289
|
-
item.data = name
|
290
|
-
@data.items.push item
|
291
|
-
end
|
292
|
-
@gui.search_field.text = "sorting..."
|
293
|
-
@gui.packet_list.on_cmd_header(0)
|
294
|
-
@gui.packet_list.update_header_width
|
295
|
-
recalc
|
296
|
-
end
|
297
|
-
|
298
|
-
def go_search(string)
|
299
|
-
@gui.search_field.text = string
|
300
|
-
on_search
|
301
|
-
end
|
302
|
-
|
303
|
-
def on_search
|
304
|
-
# do nothing if not fully loaded
|
305
|
-
return if !@isLoaded
|
306
|
-
@search_engine.on_search
|
307
|
-
end
|
308
|
-
|
309
|
-
def on_show
|
310
|
-
begin
|
311
|
-
w = @gui.text.width / @gui.text_width - 3
|
312
|
-
w = [w, $cfg.minimum_letters_per_line].max
|
313
|
-
@data.ri_manager.show(@desc, w)
|
314
|
-
rescue RiError => e
|
315
|
-
#puts desc
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
def show_info(desc)
|
320
|
-
@desc = desc
|
321
|
-
on_show
|
322
|
-
end
|
323
|
-
|
324
|
-
|
325
|
-
# x beeing the name of the ri doc, like "Set#delete"
|
326
|
-
# This creates a sortable representation. First class, then class methods, then instance.
|
327
|
-
def make_sortable(x)
|
328
|
-
[ x.downcase.gsub("::", " 1 ").gsub("#", " 2 "),
|
329
|
-
x.downcase,
|
330
|
-
x]
|
331
|
-
end
|
332
|
-
|
333
|
-
end
|
334
|
-
|
335
|
-
Thread.abort_on_exception= true
|
336
|
-
|
337
|
-
application = FXApp.new($cfg.app.name, $cfg.app.name)
|
338
|
-
application.threadsEnabled = true
|
339
|
-
#application.init(ARGV)
|
340
|
-
window = FXMainWindow.new(application, $cfg.app.name, nil, nil, DECOR_ALL, 0, 0, $cfg.app.width, $cfg.app.height)
|
341
|
-
FXri.new(window,FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0,0,0,0,0,0,0)
|
342
|
-
application.create
|
343
|
-
window.show(PLACEMENT_SCREEN)
|
344
|
-
application.run
|
1
|
+
#!/bin/env ruby
|
2
|
+
|
3
|
+
#Dir.chdir(File.dirname(File.expand_path(__FILE__)))
|
4
|
+
load 'fxri.rb'
|
data/fxri.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
#!/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
spec = Gem::Specification.new do |s|
|
5
|
-
s.name = "fxri"
|
6
|
-
s.add_dependency('fxruby',
|
7
|
-
s.version = "0.3.
|
8
|
-
s.date =
|
9
|
-
s.summary = "Graphical interface to the RI documentation, with search engine."
|
10
|
-
s.require_paths = ["lib"]
|
11
|
-
s.email = "markus.prinz@qsig.org"
|
12
|
-
s.homepage = "http://rubyforge.org/projects/fxri/"
|
13
|
-
s.rubyforge_project = "fxri"
|
14
|
-
s.description = "FxRi is an FXRuby interface to the RI documentation, with a search engine that allows for search-on-typing."
|
15
|
-
s.has_rdoc = false
|
16
|
-
s.files = Dir.glob("**/*")
|
17
|
-
s.bindir = "."
|
18
|
-
s.executables = ["fxri"]
|
19
|
-
end
|
20
|
-
|
21
|
-
if __FILE__ == $0
|
22
|
-
Gem.manage_gems
|
23
|
-
Gem::Builder.new(spec).build
|
24
|
-
end
|
1
|
+
#!/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = "fxri"
|
6
|
+
s.add_dependency('fxruby', '>= 1.2.0')
|
7
|
+
s.version = "0.3.5"
|
8
|
+
s.date = Time.now
|
9
|
+
s.summary = "Graphical interface to the RI documentation, with search engine."
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
s.email = "markus.prinz@qsig.org"
|
12
|
+
s.homepage = "http://rubyforge.org/projects/fxri/"
|
13
|
+
s.rubyforge_project = "fxri"
|
14
|
+
s.description = "FxRi is an FXRuby interface to the RI documentation, with a search engine that allows for search-on-typing."
|
15
|
+
s.has_rdoc = false
|
16
|
+
s.files = Dir.glob("**/*")
|
17
|
+
s.bindir = "."
|
18
|
+
s.executables = ["fxri"]
|
19
|
+
end
|
20
|
+
|
21
|
+
if __FILE__ == $0
|
22
|
+
Gem.manage_gems
|
23
|
+
Gem::Builder.new(spec).build
|
24
|
+
end
|
data/fxri.rb
ADDED
@@ -0,0 +1,351 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
|
3
|
+
# move to directory of this file, so that icons can load correctly.
|
4
|
+
Dir.chdir(File.dirname(File.expand_path(__FILE__)))
|
5
|
+
|
6
|
+
|
7
|
+
# Load FXRuby: try gem, then Fox 1.6 directly
|
8
|
+
begin
|
9
|
+
# try fxruby gem
|
10
|
+
require 'rubygems'
|
11
|
+
require_gem 'fxruby', '= 1.6'
|
12
|
+
require 'fox16'
|
13
|
+
require 'fox16/colors'
|
14
|
+
FOXVERSION="1.6"
|
15
|
+
include Fox
|
16
|
+
rescue LoadError
|
17
|
+
# no gem? try fox16 direct.
|
18
|
+
begin
|
19
|
+
require 'fox16'
|
20
|
+
require 'fox16/colors'
|
21
|
+
FOXVERSION="1.6"
|
22
|
+
include Fox
|
23
|
+
rescue
|
24
|
+
# Workaround for Windows OCI: Use fox12
|
25
|
+
begin
|
26
|
+
require_gem 'fxruby'
|
27
|
+
require 'fox12'
|
28
|
+
require 'fox12/colors'
|
29
|
+
FOXVERSION="1.2"
|
30
|
+
include Fox
|
31
|
+
rescue
|
32
|
+
# no gem, no fox16/12? -> die
|
33
|
+
STDERR << "ERROR: You need FXRuby >= 1.2!"
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'thread'
|
40
|
+
|
41
|
+
require 'lib/RiManager'
|
42
|
+
require 'lib/Recursive_Open_Struct'
|
43
|
+
require 'lib/Globals'
|
44
|
+
require 'lib/Packet_List'
|
45
|
+
require 'lib/Packet_Item'
|
46
|
+
require 'lib/Empty_Text_Field_Handler'
|
47
|
+
require 'lib/Icon_Loader'
|
48
|
+
require 'lib/Search_Engine'
|
49
|
+
require 'lib/FoxDisplayer'
|
50
|
+
require 'lib/FoxTextFormatter'
|
51
|
+
require 'lib/fxirb'
|
52
|
+
|
53
|
+
=begin
|
54
|
+
# Parse any options passed to fxri and store them in $options
|
55
|
+
$options = OpenStruct.new
|
56
|
+
$options.search_paths = []
|
57
|
+
|
58
|
+
opts = OptionParser.new { |opts|
|
59
|
+
opts.banner = "fxri - A graphical interface to the Ruby documentation.\nUsage: fxri [options]"
|
60
|
+
|
61
|
+
opts.separator ""
|
62
|
+
opts.separator "Specific options:"
|
63
|
+
|
64
|
+
opts.on( "-I", "--search-path [PATH]",
|
65
|
+
"Specify additional search paths to look for ri documentation",
|
66
|
+
"(may be used multiple times)") { |path|
|
67
|
+
$options.search_paths << path if File.directory? path
|
68
|
+
}
|
69
|
+
|
70
|
+
opts.separator ""
|
71
|
+
opts.separator "Common options:"
|
72
|
+
|
73
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
74
|
+
puts opts
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
}
|
78
|
+
|
79
|
+
opts.parse!( ARGV )
|
80
|
+
=end
|
81
|
+
|
82
|
+
# Responsible for application initialization
|
83
|
+
class FXri < FXHorizontalFrame
|
84
|
+
|
85
|
+
# Initializes the XDCC-application.
|
86
|
+
def initialize(p, opts=0, x=0 ,y=0 ,w=0 ,h=0 , pl=DEFAULT_SPACING, pr=DEFAULT_SPACING, pt=DEFAULT_SPACING, pb=DEFAULT_SPACING, hs=DEFAULT_SPACING, vs=DEFAULT_SPACING)
|
87
|
+
super(p, opts, x ,y ,w ,h , pl, pr, pt, pb, hs, vs)
|
88
|
+
@isLoaded = false
|
89
|
+
set_default_font
|
90
|
+
# load icons
|
91
|
+
icon_loader = Icon_Loader.new(FXApp::instance)
|
92
|
+
icon_loader.cfg_to_icons($cfg.icons)
|
93
|
+
|
94
|
+
@gui = Recursive_Open_Struct.new
|
95
|
+
@gui.main = self
|
96
|
+
@data = Recursive_Open_Struct.new
|
97
|
+
@data.gui_mutex = Mutex.new
|
98
|
+
|
99
|
+
build(self)
|
100
|
+
FXToolTip.new(FXApp::instance, TOOLTIP_NORMAL)
|
101
|
+
|
102
|
+
@gui.close
|
103
|
+
create_data
|
104
|
+
|
105
|
+
@data.close
|
106
|
+
|
107
|
+
@search_engine = Search_Engine.new(@gui, @data)
|
108
|
+
|
109
|
+
# show init message
|
110
|
+
@data.displayer.display_information($cfg.text.help)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Automatically called when the Fox application is created
|
114
|
+
def create
|
115
|
+
super
|
116
|
+
show
|
117
|
+
# load items
|
118
|
+
Thread.new do
|
119
|
+
# delayed loading, this speeds up freeride's startup.
|
120
|
+
sleep 1 if $cfg.delayed_loading
|
121
|
+
@gui.search_field.enabled = false
|
122
|
+
load_items
|
123
|
+
@isLoaded = true
|
124
|
+
@gui.search_field.enabled = true
|
125
|
+
@gui.search_field.text = ""
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def create_data
|
130
|
+
@data.displayer = FoxDisplayer.new(@gui.text)
|
131
|
+
@data.ri_manager = RiManager.new(@data.displayer)
|
132
|
+
@data.items = Array.new
|
133
|
+
@desc = nil
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
# Set the default font to the first font of $cfg.app.font.name that is available on this system.
|
138
|
+
def set_default_font
|
139
|
+
@font = load_font($cfg.app.font.name)
|
140
|
+
FXApp::instance.normalFont = @font if @font
|
141
|
+
end
|
142
|
+
|
143
|
+
# Returns the first font of the given array of font names that can be loaded, or nil.
|
144
|
+
def load_font(font_array)
|
145
|
+
# load default font
|
146
|
+
font = nil
|
147
|
+
font_array.detect do |name|
|
148
|
+
next if FXFont.listFonts(name).empty?
|
149
|
+
font = FXFont.new(FXApp::instance, name, $cfg.app.font.size)
|
150
|
+
end
|
151
|
+
font
|
152
|
+
end
|
153
|
+
|
154
|
+
# build gui
|
155
|
+
def build(parent)
|
156
|
+
FXSplitter.new(parent, SPLITTER_TRACKING|LAYOUT_FILL_X|LAYOUT_FILL_Y) do |base|
|
157
|
+
FXVerticalFrame.new(base, LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,$cfg.packet_list_width,0, 0,0,0,0,0,0) do |search_frame|
|
158
|
+
|
159
|
+
@gui.search_field = FXTextField.new(search_frame, 1, nil, 0, TEXTFIELD_NORMAL|LAYOUT_FILL_X|FRAME_SUNKEN)
|
160
|
+
@gui.search_field.connect(SEL_CHANGED) do |*args|
|
161
|
+
on_search
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
FXVerticalFrame.new(search_frame, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0,0,0) do |list_frame|
|
166
|
+
@gui.packet_list = Packet_List.new(@data, list_frame, nil, 0,
|
167
|
+
ICONLIST_DETAILED|
|
168
|
+
ICONLIST_COLUMNS|
|
169
|
+
#ICONLIST_MINI_ICONS|
|
170
|
+
HSCROLLER_NEVER|
|
171
|
+
VSCROLLER_ALWAYS|
|
172
|
+
ICONLIST_BROWSESELECT|
|
173
|
+
LAYOUT_FILL_X|
|
174
|
+
LAYOUT_FILL_Y) do |packet_list|
|
175
|
+
packet_list.add_header($cfg.text.method_name, $cfg.packet_list_width) { |x| make_sortable(x) }
|
176
|
+
end
|
177
|
+
|
178
|
+
@gui.packet_list.setHeaderSize(0, 1000)
|
179
|
+
end
|
180
|
+
|
181
|
+
@gui.search_label = FXLabel.new(search_frame, "", nil, LAYOUT_FILL_X|LABEL_NORMAL|JUSTIFY_RIGHT, 0,0,0,0, 0,0,0,0)
|
182
|
+
|
183
|
+
@gui.packet_list.connect(SEL_SELECTED) do |sender, sel, data|
|
184
|
+
item = sender.getItem(data).packet_item
|
185
|
+
show_info(item.data)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
split = FXSplitter.new(base, SPLITTER_TRACKING|LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_VERTICAL) if $cfg.launch_irb
|
190
|
+
right = FXHorizontalFrame.new(($cfg.launch_irb ? split : base), FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0,0,0)
|
191
|
+
@gui.text = FXText.new(right, nil, 0, TEXT_READONLY|TEXT_WORDWRAP|LAYOUT_FILL_X|LAYOUT_FILL_Y)
|
192
|
+
if $cfg.launch_irb
|
193
|
+
irb_frame = FXHorizontalFrame.new(split, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0,0,0)
|
194
|
+
@irb_frame = irb_frame
|
195
|
+
@gui.irb = FXIrb.init(irb_frame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_WORDWRAP|TEXT_SHOWACTIVE)
|
196
|
+
@gui.irb.setFont(@font) if @font
|
197
|
+
split.setSplit(0, $cfg.irb_height)
|
198
|
+
end
|
199
|
+
font = load_font($cfg.ri_font)
|
200
|
+
@gui.text.font = font if font
|
201
|
+
font.create
|
202
|
+
@gui.text_width = font.fontWidth
|
203
|
+
|
204
|
+
@gui.text.connect(SEL_CONFIGURE) do
|
205
|
+
on_show if @desc
|
206
|
+
end
|
207
|
+
|
208
|
+
# construct hilite styles
|
209
|
+
@gui.text.styled = true
|
210
|
+
@gui.text.hiliteStyles = create_styles
|
211
|
+
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def create_empty_style
|
216
|
+
hs = FXHiliteStyle.new
|
217
|
+
hs.activeBackColor = FXColor::White
|
218
|
+
hs.hiliteBackColor = FXColor::DarkBlue
|
219
|
+
hs.normalBackColor = FXColor::White
|
220
|
+
hs.normalForeColor = FXColor::Black
|
221
|
+
hs.selectBackColor = FXColor::DarkBlue
|
222
|
+
hs.selectForeColor = FXColor::White
|
223
|
+
hs.style = 0
|
224
|
+
hs
|
225
|
+
end
|
226
|
+
|
227
|
+
def create_styles
|
228
|
+
styles = Array.new
|
229
|
+
|
230
|
+
#normal
|
231
|
+
styles.push create_empty_style
|
232
|
+
|
233
|
+
# bold
|
234
|
+
hs = create_empty_style
|
235
|
+
hs.style = FXText::STYLE_BOLD
|
236
|
+
styles.push hs
|
237
|
+
|
238
|
+
# H1
|
239
|
+
hs = create_empty_style
|
240
|
+
hs.style = FXText::STYLE_UNDERLINE|FXText::STYLE_BOLD
|
241
|
+
hs.normalForeColor = FXColor::ForestGreen
|
242
|
+
styles.push hs
|
243
|
+
|
244
|
+
# H2
|
245
|
+
hs = create_empty_style
|
246
|
+
hs.style = FXText::STYLE_UNDERLINE
|
247
|
+
hs.normalForeColor = FXColor::ForestGreen
|
248
|
+
styles.push hs
|
249
|
+
|
250
|
+
# H3
|
251
|
+
hs = create_empty_style
|
252
|
+
hs.normalForeColor = FXColor::ForestGreen
|
253
|
+
styles.push hs
|
254
|
+
|
255
|
+
# teletype
|
256
|
+
hs = create_empty_style
|
257
|
+
hs.normalForeColor = FXColor::DarkCyan
|
258
|
+
styles.push hs
|
259
|
+
|
260
|
+
# code
|
261
|
+
hs = create_empty_style
|
262
|
+
hs.activeBackColor = FXColor::LightGrey
|
263
|
+
hs.normalForeColor = FXColor::DarkGreen
|
264
|
+
hs.style = FXText::STYLE_UNDERLINE|FXText::STYLE_BOLD
|
265
|
+
styles.push hs
|
266
|
+
|
267
|
+
# emphasis
|
268
|
+
hs = create_empty_style
|
269
|
+
hs.normalForeColor = FXColor::DarkCyan
|
270
|
+
styles.push hs
|
271
|
+
|
272
|
+
# class
|
273
|
+
hs = create_empty_style
|
274
|
+
hs.style = FXText::STYLE_BOLD
|
275
|
+
hs.normalForeColor = FXColor::Blue
|
276
|
+
styles.push hs
|
277
|
+
|
278
|
+
styles
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
# loads all ri items
|
283
|
+
def load_items
|
284
|
+
@gui.search_field.text = "loading..."
|
285
|
+
@data.ri_manager.all_names.each do |name|
|
286
|
+
icon = case name.type
|
287
|
+
when NameDescriptor::CLASS
|
288
|
+
$cfg.icons.klass
|
289
|
+
when NameDescriptor::INSTANCE_METHOD
|
290
|
+
$cfg.icons.instance_method
|
291
|
+
when NameDescriptor::CLASS_METHOD
|
292
|
+
$cfg.icons.class_method
|
293
|
+
end
|
294
|
+
item = Packet_Item.new(@gui.packet_list, icon, name.to_s)
|
295
|
+
@search_engine.update_search_status_text
|
296
|
+
item.data = name
|
297
|
+
@data.items.push item
|
298
|
+
end
|
299
|
+
@gui.search_field.text = "sorting..."
|
300
|
+
@gui.packet_list.on_cmd_header(0)
|
301
|
+
@gui.packet_list.update_header_width
|
302
|
+
recalc
|
303
|
+
end
|
304
|
+
|
305
|
+
def go_search(string)
|
306
|
+
@gui.search_field.text = string
|
307
|
+
on_search
|
308
|
+
end
|
309
|
+
|
310
|
+
def on_search
|
311
|
+
# do nothing if not fully loaded
|
312
|
+
return if !@isLoaded
|
313
|
+
@search_engine.on_search
|
314
|
+
end
|
315
|
+
|
316
|
+
def on_show
|
317
|
+
begin
|
318
|
+
w = @gui.text.width / @gui.text_width - 3
|
319
|
+
w = [w, $cfg.minimum_letters_per_line].max
|
320
|
+
@data.ri_manager.show(@desc, w)
|
321
|
+
rescue RiError => e
|
322
|
+
#puts desc
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
def show_info(desc)
|
327
|
+
@desc = desc
|
328
|
+
on_show
|
329
|
+
end
|
330
|
+
|
331
|
+
|
332
|
+
# x beeing the name of the ri doc, like "Set#delete"
|
333
|
+
# This creates a sortable representation. First class, then class methods, then instance.
|
334
|
+
def make_sortable(x)
|
335
|
+
[ x.downcase.gsub("::", " 1 ").gsub("#", " 2 "),
|
336
|
+
x.downcase,
|
337
|
+
x]
|
338
|
+
end
|
339
|
+
|
340
|
+
end
|
341
|
+
|
342
|
+
Thread.abort_on_exception= true
|
343
|
+
|
344
|
+
application = FXApp.new($cfg.app.name, $cfg.app.name)
|
345
|
+
application.threadsEnabled = true
|
346
|
+
#application.init(ARGV)
|
347
|
+
window = FXMainWindow.new(application, $cfg.app.name, nil, nil, DECOR_ALL, 0, 0, $cfg.app.width, $cfg.app.height)
|
348
|
+
FXri.new(window,FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0,0,0,0,0,0,0)
|
349
|
+
application.create
|
350
|
+
window.show(PLACEMENT_SCREEN)
|
351
|
+
application.run
|