Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hyperlink function to ViritualTerminal TextFormat namespace #758

Merged
merged 5 commits into from
Feb 18, 2021

Conversation

marstr
Copy link
Member

@marstr marstr commented Feb 17, 2021

Adding VirtualTerminal TextFormat helper for making text a clickable link.

Microsoft Reviewers: Open in CodeFlow

@marstr marstr requested a review from a team as a code owner February 17, 2021 22:25
@ghost ghost added the Issue-Feature This is a feature request for the Windows Package Manager client. label Feb 17, 2021
@github-actions
Copy link

Misspellings found, please review:

  • Hyperlink
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"validator valijson valueiterator "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"Hyperlink "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

2 similar comments
@github-actions
Copy link

Misspellings found, please review:

  • Hyperlink
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"validator valijson valueiterator "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"Hyperlink "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

@github-actions
Copy link

Misspellings found, please review:

  • Hyperlink
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"validator valijson valueiterator "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"Hyperlink "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

@yao-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@yao-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@JohnMcPMS
Copy link
Member

I removed the link to #558 as I believe the spirit of that issue is that we should also use the VT support when appropriate.

Let us know if you want tackle that in this PR as well so that we don't merge it before you are ready. If you don't, I'm perfectly happy to accept the assist and use it when we get the chance.

@marstr
Copy link
Member Author

marstr commented Feb 18, 2021

Thanks, @JohnMcPMS. I'd be happy to break this into two PRs. This one to add the helper, and then if I get some time this weekend or over lunch or something I can look into plumbing the rest through.

I should point out, WT seems to automatically make links that are emitted clickable. For instance, project page URLs in the manifest are already navigable. We could make that text explicitly a link, but this helper will be most helpful when text that is not intrinsically a link should navigate somewhere. Maybe well-known license names could point to their text? Any other scenarios that you had in mind?

@JohnMcPMS
Copy link
Member

I hadn't really paid attention to Terminal making links automatically. I think that means that we do actually have all of our current uses covered (at least in Terminal), although we should probably do the right thing and output the VT sequence. We could use it to compress some of our output, such as having show only output one line for License that shows the text and has the LicenseUrl link. That assumes that the terminal we are running in does support these OSC codes, which may not be true. And it would probably mean moving some knowledge of whether VT is enabled up to the business logic layer, which isn't great either.

@JohnMcPMS JohnMcPMS merged commit 53887b3 into microsoft:master Feb 18, 2021
@WSLUser
Copy link

WSLUser commented Feb 19, 2021

that the terminal we are running in does support these OSC codes, which may not be true

I should point out Mintty and ConEmu, the 2 other major terminals on Windows support the OSC 8 sequence and I believe a few others that ported to Windows also support it. Fundamentally we'll need to output the OSC 8 VT sequence in the case of using conhost (which doesn't automatically display hyperlinks unlike Terminal) or a terminal running on top of conhost that doesn't support the VT sequence natively. I think the general idea is that while there are Windows specific APIs for the console for compatibility purposes, new CLI applications and terminals should support using the VT sequences provided by the console or implement the support themselves (if a terminal). It's also possible that one day winget gets run under a .net5 cli on Linux or Mac to install .net applications more easily. Supporting the necessary VT sequences would become more critical at that point.

@marstr
Copy link
Member Author

marstr commented Feb 19, 2021

We should probably update #558 to include this conversation, and the new understanding of the requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature This is a feature request for the Windows Package Manager client.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants