Skip to content

Commit 1549c65

Browse files
author
Noam Lewis
committed
WIP
1 parent 2fbdc04 commit 1549c65

File tree

2 files changed

+8
-107
lines changed

2 files changed

+8
-107
lines changed

src/chunks.rs

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/main.rs

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ use std::{
77
};
88

99
use crate::lines::LoadedLine;
10-
use chunks::Chunk;
1110
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
11+
use memstore::Memstore;
1212
use ratatui::{
1313
layout::{Position, Rect, Size},
1414
style::{Style, Stylize},
1515
text::{Line, Span, Text},
1616
DefaultTerminal, Frame,
1717
};
18+
use virtual_file::VirtualFile;
1819

19-
mod chunks;
2020
mod lines;
2121
mod lines_iter;
22+
mod memstore;
23+
mod virtual_file;
2224

2325
// TODO
2426
// How to represent edited content?
@@ -37,39 +39,9 @@ mod lines_iter;
3739
// if disk_offset = write offset and is_modified = false, no need to write (skip the chunk).
3840
// This can optimize writing huge files.
3941

40-
struct VirtualLines {}
41-
42-
impl VirtualLines {
43-
fn get_mut(&self, line_index: usize) -> &mut LoadedLine {
44-
todo!()
45-
}
46-
47-
fn len(&self) -> u16 {
48-
todo!()
49-
}
50-
51-
fn remove(&self, y: usize) -> LoadedLine {
52-
todo!()
53-
}
54-
55-
fn insert(&self, y: usize, new_line: LoadedLine) {
56-
todo!()
57-
}
58-
59-
fn get(&self, y: usize) -> &LoadedLine {
60-
todo!()
61-
}
62-
63-
fn iter<I: Iterator>(&self, y: usize, lines_per_page: usize) -> I {
64-
todo!()
65-
}
66-
}
67-
6842
struct State {
6943
/// Content loaded from the file, may be a small portion of the entire file starting at some offset
70-
data: Chunk<'static>,
71-
72-
lines: VirtualLines,
44+
lines: VirtualFile,
7345

7446
/// Cursor position relative to loaded content (lines)
7547
cursor: Position,
@@ -84,9 +56,6 @@ struct State {
8456
status_text: String,
8557

8658
terminal_size: Size,
87-
88-
file: Option<std::fs::File>,
89-
file_offset: u64,
9059
}
9160

9261
impl State {
@@ -369,10 +338,8 @@ impl State {
369338
frame.render_widget(
370339
Text::from_iter(
371340
self.lines
372-
.iter(
373-
self.window_offset.y as usize,
374-
self.lines_per_page() as usize,
375-
)
341+
.iter_at(self.window_offset.y as usize)
342+
.take(self.lines_per_page() as usize)
376343
.enumerate()
377344
.map(render_line),
378345
),
@@ -512,7 +479,7 @@ fn main() -> io::Result<()> {
512479
file: file,
513480
file_offset: 0,
514481
terminal_size: terminal.size()?,
515-
data: todo!(),
482+
memstore: todo!(), //Memstore::new(1024 *1024 , |offset:u64| , store_fn),
516483
lines: todo!(),
517484
};
518485
//state.load()?;

0 commit comments

Comments
 (0)