Skip to content

Commit

Permalink
Merge pull request #1963 from midichef/two_none_errors
Browse files Browse the repository at this point in the history
[layout-] stop errors: hide-col on empty sheet, inputMultiple()
  • Loading branch information
anjakefala committed Jul 27, 2023
2 parents 4c9b810 + a323571 commit d28bd99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion visidata/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def _throw(v, i):

for k, v in kwargs.items():
promptlen = clipdraw(sheet._scr, y-v.get('dy'), 0, v.get('prompt'), attr, w=sheet.windowWidth-1) #1947
promptlen = clipdraw(sheet._scr, y-v.get('dy'), promptlen, v.get('value'), attr, w=sheet.windowWidth-1)
promptlen = clipdraw(sheet._scr, y-v.get('dy'), promptlen, v.get('value', ''), attr, w=sheet.windowWidth-1)

try:
input_kwargs = kwargs[cur_input_key]
Expand Down
6 changes: 5 additions & 1 deletion visidata/features/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ def unhide_cols(vd, cols, rows):
for c in cols:
c.setWidth(abs(c.width or 0) or c.getMaxWidth(rows))

@VisiData.api
def hide_col(vd, col):
if not col: vd.fail("no columns to hide")
col.hide()

Sheet.addCommand('_', 'resize-col-max', 'cursorCol.toggleWidth(cursorCol.getMaxWidth(visibleRows))', 'toggle width of current column between full and default width')
Sheet.addCommand('z_', 'resize-col-input', 'width = int(input("set width= ", value=cursorCol.width)); cursorCol.setWidth(width)', 'adjust width of current column to N')
Sheet.addCommand('g_', 'resize-cols-max', 'for c in visibleCols: c.setWidth(c.getMaxWidth(visibleRows))', 'toggle widths of all visible columns between full and default width')
Sheet.addCommand('gz_', 'resize-cols-input', 'width = int(input("set width= ", value=cursorCol.width)); Fanout(visibleCols).setWidth(width)', 'adjust widths of all visible columns to N')

Sheet.addCommand('-', 'hide-col', 'cursorCol.hide()', 'Hide current column')
Sheet.addCommand('-', 'hide-col', 'hide_col(cursorCol)', 'Hide current column')
Sheet.addCommand('z-', 'resize-col-half', 'cursorCol.setWidth(cursorCol.width//2)', 'reduce width of current column by half')

Sheet.addCommand('gv', 'unhide-cols', 'unhide_cols(columns, visibleRows)', 'Show all columns')
Expand Down

0 comments on commit d28bd99

Please sign in to comment.