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).
This commit is contained in:
morkt 2015-12-22 09:18:18 +04:00
parent 87dd1792ce
commit 4df7576563
3 changed files with 36 additions and 0 deletions

View File

@ -265,6 +265,7 @@
SelectionMode="Extended" Foreground="Black" AlternationCount="2" SelectionMode="Extended" Foreground="Black" AlternationCount="2"
ContextMenu="{StaticResource lvDirContextMenu}" ContextMenu="{StaticResource lvDirContextMenu}"
PreviewTextInput="lv_TextInput" IsSynchronizedWithCurrentItem="True" PreviewTextInput="lv_TextInput" IsSynchronizedWithCurrentItem="True"
PreviewKeyDown="lv_KeyDown"
SelectionChanged="lv_SelectionChanged" SelectionChanged="lv_SelectionChanged"
GridViewColumnHeader.Click="lv_ColumnHeaderClicked"> GridViewColumnHeader.Click="lv_ColumnHeaderClicked">
<ListView.Resources> <ListView.Resources>
@ -274,6 +275,7 @@
<KeyBinding Key="Enter" Command="{x:Static local:Commands.OpenItem}"/> <KeyBinding Key="Enter" Command="{x:Static local:Commands.OpenItem}"/>
<KeyBinding Gesture="Ctrl+E" Command="{x:Static local:Commands.ExploreItem}"/> <KeyBinding Gesture="Ctrl+E" Command="{x:Static local:Commands.ExploreItem}"/>
<KeyBinding Gesture="F2" Command="{x:Static local:Commands.RenameItem}"/> <KeyBinding Gesture="F2" Command="{x:Static local:Commands.RenameItem}"/>
<KeyBinding Gesture="Space" Command="{x:Static local:Commands.NextItem}"/>
<MouseBinding Gesture="LeftDoubleClick" Command="{x:Static local:Commands.OpenItem}" /> <MouseBinding Gesture="LeftDoubleClick" Command="{x:Static local:Commands.OpenItem}" />
</ListView.InputBindings> </ListView.InputBindings>
<ListView.ItemContainerStyle> <ListView.ItemContainerStyle>
@ -368,6 +370,7 @@
<KeyBinding Gesture="F6" Command="{x:Static local:Commands.ConvertMedia}"/> <KeyBinding Gesture="F6" Command="{x:Static local:Commands.ConvertMedia}"/>
<KeyBinding Gesture="Delete" Command="{x:Static local:Commands.DeleteItem}"/> <KeyBinding Gesture="Delete" Command="{x:Static local:Commands.DeleteItem}"/>
<KeyBinding Gesture="Add" Command="{x:Static local:Commands.AddSelection}"/> <KeyBinding Gesture="Add" Command="{x:Static local:Commands.AddSelection}"/>
<KeyBinding Gesture="Space" Command="{x:Static local:Commands.NextItem}"/>
</Window.InputBindings> </Window.InputBindings>
<Window.CommandBindings> <Window.CommandBindings>
<CommandBinding Command="{x:Static local:Commands.OpenItem}" Executed="OpenItemExec" CanExecute="CanExecuteOnSelected"/> <CommandBinding Command="{x:Static local:Commands.OpenItem}" Executed="OpenItemExec" CanExecute="CanExecuteOnSelected"/>
@ -375,6 +378,7 @@
<CommandBinding Command="{x:Static local:Commands.OpenRecent}" Executed="OpenRecentExec" CanExecute="CanExecuteAlways"/> <CommandBinding Command="{x:Static local:Commands.OpenRecent}" Executed="OpenRecentExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.AddSelection}" Executed="AddSelectionExec" CanExecute="CanExecuteAlways"/> <CommandBinding Command="{x:Static local:Commands.AddSelection}" Executed="AddSelectionExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.SelectAll}" Executed="SelectAllExec" CanExecute="CanExecuteAlways"/> <CommandBinding Command="{x:Static local:Commands.SelectAll}" Executed="SelectAllExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.NextItem}" Executed="NextItemExec" CanExecute="CanExecuteAlways"/>
<CommandBinding Command="{x:Static local:Commands.ExtractItem}" Executed="ExtractItemExec" CanExecute="CanExecuteExtract"/> <CommandBinding Command="{x:Static local:Commands.ExtractItem}" Executed="ExtractItemExec" CanExecute="CanExecuteExtract"/>
<CommandBinding Command="{x:Static local:Commands.CreateArchive}" Executed="CreateArchiveExec" CanExecute="CanExecuteCreateArchive"/> <CommandBinding Command="{x:Static local:Commands.CreateArchive}" Executed="CreateArchiveExec" CanExecute="CanExecuteCreateArchive"/>
<CommandBinding Command="{x:Static local:Commands.DeleteItem}" Executed="DeleteItemExec" CanExecute="CanExecuteOnPhysicalFile" /> <CommandBinding Command="{x:Static local:Commands.DeleteItem}" Executed="DeleteItemExec" CanExecute="CanExecuteOnPhysicalFile" />

View File

@ -588,12 +588,26 @@ namespace GARbro.GUI
e.Handled = true; 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 class InputData
{ {
public int LastTime = 0; public int LastTime = 0;
public StringBuilder Phrase = new StringBuilder(); public StringBuilder Phrase = new StringBuilder();
public bool Mismatch = false; public bool Mismatch = false;
public bool LookupActive
{
get { return Phrase.Length > 0 && Environment.TickCount - LastTime < TextLookupTimeout; }
}
public void Reset () public void Reset ()
{ {
Phrase.Clear (); Phrase.Clear ();
@ -605,6 +619,8 @@ namespace GARbro.GUI
InputData m_current_input = new InputData(); InputData m_current_input = new InputData();
public bool LookupActive { get { return m_current_input.LookupActive; } }
/// <summary> /// <summary>
/// Lookup item in listview pane by first letters of name. /// Lookup item in listview pane by first letters of name.
/// </summary> /// </summary>
@ -1147,6 +1163,20 @@ namespace GARbro.GUI
CurrentDirectory.SelectAll(); 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;
}
/// <summary> /// <summary>
/// Handle "Exit" command. /// Handle "Exit" command.
/// </summary> /// </summary>
@ -1351,5 +1381,6 @@ namespace GARbro.GUI
public static readonly RoutedCommand AddSelection = new RoutedCommand(); public static readonly RoutedCommand AddSelection = new RoutedCommand();
public static readonly RoutedCommand SelectAll = new RoutedCommand(); public static readonly RoutedCommand SelectAll = new RoutedCommand();
public static readonly RoutedCommand SetFileType = new RoutedCommand(); public static readonly RoutedCommand SetFileType = new RoutedCommand();
public static readonly RoutedCommand NextItem = new RoutedCommand();
} }
} }

View File

@ -19,6 +19,7 @@ GUI Hotkeys
<tr><td><kbd>Alt</kbd>+<kbd>&rarr;</kbd></td><td> Go forward</td></tr> <tr><td><kbd>Alt</kbd>+<kbd>&rarr;</kbd></td><td> Go forward</td></tr>
<tr><td><kbd>Ctrl</kbd>+<kbd>O</kbd></td><td> Open file as archive</td></tr> <tr><td><kbd>Ctrl</kbd>+<kbd>O</kbd></td><td> Open file as archive</td></tr>
<tr><td><kbd>Ctrl</kbd>+<kbd>A</kbd></td><td> Select all files</td></tr> <tr><td><kbd>Ctrl</kbd>+<kbd>A</kbd></td><td> Select all files</td></tr>
<tr><td><kbd>Space</kbd></td><td> Select next file</td></tr>
<tr><td><kbd>Numpad +</kbd></td><td> Select files matching specified mask</td></tr> <tr><td><kbd>Numpad +</kbd></td><td> Select files matching specified mask</td></tr>
<tr><td><kbd>F3</kbd></td><td> Create archive</td></tr> <tr><td><kbd>F3</kbd></td><td> Create archive</td></tr>
<tr><td><kbd>F4</kbd></td><td> Extract selected files</td></tr> <tr><td><kbd>F4</kbd></td><td> Extract selected files</td></tr>