SHARE
TWEET

docSwitcherLeft.py

azrafe7 May 8th, 2013 47 Never
  1.  
  2. from operator import itemgetter
  3.  
  4. __author__ = "azrafe7"
  5.  
  6. BUFF_ID = 1
  7. INDEX = 2
  8. VIEW = 3
  9.  
  10. currView = notepad.getCurrentView()
  11. currBuffId = notepad.getCurrentBufferID()
  12. tabsInView = filter(lambda item: item[VIEW] == currView, notepad.getFiles())
  13. tabsInView.sort(key=itemgetter(INDEX))
  14. nTabs = len(tabsInView)
  15.  
  16. prevTabIdx = None
  17. for i, tab in enumerate(tabsInView):
  18.         if tab[BUFF_ID] == currBuffId:
  19.                 prevTabIdx = tabsInView[(i + nTabs - 1) % nTabs][INDEX]
  20.                 break
  21.                
  22. notepad.activateIndex(currView, prevTabIdx)
RAW Paste Data
Top