1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 '''This plugin provides actions to switch to the next or previous buffer
22 in the buffer list, or to switch to a particular filename. Currently,
23 the sequence is defined arbitrarily by the BufferList class in Views,
24 but eventually either this plugin or that class should support some sort
25 of recency list
26
27 This plugin provides the following actions:
28 NextBuffer
29 Go to the next buffer in the list.
30 PreviousBuffer
31 Go to the previous buffer in the list
32 GoToBuffer
33 Prompt for a buffer to go to.'''
34
35
36 from pallavi import EventActionManager
37 import wx
38
43
45 pageidx = pallavi.focusedView.bufferNotebook.GetPageIndex(pallavi.focusedView.focusedTextView)
46 pageidx = pageidx - 1
47 if pageidx < 0: pageidx = pallavi.focusedView.bufferNotebook.PageCount-1
48 pallavi.focusedView.bufferNotebook.SetSelection(pageidx)
50 pageidx = pallavi.focusedView.bufferNotebook.GetPageIndex(pallavi.focusedView.focusedTextView)
51 pageidx = (pageidx + 1) % pallavi.focusedView.bufferNotebook.PageCount
52 pallavi.focusedView.bufferNotebook.SetSelection(pageidx)
53
55 '''If data is specified, assume it is a filename to find a buffer for,
56 otherwise prompt using an ugly dialog box'''
57 if data == None:
58 dlg = wx.TextEntryDialog(pallavi.focusedView, "Switch To Buffer:", "Buffer Filename:")
59 if dlg.ShowModal() == wx.ID_OK:
60 data = dlg.GetValue()
61 dlg.Destroy()
62
63 for filename in pallavi.focusedView.textViews.keys():
64 if filename.endswith(data):
65 pallavi.focusedView.bufferNotebook.SetSelection(pallavi.focusedView.bufferNotebook.GetPageIndex(pallavi.focusedView.textViews[filename]))
66 return
67