Class: MonitorLastUsedDir

Inherits:
Object
  • Object
show all
Defined in:
lib/a-core.rb

Overview

receives messages and tracks the by Roger D. Pack

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMonitorLastUsedDir

Returns a new instance of MonitorLastUsedDir.



3521
3522
3523
3524
3525
# File 'lib/a-core.rb', line 3521

def initialize
  for event in [SaveBufferEvent, AckInFilesEvent, SearchInFilesEvent, OpenBufferEvent] do
   Arcadia.attach_listener(self, event)
  end
end

Class Method Details

.get_last_dirObject



3542
3543
3544
3545
3546
3547
3548
3549
# File 'lib/a-core.rb', line 3542

def self.get_last_dir
  current = $arcadia['pers']['last.used.dir']
  if current != nil && current != ''
   current
  else
   $pwd # startup dir
  end
end

.set_last(to_this) ⇒ Object

TODO set as private…



3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
# File 'lib/a-core.rb', line 3551

def MonitorLastUsedDir.set_last to_this # TODO set as private...
  return if to_this.nil? or to_this == ''
  if(File.directory?(to_this))
    to_this_dir = to_this
  elsif File.directory? File.dirname(to_this)
    # filename,
    to_this_dir = File.dirname(to_this)
  end
  $arcadia['pers']['last.used.dir'] = File.expand_path(to_this_dir)
end

Instance Method Details

#on_after_ack_in_files(_event) ⇒ Object Also known as: on_after_search_in_files



3531
3532
3533
# File 'lib/a-core.rb', line 3531

def on_after_ack_in_files _event
  MonitorLastUsedDir.set_last _event.dir
end

#on_after_open_buffer(_event) ⇒ Object

we want this one…but…not at startup time…hmm.



3536
3537
3538
# File 'lib/a-core.rb', line 3536

def on_after_open_buffer _event
  MonitorLastUsedDir.set_last _event.file
end

#on_after_save_as_buffer(_event) ⇒ Object



3527
3528
3529
# File 'lib/a-core.rb', line 3527

def on_after_save_as_buffer(_event)
 MonitorLastUsedDir.set_last _event.new_file
end