Vixen
dd8b0a81
csharp
public static class KeyMapYaml

The YAML a keymap and a preset are both written in.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

One reader and one writer for the two files, because they are one format. A preset is exactly what a user's keymap is minus the preset name — which is what lets somebody export their bindings and hand them to a colleague as a preset — so a second copy would be a second thing to keep in step with a format whose whole point is that there is one.

⚠ This is where KeyMap stopped, and the stopping place is the layering (#650). The keymap's mechanism — three layers, conflicts, contexts, reservation — is what any application with an accelerator has, and it is Vixen.Ui.Controls's now. Where the bindings are kept between runs is not: this file reaches Vixen.Core.Yaml, which reaches YamlDotNet, and a control library that did the same would put a YAML parser in the dependency closure of every application that has a button. A game that keeps its settings in JSON writes the other half of Overrides and Restore and owes this assembly nothing.

Only what the user did is written: the preset's name, and the bindings they moved themselves — including a command deliberately unbound, which is an empty chord rather than an omission, because omitting it would mean "use the layer underneath" and the user said the opposite.

Methods (4)

  • public static string Write(KeyMap keys)

    The user's overrides and their chosen preset, as YAML.

  • public static void Read(KeyMap keys, string yaml)

    Applies a user keymap over the defaults.

  • public static string Write(KeyMapPreset preset)

    Writes a preset back out in the format ReadPreset reads.

  • public static KeyMapPreset ReadPreset(string name, string yaml)

    Reads a preset from the same YAML a keymap is written in.

Used by (5)

  • CommandTestsVixen.Editor.Ui.Tests
  • EditorApplicationVixen.Editor.App
  • KeyMapPresetTestsVixen.Editor.Ui.Tests
  • KeyMapPresetsVixen.Editor.Ui
  • PlatformKeyTestsVixen.Editor.Ui.Tests