1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//! Trait-surface cast helpers shared between [`crate::editor`] and
//! [`crate::vim`].
//!
//! Promoted from `editor.rs` in 0.0.42 (Patch C-δ.7) so the vim free
//! functions can route their `ed.buffer().*` reaches through the
//! `Cursor` / `Query` / `BufferEdit` trait surface using the same cast
//! primitives the editor body uses. Mirrors the pattern lifted into
//! `motions.rs` in 0.0.40.
//!
//! All helpers take a generic `B: <trait> + ?Sized` so they compile
//! against the in-tree `hjkl_buffer::Buffer` and the engine's mock
//! buffers (used by motion / search / vim trait-routing tests). The
//! `Pos { line: u32, col: u32 }` ⇄ `Position { row: usize, col: usize }`
//! cast lives at the boundary so call sites stay terse.
use crate;
/// Read the cursor as a `(row, col)` `usize` tuple — the shape every
/// editor / vim free fn body expects. One inline cast at the trait
/// boundary.
pub Sized>
/// Read the cursor row.
pub Sized>
/// Read the cursor as an `hjkl_buffer::Position` — the shape the
/// concrete-buffer call sites consumed before the trait routing.
pub Sized>
/// Set the cursor from `(row, col)` `usize` coordinates.
pub Sized>
/// Set the cursor from a concrete `hjkl_buffer::Position`. Routes the
/// `ed.buffer_mut().set_cursor(Position::new(...))` call sites in
/// `vim.rs` through the trait surface without a dedicated helper at
/// each site.
pub Sized>
/// Number of rows.
pub Sized>
/// Borrow line `row`, returning `None` for out-of-bounds. Mirrors the
/// pre-0.0.41 `hjkl_buffer::Buffer::line(row) -> Option<&str>` shape.
pub Sized>
/// Snapshot every line into a `Vec<String>`. Allocates — call sites
/// that previously borrowed `lines() -> &[String]` and immediately
/// `.to_vec()`'d / `.iter().map(...)`'d collapse cleanly onto this.
pub Sized>
/// Length (chars) of `row`. Returns 0 for out-of-bounds rows so call
/// sites that previously did
/// `buf.line(r).map(|l| l.chars().count()).unwrap_or(0)` collapse to
/// one call.
pub Sized>
/// Length (bytes) of `row`. Returns 0 for out-of-bounds rows. The
/// byte-shape mirror of [`buf_line_chars`] — used by call sites that
/// pre-0.0.42 inspected `buf.lines()[row].len()`.
pub Sized>
/// Apply a [`hjkl_buffer::Edit`] and return the inverse for undo.
///
/// 0.0.42 (Patch C-δ.7): the `apply_edit` reach is intentionally kept
/// against the concrete `&mut hjkl_buffer::Buffer` rather than lifted
/// onto a trait method. Rationale:
///
/// - `hjkl_buffer::Edit` is the rich buffer-side enum (~8 variants —
/// `InsertChar`, `InsertStr`, `DeleteRange`, `JoinLines`,
/// `SplitLines`, `Replace`, `InsertBlock`, `DeleteBlockChunks`)
/// with ~700 LOC of `do_*` machinery in `hjkl-buffer`. Lifting it
/// onto `BufferEdit` would require either an associated `Edit` type
/// (forces every backend to design its own rich-edit enum just to
/// compile) or duplicating the 8 variants on the trait surface
/// (busts the discipline cap).
/// - `crate::types::Edit` is a separate value type (`Range<Pos>` +
/// `String` replacement) used by the change-log emitter; it's
/// intentionally simpler and lossy for block / join / split ops.
///
/// Centralizing the reach in this free fn keeps `Editor::mutate_edit`
/// trait-shaped at the call site (no `self.buffer.<inherent>` hop in
/// the editor body) and gives 0.1.0 a single seam to flip when the
/// `B: Buffer` generic lands.
///
/// The 0.1.0 design will introduce
/// `BufferEdit::apply_edit(&mut self, op: Self::Edit) -> Self::Edit`
/// with `type Edit;` so backends pick their own edit enum. This free
/// fn forwards there once that lands.
pub