from visidata import theme, globalCommand, Sheet, CellColorizer theme('color_diff', 'red', 'color of values different from --diff source') theme('color_diff_add', 'yellow', 'color of rows/columns added to --diff source') globalCommand(None, 'setdiff-sheet', 'setDiffSheet(sheet)') def makeDiffColorizer(othersheet): def colorizeDiffs(sheet, col, row, cellval): if not row or not col: return None vcolidx = sheet.visibleCols.index(col) rowidx = sheet.rows.index(row) if vcolidx < len(othersheet.visibleCols) and rowidx < len( othersheet.rows): otherval = othersheet.visibleCols[vcolidx].getDisplayValue( othersheet.rows[rowidx]) if cellval.display != otherval: return 'color_diff' else: return 'color_diff_add' return colorizeDiffs def setDiffSheet(vs): Sheet.colorizers.append(CellColorizer(8, None, makeDiffColorizer(vs)))
# VisiData uses Python native int, float, str, and adds simple date, currency, and anytype. import functools import datetime from visidata import options, theme, Sheet, TypedWrapper from .vdtui import vdtype try: import dateutil.parser except ImportError: pass theme('disp_date_fmt', '%Y-%m-%d', 'default fmtstr to strftime for date values') Sheet.addCommand('z~', 'type-any', 'cursorCol.type = anytype'), Sheet.addCommand('~', 'type-string', 'cursorCol.type = str'), Sheet.addCommand('@', 'type-date', 'cursorCol.type = date'), Sheet.addCommand('#', 'type-int', 'cursorCol.type = int'), Sheet.addCommand('z#', 'type-len', 'cursorCol.type = len'), Sheet.addCommand('$', 'type-currency', 'cursorCol.type = currency'), Sheet.addCommand('%', 'type-float', 'cursorCol.type = float'), floatchars = '+-0123456789.' def currency(s=''): 'dirty float (strip non-numeric characters)' if isinstance(s, str): s = ''.join(ch for ch in s if ch in floatchars)
from contextlib import suppress import collections import curses from visidata import EscapeException, ExpectedException, clipdraw, Sheet, VisiData from visidata import vd, status, error, warning, fail, options, theme, colors from visidata import launchExternalEditor, suspend __all__ = ['confirm', 'choose', 'chooseOne', 'chooseMany', 'CompleteKey'] theme('color_edit_cell', 'normal', 'cell color to use when editing cell') theme('disp_edit_fill', '_', 'edit field fill character') theme('disp_unprintable', '·', 'substitute character for unprintables') VisiData.init('lastInputs', lambda: collections.defaultdict(list) ) # [input_type] -> list of prevInputs # editline helpers class EnableCursor: def __enter__(self): with suppress(curses.error): curses.mousemask(0) curses.curs_set(1) def __exit__(self, exc_type, exc_val, tb): with suppress(curses.error): curses.curs_set(0) curses.mousemask(-1)
import collections import curses from visidata import vd, VisiData, BaseSheet, Sheet, ColumnItem, Column, RowColorizer, options, colors, wrmap, clipdraw, ExpectedException, update_attr, theme __all__ = ['StatusSheet', 'status', 'error', 'fail', 'warning', 'debug'] theme('disp_rstatus_fmt', '{sheet.nRows:9d} {sheet.rowtype} ', 'right-side status format string') theme('disp_status_fmt', '{sheet.shortcut}› {sheet.name}| ', 'status line prefix') theme('disp_lstatus_max', 0, 'maximum length of left status line') theme('disp_status_sep', ' | ', 'separator between statuses') theme('color_keystrokes', 'white', 'color of input keystrokes on status line') theme('color_status', 'bold', 'status line color') theme('color_error', 'red', 'error message color') theme('color_warning', 'yellow', 'warning message color') theme('color_top_status', 'underline', 'top window status bar color') theme('color_active_status', 'bold', ' active window status bar color') theme('color_inactive_status', '8', 'inactive window status bar color') @VisiData.lazy_property def statuses(vd): return collections.OrderedDict( ) # (priority, statusmsg) -> num_repeats; shown until next action @VisiData.lazy_property def statusHistory(vd):
TypedExceptionWrapper, getGlobals, BaseSheet, UNLOADED, vd, getType, clipdraw, ColorAttr, update_attr, colors, undoAttrFunc) __all__ = ['RowColorizer', 'CellColorizer', 'ColumnColorizer', 'Sheet', 'IndexSheet', 'SheetsSheet', 'LazyComputeRow', 'SequenceSheet'] option('default_width', 20, 'default column width', replay=True) # TODO: make not replay and remove from markdown saver option('textwrap_cells', True, 'wordwrap text for multiline rows') option('cmd_after_edit', 'go-down', 'command longname to execute after successful edit') option('quitguard', False, 'confirm before quitting last sheet') option('debug', False, 'exit on error and display stacktrace') option('skip', 0, 'skip N rows before header', replay=True) option('header', 1, 'parse first N rows as column names', replay=True) theme('force_256_colors', False, 'use 256 colors even if curses reports fewer') theme('use_default_colors', False, 'curses use default terminal colors') theme('disp_note_none', '⌀', 'visible contents of a cell whose value is None') theme('disp_truncator', '…', 'indicator that the contents are only partially visible') theme('disp_oddspace', '\u00b7', 'displayable character for odd whitespace') theme('disp_more_left', '<', 'header note indicating more columns to the left') theme('disp_more_right', '>', 'header note indicating more columns to the right') theme('disp_error_val', '', 'displayed contents for computation exception') theme('disp_ambig_width', 1, 'width to use for unicode chars marked ambiguous') theme('disp_pending', '', 'string to display in pending cells') theme('note_pending', '⌛', 'note to display for pending cells') theme('note_format_exc', '?', 'cell note for an exception during formatting') theme('note_getter_exc', '!', 'cell note for an exception during computation') theme('note_type_exc', '!', 'cell note for an exception during type conversion')