New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hidden setting (AlternateMouseScroll) for arrow keys on mouse scroll #164

Merged
merged 2 commits into from Mar 13, 2014

Conversation

Projects
None yet
6 participants
@FiloSottile
Copy link
Contributor

FiloSottile commented Mar 13, 2014

The hidden defaults setting AlternateMouseScroll turns on "mouse wheel scrolling support when a terminal is in MOUSE_REPORTING_NONE mouse mode and is using an alternate screen by translating them to arrow up/down terminfo escape sequences. (ala MouseTerm)"

Activate it with

$ defaults write com.googlecode.iterm2 AlternateMouseScroll -bool true

This patch was submitted and adapted in https://code.google.com/p/iterm2/issues/detail?id=974 and then wrapped in a hidden setting by me

Add hidden setting (AlternateMouseScroll) for arrow keys on mouse scroll
The hidden defaults setting AlternateMouseScroll turns on "mouse wheel
scrolling support when a terminal is in MOUSE_REPORTING_NONE mouse mode and
is using an alternate screen by translating them to arrow up/down terminfo
escape sequences. (ala MouseTerm)"

Activate it with
$ defaults write com.googlecode.iterm2 AlternateMouseScroll -bool true

This patch was submitted and adapted in
https://code.google.com/p/iterm2/issues/detail?id=974
and then wrapped in a hidden setting by me
- (BOOL) alternateMouseScroll
{
assert(prefs);
return [prefs objectForKey:@"AlternateMouseScroll"] ? [[prefs objectForKey:@"AlternateMouseScroll"] boolValue] : NO;

This comment has been minimized.

@gnachman

gnachman Mar 13, 2014

Owner

This can be simply: return [[NSUserDefaults standardUserDefaults] boolForKey:@"AlternateMouseScroll"]

This comment has been minimized.

@FiloSottile

FiloSottile Mar 13, 2014

Contributor

Copy-pasted from (BOOL) traditionalVisualBell above. Should I switch that too?

@@ -74,6 +74,7 @@ - (id)initWithTerminal:(VT100Terminal *)terminal
kDefaultScreenRows)
delegate:self];
currentGrid_ = primaryGrid_;
terminal_.isAlternate = false;

This comment has been minimized.

@FiloSottile

FiloSottile Mar 13, 2014

Contributor

Ok, pulling this line (it was in the original patch, not part of my edits)

@@ -26,6 +26,7 @@
@property(nonatomic, readonly) BOOL originMode;
@property(nonatomic, assign) BOOL wraparoundMode;
@property(nonatomic, readonly) BOOL isAnsi;
@property(nonatomic, assign) BOOL isAlternate;

This comment has been minimized.

@gnachman

gnachman Mar 13, 2014

Owner

Instead of adding this property to VT100Terminal, add a method the PTYTextViewDataSource protocol exposing it. VT100Screen implements that protocol, and the test is simply if currentGrid_ == altGrid_.

This comment has been minimized.

@FiloSottile

FiloSottile Mar 13, 2014

Contributor

Ok, attempting this, but I've only ever read Obj-C. Be right back.

terminal.isAlternate) {
CGFloat deltaY = [event deltaY];
if (deltaY > 0) {
NSData* keyMove = [terminal.output keyArrowUp:[event modifierFlags]];

This comment has been minimized.

@gnachman

gnachman Mar 13, 2014

Owner

You don't need to duplicate the loop code. Just iterate while "i < ceil(fabs(deltaY))"

This comment has been minimized.

@FiloSottile

FiloSottile Mar 13, 2014

Contributor

Right, I see this. Patching.

@FiloSottile

This comment has been minimized.

Copy link
Contributor

FiloSottile commented Mar 13, 2014

@gnachman Tried to address all the points in the last commit

@gnachman gnachman merged commit 48934d5 into gnachman:master Mar 13, 2014

@gnachman

This comment has been minimized.

Copy link
Owner

gnachman commented Mar 13, 2014

Merged, thanks!

@FiloSottile

This comment has been minimized.

Copy link
Contributor

FiloSottile commented Mar 13, 2014

Nice, thank you!

@mtsgrd

This comment has been minimized.

Copy link

mtsgrd commented Jan 20, 2015

I can't seem to make this work. I've run defaults write com.googlecode.iterm2 AlternateMouseScroll -bool true, is there anything else I need to pay attention to before trying to scroll a file in vim?

@adriaant

This comment has been minimized.

Copy link

adriaant commented Jan 20, 2015

OP wrote: "turns on "mouse wheel scrolling support when a terminal is in MOUSE_REPORTING_NONE mouse mode and is using an alternate screen by translating them to arrow up/down terminfo escape sequences. "
so check if your terminal is in MOUSE_REPORTING_NONE and if you have arrow up/down terminfo escape sequences.

@afletch

This comment has been minimized.

Copy link

afletch commented Jan 27, 2015

Is this in the latest beta?

@gnachman

This comment has been minimized.

Copy link
Owner

gnachman commented Feb 3, 2015

No, nightly only. The 2.9 branch hasn't gone beta yet because I've been distracted by having a baby :) I hope to have enough time to release a 2.9 beta this summer.

@ebigelow

This comment has been minimized.

Copy link

ebigelow commented May 11, 2015

adriaant commented on Jan 20:
"so check if your terminal is in MOUSE_REPORTING_NONE and if you have arrow up/down terminfo escape sequences."

I apologize for my naivety with iterm, but can someone please advise me on how to do this?

In the iterm preferences there's a checkbox for 'enable xterm mouse reporting' -- should this be unchecked? I'm also not sure what escape sequence to set for the up/down arrows, since 'ku' & 'kd' don't seem to work, and neither do 'up' & 'do'.

@gnachman

This comment has been minimized.

Copy link
Owner

gnachman commented May 13, 2015

@ebigelow These are the conditions that enable this feature:

  1. Run the nightly build of iTerm2
  2. Ensure enable xterm mouse reporting is on
  3. Ensure disable save/restore alternate screen is off
  4. Run a program that switches into alternate screen mode (less, vi, emacs, etc.; these programs restore the screen contents upon exiting)
  5. Mouse reporting should not be in use by that program (you can tell because the I-bar cursor looks like this, not like this)
  6. Use the scroll bar
@ebigelow

This comment has been minimized.

Copy link

ebigelow commented May 13, 2015

Silly mistake on my part, I wasn't using the nightly build -- I assumed this had been integrated into the stable release by now. Thank you for the prompt and thorough response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment