Skip to content

Commit

Permalink
[memo-] fix memo-cell for cells wider than screen
Browse files Browse the repository at this point in the history
  • Loading branch information
midichef committed Feb 26, 2024
1 parent 54a1468 commit a9fb21c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion visidata/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ def memo(vd, name, col, row):
vd.memory[name] = col.getTypedValue(row)
vd.status('memo %s=%s' % (name, col.getDisplayValue(row)))

@Sheet.api
def memo_cell(sheet):
if not sheet.cursorCol or not sheet.cursorRow: return
value_params = dict(prompt='assign value: ', value=sheet.cursorDisplay)
name_params = dict(prompt='to memo name: ')
# edits to memo_value are blocked, to preserve its type #2287
inputs = vd.inputMultiple(memo_name=name_params,
memo_value=value_params,
readonly_keys=('memo_value',))
if not inputs['memo_name']:
vd.fail('memo name cannot be blank')
vd.memory[inputs['memo_name']] = sheet.cursorTypedValue
vd.status(f'memo {inputs["memo_name"]}={sheet.cursorDisplay}')

class MemorySheet(Sheet):
rowtype = 'memos' # rowdef: keys into vd.memory
Expand All @@ -32,4 +45,4 @@ def memosSheet(vd):


Sheet.addCommand('Alt+Shift+M', 'open-memos', 'vd.push(vd.memosSheet)', 'open the Memory Sheet')
Sheet.addCommand('Alt+m', 'memo-cell', r'vd.memory[input("assign \""+cursorCol.getDisplayValue(cursorRow)+"\" to: ")] = cursorCol.getTypedValue(cursorRow)', 'store value in current cell in Memory Sheet')
Sheet.addCommand('Alt+m', 'memo-cell', 'memo_cell()', 'store value in current cell in Memory Sheet')
1 change: 1 addition & 0 deletions visidata/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def isTestableCommand(longname, cmdlist):
'sheet': '',
'col': 'Units',
'row': '5',
'memo-cell': 'rise',
}

@pytest.mark.usefixtures('curses_setup')
Expand Down

0 comments on commit a9fb21c

Please sign in to comment.