4coder»Forums
Paul Riddle
4 posts
Is it possible to change the behavior of the search function?
Edited by Paul Riddle on Reason: Initial post
First of all, I'm wondering if it's possible to make Ctrl-f search to highlight all matches of the word with one color and the one under cursor with another. Like in browsers and vim.

Second, to make it work across all visible buffers. Say I opened 2 files and search for "bind", I want it to highlight in both buffers.

Third, make it rotate when it hits bottom. So if the buffer contains 8 occurrences of the word "bind", I want to press Ctrl-f and then when I'm at the bottom just hit f and start searching from the top again.

Fourth is a tricky one. Lister navigation is fast but it needs fuzzy search. I'm not sure how it works currently, but it seems to be directory oriented. So if the file is 5 directories deep but has a unique name like "pubserv.c" across the whole project you'll need to do some typing. With fuzzy search I could have just typed "psrv" and hit enter. It is not directory oriented. It might be, but then it'll become less powerful. I don't think fuzzy lister should replace the current one. They might coexist.

All of this in configuration layer.

Anyway, I'm still barely even a 4coder user and haven't dived deep into configuration capabilities. But I'm trying to use it more.
Simon Anciaux
1337 posts
Is it possible to change the behavior of the search function?
Here is some code for search highlight (in all buffer) and looping search. It might not be exactly what you want but it should get you started. To highlight the word under the cursor you can modify the code in the render caller.

For the fuzzy search, I'm not sure I understand exactly what you want, but you can create a custom lister to display any data you want. Have a look in 4coder_lists.cpp to see how default listers work.
Paul Riddle
4 posts
Is it possible to change the behavior of the search function?
Thanks I will take a look. I was just wondering if it was possible at all but having some code to look at is even better! About fuzzy search, basically I want to have something like https://github.com/junegunn/fzf for file opening. It is a popular little program but apparently doesn't work quite as well on Windows, as it does on Linux.