From 4df75765634fd01d87da14eb646736c840fd549e Mon Sep 17 00:00:00 2001 From: morkt Date: Tue, 22 Dec 2015 09:18:18 +0400 Subject: [PATCH] spacebar moves selection to the next file in directory view. also, space is considered now when performing dynamic filename lookups (PreviewTextInput event isn't fired for space key). --- MainWindow.xaml | 4 ++++ MainWindow.xaml.cs | 31 +++++++++++++++++++++++++++++++ README.md | 1 + 3 files changed, 36 insertions(+) diff --git a/MainWindow.xaml b/MainWindow.xaml index b59af88b..ebf8345e 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -265,6 +265,7 @@ SelectionMode="Extended" Foreground="Black" AlternationCount="2" ContextMenu="{StaticResource lvDirContextMenu}" PreviewTextInput="lv_TextInput" IsSynchronizedWithCurrentItem="True" + PreviewKeyDown="lv_KeyDown" SelectionChanged="lv_SelectionChanged" GridViewColumnHeader.Click="lv_ColumnHeaderClicked"> @@ -274,6 +275,7 @@ + @@ -368,6 +370,7 @@ + @@ -375,6 +378,7 @@ + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 04886355..218900eb 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -588,12 +588,26 @@ namespace GARbro.GUI e.Handled = true; } + private void lv_KeyDown (object sender, KeyEventArgs e) + { + if (e.IsDown && Key.Space == e.Key && LookupActive) + { + LookupItem (" ", e.Timestamp); + e.Handled = true; + } + } + class InputData { public int LastTime = 0; public StringBuilder Phrase = new StringBuilder(); public bool Mismatch = false; + public bool LookupActive + { + get { return Phrase.Length > 0 && Environment.TickCount - LastTime < TextLookupTimeout; } + } + public void Reset () { Phrase.Clear (); @@ -605,6 +619,8 @@ namespace GARbro.GUI InputData m_current_input = new InputData(); + public bool LookupActive { get { return m_current_input.LookupActive; } } + /// /// Lookup item in listview pane by first letters of name. /// @@ -1147,6 +1163,20 @@ namespace GARbro.GUI CurrentDirectory.SelectAll(); } + void NextItemExec (object sender, ExecutedRoutedEventArgs e) + { + if (LookupActive) + return; + + var index = CurrentDirectory.SelectedIndex; + if (-1 == index) + index = 0; + else + ++index; + if (index < CurrentDirectory.Items.Count) + CurrentDirectory.SelectedIndex = index; + } + /// /// Handle "Exit" command. /// @@ -1351,5 +1381,6 @@ namespace GARbro.GUI public static readonly RoutedCommand AddSelection = new RoutedCommand(); public static readonly RoutedCommand SelectAll = new RoutedCommand(); public static readonly RoutedCommand SetFileType = new RoutedCommand(); + public static readonly RoutedCommand NextItem = new RoutedCommand(); } } diff --git a/README.md b/README.md index 33e6580e..ad8affe4 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ GUI Hotkeys Alt+ Go forward Ctrl+O Open file as archive Ctrl+A Select all files +Space Select next file Numpad + Select files matching specified mask F3 Create archive F4 Extract selected files