| 4687 | } |
| 4688 | |
| 4689 | static size_t |
| 4690 | quote_name (char const *name, struct quoting_options const *options, |
| 4691 | int needs_general_quoting, const struct bin_str *color, |
| 4692 | bool allow_pad, struct obstack *stack, char const *absolute_name) |
| 4693 | { |
| 4694 | char smallbuf[BUFSIZ]; |
| 4695 | char *buf = smallbuf; |
| 4696 | size_t len; |
| 4697 | bool pad; |
| 4698 | |
| 4699 | len = quote_name_buf (&buf, sizeof smallbuf, (char *) name, options, |
| 4700 | needs_general_quoting, NULL, &pad); |
| 4701 | |
| 4702 | if (pad && allow_pad) |
| 4703 | dired_outbyte (' '); |
| 4704 | |
| 4705 | if (color) |
| 4706 | print_color_indicator (color); |
| 4707 | |
| 4708 | /* If we're padding, then don't include the outer quotes in |
| 4709 | the --hyperlink, to improve the alignment of those links. */ |
| 4710 | bool skip_quotes = false; |
| 4711 | |
| 4712 | if (absolute_name) |
| 4713 | { |
| 4714 | if (align_variable_outer_quotes && cwd_some_quoted && ! pad) |
| 4715 | { |
| 4716 | skip_quotes = true; |
| 4717 | putchar (*buf); |
| 4718 | } |
| 4719 | char *h = file_escape (hostname, /* path= */ false); |
| 4720 | char *n = file_escape (absolute_name, /* path= */ true); |
| 4721 | /* TODO: It would be good to be able to define parameters |
| 4722 | to give hints to the terminal as how best to render the URI. |
| 4723 | For example since ls is outputting a dense block of URIs |
| 4724 | it would be best to not underline by default, and only |
| 4725 | do so upon hover etc. */ |
| 4726 | printf ("\033]8;;file://%s%s%s\033\\", h, *n == '/' ? "" : "/", n); |
| 4727 | free (h); |
| 4728 | free (n); |
| 4729 | } |
| 4730 | |
| 4731 | if (stack) |
| 4732 | push_current_dired_pos (stack); |
| 4733 | |
| 4734 | fwrite (buf + skip_quotes, 1, len - (skip_quotes * 2), stdout); |
| 4735 | |
| 4736 | dired_pos += len; |
| 4737 | |
| 4738 | if (stack) |
| 4739 | push_current_dired_pos (stack); |
| 4740 | |
| 4741 | if (absolute_name) |
| 4742 | { |
| 4743 | fputs ("\033]8;;\033\\", stdout); |
| 4744 | if (skip_quotes) |
| 4745 | putchar (*(buf + len - 1)); |
| 4746 | } |
no test coverage detected