Example #1
0
 def pad(s, l):
     return s + " " * (l - encoding.colwidth(s))
Example #2
0
def subsubsubsection(ui, s):
    ui.write("%s\n%s\n\n" % (s, "#" * encoding.colwidth(s)))
Example #3
0
 def show(self, now, topic, pos, item, unit, total):
     if not shouldprint(self.ui):
         return
     termwidth = self.width()
     self.printed = True
     head = ''
     needprogress = False
     tail = ''
     for indicator in self.order:
         add = ''
         if indicator == 'topic':
             add = topic
         elif indicator == 'number':
             if total:
                 add = ('% ' + str(len(str(total))) + 's/%s') % (pos, total)
             else:
                 add = str(pos)
         elif indicator.startswith('item') and item:
             slice = 'end'
             if '-' in indicator:
                 wid = int(indicator.split('-')[1])
             elif '+' in indicator:
                 slice = 'beginning'
                 wid = int(indicator.split('+')[1])
             else:
                 wid = 20
             if slice == 'end':
                 add = encoding.trim(item, wid, leftside=True)
             else:
                 add = encoding.trim(item, wid)
             add += (wid - encoding.colwidth(add)) * ' '
         elif indicator == 'bar':
             add = ''
             needprogress = True
         elif indicator == 'unit' and unit:
             add = unit
         elif indicator == 'estimate':
             add = self.estimate(topic, pos, total, now)
         elif indicator == 'speed':
             add = self.speed(topic, pos, unit, now)
         if not needprogress:
             head = spacejoin(head, add)
         else:
             tail = spacejoin(tail, add)
     if needprogress:
         used = 0
         if head:
             used += encoding.colwidth(head) + 1
         if tail:
             used += encoding.colwidth(tail) + 1
         progwidth = termwidth - used - 3
         if total and pos <= total:
             amt = pos * progwidth // total
             bar = '=' * (amt - 1)
             if amt > 0:
                 bar += '>'
             bar += ' ' * (progwidth - amt)
         else:
             progwidth -= 3
             self.indetcount += 1
             # mod the count by twice the width so we can make the
             # cursor bounce between the right and left sides
             amt = self.indetcount % (2 * progwidth)
             amt -= progwidth
             bar = (' ' * int(progwidth - abs(amt)) + '<=>' +
                    ' ' * int(abs(amt)))
         prog = ''.join(('[', bar, ']'))
         out = spacejoin(head, prog, tail)
     else:
         out = spacejoin(head, tail)
     sys.stderr.write('\r' + encoding.trim(out, termwidth))
     self.lasttopic = topic
     sys.stderr.flush()
Example #4
0
def subsubsubsection(ui, s):
    ui.write("%s\n%s\n\n" % (s, "#" * encoding.colwidth(s)))
Example #5
0
 def pad(s, l):
     return s + " " * (l - encoding.colwidth(s))
Example #6
0
 def subsection(s):
     ui.write("%s\n%s\n\n" % (s, '"' * encoding.colwidth(s)))
Example #7
0
 def section(s):
     ui.write("%s\n%s\n\n" % (s, "-" * encoding.colwidth(s)))
Example #8
0
 def show(self, now, topic, pos, item, unit, total):
     if not shouldprint(self.ui):
         return
     termwidth = self.width()
     self.printed = True
     head = ''
     needprogress = False
     tail = ''
     for indicator in self.order:
         add = ''
         if indicator == 'topic':
             add = topic
         elif indicator == 'number':
             if total:
                 add = ('% ' + str(len(str(total))) +
                        's/%s') % (pos, total)
             else:
                 add = str(pos)
         elif indicator.startswith('item') and item:
             slice = 'end'
             if '-' in indicator:
                 wid = int(indicator.split('-')[1])
             elif '+' in indicator:
                 slice = 'beginning'
                 wid = int(indicator.split('+')[1])
             else:
                 wid = 20
             if slice == 'end':
                 add = encoding.trim(item, wid, leftside=True)
             else:
                 add = encoding.trim(item, wid)
             add += (wid - encoding.colwidth(add)) * ' '
         elif indicator == 'bar':
             add = ''
             needprogress = True
         elif indicator == 'unit' and unit:
             add = unit
         elif indicator == 'estimate':
             add = self.estimate(topic, pos, total, now)
         elif indicator == 'speed':
             add = self.speed(topic, pos, unit, now)
         if not needprogress:
             head = spacejoin(head, add)
         else:
             tail = spacejoin(tail, add)
     if needprogress:
         used = 0
         if head:
             used += encoding.colwidth(head) + 1
         if tail:
             used += encoding.colwidth(tail) + 1
         progwidth = termwidth - used - 3
         if total and pos <= total:
             amt = pos * progwidth // total
             bar = '=' * (amt - 1)
             if amt > 0:
                 bar += '>'
             bar += ' ' * (progwidth - amt)
         else:
             progwidth -= 3
             self.indetcount += 1
             # mod the count by twice the width so we can make the
             # cursor bounce between the right and left sides
             amt = self.indetcount % (2 * progwidth)
             amt -= progwidth
             bar = (' ' * int(progwidth - abs(amt)) + '<=>' +
                    ' ' * int(abs(amt)))
         prog = ''.join(('[', bar , ']'))
         out = spacejoin(head, prog, tail)
     else:
         out = spacejoin(head, tail)
     sys.stderr.write('\r' + encoding.trim(out, termwidth))
     self.lasttopic = topic
     sys.stderr.flush()