Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ Change Log
==========


## Unreleased

**Fixed**

- Mouse mode only responded to left click. The button codes were
hardcoded integers from `NCURSES_MOUSE_VERSION` 1, which gave each
button six bits; version 2 packs them into five to make room for
button 5, moving every value except `BUTTON1_RELEASED`. Right click
and both scroll directions were therefore matched against numbers
ncurses never sends. The codes now come from curses itself.

## [v0.3.2](https://github.com/leancode/suplemon/tree/0.3.2) (2026-09-03)

Nothing here changes the installed package. The launcher fix affects the
Expand Down
20 changes: 16 additions & 4 deletions suplemon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


import os
import curses
import sys

from . import ui
Expand All @@ -21,6 +22,12 @@
__version__ = "0.3.2"


# ncurses only defines BUTTON5 when built with NCURSES_MOUSE_VERSION 2.
# Without it there is no wheel-down event to match, so scrolling down is
# simply unavailable rather than mismatched.
BUTTON5_PRESSED = getattr(curses, "BUTTON5_PRESSED", 0)


class App:
def __init__(self, filenames=None, config_file=None, log_level=None):
"""
Expand Down Expand Up @@ -340,13 +347,18 @@ def handle_mouse(self, event):
:rtype: boolean
"""
editor = self.get_editor()
if event.mouse_code == 1: # Left mouse button release
code = event.mouse_code
# These were hardcoded integers matching NCURSES_MOUSE_VERSION 1,
# which gave each button six bits. Version 2 packs them into five to
# make room for button 5, so every value except BUTTON1_RELEASED
# moved and only left click still worked. Ask curses instead.
if code & curses.BUTTON1_RELEASED:
editor.set_single_cursor(event.mouse_pos)
elif event.mouse_code == 4096: # Right mouse button release
elif code & curses.BUTTON3_RELEASED:
editor.add_cursor(event.mouse_pos)
elif event.mouse_code == 524288: # Wheel up
elif code & curses.BUTTON4_PRESSED: # Wheel up
editor.jump_up()
elif event.mouse_code == 134217728: # Wheel down(and unfortunately left button drag)
elif BUTTON5_PRESSED and code & BUTTON5_PRESSED:
editor.jump_down()
else:
return False
Expand Down
Loading