-
-
Notifications
You must be signed in to change notification settings - Fork 312
feature: highlight patterns like vim's hlsearch #2861
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
base: develop
Are you sure you want to change the base?
Conversation
…unks This should change no current behavior, as clipdraw_chunks was only being called with cattr that were dicts or empty strings.
instead of silently failing
@daviewales @frosencrantz You two have contributed to past discussions and work on visidata's colorizers. Like those, pattern highlighting is a visual cue. Perhaps you have some feedback? |
Is there a way to clear the highlighting? For example, vim-sensible maps this to Ctrl+L: |
There's no command/binding to clear it now. The only way to clear it is to set a new nonexistent pattern. Having one is a good suggestion. On thinking about it more, allowing multiple simultaneous highlight patterns (one for each column, plus one for the entire sheet) is too complicated. Instead there should only be one at a time. That's what users expect from |
Thank you for doing this. I think this is great. Having only one highlighting format at a time is reasonable. Having multiple different highlights can get too complicated. Would the highlighting be per column or per sheet depending on the last type of search performed? Or would it be useful for it to control that by option? At some point it might be interesting to have a way do some sort of syntax highlight like I think the special cases where the matches are at the edge of the cell or screen should eventually be fixed. |
I agree that it makes sense just to have one highlight type at a time. In Vim at least, the highlight is based on the most recent search. I'd likely expect similar in Visidata. For example, I know that when I jump to the next match, it will be the next highlighted item. |
@frosencrantz I've pushed a change. The last search sets the highlight type. So
For So the remaining issues now are just 3, 4, and 5 from my initial list: fixing undo for |
elif len(lines) < height: | ||
lines.extend([[('', '')]]*(height-len(lines))) | ||
|
||
if options.highlight: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always use sheet.options
(self.options in this case) when possible. Then the option can be set per-sheet.
defer = False # False for not deferring changes until save | ||
guide = '' # default to show in sidebar | ||
icon = '›' | ||
highlight_regex = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be on Sheet, not BaseSheet.
This is a neat feature. My main concern is that it has to be a core feature. If it could be segmented into a self-contained file in |
This is a draft of a feature to highlight substrings within a column, or in every column. It looks like this, highlighting
\d+
in theSKU
column, and highlightingcat
everywhere.I'm floating this to get feedback. By default, highlighting is used after every search with
/
and?
andg/
andg?
.options.highlight
can be toggled to turn highlighting off.highlight-sheet
will do the same highlighting asg/
andhighlight-col
will do the same as/
, while keeping the cursor in place.In the screenshot you can see that partial offscreen matches are highlighted for strings that don't fully fit in the cell, like where
Cat
is shown asC…
. (But partial offscreen data will not be highlighted for collections like tuples, lists, and dictionaries. That treatment of offscreen contents is the same as the current behavior for/
.)Remaining work
|
set the highlight pattern like/
does? I'm not sure.SKU
column, you can see that the column\d+
pattern is lit, but the sheet patterncat
is not.search-*
does not undo highlighting. (undo ofhighlight-*
works properly, butsearch-*
is innonLogged
so it is more complicated)