@@ -5,17 +5,56 @@ use std::borrow::Cow;
5use crate::{Document, DocumentId, ViewId};
5use crate::{Document, DocumentId, ViewId};
6use helix_core::{
6use helix_core::{
7 graphemes::{grapheme_width, RopeGraphemes},
7 graphemes::{grapheme_width, RopeGraphemes},
8− Position, RopeSlice,
8+ Position, RopeSlice, Selection,
10use tui::layout::Rect;
10use tui::layout::Rect;
12pub const PADDING: usize = 5;
12pub const PADDING: usize = 5;
14+type Jump = (DocumentId, Selection);
22+ pub fn new(initial: Jump) -> Self {
24+ jumps: vec![initial],
29+ pub fn push(&mut self, jump: Jump) {
30+ self.jumps.truncate(self.current + 1);
31+ self.jumps.push(jump);
35+ pub fn forward(&mut self, count: usize) -> Option<&Jump> {
36+ if self.current + count < self.jumps.len() {
37+ self.current += count;
38+ return self.jumps.get(self.current);
43+ pub fn backward(&mut self, count: usize) -> Option<&Jump> {
44+ if self.current.checked_sub(count).is_some() {
45+ self.current -= count;
46+ return self.jumps.get(self.current);
14pub struct View {
52pub struct View {
15 pub id: ViewId,
53 pub id: ViewId,
16 pub doc: DocumentId,
54 pub doc: DocumentId,
17 pub first_line: usize,
55 pub first_line: usize,
18 pub area: Rect,
56 pub area: Rect,
21impl View {
60impl View {
@@ -25,6 +64,7 @@ impl View {
26 first_line: 0,
65 first_line: 0,
27 area: Rect::default(), // will get calculated upon inserting into tree
66 area: Rect::default(), // will get calculated upon inserting into tree
67+ jumps: JumpList::new((doc, Selection::point(0))), // TODO: use actual sel