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

[sheets-] record key-col toggle for replay as key-col-on/-off #2622

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions visidata/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,12 @@ def keystr(sheet, row):
return sheet.rowname(row)

vd.optalias('color_refline', 'color_graph_refline') # color_refline was used in v3.1 by mistake

@deprecated('3.2', '[self.unsetKeys([c]) if c.keycol else self.setKeys([c]) for c in cols]')
@visidata.TableSheet.api
def toggleKeys(self, cols):
for col in cols:
if col.keycol:
self.unsetKeys([col])
else:
self.setKeys([col])
7 changes: 4 additions & 3 deletions visidata/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ def afterExecSheet(cmdlog, sheet, escaped, err):
if not vd.activeCommand: return
if vd.activeCommand.longname == 'macro-record': return

cmd = copy(vd.activeCommand)
cmd.sheet = ''
vd.macroMode.addRow(cmd)
if vd.activeCommand.replayable:
cmd = copy(vd.activeCommand)
cmd.sheet = ''
vd.macroMode.addRow(cmd)


@CommandLogJsonl.api
Expand Down
10 changes: 2 additions & 8 deletions visidata/sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,6 @@ def unsetKeys(self, cols):
for col in cols:
col.keycol = 0

def toggleKeys(self, cols):
for col in cols:
if col.keycol:
self.unsetKeys([col])
else:
self.setKeys([col])

def rowkey(self, row):
'Return tuple of the key for *row*.'
return tuple(c.getTypedValue(row) for c in self.keyCols)
Expand Down Expand Up @@ -1192,7 +1185,8 @@ def _async_deepcopy(newlist, oldlist):
BaseSheet.addCommand('^R', 'reload-sheet', 'preloadHook(); reload()', 'Reload current sheet')
Sheet.addCommand('', 'show-cursor', 'status(statusLine)', 'show cursor position and bounds of current sheet on status line')

Sheet.addCommand('!', 'key-col', 'toggleKeys([cursorCol])', 'toggle current column as a key column')
Sheet.addCommand('!', 'key-col', 'exec_longname("key-col-off") if cursorCol.keycol else exec_longname("key-col-on")', 'toggle current column as a key column', replay=False)
Sheet.addCommand('', 'key-col-on', 'setKeys([cursorCol])', 'set current column as a key column')
Sheet.addCommand('z!', 'key-col-off', 'unsetKeys([cursorCol])', 'unset current column as a key column')

Sheet.addCommand('e', 'edit-cell', 'cursorCol.setValues([cursorRow], editCell(cursorVisibleColIndex)) if not (cursorRow is None) else fail("no rows to edit")', 'edit contents of current cell')
Expand Down
Loading