gnodet commented on code in PR #24328:
URL: https://github.com/apache/camel/pull/24328#discussion_r3497287502


##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ShellPanel.java:
##########
@@ -269,17 +283,46 @@ void render(Frame frame, Rect area) {
             lines = renderLiveView(screen, innerWidth, innerHeight);
         }
 
+        // Split the inner area: content (fill) + scrollbar (1 col) when 
history exists
+        int totalLines = histSize + innerHeight;
+        boolean showScrollbar = totalLines > innerHeight;
+        Rect contentArea;
+        if (showScrollbar) {
+            List<Rect> hChunks = Layout.horizontal()
+                    .constraints(Constraint.fill(), Constraint.length(1))
+                    .split(inner);
+            contentArea = hChunks.get(0);
+
+            // Map scrollOffset (lines-from-bottom) to top-down position for 
ScrollbarState
+            int viewStart = Math.max(0, totalLines - scrollOffset - 
innerHeight);
+            scrollbarState
+                    .contentLength(totalLines)
+                    .viewportContentLength(innerHeight)
+                    .position(viewStart);
+            frame.renderStatefulWidget(Scrollbar.builder().build(), 
hChunks.get(1), scrollbarState);
+        } else {
+            contentArea = inner;
+        }
+
         frame.renderWidget(
                 Paragraph.builder()
                         .text(Text.from(lines))
                         .overflow(Overflow.CLIP)
                         .build(),
-                inner);
+                contentArea);
+
+        // Set the real terminal cursor position so it blinks at the shell 
prompt.
+        // Only show the cursor in live view (not scrolled back) and when the 
shell is focused.
+        if (scrollOffset == 0 && cursor[1] >= 0 && cursor[1] < innerHeight
+                && cursor[0] >= 0 && cursor[0] < innerWidth) {
+            frame.setCursorPosition(contentArea.x() + cursor[0], 
contentArea.y() + cursor[1]);
+        }
     }
 
     void renderFooter(List<Span> spans) {
         MonitorContext.hint(spans, "F6", "close");
-        MonitorContext.hint(spans, "Shift+F6", SPLIT_PERCENTS[splitIndex] + 
"%");
+        int nextIndex = (splitIndex + 1) % SPLIT_PERCENTS.length;
+        MonitorContext.hint(spans, "Shift+F6", SPLIT_PERCENTS[nextIndex] + 
"%");

Review Comment:
   Fixed — reverted to show the current percentage (`splitIndex`). Good point 
that it matches the zoom-indicator pattern. Also added tests that verify 
`renderFooter()` shows the correct percentage before and after `cycleHeight()`.
   
   _Claude Code on behalf of Guillaume Nodet_



##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ShellPanel.java:
##########
@@ -616,14 +653,37 @@ static byte[] encodeKeyEvent(KeyEvent ke) {
         };
     }
 
+    // TODO: ScreenTerminal.history is private with no public accessor in 
JLine 4.2.1.
+    //       File a JLine issue to add getHistory()/getHistorySize() public 
methods,
+    //       then replace this reflection with direct calls.
+    //       See: https://github.com/jline/jline3/issues/1266
+    private static final Field HISTORY_FIELD;
+    private static final AtomicBoolean HISTORY_WARN_LOGGED = new 
AtomicBoolean(false);
+
+    static {
+        Field f = null;
+        try {
+            f = ScreenTerminal.class.getDeclaredField("history");
+            f.setAccessible(true);
+        } catch (NoSuchFieldException e) {
+            System.err.println("[ShellPanel] ScreenTerminal.history field not 
found — "
+                               + "scrollback will be unavailable. JLine API 
may have changed.");
+        }
+        HISTORY_FIELD = f;

Review Comment:
   Good catch — replaced both `System.err.println` calls with 
`LOG.log(Level.WARNING, ...)` for consistency with the rest of the file.
   
   Regarding alignment with PR #24322 (`org.slf4j.Logger` vs 
`java.lang.System.Logger`): since `System.Logger` is zero-dependency and SLF4J 
is not currently a dependency of this module, we went with the platform logger. 
Happy to align whichever direction the project prefers when both PRs merge.
   
   _Claude Code on behalf of Guillaume Nodet_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to