mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 05:10:25 +08:00
refactor: standalone commit message editor (#2096)
- Clicking `OK` button will apply the modified message and exit with code `0` - Clicking `CANCEL` or pressing `ESC` will not apply the modified message and exit with code `-1` - Clicking the window caption button `X` will not apply the modified message and exit with code `0` Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -37,12 +37,20 @@
|
||||
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="8">
|
||||
<v:CommitMessageToolBox x:Name="Editor" Height="400"/>
|
||||
<Button Classes="flat primary"
|
||||
Width="80"
|
||||
Margin="0,8,0,4"
|
||||
Content="{DynamicResource Text.Sure}"
|
||||
Click="SaveAndClose"
|
||||
HorizontalAlignment="Center"/>
|
||||
|
||||
<StackPanel Margin="0,8,0,4" Orientation="Horizontal" HorizontalAlignment="Center" Spacing="8">
|
||||
<Button Classes="flat primary"
|
||||
Width="80"
|
||||
Content="{DynamicResource Text.Sure}"
|
||||
Click="SaveAndClose"
|
||||
HorizontalAlignment="Center"/>
|
||||
<Button Classes="flat"
|
||||
Width="80"
|
||||
Content="{DynamicResource Text.Cancel}"
|
||||
Click="CancelAndClose"
|
||||
HotKey="Escape"
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</v:ChromelessWindow>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
@@ -15,7 +16,6 @@ namespace SourceGit.Views
|
||||
|
||||
public CommitMessageEditor()
|
||||
{
|
||||
CloseOnESC = true;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -67,12 +67,17 @@ namespace SourceGit.Views
|
||||
private void SaveAndClose(object _1, RoutedEventArgs _2)
|
||||
{
|
||||
_onSave?.Invoke(Editor.CommitMessage);
|
||||
_exitCode = 0;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CancelAndClose(object _1, RoutedEventArgs _2)
|
||||
{
|
||||
_exitCode = -1;
|
||||
Close();
|
||||
}
|
||||
|
||||
private Action<string> _onSave = null;
|
||||
private bool _shouldExitApp = true;
|
||||
private int _exitCode = -1;
|
||||
private int _exitCode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user