mwxlib 1.4.20__py3-none-any.whl → 1.5.9__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.
Potentially problematic release.
This version of mwxlib might be problematic. Click here for more details.
- mwx/bookshelf.py +19 -13
- mwx/controls.py +10 -10
- mwx/framework.py +85 -71
- mwx/graphman.py +114 -121
- mwx/matplot2.py +13 -12
- mwx/matplot2g.py +22 -30
- mwx/matplot2lg.py +10 -10
- mwx/mgplt.py +1 -1
- mwx/nutshell.py +116 -97
- mwx/plugins/ffmpeg_view.py +3 -4
- mwx/plugins/fft_view.py +2 -2
- mwx/plugins/frame_listview.py +1 -1
- mwx/testsuite.py +10 -10
- mwx/utilus.py +31 -9
- mwx/wxpdb.py +3 -3
- {mwxlib-1.4.20.dist-info → mwxlib-1.5.9.dist-info}/METADATA +1 -1
- mwxlib-1.5.9.dist-info/RECORD +28 -0
- {mwxlib-1.4.20.dist-info → mwxlib-1.5.9.dist-info}/WHEEL +1 -1
- mwxlib-1.4.20.dist-info/RECORD +0 -28
- {mwxlib-1.4.20.dist-info → mwxlib-1.5.9.dist-info}/top_level.txt +0 -0
mwx/nutshell.py
CHANGED
|
@@ -27,7 +27,7 @@ from wx.py.shell import Shell
|
|
|
27
27
|
from wx.py.editwindow import EditWindow
|
|
28
28
|
|
|
29
29
|
from .utilus import funcall as _F
|
|
30
|
-
from .utilus import
|
|
30
|
+
from .utilus import typename
|
|
31
31
|
from .utilus import split_words, split_parts, split_tokens, find_modules
|
|
32
32
|
from .framework import CtrlInterface, AuiNotebook, Menu
|
|
33
33
|
|
|
@@ -54,6 +54,7 @@ py_break_re = r'at ([^*?"<>|\r\n]+?):([0-9]+)'
|
|
|
54
54
|
stc.STC_STYLE_CARETLINE = 40
|
|
55
55
|
stc.STC_STYLE_ANNOTATION = 41
|
|
56
56
|
|
|
57
|
+
|
|
57
58
|
class Stylus:
|
|
58
59
|
py_log_mode = {
|
|
59
60
|
stc.STC_STYLE_DEFAULT : "fore:#7f7f7f,back:#ffffb8,size:9,face:MS Gothic",
|
|
@@ -338,7 +339,7 @@ class AutoCompInterfaceMixin:
|
|
|
338
339
|
## ls = [x for x in self.fragmwords if x.startswith(hint)] # case-sensitive match
|
|
339
340
|
q = hint.lower()
|
|
340
341
|
ls = [x for x in self.fragmwords if x.lower().startswith(q)] # case-insensitive match
|
|
341
|
-
words = sorted(ls, key=lambda s:s.upper())
|
|
342
|
+
words = sorted(ls, key=lambda s: s.upper())
|
|
342
343
|
|
|
343
344
|
self._gen_autocomp(0, hint, words)
|
|
344
345
|
self.message("[text] {} candidates matched"
|
|
@@ -396,7 +397,7 @@ class AutoCompInterfaceMixin:
|
|
|
396
397
|
|
|
397
398
|
P = re.compile(hint)
|
|
398
399
|
p = re.compile(hint, re.I)
|
|
399
|
-
words = sorted([x for x in modules if p.match(x)], key=lambda s:s.upper())
|
|
400
|
+
words = sorted([x for x in modules if p.match(x)], key=lambda s: s.upper())
|
|
400
401
|
|
|
401
402
|
j = next((k for k, w in enumerate(words) if P.match(w)),
|
|
402
403
|
next((k for k, w in enumerate(words) if p.match(w)), -1))
|
|
@@ -428,7 +429,7 @@ class AutoCompInterfaceMixin:
|
|
|
428
429
|
obj = self.eval(text)
|
|
429
430
|
P = re.compile(hint)
|
|
430
431
|
p = re.compile(hint, re.I)
|
|
431
|
-
words = sorted([x for x in dir(obj) if p.match(x)], key=lambda s:s.upper())
|
|
432
|
+
words = sorted([x for x in dir(obj) if p.match(x)], key=lambda s: s.upper())
|
|
432
433
|
|
|
433
434
|
j = next((k for k, w in enumerate(words) if P.match(w)),
|
|
434
435
|
next((k for k, w in enumerate(words) if p.match(w)), -1))
|
|
@@ -460,7 +461,7 @@ class AutoCompInterfaceMixin:
|
|
|
460
461
|
obj = self.eval(text)
|
|
461
462
|
P = re.compile(hint)
|
|
462
463
|
p = re.compile(hint, re.I)
|
|
463
|
-
words = sorted([x for x in dir(obj) if p.search(x)], key=lambda s:s.upper())
|
|
464
|
+
words = sorted([x for x in dir(obj) if p.search(x)], key=lambda s: s.upper())
|
|
464
465
|
|
|
465
466
|
j = next((k for k, w in enumerate(words) if P.match(w)),
|
|
466
467
|
next((k for k, w in enumerate(words) if p.match(w)), -1))
|
|
@@ -513,15 +514,15 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
513
514
|
'C-e pressed' : (0, _F(self.end_of_line)),
|
|
514
515
|
'M-a pressed' : (0, _F(self.back_to_indentation)),
|
|
515
516
|
'M-e pressed' : (0, _F(self.end_of_line)),
|
|
516
|
-
'M-g pressed' : (0, ask(self.goto_line, "Line to goto:", lambda x:int(x)-1),
|
|
517
|
+
'M-g pressed' : (0, ask(self.goto_line, "Line to goto:", lambda x: int(x)-1),
|
|
517
518
|
_F(self.recenter)),
|
|
518
519
|
'M-f pressed' : (10, _F(self.filter_text), self.on_itext_enter),
|
|
519
520
|
'C-k pressed' : (0, _F(self.kill_line)),
|
|
520
521
|
'C-S-c pressed' : (0, _F(self.Copy)),
|
|
521
522
|
'C-S-v pressed' : (0, _F(self.Paste)),
|
|
522
523
|
'C-l pressed' : (0, _F(self.recenter)),
|
|
523
|
-
'C-S-l pressed' : (0, _F(self.recenter)), # overrides delete-line
|
|
524
|
-
'C-S-f pressed' : (0, _F(self.set_mark)), # overrides mark
|
|
524
|
+
## 'C-S-l pressed' : (0, _F(self.recenter)), # overrides delete-line
|
|
525
|
+
## 'C-S-f pressed' : (0, _F(self.set_mark)), # overrides mark
|
|
525
526
|
'C-space pressed' : (0, _F(self.set_mark)),
|
|
526
527
|
'C-S-space pressed' : (0, _F(self.set_pointer)),
|
|
527
528
|
'C-backspace pressed' : (0, _F(self.backward_kill_word)),
|
|
@@ -778,23 +779,23 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
778
779
|
|
|
779
780
|
white_arrow = property(
|
|
780
781
|
lambda self: self.get_marker(1),
|
|
781
|
-
lambda self,v: self.set_marker(v, 1),
|
|
782
|
-
lambda self: self.del_marker(1))
|
|
782
|
+
lambda self, v: self.set_marker(v, 1), # [arrow_set]
|
|
783
|
+
lambda self: self.del_marker(1)) # [arrow_unset]
|
|
783
784
|
|
|
784
785
|
red_arrow = property(
|
|
785
786
|
lambda self: self.get_marker(2),
|
|
786
|
-
lambda self,v: self.set_marker(v, 2),
|
|
787
|
-
lambda self: self.del_marker(2))
|
|
787
|
+
lambda self, v: self.set_marker(v, 2), # [red-arrow_set]
|
|
788
|
+
lambda self: self.del_marker(2)) # [red-arrow_unset]
|
|
788
789
|
|
|
789
790
|
pointer = property(
|
|
790
791
|
lambda self: self.get_marker(3),
|
|
791
|
-
lambda self,v: self.set_marker(v, 3),
|
|
792
|
-
lambda self: self.del_marker(3))
|
|
792
|
+
lambda self, v: self.set_marker(v, 3), # [pointer_set]
|
|
793
|
+
lambda self: self.del_marker(3)) # [pointer_unset]
|
|
793
794
|
|
|
794
795
|
red_pointer = property(
|
|
795
796
|
lambda self: self.get_marker(4),
|
|
796
|
-
lambda self,v: self.set_marker(v, 4),
|
|
797
|
-
lambda self: self.del_marker(4))
|
|
797
|
+
lambda self, v: self.set_marker(v, 4), # [red-pointer_set]
|
|
798
|
+
lambda self: self.del_marker(4)) # [red-pointer_unset]
|
|
798
799
|
|
|
799
800
|
@property
|
|
800
801
|
def markline(self):
|
|
@@ -908,15 +909,15 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
908
909
|
|
|
909
910
|
anchor = property(
|
|
910
911
|
lambda self: self.GetAnchor(),
|
|
911
|
-
lambda self,v: self.SetAnchor(v))
|
|
912
|
+
lambda self, v: self.SetAnchor(v))
|
|
912
913
|
|
|
913
914
|
cpos = property(
|
|
914
915
|
lambda self: self.GetCurrentPos(),
|
|
915
|
-
lambda self,v: self.SetCurrentPos(v))
|
|
916
|
+
lambda self, v: self.SetCurrentPos(v))
|
|
916
917
|
|
|
917
918
|
cline = property(
|
|
918
919
|
lambda self: self.GetCurrentLine(),
|
|
919
|
-
lambda self,v: self.SetCurrentPos(self.PositionFromLine(v)))
|
|
920
|
+
lambda self, v: self.SetCurrentPos(self.PositionFromLine(v)))
|
|
920
921
|
|
|
921
922
|
@property
|
|
922
923
|
def bol(self):
|
|
@@ -972,12 +973,12 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
972
973
|
return topic
|
|
973
974
|
with self.save_excursion():
|
|
974
975
|
p = q = self.cpos
|
|
975
|
-
|
|
976
|
-
if
|
|
976
|
+
cp = self.GetTextRange(self.PositionBefore(p), p) # cf. self.get_char(p-1)
|
|
977
|
+
if cp.isidentifier() or cp.isalnum():
|
|
977
978
|
self.WordLeft()
|
|
978
979
|
p = self.cpos
|
|
979
|
-
|
|
980
|
-
if
|
|
980
|
+
cq = self.GetTextRange(q, self.PositionAfter(q)) # cf. self.get_char(q)
|
|
981
|
+
if cq.isidentifier() or cq.isalnum():
|
|
981
982
|
self.WordRightEnd()
|
|
982
983
|
q = self.cpos
|
|
983
984
|
return self.GetTextRange(p, q)
|
|
@@ -1322,22 +1323,26 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
1322
1323
|
if not hl + offset < vl < hl + n - 1 - offset:
|
|
1323
1324
|
self.ScrollToLine(vl - n//2)
|
|
1324
1325
|
|
|
1325
|
-
|
|
1326
|
+
## --------------------------------
|
|
1327
|
+
## Search functions
|
|
1328
|
+
## --------------------------------
|
|
1329
|
+
|
|
1330
|
+
def DoFindNext(self, findData):
|
|
1326
1331
|
"""Find the search text defined in `findData`.
|
|
1327
1332
|
|
|
1328
1333
|
If found, selects the matched text and scrolls to its line.
|
|
1329
1334
|
Typically called from `wx.EVT_FIND` event handlers.
|
|
1330
1335
|
|
|
1331
|
-
(override) Enables
|
|
1332
|
-
Returns
|
|
1336
|
+
(override) Enables whole word search.
|
|
1337
|
+
Returns the match position if found, -1 otherwise.
|
|
1333
1338
|
"""
|
|
1334
1339
|
flags = 0
|
|
1335
|
-
if findData.Flags & wx.FR_MATCHCASE: flags |=
|
|
1336
|
-
if findData.Flags & wx.FR_WHOLEWORD: flags |=
|
|
1340
|
+
if findData.Flags & wx.FR_MATCHCASE: flags |= stc.STC_FIND_MATCHCASE
|
|
1341
|
+
if findData.Flags & wx.FR_WHOLEWORD: flags |= stc.STC_FIND_WHOLEWORD
|
|
1337
1342
|
self.SetSearchFlags(flags)
|
|
1338
1343
|
|
|
1339
1344
|
backward = not (findData.Flags & wx.FR_DOWN)
|
|
1340
|
-
findstring = findData.FindString
|
|
1345
|
+
findstring = findData.FindString.encode()
|
|
1341
1346
|
if backward:
|
|
1342
1347
|
self.TargetStart = self.anchor # backward anchor
|
|
1343
1348
|
self.TargetEnd = 0
|
|
@@ -1353,20 +1358,37 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
1353
1358
|
|
|
1354
1359
|
## Was it still not found?
|
|
1355
1360
|
if loc == -1:
|
|
1356
|
-
wx.MessageBox("Unable to find the search text.",
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
return True
|
|
1361
|
+
## wx.MessageBox("Unable to find the search text any more.",
|
|
1362
|
+
## "Not found!", wx.OK|wx.ICON_INFORMATION)
|
|
1363
|
+
wx.Bell()
|
|
1364
|
+
pass
|
|
1365
|
+
else:
|
|
1366
|
+
self.SetSelection(loc, loc + len(findstring))
|
|
1367
|
+
self.EnsureVisible(self.cline) # expand if folded
|
|
1368
|
+
self.EnsureCaretVisible()
|
|
1369
|
+
return loc
|
|
1366
1370
|
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1371
|
+
def DoReplaceNext(self, findData):
|
|
1372
|
+
if self.SelectedText == findData.FindString:
|
|
1373
|
+
if self.CanEdit():
|
|
1374
|
+
self.ReplaceSelection(findData.ReplaceString)
|
|
1375
|
+
return self.DoFindNext(findData)
|
|
1376
|
+
|
|
1377
|
+
def DoReplaceAll(self, findData):
|
|
1378
|
+
with self.save_excursion():
|
|
1379
|
+
locs = [-1]
|
|
1380
|
+
count = 0
|
|
1381
|
+
while 1:
|
|
1382
|
+
loc = self.DoFindNext(findData)
|
|
1383
|
+
if loc in locs:
|
|
1384
|
+
break
|
|
1385
|
+
locs.append(loc)
|
|
1386
|
+
self.TargetStart = self.anchor
|
|
1387
|
+
self.TargetEnd = self.cpos
|
|
1388
|
+
if self.CanEdit():
|
|
1389
|
+
self.ReplaceTarget(findData.ReplaceString)
|
|
1390
|
+
count += 1
|
|
1391
|
+
return count
|
|
1370
1392
|
|
|
1371
1393
|
def get_right_paren(self, p):
|
|
1372
1394
|
if self.get_char(p) in "({[<": # left-parentheses, <
|
|
@@ -1453,21 +1475,6 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
1453
1475
|
def grep(self, pattern, flags=re.M):
|
|
1454
1476
|
yield from re.finditer(pattern.encode(), self.TextRaw, flags)
|
|
1455
1477
|
|
|
1456
|
-
def search_text(self, text, mode=True):
|
|
1457
|
-
"""Yields positions where `text` is found.
|
|
1458
|
-
If mode is True, search by word; otherwise, search by string.
|
|
1459
|
-
"""
|
|
1460
|
-
text = text.encode()
|
|
1461
|
-
pos = -1
|
|
1462
|
-
p = re.compile(r"[a-zA-Z0-9_]")
|
|
1463
|
-
while 1:
|
|
1464
|
-
pos = self.TextRaw.find(text, pos+1)
|
|
1465
|
-
if pos < 0:
|
|
1466
|
-
break
|
|
1467
|
-
if mode and p.search(self.get_char(pos-1) + self.get_char(pos+len(text))):
|
|
1468
|
-
continue
|
|
1469
|
-
yield pos
|
|
1470
|
-
|
|
1471
1478
|
def filter_text(self):
|
|
1472
1479
|
"""Show indicators for the selected text."""
|
|
1473
1480
|
self.__itextlines = []
|
|
@@ -1478,14 +1485,18 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
1478
1485
|
if not text:
|
|
1479
1486
|
self.message("No words")
|
|
1480
1487
|
return
|
|
1481
|
-
wholeword = (not self.SelectedText
|
|
1482
|
-
|
|
1488
|
+
wholeword = (not self.SelectedText # Enable or disable whole word search.
|
|
1489
|
+
and text.isascii()) # whole word search is for ascii only. (単語境界が不明確のため)
|
|
1490
|
+
pattern = re.escape(text)
|
|
1491
|
+
if wholeword:
|
|
1492
|
+
pattern = rf"\b{pattern}\b"
|
|
1483
1493
|
lines = []
|
|
1484
|
-
for
|
|
1494
|
+
for m in self.grep(pattern):
|
|
1495
|
+
p, q = m.span()
|
|
1485
1496
|
lines.append(self.LineFromPosition(p))
|
|
1486
1497
|
for i in (10, 11,):
|
|
1487
1498
|
self.SetIndicatorCurrent(i)
|
|
1488
|
-
self.IndicatorFillRange(p,
|
|
1499
|
+
self.IndicatorFillRange(p, q-p)
|
|
1489
1500
|
self.__itextlines = sorted(set(lines)) # keep order, no duplication
|
|
1490
1501
|
self.message("{}: {} found".format(text, len(lines)))
|
|
1491
1502
|
try:
|
|
@@ -1800,7 +1811,7 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
1800
1811
|
"""
|
|
1801
1812
|
self.eat_white_forward()
|
|
1802
1813
|
_text, lp = self.CurLine
|
|
1803
|
-
for
|
|
1814
|
+
for _i in range(lp % 4 or 4):
|
|
1804
1815
|
p = self.cpos
|
|
1805
1816
|
if p == self.bol or self.get_char(p-1) != ' ':
|
|
1806
1817
|
break
|
|
@@ -1952,9 +1963,9 @@ class Buffer(EditorInterface, EditWindow):
|
|
|
1952
1963
|
None : {
|
|
1953
1964
|
'buffer_saved' : [ None, dispatch ],
|
|
1954
1965
|
'buffer_loaded' : [ None, dispatch ],
|
|
1955
|
-
'buffer_modified' : [ None, dispatch, self.
|
|
1956
|
-
'buffer_activated' : [ None, dispatch, self.
|
|
1957
|
-
'buffer_inactivated' : [ None, dispatch, self.
|
|
1966
|
+
'buffer_modified' : [ None, dispatch, self.on_buffer_modified ],
|
|
1967
|
+
'buffer_activated' : [ None, dispatch, self.on_buffer_activated ],
|
|
1968
|
+
'buffer_inactivated' : [ None, dispatch, self.on_buffer_inactivated ],
|
|
1958
1969
|
'buffer_region_executed' : [ None, dispatch ],
|
|
1959
1970
|
},
|
|
1960
1971
|
-1 : { # original action of the EditWindow
|
|
@@ -2079,7 +2090,7 @@ class Buffer(EditorInterface, EditWindow):
|
|
|
2079
2090
|
## Note: post-call for the confirmation dialog.
|
|
2080
2091
|
wx.CallAfter(self.parent.load_file, url)
|
|
2081
2092
|
|
|
2082
|
-
def
|
|
2093
|
+
def on_buffer_modified(self, buf):
|
|
2083
2094
|
"""Called when the buffer is modified."""
|
|
2084
2095
|
self.SetIndicatorCurrent(2)
|
|
2085
2096
|
self.IndicatorClearRange(0, self.TextLength)
|
|
@@ -2106,12 +2117,12 @@ class Buffer(EditorInterface, EditWindow):
|
|
|
2106
2117
|
self.handler('quit', evt) # don't enter autocomp
|
|
2107
2118
|
evt.Skip()
|
|
2108
2119
|
|
|
2109
|
-
def
|
|
2120
|
+
def on_buffer_activated(self, buf):
|
|
2110
2121
|
"""Called when the buffer is activated."""
|
|
2111
2122
|
self.update_caption()
|
|
2112
2123
|
self.trace_position()
|
|
2113
2124
|
|
|
2114
|
-
def
|
|
2125
|
+
def on_buffer_inactivated(self, buf):
|
|
2115
2126
|
"""Called when the buffer is inactivated."""
|
|
2116
2127
|
pass
|
|
2117
2128
|
|
|
@@ -2279,9 +2290,8 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2279
2290
|
## So we set the tabs' height to zero to hide them.
|
|
2280
2291
|
self.TabCtrlHeight = 0
|
|
2281
2292
|
|
|
2282
|
-
self.defaultBufferStyle =
|
|
2283
|
-
|
|
2284
|
-
)
|
|
2293
|
+
self.defaultBufferStyle = {}
|
|
2294
|
+
|
|
2285
2295
|
self.parent = parent #: parent<ShellFrame> is not Parent<AuiNotebook>
|
|
2286
2296
|
self.Name = name
|
|
2287
2297
|
self.default_name = "*{}*".format(name.lower()) # e.g. '*scratch*'
|
|
@@ -2306,8 +2316,8 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2306
2316
|
'buffer_loaded' : [ None, dispatch ],
|
|
2307
2317
|
'buffer_deleted' : [ None, dispatch ],
|
|
2308
2318
|
'buffer_modified' : [ None, dispatch ],
|
|
2309
|
-
'buffer_activated' : [ None, dispatch, self.
|
|
2310
|
-
'buffer_inactivated' : [ None, dispatch, self.
|
|
2319
|
+
'buffer_activated' : [ None, dispatch, self.on_buffer_activated ],
|
|
2320
|
+
'buffer_inactivated' : [ None, dispatch, self.on_buffer_inactivated ],
|
|
2311
2321
|
'buffer_caption_updated' : [ None, dispatch ],
|
|
2312
2322
|
},
|
|
2313
2323
|
0 : { # Normal mode
|
|
@@ -2373,12 +2383,12 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2373
2383
|
for buf in self.get_all_buffers():
|
|
2374
2384
|
_setattribute(buf, self.defaultBufferStyle)
|
|
2375
2385
|
|
|
2376
|
-
def
|
|
2386
|
+
def on_buffer_activated(self, buf):
|
|
2377
2387
|
"""Called when the buffer is activated."""
|
|
2378
2388
|
title = "{} file: {}".format(self.Name, buf.filename)
|
|
2379
2389
|
self.parent.handler('title_window', title)
|
|
2380
2390
|
|
|
2381
|
-
def
|
|
2391
|
+
def on_buffer_inactivated(self, buf):
|
|
2382
2392
|
"""Called when the buffer is inactivated."""
|
|
2383
2393
|
pass
|
|
2384
2394
|
|
|
@@ -2444,7 +2454,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2444
2454
|
"""Create a new default buffer."""
|
|
2445
2455
|
buf = self.default_buffer
|
|
2446
2456
|
if not buf or buf.mtdelta is not None: # is saved?
|
|
2447
|
-
buf = self.create_buffer(self.default_name
|
|
2457
|
+
buf = self.create_buffer(self.default_name)
|
|
2448
2458
|
self.default_buffer = buf
|
|
2449
2459
|
else:
|
|
2450
2460
|
buf.ClearAll()
|
|
@@ -2803,7 +2813,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
2803
2813
|
"""Reset the shell target object; Rename the parent title.
|
|
2804
2814
|
"""
|
|
2805
2815
|
if not hasattr(obj, '__dict__'):
|
|
2806
|
-
raise TypeError("
|
|
2816
|
+
raise TypeError("invalid target")
|
|
2807
2817
|
|
|
2808
2818
|
self.__target = obj
|
|
2809
2819
|
self.locals = obj.__dict__
|
|
@@ -2812,7 +2822,8 @@ class Nautilus(EditorInterface, Shell):
|
|
|
2812
2822
|
try:
|
|
2813
2823
|
obj.self = obj
|
|
2814
2824
|
obj.this = inspect.getmodule(obj)
|
|
2815
|
-
obj.shell = self
|
|
2825
|
+
obj.shell = self # Overwrite the facade <wx.py.shell.ShellFacade>.
|
|
2826
|
+
obj.__name__ = typename(obj) # A namespace for ghost in the shell. cf. exec_region
|
|
2816
2827
|
except AttributeError:
|
|
2817
2828
|
pass
|
|
2818
2829
|
self.parent.handler('title_window', obj)
|
|
@@ -2901,10 +2912,10 @@ class Nautilus(EditorInterface, Shell):
|
|
|
2901
2912
|
self.handler.update({ # DNA<Nautilus>
|
|
2902
2913
|
None : {
|
|
2903
2914
|
'interp_error' : [ None, self.on_interp_error ],
|
|
2904
|
-
'shell_deleted' : [ None, dispatch, self.
|
|
2915
|
+
'shell_deleted' : [ None, dispatch, self.on_shell_deleted ],
|
|
2905
2916
|
'shell_modified' : [ None, dispatch ],
|
|
2906
|
-
'shell_activated' : [ None, dispatch, self.
|
|
2907
|
-
'shell_inactivated' : [ None, dispatch, self.
|
|
2917
|
+
'shell_activated' : [ None, dispatch, self.on_shell_activated ],
|
|
2918
|
+
'shell_inactivated' : [ None, dispatch, self.on_shell_inactivated ],
|
|
2908
2919
|
},
|
|
2909
2920
|
-1 : { # original action of the wx.py.shell
|
|
2910
2921
|
'* pressed' : (0, skip, self.on_exit_escmap),
|
|
@@ -3186,7 +3197,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3186
3197
|
if text[:lp] == sys.ps2:
|
|
3187
3198
|
self.cpos -= lp # Select ps2:prompt
|
|
3188
3199
|
self.WordLeftExtend() # Select cr/lf chunks
|
|
3189
|
-
else:
|
|
3200
|
+
else:
|
|
3190
3201
|
q = max(self.bol, self.bolc) # for debugger mode: bol <= bolc
|
|
3191
3202
|
if self.cpos > q:
|
|
3192
3203
|
self.cpos = q
|
|
@@ -3248,9 +3259,9 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3248
3259
|
def on_exit_escmap(self, evt):
|
|
3249
3260
|
self.CaretPeriod = self.__caret_mode
|
|
3250
3261
|
self.message("ESC {}".format(evt.key))
|
|
3251
|
-
if self.eolc < self.bolc:
|
|
3262
|
+
if self.eolc < self.bolc: # Check if prompt is in valid state.
|
|
3252
3263
|
self.goto_char(self.eolc)
|
|
3253
|
-
self.promptPosEnd = 0
|
|
3264
|
+
self.promptPosEnd = 0 # Enabale write(prompt).
|
|
3254
3265
|
self.prompt()
|
|
3255
3266
|
self.AnnotationClearAll()
|
|
3256
3267
|
|
|
@@ -3264,7 +3275,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3264
3275
|
self.noteMode = False
|
|
3265
3276
|
self.CaretForeground = self.__caret_mode
|
|
3266
3277
|
self.goto_char(self.eolc)
|
|
3267
|
-
self.promptPosEnd = 0
|
|
3278
|
+
self.promptPosEnd = 0 # Enabale write(prompt).
|
|
3268
3279
|
self.prompt()
|
|
3269
3280
|
self.message("")
|
|
3270
3281
|
|
|
@@ -3380,7 +3391,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3380
3391
|
lhs += c # store in lhs; no more processing
|
|
3381
3392
|
return lhs
|
|
3382
3393
|
|
|
3383
|
-
def
|
|
3394
|
+
def on_shell_deleted(self, shell):
|
|
3384
3395
|
"""Called before shell:self is killed.
|
|
3385
3396
|
Delete target shell to prevent referencing the dead shell.
|
|
3386
3397
|
"""
|
|
@@ -3393,21 +3404,21 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3393
3404
|
pass
|
|
3394
3405
|
wx.CallAfter(_del)
|
|
3395
3406
|
|
|
3396
|
-
def
|
|
3407
|
+
def on_shell_activated(self, shell):
|
|
3397
3408
|
"""Called when the shell:self is activated.
|
|
3398
|
-
Reset localvars assigned for the shell target.
|
|
3409
|
+
Reset localvars assigned for the shell target. cf. target.setter.
|
|
3399
3410
|
"""
|
|
3400
3411
|
self.trace_position()
|
|
3401
3412
|
obj = self.target
|
|
3402
3413
|
try:
|
|
3403
3414
|
obj.self = obj
|
|
3404
3415
|
obj.this = inspect.getmodule(obj)
|
|
3405
|
-
obj.shell = self
|
|
3416
|
+
obj.shell = self # Overwrite the facade <wx.py.shell.ShellFacade>
|
|
3406
3417
|
except AttributeError:
|
|
3407
3418
|
pass
|
|
3408
3419
|
self.parent.handler('title_window', obj)
|
|
3409
3420
|
|
|
3410
|
-
def
|
|
3421
|
+
def on_shell_inactivated(self, shell):
|
|
3411
3422
|
"""Called when shell:self is inactivated.
|
|
3412
3423
|
Remove target localvars assigned for the shell target.
|
|
3413
3424
|
"""
|
|
@@ -3554,14 +3565,26 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3554
3565
|
## shell.__init__ よりも先に実行される
|
|
3555
3566
|
pass
|
|
3556
3567
|
|
|
3568
|
+
def setBuiltinKeywords(self):
|
|
3569
|
+
"""Create pseudo keywords as part of builtins.
|
|
3570
|
+
|
|
3571
|
+
(override) Don't add `close`, `exit` and `quit` to builtins.
|
|
3572
|
+
"""
|
|
3573
|
+
from wx.py.path import ls, cd, pwd, sx
|
|
3574
|
+
builtins.cd = cd
|
|
3575
|
+
builtins.ls = ls
|
|
3576
|
+
builtins.pwd = pwd
|
|
3577
|
+
builtins.sx = sx
|
|
3578
|
+
|
|
3557
3579
|
def execStartupScript(self, su):
|
|
3558
3580
|
"""Execute the user's PYTHONSTARTUP script if they have one.
|
|
3559
3581
|
|
|
3560
3582
|
(override) Add globals when executing su:startupScript.
|
|
3561
|
-
|
|
3583
|
+
Don't add '_f' to globals when executing su:startupScript.
|
|
3584
|
+
Don't add intro text in the history.
|
|
3562
3585
|
"""
|
|
3563
|
-
keys = set(self.locals.keys())
|
|
3564
|
-
self.promptPosEnd = self.TextLength
|
|
3586
|
+
keys = set(self.locals.keys()) # to check for locals map changes.
|
|
3587
|
+
self.promptPosEnd = self.TextLength # Fix history point
|
|
3565
3588
|
if su and os.path.isfile(su):
|
|
3566
3589
|
self.push("print('Startup script executed:', {0!r})\n".format(su))
|
|
3567
3590
|
self.push("with open({0!r}) as _f: exec(_f.read())\n".format(su))
|
|
@@ -3703,10 +3726,6 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3703
3726
|
self.write(cmd)
|
|
3704
3727
|
self.processLine()
|
|
3705
3728
|
|
|
3706
|
-
## --------------------------------
|
|
3707
|
-
## Autocomp actions of the shell
|
|
3708
|
-
## --------------------------------
|
|
3709
|
-
|
|
3710
3729
|
def eval_line(self):
|
|
3711
3730
|
"""Evaluate the selected word or line and show calltips."""
|
|
3712
3731
|
if self.CallTipActive():
|
mwx/plugins/ffmpeg_view.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#! python3
|
|
2
2
|
"""FFmpeg wrapper.
|
|
3
3
|
"""
|
|
4
|
-
from functools import partial
|
|
5
4
|
from subprocess import Popen, PIPE
|
|
6
5
|
import numpy as np
|
|
7
6
|
import os
|
|
@@ -151,9 +150,9 @@ class Plugin(Layer):
|
|
|
151
150
|
},
|
|
152
151
|
})
|
|
153
152
|
|
|
154
|
-
self.mc.Bind(wx.media.EVT_MEDIA_PAUSE,
|
|
155
|
-
self.mc.Bind(wx.media.EVT_MEDIA_PLAY,
|
|
156
|
-
self.mc.Bind(wx.media.EVT_MEDIA_STOP,
|
|
153
|
+
self.mc.Bind(wx.media.EVT_MEDIA_PAUSE, lambda v: self.handler('pause', v))
|
|
154
|
+
self.mc.Bind(wx.media.EVT_MEDIA_PLAY, lambda v: self.handler('play', v))
|
|
155
|
+
self.mc.Bind(wx.media.EVT_MEDIA_STOP, lambda v: self.handler('stop', v))
|
|
157
156
|
|
|
158
157
|
self.mc.Bind(wx.EVT_KEY_DOWN, self.on_hotkey_down)
|
|
159
158
|
self.mc.Bind(wx.EVT_KEY_UP, self.on_hotkey_up)
|
mwx/plugins/fft_view.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"""
|
|
4
4
|
import wx
|
|
5
5
|
import numpy as np
|
|
6
|
-
from numpy.fft import fft2,ifft2,fftshift,ifftshift
|
|
6
|
+
from numpy.fft import fft2, ifft2, fftshift, ifftshift
|
|
7
7
|
|
|
8
8
|
from mwx.graphman import Layer
|
|
9
9
|
from mwx.controls import Param
|
|
@@ -74,7 +74,7 @@ class Plugin(Layer):
|
|
|
74
74
|
|
|
75
75
|
if self.ftor.check:
|
|
76
76
|
y, x = np.ogrid[-h/2:h/2, -w/2:w/2]
|
|
77
|
-
mask = np.hypot(y,x) > w / self.ftor.value
|
|
77
|
+
mask = np.hypot(y, x) > w / self.ftor.value
|
|
78
78
|
src = src.copy() # apply mask to the copy
|
|
79
79
|
src[mask] = 0
|
|
80
80
|
|
mwx/plugins/frame_listview.py
CHANGED
mwx/testsuite.py
CHANGED
|
@@ -17,7 +17,7 @@ Is equivalent to:
|
|
|
17
17
|
from contextlib import contextmanager
|
|
18
18
|
import wx
|
|
19
19
|
|
|
20
|
-
__all__ = ["testApp", "testFrame", "
|
|
20
|
+
__all__ = ["testApp", "testFrame", "testPlugin", "testPanel"]
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
@contextmanager
|
|
@@ -38,15 +38,6 @@ def testFrame(**kwargs):
|
|
|
38
38
|
## wx.Frame.run = staticmethod(testFrame)
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
@contextmanager
|
|
42
|
-
def Plugman(**kwargs):
|
|
43
|
-
import mwx.graphman
|
|
44
|
-
with testApp():
|
|
45
|
-
frm = mwx.graphman.Frame(None, **kwargs)
|
|
46
|
-
yield frm
|
|
47
|
-
frm.Show()
|
|
48
|
-
|
|
49
|
-
|
|
50
41
|
@contextmanager
|
|
51
42
|
def testPanel(**kwargs):
|
|
52
43
|
import mwx
|
|
@@ -56,3 +47,12 @@ def testPanel(**kwargs):
|
|
|
56
47
|
yield panel
|
|
57
48
|
panel.Sizer.Fit(frm)
|
|
58
49
|
frm.Show()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@contextmanager
|
|
53
|
+
def testPlugin(**kwargs):
|
|
54
|
+
import mwx.graphman
|
|
55
|
+
with testApp():
|
|
56
|
+
frm = mwx.graphman.Frame(None, **kwargs)
|
|
57
|
+
yield frm
|
|
58
|
+
frm.Show()
|