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
//! Memory management subsystem.
//!
//! Linux equivalent: `mm/`
//!
//! This module provides the foundational data structures for text editing:
//! buffer storage, position types, and edit operations. It serves as the
//! foundation upon which all other kernel modules are built.
//!
//! # Module Structure
//!
//! - [`buffer_id`]: Unique buffer identifiers with atomic generation
//! - [`position`]: Position and cursor types for text navigation
//! - [`edit`]: Edit operations for undo/redo support
//! - [`buffer`]: Core buffer data structure with line-based storage
//!
//! # Design Philosophy
//!
//! This module follows the Linux kernel's memory management principles:
//! - Simple, efficient data structures
//! - Clear ownership semantics
//! - No external dependencies (pure Rust)
//! - Extensible foundation for advanced features
//!
//! # Example
//!
//! ```
//! use reovim_kernel::api::v1::*;
//!
//! // Create a buffer from text
//! let mut buf = Buffer::from_string("Hello\nWorld");
//! assert_eq!(buf.line_count(), 2);
//! assert_eq!(buf.line(0), Some("Hello"));
//!
//! // Edit the buffer at explicit position (cursor is per-window, not per-buffer)
//! buf.insert_at(Position::new(0, 5), "!");
//! assert_eq!(buf.line(0), Some("Hello!"));
//!
//! // Create edit for undo tracking (edits are self-contained)
//! let edit = Edit::insert(Position::new(0, 5), "!");
//! assert!(edit.is_insert());
//! assert_eq!(edit.text(), "!");
//!
//! // Get inverse for undo
//! let undo = edit.inverse();
//! assert!(undo.is_delete());
//! ```
// Re-export Rope for snapshot types in block/. Not exposed via api::v1
// because the mm module itself is private.
pub use Rope;
pub use ;