Compare commits

...

2 commits

Author SHA1 Message Date
leo
19e930ef40
refactor: change hotkeys of commit buttons (#521)
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
* Ctrl+Shift+Enter to stage all changes then commit
* Alt+Enter to commit and push
2024-09-28 11:40:15 +08:00
leo
841a009a56
ux: change cursor to Hand when hover a commit hash link (#522) 2024-09-28 11:25:17 +08:00
7 changed files with 59 additions and 31 deletions

View file

@ -623,8 +623,7 @@
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">COMMIT &amp; PUSH</x:String>
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" xml:space="preserve">Template/Histories</x:String>
<x:String x:Key="Text.WorkingCopy.CommitTip" xml:space="preserve">CTRL + Enter</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">Use 'Alt+Enter' to stage all changes and commit</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage.MacOS" xml:space="preserve">Use '⌥+Enter' to stage all changes and commit</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">Use 'Ctrl(⌘)+Shift+Enter' to stage all changes and commit</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">CONFLICTS DETECTED</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">FILE CONFLICTS ARE RESOLVED</x:String>
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">INCLUDE UNTRACKED FILES</x:String>

View file

@ -621,8 +621,7 @@
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">提交并推送</x:String>
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" xml:space="preserve">历史输入/模板</x:String>
<x:String x:Key="Text.WorkingCopy.CommitTip" xml:space="preserve">CTRL + Enter</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">使用 Alt+Enter 自动暂存所有变更并提交</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage.MacOS" xml:space="preserve">使用 ⌥+Enter 自动暂存所有变更并提交</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">使用 Ctrl(⌘)+Shift+Enter 自动暂存所有变更并提交</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">检测到冲突</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">文件冲突已解决</x:String>
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">显示未跟踪文件</x:String>

View file

@ -626,8 +626,7 @@
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">提交並推送</x:String>
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" xml:space="preserve">歷史輸入/範本</x:String>
<x:String x:Key="Text.WorkingCopy.CommitTip" xml:space="preserve">CTRL + Enter</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">使用 Alt+Enter 自動暫存全部變更並提交</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage.MacOS" xml:space="preserve">使用 ⌥+Enter 自動暫存全部變更並提交</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">使用 Ctrl(⌘)+Shift+Enter 自動暫存全部變更並提交</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">檢測到衝突</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">檔案衝突已解決</x:String>
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">顯示未追蹤檔案</x:String>

View file

@ -33,7 +33,7 @@ namespace SourceGit.Views
return;
var view = TextView;
if (view != null && view.VisualLinesValid)
if (view is { VisualLinesValid: true })
{
var typeface = view.CreateTypeface();
var underlinePen = new Pen(Brushes.DarkOrange);
@ -142,12 +142,53 @@ namespace SourceGit.Views
return new Size(maxWidth, 0);
}
protected override void OnPointerMoved(PointerEventArgs e)
{
base.OnPointerMoved(e);
var view = TextView;
if (!e.Handled && view is { VisualLinesValid: true })
{
var pos = e.GetPosition(this);
var typeface = view.CreateTypeface();
foreach (var line in view.VisualLines)
{
if (line.IsDisposed || line.FirstDocumentLine == null || line.FirstDocumentLine.IsDeleted)
continue;
var lineNumber = line.FirstDocumentLine.LineNumber;
if (lineNumber >= _editor.BlameData.LineInfos.Count)
break;
var info = _editor.BlameData.LineInfos[lineNumber - 1];
var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset;
var shaLink = new FormattedText(
info.CommitSHA,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
typeface,
_editor.FontSize,
Brushes.DarkOrange);
var rect = new Rect(0, y, shaLink.Width, shaLink.Height);
if (rect.Contains(pos))
{
Cursor = Cursor.Parse("Hand");
return;
}
}
}
Cursor = Cursor.Default;
}
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
base.OnPointerPressed(e);
var view = TextView;
if (!e.Handled && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && view != null && view.VisualLinesValid)
if (!e.Handled && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && view is { VisualLinesValid: true })
{
var pos = e.GetPosition(this);
var typeface = view.CreateTypeface();

View file

@ -87,6 +87,7 @@
<TextBlock Grid.Column="2"
Classes="primary"
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
Cursor="Hand"
Background="Transparent"
Foreground="DarkOrange"
TextDecorations="Underline"

View file

@ -103,10 +103,10 @@
<TextBlock Grid.Row="7" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"/>
<TextBlock Grid.Row="7" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.Commit}" />
<TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Alt+Enter, macOS=⌥+Enter}"/>
<TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+Enter, macOS=⌘+⇧+Enter}"/>
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.CommitWithAutoStage}" />
<TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+Enter, macOS=⌘+⇧+Enter}"/>
<TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Alt+Enter, macOS=⌥+Enter}"/>
<TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.CommitAndPush}" />
<TextBlock Grid.Row="10" Grid.Column="0" Classes="primary bold" Text="F5"/>

View file

@ -226,32 +226,21 @@
ToolTip.Placement="Top"
ToolTip.VerticalOffset="0">
<ToolTip.Tip>
<StackPanel Orientation="Vertical">
<TextBlock Text="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"/>
<TextBlock Classes="small italic"
Margin="0,4,0,0"
Foreground="{DynamicResource Brush.FG2}">
<TextBlock.Text>
<OnPlatform>
<On Options="Windows, Linux">
<DynamicResource ResourceKey="Text.WorkingCopy.CommitWithAutoStage"/>
</On>
<On Options="macOS">
<DynamicResource ResourceKey="Text.WorkingCopy.CommitWithAutoStage.MacOS"/>
</On>
</OnPlatform>
</TextBlock.Text>
<TextBlock TextWrapping="Wrap" TextAlignment="Left">
<Run Text="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"/>
<Run Foreground="{DynamicResource Brush.FG2}"
FontSize="12"
Text="{DynamicResource Text.WorkingCopy.CommitWithAutoStage}"/>
</TextBlock>
</StackPanel>
</ToolTip.Tip>
</Button>
<!-- Invisible button just to add another hotkey `Alt+Enter/⌥+Enter` to commit with auto-stage -->
<!-- Invisible button just to add another hotkey `Ctrl+Shift+Enter` to commit with auto-stage -->
<Button Grid.Column="7"
Width="0" Height="0"
Background="Transparent"
Command="{Binding CommitWithAutoStage}"
HotKey="Alt+Enter"/>
HotKey="{OnPlatform Ctrl+Shift+Enter, macOS=⌘+Shift+Enter}"/>
<Button Grid.Column="8"
Classes="flat"
@ -260,8 +249,8 @@
Margin="8,0,0,0"
Padding="8,0"
Command="{Binding CommitWithPush}"
HotKey="{OnPlatform Ctrl+Shift+Enter, macOS=⌘+Shift+Enter}"
ToolTip.Tip="{OnPlatform Ctrl+Shift+Enter, macOS=⌘+Shift+Enter}"
HotKey="Alt+Enter"
ToolTip.Tip="{OnPlatform Alt+Enter, macOS=⌥+Enter}"
ToolTip.Placement="Top"
ToolTip.VerticalOffset="0"
IsVisible="{Binding IsCommitWithPushVisible}"/>