aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJeremy Klein <jlklein@google.com>2015-09-25 15:32:12 -0700
committerJeremy Klein <jlklein@google.com>2015-10-01 14:56:39 -0700
commite4e3047bd5e9c8e010041aec196a77797e420332 (patch)
tree21ad5198ed3f2985841878e3fd9967b5b4e35225 /app
parent4255b573c13f4f76f4aec515dd78688f428d871a (diff)
downloadconnectbot-e4e3047bd5e9c8e010041aec196a77797e420332.tar.gz
connectbot-e4e3047bd5e9c8e010041aec196a77797e420332.tar.bz2
connectbot-e4e3047bd5e9c8e010041aec196a77797e420332.zip
Add support for mouse wheel forwarding.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/de/mud/terminal/VDUInput.java11
-rw-r--r--app/src/main/java/de/mud/terminal/vt320.java32
-rw-r--r--app/src/main/java/org/connectbot/TerminalView.java16
3 files changed, 58 insertions, 1 deletions
diff --git a/app/src/main/java/de/mud/terminal/VDUInput.java b/app/src/main/java/de/mud/terminal/VDUInput.java
index abaa70f..e1bce90 100644
--- a/app/src/main/java/de/mud/terminal/VDUInput.java
+++ b/app/src/main/java/de/mud/terminal/VDUInput.java
@@ -57,6 +57,17 @@ public interface VDUInput {
void mousePressed(int x, int y, int modifiers);
/**
+ * Passes mouse wheel events to the terminal.
+ * @param down True if scrolling down the page. False if scrolling up.
+ * @param x
+ * @param y
+ * @param ctrl
+ * @param shift
+ * @param meta
+ */
+ public void mouseWheel(boolean down, int x, int y, boolean ctrl, boolean shift, boolean meta);
+
+ /**
* Terminal is mouse-aware and requires the coordinates and button
* of the release.
* @param x
diff --git a/app/src/main/java/de/mud/terminal/vt320.java b/app/src/main/java/de/mud/terminal/vt320.java
index 4f36f28..90c7403 100644
--- a/app/src/main/java/de/mud/terminal/vt320.java
+++ b/app/src/main/java/de/mud/terminal/vt320.java
@@ -376,6 +376,38 @@ public void setScreenSize(int c, int r, boolean broadcast) {
}
/**
+ * Passes mouse wheel events to the terminal.
+ * @param down True if scrolling down the page. False if scrolling up.
+ * @param x
+ * @param y
+ * @param ctrl
+ * @param shift
+ * @param meta
+ */
+ public void mouseWheel(boolean down, int x, int y, boolean ctrl, boolean shift, boolean meta) {
+ if (mouserpt == 0 || mouserpt == 9)
+ return;
+
+ int mods = 0;
+ if (ctrl) mods |= 2;
+ if (shift) mods |= 1;
+ if (meta) mods |= 4;
+
+ int mousecode = ((down ? 0 : 1) + 96) | 0x20 | ((mods & 7) << 2);
+
+ byte b[] = new byte[6];
+
+ b[0] = 27;
+ b[1] = (byte) '[';
+ b[2] = (byte) 'M';
+ b[3] = (byte) mousecode;
+ b[4] = (byte) (0x20 + x + 1);
+ b[5] = (byte) (0x20 + y + 1);
+
+ write(b); // FIXME: writeSpecial here
+ }
+
+ /**
* Terminal is mouse-aware and requires the coordinates and button
* of the release.
* @param x
diff --git a/app/src/main/java/org/connectbot/TerminalView.java b/app/src/main/java/org/connectbot/TerminalView.java
index 261407c..ffe8d8b 100644
--- a/app/src/main/java/org/connectbot/TerminalView.java
+++ b/app/src/main/java/org/connectbot/TerminalView.java
@@ -52,6 +52,7 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.Toast;
import de.mud.terminal.VDUBuffer;
+import de.mud.terminal.vt320;
/**
* User interface {@link View} for showing a TerminalBridge in an
@@ -329,7 +330,20 @@ public class TerminalView extends View implements FontSizeChangedListener {
case MotionEvent.ACTION_SCROLL:
// Process scroll wheel movement:
float yDistance = MotionEventCompat.getAxisValue(event, MotionEvent.AXIS_VSCROLL);
- if (yDistance != 0) {
+ boolean mouseReport = ((vt320) bridge.buffer).isMouseReportEnabled();
+ if (mouseReport) {
+ int row = (int) Math.floor(event.getY() / bridge.charHeight);
+ int col = (int) Math.floor(event.getX() / bridge.charWidth);
+
+ ((vt320) bridge.buffer).mouseWheel(
+ yDistance > 0,
+ col,
+ row,
+ (event.getMetaState() & KeyEvent.META_CTRL_ON) != 0,
+ (event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0,
+ (event.getMetaState() & KeyEvent.META_META_ON) != 0);
+ return true;
+ } else if (yDistance != 0) {
int base = bridge.buffer.getWindowBase();
bridge.buffer.setWindowBase(base - Math.round(yDistance));
return true;