Skip to content

fix: clip input text, selection, and caret to the field viewport - #36

Merged
medvednikov merged 1 commit into
masterfrom
fix/issue-33-20260919
Sep 19, 2026
Merged

medvednikov merged 1 commit into
masterfrom
fix/issue-33-20260919

Conversation

@medvednikov

Copy link
Copy Markdown
Member

Fixes #33.

Changes

  • Clip single-line input text, placeholder text, selection highlights, and the caret to the padded input viewport intersected with the parent clip.
  • Restore the parent clip after drawing, preserving sibling rendering and the field's full hit area.
  • Keep the underlying text unchanged rather than ellipsizing editable content. Clamp empty and tiny viewport dimensions.
  • Add regression tests for padding, parent clipping, and zero/negative/tiny dimensions.

Verification

Passed with V 0.5.2 on Linux:

v test ui/text_input_test.v
v -check -shared .

These checks passed before the branch was committed and published in the isolated verification run. That shared run later failed on an unrelated existing scrolling test while verifying a different issue; the commands above succeeded.

Manual pixel-level GUI verification has not been performed. This PR contains only the fix and regression tests, not the temporary verification workflow.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-19T14:04:30.070144Z d61d7dc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d61d7dc14c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ui/ui_immediate.c.v
content_clip := intersect_rect(text_field_content_rect(rect(x, y,
el.frame.width, el.frame.height), padding_left), clip)
if content_clip.width > 0 && content_clip.height > 0 {
apply_clip(ctx, content_clip)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the active end of long inputs visible

In the immediate renderer, a default left-aligned field whose text is wider than content_width keeps text_origin fixed at the left edge while calculating cursor_x from the full prefix width. This new scissor therefore hides the caret and newly appended characters; because focusing or clicking a text field places the caret at rune_len(editor.text), editing an existing long value gives no visible insertion point or feedback. Apply a horizontal text offset that keeps the active caret or selection endpoint inside the viewport before clipping.

Useful? React with 👍 / 👎.

@medvednikov
medvednikov merged commit 3200aec into master Sep 19, 2026
0 of 5 checks passed
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.

Input boxes don't clip their contents

1 participant