mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
feature: add hotkeys to move interactive rebase item up and down (#557)
This commit is contained in:
parent
adca61c538
commit
b9a24ceb53
10 changed files with 83 additions and 45 deletions
|
@ -359,8 +359,6 @@
|
|||
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">Interaktiver Rebase</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">Ziel Branch:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">Auf:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveUp" xml:space="preserve">Hochschieben</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveDown" xml:space="preserve">Runterschieben</x:String>
|
||||
<x:String x:Key="Text.Launcher" xml:space="preserve">Source Git</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">FEHLER</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">INFO</x:String>
|
||||
|
|
|
@ -357,8 +357,6 @@
|
|||
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">Interactive Rebase</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">Target Branch:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">On:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveUp" xml:space="preserve">Move Up</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveDown" xml:space="preserve">Move Down</x:String>
|
||||
<x:String x:Key="Text.Launcher" xml:space="preserve">Source Git</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">ERROR</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">NOTICE</x:String>
|
||||
|
|
|
@ -345,8 +345,6 @@
|
|||
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">Interactive Rebase</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">Target Branch:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">On:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveUp" xml:space="preserve">Move Up</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveDown" xml:space="preserve">Move Down</x:String>
|
||||
<x:String x:Key="Text.Launcher" xml:space="preserve">Source Git</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">ERROR</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">NOTICE</x:String>
|
||||
|
|
|
@ -340,8 +340,6 @@
|
|||
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">Rebase Interativo</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">Ramo Alvo:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">Em:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveUp" xml:space="preserve">Mover Para Cima</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveDown" xml:space="preserve">Mover Para Baixo</x:String>
|
||||
<x:String x:Key="Text.Launcher" xml:space="preserve">Source Git</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">ERRO</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">AVISO</x:String>
|
||||
|
|
|
@ -359,8 +359,6 @@
|
|||
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">Интерактивное перемещение</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">Целевая ветка:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">На:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveUp" xml:space="preserve">Вверх</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveDown" xml:space="preserve">Вниз</x:String>
|
||||
<x:String x:Key="Text.Launcher" xml:space="preserve">Source Git</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">ОШИБКА</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">УВЕДОМЛЕНИЕ</x:String>
|
||||
|
|
|
@ -360,8 +360,6 @@
|
|||
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">交互式变基</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">目标分支 :</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">起始提交 :</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveUp" xml:space="preserve">向上移动</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveDown" xml:space="preserve">向下移动</x:String>
|
||||
<x:String x:Key="Text.Launcher" xml:space="preserve">Source Git</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">出错了</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">系统提示</x:String>
|
||||
|
|
|
@ -360,8 +360,6 @@
|
|||
<x:String x:Key="Text.InteractiveRebase" xml:space="preserve">互動式重定基底</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.Target" xml:space="preserve">目標分支:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.On" xml:space="preserve">起始提交:</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveUp" xml:space="preserve">向上移動</x:String>
|
||||
<x:String x:Key="Text.InteractiveRebase.MoveDown" xml:space="preserve">向下移動</x:String>
|
||||
<x:String x:Key="Text.Launcher" xml:space="preserve">Source Git</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">發生錯誤</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">系統提示</x:String>
|
||||
|
|
|
@ -140,6 +140,7 @@ namespace SourceGit.ViewModels
|
|||
var prev = Items[idx - 1];
|
||||
Items.RemoveAt(idx - 1);
|
||||
Items.Insert(idx, prev);
|
||||
SelectedItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,6 +152,7 @@ namespace SourceGit.ViewModels
|
|||
var next = Items[idx + 1];
|
||||
Items.RemoveAt(idx + 1);
|
||||
Items.Insert(idx, next);
|
||||
SelectedItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,14 +59,14 @@
|
|||
<!-- Body -->
|
||||
<Border Grid.Row="2" Margin="8,0,8,8" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">
|
||||
<Grid RowDefinitions="*,3,*">
|
||||
<ListBox Grid.Row="0"
|
||||
Background="{DynamicResource Brush.Contents}"
|
||||
ItemsSource="{Binding Items}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
KeyDown="OnItemsListBoxKeyDown">
|
||||
<v:InteractiveRebaseListBox Grid.Row="0"
|
||||
Focusable="True"
|
||||
Background="{DynamicResource Brush.Contents}"
|
||||
ItemsSource="{Binding Items}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
|
@ -213,18 +213,18 @@
|
|||
<TextBlock Grid.Column="6" Classes="primary" Text="{Binding Commit.CommitterTimeStr}" Margin="8,0"/>
|
||||
|
||||
<!-- MoveUp Button -->
|
||||
<Button Grid.Column="7" Classes="icon_button" Click="OnMoveItemUp" ToolTip.Tip="{DynamicResource Text.InteractiveRebase.MoveUp}">
|
||||
<Button Grid.Column="7" Classes="icon_button" Click="OnMoveItemUp" ToolTip.Tip="Alt+Up">
|
||||
<Path Width="14" Height="14" Margin="0,4,0,0" Data="{StaticResource Icons.Up}"/>
|
||||
</Button>
|
||||
|
||||
<!-- MoveDown Button -->
|
||||
<Button Grid.Column="8" Classes="icon_button" Click="OnMoveItemDown" ToolTip.Tip="{DynamicResource Text.InteractiveRebase.MoveDown}">
|
||||
<Button Grid.Column="8" Classes="icon_button" Click="OnMoveItemDown" ToolTip.Tip="Alt+Down">
|
||||
<Path Width="14" Height="14" Margin="0,4,0,0" Data="{StaticResource Icons.Down}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</v:InteractiveRebaseListBox>
|
||||
|
||||
<v:LoadingIcon Grid.Row="0" Width="48" Height="48" HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="{Binding IsLoading}"/>
|
||||
|
||||
|
|
|
@ -1,9 +1,79 @@
|
|||
using System;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public class InteractiveRebaseListBox : ListBox
|
||||
{
|
||||
protected override Type StyleKeyOverride => typeof(ListBox);
|
||||
|
||||
/// <summary>
|
||||
/// Prevent ListBox handle the arrow keys.
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
var vm = DataContext as ViewModels.InteractiveRebase;
|
||||
if (vm == null)
|
||||
return;
|
||||
|
||||
var item = vm.SelectedItem;
|
||||
if (item == null)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.P)
|
||||
{
|
||||
item.SetAction(Models.InteractiveRebaseAction.Pick);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.E)
|
||||
{
|
||||
item.SetAction(Models.InteractiveRebaseAction.Edit);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.R)
|
||||
{
|
||||
item.SetAction(Models.InteractiveRebaseAction.Reword);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.S)
|
||||
{
|
||||
item.SetAction(Models.InteractiveRebaseAction.Squash);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.F)
|
||||
{
|
||||
item.SetAction(Models.InteractiveRebaseAction.Fixup);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.D)
|
||||
{
|
||||
item.SetAction(Models.InteractiveRebaseAction.Drop);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.KeyModifiers == KeyModifiers.Alt && e.Key == Key.Up)
|
||||
{
|
||||
vm.MoveItemUp(item);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.KeyModifiers == KeyModifiers.Alt && e.Key == Key.Down)
|
||||
{
|
||||
vm.MoveItemDown(item);
|
||||
e.Handled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class InteractiveRebase : ChromelessWindow
|
||||
{
|
||||
public InteractiveRebase()
|
||||
|
@ -89,26 +159,6 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void OnItemsListBoxKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
var item = (sender as ListBox)?.SelectedItem as ViewModels.InteractiveRebaseItem;
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.P)
|
||||
item.SetAction(Models.InteractiveRebaseAction.Pick);
|
||||
else if (e.Key == Key.E)
|
||||
item.SetAction(Models.InteractiveRebaseAction.Edit);
|
||||
else if (e.Key == Key.R)
|
||||
item.SetAction(Models.InteractiveRebaseAction.Reword);
|
||||
else if (e.Key == Key.S)
|
||||
item.SetAction(Models.InteractiveRebaseAction.Squash);
|
||||
else if (e.Key == Key.F)
|
||||
item.SetAction(Models.InteractiveRebaseAction.Fixup);
|
||||
else if (e.Key == Key.D)
|
||||
item.SetAction(Models.InteractiveRebaseAction.Drop);
|
||||
}
|
||||
|
||||
private async void StartJobs(object _1, RoutedEventArgs _2)
|
||||
{
|
||||
var vm = DataContext as ViewModels.InteractiveRebase;
|
||||
|
|
Loading…
Reference in a new issue