-
Notifications
You must be signed in to change notification settings - Fork 197
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
Implement lazy search #581
Conversation
0af179c
to
bf0bfd1
Compare
src/document.h
Outdated
@@ -2024,10 +2023,21 @@ struct Document { | |||
} | |||
} | |||
|
|||
const wxChar *LoadSearch() { |
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.
Unless they're gigantic, I'd generally say there is no good reason introducing functions that only get called once, makes the code harder to follow
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.
Thanks for your feedback.
Ok, I changed that.
src/document.h
Outdated
if (!c->text.t.Len()) return _(L"No text in this cell."); | ||
sys->frame->filter->SetFocus(); | ||
sys->frame->filter->SetValue(c->text.t); | ||
return _(L"Search string was loaded from selection."); |
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 status is maybe superfluous, status should only be set on special events
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 status is maybe superfluous, status should only be set on special events
Ok, I was unsure myself. I replaced it with nullptr
.
src/document.h
Outdated
return SearchNext(dc, false, true, true); | ||
return sys->searchstring.Len() | ||
? SearchNext(dc, false, true, k == A_SEARCHPREV) | ||
: LoadSearch(); |
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 function only sets the search, so does that mean I have to press search twice to do the actual search? what is the idea behind that UI (as opposed to searching directly?)
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.
The main idea is to implement some lazy search option if one wants to look for the same text in other cells without having to copy & paste the cell text to the filter
text control.
I think of two reasons for having to do it twice (load the cell text into the filter
text control and actually do the search with SearchNext
):
- First provide some kind of visual feedback that the search is now active (the cells are darkened) and ready to proceed. Something of the kind: "The search term is loaded". The darkening also provides some kind of visual orientation (are matches nearby?).
- The search parameters are set by
MyFrame::OnSearch
that is run when the value of thewxTextCtrl
filter
is changed. This is triggered bySetValue(...)
. SoOnSearch
runs event-driven/asynchronously and we cannot just runSearchNext
without knowing for sure that the search parameters are already all set (thus avoiding a race).
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.
Ok, I suppose that's fine for the moment.. much better than not working at all :)
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.
Thanks for your review!
If no search term is given and one cell is selected and the user triggers the search, use the cell text string as search query. This is similiar to the F6 and F7 (jump to text/image) experience. Also make the rootgrid check the first check for futureproofness.
If no search term is given and one cell is selected and the user triggers the search, use the cell text string as search query.
This is similiar to the F6 and F7 (jump to text/image) experience.
Also make the rootgrid check the first check for futureproofness.