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

Method adjust_view

std/src/console/readline.rs:48–58  ·  view source on GitHub ↗

Adjusts the viewport start to ensure `pos` remains visible.

(&self, pos: usize, view_start: usize)

Source from the content-addressed store, hash-verified

46impl<'a, 'h> Readline<'a, 'h> {
47 /// Adjusts the viewport start to ensure `pos` remains visible.
48 fn adjust_view(&self, pos: usize, view_start: usize) -> usize {
49 if self.input_width == 0 {
50 0
51 } else if pos < view_start {
52 pos
53 } else if pos > view_start + self.input_width {
54 pos - self.input_width
55 } else {
56 view_start
57 }
58 }
59
60 /// Returns the cursor offset within the currently-rendered viewport.
61 fn current_pos(&self) -> usize {

Callers 5

do_backspaceMethod · 0.80
do_charMethod · 0.80
do_deleteMethod · 0.80
do_move_toMethod · 0.80
newMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected