feat: 响应式分页引擎 - 基于egui Galley精确测量替代字符计数
This commit is contained in:
13
src/book.rs
13
src/book.rs
@@ -179,12 +179,18 @@ pub struct TocEntry {
|
||||
pub children: Vec<TocEntry>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ContentBlock {
|
||||
pub text: String,
|
||||
pub is_heading: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Section {
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
/// Populated by pagination algorithm (pre-computed char offsets for page boundaries)
|
||||
pub pages: Vec<usize>,
|
||||
pub blocks: Vec<ContentBlock>,
|
||||
pub page_block_ranges: Vec<(usize, usize)>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
@@ -253,7 +259,8 @@ pub fn load_epub(path: impl AsRef<Path>) -> Result<Book, String> {
|
||||
sections.push(Section {
|
||||
title,
|
||||
content: text,
|
||||
pages: Vec::new(),
|
||||
blocks: Vec::new(),
|
||||
page_block_ranges: Vec::new(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user