class FileHistory
History of previously opened files
Attributes
history[RW]
Public Class Methods
new()
click to toggle source
# File lib/vimamsa/file_history.rb, line 6 def initialize() # puts self.method("update") # x = self.method("update") # x.call("ASFASF") $hook.register(:change_buffer, self.method("update")) $hook.register(:shutdown, self.method("save")) reg_act(:fhist_remove_nonexisting, proc { remove_nonexisting }, "Cleanup history, remove non-existing files") @history = vma.marshal_load("file_history", {}) $search_list = [] end
Public Instance Methods
remove_nonexisting()
click to toggle source
# File lib/vimamsa/file_history.rb, line 41 def remove_nonexisting() size_orig = @history.size for k, v in @history if !File.exist?(k) @history.delete(k) log_message("Delete #{k} from history") end end size_new = @history.size message("History size #{size_orig} => #{size_new}") end
save()
click to toggle source
# File lib/vimamsa/file_history.rb, line 37 def save() vma.marshal_save("file_history", @history) end
start_gui()
click to toggle source
# File lib/vimamsa/file_history.rb, line 53 def start_gui() return if $vma.fh.history.empty? l = [] $select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"] opt = { :title => "File history search", :desc => "Search for previously opened files. Fuzzy search." , :columns => [{:title=>'Filename',:id=>0}] } gui_select_update_window(l, $select_keys.collect { |x| x.upcase }, "gui_file_history_select_callback", "gui_file_history_update_callback", opt) end
update(buf)
click to toggle source
def self.init() end
# File lib/vimamsa/file_history.rb, line 23 def update(buf) puts "FileHistory.update(buf=#{buf.fname})" return if !buf.fname @history[buf.fname] if !@history[buf.fname] if !@history[buf.fname] @history[buf.fname] = 1 else @history[buf.fname] += 1 end puts @history # puts "FileHistory.update(buf=#{buf})" end