|
11 | 11 | import android.os.Build;
|
12 | 12 | import android.os.Handler;
|
13 | 13 | import android.os.Looper;
|
| 14 | +import android.os.SystemClock; |
14 | 15 | import android.text.Editable;
|
15 | 16 | import android.text.InputType;
|
16 | 17 | import android.text.TextUtils;
|
@@ -872,13 +873,36 @@ public boolean handleKeyCode(int keyCode, int keyMod) {
|
872 | 873 | if (mEmulator != null)
|
873 | 874 | mEmulator.setCursorBlinkState(true);
|
874 | 875 |
|
| 876 | + if (handleKeyCodeAction(keyCode, keyMod)) |
| 877 | + return true; |
| 878 | + |
875 | 879 | TerminalEmulator term = mTermSession.getEmulator();
|
876 | 880 | String code = KeyHandler.getCode(keyCode, keyMod, term.isCursorKeysApplicationMode(), term.isKeypadApplicationMode());
|
877 | 881 | if (code == null) return false;
|
878 | 882 | mTermSession.write(code);
|
879 | 883 | return true;
|
880 | 884 | }
|
881 | 885 |
|
| 886 | + public boolean handleKeyCodeAction(int keyCode, int keyMod) { |
| 887 | + boolean shiftDown = (keyMod & KeyHandler.KEYMOD_SHIFT) != 0; |
| 888 | + |
| 889 | + switch (keyCode) { |
| 890 | + case KeyEvent.KEYCODE_PAGE_UP: |
| 891 | + case KeyEvent.KEYCODE_PAGE_DOWN: |
| 892 | + // shift+page_up and shift+page_down should scroll scrollback history instead of |
| 893 | + // scrolling command history or changing pages |
| 894 | + if (shiftDown) { |
| 895 | + long time = SystemClock.uptimeMillis(); |
| 896 | + MotionEvent motionEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN, 0, 0, 0); |
| 897 | + doScroll(motionEvent, keyCode == KeyEvent.KEYCODE_PAGE_UP ? -1 : 1); |
| 898 | + motionEvent.recycle(); |
| 899 | + return true; |
| 900 | + } |
| 901 | + } |
| 902 | + |
| 903 | + return false; |
| 904 | + } |
| 905 | + |
882 | 906 | /**
|
883 | 907 | * Called when a key is released in the view.
|
884 | 908 | *
|
|
0 commit comments