MessageReceived(): Override B_MOUSE_WHEEL_CHANGED when in alternative screen
mode and send the key/page up/down escape sequences instead of trying to scroll. Makes mouse wheel scrolling in less, nano,... working. Closes #6460. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39589 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fa8c3f1065
commit
c059c8c5d0
@ -1937,6 +1937,54 @@ TermView::MessageReceived(BMessage *msg)
|
||||
break;
|
||||
}
|
||||
|
||||
case B_MOUSE_WHEEL_CHANGED:
|
||||
{
|
||||
// overridden to allow scrolling emulation in alternative screen
|
||||
// mode
|
||||
BAutolock locker(fTextBuffer);
|
||||
float deltaY = 0;
|
||||
if (fTextBuffer->IsAlternateScreenActive()
|
||||
&& msg->FindFloat("be:wheel_delta_y", &deltaY) == B_OK
|
||||
&& deltaY != 0) {
|
||||
// We are in alternative screen mode and have a vertical delta
|
||||
// we can work with -- emulate scrolling via terminal escape
|
||||
// sequences.
|
||||
locker.Unlock();
|
||||
|
||||
// scroll pagewise, if one of Option, Command, or Control is
|
||||
// pressed
|
||||
int32 steps;
|
||||
const char* stepString;
|
||||
if ((modifiers()
|
||||
& (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY))
|
||||
!= 0) {
|
||||
// pagewise
|
||||
stepString = deltaY > 0
|
||||
? PAGE_DOWN_KEY_CODE : PAGE_UP_KEY_CODE;
|
||||
steps = abs((int)deltaY);
|
||||
} else {
|
||||
// three lines per step
|
||||
stepString = deltaY > 0
|
||||
? DOWN_ARROW_KEY_CODE : UP_ARROW_KEY_CODE;
|
||||
steps = 3 * abs((int)deltaY);
|
||||
}
|
||||
|
||||
// We want to do only a single write(), so compose a string
|
||||
// repeating the sequence as often as required by the delta.
|
||||
BString toWrite;
|
||||
for (int32 i = 0; i <steps; i++)
|
||||
toWrite << stepString;
|
||||
|
||||
_WritePTY(toWrite.String(), toWrite.Length());
|
||||
} else {
|
||||
// let the BView's implementation handle the standard scrolling
|
||||
locker.Unlock();
|
||||
BView::MessageReceived(msg);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MENU_CLEAR_ALL:
|
||||
Clear();
|
||||
fShell->Write(ctrl_l, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user