mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
insertion points working, commit test case
This commit is contained in:
parent
c999576afd
commit
481cf81824
2 changed files with 37 additions and 3 deletions
|
|
@ -11,7 +11,8 @@ enum TestType {
|
|||
TopLeft = 3,
|
||||
TopRight = 4,
|
||||
Overflow = 5,
|
||||
End = 6,
|
||||
Insert = 6,
|
||||
End = 7,
|
||||
}
|
||||
const TEST_STYLE: GlyphStyle = GlyphStyle::Regular;
|
||||
pub fn tests() {
|
||||
|
|
@ -171,6 +172,31 @@ pub fn tests() {
|
|||
ticktimer.sleep_ms(200).unwrap();
|
||||
}
|
||||
}
|
||||
Some(TestType::Insert) => {
|
||||
gfx.draw_rectangle(blackout).unwrap();
|
||||
gfx.flush().unwrap();
|
||||
gfx.draw_rectangle(checkbound).unwrap();
|
||||
gfx.flush().unwrap();
|
||||
|
||||
let mut tv = TextView::new(Gid::new([0, 0, 0, 0]),
|
||||
TextBounds::BoundingBox(
|
||||
text_bounds
|
||||
));
|
||||
tv.clip_rect = Some(clipping_area);
|
||||
tv.style = TEST_STYLE;
|
||||
tv.ellipsis = true;
|
||||
tv.rounded_border = Some(4);
|
||||
write!(tv, "This is a test of basic 自动换行 inside\na\n\n😃 bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap();
|
||||
write!(tv, "Let's add more text😃 until it overflows this is just another test with https://github.com/samblenny/blitstr2/commit/bb7d4ab6a2d8913dcb520895a3c242c933413aae more words and words and words and whatever.").unwrap();
|
||||
for i in 20..60 {
|
||||
log::info!("insertion point at {},{:?}", i, tv.to_str().chars().skip(i).next());
|
||||
tv.insertion = Some(i as i32);
|
||||
gfx.draw_textview(&mut tv).unwrap();
|
||||
gfx.flush().unwrap();
|
||||
ticktimer.sleep_ms(250).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,9 +132,12 @@ impl ComposedType {
|
|||
/// additional checks around this.
|
||||
pub fn render(&self, frbuf: &mut [u32; FB_SIZE], offset: Point, invert: bool, clip_rect: Rectangle) {
|
||||
const MAX_GLYPH_MARGIN: i16 = 16;
|
||||
// let mut strpos; // just for debugging insertion points
|
||||
for word in self.words.iter() {
|
||||
// strpos = word.strpos;
|
||||
let mut point = word.origin.clone();
|
||||
for glyph in word.gs.iter() {
|
||||
// strpos += 1;
|
||||
// the offset can actually be negative for good reasons, e.g., we're doing a scrollable buffer,
|
||||
// but the blitstr2 was written assuming only positive offsets. Handle this here.
|
||||
let maybe_x = offset.x + point.x as i16;
|
||||
|
|
@ -176,6 +179,7 @@ impl ComposedType {
|
|||
);
|
||||
}
|
||||
if glyph.insert {
|
||||
// log::info!("insert at {},{}", glyph.ch, strpos - 1);
|
||||
// draw the insertion point after the glyph's position
|
||||
crate::op::line(frbuf,
|
||||
crate::api::Line::new(
|
||||
|
|
@ -479,7 +483,6 @@ impl Typesetter {
|
|||
self.last_line_height = self.cursor.line_height;
|
||||
}
|
||||
if false {tsw_debug(&self.candidate)};
|
||||
self.charpos += 1;
|
||||
composition.push(
|
||||
std::mem::replace(
|
||||
&mut self.candidate,
|
||||
|
|
@ -535,7 +538,12 @@ impl Typesetter {
|
|||
assert!(self.candidate.gs.len() == 0, "self.candidate was not set to a new state prior to this call");
|
||||
if (self.cursor.pt.x + self.space.wide as usize) < self.bb.max.x {
|
||||
// our candidate word is "just as space"
|
||||
self.candidate.push(self.space.clone());
|
||||
let mut candidate_space = self.space.clone();
|
||||
if self.is_insert_point() {
|
||||
candidate_space.insert = true;
|
||||
}
|
||||
self.candidate.push(candidate_space);
|
||||
self.commit_candidate_glyph(&candidate_space);
|
||||
self.cursor.line_height = self.cursor.line_height.max(self.space.high as usize);
|
||||
// if we're at the beginning of a line, mark the candidate word (that just contains a space) as non-drawable
|
||||
if self.cursor.pt.x == self.bb.min.x {
|
||||
|
|
|
|||
Loading…
Reference in a new issue