Repository navigation
Keep the editor's code clear of Jim's stage #791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,6 +324,9 @@ const JIM_SELF_VIEW_WIDTH_PX = 120; | |
|
|
||
| /// In px, between the editor toolbar's bottom and the top of Jim's stage. | ||
| const JIM_STAGE_TOOLBAR_GAP_PX = 6; | ||
| /// In px, between the end of the editor's text and the floating stage, so the | ||
| /// last glyph never ends flush against it or a fraction under it. | ||
| const JIM_STAGE_EDITOR_GAP_PX = 6; | ||
|
|
||
| // From /runtime-config.js, which is the only thing allowed to name what the | ||
| // server does. A literal here would be a second answer to "does this server | ||
|
|
@@ -5857,14 +5860,44 @@ function placeJimStageBelowToolbar(toolbar) { | |
| "scrollable", | ||
| stage.top < 0 || stage.bottom > window.innerHeight, | ||
| ); | ||
| reserveJimStageInEditor(stage); | ||
| }; | ||
| const observer = new window.ResizeObserver(place); | ||
| observer.observe(toolbar); | ||
| observer.observe(nodes.jimStage); | ||
| // The test drawer's splitter moves the editor's bottom under the card. | ||
| if (nodes.editorStack.isConnected) observer.observe(nodes.editorStack); | ||
| window.addEventListener("resize", place); | ||
| place(); | ||
| } | ||
|
|
||
| /// Tells the editor how much of it Jim's stage covers, so the end of a long | ||
| /// line and the caret never scroll under it: the right edge beside the floating | ||
| /// stage, the bottom under the compact card. A whiteboard has no editor, and an | ||
| /// editor running past the window scrolls with the page, which already brings | ||
| /// any row out from under the fixed card. | ||
| function reserveJimStageInEditor(stage) { | ||
| const stack = nodes.editorStack; | ||
| if (!stack.isConnected) return; | ||
| const editor = stack.getBoundingClientRect(); | ||
| const covers = | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The reservation is computed from viewport positions, but it only refreshes on resize, not on scroll. When the editor panel or page scrolls, Prompt for AI agents |
||
| editor.top >= 0 && | ||
| editor.bottom <= window.innerHeight && | ||
| stage.width > 0 && | ||
| stage.left < editor.right && | ||
| stage.right > editor.left && | ||
| stage.top < editor.bottom && | ||
| stage.bottom > editor.top; | ||
| const compact = nodes.jimStage.classList.contains("compact"); | ||
| const right = | ||
| covers && !compact | ||
| ? Math.ceil(editor.right - stage.left) + JIM_STAGE_EDITOR_GAP_PX | ||
| : 0; | ||
| const bottom = covers && compact ? Math.ceil(editor.bottom - stage.top) : 0; | ||
| stack.style.setProperty("--jim-stage-reserve-right", `${right}px`); | ||
| stack.style.setProperty("--jim-stage-reserve-bottom", `${bottom}px`); | ||
| } | ||
|
|
||
| function editorFontSize() { | ||
| return nodes.editorStack.style | ||
| .getPropertyValue("--editor-font-size") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1639,8 +1639,15 @@ p { | |
| position: absolute; | ||
| inset: 0 0 0 var(--editor-gutter); | ||
| margin: 0; | ||
| /* What Jim's stage covers, measured by interview.js. A border, not right | ||
| padding, which a textarea leaves out of its scroll range, nor a narrower | ||
| box, which would not take a click beside the code. The compact card, | ||
| which grows with the captions, gets bottom padding so the text area | ||
| never resizes while Jim speaks. */ | ||
| border: 0; | ||
| border-right: var(--jim-stage-reserve-right, 0px) solid transparent; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In forced-colors mode (Windows High Contrast) the browser replaces |
||
| padding: 1rem; | ||
| padding-bottom: calc(1rem + var(--jim-stage-reserve-bottom, 0px)); | ||
| font-family: var(--editor-font-family); | ||
| font-size: var(--editor-font-size); | ||
| line-height: 1.5; | ||
|
|
@@ -1695,6 +1702,8 @@ p { | |
| width: var(--editor-gutter); | ||
| margin: 0; | ||
| padding: 1rem 0.5rem; | ||
| /* Follows the text layers' scrollTop, so it reserves the same bottom. */ | ||
| padding-bottom: calc(1rem + var(--jim-stage-reserve-bottom, 0px)); | ||
| overflow: hidden; | ||
| color: var(--code-gutter-ink); | ||
| background-color: var(--code-gutter); | ||
|
|
@@ -1715,6 +1724,8 @@ p { | |
| past what they can follow and the painted text would sit a line above the | ||
| caret near the end of a long file. Wheel, keys, and the caret still scroll. */ | ||
| scrollbar-width: none; | ||
| /* Keeps the caret above the compact card while typing. */ | ||
| scroll-padding-bottom: calc(1rem + var(--jim-stage-reserve-bottom, 0px)); | ||
| background: transparent; | ||
| /* Transparent glyphs: the overlay supplies the visible, colored ones. */ | ||
| color: transparent; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The reservation uses a stale stage rectangle after
.scrollablecan reposition the stage. Re-readgetBoundingClientRect()after toggling.scrollable, otherwise an oversized compact card can reserve the fixed-bottom position while it is actually rendered at the toolbar anchor.Prompt for AI agents