Skip to content
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 alternate scroll mode (xterm) #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 17 additions & 14 deletions PTYTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions VT100Terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions VT100Terminal.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ - (id)init
bgColorCode_ = ALTSEM_DEFAULT;
bgColorMode_ = ColorModeAlternate;
_mouseMode = MOUSE_REPORTING_NONE;
_alternateScrollMode = NO;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to initialize ivars to NO in -init because they're zeroed out during allocation.

_mouseFormat = MOUSE_FORMAT_XTERM;

_allowKeypadMode = YES;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -521,6 +523,11 @@ - (void)executeModeUpdates:(VT100Token *)token
}
break;

case 1007: // xterm style
case 7786: // mintty style
self.alternateScrollMode = mode;
break;

case 1015:
if (mode) {
self.mouseFormat = MOUSE_FORMAT_URXVT;
Expand Down