Add caret, text selection and copy/cut/paste to the chat input box#4976
Open
TheCrazy17 wants to merge 3 commits into
Open
Add caret, text selection and copy/cut/paste to the chat input box#4976TheCrazy17 wants to merge 3 commits into
TheCrazy17 wants to merge 3 commits into
Conversation
The chat input never had a real cursor: backspace only worked at the end of the line, and there was no way to move around, select text, or use copy/paste. The debug console gets all of this for free from CGUIEdit, but the chat input draws its own text by hand, so none of it applied there. Adds a blinking caret, left/right/home/end navigation (ctrl to skip words), delete, shift-extendable selection with a highlight, ctrl+a, ctrl+c/x/v against the system clipboard, and mouse drag selection - all on top of the existing custom-drawn input instead of switching it over to a CEGUI editbox. Partially addresses multitheftauto#755 (caret/selection/copy-paste only, no scriptable auto-completion)
It was advancing by a fixed step every draw call, so it blinked faster at higher framerates instead of on a real clock. Switched it to GetSecondCount(), which the rest of this file already uses for timing. Also named the selection highlight color and caret width instead of leaving them as bare numbers, and dropped an unused helper.
Contributor
|
very cool, this was always a real lack |
A few hand-aligned comments and column widths didn't match what clang-format recalculates after the new code, which is what the CI formatting check was catching.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds, on top of the existing custom-drawn chat input (no migration to a CEGUI editbox):
Chat.test.mp4
Out of scope (left for a follow-up): scriptable client-side auto-completion, and selecting/copying text from already-sent chat history lines with the mouse.
Motivation
The chat input box was hand-rolled text editing with no concept of a cursor: Backspace only removed the last character, and there was no way to navigate within the text, select a range, or use the system clipboard, unlike the debug console, which already gets all of this for free from
CGUIEdit.Implement one of the ideas of (but no closes) #755 (caret, selection and copy/paste; auto-completion not included).
Test plan
Manually tested in-game:
To verify: open the chat, type a message, move the caret around with arrows/Ctrl+arrows, select text with Shift+arrows or by dragging the mouse, and try Ctrl+A/C/X/V.
Checklist