mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
Fix calculation of row number for selection and URL clicking
When calculating the row that is clicked, for mouse tracking mFontLineSpacingAndAscent was taken into account, but for selection and URL clicking it wasn't. This adds a common function for calculating the column and row which does take it into account and use that for all three. I'm not quite sure why it's necessary to subtract mFontLineSpacingAndAscent, but with this calculation the click location matches the line that is acted on for me with both touch and mouse and on different font sizes. It also removes the offset for finger the selection/url used because I don't think it's common for apps on Android to have such an offset, and because the mouse tracking did not use such an offset.
This commit is contained in:
@@ -177,8 +177,8 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
||||
TerminalEmulator term = mActivity.getCurrentSession().getEmulator();
|
||||
|
||||
if (mActivity.getProperties().shouldOpenTerminalTranscriptURLOnClick()) {
|
||||
int[] xAndY = mActivity.getTerminalView().getTextSelectionCursorController().getXAndYFromEvent(e);
|
||||
String wordAtTap = term.getScreen().getWordAtLocation(xAndY[0], xAndY[1]);
|
||||
int[] columnAndRow = mActivity.getTerminalView().getColumnAndRow(e, true);
|
||||
String wordAtTap = term.getScreen().getWordAtLocation(columnAndRow[0], columnAndRow[1]);
|
||||
LinkedHashSet<CharSequence> urlSet = UrlUtils.extractUrls(wordAtTap);
|
||||
|
||||
if (!urlSet.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user