@@ -81,6 +81,7 @@ pub struct EditorBuffer {
8181}
8282
8383impl EditorBuffer {
84+ /// Creates a new empty editor buffer with default values.
8485 pub fn new ( ) -> Self {
8586 Self {
8687 lines : vec ! [ String :: new( ) ] ,
@@ -97,6 +98,7 @@ impl EditorBuffer {
9798 }
9899 }
99100
101+ /// Creates an editor buffer initialized with the given content.
100102 pub fn from_content ( content : & str ) -> Self {
101103 let lines: Vec < String > = if content. is_empty ( ) {
102104 vec ! [ String :: new( ) ]
@@ -119,6 +121,7 @@ impl EditorBuffer {
119121 }
120122 }
121123
124+ /// Inserts a character at the specified line and column position.
122125 pub fn insert_char ( & mut self , line : usize , col : usize , ch : char ) {
123126 if line >= self . lines . len ( ) {
124127 self . lines . resize ( line + 1 , String :: new ( ) ) ;
@@ -135,13 +138,15 @@ impl EditorBuffer {
135138 line_str. insert ( byte_idx, ch) ;
136139 }
137140
141+ /// Inserts a new line with the given content at the specified position.
138142 pub fn insert_line ( & mut self , line : usize , content : String ) {
139143 if line > self . lines . len ( ) {
140144 self . lines . resize ( line, String :: new ( ) ) ;
141145 }
142146 self . lines . insert ( line, content) ;
143147 }
144148
149+ /// Deletes the line at the specified position.
145150 pub fn delete_line ( & mut self , line : usize ) {
146151 if line < self . lines . len ( ) {
147152 self . lines . remove ( line) ;
@@ -251,6 +256,7 @@ pub struct AnimationEngine {
251256}
252257
253258impl AnimationEngine {
259+ /// Creates a new animation engine with the specified typing speed.
254260 pub fn new ( speed_ms : u64 ) -> Self {
255261 let target_fps: u64 = 120 ;
256262 let frame_interval_ms = 1000 / target_fps;
@@ -302,10 +308,12 @@ impl AnimationEngine {
302308 self . base_speed_ms
303309 }
304310
311+ /// Sets the viewport height for scroll calculations.
305312 pub fn set_viewport_height ( & mut self , height : usize ) {
306313 self . viewport_height = height;
307314 }
308315
316+ /// Sets the content width for line wrapping calculations.
309317 pub fn set_content_width ( & mut self , width : usize ) {
310318 self . content_width = width;
311319 }
@@ -802,7 +810,7 @@ impl AnimationEngine {
802810 ( cursor_line, buffer_line)
803811 }
804812
805- /// Update animation state and return true if display needs refresh
813+ /// Updates animation state and returns true if display needs refresh.
806814 pub fn tick ( & mut self ) -> bool {
807815 self . update_cursor_blink ( ) ;
808816
@@ -1101,6 +1109,7 @@ impl AnimationEngine {
11011109 self . buffer . scroll_offset = logical_offset;
11021110 }
11031111
1112+ /// Returns true if the animation has completed.
11041113 pub fn is_finished ( & self ) -> bool {
11051114 self . state == AnimationState :: Finished
11061115 }
0 commit comments