fxri 0.3.2 → 0.3.3
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 +260 -258
- data/fxri.gemspec +16 -16
- data/fxri.kpf +66 -0
- data/lib/Empty_Text_Field_Handler.rb +57 -57
- data/lib/FoxDisplayer.rb +146 -146
- data/lib/FoxTextFormatter.rb +270 -260
- data/lib/Globals.rb +3 -2
- data/lib/Icon_Loader.rb +30 -30
- data/lib/Packet_Item.rb +167 -167
- data/lib/Packet_List.rb +187 -187
- data/lib/Recursive_Open_Struct.rb +205 -205
- data/lib/RiManager.rb +133 -133
- data/lib/Search_Engine.rb +159 -159
- data/lib/fxirb.rb +321 -332
- metadata +51 -42
data/fxri
CHANGED
@@ -1,34 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
+
|
4
6
|
|
5
7
|
# Load FXRuby: try gem, then Fox 1.2, then Fox 1.0
|
6
8
|
begin
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
# try fxruby gem
|
10
|
+
require 'rubygems'
|
11
|
+
require_gem 'fxruby', '= 1.2.0'
|
12
|
+
require 'fox12'
|
13
|
+
require 'fox12/colors'
|
14
|
+
FOXVERSION="1.2"
|
15
|
+
include Fox
|
14
16
|
rescue LoadError
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
# no gem? try fox12 direct.
|
18
|
+
begin
|
19
|
+
require "fox12"
|
20
|
+
require "fox12/colors"
|
21
|
+
FOXVERSION="1.2"
|
22
|
+
include Fox
|
23
|
+
rescue LoadError
|
24
|
+
# no gem, no fox12? try fox 1.0
|
25
|
+
require "fox"
|
26
|
+
require "fox/colors"
|
27
|
+
# grep for FOXVERSION to find all code that depends on this
|
28
|
+
FOXVERSION="1.0"
|
29
|
+
include Fox
|
30
|
+
FXMenuBar = FXMenubar
|
31
|
+
FXToolTip = FXTooltip
|
32
|
+
FXStatusBar = FXStatusbar
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
require 'thread'
|
@@ -47,40 +49,40 @@ require 'lib/fxirb'
|
|
47
49
|
|
48
50
|
# Responsible for application initialization
|
49
51
|
class FXri < FXHorizontalFrame
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
|
53
|
+
# Initializes the XDCC-application.
|
54
|
+
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)
|
55
|
+
super(p, opts, x ,y ,w ,h , pl, pr, pt, pb, hs, vs)
|
54
56
|
@isLoaded = false
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
57
|
+
set_default_font
|
58
|
+
# load icons
|
59
|
+
icon_loader = Icon_Loader.new(FXApp::instance)
|
60
|
+
icon_loader.cfg_to_icons($cfg.icons)
|
61
|
+
|
62
|
+
@gui = Recursive_Open_Struct.new
|
63
|
+
@gui.main = self
|
64
|
+
@data = Recursive_Open_Struct.new
|
65
|
+
@data.gui_mutex = Mutex.new
|
66
|
+
|
67
|
+
build(self)
|
68
|
+
FXToolTip.new(FXApp::instance, TOOLTIP_NORMAL)
|
69
|
+
|
70
|
+
@gui.close
|
71
|
+
create_data
|
72
|
+
|
73
|
+
@data.close
|
74
|
+
|
75
|
+
@search_engine = Search_Engine.new(@gui, @data)
|
76
|
+
|
77
|
+
# show init message
|
78
|
+
@data.displayer.display_information($cfg.text.help)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Automatically called when the Fox application is created
|
82
|
+
def create
|
83
|
+
super
|
84
|
+
show
|
85
|
+
# load items
|
84
86
|
Thread.new do
|
85
87
|
# delayed loading, this speeds up freeride's startup.
|
86
88
|
sleep 1 if $cfg.delayed_loading
|
@@ -91,162 +93,162 @@ class FXri < FXHorizontalFrame
|
|
91
93
|
@gui.search_field.text = ""
|
92
94
|
end
|
93
95
|
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
96
|
+
|
97
|
+
def create_data
|
98
|
+
@data.displayer = FoxDisplayer.new(@gui.text)
|
99
|
+
@data.ri_manager = RiManager.new(@data.displayer)
|
100
|
+
@data.items = Array.new
|
101
|
+
@desc = nil
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# Set the default font to the first font of $cfg.app.font.name that is available on this system.
|
106
|
+
def set_default_font
|
107
|
+
@font = load_font($cfg.app.font.name)
|
108
|
+
FXApp::instance.normalFont = @font if @font
|
109
|
+
end
|
110
|
+
|
111
|
+
# Returns the first font of the given array of font names that can be loaded, or nil.
|
112
|
+
def load_font(font_array)
|
113
|
+
# load default font
|
114
|
+
font = nil
|
115
|
+
font_array.detect do |name|
|
116
|
+
next if FXFont.listFonts(name).empty?
|
117
|
+
font = FXFont.new(FXApp::instance, name, $cfg.app.font.size)
|
118
|
+
end
|
119
|
+
font
|
120
|
+
end
|
121
|
+
|
122
|
+
# build gui
|
123
|
+
def build(parent)
|
124
|
+
FXSplitter.new(parent, SPLITTER_TRACKING|LAYOUT_FILL_X|LAYOUT_FILL_Y) do |base|
|
125
|
+
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|
|
126
|
+
|
127
|
+
@gui.search_field = FXTextField.new(search_frame, 1, nil, 0, TEXTFIELD_NORMAL|LAYOUT_FILL_X|FRAME_SUNKEN)
|
128
|
+
@gui.search_field.connect(SEL_CHANGED) do |*args|
|
129
|
+
on_search
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
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|
|
134
|
+
@gui.packet_list = Packet_List.new(@data, list_frame, nil, 0,
|
135
|
+
ICONLIST_DETAILED|
|
136
|
+
ICONLIST_COLUMNS|
|
137
|
+
#ICONLIST_MINI_ICONS|
|
138
|
+
HSCROLLER_NEVER|
|
139
|
+
VSCROLLER_ALWAYS|
|
140
|
+
ICONLIST_BROWSESELECT|
|
141
|
+
LAYOUT_FILL_X|
|
142
|
+
LAYOUT_FILL_Y) do |packet_list|
|
143
|
+
packet_list.add_header($cfg.text.method_name, $cfg.packet_list_width) { |x| make_sortable(x) }
|
144
|
+
end
|
145
|
+
|
146
|
+
@gui.packet_list.setHeaderSize(0, 1000)
|
147
|
+
end
|
148
|
+
|
149
|
+
@gui.search_label = FXLabel.new(search_frame, "", nil, LAYOUT_FILL_X|LABEL_NORMAL|JUSTIFY_RIGHT, 0,0,0,0, 0,0,0,0)
|
150
|
+
|
151
|
+
@gui.packet_list.connect(SEL_SELECTED) do |sender, sel, data|
|
152
|
+
item = sender.getItem(data).packet_item
|
153
|
+
show_info(item.data)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
split = FXSplitter.new(base, SPLITTER_TRACKING|LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_VERTICAL) if $cfg.launch_irb
|
156
158
|
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)
|
157
159
|
@gui.text = FXText.new(right, nil, 0, TEXT_READONLY|TEXT_WORDWRAP|LAYOUT_FILL_X|LAYOUT_FILL_Y)
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
160
|
+
if $cfg.launch_irb
|
161
|
+
irb_frame = FXHorizontalFrame.new(split, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0,0,0)
|
162
|
+
@irb_frame = irb_frame
|
163
|
+
@gui.irb = FXIrb.init(irb_frame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_WORDWRAP|TEXT_SHOWACTIVE)
|
164
|
+
@gui.irb.setFont(@font) if @font
|
165
|
+
split.setSplit(0, $cfg.irb_height)
|
166
|
+
end
|
167
|
+
font = load_font($cfg.ri_font)
|
168
|
+
@gui.text.font = font if font
|
169
|
+
font.create
|
170
|
+
@gui.text_width = font.fontWidth
|
171
|
+
|
172
|
+
@gui.text.connect(SEL_CONFIGURE) do
|
173
|
+
on_show if @desc
|
174
|
+
end
|
175
|
+
|
176
|
+
# construct hilite styles
|
177
|
+
@gui.text.styled = true
|
178
|
+
@gui.text.hiliteStyles = create_styles
|
179
|
+
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def create_empty_style
|
184
|
+
hs = FXHiliteStyle.new
|
185
|
+
hs.activeBackColor = FXColor::White
|
186
|
+
hs.hiliteBackColor = FXColor::DarkBlue
|
187
|
+
hs.normalBackColor = FXColor::White
|
188
|
+
hs.normalForeColor = FXColor::Black
|
189
|
+
hs.selectBackColor = FXColor::DarkBlue
|
190
|
+
hs.selectForeColor = FXColor::White
|
191
|
+
hs.style = 0
|
192
|
+
hs
|
193
|
+
end
|
194
|
+
|
195
|
+
def create_styles
|
196
|
+
styles = Array.new
|
197
|
+
|
198
|
+
#normal
|
199
|
+
styles.push create_empty_style
|
200
|
+
|
201
|
+
# bold
|
202
|
+
hs = create_empty_style
|
203
|
+
hs.style = FXText::STYLE_BOLD
|
204
|
+
styles.push hs
|
205
|
+
|
206
|
+
# H1
|
207
|
+
hs = create_empty_style
|
208
|
+
hs.style = FXText::STYLE_UNDERLINE|FXText::STYLE_BOLD
|
209
|
+
hs.normalForeColor = FXColor::ForestGreen
|
210
|
+
styles.push hs
|
211
|
+
|
212
|
+
# H2
|
213
|
+
hs = create_empty_style
|
214
|
+
hs.style = FXText::STYLE_UNDERLINE
|
215
|
+
hs.normalForeColor = FXColor::ForestGreen
|
216
|
+
styles.push hs
|
217
|
+
|
218
|
+
# H3
|
219
|
+
hs = create_empty_style
|
220
|
+
hs.normalForeColor = FXColor::ForestGreen
|
221
|
+
styles.push hs
|
222
|
+
|
223
|
+
# teletype
|
224
|
+
hs = create_empty_style
|
225
|
+
hs.normalForeColor = FXColor::DarkCyan
|
226
|
+
styles.push hs
|
227
|
+
|
228
|
+
# code
|
229
|
+
hs = create_empty_style
|
230
|
+
hs.activeBackColor = FXColor::LightGrey
|
231
|
+
hs.normalForeColor = FXColor::DarkGreen
|
232
|
+
hs.style = FXText::STYLE_UNDERLINE|FXText::STYLE_BOLD
|
233
|
+
styles.push hs
|
234
|
+
|
235
|
+
# emphasis
|
236
|
+
hs = create_empty_style
|
237
|
+
hs.normalForeColor = FXColor::DarkCyan
|
238
|
+
styles.push hs
|
239
|
+
|
240
|
+
# class
|
241
|
+
hs = create_empty_style
|
242
|
+
hs.style = FXText::STYLE_BOLD
|
243
|
+
hs.normalForeColor = FXColor::Blue
|
244
|
+
styles.push hs
|
245
|
+
|
246
|
+
styles
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
# loads all ri items
|
251
|
+
def load_items
|
250
252
|
@gui.search_field.text = "loading..."
|
251
253
|
@data.ri_manager.all_names.each do |name|
|
252
254
|
icon = case name.type
|
@@ -266,52 +268,52 @@ class FXri < FXHorizontalFrame
|
|
266
268
|
@gui.packet_list.on_cmd_header(0)
|
267
269
|
@gui.packet_list.update_header_width
|
268
270
|
recalc
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
271
|
+
end
|
272
|
+
|
273
|
+
def go_search(string)
|
274
|
+
@gui.search_field.text = string
|
275
|
+
on_search
|
276
|
+
end
|
277
|
+
|
278
|
+
def on_search
|
277
279
|
# do nothing if not fully loaded
|
278
280
|
return if !@isLoaded
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
281
|
+
@search_engine.on_search
|
282
|
+
end
|
283
|
+
|
284
|
+
def on_show
|
285
|
+
begin
|
286
|
+
w = @gui.text.width / @gui.text_width - 3
|
287
|
+
w = [w, $cfg.minimum_letters_per_line].max
|
288
|
+
@data.ri_manager.show(@desc, w)
|
289
|
+
rescue RiError => e
|
290
|
+
#puts desc
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
def show_info(desc)
|
295
|
+
@desc = desc
|
296
|
+
on_show
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
# x beeing the name of the ri doc, like "Set#delete"
|
301
|
+
# This creates a sortable representation. First class, then class methods, then instance.
|
302
|
+
def make_sortable(x)
|
303
|
+
[ x.downcase.gsub("::", " 1 ").gsub("#", " 2 "),
|
304
|
+
x.downcase,
|
305
|
+
x]
|
306
|
+
end
|
307
|
+
|
306
308
|
end
|
307
309
|
|
308
|
-
|
310
|
+
Thread.abort_on_exception= true
|
309
311
|
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
312
|
+
application = FXApp.new($cfg.app.name, $cfg.app.name)
|
313
|
+
application.threadsEnabled = true
|
314
|
+
#application.init(ARGV)
|
315
|
+
window = FXMainWindow.new(application, $cfg.app.name, nil, nil, DECOR_ALL, 0, 0, $cfg.app.width, $cfg.app.height)
|
316
|
+
FXri.new(window,FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0,0,0,0,0,0,0)
|
317
|
+
application.create
|
318
|
+
window.show(PLACEMENT_SCREEN)
|
319
|
+
application.run
|