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

davsclaus pushed a commit to branch jline
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e50534bb71b95f9ead6e083b2329824e0d4f827d
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Dec 10 18:05:27 2025 +0100

    camel-jbang - camel get history use jline to make it mode better
---
 .../core/commands/action/CamelHistoryAction.java   | 24 +++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelHistoryAction.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelHistoryAction.java
index 4947f002551e..c4606c755304 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelHistoryAction.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelHistoryAction.java
@@ -318,6 +318,8 @@ public class CamelHistoryAction extends ActionWatchCommand {
         var select = AttributedStyle.DEFAULT
                 .background(AttributedStyle.YELLOW)
                 .bold();
+        var faint = AttributedStyle.DEFAULT.faint();
+        var faint_u = AttributedStyle.DEFAULT.faint().underline();
 
         int maxLength = 0;
         String[] lines = table.split(System.lineSeparator());
@@ -327,10 +329,30 @@ public class CamelHistoryAction extends 
ActionWatchCommand {
         }
 
         answer.add(new AttributedString(lines[0])); // header
+
+        List<AttributedString> pending = new ArrayList<>();
         for (int i = 1; i < lines.length; i++) {
+            int j = i - 1;
             String line = lines[i];
-            answer.add(new AttributedString(line, i == pos + 1 ? select : 
normal));
+            AttributedStyle style;
+            if (j < pos) {
+                style = normal;
+            } else if (j == pos) {
+                style = select;
+            } else {
+                style = normal;
+//                style = faint;
+            }
+            pending.add(new AttributedString(line, style));
         }
+        if (rows.size() <= 10) {
+            answer.addAll(pending);
+        } else if (pos < 10) {
+            answer.addAll(pending.subList(0, 10));
+        } else {
+            answer.addAll(pending.subList(pos - 9, pos + 1));
+        }
+
         String help = String.format("  select:%d/%d   q=quit   f5=refresh    
(arrow up/down   page up/down   home/end)", pos + 1, rows.size());
         String pad = StringHelper.padString(maxLength - help.length(), 1);
         answer.add(new AttributedString(help + pad, AttributedStyle.INVERSE));

Reply via email to