Implement {move_to,select_to,delete_to}_{beginning,end}_of_line

This commit is contained in:
Antonio Scandurra
2021-04-29 10:38:11 +02:00
parent 0aacf858ce
commit 283c734c91
3 changed files with 330 additions and 24 deletions
+14
View File
@@ -67,6 +67,20 @@ impl DisplayMap {
Ok(chars.take_while(|c| *c != '\n').collect())
}
pub fn line_indent(&self, display_row: u32, app: &AppContext) -> Result<(u32, bool)> {
let mut indent = 0;
let mut is_blank = true;
for c in self.chars_at(DisplayPoint::new(display_row, 0), app)? {
if c == ' ' {
indent += 1;
} else {
is_blank = c == '\n';
break;
}
}
Ok((indent, is_blank))
}
pub fn chars_at<'a>(&'a self, point: DisplayPoint, app: &'a AppContext) -> Result<Chars<'a>> {
let column = point.column() as usize;
let (point, to_next_stop) = point.collapse_tabs(self, Bias::Left, app)?;