mwxlib 1.7.13__py3-none-any.whl → 1.8.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mwx/nutshell.py CHANGED
@@ -369,7 +369,7 @@ class AutoCompInterfaceMixin:
369
369
  self.message("[module]>>> loading {}...".format(text))
370
370
  modules = set(dir(import_module(text)))
371
371
  except ImportError as e:
372
- self.message("\b failed.", e)
372
+ self.message("\b failed;", e)
373
373
  return
374
374
  else:
375
375
  ## Add unimported module names (case-insensitive match).
@@ -489,12 +489,12 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
489
489
  self.make_keymap('C-x')
490
490
  self.make_keymap('C-c')
491
491
 
492
- self.handler.update({ # DNA<EditorInterface>
492
+ self.handler.update({ # DNA<EditorInterface>
493
493
  None : {
494
- 'mark_set' : [ None, dispatch ],
495
- 'mark_unset' : [ None, dispatch ],
496
- 'pointer_set' : [ None, dispatch ],
497
- 'pointer_unset' : [ None, dispatch ],
494
+ 'mark_set' : [None, dispatch],
495
+ 'mark_unset' : [None, dispatch],
496
+ 'pointer_set' : [None, dispatch],
497
+ 'pointer_unset' : [None, dispatch],
498
498
  },
499
499
  0 : {
500
500
  'insert pressed' : (0, _F(self.over, mode=None, doc="toggle-over")),
@@ -696,14 +696,14 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
696
696
 
697
697
  __dnd_flag = 0
698
698
 
699
- def OnDrag(self, evt): #<wx._core.StyledTextEvent>
699
+ def OnDrag(self, evt): # <wx._core.StyledTextEvent>
700
700
  if isinstance(self, Shell):
701
701
  EditorInterface.__dnd_flag = (evt.Position < self.bolc) # readonly
702
702
  else:
703
703
  EditorInterface.__dnd_flag = 0
704
704
  evt.Skip()
705
705
 
706
- def OnDragging(self, evt): #<wx._core.StyledTextEvent>
706
+ def OnDragging(self, evt): # <wx._core.StyledTextEvent>
707
707
  if isinstance(self, Shell):
708
708
  if evt.Position < self.bolc: # target is readonly
709
709
  evt.DragResult = wx.DragNone
@@ -716,7 +716,7 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
716
716
  evt.DragResult = wx.DragCopy if wx.GetKeyState(wx.WXK_CONTROL) else wx.DragNone
717
717
  evt.Skip()
718
718
 
719
- def OnDragged(self, evt): #<wx._core.StyledTextEvent>
719
+ def OnDragged(self, evt): # <wx._core.StyledTextEvent>
720
720
  EditorInterface.__dnd_flag = 0
721
721
  evt.Skip()
722
722
 
@@ -1104,7 +1104,7 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
1104
1104
  self.SetFoldMarginColour(True, 'black')
1105
1105
  self.SetFoldMarginHiColour(True, 'black')
1106
1106
 
1107
- def OnMarginClick(self, evt): #<wx._stc.StyledTextEvent>
1107
+ def OnMarginClick(self, evt): # <wx._stc.StyledTextEvent>
1108
1108
  lc = self.LineFromPosition(evt.Position)
1109
1109
  level = self.GetFoldLevel(lc) ^ stc.STC_FOLDLEVELBASE
1110
1110
  ## `level` indicates indent-level number
@@ -1116,7 +1116,7 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
1116
1116
  else:
1117
1117
  self.handler('select_line', evt)
1118
1118
 
1119
- def OnMarginRClick(self, evt): #<wx._stc.StyledTextEvent>
1119
+ def OnMarginRClick(self, evt): # <wx._stc.StyledTextEvent>
1120
1120
  """Popup context menu."""
1121
1121
  def _Icon(key):
1122
1122
  return wx.ArtProvider.GetBitmap(key, size=(16,16))
@@ -1160,13 +1160,13 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
1160
1160
 
1161
1161
  def on_linesel_begin(self, evt):
1162
1162
  """Called when a line of text selection begins."""
1163
- self.cpos = self.anchor = evt.Position #<select_line>
1163
+ self.cpos = self.anchor = evt.Position # <select_line>
1164
1164
  self.CaptureMouse()
1165
1165
  evt.Skip()
1166
1166
 
1167
1167
  def on_linesel_next(self, evt):
1168
1168
  """Called when next line of text selection begins."""
1169
- self.cpos = evt.Position #<select_lines>
1169
+ self.cpos = evt.Position # <select_lines>
1170
1170
  self.CaptureMouse()
1171
1171
  evt.Skip()
1172
1172
 
@@ -1863,10 +1863,7 @@ class Buffer(EditorInterface, EditWindow):
1863
1863
  < 0: a url file
1864
1864
  """
1865
1865
  try:
1866
- mtime = os.path.getmtime(self.__path)
1867
- return mtime - self.__mtime
1868
- except FileNotFoundError:
1869
- self.__mtime = False # valid path (but not found)
1866
+ return os.path.getmtime(self.__path) - self.__mtime
1870
1867
  except OSError:
1871
1868
  pass
1872
1869
  return self.__mtime
@@ -1924,18 +1921,6 @@ class Buffer(EditorInterface, EditWindow):
1924
1921
  self.Bind(stc.EVT_STC_SAVEPOINTLEFT, self.OnSavePointLeft)
1925
1922
  self.Bind(stc.EVT_STC_SAVEPOINTREACHED, self.OnSavePointReached)
1926
1923
 
1927
- def activate(evt):
1928
- if self:
1929
- self.handler('buffer_activated', self)
1930
- evt.Skip()
1931
- self.Bind(wx.EVT_SET_FOCUS, activate)
1932
-
1933
- def inactivate(evt):
1934
- if self:
1935
- self.handler('buffer_inactivated', self)
1936
- evt.Skip()
1937
- self.Bind(wx.EVT_KILL_FOCUS, inactivate)
1938
-
1939
1924
  def clear(evt):
1940
1925
  ## """Clear selection and message, no skip."""
1941
1926
  ## *DO NOT* clear autocomp, so that the event can skip to AutoComp properly.
@@ -1954,23 +1939,25 @@ class Buffer(EditorInterface, EditWindow):
1954
1939
  ## Note: Mouse events are not propagated from Buffer to EditorBook.
1955
1940
  ## They are explicitly dispatched from buffer.handler to editor.handler.
1956
1941
 
1957
- self.handler.update({ # DNA<Buffer>
1942
+ self.handler.update({ # DNA<Buffer>
1958
1943
  None : {
1959
- 'buffer_saved' : [ None, dispatch ],
1960
- 'buffer_loaded' : [ None, dispatch ],
1961
- 'buffer_modified' : [ None, dispatch, self.on_buffer_modified ],
1962
- 'buffer_activated' : [ None, dispatch, self.on_buffer_activated ],
1963
- 'buffer_inactivated' : [ None, dispatch, self.on_buffer_inactivated ],
1964
- 'buffer_region_executed' : [ None, dispatch ],
1944
+ 'focus_set' : [None, self.on_buffer_activate],
1945
+ 'focus_kill' : [None, self.on_buffer_inactivate],
1946
+ 'buffer_saved' : [None, dispatch],
1947
+ 'buffer_loaded' : [None, dispatch],
1948
+ 'buffer_modified' : [None, dispatch],
1949
+ 'buffer_activated' : [None, dispatch],
1950
+ 'buffer_inactivated' : [None, dispatch],
1951
+ 'buffer_region_executed' : [None, dispatch],
1965
1952
  },
1966
- -1 : { # original action of the EditWindow
1953
+ -1 : { # original action of the EditWindow
1967
1954
  '* pressed' : (0, skip, self.on_exit_escmap),
1968
1955
  '*alt pressed' : (-1, ),
1969
1956
  '*ctrl pressed' : (-1, ),
1970
1957
  '*shift pressed' : (-1, ),
1971
1958
  '*[LR]win pressed' : (-1, ),
1972
1959
  },
1973
- 0 : { # Normal mode
1960
+ 0 : { # Normal mode
1974
1961
  '* pressed' : (0, skip),
1975
1962
  '* released' : (0, skip, dispatch),
1976
1963
  '*button* pressed' : (0, skip, dispatch),
@@ -1983,7 +1970,7 @@ class Buffer(EditorInterface, EditWindow):
1983
1970
  'M-. pressed' : (2, self.call_word_autocomp),
1984
1971
  'M-/ pressed' : (3, self.call_apropos_autocomp),
1985
1972
  },
1986
- 2 : { # word auto completion AS-mode
1973
+ 2 : { # word auto completion AS-mode
1987
1974
  'quit' : (0, self.clear_autocomp),
1988
1975
  '* pressed' : (0, self.clear_autocomp, fork),
1989
1976
  'tab pressed' : (0, clear, skip),
@@ -2010,7 +1997,7 @@ class Buffer(EditorInterface, EditWindow):
2010
1997
  '*[LR]win pressed' : (2, ),
2011
1998
  '*f[0-9]* pressed' : (2, ),
2012
1999
  },
2013
- 3 : { # apropos auto completion AS-mode
2000
+ 3 : { # apropos auto completion AS-mode
2014
2001
  'quit' : (0, self.clear_autocomp),
2015
2002
  '* pressed' : (0, self.clear_autocomp, fork),
2016
2003
  'tab pressed' : (0, clear, skip),
@@ -2051,14 +2038,19 @@ class Buffer(EditorInterface, EditWindow):
2051
2038
  _text, lp = self.CurLine
2052
2039
  self.message("{:>6d}:{} ({})".format(self.cline, lp, self.cpos), pane=-1)
2053
2040
 
2054
- def OnUpdate(self, evt): #<wx._stc.StyledTextEvent>
2041
+ def OnUpdate(self, evt): # <wx._stc.StyledTextEvent>
2055
2042
  if evt.Updated & (stc.STC_UPDATE_SELECTION | stc.STC_UPDATE_CONTENT):
2056
2043
  self.trace_position()
2057
2044
  if evt.Updated & stc.STC_UPDATE_CONTENT:
2045
+ self.SetIndicatorCurrent(2)
2046
+ self.IndicatorClearRange(0, self.TextLength)
2047
+ for m in self.grep(url_re):
2048
+ p, q = m.span()
2049
+ self.IndicatorFillRange(p, q-p)
2058
2050
  self.handler('buffer_modified', self)
2059
2051
  evt.Skip()
2060
2052
 
2061
- def OnCallTipClick(self, evt): #<wx._stc.StyledTextEvent>
2053
+ def OnCallTipClick(self, evt): # <wx._stc.StyledTextEvent>
2062
2054
  if self.CallTipActive():
2063
2055
  self.CallTipCancel()
2064
2056
  pos, tip, more = self._calltips
@@ -2066,7 +2058,7 @@ class Buffer(EditorInterface, EditWindow):
2066
2058
  self.CallTipShow(pos, tip, N=None)
2067
2059
  evt.Skip()
2068
2060
 
2069
- def OnIndicatorClick(self, evt): #<wx._stc.StyledTextEvent>
2061
+ def OnIndicatorClick(self, evt): # <wx._stc.StyledTextEvent>
2070
2062
  if self.SelectedText or not wx.GetKeyState(wx.WXK_CONTROL):
2071
2063
  ## Processing text selection or dragging.
2072
2064
  evt.Skip()
@@ -2086,14 +2078,6 @@ class Buffer(EditorInterface, EditWindow):
2086
2078
  ## Note: post-call for the confirmation dialog.
2087
2079
  wx.CallAfter(self.parent.load_file, url)
2088
2080
 
2089
- def on_buffer_modified(self, buf):
2090
- """Called when the buffer is modified."""
2091
- self.SetIndicatorCurrent(2)
2092
- self.IndicatorClearRange(0, self.TextLength)
2093
- for m in self.grep(url_re):
2094
- p, q = m.span()
2095
- self.IndicatorFillRange(p, q-p)
2096
-
2097
2081
  def OnSavePointLeft(self, evt):
2098
2082
  self.update_caption()
2099
2083
  evt.Skip()
@@ -2113,14 +2097,15 @@ class Buffer(EditorInterface, EditWindow):
2113
2097
  self.handler('quit', evt) # Don't enter autocomp
2114
2098
  evt.Skip()
2115
2099
 
2116
- def on_buffer_activated(self, buf):
2117
- """Called when the buffer is activated."""
2100
+ def on_buffer_activate(self, evt):
2101
+ """Called when the buffer (self) is activated."""
2118
2102
  self.update_caption()
2119
2103
  self.trace_position()
2104
+ self.handler('buffer_activated', self)
2120
2105
 
2121
- def on_buffer_inactivated(self, buf):
2122
- """Called when the buffer is inactivated."""
2123
- pass
2106
+ def on_buffer_inactivate(self, evt):
2107
+ """Called when the buffer (self) is inactivated."""
2108
+ self.handler('buffer_inactivated', self)
2124
2109
 
2125
2110
  def on_left_down(self, evt):
2126
2111
  pos = self.PositionFromPoint(evt.Position)
@@ -2317,18 +2302,18 @@ class EditorBook(AuiNotebook, CtrlInterface):
2317
2302
  self.make_keymap('C-x')
2318
2303
  self.make_keymap('C-c')
2319
2304
 
2320
- self.handler.update({ # DNA<EditorBook>
2305
+ self.handler.update({ # DNA<EditorBook>
2321
2306
  None : {
2322
- 'buffer_new' : [ None, dispatch ],
2323
- 'buffer_saved' : [ None, dispatch ],
2324
- 'buffer_loaded' : [ None, dispatch ],
2325
- 'buffer_deleted' : [ None, dispatch ],
2326
- 'buffer_modified' : [ None, dispatch ],
2327
- 'buffer_activated' : [ None, dispatch, self.on_buffer_activated ],
2328
- 'buffer_inactivated' : [ None, dispatch, self.on_buffer_inactivated ],
2329
- 'buffer_caption_updated' : [ None, dispatch ],
2307
+ 'buffer_new' : [None, dispatch],
2308
+ 'buffer_saved' : [None, dispatch],
2309
+ 'buffer_loaded' : [None, dispatch],
2310
+ 'buffer_deleted' : [None, dispatch],
2311
+ 'buffer_modified' : [None, dispatch],
2312
+ 'buffer_activated' : [None, dispatch, self.on_buffer_activated],
2313
+ 'buffer_inactivated' : [None, dispatch, self.on_buffer_inactivated],
2314
+ 'buffer_caption_updated' : [None, dispatch],
2330
2315
  },
2331
- 0 : { # Normal mode
2316
+ 0 : { # Normal mode
2332
2317
  '* pressed' : (0, skip),
2333
2318
  '* released' : (0, skip, dispatch),
2334
2319
  '*button* pressed' : (0, skip, dispatch),
@@ -2343,10 +2328,10 @@ class EditorBook(AuiNotebook, CtrlInterface):
2343
2328
  self.handler('buffer_deleted', obj)
2344
2329
  evt.Skip()
2345
2330
 
2346
- def OnPageClose(self, evt): #<wx._aui.AuiNotebookEvent>
2331
+ def OnPageClose(self, evt): # <wx._aui.AuiNotebookEvent>
2347
2332
  buf = self.GetPage(evt.Selection)
2348
2333
  if buf.need_buffer_save:
2349
- if wx.MessageBox( # Confirm closing the buffer.
2334
+ if wx.MessageBox( # Confirm closing the buffer.
2350
2335
  "You are closing unsaved content.\n\n"
2351
2336
  "The changes will be discarded.\n"
2352
2337
  "Continue closing?",
@@ -2357,7 +2342,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
2357
2342
  return
2358
2343
  evt.Skip()
2359
2344
 
2360
- def OnPageClosed(self, evt): #<wx._aui.AuiNotebookEvent>
2345
+ def OnPageClosed(self, evt): # <wx._aui.AuiNotebookEvent>
2361
2346
  if self.PageCount == 0:
2362
2347
  self.new_buffer()
2363
2348
  evt.Skip()
@@ -2535,13 +2520,14 @@ class EditorBook(AuiNotebook, CtrlInterface):
2535
2520
 
2536
2521
  def load_file(self, filename, lineno=0, verbose=True, **kwargs):
2537
2522
  """Load a file into an existing or new buffer.
2538
- The requests module is required to use URL extension.
2523
+ Note:
2524
+ The 'requests' module is required to load from a URL.
2539
2525
  """
2540
2526
  buf = self.find_buffer(filename)
2541
2527
  if not buf:
2542
2528
  buf = self.create_buffer("*temp file*")
2543
2529
  elif buf.need_buffer_save and verbose:
2544
- if wx.MessageBox( # Confirm loading the buffer.
2530
+ if wx.MessageBox( # Confirm loading the buffer.
2545
2531
  "You are leaving unsaved content.\n\n"
2546
2532
  "The changes will be discarded.\n"
2547
2533
  "Continue loading?",
@@ -2568,7 +2554,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
2568
2554
  return True
2569
2555
  return False
2570
2556
  except (OSError, UnicodeDecodeError, ModuleNotFoundError) as e:
2571
- self.post_message("Failed to load:", e)
2557
+ self.post_message("Failed to load;", e)
2572
2558
  self.delete_buffer(buf)
2573
2559
  return False
2574
2560
 
@@ -2590,12 +2576,12 @@ class EditorBook(AuiNotebook, CtrlInterface):
2590
2576
  return retval
2591
2577
 
2592
2578
  def save_file(self, filename, buf=None, verbose=True):
2593
- """Save the current buffer to a file.
2579
+ """Save the specified buffer to the given filename.
2594
2580
  """
2595
2581
  buf = buf or self.buffer
2596
2582
  if buf.need_buffer_load and verbose:
2597
2583
  self.swap_buffer(buf)
2598
- if wx.MessageBox( # Confirm saving the buffer.
2584
+ if wx.MessageBox( # Confirm saving the buffer.
2599
2585
  "The file has been modified externally.\n\n"
2600
2586
  "The contents of the file will be overwritten.\n"
2601
2587
  "Continue saving?",
@@ -2610,11 +2596,11 @@ class EditorBook(AuiNotebook, CtrlInterface):
2610
2596
  return True
2611
2597
  return False
2612
2598
  except (OSError, UnicodeDecodeError) as e:
2613
- self.post_message("Failed to save:", e)
2599
+ self.post_message("Failed to save;", e)
2614
2600
  return False
2615
2601
 
2616
2602
  def load_buffer(self, buf=None):
2617
- """Confirm the load with the dialog."""
2603
+ """Load the buffer; confirm the load with the dialog."""
2618
2604
  buf = buf or self.buffer
2619
2605
  dt = buf.mtdelta
2620
2606
  if dt is None:
@@ -2627,7 +2613,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
2627
2613
  return self.load_file(buf.filename, buf.markline+1)
2628
2614
 
2629
2615
  def save_buffer(self, buf=None):
2630
- """Confirm the save with the dialog."""
2616
+ """Save the buffer."""
2631
2617
  buf = buf or self.buffer
2632
2618
  dt = buf.mtdelta
2633
2619
  if dt is None:
@@ -2640,7 +2626,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
2640
2626
  return self.save_file(buf.filename, buf)
2641
2627
 
2642
2628
  def save_buffer_as(self, buf=None):
2643
- """Confirm the saveas with the dialog."""
2629
+ """Save the buffer as a new file."""
2644
2630
  buf = buf or self.buffer
2645
2631
  with wx.FileDialog(self, "Save buffer as",
2646
2632
  defaultDir=os.path.dirname(self.buffer.filename),
@@ -2651,15 +2637,16 @@ class EditorBook(AuiNotebook, CtrlInterface):
2651
2637
  return self.save_file(dlg.Path, buf)
2652
2638
 
2653
2639
  def save_all_buffers(self):
2640
+ """Save all buffers."""
2654
2641
  for buf in self.get_all_buffers():
2655
2642
  if buf.need_buffer_save:
2656
2643
  self.save_buffer(buf)
2657
2644
 
2658
2645
  def kill_buffer(self, buf=None):
2659
- """Confirm the close with the dialog."""
2646
+ """Delete the buffer; confirm the close with a dialog."""
2660
2647
  buf = buf or self.buffer
2661
2648
  if buf.need_buffer_save:
2662
- if wx.MessageBox( # Confirm closing the buffer.
2649
+ if wx.MessageBox( # Confirm closing the buffer.
2663
2650
  "You are closing unsaved content.\n\n"
2664
2651
  "The changes will be discarded.\n"
2665
2652
  "Continue closing?",
@@ -2670,9 +2657,10 @@ class EditorBook(AuiNotebook, CtrlInterface):
2670
2657
  self.delete_buffer(buf)
2671
2658
 
2672
2659
  def kill_all_buffers(self):
2660
+ """Delete all buffers; confirm the close with a dialog."""
2673
2661
  for buf in self.get_all_buffers():
2674
2662
  if buf.need_buffer_save:
2675
- if wx.MessageBox( # Confirm closing the buffer.
2663
+ if wx.MessageBox( # Confirm closing the buffer.
2676
2664
  "You are closing unsaved content.\n\n"
2677
2665
  "The changes will be discarded.\n"
2678
2666
  "Continue closing?",
@@ -2887,18 +2875,6 @@ class Nautilus(EditorInterface, Shell):
2887
2875
 
2888
2876
  self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
2889
2877
 
2890
- def activate(evt):
2891
- if self:
2892
- self.handler('shell_activated', self)
2893
- evt.Skip()
2894
- self.Bind(wx.EVT_SET_FOCUS, activate)
2895
-
2896
- def inactivate(evt):
2897
- if self:
2898
- self.handler('shell_inactivated', self)
2899
- evt.Skip()
2900
- self.Bind(wx.EVT_KILL_FOCUS, inactivate)
2901
-
2902
2878
  def clear(evt):
2903
2879
  ## """Clear selection and message, no skip."""
2904
2880
  ## *DO NOT* clear autocomp, so that the event can skip to AutoComp properly.
@@ -2914,15 +2890,17 @@ class Nautilus(EditorInterface, Shell):
2914
2890
  """Fork events to the parent."""
2915
2891
  self.parent.handler(self.handler.current_event, evt)
2916
2892
 
2917
- self.handler.update({ # DNA<Nautilus>
2893
+ self.handler.update({ # DNA<Nautilus>
2918
2894
  None : {
2919
- 'interp_error' : [ None, self.on_interp_error ],
2920
- 'shell_deleted' : [ None, dispatch, self.on_shell_deleted ],
2921
- 'shell_modified' : [ None, dispatch ],
2922
- 'shell_activated' : [ None, dispatch, self.on_shell_activated ],
2923
- 'shell_inactivated' : [ None, dispatch, self.on_shell_inactivated ],
2895
+ 'interp_error' : [None, self.on_interp_error],
2896
+ 'focus_set' : [None, self.on_shell_activate],
2897
+ 'focus_kill' : [None, self.on_shell_inactivate],
2898
+ 'shell_deleted' : [None, dispatch, self.on_shell_deleted],
2899
+ 'shell_modified' : [None, dispatch],
2900
+ 'shell_activated' : [None, dispatch],
2901
+ 'shell_inactivated' : [None, dispatch],
2924
2902
  },
2925
- -1 : { # original action of the wx.py.shell
2903
+ -1 : { # original action of the wx.py.shell
2926
2904
  '* pressed' : (0, skip, self.on_exit_escmap),
2927
2905
  '*alt pressed' : (-1, ),
2928
2906
  '*ctrl pressed' : (-1, ),
@@ -2930,12 +2908,12 @@ class Nautilus(EditorInterface, Shell):
2930
2908
  '*[LR]win pressed' : (-1, ),
2931
2909
  '*f12 pressed' : (-2, self.on_exit_escmap, self.on_enter_notemode),
2932
2910
  },
2933
- -2 : { # Note mode
2911
+ -2 : { # Note mode
2934
2912
  'C-g pressed' : (0, self.on_exit_notemode),
2935
2913
  '*f12 pressed' : (0, self.on_exit_notemode),
2936
2914
  'escape pressed' : (0, self.on_exit_notemode),
2937
2915
  },
2938
- 0 : { # Normal mode
2916
+ 0 : { # Normal mode
2939
2917
  '* pressed' : (0, skip),
2940
2918
  '* released' : (0, skip, dispatch),
2941
2919
  '*button* pressed' : (0, skip, dispatch),
@@ -2975,7 +2953,7 @@ class Nautilus(EditorInterface, Shell):
2975
2953
  'M-, pressed' : (4, self.call_text_autocomp),
2976
2954
  'M-m pressed' : (5, self.call_module_autocomp),
2977
2955
  },
2978
- 1 : { # history auto completion S-mode
2956
+ 1 : { # history auto completion S-mode
2979
2957
  'quit' : (0, clear),
2980
2958
  'skip' : (0, self.on_indent_line),
2981
2959
  '* pressed' : (0, fork),
@@ -3000,7 +2978,7 @@ class Nautilus(EditorInterface, Shell):
3000
2978
  '*[LR]win pressed' : (1, ),
3001
2979
  '*f[0-9]* pressed' : (1, ),
3002
2980
  },
3003
- 2 : { # word auto completion AS-mode
2981
+ 2 : { # word auto completion AS-mode
3004
2982
  'quit' : (0, self.clear_autocomp),
3005
2983
  '* pressed' : (0, self.clear_autocomp, fork),
3006
2984
  'tab pressed' : (0, clear, skip),
@@ -3028,7 +3006,7 @@ class Nautilus(EditorInterface, Shell):
3028
3006
  '*[LR]win pressed' : (2, ),
3029
3007
  '*f[0-9]* pressed' : (2, ),
3030
3008
  },
3031
- 3 : { # apropos auto completion AS-mode
3009
+ 3 : { # apropos auto completion AS-mode
3032
3010
  'quit' : (0, self.clear_autocomp),
3033
3011
  '* pressed' : (0, self.clear_autocomp, fork),
3034
3012
  'tab pressed' : (0, clear, skip),
@@ -3056,7 +3034,7 @@ class Nautilus(EditorInterface, Shell):
3056
3034
  '*[LR]win pressed' : (3, ),
3057
3035
  '*f[0-9]* pressed' : (3, ),
3058
3036
  },
3059
- 4 : { # text auto completion AS-mode
3037
+ 4 : { # text auto completion AS-mode
3060
3038
  'quit' : (0, self.clear_autocomp),
3061
3039
  '* pressed' : (0, self.clear_autocomp, fork),
3062
3040
  'tab pressed' : (0, clear, skip),
@@ -3084,7 +3062,7 @@ class Nautilus(EditorInterface, Shell):
3084
3062
  '*[LR]win pressed' : (4, ),
3085
3063
  '*f[0-9]* pressed' : (4, ),
3086
3064
  },
3087
- 5 : { # module auto completion AS-mode
3065
+ 5 : { # module auto completion AS-mode
3088
3066
  'quit' : (0, self.clear_autocomp),
3089
3067
  '* pressed' : (0, self.clear_autocomp, fork),
3090
3068
  'tab pressed' : (0, clear, skip),
@@ -3134,7 +3112,7 @@ class Nautilus(EditorInterface, Shell):
3134
3112
  self.handler('shell_deleted', self)
3135
3113
  evt.Skip()
3136
3114
 
3137
- def OnUpdate(self, evt): #<wx._stc.StyledTextEvent>
3115
+ def OnUpdate(self, evt): # <wx._stc.StyledTextEvent>
3138
3116
  if evt.Updated & (stc.STC_UPDATE_SELECTION | stc.STC_UPDATE_CONTENT):
3139
3117
  self.trace_position()
3140
3118
  if self.handler.current_state == 0:
@@ -3409,8 +3387,8 @@ class Nautilus(EditorInterface, Shell):
3409
3387
  pass
3410
3388
  wx.CallAfter(_del)
3411
3389
 
3412
- def on_shell_activated(self, shell):
3413
- """Called when the shell:self is activated.
3390
+ def on_shell_activate(self, evt):
3391
+ """Called when the shell (self) is activated.
3414
3392
  Reset localvars assigned for the shell target. cf. target.setter.
3415
3393
  """
3416
3394
  self.trace_position()
@@ -3421,16 +3399,18 @@ class Nautilus(EditorInterface, Shell):
3421
3399
  obj.shell = self # Overwrite the facade <wx.py.shell.ShellFacade>
3422
3400
  except AttributeError:
3423
3401
  pass
3402
+ self.handler('shell_activated', self)
3424
3403
  self.parent.handler('title_window', obj)
3425
3404
 
3426
- def on_shell_inactivated(self, shell):
3427
- """Called when shell:self is inactivated.
3405
+ def on_shell_inactivate(self, evt):
3406
+ """Called when the shell (self) is inactivated.
3428
3407
  Remove target localvars assigned for the shell target.
3429
3408
  """
3430
3409
  if self.AutoCompActive():
3431
3410
  self.AutoCompCancel()
3432
3411
  if self.CallTipActive():
3433
3412
  self.CallTipCancel()
3413
+ self.handler('shell_inactivated', self)
3434
3414
 
3435
3415
  def on_text_input(self, text):
3436
3416
  """Called when [Enter] text (before push).
@@ -3455,9 +3435,9 @@ class Nautilus(EditorInterface, Shell):
3455
3435
  self.add_marker(ln, 1 if not err else 2) # 1:white-arrow 2:red-arrow
3456
3436
  return (not err)
3457
3437
 
3458
- def on_interp_error(self, e):
3438
+ def on_interp_error(self, value):
3459
3439
  ln = self.LineFromPosition(self.bolc)
3460
- self.red_pointer = ln + e.lineno - 1
3440
+ self.red_pointer = ln + value.lineno - 1
3461
3441
 
3462
3442
  ## --------------------------------
3463
3443
  ## Attributes of the shell.