Skip to content

Added font zoom (Alt+Scroll / Ctrl+0) for Terminal and Markdown Preview - #120

Merged
oleg68 merged 4 commits into
nbplugins:mainfrom
oleg68:feature/zoom
May 18, 2026
Merged

oleg68 merged 4 commits into
nbplugins:mainfrom
oleg68:feature/zoom

Conversation

@oleg68

@oleg68 oleg68 commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Adds a per-surface font zoom feature for both the embedded terminal and the Markdown Preview.

Features

  • Alt+Scroll zooms in/out; Ctrl+0 resets — for both the JediTerm terminal and the Markdown Preview.
  • Right-click Zoom submenu (Increase / Decrease / Reset). Spliced into JediTerm's native context menu (which it builds internally and does not expose via setComponentPopupMenu).
  • Zoom level persists per surface via NbPreferences.

Fixes included on this branch

  • Fixed Markdown Preview mouse-wheel scrolling broken by the zoom listener (registering any wheel listener on the JEditorPane disabled the JDK's dispatchMouseWheelToAncestor fallback; non-zoom wheel events are now forwarded to the ancestor JScrollPane).
  • Fixed Ctrl+0 and F5 not working in Markdown Preview: both were bound only in WHEN_IN_FOCUSED_WINDOW, which the NetBeans global keymap pre-empts. They are now also bound in WHEN_FOCUSED (mirroring the existing Ctrl+F fix), so they win while the preview pane is focused.

CHANGELOG

  • Added font zoom (Alt+Scroll) for Terminal and Markdown Preview; Ctrl+0 resets; right-click "Zoom" submenu
  • Fixed F5 not refreshing the Markdown Preview from disk

(Ctrl+0/F5 input-map fixes carry no separate CHANGELOG entry where the surrounding zoom feature is still unreleased; the F5 regression entry is included because Refresh shipped in a published release.)

Tests

  • ZoomSupportTest, MarkdownZoomTest, NetBeansSettingsProviderZoomTest cover the wheel listener, scroll-forwarding regression, zoom menu, and the Ctrl+0 / F5 input-map bindings.
  • Full build green: mvn package → 808 tests, 0 failures, 0 errors.

Manual verification (confirmed)

  • Terminal & Markdown Preview: Alt+Scroll zooms, Ctrl+0 resets.
  • Markdown Preview: plain scroll works; F5 reloads from disk; Ctrl+F Find bar unaffected.

🤖 Generated with Claude Code

oleg68 and others added 4 commits May 18, 2026 00:58
The Zoom submenu was previously registered via JComponent.setComponentPopupMenu().
JediTerm's TerminalPanel builds its right-click menu internally (its own mouse
listener calls the protected createPopupMenu() and fills it from the
TerminalActionProvider chain) and never consults Swing's component popup, so the
Zoom item appeared as a separate single-item menu instead of extending the
native Copy/Paste/Clear menu.

Added ZoomableJediTermWidget, a JediTermWidget subclass whose overridden
createTerminalPanel() returns a TerminalPanel that overrides createPopupMenu():
it builds the native menu via super, then appends a separator and the Zoom
submenu. The append logic is extracted into the unit-tested
ZoomSupport.appendZoomMenu(JPopupMenu, Zoomable). The same subclass exposes
refreshFont(), replacing the reflective TerminalPanel.reinitFontAndResize() call
in ClaudeSessionTab.applyTermZoom().

Documented in CLAUDE.md why JediTerm is used instead of NetBeans' built-in
terminal (no alt-screen buffer / 256-color, no screen-buffer introspection,
non-extensible context menu, no per-instance zoom, friend-only API).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adding any MouseWheelListener to the JEditorPane disabled Swing's native
dispatchMouseWheelToAncestor fallback (gated by eventTypeEnabled(MOUSE_WHEEL)),
so plain wheel events no longer reached the wrapping JScrollPane. The zoom
listener only handled Alt+wheel and dropped the rest.

Added a createWheelListener(Zoomable, boolean forwardToScrollAncestor) overload
that re-dispatches non-zoom wheel events to the nearest ancestor JScrollPane,
replicating the JDK's behavior. Markdown Preview opts in (both openLive and
componentOpened paths); the legacy single-arg method delegates with false so
JediTerm's terminal panel — which scrolls via its own wheel listener — is
unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Ctrl+0 (reset zoom) and F5 (refresh from disk) were registered only in the
JEditorPane's WHEN_IN_FOCUSED_WINDOW input map, which the NetBeans global
keymap pre-empts. Mirroring the earlier Ctrl+F fix, both keystrokes are now
also bound in WHEN_FOCUSED so they win while the preview pane is focused.

ZoomSupport.bindResetKey is shared with the terminal, but the change is inert
there (the TopComponent is never the focus owner and Ctrl+0 is handled via a
KeyEventDispatcher). Added unit tests for both bindings and a CHANGELOG entry
for the F5 regression (Ctrl+0 is part of the still-unreleased zoom feature).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@oleg68
oleg68 merged commit 8433cbd into nbplugins:main May 18, 2026
3 checks passed
@oleg68
oleg68 deleted the feature/zoom branch May 18, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant