Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Console.WriteLine(document.Target); // Session
```

You write C# and tmux receives tmux: `Session.Name` goes on the wire as
`session_name`, and `Client.IsControlClient` as `client_control`. The catalog
`session_name`, and `Client.IsControlClient` as `client_control_mode`. The catalog
carries that pair for all twelve queryable fields, and it is closed — a field
outside it throws `UnsupportedQueryExpressionException` rather than falling
back, so an expression that translates is one tmux can answer.
Expand Down
4 changes: 2 additions & 2 deletions src/LibTmux.Generators/FieldCatalogGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public sealed class FieldCatalogGenerator : IIncrementalGenerator
/// <summary>The closed catalog, and where each field lives on its entity.</summary>
/// <remarks>
/// Wire name and property are declared explicitly because the mapping is
/// not systematic (<c>client_control</c> → <c>IsControlClient</c>, and two
/// not systematic (<c>client_control_mode</c> → <c>IsControlClient</c>, and two
/// fields have no property at all).
/// </remarks>
private static readonly (string WireName, string Target, bool Relation, string? Property)[]
Fields =
{
("client_control", "Client", false, "IsControlClient"),
("client_control_mode", "Client", false, "IsControlClient"),
("client_id", "Client", false, null),
("client_name", "Client", false, "Name"),
("pane_command", "Pane", false, null),
Expand Down
2 changes: 1 addition & 1 deletion src/LibTmux.Query.Json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Console.WriteLine($"depth {QueryJsonLimits.V1.MaximumDepth}, nodes {QueryJsonLim

`session_name`, `session_attached`, `session_id`, `session_windows`,
`window_name`, `window_id`, `window_panes`, `pane_id`, `pane_command`,
`client_id`, `client_name`, `client_control`.
`client_id`, `client_name`, `client_control_mode`.

You write these as the properties they are — `Session.Name`,
`Client.IsControlClient` — and the wire carries the tmux spelling.
Expand Down
6 changes: 3 additions & 3 deletions src/LibTmux.Query.Json/libtmux-query-v1.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"target": { "$ref": "#/$defs/target" },
"wireName": {
"enum": [
"client_control",
"client_control_mode",
"client_id",
"client_name",
"pane_command",
Expand Down Expand Up @@ -99,7 +99,7 @@
"properties": {
"target": { "const": "client" },
"wireName": {
"enum": ["client_control", "client_id", "client_name"]
"enum": ["client_control_mode", "client_id", "client_name"]
}
}
}
Expand All @@ -112,7 +112,7 @@
{ "$ref": "#/$defs/field" },
{
"properties": {
"wireName": { "enum": ["client_control", "session_attached"] }
"wireName": { "enum": ["client_control_mode", "session_attached"] }
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/LibTmux/Client.Administration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal Client(
public string? Tty => ReadSnapshot("client_tty");

/// <summary>Gets whether the client speaks tmux's control protocol.</summary>
public bool IsControlClient => ReadSnapshot("client_control") == "1";
public bool IsControlClient => ReadSnapshot("client_control_mode") == "1";

/// <summary>Gets the session the client was attached to when it was read.</summary>
/// <remarks>
Expand Down
2 changes: 1 addition & 1 deletion src/LibTmux/Query/QueryTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private static QueryNode TranslateOperand(
private static FieldNode FieldFor(MemberInfo member)
{
// What tmux calls a field is not a transformation of what C# calls
// it -- Client.IsControlClient is client_control, not
// it -- Client.IsControlClient is client_control_mode, not
// is_control_client. The catalog carries that pairing; an unknown
// type is a caller's own row, whose property names are wire names already.
string wireName =
Expand Down
2 changes: 1 addition & 1 deletion src/LibTmux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ QueryDocument document = QueryExtensions.Translate<Session>(

You write C# and tmux receives tmux. The catalog carries the pair for all
twelve queryable fields — `Session.Name` is `session_name`,
`Client.IsControlClient` is `client_control` — and it is closed:
`Client.IsControlClient` is `client_control_mode` — and it is closed:

| Session | Window | Pane | Client |
|---|---|---|---|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ await Assert.ThrowsAsync<TmuxObjectNotFoundException>(
}
}

[Fact(
Skip = "Requires a Unix process environment.",
SkipType = typeof(UnixTestEnvironment),
SkipUnless = nameof(UnixTestEnvironment.IsUnix))]
public async Task Control_client_reads_back_as_one()
{
await using RawTmuxTestContext raw = await RawTmuxTestContext.StartAsync(
TestContext.Current.CancellationToken);
CancellationToken token = TestContext.Current.CancellationToken;
Server server = await ConnectAsync(raw, token);

await using ControlModeClientScope control = await ControlModeClientScope.StartAsync(
raw,
token);

// The only assertion in the suite a broken read cannot satisfy: every
// other client test attaches a terminal, for which false is the right
// answer whether or not the field resolves.
Client client = await WaitForClientAsync(server, token);
Assert.Equal(control.ClientName, client.Name);
Assert.True(client.IsControlClient);
}

[Fact(
Skip = "Requires a Unix process environment.",
SkipType = typeof(UnixTestEnvironment),
Expand Down
2 changes: 1 addition & 1 deletion tests/LibTmux.UnitTests/Query/QuerySemanticsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void An_entity_translates_through_the_name_tmux_uses_for_the_field()

// The one that a naming rule would never produce.
Assert.Equal(
"client_control",
"client_control_mode",
Field(QueryExtensions.Translate<Client>(client => client.IsControlClient)));
}

Expand Down
Loading