Changeset 1572

Show
Ignore:
Timestamp:
08/07/08 18:14:29 (4 months ago)
Author:
rob
Message:

Fixed #481: added save position data for switching buffers
* leveraged the MajorMode?'s getViewPositionData to create an options dict, which is then passed to showInitialPosition
* changed BufferFrame?.setBuffer to take the options dict as an argument

Location:
trunk/peppy
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/frame.py

    r1571 r1572  
    665665        return False 
    666666 
    667     def setBuffer(self, buffer, wrapper=None): 
     667    def setBuffer(self, buffer, wrapper=None, options=None): 
    668668        if wrapper is None: 
    669669            # this gets a default view for the selected buffer 
     
    672672        assert self.dprint("set buffer to new view %s" % mode) 
    673673        self.tabs.updateWrapper(wrapper) 
    674      
     674        if options: 
     675            mode.showInitialPosition(buffer.raw_url, options) 
     676 
    675677    def newBuffer(self, buffer): 
    676678        # proxy it up to tabs 
  • trunk/peppy/fundamental.py

    r1505 r1572  
    608608            line -= self.classprefs.line_number_offset 
    609609            self.showLine(line) 
     610        if options: 
     611            self.setViewPositionData(options) 
    610612 
    611613    ##### Comment handling 
  • trunk/peppy/plugins/switch_buffers.py

    r1569 r1572  
    4747    last_buffer = "" 
    4848     
     49    # Store options used to restore view state when switching back to a 
     50    # previous buffer 
     51    last_options = {} 
     52     
    4953    def createList(self): 
    5054        """Generate list of possible buffer names to complete. 
     
    7276        if text in self.display_names: 
    7377            self.__class__.last_buffer = mode.buffer.displayname 
     78            self.__class__.last_options[mode.buffer.displayname] = mode.getViewPositionData() 
    7479            index = self.display_names.index(text) 
    7580            url = self.full_names[index] 
    76             dprint("found %s, switching to %s" % (text, url)) 
    77             wx.CallAfter(self.frame.setBuffer, url) 
     81            if text in self.__class__.last_options: 
     82                options = self.__class__.last_options[text] 
     83            else: 
     84                options = None 
     85            dprint("found %s, switching to %s with options %s" % (text, url, options)) 
     86            wx.CallAfter(self.frame.setBuffer, url, options=options) 
    7887        else: 
    7988            dprint("buffer %s doesn't exist" % text)