Skip to content

Commit

Permalink
[status] hintStatus on menu line #2546
Browse files Browse the repository at this point in the history
  • Loading branch information
saulpw committed Oct 10, 2024
1 parent 7636756 commit a64bc55
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion visidata/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@BaseSheet.api
def hint_basichelp(sheet):
return 0, '`Alt+[:underline]H[/]` to open the [:underline]H[/]elp menu'
return 0, 'Alt+H to open the [:underline]H[/]elp menu'


@VisiData.api
Expand Down
3 changes: 2 additions & 1 deletion visidata/hint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ def getHint(sheet, *args, **kwargs) -> str:
n = 1
v = r

results.append((n, v))
if v not in sheet.prevHints:
results.append((n, v))
sheet.prevHints[v] += 1
except Exception as e:
vd.debug(f'{f.__name__}: {e}')

if results:
return sorted(results, reverse=True)[0][1]

return ''

vd.addCommand('', 'help-hint', 'status(getHint() or pressMenu("Help"))', 'get context-dependent hint on what to do next')
13 changes: 12 additions & 1 deletion visidata/menu.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import string
import textwrap
import time
import curses

from typing import List, Union
Expand All @@ -17,11 +18,21 @@
vd.theme_option('disp_menu_more', '»', 'command submenu indicator')
vd.theme_option('disp_menu_push', '⎘', 'indicator if command pushes sheet onto sheet stack')
vd.theme_option('disp_menu_input', '…', 'indicator if input required for command')
vd.option('disp_menu_fmt', '| VisiData {vd.version} | Alt+H for help menu', 'right-side menu format string')
vd.option('disp_menu_fmt', '| VisiData {vd.version} | {vd.hintStatus}', 'right-side menu format string')

BaseSheet.init('activeMenuItems', list)
vd.menuRunning = False

@VisiData.property
def hintStatus(vd):
if vd.options.disp_expert <= 0:
if int(time.time()/60) % 2 == 0:
return 'Alt+H for help menu'
else:
return 'Ctrl+G to cycle help sidebar'

return vd.sheet.getHint()

def menudraw(*args):
return clipdraw(*args, truncator='')

Expand Down

0 comments on commit a64bc55

Please sign in to comment.