Skip to content

Commit

Permalink
[macro] record all commands; add status indicator #2435
Browse files Browse the repository at this point in the history
add even commands nonloggable commands to the current macro when recording.
  • Loading branch information
saulpw committed Sep 23, 2024
1 parent 2515b9b commit 8cde857
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion visidata/cmdlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

vd.option('replay_wait', 0.0, 'time to wait between replayed commands, in seconds', sheettype=None)
vd.theme_option('disp_replay_play', '▶', 'status indicator for active replay')
vd.theme_option('disp_replay_record', '⏺', 'status indicator for macro record')
vd.theme_option('color_status_replay', 'green', 'color of replay status indicator')

# prefixes which should not be logged
Expand Down Expand Up @@ -384,8 +385,12 @@ def setLastArgs(vd, args):

@VisiData.property
def replayStatus(vd):
if vd.macroMode:
return f'|[:error] {len(vd.macroMode)} {vd.options.disp_replay_record} [:]'

if vd._nextCommands:
return f' | [:status_replay] {len(vd._nextCommands)} {vd.options.disp_replay_play}[:]'
return f'|[:status_replay] {len(vd._nextCommands)} {vd.options.disp_replay_play} [:]'

return ''


Expand Down
9 changes: 5 additions & 4 deletions visidata/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ def saveMacro(self, rows, ks):
def afterExecSheet(cmdlog, sheet, escaped, err):
if not vd.macroMode: return
if not vd.activeCommand: return
if vd.isLoggableCommand(vd.activeCommand):
cmd = copy(vd.activeCommand)
cmd.sheet = ''
vd.macroMode.addRow(cmd)
if vd.activeCommand.longname == 'macro-record': return

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


@CommandLogJsonl.api
Expand Down

0 comments on commit 8cde857

Please sign in to comment.