Skip to content

Add code editing features to the scripting terminal - #86

Merged
rubensworks merged 10 commits into
master-1.21-ltsfrom
terminal-ux-clean/3-editing-features
Oct 18, 2026
Merged

rubensworks merged 10 commits into
master-1.21-ltsfrom
terminal-ux-clean/3-editing-features

Conversation

@rubensworks

Copy link
Copy Markdown
Member

Replaces #79, with the same changes and a clean commit history: every commit is one standalone change. Phase 3 of the scripting terminal UX improvements, stacked on #85.

I checked each problem on the previous phase's build in a dev client driven by clientdevbridge, then checked the feature with this branch.

Commit Problem before Result with this PR
Indent with tab in the script editor Tab inserted nothing. Tab inserts one indent, or indents every selected line; Shift+Tab removes one level.
Keep indentation on enter in the script editor Enter after an indented line put the cursor in column 0. The new line keeps the indentation, gets one more level after {, ( or [, and {} is split so the closing bracket gets its own line.
Highlight matching brackets in the script editor Hard to see which bracket closes which block. The bracket next to the cursor and its match are highlighted.
Add find and go to line to the script editor No way to search; you had to scroll. Ctrl+F opens a search bar below the editor to find text, and Ctrl+G opens it to go to a line number. It shows the current match and total (2/29), has previous/next buttons (also Shift+Enter / Enter), highlights all matches, and turns red when nothing matches or the line number is invalid. Escape closes the bar before it closes the screen. Checked in-game: wrap-around in both directions with the view following, the count updating while editing, the editor regaining its full height when closed, and the bar closing on resize.
Add toggle comment and move lines to the script editor Commenting out or moving lines meant editing each line by hand. Ctrl+/ toggles // on the current or selected lines; Alt+Up/Down moves them. Both are undoable.
Scroll the script editor while drag-selecting Dragging below the editor stopped at the 12 visible lines. The editor keeps scrolling while a selection is held above or below it, from about 5 lines per second right below the last line to about 50 further away, also when the mouse is held still. It stops on release (checked: no further scrolling 2 seconds after release), and works in both directions.
Make the indent size of the script editor configurable The indent was a fixed 4 spaces, which is wide in the small editor and doesn't match every code style. New client option terminalScriptingIndentSize (1–16), default 2, the common JavaScript style. Checked in-game: Tab and Enter-after-{ use 2 spaces; after changing the config file to 4, Tab added 4 without restarting the game.
Add toolbar buttons for editor actions All of the above were only reachable through keyboard shortcuts, which players have no way to discover. Small icon buttons next to the terminal title: undo, redo, find, go to line and toggle comment. Each tooltip shows the action and its shortcut. Undo/redo are dimmed and inactive when there is nothing to undo or redo. Longer translations of the title (for example pt_br) are cut off with … before the toolbar.
Make the script editor shortcuts rebindable The shortcuts were hardcoded, so players couldn't change them, for example when they clash with another mod. Undo, redo, find, go to line, toggle comment and move lines up/down are key mappings under "Integrated Scripting" in Controls, and the tooltips show the current key. Modifiers must match exactly, so Ctrl+Shift+Z doesn't trigger Ctrl+Z (5 unit tests). Ctrl+Shift+Z stays as a fixed extra redo key, since a key mapping can only have one modifier. Checked in-game: after rebinding Find in the Controls screen, the tooltip shows the new key, the new key opens find, and Ctrl+F no longer does.
Document the script editor shortcuts in the info book The shortcuts were only discoverable through tooltips. New "Editor Shortcuts" section after "Scripting Terminal", with a keybinding appendix per rebindable shortcut, and a paragraph for the fixed keys (Tab, Page Up/Down, word and line navigation including the macOS variants, search bar keys).

I left out duplicate-line, which was in the original plan: copy/paste already covers it.

Known issues

  • The keybinding appendix only shows readable keys (CTRL + Z instead of key.keyboard.z) once Integrated Scripting depends on a CyclopsCore release with Show the bound key in key binding appendices CyclopsCore#255, which is merged.
  • NeoForge's Controls screen marks Toggle comment (Ctrl+/) red, because it counts it as a conflict with vanilla's universal "Open Command" key (/). There is no actual clash at runtime, since our keys are only checked inside the terminal.

All text logic is in a new TextEditing class with unit tests, covering both indent sizes and the search helpers.

Testing

  • Every commit compiles on its own, including tests and Spotless.
  • ./gradlew build passes, including the new unit tests.
  • ./gradlew runGameTestServer: all 23 tests pass.

Generated by Claude Code

Tab did nothing in the editor, so indenting code meant typing spaces one
by one. Make tab insert an indent, or indent all selected lines, and
shift+tab remove one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
A new line always started at the first column, so the indentation had to
be retyped on every line. Keep the indentation of the current line, and
indent one more level after an opening bracket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
In the small editor it was hard to see which bracket closes which block.
Highlight the bracket next to the cursor and its matching bracket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
Finding something in a script meant scrolling through it in the small
editor. Ctrl+F opens a search bar below the editor to find text, and
Ctrl+G opens it to go to a line number, for example one from an error
message. The bar shows the current match and the number of matches, has
previous and next buttons (also Shift+Enter and Enter), highlights all
matches, and turns red when nothing matches. Escape closes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
Commenting out or reordering multiple lines meant editing every line by
hand. Add ctrl+/ to toggle line comments and alt+up/down to move the
current or selected lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
Dragging a selection beyond the top or bottom of the editor stopped at
the visible lines, so a selection could not be larger than the viewport.
The editor now keeps scrolling while a selection is held above or below
it, faster the further away the mouse is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
Tab inserted a fixed 4 spaces, which is wide in the small editor, and
doesn't match every code style. Add a client option for the number of
spaces, defaulting to 2, which is common for JavaScript.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
The editor actions were only available through keyboard shortcuts, which
players can't discover in-game. Add small buttons for undo, redo, find,
go to line and toggle comment next to the terminal title, whose tooltips
also show their shortcut. Long translations of the title are shortened
so they don't run under the buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
The shortcuts for undo, redo, find, go to line, toggle comment and moving
lines were hardcoded. They are now key mappings that can be changed in the
Controls settings, and the toolbar tooltips show the current key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
@coveralls

coveralls commented Oct 18, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39152697881

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage decreased (-2.3%) to 45.27%

Details

  • Coverage decreased (-2.3%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 586 coverage regressions across 5 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

586 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
org/cyclops/integratedscripting/client/gui/component/input/WidgetTextArea.java 315 0.0%
org/cyclops/integratedscripting/client/gui/container/ContainerScreenTerminalScripting.java 258 0.0%
org/cyclops/integratedscripting/proxy/ClientProxy.java 6 0.0%
org/cyclops/integratedscripting/client/gui/image/ScriptImages.java 5 0.0%
org/cyclops/integratedscripting/client/gui/component/input/TextHistory.java 2 86.54%

Coverage Stats

Coverage Status
Relevant Lines: 3306
Covered Lines: 1624
Line Coverage: 49.12%
Relevant Branches: 1313
Covered Branches: 467
Branch Coverage: 35.57%
Branches in Coverage %: Yes
Coverage Strength: 23.85 hits per line

💛 - Coveralls

Base automatically changed from terminal-ux-clean/2-undo-and-sync to master-1.21-lts October 18, 2026 17:46
Comment thread src/main/resources/assets/integratedscripting/lang/en_us.json Outdated
The shortcuts were only discoverable through the toolbar tooltips. A new
info book section lists them with the keybinding appendix, so it shows
the keys as currently bound, plus the keys that can not be changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
@rubensworks
rubensworks force-pushed the terminal-ux-clean/3-editing-features branch from fa706d0 to bf7170f Compare October 18, 2026 18:07
@rubensworks
rubensworks merged commit 51d352b into master-1.21-lts Oct 18, 2026
31 checks passed
@rubensworks
rubensworks deleted the terminal-ux-clean/3-editing-features branch October 18, 2026 18:12
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.

3 participants