From 49f22a1f81a0a9ef68fb033ce3026827661408aa Mon Sep 17 00:00:00 2001 From: stax76 Date: Wed, 13 Dec 2023 03:38:23 +0100 Subject: [PATCH] misc --- docs/changelog.md | 1 + docs/manual.md | 4 ++++ src/MpvNet.Windows/WPF/InputWindow.xaml.cs | 2 +- src/MpvNet/App.cs | 2 ++ src/MpvNet/InputConf.cs | 2 +- src/MpvNet/InputHelp.cs | 21 +++++++-------------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index f5e1034f..58a44d7b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,6 +5,7 @@ - Fix certain binding setups shown poorly or incorrect in the main menu. - Fix conf editor not remembering the search text. - Fix quit-watch-later not working. +- New option `menu-syntax`. Default: `#menu:` - New zhongfly libmpv build. # v7.0.0.1 Beta (2023-12-11) diff --git a/docs/manual.md b/docs/manual.md index e2ead78b..e5de3910 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -390,6 +390,10 @@ For single files automatically load the entire directory into the playlist. ### General +#### --menu-syntax=\ + +Used menu syntax, typically `#menu:` or `#!`. Default: `#menu:` + #### --process-instance=\ Defines if more then one mpv.net process is allowed. diff --git a/src/MpvNet.Windows/WPF/InputWindow.xaml.cs b/src/MpvNet.Windows/WPF/InputWindow.xaml.cs index fa2a0793..9d6a52b8 100644 --- a/src/MpvNet.Windows/WPF/InputWindow.xaml.cs +++ b/src/MpvNet.Windows/WPF/InputWindow.xaml.cs @@ -109,7 +109,7 @@ void Window_Closed(object sender, EventArgs e) else { newContent = InputHelp.ConvertToString(InputHelp.GetReducedBindings(Bindings)); - newContent = newContent.Replace("#menu: ", "# "); + newContent = newContent.Replace(App.MenuSyntax + " ", "# "); File.WriteAllText(App.InputConf.Path, App.InputConf.Content = newContent); } diff --git a/src/MpvNet/App.cs b/src/MpvNet/App.cs index 807cf74a..e6e7b81f 100644 --- a/src/MpvNet/App.cs +++ b/src/MpvNet/App.cs @@ -20,6 +20,7 @@ public class AppClass public string StartSize { get; set; } = "height-session"; public string Language { get; set; } = "system"; public string CommandLine { get; set; } = Environment.CommandLine; + public string MenuSyntax { get; set; } = "#menu:"; public bool AutoLoadFolder { get; set; } = true; public bool DebugMode { get; set; } @@ -145,6 +146,7 @@ public bool ProcessProperty(string name, string value, bool writeError = false) case "language": Language = value; return true; case "light-theme": LightTheme = value.Trim('\'', '"'); return true; case "media-info": MediaInfo = value == "yes"; return true; + case "menu-syntax": MenuSyntax = value; return true; case "minimum-aspect-ratio-audio": MinimumAspectRatioAudio = value.ToFloat(); return true; case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true; case "process-instance": ProcessInstance = value; return true; diff --git a/src/MpvNet/InputConf.cs b/src/MpvNet/InputConf.cs index f86387cd..81f2efd1 100644 --- a/src/MpvNet/InputConf.cs +++ b/src/MpvNet/InputConf.cs @@ -20,7 +20,7 @@ public string Path { } } - public bool HasMenu => Content.Contains("#menu:") || Content.Contains("#! "); + public bool HasMenu => Content.Contains(App.MenuSyntax + " "); public (List menuBindings, List? confBindings) GetBindings() { diff --git a/src/MpvNet/InputHelp.cs b/src/MpvNet/InputHelp.cs index 5843d675..8d6f6fdd 100644 --- a/src/MpvNet/InputHelp.cs +++ b/src/MpvNet/InputHelp.cs @@ -321,18 +321,11 @@ public static List Parse(string content) line = line[(line.IndexOf(" ") + 1)..]; - if (line.Contains("#menu:")) + if (line.Contains(App.MenuSyntax)) { - binding.Comment = line[(line.IndexOf("#menu:") + 6)..].Trim(); + binding.Comment = line[(line.IndexOf(App.MenuSyntax) + App.MenuSyntax.Length)..].Trim(); binding.IsMenu = true; - line = line[..line.IndexOf("#menu:")]; - } - else if (line.Contains("#!")) - { - binding.Comment = line[(line.IndexOf("#!") + 2)..].Trim(); - binding.IsMenu = true; - binding.IsShortMenuSyntax = true; - line = line[..line.IndexOf("#!")]; + line = line[..line.IndexOf(App.MenuSyntax)]; } else if (line.Contains("#custom-menu:")) { @@ -432,10 +425,10 @@ public static List GetBindingsFromContent(string content) value = value[(value.IndexOf(" ") + 1)..]; - if (value.Contains("#menu:")) + if (value.Contains(App.MenuSyntax)) { - binding.Comment = value[(value.IndexOf("#menu:") + 6)..].Trim(); - value = value[..value.IndexOf("#menu:")]; + binding.Comment = value[(value.IndexOf(App.MenuSyntax) + App.MenuSyntax.Length)..].Trim(); + value = value[..value.IndexOf(App.MenuSyntax)]; if (binding.Comment.Contains(';')) binding.Comment = binding.Comment[(binding.Comment.IndexOf(";") + 1)..].Trim(); @@ -482,7 +475,7 @@ public static string GetBindingsForCommand(Dictionary activeBin Binding binding = it.Value; - if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 20) + if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 20 && keys.Count < 2) { keys.Add(binding.Input); charCount += binding.Input.Length;