This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch worktree-happy-tickling-stream
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1fa7a48983c41d126f7ad9211c098aa5f34c00d6
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jun 5 22:08:40 2026 +0200

    CAMEL-23672: TUI - Improve source view highlight readability
    
    Change selected line background from dark gray to dark navy blue for
    better contrast with red syntax tokens. Extend the highlight to fill
    the full viewport width so the selection bar doesn't stop at end of text.
    
    Co-Authored-By: Claude <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../dsl/jbang/core/commands/tui/SourceViewer.java  | 48 +++++++++++++---------
 1 file changed, 29 insertions(+), 19 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java
index 21e502932ca3..dd22626eba87 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java
@@ -196,7 +196,7 @@ class SourceViewer {
         for (int i = scrollY; i < end; i++) {
             String raw = lines.get(i);
             boolean isSelected = (i == selectedLine);
-            visible.add(highlightSourceLine(raw, scrollX, isSelected));
+            visible.add(highlightSourceLine(raw, scrollX, isSelected, 
inner.width()));
         }
         
frame.renderWidget(Paragraph.builder().text(Text.from(visible)).build(), inner);
 
@@ -406,7 +406,7 @@ class SourceViewer {
         });
     }
 
-    private Line highlightSourceLine(String raw, int hSkip, boolean 
isSelected) {
+    private Line highlightSourceLine(String raw, int hSkip, boolean 
isSelected, int viewportWidth) {
         int prefixEnd = 0;
         while (prefixEnd < raw.length() && (raw.charAt(prefixEnd) == ' ' || 
Character.isDigit(raw.charAt(prefixEnd)))) {
             prefixEnd++;
@@ -418,11 +418,11 @@ class SourceViewer {
         Line highlighted = SyntaxHighlighter.highlightLine(code, language);
 
         List<Span> spans = new ArrayList<>();
-        Style selBg = Style.EMPTY.bg(Color.DARK_GRAY);
+        Style selBg = Style.EMPTY.bg(Color.rgb(30, 45, 70));
         if (isSelected) {
             spans.add(Span.styled(">> ", Style.EMPTY.fg(Color.YELLOW).bold()));
             if (!prefix.isEmpty()) {
-                spans.add(Span.styled(prefix, 
Style.EMPTY.fg(Color.YELLOW).bold().bg(Color.DARK_GRAY)));
+                spans.add(Span.styled(prefix, 
Style.EMPTY.fg(Color.YELLOW).bold().patch(selBg)));
             }
             for (Span s : highlighted.spans()) {
                 spans.add(Span.styled(s.content(), s.style().patch(selBg)));
@@ -437,24 +437,34 @@ class SourceViewer {
 
         Line full = Line.from(spans);
 
-        if (hSkip <= 0) {
-            return full;
+        if (hSkip > 0) {
+            List<Span> scrolled = new ArrayList<>();
+            int skipped = 0;
+            for (Span span : full.spans()) {
+                String content = span.content();
+                if (skipped >= hSkip) {
+                    scrolled.add(span);
+                } else if (skipped + content.length() > hSkip) {
+                    int offset = hSkip - skipped;
+                    scrolled.add(Span.styled(content.substring(offset), 
span.style()));
+                    skipped = hSkip;
+                } else {
+                    skipped += content.length();
+                }
+            }
+            full = scrolled.isEmpty() ? Line.from(List.of(Span.raw(""))) : 
Line.from(scrolled);
         }
-        List<Span> scrolled = new ArrayList<>();
-        int skipped = 0;
-        for (Span span : full.spans()) {
-            String content = span.content();
-            if (skipped >= hSkip) {
-                scrolled.add(span);
-            } else if (skipped + content.length() > hSkip) {
-                int offset = hSkip - skipped;
-                scrolled.add(Span.styled(content.substring(offset), 
span.style()));
-                skipped = hSkip;
-            } else {
-                skipped += content.length();
+
+        if (isSelected && viewportWidth > 0) {
+            int contentWidth = full.width();
+            if (contentWidth < viewportWidth) {
+                List<Span> padded = new ArrayList<>(full.spans());
+                padded.add(Span.styled(" ".repeat(viewportWidth - 
contentWidth), selBg));
+                full = Line.from(padded);
             }
         }
-        return scrolled.isEmpty() ? Line.from(List.of(Span.raw(""))) : 
Line.from(scrolled);
+
+        return full;
     }
 
     static int findLicenseHeaderEnd(List<JsonObject> codeLines) {

Reply via email to