Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Dec 13, 2023
1 parent 7cd5686 commit 49f22a1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ For single files automatically load the entire directory into the playlist.

### General

#### --menu-syntax=\<yes|no\>

Used menu syntax, typically `#menu:` or `#!`. Default: `#menu:`

#### --process-instance=\<value\>

Defines if more then one mpv.net process is allowed.
Expand Down
2 changes: 1 addition & 1 deletion src/MpvNet.Windows/WPF/InputWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions src/MpvNet/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/MpvNet/InputConf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public string Path {
}
}

public bool HasMenu => Content.Contains("#menu:") || Content.Contains("#! ");
public bool HasMenu => Content.Contains(App.MenuSyntax + " ");

public (List<Binding> menuBindings, List<Binding>? confBindings) GetBindings()
{
Expand Down
21 changes: 7 additions & 14 deletions src/MpvNet/InputHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,11 @@ public static List<Binding> 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:"))
{
Expand Down Expand Up @@ -432,10 +425,10 @@ public static List<Binding> 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();
Expand Down Expand Up @@ -482,7 +475,7 @@ public static string GetBindingsForCommand(Dictionary<string, Binding> 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;
Expand Down

0 comments on commit 49f22a1

Please sign in to comment.