Class: FileSelector
- Inherits:
-
Object
- Object
- FileSelector
- Defined in:
- lib/vimamsa/search_replace.rb
Instance Method Summary collapse
- #dir_to_buf(dirpath, b = nil) ⇒ Object
- #fullp(fn) ⇒ Object
-
#initialize ⇒ FileSelector
constructor
A new instance of FileSelector.
- #run ⇒ Object
- #select_line ⇒ Object
Constructor Details
#initialize ⇒ FileSelector
Returns a new instance of FileSelector.
9 10 11 |
# File 'lib/vimamsa/search_replace.rb', line 9 def initialize() @buf = nil end |
Instance Method Details
#dir_to_buf(dirpath, b = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vimamsa/search_replace.rb', line 20 def dir_to_buf(dirpath, b = nil) @ld = dirpath @dlist = Dir.children(@ld) @cdirs = [] @cfiles = [] for x in @dlist if File.directory?(fullp(x)) @cdirs << x else @cfiles << x end end s = "..\n" s << @cdirs.join("\n") s << @cfiles.join("\n") if @buf.nil? @buf = create_new_file(nil, s) @buf.module = self @buf.active_kbd_mode = :file_exp else @buf.set_content(s) end end |
#fullp(fn) ⇒ Object
45 46 47 |
# File 'lib/vimamsa/search_replace.rb', line 45 def fullp(fn) "#{@ld}/#{fn}" end |
#run ⇒ Object
13 14 15 16 17 18 |
# File 'lib/vimamsa/search_replace.rb', line 13 def run ld = buflist.get_last_dir dir_to_buf(ld) # puts "ld=#{ld}" # dlist = Dir["#{ld}/*"] end |
#select_line ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vimamsa/search_replace.rb', line 49 def select_line # puts "def select_line" fn = fullp(@buf.get_current_line[0..-2]) if File.directory?(fn) debug "CHDIR: #{fn}" dir_to_buf(fn) # elsif vma.can_open_extension?(fn) #TODO: remove this check? # jump_to_file(fn) elsif file_is_text_file(fn) jump_to_file(fn) else open_with_default_program(fn) end end |