Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

docSwitcherRight.py

By: azrafe7 on May 8th, 2013  |  syntax: Python  |  size: 0.51 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. nextTabIdx = None
  17. for i, tab in enumerate(tabsInView):
  18.         if tab[BUFF_ID] == currBuffId:
  19.                 nextTabIdx = tabsInView[(i + 1) % nTabs][INDEX]
  20.                 break
  21.                
  22. notepad.activateIndex(currView, nextTabIdx)