pub struct Env { /* private fields */ }Expand description
Everything widgets need to know about how to draw and label themselves.
Implementations§
Source§impl Env
impl Env
Sourcepub fn builtin() -> Self
pub fn builtin() -> Self
Built-in files only, the monochrome theme, Unicode glyphs, English and 24-bit colour.
Deterministic, which makes it the environment for tests.
Sourcepub fn load(dirs: &AssetDirs) -> Result<Self>
pub fn load(dirs: &AssetDirs) -> Result<Self>
Loads the application’s files over the built-ins and detects colour depth, glyphs, language and the kind of connection from the process environment.
§Errors
Returns an I/O error when a configured directory or file cannot be read and no text was
given for that kind of file; with text given, an unreadable path is a diagnostic and the
text stands in for it. Problems inside files are never errors; they are collected in
Env::diagnostics.
Sourcepub fn load_with(
dirs: &AssetDirs,
lookup: impl Fn(&str) -> Option<String>,
) -> Result<Self>
pub fn load_with( dirs: &AssetDirs, lookup: impl Fn(&str) -> Option<String>, ) -> Result<Self>
Loads the application’s files like load, reading the variables it would
read from the process environment (LANG, LC_ALL, LC_TIME, TERM, COLORTERM,
SSH_CONNECTION and the rest) through lookup instead.
For a test that runs an application with its real files: the machine’s language and
region would otherwise reach it, so the first day of the week, a number’s decimal mark or
the language itself would change from one machine to the next. |_| None is a machine
with nothing set. Unlike load, the operating system’s own language setting is never
asked: only lookup answers.
§Errors
As for load.
Sourcepub fn icon_sets(&self) -> Vec<(String, String)>
pub fn icon_sets(&self) -> Vec<(String, String)>
(id, name) of every icon set, the way Env::themes lists the themes. A theme names
the set it draws with, so this tells which sets a theme may name.
Sourcepub fn glyph_mode(&self) -> GlyphMode
pub fn glyph_mode(&self) -> GlyphMode
The glyph column actually drawn.
Sourcepub fn keymap_mut(&mut self) -> &mut Keymap
pub fn keymap_mut(&mut self) -> &mut Keymap
The keymap, to bind actions in code, e.g. before handing the environment to a
Harness.
Sourcepub fn depth(&self) -> ColorDepth
pub fn depth(&self) -> ColorDepth
The terminal’s colour depth.
Sourcepub fn remote(&self) -> bool
pub fn remote(&self) -> bool
Whether the terminal is at the other end of a remote connection, so every drawn frame travels over a network.
True when SSH_CONNECTION or SSH_TTY is set and not empty, which is how an SSH server
marks the session it started; an empty value counts as unset, the way an empty variable
left over from another program does. Detected once by Env::load, so it cannot change
under a running application; Env::builtin, the environment of tests, is never remote
until Harness::set_remote says so.
The runtime already uses it for the FrameLimit an
application does not set. An application reads it to spend less on a slow link: fewer
animations, smaller pictures, a plainer screen.
Sourcepub fn remote_session() -> bool
pub fn remote_session() -> bool
Whether this process runs in a remote session, by the rule Env::remote uses, without
loading an environment.
It reads SSH_CONNECTION and SSH_TTY and nothing else, so it costs no file reads. An
application calls it before Runtime::run, where no
Env is handed out yet, to choose what depends on the connection between frames, such as
the size a picture is decoded at. In a view, Env::remote gives the same answer, and
Harness::set_remote sets it in a test.
Sourcepub fn graphics(&self) -> Graphics
pub fn graphics(&self) -> Graphics
The way a picture can be drawn in this terminal.
The runtime asks the terminal once, as it starts: a kitty graphics query and a request
for its device attributes, with a wait of 150 ms at most that the attributes end, so a
local terminal answers in milliseconds and starting never waits on the network. A kitty OK gives Graphics::Kitty, attributes
that list sixel give Graphics::Sixel, and anything else, silence included, gives
Graphics::HalfBlock. A kitty OK that arrives after the wait, over a very slow link,
still gives Graphics::Kitty from then on. The answers never reach the
application as keys. The terminal is not asked when its answer could not change the
result, and never when it is not a terminal.
Then the environment has its say:
- 16 colours or ASCII glyphs give
Graphics::None: no picture is drawn. - Inside tmux or GNU screen (
TMUXorSTYset and not empty) kitty and sixel become half blocks, because the multiplexer does not pass them through. - The
QUVYTA_GRAPHICSenvironment variable, set tokitty,sixel,halfblockornone, wins over all of it, for a terminal the probe misjudges or a person who wants something else. Any other value is ignored and becomes a diagnostic.
Env::builtin, the environment of tests, asks nothing and gives half blocks; see
Harness::set_graphics for the others.
Sourcepub fn reduced_motion(&self) -> bool
pub fn reduced_motion(&self) -> bool
Whether animations are reduced: layers appear at once, nothing breathes or spins.
The QUVYTA_REDUCED_MOTION environment variable, read by Env::load, decides when it
is set: 0 keeps motion, any other non-empty value reduces it. It wins over a saved
reduced-motion setting and over Command::set_reduced_motion, because a choice made in
the user’s shell is the stronger signal, the way accessibility overrides work. Unset or
empty, the saved setting and the application decide.
Sourcepub fn reduced_motion_forced(&self) -> bool
pub fn reduced_motion_forced(&self) -> bool
Whether the QUVYTA_REDUCED_MOTION environment variable decides reduced motion, so neither
a saved setting nor Command::set_reduced_motion can change it. A settings screen uses it to
show its reduced-motion switch as decided by the environment instead of letting the switch
snap back when pressed.
Sourcepub fn pillar_style(&self) -> Option<PillarStyle>
pub fn pillar_style(&self) -> Option<PillarStyle>
The pillar the user chose over the theme’s, if any.
Sourcepub fn slide(&self) -> bool
pub fn slide(&self) -> bool
Whether list structures (lists, menus, trees, tables, tab strips and rails, dropdown options)
slide the leading text of hovered and selected rows one cell; buttons and fields never do.
The user’s choice when made, otherwise the theme’s motion.slide.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Problems found in theme, icon, locale and keymap files, including theme switches that fell back to the default.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Env
impl RefUnwindSafe for Env
impl Send for Env
impl Sync for Env
impl Unpin for Env
impl UnsafeUnpin for Env
impl UnwindSafe for Env
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more