|
|
@ -355,22 +355,42 @@ impl View {
|
|
|
|
Some(offset)
|
|
|
|
Some(offset)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn ensure_cursor_in_view(&self, doc: &mut Document, scrolloff: usize, unobtrusive_statusline: bool) {
|
|
|
|
pub fn ensure_cursor_in_view(
|
|
|
|
if let Some(offset) = self.offset_coords_to_in_view_center::<false>(doc, scrolloff, unobtrusive_statusline) {
|
|
|
|
&self,
|
|
|
|
|
|
|
|
doc: &mut Document,
|
|
|
|
|
|
|
|
scrolloff: usize,
|
|
|
|
|
|
|
|
unobtrusive_statusline: bool,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
if let Some(offset) =
|
|
|
|
|
|
|
|
self.offset_coords_to_in_view_center::<false>(doc, scrolloff, unobtrusive_statusline)
|
|
|
|
|
|
|
|
{
|
|
|
|
doc.set_view_offset(self.id, offset);
|
|
|
|
doc.set_view_offset(self.id, offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn ensure_cursor_in_view_center(&self, doc: &mut Document, scrolloff: usize, unobtrusive_statusline: bool) {
|
|
|
|
pub fn ensure_cursor_in_view_center(
|
|
|
|
if let Some(offset) = self.offset_coords_to_in_view_center::<true>(doc, scrolloff, unobtrusive_statusline) {
|
|
|
|
&self,
|
|
|
|
|
|
|
|
doc: &mut Document,
|
|
|
|
|
|
|
|
scrolloff: usize,
|
|
|
|
|
|
|
|
unobtrusive_statusline: bool,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
if let Some(offset) =
|
|
|
|
|
|
|
|
self.offset_coords_to_in_view_center::<true>(doc, scrolloff, unobtrusive_statusline)
|
|
|
|
|
|
|
|
{
|
|
|
|
doc.set_view_offset(self.id, offset);
|
|
|
|
doc.set_view_offset(self.id, offset);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
align_view(doc, self, Align::Center, unobtrusive_statusline);
|
|
|
|
align_view(doc, self, Align::Center, unobtrusive_statusline);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn is_cursor_in_view(&mut self, doc: &Document, scrolloff: usize, unobtrusive_statusline: bool) -> bool {
|
|
|
|
pub fn is_cursor_in_view(
|
|
|
|
self.offset_coords_to_in_view(doc, scrolloff, unobtrusive_statusline).is_none()
|
|
|
|
&mut self,
|
|
|
|
|
|
|
|
doc: &Document,
|
|
|
|
|
|
|
|
scrolloff: usize,
|
|
|
|
|
|
|
|
unobtrusive_statusline: bool,
|
|
|
|
|
|
|
|
) -> bool {
|
|
|
|
|
|
|
|
self.offset_coords_to_in_view(doc, scrolloff, unobtrusive_statusline)
|
|
|
|
|
|
|
|
.is_none()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Estimates the last visible document line on screen.
|
|
|
|
/// Estimates the last visible document line on screen.
|
|
|
|