Crates.io | duat-utils |
lib.rs | duat-utils |
version | 0.6.0 |
created_at | 2025-06-16 06:01:13.972401+00 |
updated_at | 2025-08-20 13:37:19.367997+00 |
description | Basic components common in Duat, such as widgets and modes |
homepage | |
repository | https://github.com/AhoyISki/duat/tree/master/duat-utils |
max_upload_size | |
id | 1713924 |
size | 171,935 |
Standard complementary additions to Duat
This crate essentially consists of the standard bits that pretty
much every config
crate will want to use, but aren’t strictly
speaking necessary for Duat to function. This split is mostly to
improve compile times, but semantically, if a crate doesn’t need
all of these extra things, it is nice to separate them out.
The crate has the following elements:
5 widgets
:
LineNumbers
shows the numbers on a File
(for now), and
you can configure their alignment, relativeness, etc.PromptLine
lets you run commands and do other things,
like incremental searchStatusLine
lets you display information that gets
updated automatically, it can show information from
RwData
s, mapping functions, static elements, and every bit
of Duat. It’s syntax, in status!
is the same as the
txt!
macro.Notifications
shows things that have been logged to the
Logs
of Duat, through the error!
, warn!
and
info!
macros.LogBook
is a log of everything that has been notified to
Duat. It is usually more admissive than Notifications
, and
is most commonly scrolled by the Pager
Mode
.3 modes
:
Regular
is essentially the standard Mode
that text
editors use. Sort of like VSCode.Prompt
is a multitool that can serve many purposes,
through the PromptMode
trait, which allows one to act on
the PromptLine
while abstracting over less important
elements of the Widget
.Pager
is a simple, read only Mode
, designed for
scrolling and searching through Widget
s, most commonly the
LogBook
.For the PromptLine
, there are 4 PromptMode
s:
RunCommands
will interpret and run Duat commands, with
syntax highlighting for correctness, defined by the
Parameter
trait.PipeSelections
will pipe each selection on the current
File
, replacing them with the return value from a shell
command.IncSearch
is a specialized mode used for incremental
search, which can abstract over what the search actually does
with the IncSearcher
trait.For IncSearch
, there are 4 IncSearcher
s:
Note that the IncSearcher
trait can be used for many more
interesting things, like in duat-kak
for example, where its
implementors allow for splitting selections, selecting everything
within a range, and many more such things in the future.
hooks
:
SearchUpdated
for when an IncSearch
is updated.SearchPerformed
for when an IncSearch
is finished.And finally, there is the state
module, which contains a bunch
of StatusLine
parts for you to customize the StatusLine
with.
I would consider this crate essential for all config
s of Duat
out there, since it defines primitives that are not only hard to
replace, but might also be very extensible by plugins in the
ecosystem.