mercurial/encoding.py
branchstable
changeset 48796 c00d3ce4e94b
parent 48671 f1ed5c304f45
child 48875 6000f5b25c9b
equal deleted inserted replaced
48776:b84ff512b645 48796:c00d3ce4e94b
   509 
   509 
   510     width -= len(ellipsis)
   510     width -= len(ellipsis)
   511     if width <= 0:  # no enough room even for ellipsis
   511     if width <= 0:  # no enough room even for ellipsis
   512         return ellipsis[: width + len(ellipsis)]
   512         return ellipsis[: width + len(ellipsis)]
   513 
   513 
       
   514     chars = list(u)
   514     if leftside:
   515     if leftside:
   515         uslice = lambda i: u[i:]
   516         chars.reverse()
   516         concat = lambda s: ellipsis + s
   517     width_so_far = 0
   517     else:
   518     for i, c in enumerate(chars):
   518         uslice = lambda i: u[:-i]
   519         width_so_far += ucolwidth(c)
   519         concat = lambda s: s + ellipsis
   520         if width_so_far > width:
   520     for i in pycompat.xrange(1, len(u)):
   521             break
   521         usub = uslice(i)
   522     chars = chars[:i]
   522         if ucolwidth(usub) <= width:
   523     if leftside:
   523             return concat(usub.encode(_sysstr(encoding)))
   524         chars.reverse()
   524     return ellipsis  # no enough room for multi-column characters
   525     u = u''.join(chars).encode(_sysstr(encoding))
       
   526     if leftside:
       
   527         return ellipsis + u
       
   528     return u + ellipsis
   525 
   529 
   526 
   530 
   527 class normcasespecs(object):
   531 class normcasespecs(object):
   528     """what a platform's normcase does to ASCII strings
   532     """what a platform's normcase does to ASCII strings
   529 
   533