Support clicking directly on a URL to open it
This allows you to click/press directly on a URL in the terminal view to open it. It takes priority over opening the keyboard, so if you click on a URL it is opened, and if you click anywhere else the keyboard opens like before. Currently, if the application in the terminal is tracking the mouse and you click on a URL, both actions happen. The mouse event is sent to the application, and the URL is also opened. To enable support for this, you have to set `terminal-onclick-url-open=true` in `termux.properties`.
This commit is contained in:
@@ -88,15 +88,19 @@ public class TextSelectionCursorController implements CursorController {
|
||||
}
|
||||
}
|
||||
|
||||
public void setInitialTextSelectionPosition(MotionEvent event) {
|
||||
public int[] getXAndYFromEvent(MotionEvent event) {
|
||||
int cx = (int) (event.getX() / terminalView.mRenderer.getFontWidth());
|
||||
final boolean eventFromMouse = event.isFromSource(InputDevice.SOURCE_MOUSE);
|
||||
// Offset for finger:
|
||||
final int SELECT_TEXT_OFFSET_Y = eventFromMouse ? 0 : -40;
|
||||
int cy = (int) ((event.getY() + SELECT_TEXT_OFFSET_Y) / terminalView.mRenderer.getFontLineSpacing()) + terminalView.getTopRow();
|
||||
return new int[] { cx, cy };
|
||||
}
|
||||
|
||||
mSelX1 = mSelX2 = cx;
|
||||
mSelY1 = mSelY2 = cy;
|
||||
public void setInitialTextSelectionPosition(MotionEvent event) {
|
||||
int[] xAndY = getXAndYFromEvent(event);
|
||||
mSelX1 = mSelX2 = xAndY[0];
|
||||
mSelY1 = mSelY2 = xAndY[1];
|
||||
|
||||
TerminalBuffer screen = terminalView.mEmulator.getScreen();
|
||||
if (!" ".equals(screen.getSelectedText(mSelX1, mSelY1, mSelX1, mSelY1))) {
|
||||
|
||||
Reference in New Issue
Block a user