Class: Run_Menu
Constant Summary
collapse
- @@RE_HIDDEN =
Regexp.new(/(^|\/)\.[^\/]*$/i)
Instance Attribute Summary
Attributes inherited from Menu
#style
Instance Method Summary
collapse
Methods inherited from Menu
#encode_with, #filter_entries, #get_font_string, #init_with, #items, #remove_item, #set_item, #to_s
Methods included from Item
#name=
Constructor Details
#initialize(parent, history = History.new(1, 5), name = "Run") ⇒ Run_Menu
Returns a new instance of Run_Menu.
8
9
10
11
12
13
|
# File 'lib/run_menu.rb', line 8
def initialize parent, history = History.new(1, 5), name = "Run"
self.name = name
@parent = parent
@history = history
self.style = parent.style
end
|
Instance Method Details
#execute ⇒ Object
19
20
21
22
23
24
|
# File 'lib/run_menu.rb', line 19
def execute
command =
Command.new("", command).execute
@history.update command unless command.empty?
!command.empty?
end
|
#get_files(dirs = (`echo $PATH`).split(':')) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/run_menu.rb', line 35
def get_files dirs = (`echo $PATH`).split(':')
@files = []
dirs.each do |dir|
get_files_rec dir
end
end
|
#get_files_rec(file) ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/run_menu.rb', line 41
def get_files_rec file
return if file.match @@RE_HIDDEN
if File.directory? file
Dir.foreach file do |cur_file|
get_files_rec cur_file
end
else
@files << file
end
end
|
#name ⇒ Object
15
16
17
|
# File 'lib/run_menu.rb', line 15
def name
">#{super}"
end
|
26
27
28
29
30
31
32
33
|
# File 'lib/run_menu.rb', line 26
def
get_files
history_items = @history.items
items = history_items.first
items << '---' unless items.empty?
items += @files + history_items[1]
super items, self.name
end
|