mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
feature: select the cursor line by triple-click (#927)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
733ffe1af2
commit
aad42a8297
1 changed files with 46 additions and 6 deletions
|
@ -172,8 +172,11 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
|
var point = e.GetCurrentPoint(this);
|
||||||
|
|
||||||
if (_lastHover != null)
|
if (_lastHover != null)
|
||||||
{
|
{
|
||||||
|
var link = _lastHover.Link;
|
||||||
e.Pointer.Capture(null);
|
e.Pointer.Capture(null);
|
||||||
|
|
||||||
if (_lastHover.IsCommitSHA)
|
if (_lastHover.IsCommitSHA)
|
||||||
|
@ -181,9 +184,6 @@ namespace SourceGit.Views
|
||||||
var parentView = this.FindAncestorOfType<CommitBaseInfo>();
|
var parentView = this.FindAncestorOfType<CommitBaseInfo>();
|
||||||
if (parentView is { DataContext: ViewModels.CommitDetail detail })
|
if (parentView is { DataContext: ViewModels.CommitDetail detail })
|
||||||
{
|
{
|
||||||
var point = e.GetCurrentPoint(this);
|
|
||||||
var link = _lastHover.Link;
|
|
||||||
|
|
||||||
if (point.Properties.IsLeftButtonPressed)
|
if (point.Properties.IsLeftButtonPressed)
|
||||||
{
|
{
|
||||||
detail.NavigateTo(_lastHover.Link);
|
detail.NavigateTo(_lastHover.Link);
|
||||||
|
@ -217,9 +217,6 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var point = e.GetCurrentPoint(this);
|
|
||||||
var link = _lastHover.Link;
|
|
||||||
|
|
||||||
if (point.Properties.IsLeftButtonPressed)
|
if (point.Properties.IsLeftButtonPressed)
|
||||||
{
|
{
|
||||||
Native.OS.OpenBrowser(link);
|
Native.OS.OpenBrowser(link);
|
||||||
|
@ -255,6 +252,49 @@ namespace SourceGit.Views
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (point.Properties.IsLeftButtonPressed && e.ClickCount == 3)
|
||||||
|
{
|
||||||
|
var text = Inlines?.Text;
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
e.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var position = e.GetPosition(this) - new Point(Padding.Left, Padding.Top);
|
||||||
|
var x = Math.Min(Math.Max(position.X, 0), Math.Max(TextLayout.WidthIncludingTrailingWhitespace, 0));
|
||||||
|
var y = Math.Min(Math.Max(position.Y, 0), Math.Max(TextLayout.Height, 0));
|
||||||
|
position = new Point(x, y);
|
||||||
|
|
||||||
|
var textPos = TextLayout.HitTestPoint(position).TextPosition;
|
||||||
|
var lineStart = 0;
|
||||||
|
var lineEnd = text.IndexOf('\n', lineStart);
|
||||||
|
if (lineEnd <= 0)
|
||||||
|
{
|
||||||
|
lineEnd = text.Length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (lineEnd < textPos)
|
||||||
|
{
|
||||||
|
lineStart = lineEnd + 1;
|
||||||
|
lineEnd = text.IndexOf('\n', lineStart);
|
||||||
|
if (lineEnd == -1)
|
||||||
|
{
|
||||||
|
lineEnd = text.Length;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCurrentValue(SelectionStartProperty, lineStart);
|
||||||
|
SetCurrentValue(SelectionEndProperty, lineEnd);
|
||||||
|
|
||||||
|
e.Pointer.Capture(this);
|
||||||
|
e.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
base.OnPointerPressed(e);
|
base.OnPointerPressed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue