##// END OF EJS Templates
progress: use 'encoding.colwidth' to get column width of output line correctly...
FUJIWARA Katsunori -
r21860:e382cf9e default
parent child Browse files
Show More
@@ -159,9 +159,9 class progbar(object):
159 if needprogress:
159 if needprogress:
160 used = 0
160 used = 0
161 if head:
161 if head:
162 used += len(head) + 1
162 used += encoding.colwidth(head) + 1
163 if tail:
163 if tail:
164 used += len(tail) + 1
164 used += encoding.colwidth(tail) + 1
165 progwidth = termwidth - used - 3
165 progwidth = termwidth - used - 3
166 if total and pos <= total:
166 if total and pos <= total:
167 amt = pos * progwidth // total
167 amt = pos * progwidth // total
@@ -275,3 +275,21 display are different from each other.
275 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 1/3\r (no-eol) (esc)
275 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 1/3\r (no-eol) (esc)
276 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 2/3\r (no-eol) (esc)
276 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 2/3\r (no-eol) (esc)
277 \r (no-eol) (esc)
277 \r (no-eol) (esc)
278
279 test calculation of bar width, when progress topic contains multi-byte
280 characters, of which length of byte sequence and columns in display
281 are different from each other.
282
283 $ cat >> $HGRCPATH <<EOF
284 > [progress]
285 > format = topic bar
286 > width= 21
287 > # progwidth should be 9 (= 21 - (8+1) - 3)
288 > EOF
289
290 $ hg --encoding utf-8 -y loop --total 3 3
291 \r (no-eol) (esc)
292 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [ ]\r (no-eol) (esc)
293 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [==> ]\r (no-eol) (esc)
294 \xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88 [=====> ]\r (no-eol) (esc)
295 \r (no-eol) (esc)
General Comments 0
You need to be logged in to leave comments. Login now