A fork of pulp-os for the xteink4 adding custom apps
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: chapter prefix overflow, leading zero drops

hansmrtn eab9f4c0 9b1f3353

+19 -3
+11 -3
src/apps/home.rs
··· 496 496 let mut cx = BM_MARGIN as i32; 497 497 498 498 if entry.chapter > 0 { 499 - let mut ch_buf = [0u8; 8]; 499 + let mut ch_buf = [0u8; 10]; 500 500 let ch_len = fmt_chapter_prefix(&mut ch_buf, entry.chapter); 501 501 for &b in &ch_buf[..ch_len] { 502 502 cx += font.draw_char_fg(strip, byte_to_char(b), fg, cx, baseline) as i32; ··· 509 509 } 510 510 511 511 // format "Ch{N} " into buf (1-based), return byte count 512 - fn fmt_chapter_prefix(buf: &mut [u8; 8], chapter: u16) -> usize { 513 - let n = chapter + 1; 512 + fn fmt_chapter_prefix(buf: &mut [u8; 10], chapter: u16) -> usize { 513 + let n = chapter.saturating_add(1); 514 514 buf[0] = b'C'; 515 515 buf[1] = b'h'; 516 516 let mut pos = 2; 517 + if n >= 10000 { 518 + buf[pos] = b'0' + ((n / 10000) % 10) as u8; 519 + pos += 1; 520 + } 521 + if n >= 1000 { 522 + buf[pos] = b'0' + ((n / 1000) % 10) as u8; 523 + pos += 1; 524 + } 517 525 if n >= 100 { 518 526 buf[pos] = b'0' + ((n / 100) % 10) as u8; 519 527 pos += 1;
+8
src/apps/widgets/format.rs
··· 34 34 let mut pos = 0; 35 35 36 36 // format current 37 + if current >= 10000 { 38 + buf[pos] = b'0' + ((current / 10000) % 10) as u8; 39 + pos += 1; 40 + } 37 41 if current >= 1000 { 38 42 buf[pos] = b'0' + ((current / 1000) % 10) as u8; 39 43 pos += 1; ··· 53 57 pos += 1; 54 58 55 59 // format total 60 + if total >= 10000 { 61 + buf[pos] = b'0' + ((total / 10000) % 10) as u8; 62 + pos += 1; 63 + } 56 64 if total >= 1000 { 57 65 buf[pos] = b'0' + ((total / 1000) % 10) as u8; 58 66 pos += 1;