fxri 0.3.3 → 0.3.4

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.
@@ -1,48 +1,50 @@
1
- require 'lib/Recursive_Open_Struct'
2
-
3
- $cfg = Recursive_Open_Struct.new
4
-
5
- $cfg.app.name = "fxri - Instant Ruby Enlightenment"
6
-
7
- $cfg.delayed_loading = false
8
-
9
- # uses the first font that is available
10
- $cfg.app.font.name = ["Bitstream Vera Sans", "Verdana", "Trebuchet MS", "Tahoma", "Arial"]
11
- $cfg.ri_font = ["Bitstream Vera Sans Mono", "Courier New", "Courier"]
12
- $cfg.app.font.size = 8
13
-
14
- $cfg.app.width = 760
15
- $cfg.app.height = 480
16
- $cfg.search_delay = 0.1
17
- $cfg.minimum_letters_per_line = 20
18
- $cfg.packet_list_width = 160
19
- $cfg.irb_height = 300
20
- $cfg.status_line_update_interval = 0.1
21
-
22
- $cfg.list.opts = ICONLIST_SINGLESELECT|ICONLIST_DETAILED|LAYOUT_FILL_X|LAYOUT_FILL_Y|ICONLIST_AUTOSIZE
23
-
24
- # icons, are automatically loaded from Icon_Loader.
25
- $cfg.icons_path = File.join("lib","icons")
26
- $cfg.icons.klass = "class.png"
27
- $cfg.icons.class_method = "module.png"
28
- $cfg.icons.instance_method = "method.png"
29
-
30
- # all texts
31
- $cfg.text.search = "%d / %d entries"
32
- $cfg.text.search_field = "What do you want to know?"
33
- $cfg.text.method_name = "name"
34
-
35
- # IRB
36
- $cfg.launch_irb = true
37
-
38
- $cfg.text.help = %|This is <b>fxri</b>, a graphical interface to the <em>Ruby</em> documentation. Fxri comes with a search engine with quite a few features. Here are several examples:
39
- '<em>Array</em>': Lists all classes with the name <em>Array</em>. Note that upcase words are treated case sensitive, lowercase words insensitive.
40
- '<em>array sort</em>': Everything that contains both <em>array</em> and <em>sort</em> (case insensitive).
41
- '<em>array -Fox</em>': Everything that contain the name <em>array</em> (case insensitive), but not <em>Fox</em> (case sensitive).
42
- After searching just press <em>down</em> to browse the search results. Press <em>Tab</em> to move back into the search field.
43
- If you have any questions, suggestions, problems, please contact the current maintainer with <b>markus.prinz@qsig.org</b>.
44
- Original author: Martin Ankerl (<b>martin.ankerl@gmail.com</b>).|
45
-
46
-
47
- # prevent further modifications
48
- $cfg.close
1
+ require 'lib/Recursive_Open_Struct'
2
+
3
+ $cfg = Recursive_Open_Struct.new
4
+
5
+ $cfg.app.name = "fxri - Instant Ruby Enlightenment"
6
+
7
+ $cfg.delayed_loading = false
8
+
9
+ $cfg.search_paths = ENV['FXRI_SEARCH_PATH'] if ENV.has_key?('FXRI_SEARCH_PATH')
10
+
11
+ # uses the first font that is available
12
+ $cfg.app.font.name = ["Bitstream Vera Sans", "Verdana", "Trebuchet MS", "Tahoma", "Arial"]
13
+ $cfg.ri_font = ["Bitstream Vera Sans Mono", "Courier New", "Courier"]
14
+ $cfg.app.font.size = 8
15
+
16
+ $cfg.app.width = 760
17
+ $cfg.app.height = 480
18
+ $cfg.search_delay = 0.1
19
+ $cfg.minimum_letters_per_line = 20
20
+ $cfg.packet_list_width = 160
21
+ $cfg.irb_height = 300
22
+ $cfg.status_line_update_interval = 0.1
23
+
24
+ $cfg.list.opts = ICONLIST_SINGLESELECT|ICONLIST_DETAILED|LAYOUT_FILL_X|LAYOUT_FILL_Y|ICONLIST_AUTOSIZE
25
+
26
+ # icons, are automatically loaded from Icon_Loader.
27
+ $cfg.icons_path = File.join("lib","icons")
28
+ $cfg.icons.klass = "class.png"
29
+ $cfg.icons.class_method = "module.png"
30
+ $cfg.icons.instance_method = "method.png"
31
+
32
+ # all texts
33
+ $cfg.text.search = "%d / %d entries"
34
+ $cfg.text.search_field = "What do you want to know?"
35
+ $cfg.text.method_name = "name"
36
+
37
+ # IRB
38
+ $cfg.launch_irb = true
39
+
40
+ $cfg.text.help = %|This is <b>fxri</b>, a graphical interface to the <em>Ruby</em> documentation. Fxri comes with a search engine with quite a few features. Here are several examples:
41
+ '<em>Array</em>': Lists all classes with the name <em>Array</em>. Note that upcase words are treated case sensitive, lowercase words insensitive.
42
+ '<em>array sort</em>': Everything that contains both <em>array</em> and <em>sort</em> (case insensitive).
43
+ '<em>array -Fox</em>': Everything that contain the name <em>array</em> (case insensitive), but not <em>Fox</em> (case sensitive).
44
+ After searching just press <em>down</em> to browse the search results. Press <em>Tab</em> to move back into the search field.
45
+ If you have any questions, suggestions, problems, please contact the current maintainer with <b>markus.prinz@qsig.org</b>.
46
+ Original author: Martin Ankerl (<b>martin.ankerl@gmail.com</b>).|
47
+
48
+
49
+ # prevent further modifications
50
+ $cfg.close
@@ -1,35 +1,35 @@
1
- # Copyright (c) 2004, 2005 Martin Ankerl
2
-
3
- # Converts a Recursive_Open_Struct that contains filenames of PNG-icons into real icons.
4
- class Icon_Loader
5
- # Create a new Icon_Loader. You need to specify the Fox-application.
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- # Takes each attribute of the given Recursive_Open_Struct,
11
- # converts it into a real icon, and sets it.
12
- def cfg_to_icons(cfg)
13
- cfg.attrs.each do |attr|
14
- value = cfg.send(attr.to_sym)
15
- if (value.class == Recursive_Open_Struct)
16
- cfg_to_icons(value)
17
- else
18
- # value is a filename
19
- icon = make_icon(value)
20
- cfg.send((attr + "=").to_sym, icon)
21
- end
22
- end
23
- end
24
-
25
- # Constructs an icon from the given filename (from the icons directory).
26
- def make_icon(filename)
27
- filename = File.join($cfg.icons_path, filename)
28
- icon = nil
29
- File.open(filename, "rb") do |f|
30
- icon = FXPNGIcon.new(@app, f.read, 0)
31
- end
32
- icon.create
33
- icon
34
- end
35
- end
1
+ # Copyright (c) 2004, 2005 Martin Ankerl
2
+
3
+ # Converts a Recursive_Open_Struct that contains filenames of PNG-icons into real icons.
4
+ class Icon_Loader
5
+ # Create a new Icon_Loader. You need to specify the Fox-application.
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ # Takes each attribute of the given Recursive_Open_Struct,
11
+ # converts it into a real icon, and sets it.
12
+ def cfg_to_icons(cfg)
13
+ cfg.attrs.each do |attr|
14
+ value = cfg.send(attr.to_sym)
15
+ if (value.class == Recursive_Open_Struct)
16
+ cfg_to_icons(value)
17
+ else
18
+ # value is a filename
19
+ icon = make_icon(value)
20
+ cfg.send((attr + "=").to_sym, icon)
21
+ end
22
+ end
23
+ end
24
+
25
+ # Constructs an icon from the given filename (from the icons directory).
26
+ def make_icon(filename)
27
+ filename = File.join($cfg.icons_path, filename)
28
+ icon = nil
29
+ File.open(filename, "rb") do |f|
30
+ icon = FXPNGIcon.new(@app, f.read, 0)
31
+ end
32
+ icon.create
33
+ icon
34
+ end
35
+ end
@@ -1,179 +1,179 @@
1
- # Copyright (c) 2004, 2005 Christoph Heindl and Martin Ankerl
2
- class MutexDummy
3
- def synchronize
4
- yield
5
- end
6
- end
7
-
8
- # Lock used to synchronize item removes.
9
- # for now, a global lock is good enough.
10
- $fx_icon_item_remove_mutex = Mutex.new
11
-
12
-
13
- # An item for Packet_List. This is a convenient wrapper for the FXIconItem.
14
- class Packet_Item
15
-
16
- attr_accessor :searchable
17
-
18
- # Fox_Item is a very thin wrapper that calles Packet_Item functionality.
19
- class Fox_Item < FXIconItem
20
- # optimization: directly sort by sort_key and reversed
21
- attr_accessor :sort_key
22
- attr_accessor :reversed
23
-
24
- # Create a new item with packet_item as the parent. *args is passed to the FXIconItem.
25
- def initialize(packet_item, *args)
26
- @packet_item = packet_item
27
- @sort_key = nil
28
- @reversed = 1
29
- @is_deleted = false
30
- super(*args)
31
- end
32
-
33
- # Sometimes draw is called AFTER the item has been removed.
34
- # In this case: return immediately. Otherwise a Runtime Error would occur!
35
- def draw(*args)
36
- $fx_icon_item_remove_mutex.synchronize do
37
- #puts "draw"
38
- return if @is_deleted
39
- super
40
- end
41
- end
42
-
43
- # Mark item as deleted, to prevent execution of draw afterwards
44
- # this is called from Packet_List which uses the same mutex
45
- # as draw.
46
- def deleted
47
- @is_deleted = true
48
- end
49
-
50
- # Called from sortItems, uses packet_item's comparison.
51
- def <=>(other)
52
- (@sort_key <=> other.sort_key) * @reversed
53
- end
54
-
55
- # Get the packet item
56
- def packet_item
57
- @packet_item
58
- end
59
-
60
- # Pass-through method
61
- def data
62
- @packet_item.data
63
- end
64
- end
65
-
66
- # Creates a Packet_Item with newParent as the parent list, which is allowed to be nil.
67
- # You can also use Packet_List#add_item instead.
68
- def initialize(newParent, icon, *content)
69
- @content = content
70
- @sortable = Array.new(@content.size)
71
- @icon = icon
72
- @data = nil
73
- @parent = nil
74
- @sort_key = nil
75
- @searchable = nil
76
- # call parent=, don't forget the self!!
77
- self.parent = newParent
78
- show if newParent
79
- # update sortable
80
- @content.each_index do |pos|
81
- update_sortable(pos, @content[pos]) if parent
82
- end
83
- end
84
-
85
- # Get the content of the given column number.
86
- def [](column_nr)
87
- @content[column_nr]
88
- end
89
-
90
- # Set new text for the given column number.
91
- def []=(column_nr, newVal)
92
- @content[column_nr] = newVal
93
- return unless @parent
94
- @item.text = @content.join("\t")
95
- update_sortable(column_nr, newVal)
96
- @parent.recalc
97
- end
98
-
99
- # Get the sortable representation of this column's content.
100
- def sortable(pos)
101
- @sortable[pos]
102
- end
103
-
104
- # update FXIconItem's sort key and reversed status
105
- def update_sort_key
106
- @item.sort_key = @sortable[@parent.sort_index]
107
- @item.reversed = @parent.reversed? ? -1 : 1
108
- end
109
-
110
- # Get the parent list for this item.
111
- def parent
112
- @parent
113
- end
114
-
115
- # Set a new parent. This removes this item from the current list and adds itself to
116
- # the new one.
117
- def parent=(newParent)
118
- return if newParent == @parent
119
- remove_item if @parent
120
- @parent = newParent
121
- @content.each_index do |pos|
122
- update_sortable(pos, @content[pos]) if @parent
123
- end
124
- end
125
-
126
- # Shows item on parent without updating the search index. This can be used
127
- # if an item is removed and added to the same list.
128
- def show
129
- create_item
130
- @parent.add_item(self)
131
- end
132
-
133
- # Get the wrapper item.
134
- def fox_item
135
- @item
136
- end
137
-
138
- # Allows to set user data.
139
- def data=(data)
140
- @data = data
141
- end
142
-
143
- # Get user data.
144
- def data
145
- @data
146
- end
147
-
148
- # Removes the item from its parent.
149
- def clear
150
- @parent = nil
151
- end
152
-
153
- # The icon of this item.
154
- def icon
155
- @icon
156
- end
157
-
158
- private
159
-
160
- # Calles the sort function to update the sortable representation of column pos.
161
- def update_sortable(pos, newVal)
162
- sort_function = @parent.sort_function(pos)
163
- if sort_function
164
- @sortable[pos] = sort_function.call(newVal)
165
- else
166
- @sortable[pos] = newVal
167
- end
168
- end
169
-
170
- # Remove item from parent
171
- def remove_item
172
- @parent.remove_item(self)
173
- end
174
-
175
- # Creates wrapper item, and sets it's data
176
- def create_item
177
- @item = Fox_Item.new(self, @content.join("\t"), @icon, @icon)
178
- end
1
+ # Copyright (c) 2004, 2005 Christoph Heindl and Martin Ankerl
2
+ class MutexDummy
3
+ def synchronize
4
+ yield
5
+ end
6
+ end
7
+
8
+ # Lock used to synchronize item removes.
9
+ # for now, a global lock is good enough.
10
+ $fx_icon_item_remove_mutex = Mutex.new
11
+
12
+
13
+ # An item for Packet_List. This is a convenient wrapper for the FXIconItem.
14
+ class Packet_Item
15
+
16
+ attr_accessor :searchable
17
+
18
+ # Fox_Item is a very thin wrapper that calles Packet_Item functionality.
19
+ class Fox_Item < FXIconItem
20
+ # optimization: directly sort by sort_key and reversed
21
+ attr_accessor :sort_key
22
+ attr_accessor :reversed
23
+
24
+ # Create a new item with packet_item as the parent. *args is passed to the FXIconItem.
25
+ def initialize(packet_item, *args)
26
+ @packet_item = packet_item
27
+ @sort_key = nil
28
+ @reversed = 1
29
+ @is_deleted = false
30
+ super(*args)
31
+ end
32
+
33
+ # Sometimes draw is called AFTER the item has been removed.
34
+ # In this case: return immediately. Otherwise a Runtime Error would occur!
35
+ def draw(*args)
36
+ $fx_icon_item_remove_mutex.synchronize do
37
+ #puts "draw"
38
+ return if @is_deleted
39
+ super
40
+ end
41
+ end
42
+
43
+ # Mark item as deleted, to prevent execution of draw afterwards
44
+ # this is called from Packet_List which uses the same mutex
45
+ # as draw.
46
+ def deleted
47
+ @is_deleted = true
48
+ end
49
+
50
+ # Called from sortItems, uses packet_item's comparison.
51
+ def <=>(other)
52
+ (@sort_key <=> other.sort_key) * @reversed
53
+ end
54
+
55
+ # Get the packet item
56
+ def packet_item
57
+ @packet_item
58
+ end
59
+
60
+ # Pass-through method
61
+ def data
62
+ @packet_item.data
63
+ end
64
+ end
65
+
66
+ # Creates a Packet_Item with newParent as the parent list, which is allowed to be nil.
67
+ # You can also use Packet_List#add_item instead.
68
+ def initialize(newParent, icon, *content)
69
+ @content = content
70
+ @sortable = Array.new(@content.size)
71
+ @icon = icon
72
+ @data = nil
73
+ @parent = nil
74
+ @sort_key = nil
75
+ @searchable = nil
76
+ # call parent=, don't forget the self!!
77
+ self.parent = newParent
78
+ show if newParent
79
+ # update sortable
80
+ @content.each_index do |pos|
81
+ update_sortable(pos, @content[pos]) if parent
82
+ end
83
+ end
84
+
85
+ # Get the content of the given column number.
86
+ def [](column_nr)
87
+ @content[column_nr]
88
+ end
89
+
90
+ # Set new text for the given column number.
91
+ def []=(column_nr, newVal)
92
+ @content[column_nr] = newVal
93
+ return unless @parent
94
+ @item.text = @content.join("\t")
95
+ update_sortable(column_nr, newVal)
96
+ @parent.recalc
97
+ end
98
+
99
+ # Get the sortable representation of this column's content.
100
+ def sortable(pos)
101
+ @sortable[pos]
102
+ end
103
+
104
+ # update FXIconItem's sort key and reversed status
105
+ def update_sort_key
106
+ @item.sort_key = @sortable[@parent.sort_index]
107
+ @item.reversed = @parent.reversed? ? -1 : 1
108
+ end
109
+
110
+ # Get the parent list for this item.
111
+ def parent
112
+ @parent
113
+ end
114
+
115
+ # Set a new parent. This removes this item from the current list and adds itself to
116
+ # the new one.
117
+ def parent=(newParent)
118
+ return if newParent == @parent
119
+ remove_item if @parent
120
+ @parent = newParent
121
+ @content.each_index do |pos|
122
+ update_sortable(pos, @content[pos]) if @parent
123
+ end
124
+ end
125
+
126
+ # Shows item on parent without updating the search index. This can be used
127
+ # if an item is removed and added to the same list.
128
+ def show
129
+ create_item
130
+ @parent.add_item(self)
131
+ end
132
+
133
+ # Get the wrapper item.
134
+ def fox_item
135
+ @item
136
+ end
137
+
138
+ # Allows to set user data.
139
+ def data=(data)
140
+ @data = data
141
+ end
142
+
143
+ # Get user data.
144
+ def data
145
+ @data
146
+ end
147
+
148
+ # Removes the item from its parent.
149
+ def clear
150
+ @parent = nil
151
+ end
152
+
153
+ # The icon of this item.
154
+ def icon
155
+ @icon
156
+ end
157
+
158
+ private
159
+
160
+ # Calles the sort function to update the sortable representation of column pos.
161
+ def update_sortable(pos, newVal)
162
+ sort_function = @parent.sort_function(pos)
163
+ if sort_function
164
+ @sortable[pos] = sort_function.call(newVal)
165
+ else
166
+ @sortable[pos] = newVal
167
+ end
168
+ end
169
+
170
+ # Remove item from parent
171
+ def remove_item
172
+ @parent.remove_item(self)
173
+ end
174
+
175
+ # Creates wrapper item, and sets it's data
176
+ def create_item
177
+ @item = Fox_Item.new(self, @content.join("\t"), @icon, @icon)
178
+ end
179
179
  end