aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJeremy Klein <jlklein@google.com>2015-07-29 15:21:44 -0700
committerJeremy Klein <jlklein@google.com>2015-07-29 17:21:54 -0700
commit625122d39150a0c0f4717c3e00c2b0c3b8fd074b (patch)
tree3a44016a6f3ffe7c2dbabe5e3a736582c0506e4a /app
parentca740c38f5178ad47a2dbb5b1041be232e865a2d (diff)
downloadconnectbot-625122d39150a0c0f4717c3e00c2b0c3b8fd074b.tar.gz
connectbot-625122d39150a0c0f4717c3e00c2b0c3b8fd074b.tar.bz2
connectbot-625122d39150a0c0f4717c3e00c2b0c3b8fd074b.zip
Automatically start copy mode when clicking and dragging with a mouse
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/org/connectbot/ConsoleActivity.java43
1 files changed, 28 insertions, 15 deletions
diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java
index 79f1269..4e4c4e2 100644
--- a/app/src/main/java/org/connectbot/ConsoleActivity.java
+++ b/app/src/main/java/org/connectbot/ConsoleActivity.java
@@ -46,10 +46,12 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
+import android.support.v4.view.MotionEventCompat;
import android.text.ClipboardManager;
import android.util.Log;
import android.view.ContextMenu;
import android.view.GestureDetector;
+import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -557,6 +559,15 @@ public class ConsoleActivity extends Activity {
public boolean onTouch(View v, MotionEvent event) {
+ // Automatically start copy mode if using a mouse.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
+ MotionEventCompat.getSource(event) == InputDevice.SOURCE_MOUSE &&
+ event.getAction() == MotionEvent.ACTION_DOWN &&
+ // Ignore right clicks.
+ event.getButtonState() == MotionEvent.BUTTON_PRIMARY) {
+ startCopyMode();
+ }
+
// when copying, highlight the area
if (copySource != null && copySource.isSelectingForCopy()) {
int row = (int) Math.floor(event.getY() / copySource.charHeight);
@@ -564,7 +575,7 @@ public class ConsoleActivity extends Activity {
SelectionArea area = copySource.getSelectionArea();
- switch(event.getAction()) {
+ switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// recording starting area
if (area.isSelectingOrigin()) {
@@ -636,7 +647,6 @@ public class ConsoleActivity extends Activity {
}
});
-
}
/**
@@ -711,19 +721,7 @@ public class ConsoleActivity extends Activity {
copy.setEnabled(activeTerminal);
copy.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- // mark as copying and reset any previous bounds
- TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
- copySource = terminalView.bridge;
-
- SelectionArea area = copySource.getSelectionArea();
- area.reset();
- area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows());
-
- copySource.setSelectingForCopy(true);
-
- // Make sure we show the initial selection
- copySource.redraw();
-
+ startCopyMode();
Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_start), Toast.LENGTH_LONG).show();
return true;
}
@@ -996,6 +994,21 @@ public class ConsoleActivity extends Activity {
unbindService(connection);
}
+ private void startCopyMode() {
+ // mark as copying and reset any previous bounds
+ TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
+ copySource = terminalView.bridge;
+
+ SelectionArea area = copySource.getSelectionArea();
+ area.reset();
+ area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows());
+
+ copySource.setSelectingForCopy(true);
+
+ // Make sure we show the initial selection
+ copySource.redraw();
+ }
+
protected void shiftCurrentTerminal(final int direction) {
View overlay;
synchronized (flip) {