43 return None |
43 return None |
44 |
44 |
45 class CustomStyledTextCtrl(wx.stc.StyledTextCtrl): |
45 class CustomStyledTextCtrl(wx.stc.StyledTextCtrl): |
46 |
46 |
47 def __init__(self, *args, **kwargs): |
47 def __init__(self, *args, **kwargs): |
48 wx.stc.StyledTextCtrl(self, *args, **kwargs) |
48 wx.stc.StyledTextCtrl.__init__(self, *args, **kwargs) |
49 |
49 |
50 self.Bind(wx.EVT_MOTION, self.OnMotion) |
50 self.Bind(wx.EVT_MOTION, self.OnMotion) |
51 |
51 |
52 def OnMotion(self, event): |
52 def OnMotion(self, event): |
53 if wx.Platform == '__WXMSW__': |
53 if wx.Platform == '__WXMSW__': |
54 if not event.Dragging(): |
54 if not event.Dragging(): |
55 x, y = event.GetPosition() |
55 x, y = event.GetPosition() |
56 margin_width = reduce( |
56 margin_width = reduce( |
57 lambda x, y: x + y, |
57 lambda x, y: x + y, |
58 [self.LogConsole.GetMarginWidth(i) |
58 [self.GetMarginWidth(i) |
59 for i in xrange(3)], |
59 for i in xrange(3)], |
60 0) |
60 0) |
61 if x <= margin_width: |
61 if x <= margin_width: |
62 self.LogConsole.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) |
62 self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) |
63 else: |
63 else: |
64 self.LogConsole.SetCursor(wx.StockCursor(wx.CURSOR_IBEAM)) |
64 self.SetCursor(wx.StockCursor(wx.CURSOR_IBEAM)) |
|
65 else: |
|
66 event.Skip() |
65 else: |
67 else: |
66 event.Skip() |
68 event.Skip() |
67 |
69 |
68 def AppendText(self, text): |
70 def AppendText(self, text): |
69 last_position = self.GetLength() |
71 self.GotoPos(self.GetLength()) |
70 current_selection = self.GetSelection() |
|
71 self.GotoPos(last_position) |
|
72 self.AddText(text) |
72 self.AddText(text) |
73 if current_selection[0] != last_position: |
|
74 self.SetSelection(*current_selection) |
|
75 else: |
|
76 self.ScrollToLine(self.GetLineCount()) |
|