Skip to main content

TranslateContext

Struct TranslateContext 

Source
pub struct TranslateContext<'a> {
Show 19 fields pub modal: ModalState, pub builtins: &'a Builtins, pub pending_count: u32, pub op_count: u32, pub recording_macro: bool, pub active_buffer: BufferKind, pub completion_open: bool, pub chord_capture: bool, pub picker_open: bool, pub insert_completion_open: bool, pub snippet_active: bool, pub terminal_insert_active: bool, pub terminal_esc_exits: bool, pub terminal_app_cursor_keys: bool, pub terminal_insert_exit_pending: bool, pub terminal_visual_active: bool, pub keymap: &'a KeymapHandle, pub partial_chord: &'a [KeyChord], pub active_minor_modes: &'a [ModeId],
}

Fields§

§modal: ModalState§builtins: &'a Builtins§pending_count: u32

In-progress count prefix; 0 means none. Translate uses this to disambiguate the 0 key (line_start when no count in progress; digit-zero appended to count otherwise).

§op_count: u32

Operator-side count latched at Pending::AfterOperator activation (App moves pending_count -> op_count then resets pending_count so the in-progress digits track the motion side of <op-count><op><motion-count><motion>). Slice 8.g.iv reads this in keymap_normal::attach_count to multiply with the motion count when an Action::Invoke resolves.

§recording_macro: bool

True when a macro is currently being recorded. Translate uses this so q while recording stops, while q otherwise starts a new recording.

§active_buffer: BufferKind

Which buffer the App’s input pipeline currently routes to. Driven by [crate::app::App::active_buffer]; defaults to BufferKind::Document. Help buffers route through the same Normal-mode chord grammar (motions, <C-o> / <C-i>, gg / G, etc.) – only three buffer-local bindings differ: Esc / q dismiss the help overlay, and <CR> follows the link under the cursor.

§completion_open: bool

True when the command-line completion popup is open (DESIGN.md §5.11.3). Tab / S-Tab / Enter / Esc are claimed by the popup before falling through to Command mode.

§chord_capture: bool

True when the cmdline cursor sits on an ArgKind::Chord arg slot. In this mode every key event renders to a chord token and gets appended — no key is reserved, so <CR>, <Esc> and <BS> describe themselves rather than acting as submit / cancel / delete (DK.2). Multi-stroke sequences (gg, <C-w>j) work by pressing each chord in turn; the keymap trie decides when the sequence is finished, so there is no terminator to press.

§picker_open: bool

True when a picker (Picker overlay) is open. Picker claims every key before the modal handlers see it: char keys append to the query, <Up> / <C-p> / <Down> / <C-n> move selection, <CR> accepts, <Esc> dismisses.

§insert_completion_open: bool

True when the Insert-mode completion popup is open (Phase 4.2.g.1). Activates the completion-popup minor mode: <C-n> / <C-p> navigate, <C-y> / <Tab> / <CR> accept, <C-e> cancels, <Esc> cancels and exits Insert. Bindings inside this layer override the usual Insert-mode + Normal-mode meanings (notably <C-d> becomes “toggle docs popup” instead of “shift-left-indent” / “half-page-down”). Closing the popup deactivates the layer; original bindings restore.

§snippet_active: bool

True when an ActiveSnippet is in flight (Phase 4.2.g.4). Activates the active-snippet minor mode: <Tab> jumps to the next placeholder, <S-Tab> to the previous, <Esc> exits the snippet (and Insert). The layer claims <Tab> ahead of Insert-mode’s “insert literal tab” so placeholder navigation is stable; closing the snippet deactivates the layer.

§terminal_insert_active: bool

Terminal-mode T2.a (2026-05-25): true when terminal-insert-mode is active on the active Terminal buffer. translate short-circuits early in this state: keystrokes encode to ANSI bytes (via keymap_terminal::key_to_ansi) and emit Action::TerminalInput instead of going through the modal-state dispatchers.

§terminal_esc_exits: bool

Terminal-mode T2.b.0 (2026-05-25): resolved value of the terminal.esc-exits typed option for the active pane’s buffer. When true and terminal_insert_active is also true, <Esc> emits Action::ExitTerminalInsert instead of encoding to \x1b for the PTY. Users running nested vim / htop inside the terminal flip the option off and use <C-\><C-n> (T2.c) to exit.

§terminal_app_cursor_keys: bool

Terminal-mode T2.c (2026-05-25): DECCKM mode bit (application-cursor-keys) from the active terminal’s alacritty Term. Threaded into keymap_terminal::key_to_ansi_with_mode so arrow keys encode as SS3 (ESC O A) vs CSI (ESC [ A).

§terminal_insert_exit_pending: bool

Terminal-mode T2.c (2026-05-25): <C-\> exit chord is armed and waiting for the confirm key. When set, the translate layer routes the next keystroke into the chord-resolution branch instead of the normal encoder.

§terminal_visual_active: bool

2026-05-25: true when the active Terminal buffer holds an in-flight Visual selection (t.visual.is_some()). Terminal-Visual lives on the buffer (modal stays Normal) so the <Esc> / v exit chords don’t come through keymap_visual’s ExitVisual bindings; this layer short-circuits them when the flag is set.

§keymap: &'a KeymapHandle

Layered keymap registry (DESIGN.md §5.2.3, audit slice 8.c – 8.d). translate consults this instead of the per-mode hand-rolled match tables one slice at a time as the migration progresses; Replace mode is the first migrated dispatcher. Borrowed for the duration of the translate call – a single ArcSwap::load happens inside the dispatcher.

§partial_chord: &'a [KeyChord]

Slice 8.i.4.a: in-flight partial-chord stack from App::partial_chord. When non-empty, translate_normal runs the keymap lookup with this as the prefix instead of the legacy match pending body; the simple prefix-only Pending variants (AfterG / AfterZ / AfterCtrlW / AfterSetMark / AfterJumpMarkLine / AfterJumpMarkExact / AfterRegister / AfterMacroStart / AfterMacroPlay) all funnel through here now.

§active_minor_modes: &'a [ModeId]

D.5.b (2026-05-30): active buffer’s minor modes, in activation order. Threaded into lookup_with_context so chord bindings registered under MinorMode(ModeId) layers only fire on buffers where the corresponding mode is in ActiveModes.minors(). Empty slice means “no minor modes active” — minor-mode bindings are invisible to dispatch under that constraint (K.1.c fast path). Normal-mode dispatch uses this today (lookup_normal / lookup_normal_with_prefix); Visual / Insert / Replace stay on the legacy all-registered-modes-active lookup until D.5 extends their grammar.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for TranslateContext<'a>

§

impl<'a> !UnwindSafe for TranslateContext<'a>

§

impl<'a> Freeze for TranslateContext<'a>

§

impl<'a> Send for TranslateContext<'a>

§

impl<'a> Sync for TranslateContext<'a>

§

impl<'a> Unpin for TranslateContext<'a>

§

impl<'a> UnsafeUnpin for TranslateContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> IntoMaybeUndefined<T> for T

§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
§

impl<T> IntoOption<T> for T

§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more