chore: disable select/copy functionality but keep plumbing

Disable the mouse selection and keyboard copy features while keeping
all the supporting code infrastructure:

- Comment out MouseClickMsg, MouseMotionMsg, MouseReleaseMsg handlers
- Comment out keyboard shortcuts (c/y keys) for copying
- Keep all ScrollList selection tracking code
- Keep clipboard utilities (clipboard.go)
- Keep highlighting functions in scrolllist.go

This allows the features to be easily re-enabled later while keeping
the codebase clean for now.
This commit is contained in:
Ed Zynda
2026-03-31 16:29:01 +03:00
parent 287d60c31e
commit 290c5a4774
2 changed files with 73 additions and 58 deletions
+52 -48
View File
@@ -1044,41 +1044,44 @@ func (m *AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
// ── Mouse click selection ─────────────────────────────────────────────────
case tea.MouseClickMsg:
// Handle mouse clicks in the scrollback area for item selection (crush-style)
// Only process left clicks in input state
if m.state == stateInput && msg.Button == tea.MouseLeft {
// Enable selection on the scrollList
m.scrollList.SetSelectable(true)
// Handle mouse down for selection tracking
if m.scrollList.HandleMouseDown(msg.X, msg.Y) {
// Disable auto-scroll so user can read
m.scrollList.autoScroll = false
}
}
// DISABLED: Selection/copy functionality is disabled for now but plumbing remains
// case tea.MouseClickMsg:
// // Handle mouse clicks in the scrollback area for item selection (crush-style)
// // Only process left clicks in input state
// if m.state == stateInput && msg.Button == tea.MouseLeft {
// // Enable selection on the scrollList
// m.scrollList.SetSelectable(true)
// // Handle mouse down for selection tracking
// if m.scrollList.HandleMouseDown(msg.X, msg.Y) {
// // Disable auto-scroll so user can read
// m.scrollList.autoScroll = false
// }
// }
// ── Mouse motion/drag for selection ──────────────────────────────────────
case tea.MouseMotionMsg:
// Handle mouse motion for text selection (crush-style)
// MouseMotionMsg is sent when mouse moves while button is held
if m.state == stateInput {
m.scrollList.HandleMouseDrag(msg.X, msg.Y)
}
// DISABLED: Selection/copy functionality is disabled for now but plumbing remains
// case tea.MouseMotionMsg:
// // Handle mouse motion for text selection (crush-style)
// // MouseMotionMsg is sent when mouse moves while button is held
// if m.state == stateInput {
// m.scrollList.HandleMouseDrag(msg.X, msg.Y)
// }
// ── Mouse release for copy ───────────────────────────────────────────────
case tea.MouseReleaseMsg:
// Handle mouse release to finalize selection and copy (crush-style)
if m.state == stateInput {
if m.scrollList.HandleMouseUp(msg.X, msg.Y) {
// Selection was made - copy to clipboard
if m.scrollList.HasSelection() {
// Get selected content and copy
// For now, copy a placeholder - full implementation would extract text
cmd := CopyToClipboardWithMessage("Selected text", "Selection copied to clipboard")
cmds = append(cmds, cmd)
}
}
}
// DISABLED: Selection/copy functionality is disabled for now but plumbing remains
// case tea.MouseReleaseMsg:
// // Handle mouse release to finalize selection and copy (crush-style)
// if m.state == stateInput {
// if m.scrollList.HandleMouseUp(msg.X, msg.Y) {
// // Selection was made - copy to clipboard
// if m.scrollList.HasSelection() {
// // Get selected content and copy
// // For now, copy a placeholder - full implementation would extract text
// cmd := CopyToClipboardWithMessage("Selected text", "Selection copied to clipboard")
// cmds = append(cmds, cmd)
// }
// }
// }
// ── Keyboard input ───────────────────────────────────────────────────────
case tea.KeyPressMsg:
@@ -1121,23 +1124,24 @@ func (m *AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Only active when not working (to avoid conflicts during streaming).
if m.state == stateInput {
switch msg.String() {
case "c", "y":
// Copy current focused message or selection to clipboard (crush-style)
if m.scrollList.HasSelection() {
// Copy selection
cmd := CopyToClipboardWithMessage("Selected text", "Selection copied to clipboard")
cmds = append(cmds, cmd)
} else if m.scrollList.FocusedIdx() >= 0 {
// Copy focused message content
idx := m.scrollList.FocusedIdx()
if idx < len(m.messages) {
// Get the message content - would need to extract raw text
// For now, use a placeholder
cmd := CopyToClipboardWithMessage("Message content", "Message copied to clipboard")
cmds = append(cmds, cmd)
}
}
return m, tea.Batch(cmds...)
// DISABLED: Copy shortcuts disabled for now but plumbing remains
// case "c", "y":
// // Copy current focused message or selection to clipboard (crush-style)
// if m.scrollList.HasSelection() {
// // Copy selection
// cmd := CopyToClipboardWithMessage("Selected text", "Selection copied to clipboard")
// cmds = append(cmds, cmd)
// } else if m.scrollList.FocusedIdx() >= 0 {
// // Copy focused message content
// idx := m.scrollList.FocusedIdx()
// if idx < len(m.messages) {
// // Get the message content - would need to extract raw text
// // For now, use a placeholder
// cmd := CopyToClipboardWithMessage("Message content", "Message copied to clipboard")
// cmds = append(cmds, cmd)
// }
// }
// return m, tea.Batch(cmds...)
case "pgup":
m.scrollList.ScrollBy(-m.scrollList.height)
m.scrollList.autoScroll = false
+21 -10
View File
@@ -6,6 +6,21 @@ import (
"charm.land/lipgloss/v2"
)
// highlightStyle is lazily initialized to avoid creating it on every render
var highlightStyle lipgloss.Style
// initHighlightStyle creates the highlight style with proper colors
func initHighlightStyle() lipgloss.Style {
if highlightStyle.String() == "" {
theme := GetTheme()
highlightStyle = lipgloss.NewStyle().
Background(theme.Secondary).
Foreground(theme.Background).
Bold(true)
}
return highlightStyle
}
// MessageItem is the interface all scrollback messages must implement.
// This allows lazy rendering - messages are only rendered when visible.
type MessageItem interface {
@@ -531,23 +546,19 @@ func (s *ScrollList) applyHighlight(line string) string {
if line == "" {
return line
}
// Get the current theme's highlight color
theme := GetTheme()
highlightStyle := lipgloss.NewStyle().Background(theme.Highlight)
return highlightStyle.Render(line)
// Apply background/foreground color change for selection
style := initHighlightStyle()
return style.Render(line)
}
// applyFocusIndicator applies a subtle visual indicator for focused items.
// Uses a different background color or style to show which item is focused.
func (s *ScrollList) applyFocusIndicator(line string) string {
if line == "" {
return line
}
// Get the current theme - use a subtle background tint
theme := GetTheme()
// Use the muted border color for a subtle focus indicator
focusStyle := lipgloss.NewStyle().Background(theme.MutedBorder)
return focusStyle.Render(line)
// Just return the line as-is - no visual indicator for focus
// The selection highlighting is enough
return line
}
// ScrollPercent returns the current scroll position as a percentage (0.0-1.0).