bytesearch

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package bytesearch turns UI search queries into byte patterns and scans byte slices in either direction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindBytes

func FindBytes(data, pat []byte, start int, forward bool) int

FindBytes returns the index of pat in data at or after (forward) / at or before (backward) start, or -1.

func FindBytesFold

func FindBytesFold(data, pat []byte, start int, forward, fold bool) int

FindBytesFold is FindBytes with optional ASCII case-insensitive matching. With fold=false it is FindBytes (the fast exact bytes.Index). With fold=true it matches letters ignoring ASCII case — for text patterns; a byte-value pattern (hex) simply won't contain letters to fold, so callers can always pass the view's case flag.

func IsTextPattern

func IsTextPattern(q string, mode Mode) bool

IsTextPattern reports whether ParsePattern would treat q as literal text (so case-folding is meaningful) rather than a hex byte pattern (where it isn't).

func ParsePattern

func ParsePattern(q string, mode Mode) []byte

ParsePattern interprets a query as bytes or text:

  • "quoted text" -> literal bytes of the text
  • hex digits / 0x -> byte pattern (spaces allowed: "de ad be ef")
  • anything else -> literal text bytes

Types

type Mode

type Mode uint8

Mode controls how a query is interpreted when searching byte-oriented views.

const (
	ModeAuto Mode = iota
	ModeText
	ModeHex
)

func NextMode

func NextMode(m Mode) Mode

NextMode cycles Auto -> Text -> Hex -> Auto.

func (Mode) String

func (m Mode) String() string

String returns the user-facing name of the search mode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL