Adjusts the viewport start to ensure `pos` remains visible.
(&self, pos: usize, view_start: usize)
| 46 | impl<'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 { |
no outgoing calls
no test coverage detected