mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-04-01 05:45:20 +01:00
Merge 61fc2e7b66
into 7c0d269279
This commit is contained in:
commit
3835d74937
1 changed files with 9 additions and 1 deletions
10
src/term.rs
10
src/term.rs
|
@ -247,12 +247,16 @@ pub fn terminal_file_link<'a>(
|
|||
canonical_path: &str,
|
||||
color: Color,
|
||||
) -> io::Result<()> {
|
||||
let encoded_spaces_canonical_path = encode_spaces(canonical_path);
|
||||
|
||||
writer
|
||||
.stdout()
|
||||
.queue(SetForegroundColor(color))?
|
||||
.queue(SetAttribute(Attribute::Underlined))?;
|
||||
writer.stdout().write_all(b"\x1b]8;;file://")?;
|
||||
writer.stdout().write_all(canonical_path.as_bytes())?;
|
||||
writer
|
||||
.stdout()
|
||||
.write_all(encoded_spaces_canonical_path.as_bytes())?;
|
||||
writer.stdout().write_all(b"\x1b\\")?;
|
||||
// Only this part is visible.
|
||||
writer.write_str(path)?;
|
||||
|
@ -265,6 +269,10 @@ pub fn terminal_file_link<'a>(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn encode_spaces(path: &str) -> String {
|
||||
path.replace(" ", "%20")
|
||||
}
|
||||
|
||||
pub fn write_ansi(output: &mut Vec<u8>, command: impl Command) {
|
||||
struct FmtWriter<'a>(&'a mut Vec<u8>);
|
||||
|
||||
|
|
Loading…
Reference in a new issue