MCPcopy Index your code
hub / github.com/endbasic/endbasic / do_move_to

Method do_move_to

std/src/console/readline.rs:264–283  ·  view source on GitHub ↗

Moves the cursor to a new position, scrolling if needed.

(&mut self, new_pos: usize)

Source from the content-addressed store, hash-verified

262
263 /// Moves the cursor to a new position, scrolling if needed.
264 fn do_move_to(&mut self, new_pos: usize) -> io::Result<DispatchResult> {
265 if new_pos == self.pos {
266 return Ok(DispatchResult::Continue);
267 }
268
269 let old_pos = self.current_pos();
270 let new_view_start = self.adjust_view(new_pos, self.view_start);
271 if new_view_start == self.view_start {
272 let delta = new_pos as i16 - self.pos as i16;
273 self.console.move_within_line(delta)?;
274 self.pos = new_pos;
275 } else {
276 let clear_len = self.rendered_len;
277 self.pos = new_pos;
278 self.view_start = new_view_start;
279 self.sync_rendered();
280 self.redraw_line(old_pos, clear_len, self.current_pos())?;
281 }
282 Ok(DispatchResult::Continue)
283 }
284
285 /// Accepts the current line.
286 fn do_newline(&mut self) -> io::Result<DispatchResult> {

Callers 3

do_endMethod · 0.80
do_homeMethod · 0.80
runMethod · 0.80

Calls 5

current_posMethod · 0.80
adjust_viewMethod · 0.80
sync_renderedMethod · 0.80
redraw_lineMethod · 0.80
move_within_lineMethod · 0.45

Tested by

no test coverage detected