Show More
@@ -1171,16 +1171,14 b' def MBTextWrapper(**kwargs):' | |||
|
1171 | 1171 | def __init__(self, **kwargs): |
|
1172 | 1172 | textwrap.TextWrapper.__init__(self, **kwargs) |
|
1173 | 1173 | |
|
1174 | def _cutdown(self, str, space_left): | |
|
1174 | def _cutdown(self, ucstr, space_left): | |
|
1175 | 1175 | l = 0 |
|
1176 | ucstr = unicode(str, encoding.encoding) | |
|
1177 | 1176 | colwidth = unicodedata.east_asian_width |
|
1178 | 1177 | for i in xrange(len(ucstr)): |
|
1179 | 1178 | l += colwidth(ucstr[i]) in 'WFA' and 2 or 1 |
|
1180 | 1179 | if space_left < l: |
|
1181 |
return (ucstr[:i] |
|
|
1182 | ucstr[i:].encode(encoding.encoding)) | |
|
1183 | return str, '' | |
|
1180 | return (ucstr[:i], ucstr[i:]) | |
|
1181 | return ucstr, '' | |
|
1184 | 1182 | |
|
1185 | 1183 | # overriding of base class |
|
1186 | 1184 | def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width): |
@@ -1202,10 +1200,13 b" def wrap(line, width, initindent='', han" | |||
|
1202 | 1200 | if width <= maxindent: |
|
1203 | 1201 | # adjust for weird terminal size |
|
1204 | 1202 | width = max(78, maxindent + 1) |
|
1203 | line = line.decode(encoding.encoding, encoding.encodingmode) | |
|
1204 | initindent = initindent.decode(encoding.encoding, encoding.encodingmode) | |
|
1205 | hangindent = hangindent.decode(encoding.encoding, encoding.encodingmode) | |
|
1205 | 1206 | wrapper = MBTextWrapper(width=width, |
|
1206 | 1207 | initial_indent=initindent, |
|
1207 | 1208 | subsequent_indent=hangindent) |
|
1208 | return wrapper.fill(line) | |
|
1209 | return wrapper.fill(line).encode(encoding.encoding) | |
|
1209 | 1210 | |
|
1210 | 1211 | def iterlines(iterator): |
|
1211 | 1212 | for chunk in iterator: |
@@ -22,14 +22,14 b' 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 b' 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