This commit is contained in:
@@ -416,19 +416,19 @@ public class CustomScreenManager implements Listener {
|
|||||||
|
|
||||||
// 当前页为空:直接开始新段落
|
// 当前页为空:直接开始新段落
|
||||||
if (page.length() == 0) {
|
if (page.length() == 0) {
|
||||||
if (p.length() > 85) {
|
if (p.length() > 100) {
|
||||||
java.util.List<String> sentences = splitSentences(p);
|
java.util.List<String> sentences = splitSentences(p);
|
||||||
for (String s : sentences) {
|
for (String s : sentences) {
|
||||||
// ★ 15m:单句本身超 85(长句无句末可拆)→ 硬切 85,残句进下一页
|
// ★ 15m:单句本身超 85(长句无句末可拆)→ 硬切 85,残句进下一页
|
||||||
while (s.length() > 85) {
|
while (s.length() > 100) {
|
||||||
if (page.length() + 85 + 1 > 85 && page.length() > 0) {
|
if (page.length() + 100 + 1 > 100 && page.length() > 0) {
|
||||||
pages.add(page.toString().trim());
|
pages.add(page.toString().trim());
|
||||||
page = new StringBuilder();
|
page = new StringBuilder();
|
||||||
}
|
}
|
||||||
page.append(s.substring(0, 85));
|
page.append(s.substring(0, 100));
|
||||||
s = s.substring(85);
|
s = s.substring(100);
|
||||||
}
|
}
|
||||||
if (page.length() + s.length() + 1 > 85 && page.length() > 0) {
|
if (page.length() + s.length() + 1 > 100 && page.length() > 0) {
|
||||||
pages.add(page.toString().trim());
|
pages.add(page.toString().trim());
|
||||||
page = new StringBuilder();
|
page = new StringBuilder();
|
||||||
}
|
}
|
||||||
@@ -441,14 +441,14 @@ public class CustomScreenManager implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 当前页已有内容:判断段落是否能整段放入
|
// 当前页已有内容:判断段落是否能整段放入
|
||||||
if (page.length() + p.length() + 1 <= 85) {
|
if (page.length() + p.length() + 1 <= 100) {
|
||||||
page.append("\n").append(p);
|
page.append("\n").append(p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 整段放不进:在「当前页 + 段落」里找语义边界截断
|
// 整段放不进:在「当前页 + 段落」里找语义边界截断
|
||||||
String candidate = page.toString() + "\n" + p;
|
String candidate = page.toString() + "\n" + p;
|
||||||
int cut = findSemanticCut(candidate, 85);
|
int cut = findSemanticCut(candidate, 100);
|
||||||
// ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段
|
// ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段
|
||||||
String firstHalf = candidate.substring(0, cut);
|
String firstHalf = candidate.substring(0, cut);
|
||||||
String secondHalf = candidate.substring(cut);
|
String secondHalf = candidate.substring(cut);
|
||||||
@@ -459,8 +459,8 @@ public class CustomScreenManager implements Listener {
|
|||||||
page = new StringBuilder(secondHalf);
|
page = new StringBuilder(secondHalf);
|
||||||
|
|
||||||
// 若剩余段仍超页,继续按语义截断或按句拆
|
// 若剩余段仍超页,继续按语义截断或按句拆
|
||||||
while (page.length() > 85) {
|
while (page.length() > 100) {
|
||||||
int nextCut = findSemanticCut(page.toString(), 85);
|
int nextCut = findSemanticCut(page.toString(), 100);
|
||||||
String chunk = page.substring(0, nextCut);
|
String chunk = page.substring(0, nextCut);
|
||||||
String remain = page.substring(nextCut);
|
String remain = page.substring(nextCut);
|
||||||
while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1);
|
while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1);
|
||||||
@@ -481,7 +481,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
if (pages.size() > 2) {
|
if (pages.size() > 2) {
|
||||||
String last = pages.get(pages.size() - 1);
|
String last = pages.get(pages.size() - 1);
|
||||||
String prev = pages.get(pages.size() - 2);
|
String prev = pages.get(pages.size() - 2);
|
||||||
if (last.length() < 20 && (prev.length() + last.length() + 1) <= 85) {
|
if (last.length() < 20 && (prev.length() + last.length() + 1) <= 100) {
|
||||||
pages.set(pages.size() - 2, prev + "\n" + last);
|
pages.set(pages.size() - 2, prev + "\n" + last);
|
||||||
pages.remove(pages.size() - 1);
|
pages.remove(pages.size() - 1);
|
||||||
}
|
}
|
||||||
@@ -491,7 +491,7 @@ public class CustomScreenManager implements Listener {
|
|||||||
for (int pi = 1; pi + 1 < pages.size(); pi++) {
|
for (int pi = 1; pi + 1 < pages.size(); pi++) {
|
||||||
String cur = pages.get(pi);
|
String cur = pages.get(pi);
|
||||||
String nxt = pages.get(pi + 1);
|
String nxt = pages.get(pi + 1);
|
||||||
if (cur.length() < 50 && (cur.length() + nxt.length() + 1) <= 130) {
|
if (cur.length() < 50 && (cur.length() + nxt.length() + 1) <= 150) {
|
||||||
pages.set(pi + 1, cur + "\n" + nxt);
|
pages.set(pi + 1, cur + "\n" + nxt);
|
||||||
pages.remove(pi);
|
pages.remove(pi);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user