Class InputBindingGroups
Reads and rewrites the semicolon-separated binding-group string on a binding.
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
public static class InputBindingGroups
Remarks
A binding's groups member is a list of control-scheme binding-group names
joined with semicolons, for example Keyboard&Mouse;Gamepad. It reads like a
plain string and is not one: a substring test against it answers the wrong question.
Asking whether that binding is in the Keyboard group returns true from a
substring match, because Keyboard occurs inside Keyboard&Mouse,
and renaming a group by substring corrupts every longer name containing it.
Every operation here is token-wise. Comparison is case-insensitive, matching how the rest of the module compares scheme names, and the spelling and order of tokens that were not touched is preserved so an edit produces the smallest possible diff.
Runtime rather than editor, because conflict detection needs the correct answer too.
Fields
SEPARATOR
The character joining group names.
Declaration
public const char SEPARATOR = ';'
Field Value
| Type | Description |
|---|---|
| char |
Methods
Add(string, string)
Adds a group to a group string when it is not already present.
Declaration
public static string Add(string groups, string group)
Parameters
| Type | Name | Description |
|---|---|---|
| string | groups | The raw group string. |
| string | group | The group to add. |
Returns
| Type | Description |
|---|---|
| string | The rewritten string. |
Contains(string, string)
Reports whether a group string contains a group.
Declaration
public static bool Contains(string groups, string group)
Parameters
| Type | Name | Description |
|---|---|---|
| string | groups | The raw group string. |
| string | group | The group name to look for. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Token-wise, so Keyboard is not found inside Keyboard&Mouse.
HaveCommonGroup(string, string)
Reports whether two group strings name at least one group in common.
Declaration
public static bool HaveCommonGroup(string a, string b)
Parameters
| Type | Name | Description |
|---|---|---|
| string | a | The first raw group string. May be |
| string | b | The second raw group string. May be |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Token-wise on both sides, which is the whole point: a binding may sit in several
groups at once, so Keyboard - WASD;Keyboard - IJKL overlaps either of them
alone. A string comparison of the two lists would call that pair different.
Two bindings whose groups have nothing in common cannot both be live while a
control scheme is applied as a binding mask, which is what conflict detection
reads this for. An empty list is not "no groups in common" but "in every scheme",
so it answers false here and the caller treats it as overlapping
everything.
Allocates nothing. It is asked once per candidate pair during a conflict scan, and the substring-per-token approach the neighbouring methods use would put a string on the heap for every token of every binding examined.
Join(IReadOnlyList<string>)
Joins tokens back into a group string.
Declaration
public static string Join(IReadOnlyList<string> tokens)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<string> | tokens | The tokens. |
Returns
| Type | Description |
|---|---|
| string | The joined string, or an empty string when there is nothing to join. |
Parse(string, List<string>)
Splits a group string into its tokens.
Declaration
public static int Parse(string groups, List<string> results)
Parameters
| Type | Name | Description |
|---|---|---|
| string | groups | The raw group string. May be |
| List<string> | results | The list to append to. Cleared first. |
Returns
| Type | Description |
|---|---|
| int | How many tokens were found. |
Remarks
Whitespace around a token is trimmed and empty tokens are dropped, so a stray trailing separator or a hand-typed space does not produce a group named nothing.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when the result list is |
Remove(string, string)
Removes one group from a group string.
Declaration
public static string Remove(string groups, string group)
Parameters
| Type | Name | Description |
|---|---|---|
| string | groups | The raw group string. |
| string | group | The group to remove. |
Returns
| Type | Description |
|---|---|
| string | The rewritten string, empty when the last group was removed. |
Rename(string, string, string)
Renames one group within a group string, leaving every other token alone.
Declaration
public static string Rename(string groups, string oldGroup, string newGroup)
Parameters
| Type | Name | Description |
|---|---|---|
| string | groups | The raw group string. |
| string | oldGroup | The group to rename. |
| string | newGroup | The replacement name. |
Returns
| Type | Description |
|---|---|
| string | The rewritten string. |
Remarks
Returns the input unchanged when the group is not present, so a caller can sweep every binding in a document and only the affected ones differ.