Skip to content

Commit a7e636f

Browse files
authored
Merge pull request #859 from rumpl/smooth-mouse-scroll
Remove the mouse filter
2 parents 804db06 + d0a5ff2 commit a7e636f

4 files changed

Lines changed: 1 addition & 19 deletions

File tree

cmd/root/new.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func (f *newFlags) runNewCommand(cmd *cobra.Command, args []string) error {
7373

7474
progOpts := []tea.ProgramOption{
7575
tea.WithContext(ctx),
76-
tea.WithFilter(tui.MouseEventFilter),
7776
}
7877

7978
p := tea.NewProgram(m, progOpts...)

cmd/root/run.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ func handleRunMode(ctx context.Context, agentFilename string, rt runtime.Runtime
245245

246246
progOpts := []tea.ProgramOption{
247247
tea.WithContext(ctx),
248-
tea.WithFilter(tui.MouseEventFilter),
249248
}
250249

251250
p := tea.NewProgram(m, progOpts...)

pkg/tui/components/messages/messages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (m *model) Update(msg tea.Msg) (layout.Model, tea.Cmd) {
199199
return m, nil
200200

201201
case tea.MouseWheelMsg:
202-
const mouseScrollAmount = 3
202+
const mouseScrollAmount = 2
203203
buttonStr := msg.Button.String()
204204

205205
switch buttonStr {

pkg/tui/tui.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package tui
33
import (
44
"context"
55
"fmt"
6-
"time"
76

87
"charm.land/bubbles/v2/help"
98
"charm.land/bubbles/v2/key"
@@ -27,21 +26,6 @@ import (
2726
"github.com/docker/cagent/pkg/tui/styles"
2827
)
2928

30-
var lastMouseEvent time.Time
31-
32-
// MouseEventFilter filters mouse events to prevent spam
33-
func MouseEventFilter(_ tea.Model, msg tea.Msg) tea.Msg {
34-
switch msg.(type) {
35-
case tea.MouseWheelMsg, tea.MouseMotionMsg, tea.MouseMsg:
36-
now := time.Now()
37-
if now.Sub(lastMouseEvent) < 20*time.Millisecond {
38-
return nil
39-
}
40-
lastMouseEvent = now
41-
}
42-
return msg
43-
}
44-
4529
// appModel represents the main application model
4630
type appModel struct {
4731
application *app.App

0 commit comments

Comments
 (0)