-- Leo's gemini proxy

-- Connecting to jan.bio:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Search


This weekend, I finnaly did something that I should have done long ago:

I implemented text search for my gopher- and gemini-client ncgopher [1].


I've had this on my TODO list for ages, but in my head it was not so

easy to implement. Turned out that I was totally wrong, and that it only

took a couple of hours. Most of the time, I spent scratching my head

over some Rust compiler errors. It's been a while that I've been written

any Rust code...


My aim was to provide a vim-like search where you just type '/' followed

by your search query. So pressing '/' switches the status line at the

bottom of the screen into an input field. You can type your search

term. If you delete the term or press ESC, the input field will close

and vanish. To trigger a search you press enter. (No incremental search

for now, but that would be trivial to implement, just call the search

function on every update).


Once the search is executed, all occurrences of the search term will be

highlighted and the current row is moved to the first occurrence of the

search term. If no occurrences are below the current position, the first

occurrence in the document will be highlighted instead (wrapping). If

the search term is not found nothing happens (Should probably show a

message).


For navigation between search result I settled for the vim-keys n (goto

next result) and N (goto previous result). It would also be easy to add

backward search, but the '?'-shortcut is already taken for the help

function. The 'n' key was originally used for jump-to-next-link (and

'p' for the opposite). I changed these to 'l' and 'L'.


There are several ways to improve this search function:


- Incremental search, maybe configurable.

- Backward search.

- Case-insensitive search

- Highlighting of search terms is not optimal, because it's invisible

on the currently selected line.

- Search term history. Press '/' and arrow up to see previous search

terms.


The new editfield opens a lot of doors. Vim-like commands are possible

now, like ':help'. Maybe ':bn' and ':bp' for switching between buffers

("tabs") would be cool.



[1] http://github.com/jansc/ncgopher


Back


-- Response ended

-- Page fetched on Sat Apr 27 23:21:58 2024