-
Notifications
You must be signed in to change notification settings - Fork 8
feat: implement forward search functionality #73
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: master
Are you sure you want to change the base?
Conversation
- Implement search_fwd() function in ted_buffer.c * Search from current cursor position forward through buffer * Move cursor to first match found - Add search command to ted_commands.c * Prompt user for search keyword * Integrate with search_fwd() function - Add ctrl+r keybinding for search in ted_input.c - Add command hints for search functionality
|
Hi @arthurbacci, any feedback for this PR? |
Hi. It seems like a good adition, thank you for contributing. But I believe something is wrong with the way x_width is used but I am not sure. Unfortunately I don't have much time this week so I will probably take some days to review it and merge. |
arthurbacci
left a comment
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.
Non optimal behaviour with width vs bytes
|
I just don't remember how to recalculate x from x_bytes, it may be a function from libgrapheme, idk. I will take a better look at this later. |
|
Thanks for reviewing it. I've updated the part to calculate the cursor position. |
Thank you. Now you just need to also calculate .x using wi_to_gi with .x_bytes |
👍 Updated. |
Actually, all that code you deleted in your last commit was probably right. Basically:
In 90% of the cases they will all be the same. I don't remember very well what recalc_cur does and what is does not, but I believe you need to set all those three. Since no functions in ted work with bytes, I don't remember how one would set both from x_bytes, but I think what you did with that while loop was the way. You should keep that, since it calculates x from x_bytes, and then you should only do: This finishes setting both three. |
It seems as long as x_width is in place, lx_width will be set as well after calling recalc_cur. |
|
What you are doing now seems right, except that you should use gi_to_wi (grapheme index to width index) instead of wi_to_gi |
Nice catch. |
|
Seems to work well, tested with the unicode-test.txt file and it seems to correctly set the x position for complex grapheme sequences. Thank you a lot for your contribution. I will just check for more details this weekend so that I can be sure it's doing everything right before merging into main, since I don't remember very well what's the correctly way of dealing with changing the x cursor. Maybe I should create a utility function to set it from width, grapheme index, or byte index so that this proccess isn't needed. |
Implement search_fwd() function in ted_buffer.c
Add search command to ted_commands.c
Add ctrl+r keybinding for search in ted_input.c
Add command hints for search functionality