How to use the visidata.vdtui.Progress function in visidata

To help you get started, we’ve selected a few visidata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saulpw / visidata / visidata / vdtui.py View on Github external
def toggle(self, rows):
        'Toggle selection of given `rows`.'
        for r in Progress(rows, len(self.rows)):
            if not self.unselectRow(r):
                self.selectRow(r)
github saulpw / visidata / visidata / vdtui.py View on Github external
def rotate_range(n, idx, reverse=False):
    if reverse:
        rng = range(idx-1, -1, -1)
        rng2 = range(n-1, idx-1, -1)
    else:
        rng = range(idx+1, n)
        rng2 = range(0, idx+1)

    wrapped = False
    with Progress(total=n) as prog:
        for r in itertools.chain(rng, rng2):
            prog.addProgress(1)
            if not wrapped and r in rng2:
                status('search wrapped')
                wrapped = True
            yield r
github saulpw / visidata / visidata / vdtui.py View on Github external
def select(self, rows, status=True, progress=True):
        "Select given rows. Don't show progress if progress=False; don't show status if status=False."
        before = len(self._selectedRows)
        for r in (Progress(rows) if progress else rows):
            self.selectRow(r)
        if status:
            vd().status('selected %s%s %s' % (len(self._selectedRows)-before, ' more' if before > 0 else '', self.rowtype))
github saulpw / visidata / visidata / vdtui.py View on Github external
def _async_deepcopy(vs, newlist, oldlist):
    for r in Progress(oldlist):
        newlist.append(deepcopy(r))
github saulpw / visidata / visidata / vdtui.py View on Github external
def getValueRows(self, rows):
        'Generate (val, row) for the given `rows` at this Column, excluding errors and nulls.'
        f = isNullFunc()

        for r in Progress(rows):
            try:
                v = self.getTypedValue(r)
                if not f(v):
                    yield v, r
            except Exception:
                pass
github saulpw / visidata / visidata / vdtui.py View on Github external
def _async_deepcopy(vs, newlist, oldlist):
    for r in Progress(oldlist, 'copying'):
        newlist.append(deepcopy(r))
github saulpw / visidata / visidata / vdtui.py View on Github external
def select(self, rows, status=True, progress=True):
        "Bulk select given rows. Don't show progress if progress=False; don't show status if status=False."
        before = len(self._selectedRows)
        if options.bulk_select_clear:
            self._selectedRows.clear()
        for r in (Progress(rows, 'selecting') if progress else rows):
            self.selectRow(r)
        if status:
            if options.bulk_select_clear:
                msg = 'selected %s %s%s' % (len(self._selectedRows), self.rowtype, ' instead' if before > 0 else '')
            else:
                msg = 'selected %s%s %s' % (len(self._selectedRows)-before, ' more' if before > 0 else '', self.rowtype)
            vd.status(msg)
github saulpw / visidata / visidata / vdtui.py View on Github external
def setValuesFromExpr(self, rows, expr):
        compiledExpr = compile(expr, '', 'eval')
        for row in Progress(rows):
            self.setValue(row, self.sheet.evalexpr(compiledExpr, row))
        self.recalc()
        status('set %d values = %s' % (len(rows), expr))
github saulpw / visidata / visidata / vdtui.py View on Github external
def deleteBy(self, func):
        'Delete rows for which func(row) is true.  Returns number of deleted rows.'
        oldrows = copy(self.rows)
        oldidx = self.cursorRowIndex
        ndeleted = 0

        row = None   # row to re-place cursor after
        while oldidx < len(oldrows):
            if not func(oldrows[oldidx]):
                row = self.rows[oldidx]
                break
            oldidx += 1

        self.rows.clear()
        for r in Progress(oldrows):
            if not func(r):
                self.rows.append(r)
                if r is row:
                    self.cursorRowIndex = len(self.rows)-1
            else:
                ndeleted += 1

        status('deleted %s %s' % (ndeleted, self.rowtype))
        return ndeleted