Skip to main content

Crate bigtext

Crate bigtext 

Source
Expand description

BigText core: file access, encodings, line index, piece table, search, replace and save. Nothing in this crate depends on the GUI; main.rs hosts the egui front end.

Modules§

ai
The AI assistant’s core. A model never reads the file: it turns a request (“find all the errors”) into calls of BigText’s own tools, BigText runs them on this computer and gives the model only short, bounded results. Nothing is sent anywhere until the user sets up a provider and asks something.
brackets
Matching brackets and tags: the partner of (, [, { (and back), the bracket that encloses a position, and for XML / HTML the closing tag of an opening one (and back).
codec
Decoding and encoding text the way logs and requests carry it: Base64 (and JWTs), URL percent-encoding, hex, HTML entities and JSON string escapes.
column_edit
The column editor: a number sequence or the same text in a column of cells, row after row. The editor applies it to a block’s rows; column_edit_to streams it from a line to the end of a file of any size.
correlate
Ids that tie log lines together — request, trace, span and session ids — found on one line, so the file can be filtered to everything one request did.
csv
CSV and TSV: delimiter detection, quote-aware field splitting, and deleting columns from a whole document in one streaming pass with bounded memory, so any file size works.
csv_chart
The distribution of one table column: how many rows have values in each range (numbers), each period (times), or of each value (text, the most frequent ones).
csv_check
Checking a CSV / TSV file’s records in one pass: a field count other than the table’s, a stray or unclosed quote, control characters, and text in columns that should hold numbers.
csv_diff
Comparing two tables by a key column, whatever their row order: each row is paired with the other table’s row with the same key (the n-th duplicate with the n-th), and the result is a table of the rows changed (with old → new values and the names of the changed columns), removed and added. Columns pair up by header name, or by position without headers; the columns only one table has are not compared.
csv_expr
Expressions over a table row, for derived columns: {price} * {qty}, substr({ts}, 0, 10), regex({url}, "id=([0-9]+)"), if({status} = "ok", 1, 0).
csv_join
Joining two tables by a key column: the right (“lookup”) table is read into memory, keyed by its column, and the left table streams past it, each row followed by the other columns of every right row with the same key (a left or an inner join). The result is UTF-8 CSV.
csv_pivot
Pivot tables: one row per value of a column (or per day, hour or month of a time column), one column per value of another, and in each cell the number of rows — or the sum, mean, minimum or maximum of a third column — with a total per row.
csv_rows
CSV records as table rows. A record is usually one line, but a quoted field may hold line breaks, and the table shows such a record as one row.
decompress
Compressed files (.gz, .zst, .xz, .bz2): rotated logs are almost always compressed. They are unpacked once, streaming, into a temporary file that is then opened like any other file, so the editor keeps its random access and bounded memory. Archives (.zip, .tar, .tar.gz and the like) list their files, and the one picked is unpacked the same way.
diff
Streaming line diff of two (possibly huge) files with bounded memory.
encoding
Encodings, line-break handling and detection.
extract
The matched texts themselves, not their lines: every match (or one capture group of it) in order, or counted by value, most frequent first — grep -o | sort | uniq -c in one pass.
extsort
Sorting the lines of a file of any size: runs of up to RUN_BYTES are sorted in memory and written to temporary files, then merged (a k-way merge, in two levels past [MERGE_WAYS] runs). Equal lines can be dropped (unique) or counted (most frequent first).
fields
The fields of one structured log line — a JSON object (JSON Lines) or logfmt key=value pairs — and a streaming count of one field’s values over a whole log.
file
File access: windowed memory mapping when possible, buffered chunked reads otherwise.
filter
Line filter (“grep”): the lines of a document that contain a match — or, inverted, the lines that do not. It streams over the document like search, so memory stays bounded and any file size works. A filter can be limited to one CSV column: a line then counts only when a match lies inside that field. Lines around each kept line (context, or the rest of a log entry such as a stack trace) can be kept with it.
find_files
Find in files: the matches of a search in every file of a folder whose name fits a pattern such as *.log, file by file with the streaming search, with line numbers and the text around each match.
gaps
Time gaps in a log: the places where the next line with a timestamp is much later than the one before it (the service was down or quiet) or much earlier (the clock jumped back).
headless
BigText’s tools for scripts, without a window: bigtext-cli COMMAND … (or bigtext --COMMAND …). They stream like the editor does, so they work on files of any size.
histogram
Time histogram of a log: how many lines, and how many of them match a pattern (errors, the search), fall in each stretch of time — from one pass over the text. Buckets start one second wide and get wider (10 s, 1 min, …) when the log spans too much time, so the histogram stays small for any log.
index
Sparse, incremental line index over the original file.
jobs
Background-job plumbing: cancellation tokens, progress counters and UI wakers.
json
Streaming JSON for files of any size: the direct children of an object or array, page by page; the value at a path such as $.items[1234].id; the path of the value at an offset; and JSON Lines (one object per line) or an array’s items to CSV. Values are skipped with a byte loop that tracks only strings and nesting depth, so nothing is ever held in memory as a tree. UTF-8 (or another ASCII-compatible encoding) only.
json_check
Checking JSON strictly: bad escapes, control characters in strings, trailing commas, NaN and other words, numbers like 01 or 1., brackets that do not match, invalid UTF-8, and text after the value. A whole document stops at its first problem; JSON Lines are checked line by line, and every bad line is listed.
json_diff
Comparing two JSON documents by structure: each is flattened into $.path = value lines (keys in sorted order, array items by index), the flat forms are compared with the line diff, and the differing lines become changes — a value changed, added or removed — so key order and formatting do not count.
json_fields
The fields of JSON records — JSON Lines, or the items of a JSON array — in one pass: every key path to depth 3 (user.address.city, array items as tags[]), with its types, how often it appears, nulls, numbers’ minimum, maximum and mean, and some distinct values and examples.
jsonq
Field queries over structured log lines: JSON Lines (.level == "error" and .duration > 500, .user.id = 42), logfmt (level=error duration=750), and, given the log’s Format, web server and syslog logs (.status >= 500 and .method = POST). A line matches when it has fields and they meet the query; a line without any never does.
lines
Reading a text’s lines front to back in large chunks, for jobs that look at every line (merging logs, time histograms).
logformat
Web server and system log formats: nginx / Apache access logs, AWS load balancer logs (Application and Classic), IIS logs (W3C extended) and syslog (RFC 3164 and RFC 5424). A log’s format is recognised from its first lines; its lines are split into columns (a CSV table), and a web log is summed up in one streaming pass into ready reports: the top URLs, the requests and 5xx errors per minute, and the slowest requests.
loglevel
Log severity levels: the words that name them and a regex that finds them in a line.
logsources
Logs of containers and services: Docker (or Podman) containers, Kubernetes pods and systemd journal units, listed and read with the tools’ own commands (docker ps / docker logs, kubectl get pods / kubectl logs, systemctl list-units / journalctl), on this computer or on a server over SSH. Nothing here changes anything: only lists and logs are read.
merge
Merging logs by time: the lines of several logs in timestamp order, each line labelled with its file, written as one UTF-8 text. Lines without a time (stack traces, continuations) stay with the line above them, and lines before a file’s first time come first. Each file is read once, front to back, so memory use does not depend on the file sizes.
net_proxy
The proxy for BigText’s own web requests: the update check and download, and files opened from https:// and s3:// addresses.
patch
Applying a unified diff (a .diff or .patch file) to a text of any size: each hunk is found where it says, or up to FUZZ lines away when it matches only one place there, in one pass over the text.
patterns
Message patterns: the lines of a log grouped by template — the line with its leading timestamp dropped and numbers, hex ids, UUIDs, IP addresses and paths replaced by placeholders — so the noisiest messages and the rarest ones stand out.
pipe
Running a shell command with text on its standard input and its standard output going to a writer. Input, output and errors are pumped on their own threads, so a chatty command never deadlocks, and cancelling kills it.
redact
Hiding secrets and personal data in text before it is shared: tokens, cookies, passwords and keys, e-mail addresses and (optionally) IP addresses become labels such as <email-3f9a2c>. The same value gets the same label within one run, so lines can still be followed, and the labels come from a hash with a random salt, so they cannot be turned back into the values.
remote
Remote files read in parts, without downloading them: HTTP(S) range requests (S3 too) and an SSH session that sends the byte ranges asked for, both behind crate::file::RangeRead; and searches that run on the SSH server with grep, so a 50 GB log is searched where it is.
replace
Replacement: templates ($1, ${name}, \n, \t), small batches as piece-table edits and the streaming replace-all that writes a new file with bounded memory.
save
Crash-safe saving: stream the document to a temp file in the target’s directory, fsync, then atomically replace the target. The original is never touched until the final rename, and any failure leaves it intact.
search
Search over byte windows of a TextBuf.
setdiff
The lines of one text that occur nowhere in another, whatever their order (a set difference by line), for texts of any size. The other text’s line hashes are held in memory up to a budget; past it both sides are split by hash into partition files on disk and compared one partition at a time.
settings_file
Where the app keeps its settings (state.txt), and the searches saved in it, for the command line to run them (bigtext-cli filter --saved NAME) as the app does.
split
Cutting a document into pieces: the byte range of a line range, and splitting the whole document into part files of a given size or line count, always at line boundaries. Both stream, so any file size works.
sqldump
SQL dumps — mysqldump (MySQL, MariaDB), pg_dump’s plain format and SQLite’s .dump — read in one streaming pass into their tables: where each table’s statements are (its structure, its rows as INSERT statements or a COPY block, its keys, indexes and triggers), how many rows and bytes it has, and the dump’s opening and closing settings. A table, or several, can then be written to a file of their own that restores on its own, and a dump split into a file per table (with one more for what belongs to no table: views, functions, events).
stats
A file’s figures in one streaming pass (File → Properties, bigtext-cli stats): lines, line breaks by kind, the longest line, NUL bytes, bytes that are not UTF-8, a missing final line break, the first and last time; and its SHA-256.
sysinfo
Process memory statistics (for the status/debug overlay and benchmarks) and free disk space.
table_export
Exporting a CSV table, or some of its columns, as JSON, JSON Lines, a Markdown table or an Excel workbook (.xlsx), streamed record by record. The header names the fields; without one the columns are called column1, column2, ….
text
Text model: piece table (buffer, with its piece list in [tree] and its add buffer in [addbuf]) and visual row segmentation (rows).
textops
Text operations on a selection: sorting and de-duplicating lines, changing case, trimming, converting indentation, and re-formatting JSON. They work on decoded text and keep the text’s own line breaks; the caller applies the result as one undoable edit, or, for a document of any size, text_op_to streams it to a file.
timestamp
Log timestamps: recognising one near the start of a line, and finding the first line at or after a given time with a binary search over byte offsets (log lines are in time order), so a jump in a 50 GB log reads only a few hundred kilobytes.
unified
Unified diffs (diff -u): written from a comparison of files of any size, streamed (no line is held in memory), and applied back to a text.
update
Updates from the project’s GitHub releases: finding newer versions and their release notes, downloading a release file (size and SHA-256 checked) and installing it. A portable copy swaps its executable in place; a copy installed with the Windows setup program runs the new installer once BigText has exited. Everything here blocks, so it runs on worker threads.
watch
Alerts on new lines: the complete lines added to a followed log since the last look, kept when one of some patterns matches them. Only the added bytes are read, with the same search as the filter, so a log that grows by megabytes a second costs little.
xml
Streaming XML for files of any size, for the structure panel: the child elements of an element, page by page; the element at a path such as /catalog/item[1234]/price (1-based, like XPath); and the path of the element at an offset. Elements are skipped with a byte loop over tags, comments, CDATA and processing instructions, so nothing is held as a tree. UTF-8 (or another ASCII-compatible encoding) only.