How to use the visidata.options 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 / sheets.py View on Github external
def drawColHeader(self, scr, y, h, vcolidx):
        'Compose and draw column header for given vcolidx.'
        col = self.visibleCols[vcolidx]

        # hdrattr highlights whole column header
        # sepattr is for header separators and indicators
        sepcattr = colors.get_color('color_column_sep')

        hdrcattr = self._colorize(col, None)
        if vcolidx == self.cursorVisibleColIndex:
            hdrcattr = update_attr(hdrcattr, colors.color_current_hdr, 2)

        C = options.disp_column_sep
        if (self.keyCols and col is self.keyCols[-1]) or vcolidx == self.rightVisibleColIndex:
            C = options.disp_keycol_sep

        x, colwidth = self.visibleColLayout[vcolidx]

        # AnameTC
        T = getType(col.type).icon
        if T is None:  # still allow icon to be explicitly non-displayed ''
            T = '?'

        hdrs = col.name.split('\n')
        for i in range(h):
            name = ' '  # save room at front for LeftMore
            if h-i-1 < len(hdrs):
                name += hdrs[::-1][h-i-1]
github saulpw / visidata / visidata / sheets.py View on Github external
vd.clear_caches()

        if not self.columns:
            if options.debug:
                self.addColumn(Column())
            else:
                return

        drawparams = {
            'isNull': isNullFunc(),

            'topsep': options.disp_rowtop_sep,
            'midsep': options.disp_rowmid_sep,
            'botsep': options.disp_rowbot_sep,
            'endsep': options.disp_rowend_sep,
            'keytopsep': options.disp_keytop_sep,
            'keymidsep': options.disp_keymid_sep,
            'keybotsep': options.disp_keybot_sep,
            'endtopsep': options.disp_endtop_sep,
            'endmidsep': options.disp_endmid_sep,
            'endbotsep': options.disp_endbot_sep,

            'colsep': options.disp_column_sep,
            'keysep': options.disp_keycol_sep,
            'selectednote': options.disp_selected_note,
        }

        self.rowLayout = {}  # [rowidx] -> (y, height)
        self.calcColLayout()

        numHeaderRows = self.nHeaderRows
        vcolidx = 0
github saulpw / visidata / visidata / _input.py View on Github external
def clean_printable(s):
    'Escape unprintable characters.'
    return ''.join(c if c.isprintable() else options.disp_unprintable for c in str(s))
github saulpw / visidata / visidata / undo.py View on Github external
def addUndo(vd, undofunc, *args, **kwargs):
    'On undo of latest command, call undofunc()'
    if options.undo:
        r = vd.activeCommand
        if not r:
            return
        r.undofuncs.append((undofunc, args, kwargs))
github saulpw / visidata / visidata / loaders / tsv.py View on Github external
def tsv_trdict(vs):
    'returns string.translate dictionary for replacing tabs and newlines'
    if options.safety_first:
        delim = options.get('delimiter', vs)
        return {ord(delim): options.get('tsv_safe_tab', vs), # \t
            10: options.get('tsv_safe_newline', vs),  # \n
            13: options.get('tsv_safe_newline', vs),  # \r
            }
    return {}
github saulpw / visidata / visidata / _sheet.py View on Github external
def splitcell(s, width=0):
    if width <= 0 or not options.textwrap_cells:
        return [s]

    ret = []
    for L in s.splitlines():
        ret.extend(textwrap.wrap(L, width=width, break_long_words=False, replace_whitespace=False))
    return ret
github saulpw / visidata / visidata / sheets.py View on Github external
if not self.columns:
            if options.debug:
                self.addColumn(Column())
            else:
                return

        drawparams = {
            'isNull': isNullFunc(),

            'topsep': options.disp_rowtop_sep,
            'midsep': options.disp_rowmid_sep,
            'botsep': options.disp_rowbot_sep,
            'endsep': options.disp_rowend_sep,
            'keytopsep': options.disp_keytop_sep,
            'keymidsep': options.disp_keymid_sep,
            'keybotsep': options.disp_keybot_sep,
            'endtopsep': options.disp_endtop_sep,
            'endmidsep': options.disp_endmid_sep,
            'endbotsep': options.disp_endbot_sep,

            'colsep': options.disp_column_sep,
            'keysep': options.disp_keycol_sep,
            'selectednote': options.disp_selected_note,
        }

        self.rowLayout = {}  # [rowidx] -> (y, height)
        self.calcColLayout()

        numHeaderRows = self.nHeaderRows
        vcolidx = 0
github saulpw / visidata / visidata / sheets.py View on Github external
def calcColLayout(self):
        'Set right-most visible column, based on calculation.'
        minColWidth = len(options.disp_more_left)+len(options.disp_more_right)
        sepColWidth = len(options.disp_column_sep)
        winWidth = self.windowWidth
        self.visibleColLayout = {}
        x = 0
        vcolidx = 0
        for vcolidx in range(0, self.nVisibleCols):
            col = self.visibleCols[vcolidx]
            if col.width is None and len(self.visibleRows) > 0:
                # handle delayed column width-finding
                col.width = col.getMaxWidth(self.visibleRows)+minColWidth
                if vcolidx != self.nVisibleCols-1:  # let last column fill up the max width
                    col.width = min(col.width, options.default_width)
            width = col.width if col.width is not None else options.default_width
            if col in self.keyCols:
                width = max(width, 1)  # keycols must all be visible
            if col in self.keyCols or vcolidx >= self.leftVisibleColIndex:  # visible columns
github saulpw / visidata / visidata / Sheet.py View on Github external
def drawColHeader(self, vcolidx):
        # choose attribute to highlight column header
        if vcolidx == self.cursorVisibleColIndex:  # cursor is at this column
            hdrattr = colors[options.c_CurHdr]
        elif vcolidx < self.nKeys:
            hdrattr = colors[options.c_KeyCols]
        else:
            hdrattr = colors[options.c_Header]

        col = self.visibleCols[vcolidx]
        x, colwidth = self.visibleColLayout[vcolidx]

        # ANameTC
        typedict = {
                int: '#',
                str: '$',
                float: '%',
                date: '@',
                anytype: ' ',
            }
        T = typedict.get(col.type, '?')
        N = ' ' + (col.name or defaultColNames[vcolidx])  # save room at front for LeftMore
        if len(N) > colwidth-1:
            N = N[:colwidth-len(options.ch_Ellipsis)] + options.ch_Ellipsis