Skip to content

Add code editing features to the scripting terminal - #79

Closed
rubensworks wants to merge 23 commits into
terminal-ux/2-undo-and-syncfrom
terminal-ux/3-editing-features
Closed

rubensworks wants to merge 23 commits into
terminal-ux/2-undo-and-syncfrom
terminal-ux/3-editing-features

Conversation

@rubensworks

@rubensworks rubensworks commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Phase 3 of the scripting terminal UX improvements, stacked on #78 (which is stacked on #77). One commit per feature.

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 finds text and Ctrl+G goes to a line number.
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 scrolls while you drag (19 lines selected, view moved to row 7).
Close the find field when the scripting terminal is resized After a resize with the find field open, the field was gone but still received key presses. Checked: after a resize, typing goes to the editor.
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.
Show find and go to line in a search bar below the editor The first version's find field floated over the top right of the code. It covered a match on line 1, had no label and no match count, and gave no feedback when nothing matched. A search bar below the editor, which takes the space of the bottom row. It shows a Find: or Line: label, the current match and total (2/29), and previous/next buttons (also Shift+Enter / Enter). All matches are highlighted, and the input turns red when nothing matches (0/0) 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 with the bar open, the editor regaining its full height when closed, and the bar closing on resize.
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.
Don't let a long terminal title overlap the toolbar With the toolbar, longer translations of the title (for example pt_br) ran under the buttons. The title is cut off before the toolbar.
Remove the keyboard shortcuts button from the editor toolbar A separate help button that only listed all shortcuts mostly repeated the other buttons' tooltips. Removed, along with its icon.
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: all defaults work; 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, search bar keys).
Use an ellipsis character when truncating the terminal title Truncation used three dots. Uses …, which is narrower.
Keep scrolling while a drag selection is held outside the editor Scrolling only happened once per mouse movement beyond the editor, so holding the mouse still below the last line stopped scrolling, and the speed depended on how fast the mouse moved. Scrolls every tick while held, from about 5 lines per second right below the last line to about 50 further away, in both directions. Starts as soon as the mouse is below the last visible line, and stops on release (checked: no further scrolling 2 seconds after release). Also checked in focus mode.
Document word and line navigation keys in the info book The word and line keys from #77 were not listed. Added to the fixed keys paragraph, including the macOS variants.

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

Known issues

  • With the current CyclopsCore, the keybinding appendix shows letter keys as key.keyboard.z and leaves out the modifier. This is fixed in Show the bound key in key binding appendices CyclopsCore#255; I checked this section against that branch, and it shows CTRL + Z, ALT + Up Arrow and so on. Bumping cyclopscore_version after that is released makes it show correctly here.
  • 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 38 unit tests, covering both indent sizes and the search helpers.

Testing

  • ./gradlew build passes, including the new unit tests.
  • ./gradlew runGameTestServer: all 22 tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9

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. Add ctrl+f to find text (enter jumps to the next match) and
ctrl+g to go to a line number, for example one from an error message.

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. Scroll the editor while dragging beyond its edges.

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

coveralls commented Oct 17, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39131775591

Coverage decreased (-2.3%) to 44.119%

Details

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

Uncovered Changes

No uncovered changes found.

Coverage Regressions

579 previously-covered lines in 6 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 246 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/inventory/container/ContainerTerminalScripting.java 5 23.75%
org/cyclops/integratedscripting/client/gui/component/input/TextHistory.java 2 86.54%

Coverage Stats

Coverage Status
Relevant Lines: 3253
Covered Lines: 1562
Line Coverage: 48.02%
Relevant Branches: 1287
Covered Branches: 441
Branch Coverage: 34.27%
Branches in Coverage %: Yes
Coverage Strength: 22.68 hits per line

💛 - Coveralls

…-features

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
Resizing removes all widgets, so an open find field kept receiving key
presses without being visible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
claude added 10 commits October 18, 2026 04:55
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
…-features

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
The find field appeared floating over the top right of the code, covering
it, without a label, without showing how many matches there are, and
without any feedback when nothing matched.

Show a search bar below the editor instead, which takes the space of the
bottom row. It shows a label, the current match and number of matches,
buttons for the previous and next match (also shift+enter and enter),
highlights all matches, and turns red when nothing is found or the line
number is invalid. Escape closes it before closing the screen.

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, whose tooltips also show their shortcut,
and a button whose tooltip lists all shortcuts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
Translations of the terminal title, such as "Terminal de Scripting", are
wider than the space left of the new toolbar. Shorten the title with an
ellipsis when it doesn't fit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
Each toolbar button already shows its shortcut in its tooltip, so a
separate button that only lists all shortcuts mostly repeats them.

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
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
This is narrower than three dots, so more of the title fits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
The editor only scrolled one line per mouse movement beyond its top or
bottom, so holding the mouse still stopped the scrolling, and the speed
depended on how fast the mouse moved. It now scrolls every tick while the
selection is held outside the editor, 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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9

Copy link
Copy Markdown
Member Author

Replaced by #86: same changes, rebased with every commit as one standalone change.


Generated by Claude Code

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