pymud 0.21.0a5__py3-none-any.whl → 0.21.2__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 +509 -453
- pymud/lang/i18n_chs.py +3 -0
- pymud/lang/i18n_eng.py +7 -3
- pymud/pymud.py +66 -57
- pymud/session.py +180 -44
- pymud/settings.py +1 -1
- {pymud-0.21.0a5.dist-info → pymud-0.21.2.dist-info}/METADATA +75 -30
- pymud-0.21.2.dist-info/RECORD +23 -0
- {pymud-0.21.0a5.dist-info → pymud-0.21.2.dist-info}/WHEEL +1 -1
- pymud-0.21.0a5.dist-info/RECORD +0 -23
- {pymud-0.21.0a5.dist-info → pymud-0.21.2.dist-info}/entry_points.txt +0 -0
- {pymud-0.21.0a5.dist-info → pymud-0.21.2.dist-info}/licenses/LICENSE.txt +0 -0
- {pymud-0.21.0a5.dist-info → pymud-0.21.2.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
@@ -9,7 +9,7 @@ from prompt_toolkit.buffer import Buffer
|
|
9
9
|
from prompt_toolkit.application import Application
|
10
10
|
from prompt_toolkit.filters import Condition
|
11
11
|
from prompt_toolkit.key_binding import KeyBindings
|
12
|
-
from prompt_toolkit.layout import ConditionalContainer, Float, VSplit, HSplit, Window, WindowAlign, ScrollbarMargin, NumberedMargin
|
12
|
+
from prompt_toolkit.layout import ConditionalContainer, Float, VSplit, HSplit, Window, WindowAlign, ScrollbarMargin, NumberedMargin, to_dimension
|
13
13
|
from prompt_toolkit.layout.layout import Layout
|
14
14
|
from prompt_toolkit.layout.controls import FormattedTextControl
|
15
15
|
from prompt_toolkit.layout.dimension import D
|
@@ -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 BufferBase, LogFileBuffer, SessionBuffer, PyMudBufferControl, 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 = LogFileBuffer("LOGBUFFER")
|
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.
|
221
|
-
|
222
|
-
self.consoleView = SessionBufferControl(
|
221
|
+
self.consoleView = PyMudBufferControl(
|
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
|
|
@@ -406,11 +398,26 @@ class PyMudApp:
|
|
406
398
|
else:
|
407
399
|
b = None
|
408
400
|
|
409
|
-
if isinstance(b,
|
401
|
+
if isinstance(b, BufferBase):
|
410
402
|
if lines < 0:
|
411
|
-
b.
|
412
|
-
|
413
|
-
|
403
|
+
if b.start_lineno < 0:
|
404
|
+
self.console._scroll_up()
|
405
|
+
b.start_lineno = b.lineCount - self.get_height() * 3 // 2
|
406
|
+
else:
|
407
|
+
b.start_lineno += lines
|
408
|
+
if b.start_lineno < 0:
|
409
|
+
b.start_lineno = 0
|
410
|
+
|
411
|
+
else:
|
412
|
+
if b.start_lineno < 0:
|
413
|
+
return
|
414
|
+
|
415
|
+
b.start_lineno += lines
|
416
|
+
|
417
|
+
if b.start_lineno >= b.lineCount - self.get_height():
|
418
|
+
b.start_lineno = -1
|
419
|
+
|
420
|
+
|
414
421
|
|
415
422
|
def page_up(self, event: KeyPressEvent) -> None:
|
416
423
|
"快捷键PageUp: 用于向上翻页。翻页页数为显示窗口行数的一半减去一行。"
|
@@ -507,22 +514,18 @@ class PyMudApp:
|
|
507
514
|
"""
|
508
515
|
|
509
516
|
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
|
-
|
517
|
+
if b and b.selection.is_valid():
|
518
518
|
if not raw:
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
519
|
+
if b.selection.start_row == b.selection.end_row:
|
520
|
+
if b.selection.end_col - b.selection.start_col == len(b.getLine(b.selection.start_row)):
|
521
|
+
# 单行且选中了整行,此时不校正显示位置匹配
|
522
|
+
line = b.getLine(b.selection.start_row)
|
523
|
+
else:
|
524
|
+
# 单行且选中了部分内容,此时校正显示位置匹配
|
525
|
+
line = self.consoleView.line_correction(b.getLine(b.selection.start_row))
|
526
|
+
|
527
|
+
start = max(0, b.selection.start_col)
|
528
|
+
end = min(len(line), b.selection.end_col)
|
526
529
|
line_plain = Session.PLAIN_TEXT_REGX.sub("", line).replace("\r", "").replace("\x00", "")
|
527
530
|
selection = line_plain[start:end]
|
528
531
|
self.app.clipboard.set_text(selection)
|
@@ -532,36 +535,38 @@ class PyMudApp:
|
|
532
535
|
else:
|
533
536
|
# 多行只认行
|
534
537
|
lines = []
|
535
|
-
for row in range(
|
536
|
-
line = b.
|
538
|
+
for row in range(b.selection.start_row, b.selection.end_row + 1):
|
539
|
+
line = b.getLine(row)
|
537
540
|
line_plain = Session.PLAIN_TEXT_REGX.sub("", line).replace("\r", "").replace("\x00", "")
|
538
541
|
lines.append(line_plain)
|
542
|
+
copy_text = "\n".join(lines)
|
543
|
+
self.app.clipboard.set_text(copy_text)
|
544
|
+
self.set_status(Settings.gettext("msg_copylines", b.selection.rows))
|
539
545
|
|
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
546
|
else:
|
547
|
-
#
|
548
|
-
if
|
549
|
-
|
547
|
+
# RAW模式,直接复制原始内容
|
548
|
+
if b.selection.start_row == b.selection.end_row:
|
549
|
+
# 单行情况
|
550
|
+
line = b.getLine(b.selection.start_row)
|
550
551
|
self.app.clipboard.set_text(line)
|
551
552
|
self.set_status(Settings.gettext("msg_copy", line))
|
552
|
-
|
553
553
|
if self.current_session:
|
554
554
|
self.current_session.setVariable("%copy", line)
|
555
555
|
|
556
556
|
else:
|
557
|
-
|
558
|
-
|
557
|
+
# 多行只认行
|
558
|
+
lines = []
|
559
|
+
for row in range(b.selection.start_row, b.selection.end_row + 1):
|
560
|
+
line = b.getLine(row)
|
561
|
+
lines.append(line)
|
562
|
+
copy_raw_text = "\n".join(lines)
|
559
563
|
self.app.clipboard.set_text(copy_raw_text)
|
560
|
-
self.set_status(Settings.gettext("msg_copylines",
|
564
|
+
self.set_status(Settings.gettext("msg_copylines", b.selection.rows))
|
561
565
|
|
562
566
|
if self.current_session:
|
563
567
|
self.current_session.setVariable("%copy", copy_raw_text)
|
564
568
|
|
569
|
+
|
565
570
|
else:
|
566
571
|
self.set_status(Settings.gettext("msg_no_selection"))
|
567
572
|
|
@@ -654,11 +659,10 @@ class PyMudApp:
|
|
654
659
|
if os.path.exists(filename):
|
655
660
|
lock = threading.RLock()
|
656
661
|
lock.acquire()
|
657
|
-
|
658
|
-
self.logSessionBuffer._set_text(file.read())
|
662
|
+
self.logSessionBuffer.loadfile(filename)
|
659
663
|
lock.release()
|
660
664
|
|
661
|
-
self.logSessionBuffer.cursor_position = len(self.logSessionBuffer.text)
|
665
|
+
#self.logSessionBuffer.cursor_position = len(self.logSessionBuffer.text)
|
662
666
|
self.consoleView.buffer = self.logSessionBuffer
|
663
667
|
self.app.invalidate()
|
664
668
|
|
@@ -702,7 +706,8 @@ class PyMudApp:
|
|
702
706
|
self.current_session.closeLoggers()
|
703
707
|
self.current_session.clean()
|
704
708
|
self.current_session = None
|
705
|
-
self.consoleView.buffer = SessionBuffer()
|
709
|
+
#self.consoleView.buffer = SessionBuffer()
|
710
|
+
self.consoleView.buffer = None
|
706
711
|
self.sessions.pop(name)
|
707
712
|
#self.set_status(f"会话 {name} 已关闭")
|
708
713
|
if len(self.sessions.keys()) > 0:
|
@@ -741,12 +746,15 @@ class PyMudApp:
|
|
741
746
|
s = self.current_session
|
742
747
|
b = s.buffer
|
743
748
|
b.exit_selection()
|
744
|
-
b.cursor_position = len(b.text)
|
749
|
+
#b.cursor_position = len(b.text)
|
750
|
+
b.nosplit()
|
745
751
|
|
746
752
|
elif self.showLog:
|
747
753
|
b = self.logSessionBuffer
|
748
|
-
b.exit_selection()
|
749
|
-
b.cursor_position = len(b.text)
|
754
|
+
#b.exit_selection()
|
755
|
+
#b.cursor_position = len(b.text)
|
756
|
+
#b.start_lineno = -1
|
757
|
+
b.nosplit()
|
750
758
|
|
751
759
|
def act_close_session(self):
|
752
760
|
"菜单: 关闭当前会话"
|
@@ -755,7 +763,7 @@ class PyMudApp:
|
|
755
763
|
|
756
764
|
elif self.showLog:
|
757
765
|
self.showLog = False
|
758
|
-
self.logSessionBuffer
|
766
|
+
#self.logSessionBuffer = None
|
759
767
|
if len(self.sessions.keys()) > 0:
|
760
768
|
new_sess = list(self.sessions.keys())[0]
|
761
769
|
self.activate_session(new_sess)
|
@@ -791,7 +799,8 @@ class PyMudApp:
|
|
791
799
|
|
792
800
|
def act_clearsession(self):
|
793
801
|
"菜单: 清空会话内容"
|
794
|
-
self.consoleView.buffer
|
802
|
+
if self.consoleView.buffer:
|
803
|
+
self.consoleView.buffer.clear()
|
795
804
|
|
796
805
|
def act_reload(self):
|
797
806
|
"菜单: 重新加载脚本配置"
|