|
|
@ -207,7 +207,7 @@ impl View {
|
|
|
|
self.area.clip_bottom(1).height.into() // -1 for statusline
|
|
|
|
self.area.clip_bottom(1).height.into() // -1 for statusline
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Does not account for height of statusline
|
|
|
|
/// Does not account for height of statusline
|
|
|
|
pub fn inner_area_raw(&self, doc: &Document) -> Rect {
|
|
|
|
pub fn inner_area_raw(&self, doc: &Document) -> Rect {
|
|
|
|
self.area.clip_left(self.gutter_offset(doc))
|
|
|
|
self.area.clip_left(self.gutter_offset(doc))
|
|
|
@ -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.
|
|
|
|