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