pymud 0.21.0a5__py3-none-any.whl → 0.21.2a1__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.
- pymud/extras.py +461 -449
- pymud/lang/i18n_chs.py +3 -0
- pymud/lang/i18n_eng.py +7 -3
- pymud/pymud.py +44 -50
- pymud/session.py +180 -44
- pymud/settings.py +1 -1
- {pymud-0.21.0a5.dist-info → pymud-0.21.2a1.dist-info}/METADATA +71 -27
- {pymud-0.21.0a5.dist-info → pymud-0.21.2a1.dist-info}/RECORD +12 -12
- {pymud-0.21.0a5.dist-info → pymud-0.21.2a1.dist-info}/WHEEL +1 -1
- {pymud-0.21.0a5.dist-info → pymud-0.21.2a1.dist-info}/entry_points.txt +0 -0
- {pymud-0.21.0a5.dist-info → pymud-0.21.2a1.dist-info}/licenses/LICENSE.txt +0 -0
- {pymud-0.21.0a5.dist-info → pymud-0.21.2a1.dist-info}/top_level.txt +0 -0
pymud/lang/i18n_chs.py
CHANGED
@@ -133,6 +133,9 @@ TRANSLATION = {
|
|
133
133
|
"msg_object_enabled" : "对象 {0} 的使能状态已打开。",
|
134
134
|
"msg_object_disabled" : "对象 {0} 的使能状态已关闭。",
|
135
135
|
"msg_object_deleted" : "对象 {0} 已从会话中被删除。",
|
136
|
+
"msg_group_objects_enabled" : "组 {0} 中的 {1} 个 {2} 对象均已使能。",
|
137
|
+
"msg_group_objects_disabled" : "组 {0} 中的 {1} 个 {2} 对象均已禁用。",
|
138
|
+
"msg_group_objects_deleted" : "组 {0} 中的 {1} 个 {2} 对象均已从会话中被删除。",
|
136
139
|
"msg_object_param_invalid" : "#{0}命令的第二个参数仅能接受on/off/del",
|
137
140
|
"msg_ignore_on" : "所有触发器使能已全局禁用。",
|
138
141
|
"msg_ignore_off" : "不再全局禁用所有触发器使能。",
|
pymud/lang/i18n_eng.py
CHANGED
@@ -132,6 +132,9 @@ TRANSLATION = {
|
|
132
132
|
"msg_object_enabled" : "Object {0} enabled status is now on.",
|
133
133
|
"msg_object_disabled" : "Object {0} enabled status is now off.",
|
134
134
|
"msg_object_deleted" : "Object {0} has been deleted from session.",
|
135
|
+
"msg_group_objects_enabled" : "{1} object(s) of Type {2} in group {1} has(have) been enabled.",
|
136
|
+
"msg_group_objects_disabled" : "{1} object(s) of Type {2} in group {1} has(have) been disabled.",
|
137
|
+
"msg_group_objects_deleted" : "{1} object(s) of Type {2} in group {1} has(have) been deleted.",
|
135
138
|
"msg_object_param_invalid" : "#{0} command's second parameter only accepts on/off/del",
|
136
139
|
"msg_ignore_on" : "All trigger enables are globally disabled.",
|
137
140
|
"msg_ignore_off" : "No longer globally disable all trigger enables.",
|
@@ -334,16 +337,17 @@ TRANSLATION = {
|
|
334
337
|
|
335
338
|
Usage:
|
336
339
|
- #ig: Toggle the global enable/disable status of triggers.
|
337
|
-
- #t+ {group}: Enable all objects in the {group} group, including aliases, triggers, commands, timers, GMCP triggers, etc.
|
338
|
-
- #t- {group}: Disable all objects in the {group} group, including aliases, triggers, commands, timers, GMCP triggers, etc.
|
340
|
+
- #t+ [>=]{group}: Enable all objects in the {group} group, including aliases, triggers, commands, timers, GMCP triggers, etc.
|
341
|
+
- #t- [>=]{group}: Disable all objects in the {group} group, including aliases, triggers, commands, timers, GMCP triggers, etc.
|
339
342
|
|
340
343
|
Parameters:
|
341
|
-
:group: Group name.
|
344
|
+
:group: Group name. There could be a '=' or '>' sign before groupname, to indicate only this group or this group and it's subgroups. If there is no sign, it is equavalant to use '='.
|
342
345
|
|
343
346
|
Examples:
|
344
347
|
- ``#ig``: Toggle the global enable/disable status of triggers. When disabled, "Global disabled" will be displayed in the lower right corner of the status bar.
|
345
348
|
- ``#t+ mygroup``: Enable all objects in the group named mygroup, including aliases, triggers, commands, timers, GMCP triggers, etc.
|
346
349
|
- ``#t- mygroup``: Disable all objects in the group named mygroup, including aliases, triggers, commands, timers, GMCP triggers, etc.
|
350
|
+
- ``#t+ >mygroup``: Enable all objects in the group named mygroup and its subgroups (eg. mygroup.subgroup, etc.), including aliases, triggers, commands, timers, GMCP triggers, etc.
|
347
351
|
|
348
352
|
Related commands:
|
349
353
|
- #trigger
|
pymud/pymud.py
CHANGED
@@ -37,7 +37,7 @@ from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
|
37
37
|
from wcwidth import wcwidth, wcswidth
|
38
38
|
|
39
39
|
from .objects import CodeBlock
|
40
|
-
from .extras import
|
40
|
+
from .extras import SessionBuffer, SessionBufferControl, EasternMenuContainer, VSplitWindow, DotDict, MenuItem
|
41
41
|
from .modules import Plugin
|
42
42
|
from .session import Session
|
43
43
|
from .settings import Settings
|
@@ -162,8 +162,9 @@ class PyMudApp:
|
|
162
162
|
self.loggers = dict() # 所有记录字典
|
163
163
|
self.showLog = False # 是否显示记录页
|
164
164
|
self.logFileShown = '' # 记录页显示的记录文件名
|
165
|
-
self.logSessionBuffer = SessionBuffer()
|
166
|
-
self.logSessionBuffer.name = "LOGBUFFER"
|
165
|
+
#self.logSessionBuffer = SessionBuffer()
|
166
|
+
#self.logSessionBuffer.name = "LOGBUFFER"
|
167
|
+
self.logSessionBuffer = SessionBuffer("LOGBUFFER", max_buffered_lines = -1)
|
167
168
|
|
168
169
|
self.load_plugins()
|
169
170
|
|
@@ -217,17 +218,8 @@ class PyMudApp:
|
|
217
218
|
show_cursor=False
|
218
219
|
)
|
219
220
|
|
220
|
-
self.mudFormatProc = MudFormatProcessor()
|
221
|
-
|
222
221
|
self.consoleView = SessionBufferControl(
|
223
222
|
buffer = None,
|
224
|
-
input_processors=[
|
225
|
-
self.mudFormatProc,
|
226
|
-
HighlightSearchProcessor(),
|
227
|
-
HighlightSelectionProcessor(),
|
228
|
-
DisplayMultipleCursors(),
|
229
|
-
],
|
230
|
-
focus_on_click = False,
|
231
223
|
)
|
232
224
|
|
233
225
|
|
@@ -507,22 +499,18 @@ class PyMudApp:
|
|
507
499
|
"""
|
508
500
|
|
509
501
|
b = self.consoleView.buffer
|
510
|
-
if b.
|
511
|
-
cur1, cur2 = b.selection_state.original_cursor_position, b.document.cursor_position
|
512
|
-
start, end = min(cur1, cur2), max(cur1, cur2)
|
513
|
-
srow, scol = b.document.translate_index_to_position(start)
|
514
|
-
erow, ecol = b.document.translate_index_to_position(end)
|
515
|
-
# srow, scol = b.document.translate_index_to_position(b.selection_state.original_cursor_position)
|
516
|
-
# erow, ecol = b.document.translate_index_to_position(b.document.cursor_position)
|
517
|
-
|
502
|
+
if b and b.selection.is_valid():
|
518
503
|
if not raw:
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
504
|
+
if b.selection.start_row == b.selection.end_row:
|
505
|
+
if b.selection.end_col - b.selection.start_col == len(b.getLine(b.selection.start_row)):
|
506
|
+
# 单行且选中了整行,此时不校正显示位置匹配
|
507
|
+
line = b.getLine(b.selection.start_row)
|
508
|
+
else:
|
509
|
+
# 单行且选中了部分内容,此时校正显示位置匹配
|
510
|
+
line = self.consoleView.line_correction(b.getLine(b.selection.start_row))
|
511
|
+
|
512
|
+
start = max(0, b.selection.start_col)
|
513
|
+
end = min(len(line), b.selection.end_col)
|
526
514
|
line_plain = Session.PLAIN_TEXT_REGX.sub("", line).replace("\r", "").replace("\x00", "")
|
527
515
|
selection = line_plain[start:end]
|
528
516
|
self.app.clipboard.set_text(selection)
|
@@ -532,36 +520,38 @@ class PyMudApp:
|
|
532
520
|
else:
|
533
521
|
# 多行只认行
|
534
522
|
lines = []
|
535
|
-
for row in range(
|
536
|
-
line = b.
|
523
|
+
for row in range(b.selection.start_row, b.selection.end_row + 1):
|
524
|
+
line = b.getLine(row)
|
537
525
|
line_plain = Session.PLAIN_TEXT_REGX.sub("", line).replace("\r", "").replace("\x00", "")
|
538
526
|
lines.append(line_plain)
|
527
|
+
copy_text = "\n".join(lines)
|
528
|
+
self.app.clipboard.set_text(copy_text)
|
529
|
+
self.set_status(Settings.gettext("msg_copylines", b.selection.rows))
|
539
530
|
|
540
|
-
self.app.clipboard.set_text("\n".join(lines))
|
541
|
-
self.set_status(Settings.gettext("msg_copylines", 1 + erow - srow))
|
542
|
-
|
543
|
-
if self.current_session:
|
544
|
-
self.current_session.setVariable("%copy", "\n".join(lines))
|
545
|
-
|
546
531
|
else:
|
547
|
-
#
|
548
|
-
if
|
549
|
-
|
532
|
+
# RAW模式,直接复制原始内容
|
533
|
+
if b.selection.start_row == b.selection.end_row:
|
534
|
+
# 单行情况
|
535
|
+
line = b.getLine(b.selection.start_row)
|
550
536
|
self.app.clipboard.set_text(line)
|
551
537
|
self.set_status(Settings.gettext("msg_copy", line))
|
552
|
-
|
553
538
|
if self.current_session:
|
554
539
|
self.current_session.setVariable("%copy", line)
|
555
540
|
|
556
541
|
else:
|
557
|
-
|
558
|
-
|
542
|
+
# 多行只认行
|
543
|
+
lines = []
|
544
|
+
for row in range(b.selection.start_row, b.selection.end_row + 1):
|
545
|
+
line = b.getLine(row)
|
546
|
+
lines.append(line)
|
547
|
+
copy_raw_text = "\n".join(lines)
|
559
548
|
self.app.clipboard.set_text(copy_raw_text)
|
560
|
-
self.set_status(Settings.gettext("msg_copylines",
|
549
|
+
self.set_status(Settings.gettext("msg_copylines", b.selection.rows))
|
561
550
|
|
562
551
|
if self.current_session:
|
563
552
|
self.current_session.setVariable("%copy", copy_raw_text)
|
564
553
|
|
554
|
+
|
565
555
|
else:
|
566
556
|
self.set_status(Settings.gettext("msg_no_selection"))
|
567
557
|
|
@@ -654,11 +644,10 @@ class PyMudApp:
|
|
654
644
|
if os.path.exists(filename):
|
655
645
|
lock = threading.RLock()
|
656
646
|
lock.acquire()
|
657
|
-
|
658
|
-
self.logSessionBuffer._set_text(file.read())
|
647
|
+
self.logSessionBuffer.loadfile(filename, encoding = 'utf-8', errors = 'ignore')
|
659
648
|
lock.release()
|
660
649
|
|
661
|
-
self.logSessionBuffer.cursor_position = len(self.logSessionBuffer.text)
|
650
|
+
#self.logSessionBuffer.cursor_position = len(self.logSessionBuffer.text)
|
662
651
|
self.consoleView.buffer = self.logSessionBuffer
|
663
652
|
self.app.invalidate()
|
664
653
|
|
@@ -702,7 +691,8 @@ class PyMudApp:
|
|
702
691
|
self.current_session.closeLoggers()
|
703
692
|
self.current_session.clean()
|
704
693
|
self.current_session = None
|
705
|
-
self.consoleView.buffer = SessionBuffer()
|
694
|
+
#self.consoleView.buffer = SessionBuffer()
|
695
|
+
self.consoleView.buffer = None
|
706
696
|
self.sessions.pop(name)
|
707
697
|
#self.set_status(f"会话 {name} 已关闭")
|
708
698
|
if len(self.sessions.keys()) > 0:
|
@@ -741,12 +731,15 @@ class PyMudApp:
|
|
741
731
|
s = self.current_session
|
742
732
|
b = s.buffer
|
743
733
|
b.exit_selection()
|
744
|
-
b.cursor_position = len(b.text)
|
734
|
+
#b.cursor_position = len(b.text)
|
735
|
+
b.nosplit()
|
745
736
|
|
746
737
|
elif self.showLog:
|
747
738
|
b = self.logSessionBuffer
|
748
739
|
b.exit_selection()
|
749
|
-
b.cursor_position = len(b.text)
|
740
|
+
#b.cursor_position = len(b.text)
|
741
|
+
#b.start_lineno = -1
|
742
|
+
b.nosplit()
|
750
743
|
|
751
744
|
def act_close_session(self):
|
752
745
|
"菜单: 关闭当前会话"
|
@@ -755,7 +748,7 @@ class PyMudApp:
|
|
755
748
|
|
756
749
|
elif self.showLog:
|
757
750
|
self.showLog = False
|
758
|
-
self.logSessionBuffer
|
751
|
+
#self.logSessionBuffer = None
|
759
752
|
if len(self.sessions.keys()) > 0:
|
760
753
|
new_sess = list(self.sessions.keys())[0]
|
761
754
|
self.activate_session(new_sess)
|
@@ -791,7 +784,8 @@ class PyMudApp:
|
|
791
784
|
|
792
785
|
def act_clearsession(self):
|
793
786
|
"菜单: 清空会话内容"
|
794
|
-
self.consoleView.buffer
|
787
|
+
if self.consoleView.buffer:
|
788
|
+
self.consoleView.buffer.clear()
|
795
789
|
|
796
790
|
def act_reload(self):
|
797
791
|
"菜单: 重新加载脚本配置"
|