mirror of
https://github.com/charmbracelet/crush.git
synced 2025-08-02 05:20:46 +03:00
feat(mouse): delegate mouse actions to terminal emulator (#218)
This commit is contained in:
@@ -31,29 +31,6 @@ import (
|
||||
"github.com/charmbracelet/lipgloss/v2"
|
||||
)
|
||||
|
||||
// MouseEventFilter filters mouse events based on the current focus state
|
||||
// This is used with tea.WithFilter to prevent mouse scroll events from
|
||||
// interfering with typing performance in the editor
|
||||
func MouseEventFilter(m tea.Model, msg tea.Msg) tea.Msg {
|
||||
// Only filter mouse events
|
||||
switch msg.(type) {
|
||||
case tea.MouseWheelMsg, tea.MouseMotionMsg:
|
||||
// Check if we have an appModel and if editor is focused
|
||||
if appModel, ok := m.(*appModel); ok {
|
||||
if appModel.currentPage == chat.ChatPageID {
|
||||
if chatPage, ok := appModel.pages[appModel.currentPage].(chat.ChatPage); ok {
|
||||
// If editor is focused (not chatFocused), filter out mouse wheel/motion events
|
||||
if !chatPage.IsChatFocused() {
|
||||
return nil // Filter out the event
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Allow all other events to pass through
|
||||
return msg
|
||||
}
|
||||
|
||||
// appModel represents the main application model that manages pages, dialogs, and UI state.
|
||||
type appModel struct {
|
||||
wWidth, wHeight int // Window dimensions
|
||||
@@ -88,8 +65,6 @@ func (a appModel) Init() tea.Cmd {
|
||||
cmd = a.status.Init()
|
||||
cmds = append(cmds, cmd)
|
||||
|
||||
cmds = append(cmds, tea.EnableMouseAllMotion)
|
||||
|
||||
return tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user