heksa icon indicating copy to clipboard operation
heksa copied to clipboard

Search functionality

Open raspi opened this issue 5 years ago • 2 comments

Add --search or --find parameter for searching bytes. Highlight the found bytes with some color and/or add bold/underline effect.

Example:

heksa --search 'Hello' hello.txt

Also what about case (in)sensitivity?

Maybe also add search option where you can use a file as search source:

heksa --search-file find-this.dat hello.txt

This will probably require double buffered io.Reader with moving search "window". The first will read for example 1024 bytes of file and mark the found search position offsets. The second is the currently used one which reads width bytes and needs to be changed to read from the bigger buffer. This changes the reader's current functionality a lot and needs some rewrites.

Other considerations:

Hex search where only [0-9a-f ] can be used in the search string:

heksa --search-hex '00010203040506...' hello.txt
heksa --search-hex '00 01 02 03 04 05 06 ...' hello.txt

raspi avatar Aug 04 '20 21:08 raspi

Interesting stuff. I've never seen it in a CLI hexa viewer. When I need it, I use | grep to look for the bytes I want but of course this is not the smarter way to do this and it's very error prone.

The text search could also consider finding both ASCII and Unicode strings.

merces avatar Aug 12 '20 13:08 merces

Initial reader prototype - https://github.com/raspi/searchreader

raspi avatar Dec 30 '22 01:12 raspi