Skip to content

Highlight selected atoms in the XYZ text editor#31

Merged
dnkats merged 1 commit into
mainfrom
feature/highlight-selected-atoms-in-editor
Jun 2, 2026
Merged

Highlight selected atoms in the XYZ text editor#31
dnkats merged 1 commit into
mainfrom
feature/highlight-selected-atoms-in-editor

Conversation

@dnkats

@dnkats dnkats commented Jun 2, 2026

Copy link
Copy Markdown
Member

Summary

Makes it easy to find and modify selected atoms while editing coordinates: in the XYZ editor's text edit mode, the lines belonging to currently selected atoms are now highlighted.

Previously the row-based selection mode highlighted selected atoms, but switching to edit mode (the textarea) cleared the selection and gave no visual cue about which lines to change.

How it works

  • A highlight overlay (#xyz-edit-backdrop / #xyz-edit-highlights) sits behind a transparent-background textarea. Both share identical font/padding/line metrics so the tint lines up exactly with the text. Atom i (0-based) maps to text line i + 2 (line 0 = count, line 1 = comment).
  • Entering edit mode no longer clears the selection.
  • The overlay updates live on textarea input/scroll and whenever the selection changes (e.g. picking an atom in the 3D structure while edit mode is open).

Files

  • index.html — wrap the textarea with the backdrop/highlights layer.
  • css/styles.css — coordinated metrics for textarea + overlay; soft-yellow line tint.
  • js/xyz-editor.jsrenderXYZEditHighlights() / initXYZEditHighlights(); toggle the wrapper and keep selection on entering edit mode.
  • js/selection.js — refresh the overlay from selection changes when edit mode is visible.

Testing

Verified the overlay alignment and line mapping by rendering the real CSS + render logic in headless Chromium: selecting atoms 1, 3, 4 tints exactly those rows, pixel-aligned with the textarea text.

🤖 Generated with Claude Code

When editing coordinates in the XYZ editor's text mode, the lines
belonging to currently selected atoms are now tinted via a highlight
overlay behind the textarea, so it's easy to find and modify them.
Entering edit mode no longer clears the selection, and selecting an
atom (in 3D or the row view) updates the overlay live.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 2, 2026 07:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds line-level highlighting in the XYZ editor's text edit mode so users can visually identify which textarea rows correspond to currently selected atoms. A transparent textarea is layered over a backdrop that renders the same text with tinted spans on selected lines; scroll and input events keep the two synchronized, and toggling into edit mode no longer clears the selection.

Changes:

  • Wrap the XYZ edit textarea in a backdrop/highlights overlay and add matching CSS metrics so text and tint align pixel-perfectly.
  • Add renderXYZEditHighlights() / initXYZEditHighlights() and stop clearing the selection on entering edit mode.
  • Refresh the overlay from updateSelectionUI() whenever edit mode is visible.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
index.html Wrap textarea with #xyz-edit-wrap containing backdrop/highlights layers.
css/styles.css Shared font/padding/line metrics for textarea + backdrop; soft-yellow line tint and transparent textarea background.
js/xyz-editor.js New highlight render/init functions; toggle wrap visibility; preserve selection on entering edit mode.
js/selection.js New refreshEditHighlightsIfVisible() invoked from updateSelectionUI().

@dnkats dnkats merged commit 274d252 into main Jun 2, 2026
1 check passed
@dnkats dnkats deleted the feature/highlight-selected-atoms-in-editor branch June 2, 2026 07:17
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.

2 participants