pymud 0.21.4.post5__py3-none-any.whl → 0.21.5.post1__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 +37 -51
- pymud/pymud.py +9 -8
- pymud/session.py +3 -0
- pymud/settings.py +1 -1
- {pymud-0.21.4.post5.dist-info → pymud-0.21.5.post1.dist-info}/METADATA +7 -1
- {pymud-0.21.4.post5.dist-info → pymud-0.21.5.post1.dist-info}/RECORD +10 -10
- {pymud-0.21.4.post5.dist-info → pymud-0.21.5.post1.dist-info}/WHEEL +0 -0
- {pymud-0.21.4.post5.dist-info → pymud-0.21.5.post1.dist-info}/entry_points.txt +0 -0
- {pymud-0.21.4.post5.dist-info → pymud-0.21.5.post1.dist-info}/licenses/LICENSE.txt +0 -0
- {pymud-0.21.4.post5.dist-info → pymud-0.21.5.post1.dist-info}/top_level.txt +0 -0
pymud/extras.py
CHANGED
@@ -626,6 +626,7 @@ class SessionBuffer(BufferBase):
|
|
626
626
|
if line.endswith(self.newline):
|
627
627
|
line = line.rstrip(self.newline)
|
628
628
|
newline_after_append = True
|
629
|
+
|
629
630
|
if not self.newline in line:
|
630
631
|
if self._isnewline:
|
631
632
|
self._lines.append(line)
|
@@ -659,6 +660,8 @@ class SessionBuffer(BufferBase):
|
|
659
660
|
self._lines.clear()
|
660
661
|
self.nosplit()
|
661
662
|
|
663
|
+
def forceNewline(self):
|
664
|
+
self._isnewline = True
|
662
665
|
|
663
666
|
@property
|
664
667
|
def lineCount(self):
|
@@ -712,10 +715,14 @@ class PyMudBufferControl(UIControl):
|
|
712
715
|
self.buffer = buffer
|
713
716
|
|
714
717
|
# 为MUD显示进行校正的处理,包括对齐校正,换行颜色校正等
|
715
|
-
self.FULL_BLOCKS = set("
|
718
|
+
self.FULL_BLOCKS = set("▂▃▅▆▇▄█")
|
719
|
+
self.TABLE_LINES = set("┃││║┃")
|
716
720
|
self.SINGLE_LINES = set("┠┌└├┬┼┴╭╰─")
|
717
|
-
self.SINGLE_LINES_LEFT = set("
|
721
|
+
self.SINGLE_LINES_LEFT = set("┨┘┐┤╮╯")
|
718
722
|
self.DOUBLE_LINES = set("╔╚╠╦╪╩═")
|
723
|
+
self.DOUBLE_LINES_LEFT = set("╗╝╣")
|
724
|
+
self.THICK_LINES = set("┏┗━")
|
725
|
+
self.THICK_LINES_LEFT = set("┓┛ ")
|
719
726
|
self.ALL_COLOR_REGX = re.compile(r"(?:\[[\d;]+m)+")
|
720
727
|
self.AVAI_COLOR_REGX = re.compile(r"(?:\[[\d;]+m)+(?!$)")
|
721
728
|
self._color_start = ""
|
@@ -737,7 +744,6 @@ class PyMudBufferControl(UIControl):
|
|
737
744
|
"""
|
738
745
|
return False
|
739
746
|
|
740
|
-
|
741
747
|
def width_correction(self, line: str) -> str:
|
742
748
|
new_str = []
|
743
749
|
for idx, ch in enumerate(line):
|
@@ -752,15 +758,28 @@ class PyMudBufferControl(UIControl):
|
|
752
758
|
elif ch in self.DOUBLE_LINES:
|
753
759
|
new_str.append(ch)
|
754
760
|
new_str.append("═")
|
755
|
-
elif ch in self.
|
756
|
-
new_str.append("─")
|
761
|
+
elif ch in self.THICK_LINES:
|
757
762
|
new_str.append(ch)
|
763
|
+
new_str.append("━")
|
758
764
|
else:
|
759
|
-
right = line[idx+1:]
|
765
|
+
right = str.rstrip(line[idx+1:])
|
760
766
|
right_len = fragment_list_width(to_formatted_text(ANSI(right)))
|
761
|
-
if right_len == 0:
|
762
|
-
|
763
|
-
|
767
|
+
if (idx == len(line) - 1) or (right_len == 0):
|
768
|
+
if ch in self.SINGLE_LINES_LEFT:
|
769
|
+
new_str.append("─")
|
770
|
+
new_str.append(ch)
|
771
|
+
elif ch in self.DOUBLE_LINES_LEFT:
|
772
|
+
new_str.append("═")
|
773
|
+
new_str.append(ch)
|
774
|
+
elif ch in self.THICK_LINES_LEFT:
|
775
|
+
new_str.append("━")
|
776
|
+
new_str.append(ch)
|
777
|
+
elif ch in self.TABLE_LINES:
|
778
|
+
new_str.append(" ")
|
779
|
+
new_str.append(ch)
|
780
|
+
else:
|
781
|
+
new_str.append(ch)
|
782
|
+
new_str.append(' ')
|
764
783
|
else:
|
765
784
|
new_str.append(ch)
|
766
785
|
new_str.append(' ')
|
@@ -798,43 +817,6 @@ class PyMudBufferControl(UIControl):
|
|
798
817
|
|
799
818
|
return line
|
800
819
|
|
801
|
-
def fragment_correction(self, fragments: StyleAndTextTuples):
|
802
|
-
"""
|
803
|
-
处理ANSI标记,包括颜色标记,下划线标记等
|
804
|
-
"""
|
805
|
-
new_fragments = []
|
806
|
-
frag_count = len(fragments)
|
807
|
-
for i in range(0, frag_count):
|
808
|
-
style, text, *_ = fragments[i]
|
809
|
-
new_text = []
|
810
|
-
|
811
|
-
for j, ch in enumerate(text):
|
812
|
-
if (east_asian_width(ch) in "FWA") and (wcwidth(ch) == 1):
|
813
|
-
if ch in self.FULL_BLOCKS:
|
814
|
-
new_text.append(ch * 2)
|
815
|
-
elif ch in self.SINGLE_LINES:
|
816
|
-
new_text.append(ch)
|
817
|
-
new_text.append("─")
|
818
|
-
elif ch in self.DOUBLE_LINES:
|
819
|
-
new_text.append(ch)
|
820
|
-
new_text.append("═")
|
821
|
-
elif ch in self.SINGLE_LINES_LEFT:
|
822
|
-
new_text.append("─")
|
823
|
-
new_text.append(ch)
|
824
|
-
elif (i == frag_count - 1) and (j == len(ch) - 1):
|
825
|
-
new_text.append(" ")
|
826
|
-
new_text.append(ch)
|
827
|
-
else:
|
828
|
-
new_text.append(ch)
|
829
|
-
new_text.append(' ')
|
830
|
-
else:
|
831
|
-
new_text.append(ch)
|
832
|
-
|
833
|
-
fragments[i] = (style, "".join(new_text))
|
834
|
-
|
835
|
-
return fragments
|
836
|
-
|
837
|
-
|
838
820
|
def create_content(self, width: int, height: int) -> UIContent:
|
839
821
|
"""
|
840
822
|
Generate the content for this user control.
|
@@ -899,8 +881,10 @@ class PyMudBufferControl(UIControl):
|
|
899
881
|
|
900
882
|
if selection_at_line:
|
901
883
|
from_, to = selection_at_line
|
902
|
-
|
903
|
-
|
884
|
+
total_display = fragment_list_width(fragments)
|
885
|
+
if to == len(buffer.getLine(i)):
|
886
|
+
to = total_display
|
887
|
+
|
904
888
|
|
905
889
|
fragments = explode_text_fragments(fragments)
|
906
890
|
|
@@ -909,12 +893,14 @@ class PyMudBufferControl(UIControl):
|
|
909
893
|
# visualize the selection.
|
910
894
|
return [(selected_fragment, " ")]
|
911
895
|
else:
|
912
|
-
for i in range(from_, to):
|
896
|
+
for i in range(from_, min(to, total_display+1)):
|
913
897
|
if i < len(fragments):
|
914
898
|
old_fragment, old_text, *_ = fragments[i]
|
915
899
|
fragments[i] = (old_fragment + selected_fragment, old_text)
|
916
|
-
elif i == len(fragments):
|
917
|
-
|
900
|
+
# elif i == len(fragments):
|
901
|
+
# fragments.append((selected_fragment, " "))
|
902
|
+
|
903
|
+
|
918
904
|
|
919
905
|
return fragments
|
920
906
|
|
pymud/pymud.py
CHANGED
@@ -672,7 +672,7 @@ class PyMudApp:
|
|
672
672
|
dlgQuery = QueryDialog(HTML(f'<b fg="red">{Settings.gettext("warning")}</b>'), HTML(f'<style fg="red">{Settings.gettext("session_close_prompt", self.current_session.name)}</style>'))
|
673
673
|
result = await self.show_dialog_as_float(dlgQuery)
|
674
674
|
if result:
|
675
|
-
self.current_session.disconnect()
|
675
|
+
self.current_session.disconnect()
|
676
676
|
|
677
677
|
# 增加延时等待确保会话关闭
|
678
678
|
wait_time = 0
|
@@ -696,13 +696,17 @@ class PyMudApp:
|
|
696
696
|
self.current_session = None
|
697
697
|
#self.consoleView.buffer = SessionBuffer()
|
698
698
|
self.consoleView.buffer = None
|
699
|
-
self.sessions.pop(name)
|
699
|
+
closesession = self.sessions.pop(name)
|
700
|
+
del closesession
|
700
701
|
#self.set_status(f"会话 {name} 已关闭")
|
701
702
|
if len(self.sessions.keys()) > 0:
|
702
703
|
new_sess = list(self.sessions.keys())[0]
|
703
704
|
self.activate_session(new_sess)
|
704
705
|
#self.set_status(f"当前会话已切换为 {self.current_session.name}")
|
705
706
|
|
707
|
+
import gc
|
708
|
+
gc.collect()
|
709
|
+
|
706
710
|
asyncio.ensure_future(coroutine()) # type: ignore
|
707
711
|
|
708
712
|
# 菜单选项操作 - 开始
|
@@ -1084,12 +1088,8 @@ class PyMudApp:
|
|
1084
1088
|
"命令行回车按键处理"
|
1085
1089
|
cmd_line = buffer.text
|
1086
1090
|
space_index = cmd_line.find(" ")
|
1087
|
-
|
1088
|
-
if len(cmd_line)
|
1089
|
-
if self.current_session:
|
1090
|
-
self.current_session.writeline("")
|
1091
|
-
|
1092
|
-
elif cmd_line[0] != Settings.client["appcmdflag"]:
|
1091
|
+
|
1092
|
+
if (len(cmd_line) >= 1) and (cmd_line[0] != Settings.client["appcmdflag"]):
|
1093
1093
|
if self.current_session:
|
1094
1094
|
self.current_session.last_command = cmd_line
|
1095
1095
|
|
@@ -1101,6 +1101,7 @@ class PyMudApp:
|
|
1101
1101
|
if self.current_session:
|
1102
1102
|
if len(cmd_line) == 0:
|
1103
1103
|
self.current_session.writeline("")
|
1104
|
+
|
1104
1105
|
else:
|
1105
1106
|
try:
|
1106
1107
|
self.current_session.log.log(f"{Settings.gettext('msg_cmdline_input')} {cmd_line}\n")
|
pymud/session.py
CHANGED
@@ -810,9 +810,12 @@ class Session:
|
|
810
810
|
else:
|
811
811
|
if Settings.client["echo_input"]:
|
812
812
|
self.writetobuffer(f"\x1b[32m{line}\x1b[0m", True)
|
813
|
+
|
813
814
|
else:
|
814
815
|
self.log.log(f"\x1b[32m{line}\x1b[0m\n")
|
815
816
|
|
817
|
+
# 当输入任意命令后,本地强制新行
|
818
|
+
self.buffer.forceNewline()
|
816
819
|
self.record_command(line)
|
817
820
|
cmd = line + self.newline
|
818
821
|
self.write(cmd.encode(self.encoding, Settings.server["encoding_errors"]))
|
pymud/settings.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pymud
|
3
|
-
Version: 0.21.
|
3
|
+
Version: 0.21.5.post1
|
4
4
|
Summary: a MUD Client written in Python
|
5
5
|
Author-email: "newstart@pkuxkx" <crapex@hotmail.com>
|
6
6
|
Maintainer-email: "newstart@pkuxkx" <crapex@hotmail.com>
|
@@ -66,6 +66,12 @@ Dynamic: license-file
|
|
66
66
|
|
67
67
|
## 版本更新信息
|
68
68
|
|
69
|
+
### 0.21.5post1 (2025-06-10)
|
70
|
+
|
71
|
+
+ 功能完善: 完善了美化功能,已知情况下,基本不会出现断行和不对齐问题了。
|
72
|
+
+ 功能完善: 在向服务器送出命令后,本地显示也强制换行。在出现『未完待续』情况时,回车后不会再跟在后面显示了,而是会强制从下一行开始。
|
73
|
+
+ 功能完善: 当对行进行双击选择时,背景增加的选择标记(灰色)会按照实际显示的宽度进行匹配,而不是按照原始数据的宽度进行匹配。
|
74
|
+
|
69
75
|
### 0.21.4 (2025-06-08)
|
70
76
|
|
71
77
|
+ 问题修复: 修复了在多行选择碰到空行时,会导致从头开始全选的问题。
|
@@ -2,7 +2,7 @@ pymud/__init__.py,sha256=oeHz0NM7_DwChCY8f_vQ_fBq0e_HoTd0cahCFwaavWE,806
|
|
2
2
|
pymud/__main__.py,sha256=lIOBiJmi8X-EWXVIx_OoxSgUZ0FYKlZI8hXVnLUYTJQ,61
|
3
3
|
pymud/decorators.py,sha256=rNuDaKk65Cwc9K6t0-BpqNUORs8-8X5Xsv6YaLQ7hc4,9839
|
4
4
|
pymud/dialogs.py,sha256=1xo5NJjch-u7RSRcclhvUE4gi8POgiZWK84lNx_HJbs,6891
|
5
|
-
pymud/extras.py,sha256=
|
5
|
+
pymud/extras.py,sha256=ehwEe48ObvypUTt6SVbGsI2C-3-Mn0J8mGZOMM-ighk,38779
|
6
6
|
pymud/i18n.py,sha256=qLgvrmYhVfkTHKpbBR-LfYMOrGgi0skHrelbsj7ItbE,3034
|
7
7
|
pymud/logger.py,sha256=F2LBUogdzv2WXHo10CNorDh2VleAX1Wbwmxc3zznHlM,5823
|
8
8
|
pymud/main.py,sha256=zaSjNhpbX3FMulKg-UNFrdiIJO8sOmmrUQrkPOalB-4,10224
|
@@ -10,14 +10,14 @@ pymud/modules.py,sha256=CsOqY1c59CrejltCS4wf7QqdCr5k_ghel8AUqlKVGIw,11873
|
|
10
10
|
pymud/objects.py,sha256=NlKAQnV6v9lSkz94zmgb513HPxskY8-tXnOdrYhuktc,38629
|
11
11
|
pymud/pkuxkx.py,sha256=qDVry-Vd6MNui0NKWZFT52IpmP1sKS5Dz74EDY4tVGQ,14740
|
12
12
|
pymud/protocol.py,sha256=noptJs6K0L9qM8VZIeP65H4k9FPLGJqxvm3qY2iAwvI,48315
|
13
|
-
pymud/pymud.py,sha256=
|
14
|
-
pymud/session.py,sha256=
|
15
|
-
pymud/settings.py,sha256=
|
13
|
+
pymud/pymud.py,sha256=9BxK51tzvaOGpSqawlGI57TOtWbaccSlK9mNNHdvyGI,53486
|
14
|
+
pymud/session.py,sha256=uJI2zm3rT3UxF0Pyt-e_daW4RkqCUR6OnkXneUVZ0tg,154790
|
15
|
+
pymud/settings.py,sha256=tWNRQAA-QnDUcXk-Vr3B9Bfi-JpSlroHC1UJ_PY2p8A,7697
|
16
16
|
pymud/lang/i18n_chs.py,sha256=2cyaHHLwpYEBBwuQXyRTxa1opX53fTv1f8_QDQeGlC0,16836
|
17
17
|
pymud/lang/i18n_eng.py,sha256=jcPz6Y5UuxJBQLY_e8UnEF3GYTlnAD44C14Oj7sK-QI,45935
|
18
|
-
pymud-0.21.
|
19
|
-
pymud-0.21.
|
20
|
-
pymud-0.21.
|
21
|
-
pymud-0.21.
|
22
|
-
pymud-0.21.
|
23
|
-
pymud-0.21.
|
18
|
+
pymud-0.21.5.post1.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
19
|
+
pymud-0.21.5.post1.dist-info/METADATA,sha256=yq8JnaorcCg5zk3cdQ6wsj04P-xucYWV-bI-rDbaAI8,47057
|
20
|
+
pymud-0.21.5.post1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
pymud-0.21.5.post1.dist-info/entry_points.txt,sha256=diPUOtTkhgC1hVny7Cdg4aRhaHSynMQoraE7ZhJxUcw,37
|
22
|
+
pymud-0.21.5.post1.dist-info/top_level.txt,sha256=8Gp1eXjxixXjqhhti6tLCspV_8s9sNV3z5Em2_KRhD4,6
|
23
|
+
pymud-0.21.5.post1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|