Skip to content

Commit

Permalink
Support OSC 7 and OSC 9 ; 9 escape sequences for reporting the workin…
Browse files Browse the repository at this point in the history
…g directory.

Closes #106.
  • Loading branch information
alexrp committed Dec 31, 2023
1 parent 77c2b0d commit fa451ef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/Text/Control/ControlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,21 @@ public ControlBuilder CloseHyperlink()
return Print(OSC).Print("8;;").Print(ST);
}

public ControlBuilder SetWorkingDirectory(Uri uri)
{
Check.Null(uri);
Check.Argument(uri.Scheme == Uri.UriSchemeFile, uri);

return Print(OSC).Print("7").Print(uri).Print(ST);
}

public ControlBuilder SetWorkingDirectory(scoped ReadOnlySpan<char> path)
{
Check.Argument(!path.IsEmpty, path);

return Print(OSC).Print("9;9;").Print("\"").Print(path).Print("\"").Print(ST);
}

public ControlBuilder BeginShellPrompt()
{
return Print(OSC).Print("133;A").Print(ST);
Expand Down
10 changes: 10 additions & 0 deletions src/core/Text/Control/ControlSequences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ public static string OpenHyperlink(Uri uri, scoped ReadOnlySpan<char> id = defau
return Create(static (cb, id, uri) => cb.OpenHyperlink(uri, id), id, uri);
}

public static string SetWorkingDirectory(Uri uri)
{
return Create(static (cb, uri) => cb.SetWorkingDirectory(uri), uri);
}

public static string SetWorkingDirectory(scoped ReadOnlySpan<char> path)
{
return Create(static (cb, path) => cb.SetWorkingDirectory(path), path);
}

public static string CloseHyperlink()
{
return Create(static cb => cb.CloseHyperlink());
Expand Down

0 comments on commit fa451ef

Please sign in to comment.