From c999576afdc95bfd4fe54370df7835092f98efe0 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 21 Jan 2022 18:16:02 +0800 Subject: [PATCH] debug insertion point failures --- services/graphics-server/src/testing.rs | 10 +++++----- services/graphics-server/src/wordwrap.rs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/graphics-server/src/testing.rs b/services/graphics-server/src/testing.rs index 1438ee0c4..f2b13f174 100644 --- a/services/graphics-server/src/testing.rs +++ b/services/graphics-server/src/testing.rs @@ -79,7 +79,7 @@ pub fn tests() { tv.rounded_border = Some(8); write!(tv, "This is a test of basic word😃 wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); - tv.insertion = Some(8); + tv.insertion = Some(0); gfx.draw_textview(&mut tv).unwrap(); gfx.flush().unwrap(); log::info!("rendered: {:?}", tv); @@ -98,7 +98,7 @@ pub fn tests() { tv.invert = true; write!(tv, "This is a test of basic word😃 wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); - tv.insertion = Some(0); + tv.insertion = Some(3); gfx.draw_textview(&mut tv).unwrap(); gfx.flush().unwrap(); log::info!("rendered: {:?}", tv); @@ -116,7 +116,7 @@ pub fn tests() { tv.rounded_border = Some(12); write!(tv, "This is a test of basic word😃 wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); - tv.insertion = Some(20); + tv.insertion = Some(4); gfx.draw_textview(&mut tv).unwrap(); gfx.flush().unwrap(); log::info!("rendered: {:?}", tv); @@ -134,7 +134,7 @@ pub fn tests() { tv.rounded_border = None; write!(tv, "This is a test of basic word😃 wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); - tv.insertion = Some(21); + tv.insertion = Some(5); gfx.draw_textview(&mut tv).unwrap(); gfx.flush().unwrap(); log::info!("rendered: {:?}", tv); @@ -164,7 +164,7 @@ pub fn tests() { tv.rounded_border = None; write!(tv, "This is a test of basic word wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); - tv.insertion = Some(21); + tv.insertion = Some(x_off as i32 + 10); gfx.draw_textview(&mut tv).unwrap(); gfx.flush().unwrap(); log::info!("rendered: {:?}", tv); diff --git a/services/graphics-server/src/wordwrap.rs b/services/graphics-server/src/wordwrap.rs index e0b589603..4282b80e3 100644 --- a/services/graphics-server/src/wordwrap.rs +++ b/services/graphics-server/src/wordwrap.rs @@ -179,10 +179,10 @@ impl ComposedType { // draw the insertion point after the glyph's position crate::op::line(frbuf, crate::api::Line::new( - crate::api::Point::new(point.x as i16 - 1, point.y as _), - crate::api::Point::new(point.x as i16 - 1, point.y as i16 + glyph.high as i16) + crate::api::Point::new(maybe_x as i16 - 1, maybe_y as _), + crate::api::Point::new(maybe_x as i16 - 1, maybe_y as i16 + glyph.high as i16) ), - None, + Some(clip_rect), invert ); }