diff --git a/Changelog.md b/Changelog.md index 91cd6f6..5fde3c2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,8 +4,11 @@ [mpv-repl](https://github.com/rossy/mpv-repl) is currently the best choice - many [wiki pages](https://github.com/stax76/mpv.net/wiki) were improved - the logo/icon had a very small cosmetic change -- the help in the context menu was improved +- the help in the context menu was improved, + for quick access consider the command palette (F1 key) - config options specific to mpv.net are now available from the command line +- the input editor no longer as known limitations, 'alt gr' and ctrl+alt are working now +- the help in the input editor was simplified and the filter logic was improved ### 5.0 diff --git a/mpv.net/WPF/InputWindow.xaml.cs b/mpv.net/WPF/InputWindow.xaml.cs index 18e4161..61a07f1 100644 --- a/mpv.net/WPF/InputWindow.xaml.cs +++ b/mpv.net/WPF/InputWindow.xaml.cs @@ -48,16 +48,21 @@ namespace mpvnet CollectionView.Refresh(); if (SearchControl.SearchTextBox.Text == "?") - Msg.Show("Filtering works by searching in the Input, Menu and Command but it's possible to reduce the filter scope to either of Input, Menu or Command by prefixing as follows:\n\ni \ni: \n\nm \nm: \n\nc \nc: \n\nIf only one character is entered the search will be performed only in the input.", "Filtering"); + { + SearchControl.SearchTextBox.Text = ""; + Msg.Show("Filtering", "Reduce the filter scope with:\n\ni input\n\nm menu\n\nc command\n\nIf only one character is entered input search is performed."); + } } bool Filter(CommandItem item) { if (item.Command == "") return false; string searchText = SearchControl.SearchTextBox.Text.ToLower(); - if (searchText == "") return true; + if (searchText == "" || searchText == "?") return true; - if (searchText.StartsWith("i ") || searchText.StartsWith("i:") || searchText.Length == 1) + if (searchText.Length == 1) + return item.Input.ToLower().Replace("ctrl+", "").Replace("shift+", "").Replace("alt+", "") == searchText.ToLower(); + else if (searchText.StartsWith("i ") || searchText.StartsWith("i:") || searchText.Length == 1) { if (searchText.Length > 1) searchText = searchText.Substring(2).Trim(); diff --git a/mpv.net/WPF/LearnWindow.xaml b/mpv.net/WPF/LearnWindow.xaml index d1e3ca5..021cf22 100644 --- a/mpv.net/WPF/LearnWindow.xaml +++ b/mpv.net/WPF/LearnWindow.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Title="Learn Input" Height="200" Width="400" WindowStartupLocation="CenterOwner" - ResizeMode="NoResize" Loaded="Window_Loaded" Background="Black" MouseWheel="Window_MouseWheel" MouseUp="Window_MouseUp" MouseDoubleClick="Window_MouseDoubleClick"> + ResizeMode="NoResize" Loaded="Window_Loaded" Background="Black" MouseWheel="Window_MouseWheel" MouseUp="Window_MouseUp" MouseDoubleClick="Window_MouseDoubleClick" TextInput="Window_TextInput"> diff --git a/mpv.net/WPF/LearnWindow.xaml.cs b/mpv.net/WPF/LearnWindow.xaml.cs index 5506e29..5e9c628 100644 --- a/mpv.net/WPF/LearnWindow.xaml.cs +++ b/mpv.net/WPF/LearnWindow.xaml.cs @@ -10,7 +10,8 @@ namespace mpvnet public partial class LearnWindow : Window { public CommandItem InputItem { get; set; } - public string NewKey { get; set; } = ""; + string NewKey = ""; + string KeyChar = ""; public LearnWindow() => InitializeComponent(); @@ -60,9 +61,9 @@ namespace mpvnet case WF.Keys.NumPad9: text = "KP" + e.KeyCode.ToString()[6].ToString(); break; case WF.Keys.Space: - text = "SPACE"; break; + text = "Space"; break; case WF.Keys.Enter: - text = "ENTER"; break; + text = "Enter"; break; case WF.Keys.Tab: text = "TAB"; break; case WF.Keys.Back: @@ -72,7 +73,7 @@ namespace mpvnet case WF.Keys.Insert: text = "INS"; break; case WF.Keys.Home: - text = "HOME"; break; + text = "Home"; break; case WF.Keys.End: text = "END"; break; case WF.Keys.PageUp: @@ -82,56 +83,56 @@ namespace mpvnet case WF.Keys.Escape: text = "ESC"; break; case WF.Keys.PrintScreen: - text = "PRINT"; break; + text = "Print"; break; case WF.Keys.Play: - text = "PLAY"; break; + text = "Play"; break; case WF.Keys.Pause: - text = "PAUSE"; break; + text = "Pause"; break; case WF.Keys.MediaPlayPause: - text = "PLAYPAUSE"; break; + text = "PlayPause"; break; case WF.Keys.MediaStop: - text = "STOP"; break; + text = "Stop"; break; case WF.Keys.MediaNextTrack: - text = "NEXT"; break; + text = "Next"; break; case WF.Keys.MediaPreviousTrack: - text = "PREV"; break; + text = "Prev"; break; case WF.Keys.VolumeUp: - text = "VOLUME_UP"; break; + text = "Volume_Up"; break; case WF.Keys.VolumeDown: - text = "VOLUME_DOWN"; break; + text = "Volume_Down"; break; case WF.Keys.VolumeMute: - text = "MUTE"; break; + text = "Mute"; break; case WF.Keys.BrowserHome: - text = "HOMEPAGE"; break; + text = "Homepage"; break; case WF.Keys.LaunchMail: - text = "MAIL"; break; + text = "Mail"; break; case WF.Keys.BrowserFavorites: - text = "FAVORITES"; break; + text = "Favorites"; break; case WF.Keys.BrowserSearch: - text = "SEARCH"; break; + text = "Search"; break; case WF.Keys.Sleep: - text = "SLEEP"; break; + text = "Sleep"; break; case WF.Keys.Cancel: - text = "CANCEL"; break; + text = "Cancel"; break; } - bool shiftWasHandled = false; + bool wasModified = false; bool isAlt = GetKeyState(18) < (short)0; bool isShift = GetKeyState(16) < (short)0; bool isCtrl = GetKeyState(17) < (short)0; - if (text.Length == 1 && isShift && text[0] != GetModifiedKey(text[0])) + if (text.Length == 1 && KeyChar != text) { - text = GetModifiedKey(text[0]).ToString(); - shiftWasHandled = true; + text = KeyChar; + wasModified = true; } - if (text == "#") text = "Sharp"; + if (text == "#") text = "SHARP"; - if (isAlt) text = "Alt+" + text; - if (isShift && !shiftWasHandled) text = "Shift+" + text; - if (isCtrl) text = "Ctrl+" + text; + if (isAlt && !wasModified) text = "ALT+" + text; + if (isShift && !wasModified) text = "SHIFT+" + text; + if (isCtrl && !wasModified) text = "CTRL+" + text; if (!string.IsNullOrEmpty(text)) SetKey(text); @@ -163,24 +164,6 @@ namespace mpvnet } } - public static char GetModifiedKey(char c) - { - short vkKeyScanResult = VkKeyScan(c); - - if (vkKeyScanResult == -1) - return c; - - uint code = (uint)vkKeyScanResult & 0xff; - byte[] b = new byte[256]; - b[0x10] = 0x80; - uint r; - - if (1 != ToAscii(code, code, b, out r, 0)) - return c; - - return (char)r; - } - void ProcessKeyEventArgs(ref WF.Message m) { int WM_KEYUP = 0x0101, WM_SYSKEYUP = 0x0105, WM_APPCOMMAND = 0x0319; @@ -382,5 +365,10 @@ namespace mpvnet BlockMBTN_LEFT = true; } } + + private void Window_TextInput(object sender, TextCompositionEventArgs e) + { + KeyChar = e.Text; + } } } \ No newline at end of file