mirror of
https://github.com/storytold/wordcraft.git
synced 2026-12-02 22:30:10 +00:00
Compare commits
33
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb67dd4f66 | ||
|
|
aac335b5e3 | ||
|
|
20f9015fec | ||
|
|
806d2a0b2f | ||
|
|
9048100c16 | ||
|
|
592d3cb902 | ||
|
|
8e7fca10b4 | ||
|
|
b83864e0f4 | ||
|
|
60ec8580cd | ||
|
|
ac306cf704 | ||
|
|
0ac9cbfba9 | ||
|
|
1a0b33f671 | ||
|
|
539d9ce9d6 | ||
|
|
ccf6340262 | ||
|
|
af9dca95de | ||
|
|
f0b5298dc4 | ||
|
|
9e8732bd85 | ||
|
|
4c0b520a53 | ||
|
|
370489a59b | ||
|
|
1392290eec | ||
|
|
b2964c2c1c | ||
|
|
3310e9f5ee | ||
|
|
82567c2c61 | ||
|
|
da295eb0c5 | ||
|
|
022be202c1 | ||
|
|
a620ad3587 | ||
|
|
c120c09423 | ||
|
|
f438ec2943 | ||
|
|
021269b675 | ||
|
|
b395c45437 | ||
|
|
68c5dfe8c7 | ||
|
|
eac757af34 | ||
|
|
3c159e2331 |
+17
-1
@@ -619,7 +619,8 @@ impl Paragraph {
|
||||
/// The word around `off` (double-click): (start, end) without trailing space.
|
||||
pub fn word_at(&self, off: usize) -> (usize, usize) {
|
||||
let off = self.clamp(off);
|
||||
let is_w = |c: char| crate::bidi::is_word_char(c);
|
||||
// Word's word unit takes a typographic apostrophe (’) like `'`, at either end too (#6517).
|
||||
let is_w = |c: char| crate::bidi::is_word_char(c) || c == '’';
|
||||
let mut a = off;
|
||||
for (i, c) in self.text.get(..off).unwrap_or("").char_indices().rev() {
|
||||
if !is_w(c) {
|
||||
@@ -852,6 +853,21 @@ mod tests {
|
||||
assert_eq!(p.prev_boundary(0), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn word_at_takes_a_typographic_apostrophe_like_a_straight_one() {
|
||||
// Byte offsets: `’` is three bytes. Word: `don’t ` (#6517).
|
||||
let p = Paragraph::with_text("don’t stop", CharProps::default());
|
||||
assert_eq!(p.word_at(1), (0, 8));
|
||||
assert_eq!(p.word_at(2), (0, 8));
|
||||
let p = Paragraph::with_text("the dogs’ bone", CharProps::default());
|
||||
assert_eq!(p.word_at(5), (4, 12));
|
||||
let p = Paragraph::with_text("’tis here", CharProps::default());
|
||||
assert_eq!(p.word_at(3), (0, 7));
|
||||
assert_eq!(p.word_at(4), (0, 7));
|
||||
let p = Paragraph::with_text("well-known", CharProps::default());
|
||||
assert_eq!(p.word_at(1), (0, 4));
|
||||
}
|
||||
|
||||
proptest::proptest! {
|
||||
#[test]
|
||||
fn edits_keep_runs_consistent(ops in proptest::collection::vec((0u8..4, 0usize..40, 0usize..40, "[a-zé ]{0,5}"), 0..40)) {
|
||||
|
||||
@@ -209,7 +209,8 @@ fn target(s: &Session) -> Option<(Pos, Pos)> {
|
||||
return Some((a, b));
|
||||
}
|
||||
let p = s.doc.para_at(&a)?;
|
||||
let is_w = |c: char| c.is_alphanumeric() || c == '\'' || c == '_';
|
||||
// Word takes a typographic apostrophe (’) like `'` here (#6517).
|
||||
let is_w = |c: char| c.is_alphanumeric() || matches!(c, '\'' | '’' | '_');
|
||||
let before = p.text.get(..a.off)?.chars().next_back();
|
||||
let after = p.text.get(a.off..)?.chars().next();
|
||||
if before.is_some_and(is_w) && after.is_some_and(is_w) {
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::{CmdError, CmdResult, CommandSpec, Selection, Session, p};
|
||||
mod changes;
|
||||
mod comments;
|
||||
mod proofing;
|
||||
pub use proofing::thesaurus_word;
|
||||
|
||||
pub(crate) use changes::StyleTarget;
|
||||
pub use changes::{
|
||||
|
||||
@@ -128,6 +128,20 @@ pub(super) fn suggestions(s: &mut Session, v: &Value) -> CmdResult {
|
||||
}
|
||||
}
|
||||
|
||||
/// The word at the caret that the thesaurus looks up and a chosen synonym replaces: the word unit
|
||||
/// without the spaces after it or the quotes around it, so `‘good’` is `good` and its quotes stay
|
||||
/// when it is replaced; an apostrophe inside a word (`don’t`) is kept (#6517).
|
||||
pub fn thesaurus_word(s: &Session) -> Option<(Pos, Pos)> {
|
||||
let f = &s.sel.focus;
|
||||
let p = s.doc.para_at(f)?;
|
||||
let (a, b) = p.word_at(f.off);
|
||||
let w = p.text.get(a..b)?;
|
||||
let edge = |c: char| c.is_whitespace() || matches!(c, '’' | '‘' | '\'');
|
||||
let start = a + (w.len() - w.trim_start_matches(edge).len());
|
||||
let end = (a + w.trim_end_matches(edge).len()).max(start);
|
||||
Some((Pos { off: start, ..f.clone() }, Pos { off: end, ..f.clone() }))
|
||||
}
|
||||
|
||||
/// A tiny built-in thesaurus of common words (our own list).
|
||||
pub(super) fn thesaurus(s: &mut Session, v: &Value) -> CmdResult {
|
||||
const T: &[(&str, &[&str])] = &[
|
||||
@@ -164,10 +178,8 @@ pub(super) fn thesaurus(s: &mut Session, v: &Value) -> CmdResult {
|
||||
let word = match p::str(v, "word") {
|
||||
Some(w) => w.to_lowercase(),
|
||||
None => {
|
||||
let f = s.sel.focus.clone();
|
||||
let p = s.doc.para_at(&f).ok_or_else(|| CmdError::Failed("no word".into()))?;
|
||||
let (a, b) = p.word_at(f.off);
|
||||
p.text.get(a..b).unwrap_or("").trim().to_lowercase()
|
||||
let (a, b) = thesaurus_word(s).ok_or_else(|| CmdError::Failed("no word".into()))?;
|
||||
s.doc.para_at(&a).and_then(|p| p.text.get(a.off..b.off)).unwrap_or("").to_lowercase()
|
||||
}
|
||||
};
|
||||
let syn = T.iter().find(|(w, _)| *w == word).map(|(_, l)| l.to_vec()).unwrap_or_default();
|
||||
|
||||
@@ -1043,6 +1043,62 @@ fn bold_toggles_selection_and_caret_word() {
|
||||
assert_eq!(p.props_of_char(9).italic, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bold_at_a_caret_takes_a_word_with_a_typographic_apostrophe() {
|
||||
// Word bolds `don’t` and `dogs’` whole: `’` is part of the word like `'` (#6517).
|
||||
let bold_word = |text: &str, caret: usize| {
|
||||
let mut s = s();
|
||||
run(&mut s, "text.insert", json!({"text": text}));
|
||||
run(&mut s, "caret.set", json!({"pos": {"story": "body", "path": [0], "off": caret}}));
|
||||
run(&mut s, "format.bold", json!({}));
|
||||
let p = s.doc.para_at(&Pos::body(0, 0)).unwrap().clone();
|
||||
p.text.char_indices().filter(|&(i, _)| p.props_of_char(i).bold == Some(true)).map(|(_, c)| c).collect::<String>()
|
||||
};
|
||||
assert_eq!(bold_word("don’t stop", 1), "don’t");
|
||||
assert_eq!(bold_word("the dogs’ bone", 5), "dogs’");
|
||||
assert_eq!(bold_word("’tis here", 3), "’tis");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_word_takes_a_typographic_apostrophe() {
|
||||
let mut s = s();
|
||||
run(&mut s, "text.insert", json!({"text": "don’t stop"}));
|
||||
run(&mut s, "caret.set", json!({"pos": {"story": "body", "path": [0], "off": 1}}));
|
||||
run(&mut s, "select.word", json!({}));
|
||||
let (a, b) = s.sel.ordered();
|
||||
assert_eq!((a.off, b.off), (0, 8), "`don’t ` with its trailing space, as Word selects it (#6517)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thesaurus_at_a_caret_looks_up_a_quoted_word_without_its_quotes() {
|
||||
// The word unit now takes `’`, so `‘good’` gives `good’`; the lookup drops enclosing quotes.
|
||||
let mut s = s();
|
||||
run(&mut s, "text.insert", json!({"text": "a ‘good’ day"}));
|
||||
run(&mut s, "caret.set", json!({"pos": {"story": "body", "path": [0], "off": 6}}));
|
||||
let r = run(&mut s, "review.thesaurus", json!({}));
|
||||
assert_eq!(r["word"], json!("good"));
|
||||
assert!(r["synonyms"].as_array().is_some_and(|a| !a.is_empty()), "{r}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_synonym_replaces_the_word_and_keeps_its_quotes() {
|
||||
// The range a chosen synonym replaces (the context menu's): the word without its quotes or the
|
||||
// space after it, while an apostrophe inside a word stays part of it (#6517).
|
||||
let word = |text: &str, caret: usize| {
|
||||
let mut s = s();
|
||||
run(&mut s, "text.insert", json!({"text": text, "raw": true}));
|
||||
run(&mut s, "caret.set", json!({"pos": {"story": "body", "path": [0], "off": caret}}));
|
||||
let (a, b) = crate::cmd::review::thesaurus_word(&s).unwrap();
|
||||
s.set_selection(crate::Selection { anchor: a, focus: b });
|
||||
run(&mut s, "text.insert", json!({"text": "fine", "raw": true}));
|
||||
s.doc.plain_text(StoryRef::Body)
|
||||
};
|
||||
assert_eq!(word("a ‘good’ day", 6), "a ‘fine’ day");
|
||||
assert_eq!(word("a 'good' day", 4), "a 'fine' day");
|
||||
assert_eq!(word("a good day", 3), "a fine day");
|
||||
assert_eq!(word("don’t go", 1), "fine go");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn border_toggles_and_saves() {
|
||||
use wordcraft_doc::props::Border;
|
||||
|
||||
@@ -261,6 +261,8 @@ pub(crate) fn layout_box(ctx: &mut Ctx, input: BoxInput<'_>) -> BoxLayout {
|
||||
// Word has no frames in a text box: a framed paragraph there (its style's frame, usually)
|
||||
// runs with the box's text (#2357).
|
||||
let frames = !matches!(story, StoryRef::Part(id) if ctx.doc.parts.get(&id).is_some_and(|p| p.kind == wordcraft_doc::PartKind::TextBox));
|
||||
// Nor in a table cell for a frame placed on the page: Word keeps its text in the cell.
|
||||
let cell_frame = |fr: &wordcraft_doc::props::TextFrame| !in_cell || fr.v_anchor == "text";
|
||||
// The bottom of the last paragraph's lines.
|
||||
let mut prev_end = 0.0f32;
|
||||
// Where the last paragraph, whose mark is hidden, ended: the next one goes on from there.
|
||||
@@ -282,7 +284,7 @@ pub(crate) fn layout_box(ctx: &mut Ctx, input: BoxInput<'_>) -> BoxLayout {
|
||||
// A text frame (a footer's page number in a frame, say) is placed apart, like a
|
||||
// floating object, and the text after it wraps around it; it takes no room in
|
||||
// the flow.
|
||||
if let Some(fr) = pl.rp.frame.clone().filter(|_| frames) {
|
||||
if let Some(fr) = pl.rp.frame.clone().filter(|fr| frames && cell_frame(fr)) {
|
||||
let fw = fr.w.unwrap_or_else(|| natural_width(&pl)).clamp(1.0, 1584.0);
|
||||
let pf = if (fw - width).abs() > 0.01 { ctx.para_labelled(p, fw, table, &[], label) } else { pl };
|
||||
let h = match fr.h {
|
||||
|
||||
@@ -909,19 +909,29 @@ impl Scan {
|
||||
}
|
||||
self.x += w;
|
||||
}
|
||||
_ => self.pending_tab = Some((j, stop, self.x)),
|
||||
_ => {
|
||||
// Its room grows from nothing with its text (a tab moved on from the line before
|
||||
// may still hold the width it had there).
|
||||
if let Some(c) = pl.clusters.get_mut(j) {
|
||||
c.adv = 0.0;
|
||||
}
|
||||
self.pending_tab = Some((j, stop, self.x));
|
||||
}
|
||||
}
|
||||
if stop.leader != TabLeader::None {
|
||||
self.leaders.push((j, stop.leader));
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether text after a right/centre tab grows leftwards into the tab's space first.
|
||||
/// Whether text after a right/centre tab grows leftwards into the tab's space first. Up to a
|
||||
/// right or decimal stop it fits even past the right indent (Word: a TOC entry whose text ends
|
||||
/// less than a digit short of the indent keeps its page number on its line when the stop is
|
||||
/// at the margin); unshifted, the text after the tab ends at `x - room`.
|
||||
fn absorbs(&self, pl: &ParaLayout, advance: f32) -> bool {
|
||||
self.pending_tab.is_some_and(|(tj, stop, _)| {
|
||||
let room = pl.clusters.get(tj).map(|t| t.adv).unwrap_or(0.0);
|
||||
match stop.align {
|
||||
TabAlign::Right | TabAlign::Decimal => room >= advance,
|
||||
TabAlign::Right | TabAlign::Decimal => room >= advance || self.x - room + advance <= stop.pos + 0.01,
|
||||
TabAlign::Center => room >= advance / 2.0 && self.x + advance / 2.0 <= self.right_edge + 0.01,
|
||||
_ => false,
|
||||
}
|
||||
@@ -997,7 +1007,9 @@ impl Scan {
|
||||
/// Text after a decimal/centre/right tab shifts as it grows.
|
||||
fn shift_pending_tab(&mut self, pl: &mut ParaLayout) {
|
||||
let Some((tj, stop, tx)) = self.pending_tab else { return };
|
||||
let seg_w = self.x - tx;
|
||||
// `x` includes the room the tab has so far.
|
||||
let old = pl.clusters.get(tj).map(|c| c.adv).unwrap_or(0.0);
|
||||
let seg_w = self.x - tx - old;
|
||||
let shift = match stop.align {
|
||||
TabAlign::Right => stop.pos - tx - seg_w,
|
||||
TabAlign::Center => stop.pos - tx - seg_w / 2.0,
|
||||
@@ -1006,7 +1018,6 @@ impl Scan {
|
||||
_ => 0.0,
|
||||
};
|
||||
let shift = shift.max(0.0);
|
||||
let old = pl.clusters.get(tj).map(|c| c.adv).unwrap_or(0.0);
|
||||
if (shift - old).abs() > 0.001 {
|
||||
let delta = shift - old;
|
||||
if let Some(c) = pl.clusters.get_mut(tj) {
|
||||
|
||||
@@ -1970,6 +1970,54 @@ fn leader_dots_are_spaced_and_placed_as_in_word() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A TOC entry with a right indent and its right tab at the margin, past the indent (Word's TOC
|
||||
/// styles): the page number may end past the indent, up to the stop. Like Word, the number stays
|
||||
/// on the text's line whenever it fits between the text and the stop, also when the text ends
|
||||
/// less than a digit short of the indent; when it doesn't fit there, the tab and the number go
|
||||
/// to the next line as before.
|
||||
#[test]
|
||||
fn right_tab_past_the_right_indent_takes_its_number_up_to_the_stop() {
|
||||
use wordcraft_doc::props::{TabAlign, TabLeader, TabStop};
|
||||
let stop = 72.0 + 468.0;
|
||||
let mut close = 0;
|
||||
for indent in [28.35f32, 6.0] {
|
||||
let edge = stop - indent;
|
||||
for m in 20..40 {
|
||||
for r in 2..7 {
|
||||
let text = format!("{}{}\t104", "abc ".repeat(m), "y".repeat(r));
|
||||
let n = text.chars().count();
|
||||
let tab = n - 4;
|
||||
let mut d = Document::from_text(&text);
|
||||
d.format_paragraphs(&Pos::body(0, 0), &Pos::body(0, 0), &|p| {
|
||||
p.indent_right = Some(indent);
|
||||
p.tabs = Some(vec![TabStop { pos: 468.0, align: TabAlign::Right, leader: TabLeader::Dot }]);
|
||||
})
|
||||
.unwrap();
|
||||
let l = lay(&d);
|
||||
let Some(para) = l.pages[0].items.iter().find_map(|i| if let Placed::Lines { para, .. } = i { Some(para.clone()) } else { None })
|
||||
else {
|
||||
panic!("no lines")
|
||||
};
|
||||
let line_of = |k: usize| para.lines.iter().position(|l| l.c0 <= k && k < l.c1).unwrap();
|
||||
// Where the text ends and how wide the number is (the text's last letter and the number
|
||||
// are each on one line; the last two letters are both a "y").
|
||||
let last = l.caret(&Pos::body(0, tab - 1)).unwrap().x;
|
||||
let text_end = last + (last - l.caret(&Pos::body(0, tab - 2)).unwrap().x);
|
||||
let end = l.caret(&Pos::body(0, n)).unwrap().x;
|
||||
let number = end - l.caret(&Pos::body(0, n - 3)).unwrap().x;
|
||||
assert!((end - stop).abs() < 0.5, "indent {indent}, {m} words + {r}: number ends at {end}");
|
||||
assert_eq!(line_of(tab), line_of(n - 1), "indent {indent}, {m} words + {r}: the tab and its number are on different lines");
|
||||
let same = line_of(tab) == line_of(tab - 1);
|
||||
assert_eq!(same, text_end + number <= stop + 0.01, "indent {indent}, {m} words + {r}: text ends at {text_end}, number {number} wide");
|
||||
if same && text_end > edge - number / 3.0 {
|
||||
close += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(close > 0, "no entry whose text ends within a digit of the indent");
|
||||
}
|
||||
|
||||
/// A left tab whose only stop is past the right indent wraps; on the next line it still can't
|
||||
/// reach that stop, so it takes no room there and its text starts at the indent instead of
|
||||
/// going to a line of its own.
|
||||
@@ -12690,6 +12738,26 @@ fn a_text_frame_in_a_cell_floats_beside_the_text() {
|
||||
assert!(frame.x > text.x + 200.0, "right-aligned in the cell: {} vs {}", frame.x, text.x);
|
||||
}
|
||||
|
||||
/// A cell paragraph framed against the page (a divider page's floating table, its paragraphs
|
||||
/// carrying the table's page position as a frame) stays in its cell in Word. WordCraft placed it
|
||||
/// apart at the page offset, past the page's foot, and added a blank page per divider.
|
||||
#[test]
|
||||
fn a_page_anchored_frame_in_a_cell_stays_in_the_cell() {
|
||||
use wordcraft_doc::props::TextFrame;
|
||||
let mut d = Document::from_text("Above");
|
||||
let mut t = Table::new(1, 1, 300.0);
|
||||
let mut framed = wordcraft_doc::Paragraph::with_text("Divider", Default::default());
|
||||
framed.props.frame = Some(TextFrame { y: 777.5, h_anchor: "page".into(), v_anchor: "page".into(), wrap: "around".into(), ..Default::default() });
|
||||
let text = wordcraft_doc::Paragraph::with_text("Cell text", Default::default());
|
||||
t.rows[0].cells[0].blocks = vec![wordcraft_doc::para_block(framed), wordcraft_doc::para_block(text)];
|
||||
d.insert_block(StoryRef::Body, &Path::top(1), wordcraft_doc::Block::Table(t)).unwrap();
|
||||
let l = lay(&d);
|
||||
let at = |i: u32| l.caret(&Pos { story: StoryRef::Body, path: Path(vec![1, 0, 0, i]), off: 0 }).unwrap();
|
||||
let (frame, text) = (at(0), at(1));
|
||||
assert!(text.top > frame.top + 5.0, "the framed paragraph takes its line: {} vs {}", frame.top, text.top);
|
||||
assert_eq!(l.pages.len(), 1, "no page for the frame's offset");
|
||||
}
|
||||
|
||||
/// Word has no frames inside a text box: a paragraph there whose style carries a frame (a
|
||||
/// letterhead's "Weld" and "Governor" styles, framed at the page's left) runs in the box's text
|
||||
/// like any other. WordCraft placed each one apart at the frame's offset, so two of them in a row
|
||||
|
||||
@@ -151,12 +151,11 @@ fn rows(app: &mut WordApp, ui: &mut Ui) {
|
||||
let _ = Menu::submenu_row(ui, tl!("Synonyms").to_string(), |ui, _cx| {
|
||||
for w in syn.iter().filter_map(|x| x.as_str()) {
|
||||
if MenuItem::new(w.to_string()).show(ui).ran {
|
||||
let _ = app.run("select.word", json!({}));
|
||||
let (a, b) = app.session.sel.ordered();
|
||||
let trimmed = app.session.doc.para_at(&a).and_then(|p| p.text.get(a.off..b.off)).map(|t| t.trim_end().len()).unwrap_or(0);
|
||||
let end = wordcraft_doc::Pos { off: a.off + trimmed, ..b };
|
||||
app.session.set_selection(wordcraft_engine::Selection { anchor: a, focus: end });
|
||||
let _ = app.run("text.insert", json!({"text": w, "raw": true}));
|
||||
// The word the synonyms were looked up for: quotes around it stay (#6517).
|
||||
if let Some((a, b)) = wordcraft_engine::cmd::review::thesaurus_word(&app.session) {
|
||||
app.session.set_selection(wordcraft_engine::Selection { anchor: a, focus: b });
|
||||
let _ = app.run("text.insert", json!({"text": w, "raw": true}));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -271,7 +271,11 @@ impl CanvasTool for PageTextTool<'_> {
|
||||
if let Some(c) = ObjectGesture::cursor(&*self.app, &self.layout, self.body, pointer.pos, pointer.mods) {
|
||||
return c;
|
||||
}
|
||||
let Some((page, x, y)) = page_of(self.body.pages, pointer.pos) else { return Cursor::System(CursorIcon::Default) };
|
||||
// Off the paper the arrow shows, except while a drag that began on the page is still held.
|
||||
let Some((page, x, y)) = page_of(self.body.pages, pointer.pos) else {
|
||||
let held = self.app.canvas.dragging || self.app.canvas.unit_drag.is_some();
|
||||
return if held { text() } else { Cursor::System(CursorIcon::Default) };
|
||||
};
|
||||
// The selection bar keeps its arrow.
|
||||
if self.app.session.sel.focus.story == StoryRef::Body && !pointer.mods.alt && self.layout.selection_bar_at(page, x, y).is_some() {
|
||||
return Cursor::System(CursorIcon::Default);
|
||||
|
||||
@@ -658,6 +658,67 @@ fn an_armed_format_painter_changes_the_pointer() {
|
||||
assert!(matches!(bar, None | Some(Cursor::System(CursorIcon::Default))), "the selection bar keeps its arrow: {bar:?}");
|
||||
}
|
||||
|
||||
/// The text pointer shows over the paper only: the grey beside a page keeps the arrow.
|
||||
#[test]
|
||||
fn the_text_pointer_stays_off_the_grey_around_the_page() {
|
||||
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
|
||||
a.run("text.insert", json!({"text": "Some text"})).unwrap();
|
||||
a.run("view.commentsPane", json!({"value": false})).unwrap();
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
app.logic(&ctx);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let c = h.state_mut().session.layout().caret(&Pos::body(0, 4)).expect("caret");
|
||||
let y = c.top + c.height / 2.0;
|
||||
let on_page = page_to_screen(h.state_mut(), c.page, c.x, y).expect("on screen");
|
||||
let beside = page_to_screen(h.state_mut(), c.page, -40.0, y).expect("on screen");
|
||||
h.event(egui::Event::PointerMoved(on_page));
|
||||
h.step();
|
||||
assert_ne!(h.output().platform_output.cursor_icon, egui::CursorIcon::Default, "text pointer on the paper");
|
||||
h.event(egui::Event::PointerMoved(beside));
|
||||
h.step();
|
||||
assert_eq!(h.output().platform_output.cursor_icon, egui::CursorIcon::Default, "arrow on the grey beside the page");
|
||||
|
||||
// A drag that starts on the page retains its text pointer after moving off it.
|
||||
h.event(egui::Event::PointerMoved(on_page));
|
||||
h.step();
|
||||
h.event(egui::Event::PointerButton { pos: on_page, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
h.step();
|
||||
h.event(egui::Event::PointerMoved(beside));
|
||||
h.step();
|
||||
assert_ne!(h.output().platform_output.cursor_icon, egui::CursorIcon::Default, "a drag that began on the page keeps its text pointer");
|
||||
h.event(egui::Event::PointerButton { pos: beside, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() });
|
||||
h.step();
|
||||
|
||||
// A drag that begins in the grey area must not inherit the text cursor merely because the
|
||||
// canvas response is dragged. Keep the pointer off the page for the whole drag.
|
||||
h.event(egui::Event::PointerButton { pos: beside, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
h.step();
|
||||
let further_beside = beside + egui::vec2(20.0, 0.0);
|
||||
h.event(egui::Event::PointerMoved(further_beside));
|
||||
h.step();
|
||||
assert_eq!(h.output().platform_output.cursor_icon, egui::CursorIcon::Default, "arrow during a drag that began in the grey area");
|
||||
h.event(egui::Event::PointerButton { pos: further_beside, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() });
|
||||
h.step();
|
||||
|
||||
// A press on the page and a move onto the grey that arrive in one frame: the press decides.
|
||||
h.event(egui::Event::PointerMoved(on_page));
|
||||
h.step();
|
||||
h.event(egui::Event::PointerButton { pos: on_page, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() });
|
||||
h.event(egui::Event::PointerMoved(beside));
|
||||
h.step();
|
||||
assert_ne!(h.output().platform_output.cursor_icon, egui::CursorIcon::Default, "press and move in one frame keep the text pointer");
|
||||
h.event(egui::Event::PointerButton { pos: beside, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() });
|
||||
h.step();
|
||||
}
|
||||
|
||||
/// #4410: with the Format Painter armed, a double-click on a word paints that word, and the
|
||||
/// painter goes off again (it was only dragging across the text that painted it).
|
||||
#[test]
|
||||
|
||||
@@ -324,6 +324,7 @@ impl<'a> Exempt<'a> {
|
||||
|| plain == "CONFIDENTIAL" // the watermark dialog's text: document content, kept as typed
|
||||
|| plain == "Figure 1" // the caption dialog's sample: the label goes into the document as is
|
||||
|| clock_text(plain) // the Date and Time preview: formatted from the clock
|
||||
|| plain.starts_with("egui PERF WARNING:") // framework diagnostic, not application interface text
|
||||
|| is_url(plain) // a link is data, not wording
|
||||
}
|
||||
}
|
||||
@@ -356,6 +357,8 @@ fn runtime_data_is_exempt_and_wording_is_not() {
|
||||
}
|
||||
assert!(exempt.allows(&app, "https://github.com/storytold/wordcraft/releases"));
|
||||
assert!(!exempt.allows(&app, "Download the newest release"), "an unwrapped sentence is reported");
|
||||
assert!(exempt.allows(&app, "egui PERF WARNING: request_discard has been called 3 frames in a row"));
|
||||
assert!(!exempt.allows(&app, "Performance warnings should be translated"));
|
||||
assert!(!exempt.allows(&app, "See https://example.com now"), "a sentence with a link is not a link");
|
||||
assert!(!exempt.allows(&app, "11/22/1999 5:28:50 PM"), "a time before the audit began is not the preview");
|
||||
// A stubbed check finds no update and puts no updater error on screen.
|
||||
|
||||
@@ -413,6 +413,7 @@ The front-of-text opt-out is retained from the earlier implementation; this patc
|
||||
| 2026-10-27 | trivial | A kept-together paragraph in a continuous section is measured against the next page's body, so a tall different first-page header no longer splits one that fits on page 2 (#3907 CodeRabbit) |
|
||||
| 2026-10-27 | trivial | 2026-10-27 · #4533 review: numeric REF updates lazily index body bookmarks once per update, retaining the first body bookmark for duplicate names. Unsupported switches and ordinary REF/PAGEREF behavior are unchanged; a synthetic 64-reference regression covers repeated updates and duplicate names. Estimates unchanged. |
|
||||
| 2026-10-27 | trivial | 2026-10-27 · #4533: numeric REF fields use paragraph list numbers for no/full/relative context, reusing bounded numbering. Shared context already embedded in a level label is removed; merged-away cells do not count. Unsupported separator/text/position switches and ambiguous contexts or delimiter-free joins retain cached results. Synthetic OOXML regressions; no native Word or real-document validation, estimates unchanged. |
|
||||
| 2026-10-27 | trivial | A right or decimal tab past the right indent (a TOC entry's page number at the margin) keeps its text on the line while it ends before the stop, also when the text before the tab ends less than a digit short of the indent; measured in Word for Mac 16.93. `layout::tests::right_tab_past_the_right_indent_takes_its_number_up_to_the_stop` |
|
||||
| 2026-10-20 | trivial | A click below a floating table, outside its cells, goes to the paragraph beside or after it instead of a cell of its last row, as checked in Word (#2038) |
|
||||
| 2026-10-19 | trivial | A right, centre or decimal tab whose text doesn't fit, or a left tab past the right indent, starts the next line with its text instead of ending the line (a TOC entry's page number keeps its leader); a left tab still past the right indent there takes no room (#1840) |
|
||||
| 2026-10-19 | trivial | Justified lines (compatibility mode 15) shrink their spaces to fit one more word by at most a quarter of the spaces' width (was a fifth) and by at most 0.355 of that word's own width with the space before it. Measured in Word for Mac with synthetic justified paragraphs: words of 2.7 to 80 pt, spaces of 3.3 and 6.7 pt, only justified text, last lines included, never in modes 12 and 14. A real paper's justified abstract now breaks like Word on all 23 lines (3 before); on 180 real-world papers, page counts matching Word went from 139 to 142, none further |
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user