Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

typealias libtmux-rs latest

IndexedHooks

The commands one hook name holds.

Source and package
Qualified name
libtmux::hooks::IndexedHooks
Module
hooks
Package
libtmux
Source
crates/libtmux/src/hooks.rs
type hooks.IndexedHooks = SparseValues<TmuxText>

Description#

A hook is an array option whose values are tmux commands, so this is the SparseValues of that shape rather than a type of its own.

Examples#

use libtmux::{IndexedHooks, ReplaceMode, TmuxText};
use std::collections::BTreeMap;
let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
// The indices are tmux's own and are sparse: removing one does not renumber
// the rest, so the map is keyed rather than positional.
let mut entries = BTreeMap::new();
entries.insert(0, TmuxText::from("display-message first"));
entries.insert(4, TmuxText::from("display-message fifth"));
server
.set_hooks("after-new-window", &IndexedHooks::from(entries), ReplaceMode::Replace)
.await?;
let hooks: IndexedHooks = server.hook("after-new-window").await?.expect("just written");
assert_eq!(hooks.len(), 2);
assert_eq!(hooks.indices().copied().collect::<Vec<_>>(), vec![0, 4]);
guard.shutdown().await?;

Guides#

Pages that discuss IndexedHooks.

Esc

Type to search.

Reference previewOpen reference