From 5ec1ba5c72f5d1f36abfb45aa88aa048b574dc30 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Wed, 22 Nov 2023 23:40:08 -0800 Subject: [PATCH 01/11] [guide] add API for getting and adding guides --- visidata/__init__.py | 1 + visidata/experimental/guide.py | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/visidata/__init__.py b/visidata/__init__.py index f79426f21..b723ee4a7 100644 --- a/visidata/__init__.py +++ b/visidata/__init__.py @@ -68,6 +68,7 @@ def getGlobals(): import visidata.textsheet import visidata.threads import visidata.path +import visidata.experimental.guide import visidata._input import visidata.tuiwin diff --git a/visidata/experimental/guide.py b/visidata/experimental/guide.py index b61ecc0d7..c13c8062a 100644 --- a/visidata/experimental/guide.py +++ b/visidata/experimental/guide.py @@ -9,15 +9,20 @@ import re -from visidata import vd, BaseSheet, Sheet, ItemColumn, Column, VisiData +from visidata import vd, BaseSheet, Sheet, ItemColumn, Column, VisiData, ENTER +vd.guides = {} # guidename -> guideobj + +@VisiData.api +def addGuide(vd, guidename, guideobj): + vd.guides[guidename] = guideobj @VisiData.api class GuideGuide(Sheet): help = __doc__ columns = [ ItemColumn('n', 0, type=int), - ItemColumn('sheetname', 1, width=0), + ItemColumn('guidename', 1, width=0), ItemColumn('topic', 2, width=60), Column('points', type=int, getter=lambda c,r: 0), Column('max_points', type=int, getter=lambda c,r: 100), @@ -86,4 +91,15 @@ def iterload(self): yield [i] + list(m.groups()) i += 1 -BaseSheet.addCommand('', 'open-guide', 'vd.push(GuideGuide("VisiData_Guide"))') +@VisiData.api +def getGuide(vd, guidename): + if guidename in vd.guides: + return vd.guides[guidename] + vd.warning(f'there is no guide: {guidename}') + +BaseSheet.addCommand('', 'open-guide', 'vd.push(GuideGuide("VisiData_Guide"))', 'opens guide to features in VisiData') +GuideGuide.addCommand(ENTER, 'open-guide-row', 'vd.push(vd.getGuide(cursorRow[1]))') + +vd.addMenuItems(''' + Help > Guide > open-guide +''') From ab0d438de246961bf0fca502406ff97b5f70aaa3 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Wed, 22 Nov 2023 23:40:23 -0800 Subject: [PATCH 02/11] [guide] add a macros guide --- visidata/macros.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/visidata/macros.py b/visidata/macros.py index 19eefcd6e..8de856a62 100644 --- a/visidata/macros.py +++ b/visidata/macros.py @@ -4,7 +4,7 @@ from visidata.cmdlog import CommandLog, CommandLogJsonl from visidata import vd, UNLOADED, asyncthread -from visidata import IndexSheet, VisiData, Sheet, Path, VisiDataMetaSheet, Column, ItemColumn, BaseSheet +from visidata import IndexSheet, VisiData, Sheet, Path, VisiDataMetaSheet, Column, ItemColumn, BaseSheet, TextSheet vd.macroMode = None vd.macrobindings = {} @@ -125,11 +125,13 @@ def startMacro(cmdlog): vd.status("recording macro; stop recording with `m`") vd.macroMode = CommandLogJsonl('current_macro', rows=[]) - @VisiData.before def run(vd, *args, **kwargs): vd.macrosheet +class MacrosGuide(TextSheet): + pass + Sheet.addCommand('m', 'macro-record', 'vd.cmdlog.startMacro()', 'record macro') Sheet.addCommand('gm', 'macro-sheet', 'vd.push(vd.macrosheet)', 'open macros sheet') @@ -137,3 +139,24 @@ def run(vd, *args, **kwargs): vd.addMenuItems(''' System > Macros sheet > macro-sheet ''') + +vd.addGuide('MacrosSheet', MacrosGuide(source = '''# Macros +Macros allow you to bind a series of commands to a key and then replay those commands within a session by using that keystroke. + +The basic usage is: + 1. Press `m` (macro-record) to begin recording the macro. + 2. Go through the commands you wish to record. + 3. Then type `m` again to complete the recording, and prompt for the keystroke or longname to bind it to. + +The macro will then be executed everytime the provided keystroke is used. Note: the Alt+keys and the function keys are left unbound; overridding other keys may conflict with existing bindings, now or in the future. + +Executing a macro will the series of commands starting on the current row and column on the current sheet. + +# The Macros Sheet + +Use `gm` (`open-macros-or-whatever`) to open an index existing macros. + +Macros can be marked for deletion (with `d`). Changes can then be committed with `z Ctrl+S`. + +`Enter` will open the macro in the current row, and you can view the series of commands composing it.'''.splitlines() +) ) From 831acc2cbf651c2968c63b55024a8ceca16a5766 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Fri, 24 Nov 2023 17:54:35 -0800 Subject: [PATCH 03/11] [guide] rework API to use a GuideSheet --- visidata/experimental/guide.py | 30 +++++++++++++++++++++++++++++- visidata/macros.py | 31 +++++++++++++++---------------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/visidata/experimental/guide.py b/visidata/experimental/guide.py index c13c8062a..b59ad60dc 100644 --- a/visidata/experimental/guide.py +++ b/visidata/experimental/guide.py @@ -10,6 +10,7 @@ import re from visidata import vd, BaseSheet, Sheet, ItemColumn, Column, VisiData, ENTER +from visidata import wraptext vd.guides = {} # guidename -> guideobj @@ -91,6 +92,32 @@ def iterload(self): yield [i] + list(m.groups()) i += 1 + def openRow(self, row): + guidename = row[1] + return vd.getGuide(guidename) + +class GuideSheet(Sheet): + rowtype = 'lines' + filetype = 'guide' + columns = [ + ItemColumn('linenum', 0, type=int, width=0), + ItemColumn('guide', 1, width=80, displayer='full'), + ] + precious = False + guide = '' + + def iterload(self): + winWidth = 78 + for startingLine, text in enumerate(self.guide.splitlines()): + text = text.strip() + if text: + for i, (L, _) in enumerate(wraptext(str(text), width=winWidth)): + yield [startingLine+i+1, L] + else: + yield [startingLine+1, text] + + + @VisiData.api def getGuide(vd, guidename): if guidename in vd.guides: @@ -98,8 +125,9 @@ def getGuide(vd, guidename): vd.warning(f'there is no guide: {guidename}') BaseSheet.addCommand('', 'open-guide', 'vd.push(GuideGuide("VisiData_Guide"))', 'opens guide to features in VisiData') -GuideGuide.addCommand(ENTER, 'open-guide-row', 'vd.push(vd.getGuide(cursorRow[1]))') vd.addMenuItems(''' Help > Guide > open-guide ''') + +vd.addGlobals({'GuideSheet':GuideSheet}) diff --git a/visidata/macros.py b/visidata/macros.py index 8de856a62..c2eaf14a3 100644 --- a/visidata/macros.py +++ b/visidata/macros.py @@ -4,7 +4,7 @@ from visidata.cmdlog import CommandLog, CommandLogJsonl from visidata import vd, UNLOADED, asyncthread -from visidata import IndexSheet, VisiData, Sheet, Path, VisiDataMetaSheet, Column, ItemColumn, BaseSheet, TextSheet +from visidata import IndexSheet, VisiData, Sheet, Path, VisiDataMetaSheet, Column, ItemColumn, BaseSheet, GuideSheet vd.macroMode = None vd.macrobindings = {} @@ -129,18 +129,8 @@ def startMacro(cmdlog): def run(vd, *args, **kwargs): vd.macrosheet -class MacrosGuide(TextSheet): - pass - - -Sheet.addCommand('m', 'macro-record', 'vd.cmdlog.startMacro()', 'record macro') -Sheet.addCommand('gm', 'macro-sheet', 'vd.push(vd.macrosheet)', 'open macros sheet') - -vd.addMenuItems(''' - System > Macros sheet > macro-sheet -''') - -vd.addGuide('MacrosSheet', MacrosGuide(source = '''# Macros +class MacrosGuide(GuideSheet): + guide = '''# Macros Macros allow you to bind a series of commands to a key and then replay those commands within a session by using that keystroke. The basic usage is: @@ -154,9 +144,18 @@ class MacrosGuide(TextSheet): # The Macros Sheet -Use `gm` (`open-macros-or-whatever`) to open an index existing macros. +Use `gm` (`macro-sheet`) to open an index existing macros. Macros can be marked for deletion (with `d`). Changes can then be committed with `z Ctrl+S`. -`Enter` will open the macro in the current row, and you can view the series of commands composing it.'''.splitlines() -) ) +`Enter` will open the macro in the current row, and you can view the series of commands composing it.''' + + +Sheet.addCommand('m', 'macro-record', 'vd.cmdlog.startMacro()', 'record macro') +Sheet.addCommand('gm', 'macro-sheet', 'vd.push(vd.macrosheet)', 'open macros sheet') + +vd.addMenuItems(''' + System > Macros sheet > macro-sheet +''') + +vd.addGuide('MacrosSheet', MacrosGuide()) From f857aaf600887229d984ae35f7da86c42c33e1d2 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Fri, 24 Nov 2023 22:34:51 -0800 Subject: [PATCH 04/11] [interface] add color_h1 for markdown formatting --- visidata/cliptext.py | 1 + visidata/interface.py | 1 + 2 files changed, 2 insertions(+) diff --git a/visidata/cliptext.py b/visidata/cliptext.py index d34ff1967..9bff7fad5 100644 --- a/visidata/cliptext.py +++ b/visidata/cliptext.py @@ -282,6 +282,7 @@ def clipdraw_chunks(scr, y, x, chunks, cattr:ColorAttr=ColorAttr(), w=None, clea def _markdown_to_internal(text): 'Return markdown-formatted `text` converted to internal formatting (like `[:color]text[/]`).' text = re.sub(r'`(.*?)`', r'[:code]\1[/]', text) + text = re.sub(r'(#.*?)$', r'[:h1]\1[/]', text) text = re.sub(r'\*\*(.*?)\*\*', r'[:bold]\1[/]', text) text = re.sub(r'\*(.*?)\*', r'[:italic]\1[/]', text) text = re.sub(r'\b_(.*?)_\b', r'[:underline]\1[/]', text) diff --git a/visidata/interface.py b/visidata/interface.py index 12fe5824b..12a2485bb 100644 --- a/visidata/interface.py +++ b/visidata/interface.py @@ -47,6 +47,7 @@ vd.theme_option('color_selected_row', '215 yellow', 'color of selected rows') vd.theme_option('color_clickable', 'underline', 'color of internally clickable item') vd.theme_option('color_code', 'bold white on 237', 'color of code sample') +vd.theme_option('color_h1', 'bold 209', 'color of h1 header') vd.theme_option('force_256_colors', False, 'use 256 colors even if curses reports fewer') From ba2db677896aa359e81bb12f7f6d7e28e8f58bc0 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Fri, 24 Nov 2023 22:44:24 -0800 Subject: [PATCH 05/11] [guide] move guide to core --- visidata/__init__.py | 2 +- visidata/{experimental => }/guide.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename visidata/{experimental => }/guide.py (100%) diff --git a/visidata/__init__.py b/visidata/__init__.py index b723ee4a7..f01d9d15f 100644 --- a/visidata/__init__.py +++ b/visidata/__init__.py @@ -68,7 +68,7 @@ def getGlobals(): import visidata.textsheet import visidata.threads import visidata.path -import visidata.experimental.guide +import visidata.guide import visidata._input import visidata.tuiwin diff --git a/visidata/experimental/guide.py b/visidata/guide.py similarity index 100% rename from visidata/experimental/guide.py rename to visidata/guide.py From 38dcfd8e61941047d9f6d6fd1edf47b163ab3ae3 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Fri, 24 Nov 2023 22:48:58 -0800 Subject: [PATCH 06/11] [interface-] color_h1 must also be clear in sidebar --- visidata/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visidata/interface.py b/visidata/interface.py index 12a2485bb..815b704df 100644 --- a/visidata/interface.py +++ b/visidata/interface.py @@ -47,7 +47,7 @@ vd.theme_option('color_selected_row', '215 yellow', 'color of selected rows') vd.theme_option('color_clickable', 'underline', 'color of internally clickable item') vd.theme_option('color_code', 'bold white on 237', 'color of code sample') -vd.theme_option('color_h1', 'bold 209', 'color of h1 header') +vd.theme_option('color_h1', 'bold 200', 'color of h1 header') vd.theme_option('force_256_colors', False, 'use 256 colors even if curses reports fewer') From 6a88c0b1ee67cf6e38b74ac90f8e776672d64e2c Mon Sep 17 00:00:00 2001 From: anjakefala Date: Fri, 24 Nov 2023 22:58:19 -0800 Subject: [PATCH 07/11] [guide] colour unwritten guides grey --- visidata/guide.py | 13 ++++++++----- visidata/interface.py | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/visidata/guide.py b/visidata/guide.py index b59ad60dc..96ae6dd60 100644 --- a/visidata/guide.py +++ b/visidata/guide.py @@ -1,15 +1,15 @@ ''' # A Guide to VisiData Guides -Each guide shows you how to use a particular feature in VisiData. +Each guide shows you how to use a particular feature in VisiData. Gray guides have not been written yet. Why not contribute one? - [:keys]Up/Down[/] to move the row cursor - [:keys]Enter[/] to view a topic - [:keys]Backspace[/] to come back to this list of guides +- [:keystrokes]Up/Down[/] to move the row cursor +- [:keystrokes]Enter[/] to view a topic +- [:keystrokes]Backspace[/] to come back to this list of guides ''' import re -from visidata import vd, BaseSheet, Sheet, ItemColumn, Column, VisiData, ENTER +from visidata import vd, BaseSheet, Sheet, ItemColumn, Column, VisiData, ENTER, RowColorizer from visidata import wraptext vd.guides = {} # guidename -> guideobj @@ -28,6 +28,9 @@ class GuideGuide(Sheet): Column('points', type=int, getter=lambda c,r: 0), Column('max_points', type=int, getter=lambda c,r: 100), ] + colorizers = [ + RowColorizer(7, 'color_guide_dne', lambda s,c,r,v: r and r[1] not in vd.guides) + ] def iterload(self): i = 0 for line in ''' diff --git a/visidata/interface.py b/visidata/interface.py index 815b704df..ee98e2ee4 100644 --- a/visidata/interface.py +++ b/visidata/interface.py @@ -48,6 +48,7 @@ vd.theme_option('color_clickable', 'underline', 'color of internally clickable item') vd.theme_option('color_code', 'bold white on 237', 'color of code sample') vd.theme_option('color_h1', 'bold 200', 'color of h1 header') +vd.theme_option('color_guide_unwritten', '243 on black', 'color of unwritten guides in GuideGuide') vd.theme_option('force_256_colors', False, 'use 256 colors even if curses reports fewer') From dcc648b06d16a6cf8e3d9ab8a5cbadf386b97bc3 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Sat, 25 Nov 2023 19:18:05 -0800 Subject: [PATCH 08/11] [color] rename color_h1 to color_heading --- visidata/cliptext.py | 2 +- visidata/guide.py | 2 +- visidata/interface.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/visidata/cliptext.py b/visidata/cliptext.py index 9bff7fad5..4a481a38f 100644 --- a/visidata/cliptext.py +++ b/visidata/cliptext.py @@ -282,7 +282,7 @@ def clipdraw_chunks(scr, y, x, chunks, cattr:ColorAttr=ColorAttr(), w=None, clea def _markdown_to_internal(text): 'Return markdown-formatted `text` converted to internal formatting (like `[:color]text[/]`).' text = re.sub(r'`(.*?)`', r'[:code]\1[/]', text) - text = re.sub(r'(#.*?)$', r'[:h1]\1[/]', text) + text = re.sub(r'(#.*?)$', r'[:heading]\1[/]', text) text = re.sub(r'\*\*(.*?)\*\*', r'[:bold]\1[/]', text) text = re.sub(r'\*(.*?)\*', r'[:italic]\1[/]', text) text = re.sub(r'\b_(.*?)_\b', r'[:underline]\1[/]', text) diff --git a/visidata/guide.py b/visidata/guide.py index 96ae6dd60..c5dfb0d20 100644 --- a/visidata/guide.py +++ b/visidata/guide.py @@ -29,7 +29,7 @@ class GuideGuide(Sheet): Column('max_points', type=int, getter=lambda c,r: 100), ] colorizers = [ - RowColorizer(7, 'color_guide_dne', lambda s,c,r,v: r and r[1] not in vd.guides) + RowColorizer(7, 'color_guide_unwritten', lambda s,c,r,v: r and r[1] not in vd.guides) ] def iterload(self): i = 0 diff --git a/visidata/interface.py b/visidata/interface.py index ee98e2ee4..4ccaf3a06 100644 --- a/visidata/interface.py +++ b/visidata/interface.py @@ -47,7 +47,7 @@ vd.theme_option('color_selected_row', '215 yellow', 'color of selected rows') vd.theme_option('color_clickable', 'underline', 'color of internally clickable item') vd.theme_option('color_code', 'bold white on 237', 'color of code sample') -vd.theme_option('color_h1', 'bold 200', 'color of h1 header') +vd.theme_option('color_heading', 'bold 200', 'color of header') vd.theme_option('color_guide_unwritten', '243 on black', 'color of unwritten guides in GuideGuide') vd.theme_option('force_256_colors', False, 'use 256 colors even if curses reports fewer') From f236a50513bc3f40edcb7c547af33d219362df08 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Sat, 25 Nov 2023 21:08:04 -0800 Subject: [PATCH 09/11] [guide] add polish to the GuideGuide Add rowdef and rowtype. guidename -> name Improve documentation and error messaging. open-guide -> open-guide-index --- visidata/guide.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/visidata/guide.py b/visidata/guide.py index c5dfb0d20..9361e4f8f 100644 --- a/visidata/guide.py +++ b/visidata/guide.py @@ -1,6 +1,6 @@ ''' # A Guide to VisiData Guides -Each guide shows you how to use a particular feature in VisiData. Gray guides have not been written yet. Why not contribute one? +Each guide shows you how to use a particular feature in VisiData. Gray guides have not been written yet. We love contributions: [:onclick https://visidata.org/docs/guides]https://visidata.org/docs/guides[/]. - [:keystrokes]Up/Down[/] to move the row cursor - [:keystrokes]Enter[/] to view a topic @@ -12,18 +12,19 @@ from visidata import vd, BaseSheet, Sheet, ItemColumn, Column, VisiData, ENTER, RowColorizer from visidata import wraptext -vd.guides = {} # guidename -> guideobj +vd.guides = {} # name -> guideobj @VisiData.api -def addGuide(vd, guidename, guideobj): - vd.guides[guidename] = guideobj +def addGuide(vd, name, guideobj): + vd.guides[name] = guideobj @VisiData.api class GuideGuide(Sheet): help = __doc__ + rowtype = 'guides' # rowdef: list(guide number, guide name, topic description, points, max_points) columns = [ ItemColumn('n', 0, type=int), - ItemColumn('guidename', 1, width=0), + ItemColumn('name', 1, width=0), ItemColumn('topic', 2, width=60), Column('points', type=int, getter=lambda c,r: 0), Column('max_points', type=int, getter=lambda c,r: 100), @@ -96,8 +97,8 @@ def iterload(self): i += 1 def openRow(self, row): - guidename = row[1] - return vd.getGuide(guidename) + name = row[1] + return vd.getGuide(name) class GuideSheet(Sheet): rowtype = 'lines' @@ -122,15 +123,15 @@ def iterload(self): @VisiData.api -def getGuide(vd, guidename): - if guidename in vd.guides: - return vd.guides[guidename] - vd.warning(f'there is no guide: {guidename}') +def getGuide(vd, name): + if name in vd.guides: + return vd.guides[name] + vd.warning(f'no guide named {name}') -BaseSheet.addCommand('', 'open-guide', 'vd.push(GuideGuide("VisiData_Guide"))', 'opens guide to features in VisiData') +BaseSheet.addCommand('', 'open-guide-index', 'vd.push(GuideGuide("VisiData_Guide"))', 'open VisiData guides table of contents') vd.addMenuItems(''' - Help > Guide > open-guide + Help > VisiData Feature Guides > open-guide-index ''') vd.addGlobals({'GuideSheet':GuideSheet}) From 0516491c6a7935500b7cee2fb4ca31d7fdfda679 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Sat, 25 Nov 2023 21:09:04 -0800 Subject: [PATCH 10/11] [macros docs] improve guide text Mention macros can be set to both keystrokes and longnames. Use pattern of "Use command to imperative" for command text. --- visidata/macros.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/visidata/macros.py b/visidata/macros.py index c2eaf14a3..877ce39bd 100644 --- a/visidata/macros.py +++ b/visidata/macros.py @@ -131,24 +131,24 @@ def run(vd, *args, **kwargs): class MacrosGuide(GuideSheet): guide = '''# Macros -Macros allow you to bind a series of commands to a key and then replay those commands within a session by using that keystroke. +Macros allow you to bind a command sequence to a keystroke or longname, to replay when that keystroke is pressed or the command is executed by longname. The basic usage is: 1. Press `m` (macro-record) to begin recording the macro. 2. Go through the commands you wish to record. 3. Then type `m` again to complete the recording, and prompt for the keystroke or longname to bind it to. -The macro will then be executed everytime the provided keystroke is used. Note: the Alt+keys and the function keys are left unbound; overridding other keys may conflict with existing bindings, now or in the future. +The macro will then be executed everytime the provided keystroke or longname are used. Note: the Alt+keys and the function keys are left unbound; overriding other keys may conflict with existing bindings, now or in the future. Executing a macro will the series of commands starting on the current row and column on the current sheet. # The Macros Sheet -Use `gm` (`macro-sheet`) to open an index existing macros. +Use `gm` (`macro-sheet`) to open an index of existing macros. -Macros can be marked for deletion (with `d`). Changes can then be committed with `z Ctrl+S`. +Use `d` to mark macros for deletion. Use `z Ctrl+S` to then commit any changes. -`Enter` will open the macro in the current row, and you can view the series of commands composing it.''' +`Enter` to open the macro in the current row, and you can view the series of commands composing it.''' Sheet.addCommand('m', 'macro-record', 'vd.cmdlog.startMacro()', 'record macro') From 4ab3551e5d69f0d00eca8718d491f5864fde8601 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Sat, 25 Nov 2023 21:56:22 -0800 Subject: [PATCH 11/11] [guide perf] addGuide now sets a class, and getGuide instantiates --- visidata/guide.py | 10 +++++----- visidata/macros.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/visidata/guide.py b/visidata/guide.py index 9361e4f8f..e8e5c4eec 100644 --- a/visidata/guide.py +++ b/visidata/guide.py @@ -12,11 +12,11 @@ from visidata import vd, BaseSheet, Sheet, ItemColumn, Column, VisiData, ENTER, RowColorizer from visidata import wraptext -vd.guides = {} # name -> guideobj +vd.guides = {} # name -> guidecls @VisiData.api -def addGuide(vd, name, guideobj): - vd.guides[name] = guideobj +def addGuide(vd, name, guidecls): + vd.guides[name] = guidecls @VisiData.api class GuideGuide(Sheet): @@ -123,9 +123,9 @@ def iterload(self): @VisiData.api -def getGuide(vd, name): +def getGuide(vd, name): # -> GuideSheet() if name in vd.guides: - return vd.guides[name] + return vd.guides[name]() vd.warning(f'no guide named {name}') BaseSheet.addCommand('', 'open-guide-index', 'vd.push(GuideGuide("VisiData_Guide"))', 'open VisiData guides table of contents') diff --git a/visidata/macros.py b/visidata/macros.py index 877ce39bd..db07a75c2 100644 --- a/visidata/macros.py +++ b/visidata/macros.py @@ -158,4 +158,4 @@ class MacrosGuide(GuideSheet): System > Macros sheet > macro-sheet ''') -vd.addGuide('MacrosSheet', MacrosGuide()) +vd.addGuide('MacrosSheet', MacrosGuide)