Skip to content
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

Merged
merged 1 commit into from
Jan 6, 2024
Merged

Implement lazy search #581

merged 1 commit into from
Jan 6, 2024

Conversation

tobiolo
Copy link
Collaborator

@tobiolo tobiolo commented Jan 6, 2024

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.

@tobiolo tobiolo force-pushed the lazy-search branch 6 times, most recently from 0af179c to bf0bfd1 Compare January 6, 2024 17:49
@tobiolo tobiolo requested a review from aardappel January 6, 2024 17:52
src/document.h Outdated
@@ -2024,10 +2023,21 @@ struct Document {
}
}

const wxChar *LoadSearch() {
Copy link
Owner

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

Copy link
Collaborator Author

@tobiolo tobiolo Jan 6, 2024

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.");
Copy link
Owner

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

Copy link
Collaborator Author

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();
Copy link
Owner

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?)

Copy link
Collaborator Author

@tobiolo tobiolo Jan 6, 2024

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):

  1. 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?).
  2. The search parameters are set by MyFrame::OnSearch that is run when the value of the wxTextCtrl filter is changed. This is triggered by SetValue(...). So OnSearch runs event-driven/asynchronously and we cannot just run SearchNext without knowing for sure that the search parameters are already all set (thus avoiding a race).

Copy link
Owner

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 :)

Copy link
Collaborator Author

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.
@tobiolo tobiolo requested a review from aardappel January 6, 2024 18:40
@aardappel aardappel merged commit e69bebf into aardappel:master Jan 6, 2024
4 checks passed
@tobiolo tobiolo deleted the lazy-search branch March 13, 2024 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants