Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[layout-] stop errors: hide-col on empty sheet, inputMultiple() #1963

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading