Re: [PATCH] input: scroll on mousewheel instead of moving cursor
Andy Koppe <[email protected]>
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <[email protected]> |
On 15/09/2023 11:29, pepa65 wrote: > On 2023-09-15 09:14, LIU Hao wrote: >> By default (when the mouse mode is off) the terminal emulator seems to >> send key up and down >> commands. The only difference between it and the mouse mode is that my >> gnome terminal scrolls five >> lines instead of three. > > I build nano with "disable-mouse", but the mousewheel does move my > cursor, which is OK. If it would make the text scroll but the cursor > stay in the same place, it would be weird, but I could probably live > with that too. The patch I proposed only affects nano mouse mode. Outside mouse mode, many terminal emulators do indeed send cursor up/down for the wheel (when on the alternate screen). I actually implemented that in the mintty terminal used for Cygwin and MSYS back in 2008 (and I think others implemented it around the same time). This was aimed primarily at 'less', where the cursor keys do scroll directly. Having the mousewheel move the cursor in editors like nano was better than nothing, as at least it scrolls eventually once the cursor reaches the top or bottom, but it doesn't match the standard behavior of the mousewheel in GUI editors and other apps as well as in the mouse mode of other terminal editors. Another angle worth considering here is the so-called "natural" mousewheel scrolling that is the default on Macs and available as an option in KDE and Gnome as well as as a registry option on Windows. With that, the mousewheel directly moves the window content, i.e. wheel up means moving the content up, whereas with the traditional approach, the wheel controls the scrollbar and the content moves in the opposite direction. With "natural" scrolling, the move-the-cursor approach becomes rather weird, as the cursor moves in the opposite direction of the wheel. So for example one notch up on the wheel moves the cursor three lines down whereas users would expect the content to move three lines up instead. Kind regards, Andy