From 0ff26b15669da1db877e551798a112c256be2471 Mon Sep 17 00:00:00 2001 From: youpaishidifu <1@ypshidifu.cn> Date: Sat, 21 Nov 2026 21:12:29 +0800 Subject: [PATCH] =?UTF-8?q?125=E7=BB=AD15l-7k=20=E4=BF=AE:=20=E6=88=90?= =?UTF-8?q?=E4=B9=A6=E5=B0=81=E9=A1=B5/=E6=AD=A3=E6=96=87=E9=A1=B5limit?= =?UTF-8?q?=E6=94=BE=E5=AE=BD400+findSemanticCut=E5=AE=B9=E5=B7=AE+20(?= =?UTF-8?q?=E6=A0=B9=E6=B2=BB=E6=8A=95=E7=A5=A8=E8=A7=84=E5=88=99=E8=AF=A6?= =?UTF-8?q?=E8=A7=81=E6=AE=B5=E8=A2=ABi 380) { + if (p.length() > 400) { java.util.List sentences = splitSentences(p); for (String s : sentences) { - if (page.length() + s.length() + 1 > 380 && page.length() > 0) { + if (page.length() + s.length() + 1 > 400 && page.length() > 0) { pages.add(page.toString().trim()); page = new StringBuilder(); } @@ -420,14 +421,14 @@ public class CustomScreenManager implements Listener { } // 当前页已有内容:判断段落是否能整段放入 - if (page.length() + p.length() + 1 <= 380) { + if (page.length() + p.length() + 1 <= 400) { page.append("\n").append(p); continue; } // 整段放不进:在「当前页 + 段落」里找语义边界截断 String candidate = page.toString() + "\n" + p; - int cut = findSemanticCut(candidate, 380); + int cut = findSemanticCut(candidate, 400); // ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段 String firstHalf = candidate.substring(0, cut); String secondHalf = candidate.substring(cut); @@ -438,8 +439,8 @@ public class CustomScreenManager implements Listener { page = new StringBuilder(secondHalf); // 若剩余段仍超页,继续按语义截断或按句拆 - while (page.length() > 380) { - int nextCut = findSemanticCut(page.toString(), 380); + while (page.length() > 400) { + int nextCut = findSemanticCut(page.toString(), 400); String chunk = page.substring(0, nextCut); String remain = page.substring(nextCut); while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1); @@ -460,7 +461,7 @@ public class CustomScreenManager implements Listener { if (pages.size() > 2) { String last = pages.get(pages.size() - 1); String prev = pages.get(pages.size() - 2); - if (last.length() < 20 && (prev.length() + last.length() + 1) <= 380) { + if (last.length() < 20 && (prev.length() + last.length() + 1) <= 400) { pages.set(pages.size() - 2, prev + "\n" + last); pages.remove(pages.size() - 1); } @@ -536,21 +537,22 @@ public class CustomScreenManager implements Listener { * 在 limit 以内找最佳语义截断点(。!?;、行首)。 * ★ 15l-7i 修复:从后往前扫时只接受 i < limit 的句末标点(避免 best 落在 limit 之后 * 导致切点越界、丢内容)。扫不到则退化按逗号/空格,再退化硬切 limit。 + * ★ 15l-7k:句末搜索容差放宽到 limit+20——MC 成书 UI 每屏竖排实际容 ~400+ 字, + * 最近句末(如分号)若落在 limit~limit+20 之间,纳入切点(避免「投票规则详见…;」 + * 被 i= 0; i--) { + int searchEnd = Math.min(s.length() - 1, limit + 20); // ★ 15l-7k 容差 +20 + for (int i = searchEnd; i >= 0; i--) { char c = s.charAt(i); - // 只接受 limit 以内的语义边界(旧 bug:i>=limit 的句末也被设为 best,越界) - if (i < limit) { - if (c == '。' || c == '!' || c == '?' || c == ';' || c == '\n') { - best = i + 1; - break; - } + if (c == '。' || c == '!' || c == '?' || c == ';' || c == '\n') { + best = i + 1; + break; } } - if (best <= 0 || best > limit) { + if (best <= 0 || best > limit + 20) { // 退化:limit 以内找逗号/空格 for (int i = Math.min(s.length() - 1, limit - 1); i >= 0; i--) { char c = s.charAt(i); @@ -560,7 +562,7 @@ public class CustomScreenManager implements Listener { } } } - if (best <= 0 || best > limit) best = limit; + if (best <= 0 || best > limit + 20) best = limit; return best; }