From 9ec799c4aebbc653fcf378449e7adb9619d44cc5 Mon Sep 17 00:00:00 2001 From: Hayaki Saito Date: Tue, 18 Mar 2014 01:03:08 +0900 Subject: [PATCH 1/2] Add alternate scroll mode (xterm) --- PTYTextView.m | 31 +++++++++++++++++-------------- VT100Terminal.h | 1 + VT100Terminal.m | 6 ++++++ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/PTYTextView.m b/PTYTextView.m index cdef23c5ab..f41d38c313 100644 --- a/PTYTextView.m +++ b/PTYTextView.m @@ -2827,22 +2827,25 @@ - (void)scrollWheel:(NSEvent *)event } break; case MOUSE_REPORTING_NONE: - if ([[PreferencePanel sharedInstance] alternateMouseScroll] && - [_dataSource showingAlternateScreen]) { - CGFloat deltaY = [event deltaY]; - NSData *keyMove = nil; - if (deltaY > 0) { - keyMove = [terminal.output keyArrowUp:[event modifierFlags]]; - } else if (deltaY < 0) { - keyMove = [terminal.output keyArrowDown:[event modifierFlags]]; - } - if (keyMove) { - for (int i = 0; i < ceil(fabs(deltaY)); i++) { - [_delegate writeTask:keyMove]; - } + if ([[PreferencePanel sharedInstance] alternateMouseScroll] || + [terminal alternateScrollMode]) { + if ([_dataSource showingAlternateScreen]) { + CGFloat deltaY = [event deltaY]; + NSData *keyMove = nil; + if (deltaY > 0) { + keyMove = [terminal.output keyArrowUp:[event modifierFlags]]; + } else if (deltaY < 0) { + keyMove = [terminal.output keyArrowDown:[event modifierFlags]]; + } + if (keyMove) { + for (int i = 0; i < ceil(fabs(deltaY)); i++) { + [_delegate writeTask:keyMove]; + } + } + return; } - return; } + break; case MOUSE_REPORTING_HILITE: // fall through break; diff --git a/VT100Terminal.h b/VT100Terminal.h index e24cfec03f..a5d676cbcd 100644 --- a/VT100Terminal.h +++ b/VT100Terminal.h @@ -31,6 +31,7 @@ @property(nonatomic, readonly) int charset; // G0 through G3 @property(nonatomic, assign) MouseMode mouseMode; @property(nonatomic, assign) MouseFormat mouseFormat; +@property(nonatomic, assign) BOOL alternateScrollMode; // The current foreground/background color to display (they're swapped when reverseVideo is on). @property(nonatomic, readonly) screen_char_t foregroundColorCode; diff --git a/VT100Terminal.m b/VT100Terminal.m index e6e2662fb3..676b9dc3d8 100644 --- a/VT100Terminal.m +++ b/VT100Terminal.m @@ -145,6 +145,7 @@ - (id)init bgColorCode_ = ALTSEM_DEFAULT; bgColorMode_ = ColorModeAlternate; _mouseMode = MOUSE_REPORTING_NONE; + _alternateScrollMode = NO; _mouseFormat = MOUSE_FORMAT_XTERM; _allowKeypadMode = YES; @@ -261,6 +262,7 @@ - (void)resetPreservingPrompt:(BOOL)preservePrompt self.keypadMode = NO; self.insertMode = NO; self.bracketedPasteMode = NO; + self.alternateScrollMode = NO; _charset = 0; xon_ = YES; bold_ = italic_ = blink_ = reversed_ = under_ = NO; @@ -521,6 +523,10 @@ - (void)executeModeUpdates:(VT100Token *)token } break; + case 1007: + self.alternateScrollMode = mode; + break; + case 1015: if (mode) { self.mouseFormat = MOUSE_FORMAT_URXVT; From ffc650923830340cc861d677ba95817ab8b3e24b Mon Sep 17 00:00:00 2001 From: Hayaki Saito Date: Wed, 19 Mar 2014 23:26:19 +0900 Subject: [PATCH 2/2] Recognize mintty style alternate scroll mode (private mode 7786) Application wheel mode (private mode 7787) is not implemented yet. --- VT100Terminal.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VT100Terminal.m b/VT100Terminal.m index 676b9dc3d8..d2d6c0e386 100644 --- a/VT100Terminal.m +++ b/VT100Terminal.m @@ -523,7 +523,8 @@ - (void)executeModeUpdates:(VT100Token *)token } break; - case 1007: + case 1007: // xterm style + case 7786: // mintty style self.alternateScrollMode = mode; break;