Make chat content selectable and add Copy context menu#1
Merged
Conversation
Lift .textSelection(.enabled) to the LazyVStack containers in MessageList and ServerMessageList so every message kind — privmsg, notice, action, join/part/quit/nick/kick, topic, mode, and server numerics — is selectable, not just privmsg/notice content. Attach a .contextMenu to MessageRow with Copy Message, Copy Text, and Copy Nickname items. Copy Message emits a plain-text log-style line using the row's current timestamp format; Copy Text emits just the message body with mIRC control codes stripped; Copy Nickname emits the sender. SwiftUI's .textSelection only supports per-Text selection, not cross-row drag-selection. Proper mIRC-style multi-line copy requires an NSTextView-backed buffer and lands in a follow-up.
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
Changes
Sources/BryggaCore/IRC/IRCFormatting.swift— new publicstripControlCodes(_:)helper. Strips bold / italic / underline / strikethrough / reverse / reset / monospace / color (^K<fg>[,<bg>]) control bytes, preserving the surrounding text. Additive; no existing API changed.Sources/Brygga/Views/ContentView.swift—import AppKitforNSPasteboard..textSelection(.enabled)hoisted to theLazyVStackinsideMessageListandServerMessageListso selection works across every row kind in every list (main chat, server console, detached window).Text.textSelectionmodifiers inMessageRowremoved.MessageRow.rowBodygains a.contextMenuwith the three Copy items and a privatecopy(_:)pasteboard helper plus aplainLogLinecomputed property.Copy Messageemits[HH:mm] <nick> bodyfor privmsg,[HH:mm] -nick- bodyfor notice, and[HH:mm] * nick bodyfor action / presence kinds.Tests/IRCFormattingTests.swift— 5 new tests covering bold/italic/underline, color sequences with fg+bg, literal comma after^K<digit>(ambiguous-separator case), reset + reverse + strikethrough, and plain-text identity.Test plan
Risk / rollback
Low. Purely additive on the selection side; no protocol, persistence, or threading changes. Revert the commit if the context menu conflicts with link-tap behaviour on any macOS version we care about.
Known limitation addressed in a follow-up: SwiftUI's `.textSelection` only supports per-`Text` selection — drag-selection does not cross row boundaries. Proper mIRC-style multi-line copy lands in a follow-up PR that backs `MessageList` with an `NSViewRepresentable` wrapping `NSScrollView` + `NSTextView`.