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
Add CodeFind feature #364
Add CodeFind feature #364
Conversation
The searchbar is not visible at all and when the searchbar is moved outside the template it becomes visible but expands vertically way too much and the codeview isnt implemented. |
initialising searchcontext throws a bunch of errors; |
@SoNiC-HeRE in GJS try
additionally, your code is wrong, I doubt that you're supposed to create a new |
Implemented the requested layout and functionalities suggested in the #347 |
For example: The https://gnome.pages.gitlab.gnome.org/gtksourceview/gtksourceview5/method.SearchContext.forward_async.html |
this.next_match.connect("clicked", () => {
settings.search_text = this.search_entry.get_text();
const searchContext = new Source.SearchContext({ buffer, settings });
const currentIter = this.buffer.get_iter_at_mark(
this.buffer.get_insert()
);
const [found, iter] = searchContext.forward(currentIter);
if (found) {
// Scroll to the previous match
this.buffer.place_cursor(iter);
this.buffer.move_mark_by_name("insert", iter);
// this.source_view.scroll_mark_onscreen(iter);
} else {
// Handle no previous match found
console.log("No previous match found.");
}}); I've implemented this function to make it work such that wherever the cursor is; it get's the next searched-match location by locating highlight and moving down the cursor one step; I've commented the scroll function because it breaks code; I'm unsure how do i modify this code to make it keep the cursor moving to next match-location not only vertically but horizontally as well |
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.
I pushed a commit that makes next/previous work dd3b17b make sure to git pull
This is how I figured it out:
https://gnome.pages.gitlab.gnome.org/gtksourceview/gtksourceview5/class.SearchContext.html
The concept of “current match” doesn’t exist yet. A way to highlight differently the current match is to select it.
Ha!
In the GtkSourceView source code, there is an example of how to use the search and replace API: see the tests/test-search.c file. It is a mini application for the search and replace, with a basic user interface.
I simply ported the relevant code to GJS see https://gitlab.gnome.org/GNOME/gtksourceview/-/blob/master/tests/test-search.c
Since this isn't easy and there are several things left, I'm asking you again to use a demo for now on which you can iterate quickly and have a short feedback loop. Instead of restarting Workbench every time you try something or make a typo. It will also be easier for me to help you.
Once we're satisfied with the demo and its features, we can move the code to CodeView
I'll apply the changes and shift the code to a demo |
Ported the codefind feature as a library entry/demo
What else can i add/improve in the feature? @sonnyp |
Great, it's much easier now to iterate on the logic and the UI.
We should iterate on the UI of the search bar in the demo too.
Works for me (light mode) :D You can use this:
It will be useful for the Source View demo anyway.
The ticket says
Please make it look and work the same. Including the shortcut for
Ignore the buttons "Search & Replace" and "Togge Search options". |
Implemented all the functionalities that i saw in the text editor's searchbar.
but i think i should ignore it cause i used a label widget as a child of searchentry so as to make them look linked. Everything else works fine as expected. |
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.
There are a bunch of problems. Please compare UI and features with GNOME Text Editor as requested previously.
- Ctrl+F doesn't focus the entry (can't type directly after)
- Ctrl+F then Esc then Ctrl+F doesn't work (consider focusing the code view on
ESC
) - The spacing between the elements of the bar are different than GNOME Text Editor
- There is no Clear Entry button in GNOME Text Editor
- GNOME Text Editor doesn't have a placeholder
- The Search Bar bottom corners are rounded in GNOME Text Editor
- "Next match" on the last match should go to the first match (cycles) and vice versa
- After hiding the search (ESC), opening the search bar should immediately enable the search
- Closing the search should not clear the entry
Less obvious ones:
- Enter should be a shortcut to "Move to next Match"
- Shift+Enter should be the a shortcut to "Move to previous Match"
- The close button should be rounded (check with hovering it with your cursor)
Let me know if something isn't clear
In response to #364 (review)
Still Unsolved:
Other:
Please let me know the changes that are required |
Closes #347