@@ -218,6 +218,26 @@ impl View {
218218 pub fn pos_at_screen_coords(&self, doc: &Document, row: u16, column: u16) -> Option<usize> {
219219 self.text_pos_at_screen_coords(&doc.text().slice(..), row, column, doc.tab_width())
220220 }
221+
222+ /// Translates screen coordinates into coordinates on the gutter of the view.
223+ /// Returns a tuple of usize typed line and column numbers starting with 0.
224+ /// Returns None if coordinates are not on the gutter.
225+ pub fn gutter_coords_at_screen_coords(&self, row: u16, column: u16) -> Option<(usize, usize)> {
226+ // 1 for status
227+ if row < self.area.top() || row >= self.area.bottom() {
228+ return None;
229+ }
230+
231+ if column < self.area.left() || column > self.area.right() {
232+ return None;
233+ }
234+
235+ Some((
236+ (row - self.area.top()) as usize,
237+ (column - self.area.left()) as usize,
238+ ))
239+ }
240+
221241 // pub fn traverse<F>(&self, text: RopeSlice, start: usize, end: usize, fun: F)
222242 // where
223243 // F: Fn(usize, usize),