Skip to main content

zsh/ported/zle/
mod.rs

1//! ZLE - Zsh Line Editor
2//!
3//! Direct port from zsh/Src/Zle/*.c
4//!
5//! This module implements the full Zsh line editor with:
6//! - Vi and Emacs editing modes
7//! - Programmable keymaps
8//! - Widgets (commands)
9//! - Completion integration
10//! - History navigation
11//! - Multi-line editing
12
13// Core ZLE types (old API for vm_helper compatibility)
14
15// New comprehensive ZLE port from C
16/// `comp_h` submodule.
17pub mod comp_h;
18/// `compcore` submodule.
19pub mod compcore;
20/// `compctl` submodule.
21pub mod compctl;
22/// `compctl_h` submodule.
23pub mod compctl_h;
24/// `complete` submodule.
25pub mod complete;
26/// `complist` submodule.
27pub mod complist;
28/// `compmatch` submodule.
29pub mod compmatch;
30/// `compresult` submodule.
31pub mod compresult;
32/// `computil` submodule.
33pub mod computil;
34/// `deltochar` submodule.
35pub mod deltochar;
36/// `termquery` submodule.
37pub mod termquery;
38/// `textobjects` submodule.
39pub mod textobjects;
40/// `zle_bindings` submodule.
41pub mod zle_bindings;
42/// `zle_h` submodule.
43pub mod zle_h;
44/// `zle_hist` submodule.
45pub mod zle_hist;
46/// `zle_keymap` submodule.
47pub mod zle_keymap;
48/// `zle_main` submodule.
49pub mod zle_main;
50/// `zle_misc` submodule.
51pub mod zle_misc;
52/// `zle_move` submodule.
53pub mod zle_move;
54/// `zle_params` submodule.
55pub mod zle_params;
56/// `zle_refresh` submodule.
57pub mod zle_refresh;
58/// `zle_thingy` submodule.
59pub mod zle_thingy;
60/// `zle_tricky` submodule.
61pub mod zle_tricky;
62/// `zle_utils` submodule.
63pub mod zle_utils;
64/// `zle_vi` submodule.
65pub mod zle_vi;
66/// `zle_word` submodule.
67pub mod zle_word;
68/// `zleparameter` submodule.
69pub mod zleparameter;
70
71pub use zle_h::{widget, WidgetImpl};
72pub use zle_keymap::Keymap;
73pub use zle_thingy::Thingy;
74
75#[cfg(test)]
76mod tests {
77    use super::*;
78
79    /// Keymap default initialises with all 256 first[] slots as None
80    /// (the `t_undefinedkey` sentinel) and empty multi table. Verifies
81    /// the new() / Default::default() contract used by every newkeymap
82    /// + bindkey path — a regression breaking this would mean every
83    /// keymap starts with random state.
84    #[test]
85    fn empty_keymap_has_all_unbound_first_slots() {
86        let _g = crate::test_util::global_state_lock();
87        let km = zle_keymap::Keymap::default();
88        assert!(km.first.iter().all(|t| t.is_none()), "all 256 slots None");
89        assert!(km.multi.is_empty(), "no multi-byte bindings yet");
90        assert_eq!(km.flags, 0);
91    }
92
93    /// Thingy::new builds an immortal stub with rc=1 and no widget.
94    /// Verifies the calloc-equivalent baseline the rest of the thingy
95    /// pipeline (refthingy / unrefthingy) is allowed to assume.
96    #[test]
97    fn freshly_minted_thingy_has_rc_one_and_no_widget() {
98        let _g = crate::test_util::global_state_lock();
99        let t = zle_thingy::Thingy::new("test-widget");
100        assert_eq!(t.rc, 1);
101        assert!(t.widget.is_none());
102        assert_eq!(t.nam, "test-widget");
103    }
104}