1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 '''
22 This plugin provides a simple statusbar. It monitors the current line and
23 column number and allows general status messages to be sent via the
24 eventaction mechanism (this would allow the statusbar to be replaced
25 by another plugin without interfering
26
27 This plugin provides the following action:
28 SetStatusMessage message
29 Set the status bar's status message.
30
31 This plugin listens for the following events:
32 Keystroke
33 TextViewFocused
34 To update the line and column number
35 TextViewAdded
36 Sets up a mouse click listener on a textview when it has been added to the view.
37 ViewCreated
38 Sets up a mouse click listener and status bar on each new view
39 '''
40
41 from pallavi import EventActionManager
42 import wx
43
54
55
57 '''Called when a new view is created -- add a statusbar to that view'''
58 for textview in view.textViews:
59 TextViewAdded(None, pallavi.focusedView.textViews[textview])
60 statusbar = wx.StatusBar(pallavi.focusedView, wx.ID_ANY)
61 statusbar.SetFieldsCount(2)
62 statusbar.SetStatusWidths([-1, 120])
63 view.SetStatusBar(statusbar)
64 statusbar.SetStatusText("", 0)
65 statusbar.SetStatusText("", 1)
66
67 -def TextViewAdded(eventname, textview):
68 '''Responds to the textviewadded event. Should not be called directly'''
69 textview.Bind(wx.EVT_LEFT_DOWN, UpdateCursorPos)
70
72 '''Set the status message to a particular string, data. This can be called
73 directly if necessary, but its better to invoke the SetStatusMessage action instead'''
74 statusbar = pallavi.focusedView.GetStatusBar()
75 if statusbar:
76 statusbar.SetStatusText(data, 0)
77 wx.CallLater(4000, statusbar.SetStatusText, "", 0)
78
80 '''Update the area of the statusbar that indicates the current line and column number.
81 This function is automatically called when the mouse relocates the cursor, a new
82 textview is focused, or a keypress moves the cursor.'''
83
84 if type(name) == wx.MouseEvent:
85 name.Skip()
86
87 tv = pallavi.focusedView.focusedTextView
88 col = tv.GetColumn(tv.GetCurrentPos())
89 line = tv.GetCurrentLine()
90 statusbar = pallavi.focusedView.GetStatusBar()
91 if statusbar: statusbar.SetStatusText("line %d col %d" %(line, col), 1)
92