| 1 | ##### mouse (works with editors; cooperates with Ctrl-g) ##### |
| 2 | |
| 3 | # When @ui_binds = off → always pass mouse to app. |
| 4 | # When @ui_binds = on: |
| 5 | # - alt-screen apps (micro/vim/less/man/htop) get the mouse |
| 6 | # - in a plain shell, drag creates tmux selection with clear highlight |
| 7 | |
| 8 | # Strong selection highlight |
| 9 | setw -g mode-style "bg=#7bd88f,fg=#0b0b0b,bold" |
| 10 | |
| 11 | # Clean slate |
| 12 | unbind -n MouseDown1Pane |
| 13 | unbind -n MouseDrag1Pane |
| 14 | unbind -n MouseUp1Pane |
| 15 | |
| 16 | # Mouse down |
| 17 | bind -n MouseDown1Pane if -F '#{||:#{==:#{@ui_binds},off},#{alternate_on}}' \ |
| 18 | 'send-keys -M' \ |
| 19 | 'select-pane -t=' |
| 20 | |
| 21 | # Drag |
| 22 | bind -n MouseDrag1Pane if -F "#{pane_in_mode}" \ |
| 23 | "send-keys -X begin-selection" \ |
| 24 | "if -F '#{||:#{==:#{@ui_binds},off},#{alternate_on}}' 'send-keys -M' 'copy-mode -M'" |
| 25 | |
| 26 | # Extend selection while in copy-mode |
| 27 | bind -T copy-mode-vi MouseDrag1Pane send-keys -X begin-selection |
| 28 | |
| 29 | # Mouse up |
| 30 | bind -n MouseUp1Pane if -F '#{||:#{==:#{@ui_binds},off},#{alternate_on}}' 'send-keys -M' |
| 31 |