pymud 0.21.4.post4__py3-none-any.whl → 0.21.4.post5__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 +58 -10
- {pymud-0.21.4.post4.dist-info → pymud-0.21.4.post5.dist-info}/METADATA +1 -1
- {pymud-0.21.4.post4.dist-info → pymud-0.21.4.post5.dist-info}/RECORD +7 -7
- {pymud-0.21.4.post4.dist-info → pymud-0.21.4.post5.dist-info}/WHEEL +0 -0
- {pymud-0.21.4.post4.dist-info → pymud-0.21.4.post5.dist-info}/entry_points.txt +0 -0
- {pymud-0.21.4.post4.dist-info → pymud-0.21.4.post5.dist-info}/licenses/LICENSE.txt +0 -0
- {pymud-0.21.4.post4.dist-info → pymud-0.21.4.post5.dist-info}/top_level.txt +0 -0
pymud/extras.py
CHANGED
@@ -502,7 +502,11 @@ class SessionSelectionState:
|
|
502
502
|
start_col: int = -1
|
503
503
|
end_col: int = -1
|
504
504
|
def is_valid(self):
|
505
|
-
return
|
505
|
+
return (self.start_row >= 0) and \
|
506
|
+
(self.start_col >= 0) and \
|
507
|
+
(self.end_row >= 0) and \
|
508
|
+
(self.end_col >= 0) and \
|
509
|
+
abs(self.start_row - self.end_row) + abs(self.start_col - self.end_col) > 0
|
506
510
|
|
507
511
|
@property
|
508
512
|
def rows(self):
|
@@ -737,8 +741,8 @@ class PyMudBufferControl(UIControl):
|
|
737
741
|
def width_correction(self, line: str) -> str:
|
738
742
|
new_str = []
|
739
743
|
for idx, ch in enumerate(line):
|
740
|
-
|
741
744
|
if (east_asian_width(ch) in "FWA") and (wcwidth(ch) == 1):
|
745
|
+
|
742
746
|
if ch in self.FULL_BLOCKS:
|
743
747
|
new_str.append(ch)
|
744
748
|
new_str.append(ch)
|
@@ -751,12 +755,15 @@ class PyMudBufferControl(UIControl):
|
|
751
755
|
elif ch in self.SINGLE_LINES_LEFT:
|
752
756
|
new_str.append("─")
|
753
757
|
new_str.append(ch)
|
754
|
-
elif idx == len(line) - 1:
|
755
|
-
new_str.append(" ")
|
756
|
-
new_str.append(ch)
|
757
758
|
else:
|
758
|
-
|
759
|
-
|
759
|
+
right = line[idx+1:]
|
760
|
+
right_len = fragment_list_width(to_formatted_text(ANSI(right)))
|
761
|
+
if right_len == 0:
|
762
|
+
new_str.append(" ")
|
763
|
+
new_str.append(ch)
|
764
|
+
else:
|
765
|
+
new_str.append(ch)
|
766
|
+
new_str.append(' ')
|
760
767
|
else:
|
761
768
|
new_str.append(ch)
|
762
769
|
|
@@ -791,6 +798,43 @@ class PyMudBufferControl(UIControl):
|
|
791
798
|
|
792
799
|
return line
|
793
800
|
|
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
|
+
|
794
838
|
def create_content(self, width: int, height: int) -> UIContent:
|
795
839
|
"""
|
796
840
|
Generate the content for this user control.
|
@@ -838,9 +882,14 @@ class PyMudBufferControl(UIControl):
|
|
838
882
|
|
839
883
|
# 其他校正
|
840
884
|
line = self.line_correction(line)
|
885
|
+
#line = self.return_correction(line)
|
841
886
|
|
842
887
|
# 处理ANSI标记(生成FormmatedText)
|
843
888
|
fragments = to_formatted_text(ANSI(line))
|
889
|
+
#fragments = explode_text_fragments(fragments)
|
890
|
+
|
891
|
+
# if Settings.client["beautify"]:
|
892
|
+
# fragments = self.fragment_correction(fragments)
|
844
893
|
|
845
894
|
# 选择内容标识
|
846
895
|
selected_fragment = " class:selected "
|
@@ -930,9 +979,8 @@ class PyMudBufferControl(UIControl):
|
|
930
979
|
buffer.selection.end_row = position.y
|
931
980
|
buffer.selection.end_col = position.x
|
932
981
|
|
933
|
-
|
934
|
-
|
935
|
-
|
982
|
+
if not buffer.selection.is_valid():
|
983
|
+
buffer.exit_selection()
|
936
984
|
|
937
985
|
# Select word around cursor on double click.
|
938
986
|
# Two MOUSE_UP events in a short timespan are considered a double click.
|
@@ -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=WAtLEyKgdsEn0-BumToX6BfV29d5iXn7SUyAWM2JPZw,39146
|
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
|
@@ -15,9 +15,9 @@ pymud/session.py,sha256=sTswAPEl5GWcxzYmgovG8lOlflNTd5k8ggW6zJ6vcMY,154690
|
|
15
15
|
pymud/settings.py,sha256=V4wHKP2UjmX_l2bKJoUJSfNbH7vs3GZlN4u-1tRFbxA,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.4.
|
19
|
-
pymud-0.21.4.
|
20
|
-
pymud-0.21.4.
|
21
|
-
pymud-0.21.4.
|
22
|
-
pymud-0.21.4.
|
23
|
-
pymud-0.21.4.
|
18
|
+
pymud-0.21.4.post5.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
19
|
+
pymud-0.21.4.post5.dist-info/METADATA,sha256=vPX5Gp0V0ZHqPWUcWhaMVeeSDIn0roS7ZrlGmud44aI,46537
|
20
|
+
pymud-0.21.4.post5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
pymud-0.21.4.post5.dist-info/entry_points.txt,sha256=diPUOtTkhgC1hVny7Cdg4aRhaHSynMQoraE7ZhJxUcw,37
|
22
|
+
pymud-0.21.4.post5.dist-info/top_level.txt,sha256=8Gp1eXjxixXjqhhti6tLCspV_8s9sNV3z5Em2_KRhD4,6
|
23
|
+
pymud-0.21.4.post5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|