This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-23512-fix-tui-tamboui-api in repository https://gitbox.apache.org/repos/asf/camel.git
commit 727e4168a388f97ea03d50919cc5022e2a94298e Author: Claus Ibsen <[email protected]> AuthorDate: Wed May 13 22:58:43 2026 +0200 CAMEL-23512: Use Paragraph scroll and word wrap for catalog description Replace manual line slicing and custom wrapText() method with Paragraph's built-in scroll() and Overflow.WRAP_WORD support. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --- .../jbang/core/commands/tui/CamelCatalogTui.java | 51 ++++------------------ 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelCatalogTui.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelCatalogTui.java index 7b5c9c0b9b34..7e8aef4c3b3b 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelCatalogTui.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelCatalogTui.java @@ -577,7 +577,9 @@ public class CamelCatalogTui extends CamelCommand { flowFields(lines, fields, wrapWidth, opt); lines.add(Line.from(Span.raw(""))); - wrapText(lines, opt.description, wrapWidth, Style.EMPTY); + if (opt.description != null && !opt.description.isEmpty()) { + lines.add(Line.from(Span.raw(" " + opt.description))); + } } else { title = " Description "; } @@ -602,32 +604,19 @@ public class CamelCatalogTui extends CamelCommand { flowFields(lines, fields, wrapWidth, null); lines.add(Line.from(Span.raw(""))); - wrapText(lines, comp.description, wrapWidth, Style.EMPTY); + if (comp.description != null && !comp.description.isEmpty()) { + lines.add(Line.from(Span.raw(" " + comp.description))); + } } else { title = " Description "; } } - // Apply scroll - int innerHeight = Math.max(1, area.height() - 2); - int maxScroll = Math.max(0, lines.size() - innerHeight); - if (descriptionScroll > maxScroll) { - descriptionScroll = maxScroll; - } - List<Line> visible; - if (descriptionScroll > 0) { - int end = Math.min(descriptionScroll + innerHeight, lines.size()); - visible = lines.subList(descriptionScroll, end); - } else if (lines.size() > innerHeight) { - visible = lines.subList(0, innerHeight); - } else { - visible = lines; - } - frame.renderWidget( Paragraph.builder() - .text(Text.from(visible)) - .overflow(Overflow.CLIP) + .text(Text.from(lines)) + .overflow(Overflow.WRAP_WORD) + .scroll(descriptionScroll) .block(Block.builder() .borderType(BorderType.ROUNDED) .title(title) @@ -721,28 +710,6 @@ public class CamelCatalogTui extends CamelCommand { } } - private static void wrapText(List<Line> lines, String text, int width, Style style) { - if (text == null || text.isEmpty()) { - return; - } - int pos = 0; - while (pos < text.length()) { - String remaining = text.substring(pos); - int remainingWidth = CharWidth.of(remaining); - if (remainingWidth <= width) { - lines.add(Line.from(Span.styled(" " + remaining.trim(), style))); - break; - } - String chunk = CharWidth.substringByWidth(remaining, width); - int lastSpace = chunk.lastIndexOf(' '); - if (lastSpace > 0) { - chunk = chunk.substring(0, lastSpace + 1); - } - lines.add(Line.from(Span.styled(" " + chunk.trim(), style))); - pos += chunk.length(); - } - } - // ---- Data Classes ---- static class ComponentInfo {
