mirror of
https://github.com/storytold/wordcraft.git
synced 2026-12-02 22:30:10 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0cd86e378 | ||
|
|
ec29711caf | ||
|
|
2bce6ed613 | ||
|
|
03b20a6ca9 | ||
|
|
e27a3bbdfc | ||
|
|
2e9699c519 | ||
|
|
7f8283a77f |
@@ -876,6 +876,14 @@ impl Scan {
|
||||
bk.wrapped_tab = Some(j);
|
||||
return true;
|
||||
}
|
||||
if bk.wrapped_tab == Some(j) && self.narrowed && stop.pos > bk.base_right + 0.01 && bk.skipped < 50 {
|
||||
// A left tab past the right indent that wrapped into a span narrowed by a
|
||||
// floating object (the far side of it, say): like Word, it goes on to the
|
||||
// first line clear of the object (#6577). A stop inside the right indent
|
||||
// keeps the zero-width path below.
|
||||
self.skip = true;
|
||||
return true;
|
||||
}
|
||||
if bk.wrapped_tab == Some(j) {
|
||||
// Still past the right indent on the line it wrapped to: it takes no
|
||||
// room, and its text starts at the indent rather than on a line of its own.
|
||||
|
||||
@@ -2028,6 +2028,70 @@ fn left_tab_past_the_right_indent_does_not_add_a_line() {
|
||||
assert!((page.x - 72.0).abs() < 0.5, "the text after the tab starts at the indent: {}", page.x);
|
||||
}
|
||||
|
||||
/// Beside a floating object the wrapped tab doesn't start its text in the span on the object's
|
||||
/// far side: like Word, it goes to the first line clear of the object, and its text starts at the
|
||||
/// indent there (#6577).
|
||||
#[test]
|
||||
fn left_tab_past_the_right_indent_beside_a_float_moves_clear_of_it() {
|
||||
use wordcraft_doc::props::{TabAlign, TabLeader, TabStop};
|
||||
crate::test_fonts();
|
||||
let mut d = Document::from_text("Name\tPage");
|
||||
d.format_paragraphs(&Pos::body(0, 0), &Pos::body(0, 0), &|p| {
|
||||
p.tabs = Some(vec![TabStop { pos: 500.0, align: TabAlign::Left, leader: TabLeader::None }])
|
||||
})
|
||||
.unwrap();
|
||||
// A box in the middle of the column, anchored after the text so the offsets stay those of
|
||||
// "Name\tPage": the rows beside it have a span on each side.
|
||||
let float = wordcraft_doc::para::Float {
|
||||
wrap: wordcraft_doc::para::Wrap::Square,
|
||||
h_rel: wordcraft_doc::para::Anchor::Column,
|
||||
v_rel: wordcraft_doc::para::Anchor::Paragraph,
|
||||
x: 184.0,
|
||||
y: 0.0,
|
||||
dist: 9.0,
|
||||
..Default::default()
|
||||
};
|
||||
let id = text_box(&mut d, 9, "", 100.0, 43.0, float);
|
||||
let l = lay(&d);
|
||||
let r = box_rect(&l, id);
|
||||
let name = l.caret(&Pos::body(0, 0)).unwrap();
|
||||
assert!((name.x - 72.0).abs() < 0.5 && name.top < r.bottom(), "the text before the tab starts beside the box: {name:?}, box {r:?}");
|
||||
let page = l.caret(&Pos::body(0, 5)).unwrap();
|
||||
assert!((page.x - 72.0).abs() < 0.5, "the text after the tab starts at the indent, not beside the box: {page:?}, box {r:?}");
|
||||
assert!(page.top >= r.bottom() - 0.5, "the text after the tab starts below the box: {page:?}, box {r:?}");
|
||||
}
|
||||
|
||||
/// A left tab whose stop is inside the right indent is not a tab "past the right indent": beside
|
||||
/// a floating object it keeps the zero-width path, its text starting where the span does, and is
|
||||
/// not moved clear of the object (#6577).
|
||||
#[test]
|
||||
fn a_left_tab_inside_the_right_indent_beside_a_float_keeps_its_line() {
|
||||
use wordcraft_doc::props::{TabAlign, TabLeader, TabStop};
|
||||
crate::test_fonts();
|
||||
let mut d = Document::from_text("Name\tPage");
|
||||
d.format_paragraphs(&Pos::body(0, 0), &Pos::body(0, 0), &|p| {
|
||||
p.tabs = Some(vec![TabStop { pos: 400.0, align: TabAlign::Left, leader: TabLeader::None }])
|
||||
})
|
||||
.unwrap();
|
||||
// A box against the right indent, anchored after the text: every row beside it has only the
|
||||
// span on its left, which ends before the 400 pt stop (inside the 468 pt text width).
|
||||
let float = wordcraft_doc::para::Float {
|
||||
wrap: wordcraft_doc::para::Wrap::Square,
|
||||
h_rel: wordcraft_doc::para::Anchor::Column,
|
||||
v_rel: wordcraft_doc::para::Anchor::Paragraph,
|
||||
x: 360.0,
|
||||
y: 0.0,
|
||||
dist: 9.0,
|
||||
..Default::default()
|
||||
};
|
||||
let id = text_box(&mut d, 9, "", 100.0, 100.0, float);
|
||||
let l = lay(&d);
|
||||
let r = box_rect(&l, id);
|
||||
let page = l.caret(&Pos::body(0, 5)).unwrap();
|
||||
assert!((page.x - 72.0).abs() < 0.5, "the text after the tab starts where the span does, not at the stop: {page:?}, box {r:?}");
|
||||
assert!(page.top < r.bottom() - 0.5, "the text after the tab stays beside the box: {page:?}, box {r:?}");
|
||||
}
|
||||
|
||||
/// A bookmark before such a tab is not text: the tab does not wrap away from it, and the
|
||||
/// paragraph breaks as it does without the bookmark (no line holding only the bookmark).
|
||||
#[test]
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user