Show More
@@ -1148,16 +1148,14 def MBTextWrapper(**kwargs): | |||
|
1148 | 1148 | def __init__(self, **kwargs): |
|
1149 | 1149 | textwrap.TextWrapper.__init__(self, **kwargs) |
|
1150 | 1150 | |
|
1151 | def _cutdown(self, str, space_left): | |
|
1151 | def _cutdown(self, ucstr, space_left): | |
|
1152 | 1152 | l = 0 |
|
1153 | ucstr = unicode(str, encoding.encoding) | |
|
1154 | 1153 | colwidth = unicodedata.east_asian_width |
|
1155 | 1154 | for i in xrange(len(ucstr)): |
|
1156 | 1155 | l += colwidth(ucstr[i]) in 'WFA' and 2 or 1 |
|
1157 | 1156 | if space_left < l: |
|
1158 |
return (ucstr[:i] |
|
|
1159 | ucstr[i:].encode(encoding.encoding)) | |
|
1160 | return str, '' | |
|
1157 | return (ucstr[:i], ucstr[i:]) | |
|
1158 | return ucstr, '' | |
|
1161 | 1159 | |
|
1162 | 1160 | # overriding of base class |
|
1163 | 1161 | def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width): |
@@ -1179,10 +1177,13 def wrap(line, width, initindent='', han | |||
|
1179 | 1177 | if width <= maxindent: |
|
1180 | 1178 | # adjust for weird terminal size |
|
1181 | 1179 | width = max(78, maxindent + 1) |
|
1180 | line = line.decode(encoding.encoding, encoding.encodingmode) | |
|
1181 | initindent = initindent.decode(encoding.encoding, encoding.encodingmode) | |
|
1182 | hangindent = hangindent.decode(encoding.encoding, encoding.encodingmode) | |
|
1182 | 1183 | wrapper = MBTextWrapper(width=width, |
|
1183 | 1184 | initial_indent=initindent, |
|
1184 | 1185 | subsequent_indent=hangindent) |
|
1185 | return wrapper.fill(line) | |
|
1186 | return wrapper.fill(line).encode(encoding.encoding) | |
|
1186 | 1187 | |
|
1187 | 1188 | def iterlines(iterator): |
|
1188 | 1189 | for chunk in iterator: |
@@ -22,14 +22,14 Test alignment of multibyte characters | |||
|
22 | 22 |
> cmdtable = { |
|
23 | 23 | > 'showoptlist': |
|
24 | 24 | > (showoptlist, |
|
25 |
> [('s', 'opt1', '', 'short width' |
|
|
26 |
> ('m', 'opt2', '', 'middle width' |
|
|
27 |
> ('l', 'opt3', '', 'long width' |
|
|
25 | > [('s', 'opt1', '', 'short width' + ' %(s)s' * 8, '%(s)s'), | |
|
26 | > ('m', 'opt2', '', 'middle width' + ' %(m)s' * 8, '%(m)s'), | |
|
27 | > ('l', 'opt3', '', 'long width' + ' %(l)s' * 8, '%(l)s') | |
|
28 | 28 | > ], |
|
29 | 29 | > "" |
|
30 | 30 | > ) |
|
31 | 31 | > } |
|
32 | > """) | |
|
32 | > """ % globals()) | |
|
33 | 33 | > f.close() |
|
34 | 34 | > EOF |
|
35 | 35 | $ S=`cat s` |
@@ -52,9 +52,11 check alignment of option descriptions i | |||
|
52 | 52 | |
|
53 | 53 | options: |
|
54 | 54 | |
|
55 | -s --opt1 \xe7\x9f\xad\xe5\x90\x8d short width (esc) | |
|
56 | -m --opt2 MIDDLE_ middle width | |
|
57 | -l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d long width (esc) | |
|
55 | -s --opt1 \xe7\x9f\xad\xe5\x90\x8d short width \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d (esc) | |
|
56 | -m --opt2 MIDDLE_ middle width MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ | |
|
57 | MIDDLE_ MIDDLE_ MIDDLE_ | |
|
58 | -l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d long width \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc) | |
|
59 | \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc) | |
|
58 | 60 | |
|
59 | 61 | use "hg -v help showoptlist" to show global options |
|
60 | 62 |
General Comments 0
You need to be logged in to leave comments.
Login now